* Linking in mdoc(7) @ 2015-03-08 16:12 ` Kristaps Dzonsons 2015-03-09 6:29 ` Thomas Klausner 2015-03-09 11:09 ` Steffen Nurpmeso 0 siblings, 2 replies; 15+ messages in thread From: Kristaps Dzonsons @ 2015-03-08 16:12 UTC (permalink / raw) To: discuss [-- Attachment #1: Type: text/plain, Size: 3034 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hi folks, Summary: mdoc(7) has linking, but it's very restrictive. You can link to `Sh' and `Ss' macros by using the `Sx' macro. I propose adding another macro, `Ix', that creates an invisible anchor that `Sx' can jump to. Thus, `Sh' and `Ss' work as they always did and `Sx' works as it always did, but we can also jump to arbitrary locations from `Sx' as defined with `Ix', which is otherwise silent. Obviously, this is only useful in -Thtml. On the console, nothing happens at all. I also propose an `Lkx', which is like `Lk' but for inter-page links. This is when the argument to `Sx' should be different from the index name. I've put together a patch that does this. Enclosed. Obviously, this only works in -Thtml mode; otherwise, it's ignored. The story is that texi2mdoc(1) is coming along nicely but I hate hate hate throwing away all the linkage. docbook2mdoc(1) has the same issue. Both of these formats encourage lots of linking. Texinfo, for example, allows you to create index entries along the way, then generate indices later that jump back to these areas. It's handy if you've ever used larger manuals. Moreover, there's also lots of menu generation that jumps forward to chapters (sections), sections (subsections), and so forth. I can do the first two, but I lose anything under a section. Sad face. I started implementing indices in mdoc(7) by remembering the section in which the index was invoked and jumping to it, but most larger manuals have not just sections and subsections, but subsubsections, etc. Moreover, the menus are all but useless, as they all point to the same thing. By having just one extra macro, `Ix', we can get all of that indexing goodness. By having `Lkx' as well, we can fully generalise jumping to those indices. While here, I also updated the ID-generation function to be clearer. Now instead of linking to "foo.htm#x1234124312341" or whatever, it's a much clearer "foo.html#index-NAME" or whatnot. Basically, "index-" followed by the link identifier, with spaces made to underscores and otherwise non-alnums replaced by a two-digit hex code. Thoughts? Best, Kristaps -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJU/HT0AAoJEMT2SUY9XBESgU4QAL038BszrWMlN1HWTi4DX3gC IdxXWCLZUR9LZfcCsFC6er3xzJojB3nJhaZydPjdTlX8QZLzlbdG3Xx2B8fgklwl 1Yw0zGef+a2GQ46oZm3+Sva7ZYIOIiBYhQBjcLlhp5leokCQKRIXCGqnoFgq6Agf Q0o8qMEL7R6YF/ACytQP9XNVlxfd5XighbMfjs4BbbEKtJY8Hos192i7mojCtDXT 6r0BhigARbfgktHiVfSfjLlMHsAjmc6Vf0LIk55pk1zRHKeXUzunRSoAuwKUxLnl b6QMDMpb67VsKCCUhXahBWeHrZuRUfNSkXGo020fKVnzIKCaRzZkONUdjAIP5iDj ImISWoLjX9EqCj2UOOEaO51iRIhP7fqWwEM7yBK9KHb0LhOGly3WdLBQjSN9l8ia 8bW5jr7MvFp5gryx2NV/QOajDXKB9I0G/vHwyZdZkaJEagB8yc9Z8JxbOFxo8LVP FYiSmb2krVok4106QXhQZT0rCOM9a99OyNc2w7lNo5gzzIk0J+3li314pCtboe+M znpWM8TX560yqc5rBr8dyfLfzVJKbDlFCAI1ICGCC2T3tGIzE/02S8qYpQyofdOx HrcxTDD05cMK3zlnWjjyyOPl/aYk6kdOmgDwvHwL99e6OGssWdPwOHTgeMS5XKFN P5swW6zPpVinfRYOj71c =VCLw -----END PGP SIGNATURE----- [-- Attachment #2: linking.patch --] [-- Type: text/plain, Size: 8372 bytes --] ? .DS_Store ? Makefile.local ? cgi.h ? config.h ? config.log ? configure.local ? demandoc ? foo.7 ? foo.7.html ? linking.patch ? machine.diff ? mandoc ? mandoc.dSYM ? tbl.patch ? tbl2.patch Index: html.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/html.c,v retrieving revision 1.185 diff -u -p -r1.185 html.c --- html.c 21 Jan 2015 20:33:25 -0000 1.185 +++ html.c 8 Mar 2015 16:10:21 -0000 @@ -752,7 +752,12 @@ bufcat_id(struct html *h, const char *sr { /* Cf. <http://www.w3.org/TR/html4/types.html#h-6.2>. */ - - while ('\0' != *src) - bufcat_fmt(h, "%.2x", *src++); + for ( ; '\0' != *src; src++) { + if (isalnum((unsigned int)*src)) + bufncat(h, src, 1); + else if (' ' == *src) + bufncat(h, "_", 1); + else + bufcat_fmt(h, "%.2x", *src); + } } Index: mdoc.7 =================================================================== RCS file: /home/cvs/mdocml/mdocml/mdoc.7,v retrieving revision 1.252 diff -u -p -r1.252 mdoc.7 --- mdoc.7 23 Feb 2015 13:31:04 -0000 1.252 +++ mdoc.7 8 Mar 2015 16:10:22 -0000 @@ -440,6 +440,8 @@ in the alphabetical .El .Ss Sections and cross references .Bl -column "Brq, Bro, Brc" description +.It Sx \&Ix Ta index anchor (one line) +.It Sx \&Lkx Ta internal cross reference to an index .It Sx \&Sh Ta section header (one line) .It Sx \&Ss Ta subsection header (one line) .It Sx \&Sx Ta internal cross reference to a section or subsection @@ -510,6 +512,7 @@ in the alphabetical .Bl -column "Brq, Bro, Brc" description .It Sx \&An Ta author name (>0 arguments) .It Sx \&Lk Ta hyperlink: Ar uri Op Ar name +.It Sx \&Lkx Ta index: Ar index Op Ar name .It Sx \&Mt Ta Do mailto Dc hyperlink: Ar address .It Sx \&Cd Ta kernel configuration declaration (>0 arguments) .It Sx \&Ad Ta memory address (>0 arguments) @@ -1854,6 +1857,18 @@ will preserve the semicolon whitespace e .Pp See also .Sx \&Bl . +.Ss \&Ix +Specify an index point with an arbitrary name. +The argument is not printed. +Its syntax is as follows: +.Pp +.Dl Pf \. Ix Ar index +.Pp +An index is an anchor within a document. +It can be accessed with +.Sx \&Lkx +and +.Sx \&Sx . .Ss \&Lb Specify a library. The syntax is as follows: @@ -1905,6 +1920,25 @@ Examples: .Pp See also .Sx \&Mt . +.Ss \&Lkx +Formats an index link. +If invoked without arguments, is the same as +.Sx \&Sx . +Its syntax is as follows: +.Pp +.Dl Pf \. Sx \&Lkx Ar index Op Ar name +.Pp +Examples: +.Bd -literal -offset indent +\&.Ix foobar +Some text here. +\&.Lkx foobar \(dqGo to the above link\(dq +.Ed +.Pp +See also +.Sx \&Ix +and +.Sx \&Sx . .Ss \&Lp Synonym for .Sx \&Pp . Index: mdoc.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/mdoc.c,v retrieving revision 1.238 diff -u -p -r1.238 mdoc.c --- mdoc.c 12 Feb 2015 13:00:52 -0000 1.238 +++ mdoc.c 8 Mar 2015 16:10:22 -0000 @@ -61,10 +61,12 @@ const char *const __mdoc_macronames[MDOC "Fo", "Fc", "Oo", "Oc", "Bk", "Ek", "Bt", "Hf", "Fr", "Ud", "Lb", "Lp", - "Lk", "Mt", "Brq", "Bro", + "Lk", "Lkx", + "Mt", "Brq", "Bro", "Brc", "%C", "Es", "En", "Dx", "%Q", "br", "sp", - "%U", "Ta", "ll", "text", + "%U", "Ta", "ll", "Ix", + "text", }; const char *const __mdoc_argnames[MDOC_ARG_MAX] = { Index: mdoc.h =================================================================== RCS file: /home/cvs/mdocml/mdocml/mdoc.h,v retrieving revision 1.136 diff -u -p -r1.136 mdoc.h --- mdoc.h 12 Feb 2015 12:24:33 -0000 1.136 +++ mdoc.h 8 Mar 2015 16:10:22 -0000 @@ -126,6 +126,7 @@ enum mdoct { MDOC_Lb, MDOC_Lp, MDOC_Lk, + MDOC_Lkx, MDOC_Mt, MDOC_Brq, MDOC_Bro, @@ -140,6 +141,7 @@ enum mdoct { MDOC__U, MDOC_Ta, MDOC_ll, + MDOC_Ix, MDOC_MAX }; Index: mdoc_html.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/mdoc_html.c,v retrieving revision 1.226 diff -u -p -r1.226 mdoc_html.c --- mdoc_html.c 3 Mar 2015 21:11:34 -0000 1.226 +++ mdoc_html.c 8 Mar 2015 16:10:22 -0000 @@ -92,6 +92,7 @@ static int mdoc_ic_pre(MDOC_ARGS); static int mdoc_igndelim_pre(MDOC_ARGS); static int mdoc_in_pre(MDOC_ARGS); static int mdoc_it_pre(MDOC_ARGS); +static int mdoc_ix_pre(MDOC_ARGS); static int mdoc_lb_pre(MDOC_ARGS); static int mdoc_li_pre(MDOC_ARGS); static int mdoc_lk_pre(MDOC_ARGS); @@ -231,6 +232,7 @@ static const struct htmlmdoc mdocs[MDOC_ {mdoc_lb_pre, NULL}, /* Lb */ {mdoc_pp_pre, NULL}, /* Lp */ {mdoc_lk_pre, NULL}, /* Lk */ + {mdoc_lk_pre, NULL}, /* Lkx */ {mdoc_mt_pre, NULL}, /* Mt */ {mdoc_quote_pre, mdoc_quote_post}, /* Brq */ {mdoc_quote_pre, mdoc_quote_post}, /* Bro */ @@ -245,6 +247,7 @@ static const struct htmlmdoc mdocs[MDOC_ {mdoc__x_pre, mdoc__x_post}, /* %U */ {NULL, NULL}, /* Ta */ {mdoc_skip_pre, NULL}, /* ll */ + {mdoc_ix_pre, NULL}, /* Ix */ }; static const char * const lists[LIST_MAX] = { @@ -538,6 +541,25 @@ mdoc_root_pre(MDOC_ARGS) } static int +mdoc_ix_pre(MDOC_ARGS) +{ + struct htmlpair tag; + + bufinit(h); + bufcat(h, "index-"); + + for (n = n->child; n && MDOC_TEXT == n->type; ) { + bufcat_id(h, n->string); + if (NULL != (n = n->next)) + bufcat_id(h, " "); + } + + PAIR_ID_INIT(&tag, h->buf); + print_otag(h, TAG_A, 1, &tag); + return(0); +} + +static int mdoc_sh_pre(MDOC_ARGS) { struct htmlpair tag; @@ -556,7 +578,7 @@ mdoc_sh_pre(MDOC_ARGS) } bufinit(h); - bufcat(h, "x"); + bufcat(h, "index-"); for (n = n->child; n && MDOC_TEXT == n->type; ) { bufcat_id(h, n->string); @@ -586,7 +608,7 @@ mdoc_ss_pre(MDOC_ARGS) return(1); bufinit(h); - bufcat(h, "x"); + bufcat(h, "index-"); for (n = n->child; n && MDOC_TEXT == n->type; ) { bufcat_id(h, n->string); @@ -1104,7 +1126,7 @@ mdoc_sx_pre(MDOC_ARGS) struct htmlpair tag[2]; bufinit(h); - bufcat(h, "#x"); + bufcat(h, "#index-"); for (n = n->child; n; ) { bufcat_id(h, n->string); @@ -1592,14 +1614,23 @@ static int mdoc_lk_pre(MDOC_ARGS) { struct htmlpair tag[2]; + enum mdoct type = n->tok; if (NULL == (n = n->child)) return(0); assert(MDOC_TEXT == n->type); - PAIR_CLASS_INIT(&tag[0], "link-ext"); - PAIR_HREF_INIT(&tag[1], n->string); + if (MDOC_Lkx == type) { + PAIR_CLASS_INIT(&tag[0], "link-int"); + bufinit(h); + bufcat(h, "#index-"); + bufcat_id(h, n->string); + PAIR_HREF_INIT(&tag[1], h->buf); + } else { + PAIR_CLASS_INIT(&tag[0], "link-ext"); + PAIR_HREF_INIT(&tag[1], n->string); + } print_otag(h, TAG_A, 2, tag); Index: mdoc_macro.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/mdoc_macro.c,v retrieving revision 1.183 diff -u -p -r1.183 mdoc_macro.c --- mdoc_macro.c 12 Feb 2015 12:24:33 -0000 1.183 +++ mdoc_macro.c 8 Mar 2015 16:10:23 -0000 @@ -180,6 +180,7 @@ const struct mdoc_macro __mdoc_macros[MD { in_line, 0 }, /* Lb */ { in_line_eoln, 0 }, /* Lp */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Lk */ + { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Lkx */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Mt */ { blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Brq */ { blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | @@ -196,6 +197,7 @@ const struct mdoc_macro __mdoc_macros[MD { in_line_eoln, 0 }, /* %U */ { phrase_ta, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ta */ { in_line_eoln, MDOC_PROLOGUE }, /* ll */ + { in_line_eoln, MDOC_JOIN }, /* Ix */ }; const struct mdoc_macro * const mdoc_macros = __mdoc_macros; Index: mdoc_term.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v retrieving revision 1.313 diff -u -p -r1.313 mdoc_term.c --- mdoc_term.c 6 Mar 2015 15:48:52 -0000 1.313 +++ mdoc_term.c 8 Mar 2015 16:10:23 -0000 @@ -232,6 +232,7 @@ static const struct termact termacts[MDO { NULL, termp_lb_post }, /* Lb */ { termp_sp_pre, NULL }, /* Lp */ { termp_lk_pre, NULL }, /* Lk */ + { termp_lk_pre, NULL }, /* Lkx */ { termp_under_pre, NULL }, /* Mt */ { termp_quote_pre, termp_quote_post }, /* Brq */ { termp_quote_pre, termp_quote_post }, /* Bro */ @@ -246,6 +247,7 @@ static const struct termact termacts[MDO { NULL, termp____post }, /* %U */ { NULL, NULL }, /* Ta */ { termp_ll_pre, NULL }, /* ll */ + { termp_skip_pre, NULL }, /* Ix */ }; ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-08 16:12 ` Linking in mdoc(7) Kristaps Dzonsons @ 2015-03-09 6:29 ` Thomas Klausner 2015-03-09 6:38 ` Anthony J. Bentley 2015-03-09 11:09 ` Steffen Nurpmeso 1 sibling, 1 reply; 15+ messages in thread From: Thomas Klausner @ 2015-03-09 6:29 UTC (permalink / raw) To: discuss On Sun, Mar 08, 2015 at 05:12:36PM +0100, Kristaps Dzonsons wrote: > I've put together a patch that does this. Enclosed. Obviously, this > only works in -Thtml mode; otherwise, it's ignored. Theoretically, this could work (in-page) for PDF too, right? Thomas -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-09 6:29 ` Thomas Klausner @ 2015-03-09 6:38 ` Anthony J. Bentley 2015-03-09 8:46 ` Kristaps Dzonsons 0 siblings, 1 reply; 15+ messages in thread From: Anthony J. Bentley @ 2015-03-09 6:38 UTC (permalink / raw) To: discuss Thomas Klausner writes: > On Sun, Mar 08, 2015 at 05:12:36PM +0100, Kristaps Dzonsons wrote: > > I've put together a patch that does this. Enclosed. Obviously, this > > only works in -Thtml mode; otherwise, it's ignored. > > Theoretically, this could work (in-page) for PDF too, right? Yes, although I don't know of any troff that makes use of PDF's hyperlinking abilities. -- Anthony J. Bentley -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-09 6:38 ` Anthony J. Bentley @ 2015-03-09 8:46 ` Kristaps Dzonsons 2015-03-09 11:12 ` Joerg Sonnenberger 0 siblings, 1 reply; 15+ messages in thread From: Kristaps Dzonsons @ 2015-03-09 8:46 UTC (permalink / raw) To: discuss -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 >>> I've put together a patch that does this. Enclosed. >>> Obviously, this only works in -Thtml mode; otherwise, it's >>> ignored. >> >> Theoretically, this could work (in-page) for PDF too, right? > > Yes, although I don't know of any troff that makes use of PDF's > hyperlinking abilities. Anthony, Thomas, This is certainly possible (both hypertext and in-document, which are basically the same), but requires a fair bit of elbow grease. See Section 6.6 in (e.g.) the PDF1.1 standard for reference, http://acroeng.adobe.com/PDFReference/PDF%20Reference%201.1.pdf There are a few tricky parts to this. First, you need to annotate the text itself as a link. I.e., the clicky part. You'd need to add some scaffolding to indicate that link text is beginning so that the position of opening each word in the link text (term_ps.c:967) would be recorded, then the end (term_ps.c:1024). Then, following each word, you'd create a new annotation object with its rectangle around the text. term_ps.c is incredibly simple in this regard: it outputs word by word. This is why the PS and PDF it generates is so huge. But that makes it easy because words don't straddle lines or font contexts, so the last word is on a horizontal box you can reference. Once the word has been written, as mentioned, you'd then create the annotation object. Here's the next problem: the PDF object database is fixed. Meaning, the number of allocated objects in the PDF stream is the number of fonts plus pages plus a few other things. You'd need to start by re-writing that to allow for arbitrary object counts. The link creation bits are all described in Section 6.6 of the PDf standard. Lastly, you'd need to edit the page-closing logic (term_ps.c:742) to include the table of annotation objects made for the previous page. There's a lot of text in the PDF standard about linking to bits in the PDF file itself as well as URIs. It seems that the link text is the hard part. Best, Kristaps -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJU/V37AAoJEMT2SUY9XBESzhoP/iBFppEsEftMVv5Knqaorgrf I5+WtmLnWHXlLlVdJM3OWoKgfZxuOt6cyuXumYV+aLEc2AdDT5VpoyYD/Fe4lApu HuhZSdYydHvZGcezveTNG8ixMIZ2k1crLcPN0JrL9L9hPueCzlMqouByJIZfNvKG ZWSokWG1A0fO2+WjVK+zBkBCDnjmHfp5930T0TmYemvrN2eKnZGRi7AhnJWAVefV eEstVHj5VGLyCM/GzbbrHqZUKJms1nMtn8s6DZSO5R7J8mrOhavYNP/Ia4CH4T0l 6epP1YHGTOLY59OT/ida907l2xBLGJfRFjMdyYgntozcPqJVOeTzy0itU2SJHgfb NN6y5MejwdN18KdUV2+M/6z8SNIqvr+kw6WE+5OGl5Ws9zShbeRHtCp6svqG1gBq jUl0Am0lkRdct7NexIE7HjRyhnuiAmH3eSxK7ktKfZlKtzfUYuh8ewUGiNjYn/sN ma5D33ONCraLXvc/bsQDaFYD7m1u2Io37ma/0ydiVdJVPGlVx0qfzg44qH+XL8LQ /WPPTIT2LMgjmLnTDzsL71+PJjjHweSaZ0Wizvt9MMOkn23BxZUUyYrQFRzJIufp AUHCgZVCa8hPRuqBOTYydUU/MBlG3wVhSS0RgmklPEq410YnCQ4nTovaXKhlERS0 h6SFvx+dDs3aEG2Q3y2c =gxf9 -----END PGP SIGNATURE----- -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-09 8:46 ` Kristaps Dzonsons @ 2015-03-09 11:12 ` Joerg Sonnenberger 2015-03-09 11:34 ` Kristaps Dzonsons 0 siblings, 1 reply; 15+ messages in thread From: Joerg Sonnenberger @ 2015-03-09 11:12 UTC (permalink / raw) To: discuss On Mon, Mar 09, 2015 at 09:46:51AM +0100, Kristaps Dzonsons wrote: > term_ps.c is incredibly simple in this regard: it outputs word by > word. This is why the PS and PDF it generates is so huge. Trust me, you can do a lot worse. Even Microsoft's SaveAsPDF creates output character by character :) Joerg -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-09 11:12 ` Joerg Sonnenberger @ 2015-03-09 11:34 ` Kristaps Dzonsons 0 siblings, 0 replies; 15+ messages in thread From: Kristaps Dzonsons @ 2015-03-09 11:34 UTC (permalink / raw) To: discuss -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 >> term_ps.c is incredibly simple in this regard: it outputs word >> by word. This is why the PS and PDF it generates is so huge. > > Trust me, you can do a lot worse. Even Microsoft's SaveAsPDF > creates output character by character :) It should be pretty trivial to compress page content, actually. Basically, between the stream/endstream parts, everything can be compressed. I'm not sure if zlib supports PDF's compression schemes, however; or if not, whether it's possible to inline a public domain implementation. If you can come up with one, I can add in the bits for it. Cf. http://acroeng.adobe.com/PDFReference/PDF%20Reference%201.1.pdf, section 4.8, "filters". -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJU/YU5AAoJEMT2SUY9XBEScWIQAKBg7t1j75MY0K2RrHDo47cN BHrFvx49IBJvg1TXMHChWlGhbBXc9uokhY3AIyfr3kdp+00KlCUgLskShzj5Bxja iAblVWki9Rpomz5gfrMGqcTe8lgnxj0tZKk2C2Y0MQQpCHXxd7fjhdiu2kiJFSHr ZcUsWeMzngH7zNRduWod44cfb1kXW80MH//IeZg/L0VT2kHs3OdcRfYLMwKEiyB8 w4/5D7nPwjBCRYfV2auQmN4sqNSN8pcayDfHLDfqXU8Yv4ww/BfgtaNmwcCYj0E2 UTMTgL4bxE4A9UnGZEa3rFjcCvbIdGaxnG1NdLswkI98XW3endE5iBVDnaAGfEXT 7JXDSyniM1oiNUYjLV4Dp+ZkiqcO6Ss5u7FsGXRPlg/50Rw7r4GC+dgr/y/jRXdZ UVkPCnsUuOhmqfCZFtKriwWMQtP0UHOlUXJSa5gFS7zF6G2XCjA4zDZOKscm/61c Aw2JKYMdEVIo8PBWdPQS2cZHJEMf3WuF7rd6vcjkX01LNKOG5FYLlU0V5rt6xp6c ocWNU3SL3koTvZxI3A4diK8E2LQWQq0i9m2wKabkPM5Iy3qwu0ZJmA7/fEnrATDx rOCWozS9vlYKOhNA2VLB3+GXhC7rIvVcUhxGQl17H9C2tfR1IneF1ivGSAia9TwY 5I0WAZHNrYfeS7p5Q6Re =1q3J -----END PGP SIGNATURE----- -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-08 16:12 ` Linking in mdoc(7) Kristaps Dzonsons 2015-03-09 6:29 ` Thomas Klausner @ 2015-03-09 11:09 ` Steffen Nurpmeso 2015-03-09 11:46 ` Ingo Schwarze 1 sibling, 1 reply; 15+ messages in thread From: Steffen Nurpmeso @ 2015-03-09 11:09 UTC (permalink / raw) To: discuss Kristaps Dzonsons <kristaps@bsd.lv> wrote: |Summary: mdoc(7) has linking, but it's very restrictive. You can link |to `Sh' and `Ss' macros by using the `Sx' macro. I propose adding |another macro, `Ix', that creates an invisible anchor that `Sx' can |jump to. Thus, `Sh' and `Ss' work as they always did and `Sx' works |as it always did, but we can also jump to arbitrary locations from |`Sx' as defined with `Ix', which is otherwise silent. Obviously, this |is only useful in -Thtml. On the console, nothing happens at all. I |also propose an `Lkx', which is like `Lk' but for inter-page links. |This is when the argument to `Sx' should be different from the index name. I have proposed something similar back in September 2014 on groff@ and implemented a complete package that can do this and much more with an interface that follows Ingo's suggestions since then. The macro is .Mx, the documentation, troff(1) awk(1) preprocessor, mdoc(1) macro extensions etc., and a patch for less(1) v471 that allows internal (including .Sh and .Ss, but many more) and external anchors (for .Xr) to be followed are available. Use it or leave it. --steffen -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-09 11:09 ` Steffen Nurpmeso @ 2015-03-09 11:46 ` Ingo Schwarze 2015-03-09 12:25 ` Kristaps Dzonsons 2015-03-09 13:11 ` Steffen Nurpmeso 0 siblings, 2 replies; 15+ messages in thread From: Ingo Schwarze @ 2015-03-09 11:46 UTC (permalink / raw) To: discuss Hi Kristaps and Steffen, Steffen Nurpmeso wrote on Mon, Mar 09, 2015 at 12:09:08PM +0100: > Kristaps Dzonsons <kristaps@bsd.lv> wrote: >> Summary: mdoc(7) has linking, but it's very restrictive. You can link >> to `Sh' and `Ss' macros by using the `Sx' macro. I propose adding >> another macro, `Ix', that creates an invisible anchor that `Sx' can >> jump to. Thus, `Sh' and `Ss' work as they always did and `Sx' works >> as it always did, but we can also jump to arbitrary locations from >> `Sx' as defined with `Ix', which is otherwise silent. Obviously, this >> is only useful in -Thtml. On the console, nothing happens at all. I >> also propose an `Lkx', which is like `Lk' but for inter-page links. >> This is when the argument to `Sx' should be different from the index name. My initial reaction is: It is about time to do something like that. However, introducing new macros is not be taken lightly, and the design must not be rushed. Before committing to something specific, we should make sure that it is as powerful as possible, as extensible as possible, and as simple as possible. I'm not yet convinced the proposed design is the most general and simple one. In particular, it isn't obvious to me yet how implicit linking - i.e. internal linking that doesn't require any new markup - integrates into Kristaps concept, and lack of an idea how terminal output can profit is a very serious downside too, give that terminal output is by far the most important output mode. Then again, we have a tradition of having good designs override bad ones soon afterwards (no insult intended :). > I have proposed something similar back in September 2014 on groff@ Exactly what i wanted to say. :-) The thread is here: http://lists.gnu.org/archive/html/groff/2014-09/msg00145.html > and implemented a complete package that can do this and much more > with an interface that follows Ingo's suggestions since then. > The macro is .Mx, the documentation, troff(1) awk(1) preprocessor, > mdoc(1) macro extensions etc., and a patch for less(1) v471 that > allows internal (including .Sh and .Ss, but many more) and > external anchors (for .Xr) to be followed are available. Use it > or leave it. I didn't look at either implementation yet, i focussed on different topics (man(1), eqn(7), UTF-8, messages, afl mopup, pod2mdoc(1)). Even though Steffen rightfully says that i influenced the design he finally chose, and even though that design seemed better to me than what was initially proposed, and even though Steffen was positively enthusiastic about it, i wasn't quite satisfied yet. So my hope is that what we finally arrive at will at least be as powerful as the union of your two implementations and at most as complex as the intersection of both of them, or maybe even better... Kristaps, if you want to commit to minimize risk of loss of work, maybe create a branch for it for now? I'm planning to prepare the 1.13.3 release soon, and this is clearly post-release material. Yours, Ingo -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-09 11:46 ` Ingo Schwarze @ 2015-03-09 12:25 ` Kristaps Dzonsons 2015-03-09 15:36 ` Kristaps Dzonsons 2015-03-09 13:11 ` Steffen Nurpmeso 1 sibling, 1 reply; 15+ messages in thread From: Kristaps Dzonsons @ 2015-03-09 12:25 UTC (permalink / raw) To: discuss -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 >>> Summary: mdoc(7) has linking, but it's very restrictive. You >>> can link to `Sh' and `Ss' macros by using the `Sx' macro. I >>> propose adding another macro, `Ix', that creates an invisible >>> anchor that `Sx' can jump to. Thus, `Sh' and `Ss' work as they >>> always did and `Sx' works as it always did, but we can also >>> jump to arbitrary locations from `Sx' as defined with `Ix', >>> which is otherwise silent. Obviously, this is only useful in >>> -Thtml. On the console, nothing happens at all. I also >>> propose an `Lkx', which is like `Lk' but for inter-page links. >>> This is when the argument to `Sx' should be different from the >>> index name. > > My initial reaction is: It is about time to do something like > that. However, introducing new macros is not be taken lightly, and > the design must not be rushed. Before committing to something > specific, we should make sure that it is as powerful as possible, > as extensible as possible, and as simple as possible. I'm not yet > convinced the proposed design is the most general and simple one. > In particular, it isn't obvious to me yet how implicit linking - > i.e. internal linking that doesn't require any new markup - > integrates into Kristaps concept, and lack of an idea how terminal > output can profit is a very serious downside too, give that > terminal output is by far the most important output mode. > > Then again, we have a tradition of having good designs override bad > ones soon afterwards (no insult intended :). > >> I have proposed something similar back in September 2014 on >> groff@ > > Exactly what i wanted to say. :-) > > The thread is here: > > http://lists.gnu.org/archive/html/groff/2014-09/msg00145.html Ingo, Steffen, Yes, I'd read through this and subsequent messages, including the mdocmx(7) package linked here: https://lists.gnu.org/archive/html/groff/2014-11/msg00281.html `Ix' is very very very simple: it's just an arbitrary place for `Sx' to jump to. The motivation is that we already have the ability to jump *to* locations, but to date we're restricted to `Ss' and `Sh'. My implementation of `Ix' simply adds a <a id=""></a> in -Thtml and does nothing in -Tascii and friends since `Sx' can't "jump" in text mode. Steffen had patched less(1) with magic to recognise anchors, which seems pretty useful. If this becomes a standard idiom, we'd need to patch -Tascii to emit the proper magic for `Sh', `Ss', and `Sx' anyway--adding the `Ix' would be as trivial as it was for -Thtml. Groff can just ignore the `Ix', as it doesn't do anything with `Sx' anyway. The general field of topical indexing, including the mdocmx(7) concept, is much broader. `Ix' doesn't try to solve that at all. `Ix' is just a place for `Sx' to jump to--no more. However, whether it's topical indexing or sub-sub-section linkage, an `Ix' macro will be necessary to define that link destination. That's all it does. Best, Kristaps -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJU/ZFWAAoJEMT2SUY9XBESxdIP/10XNqkAe7oLghOTe9B9HUPU vmytGhsp7LCtuv7FjAQmIfj4UrrCGex1T9HQWxiEkRL2FZERZ799msJng02JJ7hM 6X/ACYuYbTA+NUb3C04Pcer+XxnLJK63cjxc8Koppw7UmWVPjEmAMA2biQHEnnjm 6RzI8mLlD4rwL5Of4eX2DD814MHaADYykvAqJFRwgJRiTLyWbhUPu/c55Is1dJhu bXAvCxfEMnvNgKpiB2d0xLJwZ2hwxVcl8Prq+h3oXsgBdoj6Q9/SiXS6nWCYGNs1 i59Ws/fEyjR13HFFq+dZ41xOYr3whiv3FnjTFnCznF+2WXzTqdI10IGTWbVNM0ok 1X+2LbWROiljbaGd30AHfJRDRLtpfBsLkj0ZfH/VchVedXnxzfZz6zvJ5Jpqo5/p GlM0Ph6/wIWoGEsI8YwtZkfG2hq8rc6B9Zk9L9XACaD+5W0I/NxPCb6rJf11FsGx eGvS1m6DkZA6ahYdSjn77wazmQddbH0Zr81BzP6g/tsO1FaathZvWFaYjcgJ4JJb Cwh13VK1qe2lRv3X6o2amcb6Wn69uFJDDycyRqIGzwMk/5i16nIprD7vU2jPf+8y u35yXa6RzAZwff9iiO4T2zUcGV50wICKyaJJ6zWB33c8f9T413/+mpZx96pCdHjv DT92GdEafvY8yEjaCq/W =ZgWU -----END PGP SIGNATURE----- -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-09 12:25 ` Kristaps Dzonsons @ 2015-03-09 15:36 ` Kristaps Dzonsons 2015-03-10 16:30 ` Steffen Nurpmeso 0 siblings, 1 reply; 15+ messages in thread From: Kristaps Dzonsons @ 2015-03-09 15:36 UTC (permalink / raw) To: discuss -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Replying to myself with an example... Here's an example of `Ix' and `Lkx' at work: http://kristaps.bsd.lv/gsl-test.7.html It's a rendering of the following: % texi2mdoc ~/src/gsl-1.16/doc/gsl-ref.texi | \ mandoc -Thtml >gsl-test.7.html In this you can see the menu items (`Lkx') pointing to arbitrary nodes (`Ix': chapters, sections, subsections, etc.). I use `Lkx' instead of `Sx' because I give the nodes a unique namespace to separate them from the `Sh' heading, which may share the same name. For example, the (x)_n symbol is as follows: http://kristaps.bsd.lv/gsl-test.7.html#index-NodePochhammer_Symbol This is a sub-sub-sub-section. Earlier, I was trying to do this with `Sx', but it would only nest to `Ss' while texinfo goes much deeper. Moreover, the menu item name is sometimes different from the node identifier, which wouldn't work with `Sx'. Something that you don't see in this manual which would be (and now is) possible is topical indexing. I would basically build up a set of `Ix' entries for each index entry (e.g., @cindex), with a unique namespace prefix, e.g., the concept index for "foo bar" would be "CPIndexfoo bar" or something. When Texinfo asks that I print the concept index list, I simply sort the entries and output a list of `Lkx' entries to the respective locations in the page, e.g., `Lkx "CPIndexfoobar" "foo bar"'. These will jump back smartly to the indices. P.S., be gentle on the GSL page. It's one of the heavier users of texinfo semantics, so there are still glitches, e.g., the function declarations are un-pretty. -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJU/b4EAAoJEMT2SUY9XBESeOEP/0BTo/De+p13B4kpjGLI4PG+ n8ulB0qlvAvbdFDKUFcPEt1yKU8jCLorKS7R9X0rTHlBfdEDMZ+P+Krp15SHea0n NgbI+nvje4x6r0RRmswwM3pqajiPsNWSMTOQ24TNVMwmNHgIqtuYkSZWIfleGnws bmeN/32qlM22YjTld7qO2B893gPd/rXv9LrGlqFezJ14co6nmeVRJxsV0dtP5pBY xPC8PKw6E+LZhYpykhMN7fPoSDbjA+OPj0mrUugUZVDzPJYNG0s1GEFqQniATqRU Dtnw7MSoz4gqi5LvJNe5I3JNskKCKMm8FOwHySRV+CYLQ+WjfytTptF0w5DnRKSw d5JKhxM4+eCxAOKKxrFQcXNdkHLBrMg+ZMdlSTbzqAPzmqh+bnt1DYqhjNezAqva ne1PqdlV70I4E8kScX/EG3otbaKFZH4fxjkyoi3l6GdxnX+0CN2rk0FBlJT4Hxzz wHery7gqsPY6yww/X1E0ba8hEfcUVQA/1YW2VzwNeG1EyTLmwJi6j0GIPjsO1NTl 1UzviYALFCmndhoQcJWLqDsFz5hBbCSgm7slyVRLAMUZIpYboZMqXXpt8H9d+qLc TTtv2kJCCrqgXNt3gh6xJuo5yo/0Gbsapkg41/O5ZOPa+PnrL7dm+g+gMTqjduOR iQIeqzolgQOjXtGoDoiX =NAB2 -----END PGP SIGNATURE----- -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-09 15:36 ` Kristaps Dzonsons @ 2015-03-10 16:30 ` Steffen Nurpmeso 2015-03-11 8:05 ` Kristaps Dzonsons 0 siblings, 1 reply; 15+ messages in thread From: Steffen Nurpmeso @ 2015-03-10 16:30 UTC (permalink / raw) To: discuss To the initial message and from the troff(1) / mdoc(7) on tty output side, to the best of my understanding, Kristaps Dzonsons <kristaps@bsd.lv> wrote: |Summary: mdoc(7) has linking, but it's very restrictive. You can link |to `Sh' and `Ss' macros by using the `Sx' macro. I propose adding |another macro, `Ix', that creates an invisible anchor that `Sx' can unfortunately this is not possible, which caused me a lot of pain when coding mdocmx(7) -- you cannot create an anchor "from nothing". I mean surely you can easily do so for mdocml, but for troff(1) tty output through mdoc(7) you must be aware of the recursive and indirect (via "pointer-to-function" calls) approach that mdoc(7) has taken. For example in (and if i recall this correctly) .Bl -tag -width ".It Fn _atexit" .Mx .It Va bla the evaluation order won't work if the .Mx would generate the invisible anchor, because the "Fn _atexit" is lazily evaluated; the only possibility was -- and is. -- a stack that was popped during actual evaluation of .Va. Things are actually worse because you currently can perform the injection only once the macro to be anchored/linked is left, a problem with e.g. long function prototypes that wrap around lines, in which case scrolling back will in the worst case leave you with only the closing semicolon... There is no hope to improve this except by completely rewriting mdoc(7) macros the very same way i have posted to groff@ (instead of dumping data on the fly during recursion implement a new ".doc-output-node TYPE [DATA]" so that a complete, flat structure is available that can be iterated upon and be modified on-the-fly before that structure is dumped. Shall i made it that far anchors/links can be generated at the front for TTY output / anchors/links can be enclosed in device-dependend output (<a name|href=X>Y</a>, PDF..). | Kristaps Dzonsons <kristaps@bsd.lv> wrote: |Replying to myself with an example... | |Here's an example of `Ix' and `Lkx' at work: | |http://kristaps.bsd.lv/gsl-test.7.html | |It's a rendering of the following: | |% texi2mdoc ~/src/gsl-1.16/doc/gsl-ref.texi | \ | mandoc -Thtml >gsl-test.7.html | |In this you can see the menu items (`Lkx') pointing to arbitrary nodes |(`Ix': chapters, sections, subsections, etc.). I use `Lkx' instead of |`Sx' because I give the nodes a unique namespace to separate them from |the `Sh' heading, which may share the same name. | |For example, the (x)_n symbol is as follows: | |http://kristaps.bsd.lv/gsl-test.7.html#index-NodePochhammer_Symbol | |This is a sub-sub-sub-section. Earlier, I was trying to do this with |`Sx', but it would only nest to `Ss' while texinfo goes much deeper. |Moreover, the menu item name is sometimes different from the node |identifier, which wouldn't work with `Sx'. The .Mx (or call it .Ix if you want to) can surely be extended by more modes, e.g., .Mx -anchor whatever .Mx -link whatever Or there could be a second new command so that mdoc(7) would gain a .Ix / .Lx pair. And even though i think that mdocml will become increasingly popular i want to speak for troff(1) and remain compatibility, and then i mean that on the functional level. Realistically a texi2mdoc(1) subsubsection would become .Pp .Mx -anchor-start whatever .Em subsubsection with nothing that creates anchors or links .Mx -anchor-end .Pp blabla .Mx -link-start whatever more blabla that doesn't create anchors or links .Mx -link-end The problem surely being that something like .Mx -anchor whatever TEXT .Mx -link whatever TEXT will produce no output unless there is compatibility available. Well if it is then having .S[34567] would most likely be the better option. Freely definable anchors and the possibility to link them i would really like to see myself, but to make that possible in troff(1) / mdoc(7) *today* both must enwrap something. I.e., Mr. Bob Beck would say "where is the meat?". We cannot simply attach to some C structure tree node and enwrap it. Maybe (maybe!) .Pp .Mx -anchor Em .Em subsubsection with nothing that creates anchors or links Whereas mdocmx(1) (mdocmx(7) not yet) takes care for duplicates regarding .Ar,.Cm etc. it doesn't yet for .Sh and .Ss. Effectively i think the first one defined will always be matched when creating links via .Sx. They do share a namespace in the end. So all i'm saying is that i'm willing to spend time on mdocmx(7) (or mdocix(7); i didn't use .Ix because someone already uses it; ditto .Lx...). I'd like to see that improved and be in sync across projects. My S-roff(1) will include the pimped mdoc(7), whatever its name will be. I plan to release S-nail v14.8 at the end of March or somewhen after Easter, and work on S-roff for several months rather exclusively. Ciao, --steffen -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-10 16:30 ` Steffen Nurpmeso @ 2015-03-11 8:05 ` Kristaps Dzonsons 2015-03-11 8:15 ` Anthony J. Bentley 2015-03-11 10:07 ` Steffen Nurpmeso 0 siblings, 2 replies; 15+ messages in thread From: Kristaps Dzonsons @ 2015-03-11 8:05 UTC (permalink / raw) To: discuss -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Steffen, I don't understand these problems. In mandoc(1), the previously enclosed patch completely implements the `Ix' functionality, both in terms of `Sx' and the nascent (badly named?) `Lkx'. It works. I've been using it happily to build index tables and chapter references that jump to functions, etc., etc. As for groff, can't it just (via doc.tmac) throw away the `Ix' arguments and that's that? And if we want an `Lkx' (which I strongly advise for arbitrary link names), it can be a duplicate of `Lk'. grohtml can't even link `Sx' and `Sh': it just italices the arguments to the former! (This may have changed in recent groff.) So if it ignores `Ix' and continues in doing what it already does with `Sx', what exactly is the loss? Best, Kristaps -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJU//dAAAoJEMT2SUY9XBESJ/IP/i8FgiUB4BI+Z2KaDTM9ROww 3VHizu22FmpfLuzzjlj5QvyzRqT8H6K/aMHwzI7n20qMDekneUkNpLmkb29FHrC1 vJl57on9wXJGeQMfSSzBjpQPNGoud5Ag0e5eK9qcrvOufANB2lCi9KOKhqt0Pjk8 +dg+so3DXCf40XTSzxWgr5HzMFWFZgONZuhHfDfUMwhwjqZPx8O9w1suNfvCkcAS czFe1j1mssBC7G2KBWmZI4J6yIlzC3rGZcEk5sxzlSsnuxeymcuLYXiZ8QV0qQAm UslqF74W5d84oU5XHfN1NZUZjrEbbC93DvM/m92KYD09E3Zr9p8qR1nTHN6mTKda ieO415F98EvCIC3AwukgaxzgC09g+B95nhVCV2NZhTRYO2vr7XXhUPM80ZRzLumI TU8c6KR5gAk7ou17xj8kdFugVjxC8uu8kRzwmgqZw2Oog7ZRJAH7UV+9DWwrX6Lx XMKDagwhGpv16I+wl97548APCdjj2XpanGNrnhZV3jKDZamQNCOaXfvGOA+86Zdh bvlw5LqeST5oTiVzFbuLRmxiFu7BmBNrfhYNNAQPqgI+s0JKToFjgPUV6LCYwg/y rUJxNu/bB8QOxvQ8D0/Qcw2M2JmQRxe6YCVoS8JjurDV6aMpXeNyLWYjjf5StIaA C4bDmDAuaB2iuWTSNg2/ =BW6G -----END PGP SIGNATURE----- -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-11 8:05 ` Kristaps Dzonsons @ 2015-03-11 8:15 ` Anthony J. Bentley 2015-03-11 10:07 ` Steffen Nurpmeso 1 sibling, 0 replies; 15+ messages in thread From: Anthony J. Bentley @ 2015-03-11 8:15 UTC (permalink / raw) To: discuss Hi Kristaps, Kristaps Dzonsons writes: > grohtml can't even link `Sx' and `Sh': it just italices the arguments > to the former! (This may have changed in recent groff.) FYI, it hasn't. -- Anthony J. Bentley -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-11 8:05 ` Kristaps Dzonsons 2015-03-11 8:15 ` Anthony J. Bentley @ 2015-03-11 10:07 ` Steffen Nurpmeso 1 sibling, 0 replies; 15+ messages in thread From: Steffen Nurpmeso @ 2015-03-11 10:07 UTC (permalink / raw) To: discuss Hello Kristaps, Kristaps Dzonsons <kristaps@bsd.lv> wrote: |Steffen, | |I don't understand these problems. In mandoc(1), the previously |enclosed patch completely implements the `Ix' functionality, both in |terms of `Sx' and the nascent (badly named?) `Lkx'. It works. I've |been using it happily to build index tables and chapter references |that jump to functions, etc., etc. | |As for groff, can't it just (via doc.tmac) throw away the `Ix' |arguments and that's that? And if we want an `Lkx' (which I strongly Of course. It really seems that unknown requests are (by default even silently) ignored, luckily. |advise for arbitrary link names), it can be a duplicate of `Lk'. |grohtml can't even link `Sx' and `Sh': it just italices the arguments |to the former! (This may have changed in recent groff.) So if it |ignores `Ix' and continues in doing what it already does with `Sx', |what exactly is the loss? troff(1) based mdoc(7) compatibility. At a minimum until i completely rewrite the mdoc(7) macros as posted (assuming that noone else will spend the time necessary for that -- and has anyone ever thought about cross-financing a GSoC student for such a basic thing like manual page usability?). If it can possibly work then depends on how you define the semantics, anchors that cannot be ".ds"'d and link content that cannot be ".if '''"d will never work. Of course ;) And do you really plan to support these new commands only for HTML and PDF output? What a pity! Better interactivity on the TTY is what really strives me. (I'm not an emacs user..) Ciao, --steffen -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Linking in mdoc(7) 2015-03-09 11:46 ` Ingo Schwarze 2015-03-09 12:25 ` Kristaps Dzonsons @ 2015-03-09 13:11 ` Steffen Nurpmeso 1 sibling, 0 replies; 15+ messages in thread From: Steffen Nurpmeso @ 2015-03-09 13:11 UTC (permalink / raw) To: discuss [-- Attachment #1: Type: text/plain, Size: 4835 bytes --] Hello Kristaps, Jörg and Ingo, Ingo Schwarze <schwarze@usta.de> wrote: |Steffen Nurpmeso wrote on Mon, Mar 09, 2015 at 12:09:08PM +0100: |> Kristaps Dzonsons <kristaps@bsd.lv> wrote: |>> Summary: mdoc(7) has linking, but it's very restrictive. You can link |Then again, we have a tradition of having good designs override |bad ones soon afterwards (no insult intended :). | |> I have proposed something similar back in September 2014 on groff@ | |Exactly what i wanted to say. :-) | |The thread is here: | | http://lists.gnu.org/archive/html/groff/2014-09/msg00145.html | |> and implemented a complete package that can do this and much more |> with an interface that follows Ingo's suggestions since then. |> The macro is .Mx, the documentation, troff(1) awk(1) preprocessor, |> mdoc(1) macro extensions etc., and a patch for less(1) v471 that |> allows internal (including .Sh and .Ss, but many more) and |> external anchors (for .Xr) to be followed are available. Use it |> or leave it. |Even though Steffen rightfully says that i influenced the design |he finally chose, and even though that design seemed better to me |than what was initially proposed, and even though Steffen was |positively enthusiastic about it, i wasn't quite satisfied yet. | |So my hope is that what we finally arrive at will at least be as |powerful as the union of your two implementations and at most as |complex as the intersection of both of them, or maybe even better... That would be my hope, too -- moving the current state forward. And maybe my final words were a bit too strong too, honestly at least they were. :-) I'm still enthusiastic since it is a real improvement to work with these more interactive manuals. And i surely would like to know any criticism you might have in order to be able to address it, shall that be possible from the troff(1) side of the road. Please let me attach the latest version of mdocmx.7 (from January 19th) to make sure we talk about the same state of affairs. I want to point out that this is a mature and usable system, regarding the entire mdocmx(1) (awk(1) preprocessor) / mdoc(7) / grotty(1) / less(1) pipeline. Let me elaborate a bit on what i personally miss from that onwards: (1) Better performance: the last commit i made to mdocmx(7) (2015-02-05) was a massive performance improvement (excerpt): Before: ?0[]$ time (mdocmx.sh nail.1| groff -Tutf8 -mdoc -dmx-toc-force=1 -dmx-debug=1 >/dev/null) 0m1.25s real 0m1.59s user 0m0.06s system ?0[]$ time (export MDOCMX_ENABLE=1; mdocmx.sh nail.1| groff -Tutf8 -mdoc -dmx-toc-force=1 -dmx-debug=1 >MAN.before) 0m7.36s real 0m7.73s user 0m0.08s system After: ?0[]$ time (mdocmx.sh nail.1| groff -Tutf8 -mdoc -dmx-toc-force=1 -dmx-debug=1 >/dev/null) 0m1.19s real 0m1.59s user 0m0.06s system ?0[]$ time (export MDOCMX_ENABLE=1; mdocmx.sh nail.1| groff -Tutf8 -mdoc -dmx-toc-force=1 -dmx-debug=1 >MAN.old) 0m2.56s real 0m2.97s user 0m0.07s system After, with an experimental .hash troff(1) builtin: ?0[]$ time (export MDOCMX_ENABLE=1; mdocmx.sh nail.1| groff -Tutf8 -mdoc -dmx-toc-force=1 -dmx-debug=1 >MAN.new) 0m2.19s real 0m2.61s user 0m0.07s system For comparison, here is plain mdocml(1): ?0[]$ time (mdocmx.sh nail.1|mandoc > /dev/null) 0m0.26s real 0m0.19s user 0m0.07s system This is extreme but nail.1 results in ~4500 lines of rendered text, the difference for NetBSD's bus_dma.9 for example is much much smaller. Shall mdocml(1) go that route i wouldn't even expect a measurable impact, the problem with troff(1) is that we cannot have hashmaps or trees from within macros. (And of course the way mdoc(7) is implemented is a problem; that can be improved, i would know how, which would then also allow referenced HTML and PDF etc. output.) (2) An index facility is missing. I still find myself using less(1)'s search command in order to get myself going in manuals. It would be better if beside automatic TOC creation there would be automatic index creation -- this is possible with mdocmx(7) and it will happen: like this you scroll to e.g. the end of the manual to the index and then can jump directly to the desired anchor. (3) Due to the way mdoc(7) is implemented the reference anchors can only be suffixes, not prefixes as is known from lynx(1). I think it wouldn't bother anyone if mdocml(1) would start generating anchors for less(1) as prefixes right from the start, over time i will adjust the mdoc(7) macros (or at least plan to do so) so they can follow. --steffen [-- Attachment #2: Original message content --] [-- Type: message/rfc822, Size: 5528 bytes --] From: Ingo Schwarze <schwarze@usta.de> To: discuss@mdocml.bsd.lv Subject: Re: Linking in mdoc(7) Date: Mon, 9 Mar 2015 12:46:48 +0100 Message-ID: <20150309114648.GA18431@athene.usta.de> Hi Kristaps and Steffen, Steffen Nurpmeso wrote on Mon, Mar 09, 2015 at 12:09:08PM +0100: > Kristaps Dzonsons <kristaps@bsd.lv> wrote: >> Summary: mdoc(7) has linking, but it's very restrictive. You can link >> to `Sh' and `Ss' macros by using the `Sx' macro. I propose adding >> another macro, `Ix', that creates an invisible anchor that `Sx' can >> jump to. Thus, `Sh' and `Ss' work as they always did and `Sx' works >> as it always did, but we can also jump to arbitrary locations from >> `Sx' as defined with `Ix', which is otherwise silent. Obviously, this >> is only useful in -Thtml. On the console, nothing happens at all. I >> also propose an `Lkx', which is like `Lk' but for inter-page links. >> This is when the argument to `Sx' should be different from the index name. My initial reaction is: It is about time to do something like that. However, introducing new macros is not be taken lightly, and the design must not be rushed. Before committing to something specific, we should make sure that it is as powerful as possible, as extensible as possible, and as simple as possible. I'm not yet convinced the proposed design is the most general and simple one. In particular, it isn't obvious to me yet how implicit linking - i.e. internal linking that doesn't require any new markup - integrates into Kristaps concept, and lack of an idea how terminal output can profit is a very serious downside too, give that terminal output is by far the most important output mode. Then again, we have a tradition of having good designs override bad ones soon afterwards (no insult intended :). > I have proposed something similar back in September 2014 on groff@ Exactly what i wanted to say. :-) The thread is here: http://lists.gnu.org/archive/html/groff/2014-09/msg00145.html > and implemented a complete package that can do this and much more > with an interface that follows Ingo's suggestions since then. > The macro is .Mx, the documentation, troff(1) awk(1) preprocessor, > mdoc(1) macro extensions etc., and a patch for less(1) v471 that > allows internal (including .Sh and .Ss, but many more) and > external anchors (for .Xr) to be followed are available. Use it > or leave it. I didn't look at either implementation yet, i focussed on different topics (man(1), eqn(7), UTF-8, messages, afl mopup, pod2mdoc(1)). Even though Steffen rightfully says that i influenced the design he finally chose, and even though that design seemed better to me than what was initially proposed, and even though Steffen was positively enthusiastic about it, i wasn't quite satisfied yet. So my hope is that what we finally arrive at will at least be as powerful as the union of your two implementations and at most as complex as the intersection of both of them, or maybe even better... Kristaps, if you want to commit to minimize risk of loss of work, maybe create a branch for it for now? I'm planning to prepare the 1.13.3 release soon, and this is clearly post-release material. Yours, Ingo -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv [-- Attachment #3: mdocmx.7 --] [-- Type: text/plain, Size: 11476 bytes --] '\" m -- preprocess: mdocmx(1) .\"@ mdocmx.7 - mdocmx(7) reference manual. .\"@ mdocmx(7) extends the mdoc(7) semantic markup language by references, .\"@ allowing mdoc(7) to create anchors and table of contents. .\" .\" Written 2014 - 2015 by Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>. .\" Public Domain . .Dd January 19, 2015 .Dt MDOCMX 7 .Os .Mx -enable . . .Sh NAME . .Nm .Mx .Nd Reference extension for the mdoc semantic markup language . . .Sh SYNOPSIS . .Nm .Fl enable .Op Ar output-formats .Pp .Nm .Fl disable .Pp .Nm .Nm .Ar macro .Nm .Ar macro Ar key .Pp .Bk .Nm .Fl toc .Op Ar output-formats .Op Fl tree Ar output-formats .Ek . . .Mx -toc -tree html xhtml pdf ps . . .Sh DESCRIPTION . .Xr mdocmx 7 introduces referenceable index anchors to the .Xr mdoc 7 semantic markup language that is used for .Ux manual pages by defining a single new multiplexer command: .Nm . A precondition for enabling this extension is to set the environment variable .Ev MDOCMX_ENABLE to a non-empty value (the value is necessary to make the variable perceivable on the macro level, i.e., to overcome a deficiency of the .Xr troff 1 command set). . .Pp The .Xr mdocmx 7 reference extension augments the standard .Xr mdoc 7 document prologue \(en .Ic \&Dd , .Ic \&Dt and .Ic \&Os \(en with the new command .Nm .Fl enable . It can be restricted to specific output formats by adding those .Xr troff 1 output devices for which expansion is desired as further arguments to .Fl enable ; for convenience all typewriter-like devices can be addressed via .Ar tty . It is not an error to specify a device for which no special .Xr mdocmx 7 support is available, but such requests are simply ignored. . .Pp Because macros driven by single-pass troff implementations cannot create forward references .Xr mdoc 7 documents which use this extension need to be preprocessed with the .Xr mdocmx 1 preprocessor, which is a regular part of .Xr mdocmx 7 and implemented in portable .Xr sh 1 and .Xr awk 1 . Specialized manual formatters and macros driven by multi-pass troff interpreters may not require a preprocessor to support this extension. It is also possible to preprocess the manual once and distribute the resulting document \(en refer to the .Sx COMPATIBILITY section for more on that. . .Pp Sometimes it may be desirable to actively suppress any processing of the .Xr mdocmx 7 reference extension: this can either be accomplished by using .Nm with the .Fl disable argument or by defining the string .Ql Dv mx-disable , as in . .Pp .Dl MDOCMX_ENABLE=anyval; export MDOCMX_ENABLE .Dl < xy.z mdocmx.sh | troff -Tutf8 -mdoc -a -dmx-disable=1 . .Ss Creating referenceable anchors . After the extension was .Fl enable Ns d in the document prologue the third group of .Nm usage forms can be used to enqueue index anchor requests. These requests form a stack which will be consumed (popped) by the later occurrence of a (corresponding) .Xr mdoc 7 .Ar macro which supports referenceable index entries. The indices are managed with distinct namespaces for each supported .Ar macro , meaning that, e.g., .Ql .Mx \&Ic sendmail and .Ql .Mx \&Va sendmail will create distinct index anchors. . .Pp Using the plain macro .Nm without arguments creates a stack entry for which both, the name of the .Ar macro as well as the .Ar key will be taken from the document content. .Nm .Ar macro will create a stack entry that will be consumed by the next occurrence of .Ar macro only, then taking the .Ar key off the document content, whereas .Nm .Ar macro Ar key creates a stack entry that also has its .Ar key defined, and which will be consumed once an exactly matching macro / key pair is seen in the document only. (The .Sx EXAMPLES section gives a use case for this form.) . .Pp Using the .Xr mdocmx 1 preprocessor will also create referenceable anchors for the .Xr mdoc 7 section header commands .Ic .Sh and .Ic .Ss automatically, so that a .Xr mdoc 7 macro package which supports the .Xr mdocmx 7 extension will be enabled to actually create references with the .Ic .Sx command, and, dependent on the output device, cross-references defined via the command .Ic .Xr will also be backed with functionality. The following macros gain support for referenceable anchors via .Nm : . .Pp .Bl -tag -compact -width ".It Ic ._B" .Mx .It Ic .Ar Command argument. .Mx .It Ic .Cm Command modifier. .Mx .It Ic .Dv Defined variable or preprocessor constant. .Mx .It Ic .Er Error constant. .Mx .It Ic .Ev Environment variable. .Mx .It Ic .Fl Command line option (flag). .Mx .It Ic .Fn Function name. .Mx .It Ic .Fo Function name (in function block syntax). This is mapped to .Ic .Fn , .Ic .Fo has no index by itself. .Mx .It Ic .Ic Internal or interactive command. .Mx .It Ic .In An .Ql include file for, e.g., the C programming language. .Mx .It Ic .Pa File system path. .Mx .It Ic .Va Variable name. .Mx .It Ic .Vt Variable type, type reference. .El . .Ss Creating table of contents . The final usage form of the .Xr mdocmx 7 reference extension allows the creation of a document table of content, which is of special interest when converting a .Xr mdoc 7 document into formats such as HTML, XHTML or PDF. To restrict the creation of the table of contents to special output formats, add the names of those .Xr troff 1 output devices for which expansion is desired as further arguments to .Fl toc ; for convenience all typewriter-like devices can be addressed via .Ar tty . . .Pp By default only .Ic .Sh section headers are a vivid part of the TOC; in order to include .Ic .Ss subsections also add a .Fl tree argument. Note that if .Fl tree is used in conjunction with output-device restrictions it will only affect those devices that appear later on the line. . .Pp In the first of the following examples a table of content will be generated for PDF and typewriter-like devices. In the second example a tree of contents will instead be generated for the output formats PDF and HTML, whereas typewriter-like devices will see a flat table of contents with only section headers. . .Pp .Dl .Mx -toc pdf tty .Dl .Mx -toc tty -tree html pdf . .Ss Strings that affect mdocmx . .Sy Note that due to deficiencies in some implementations of .Xr troff 1 strings given on the command line (via option .Fl d Ns ) have to be given an argument in order to be perceived on the macro level; see the example given above in the section .Sx DESCRIPTION . . .Bl -tag -width ".It Dv _docmx-_oc-_merged" .Mx .It Dv mx-debug If defined .Xr mdocmx 7 macros will offer some verbosity. In addition not only references will produce visual output, but also anchors. . .Mx .It Dv mx-disable Has the same effect as .Ql .Mx -disable . . .Mx .It Dv mx-toc-emerged Normally .Fl compact display is used for the table of contents, but when this string is set an emerged display is used for the first level that lists the headings. . .Mx .It Dv mx-toc-force Can be used to enforce creation of a table of content even if the documents .Fl toc configuration wouldn't create one for the targeted output device. . .Mx .It Dv mx-toc-name If defined its content is used as the headline of the table of contents, which can be used for, e.g., localization purposes. The default is .Dq TABLE OF CONTENTS . . .Mx .It Dv mx-toc-numbered If defined the first level of the table of contents will be numbered. .El . . .Sh IMPLEMENTATION NOTES . The .Nm request cannot share a line with other macros, neither in the document prologue nor in its content. Whereas that is mostly owed to the necessity of ensuring (backward) compatibility with environments that don't support .Xr mdocmx 7 , it also simplified implementation of the preprocessor. . .Ss Internal extended synopsis . In addition to those usage forms that have been described above the .Ic .Mx multiplexer command also understands further flags and arguments which are of possible interest for formatter and macro implementors. These further flags and arguments are only generated by the .Xr mdocmx 1 preprocessor and are solely ment to communicate the preprocessed state of the document to the actual consumers. . .Pp For one a .Fl preprocessed flag is appended to the single .Fl enable command in the document prologue. And then an additional .Fl anchor-spass form is introduced, which takes two or three arguments \(en the macro (name of the command) for which this defines an anchor as well as its key, possibly followed by a numeric argument that describes the relationship in between section headings: for .Ic .Sh commands it defines a running one-based index count of section headers, for .Ic .Ss commands it instead specifies the index of the section header they belong to, therefore creating the possibility to generate TOCs. . . .Sh ENVIRONMENT . Only if the environment variable .Mx .Ev MDOCMX_ENABLE is set to a non-empty value will the .Xr mdocmx 7 macros generate the necessary information that the chosen output device of .Xr troff 1 can, sufficient support provided, use to generate table of contents, internal and external references. . . .Sh EXAMPLES . A complete, but completely fanciful .Xr mdoc 7 document that uses the .Xr mdocmx 7 extension would for example be: . .Bd -literal -offset indent \&.Dd January 19, 2015 \&.Dt MDOCMX-EXAMPLE 7 \&.Os \&.Mx -enable tty \&. \&.Sh NAME \&.Nm mdocmx-example \&.Nd An example for the mdocmx mdoc reference extension \&.Mx -toc \&. \&.Sh DESCRIPTION Sors salutis et virtutis michi nunc contraria. \&. \&.Bl -tag -width ".It Fn _a_e_i_" \&.Mx \&.It Ic .Ar This will create an anchor for a macro `Ic', key `.Ar'. \&.Mx \&.It Ic .Cm Anchor for `Ic', key `.Cm'. \&.Mx \&.It Ic .Dv And an anchor for `Ic', key `.Dv'. \&.Mx Ic \&.Mx Ic "final anchor" \&.Mx Fn _atexit \&.It Fn exit No anchor here. \&.It Fn at_quick_exit , Fn _atexit Not for the first, but for the second `Fn' there will be an anchor with the key `_atexit'. \&.It Ic "no anchor here" \&.It Ic "final anchor" Pops the pushed `Ic' / `final anchor' macro / key pair. \&.It Ic ciao Pops the `Ic' and assigns the key `Ciao'. \&.El .Ed . . .Sh COMPATIBILITY . Using the .Xr mdocmx 7 extension in .Xr mdoc 7 manual pages should not cause any compatibility problems in sofar as all tested environments silently ignore the unknown commands by default. Because of this, and due to the nature of this extension, an interesting, backward as well as forward compatible approach to use .Xr mdocmx 7 may be to preprocess manuals with .Xr mdocmx 1 on developer machines and instead distribute the resulting documents. . . .Sh SEE ALSO . .Xr awk 1 , .Xr mandoc 1 , .Xr mdocmx 1 , .Xr sh 1 , .Xr troff 1 , .Xr mdoc 7 . . .Sh HISTORY . The .Nm environment appeared in 2014. . . .Sh AUTHORS . Idea and first implementation by .An Steffen Nurpmeso Aq Mt sdaoden@users.sf.net . .An Ingo Schwarze Aq Mt schwarze@openbsd.org designed the command semantics. . . .Sh CAVEATS . Be aware that the content of the .Fl width argument to .Xr mdoc 7 lists etc. is evaluated as if it were normal document content; e.g., in the following example the .Ql \&Fn _atexit will be evaluated and may thus get used by .Nm : . .Pp .Dl ".Bl -tag -width "".It Fn _atexit""" . .Pp When developing a manual it may be helpful to increase verbosity of the .Xr mdocmx 1 preprocessor on its standard error I/O channel by using the .Fl v command line flag in order to get a notion on what is going on: . .Bd -literal -offset indent $ mdocmx -vv -T Sh < mdocmx.7 2> stderr.txt | \e groff -Tutf8 -mdoc | less $ cat stderr.txt .Ed . .\" s-ts-mode ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2015-03-11 10:07 UTC | newest] Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <sfid-H20150308-171308-+043.19-1@spamfilter.osbf.lua> 2015-03-08 16:12 ` Linking in mdoc(7) Kristaps Dzonsons 2015-03-09 6:29 ` Thomas Klausner 2015-03-09 6:38 ` Anthony J. Bentley 2015-03-09 8:46 ` Kristaps Dzonsons 2015-03-09 11:12 ` Joerg Sonnenberger 2015-03-09 11:34 ` Kristaps Dzonsons 2015-03-09 11:09 ` Steffen Nurpmeso 2015-03-09 11:46 ` Ingo Schwarze 2015-03-09 12:25 ` Kristaps Dzonsons 2015-03-09 15:36 ` Kristaps Dzonsons 2015-03-10 16:30 ` Steffen Nurpmeso 2015-03-11 8:05 ` Kristaps Dzonsons 2015-03-11 8:15 ` Anthony J. Bentley 2015-03-11 10:07 ` Steffen Nurpmeso 2015-03-09 13:11 ` Steffen Nurpmeso
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).