From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from scc-mailout-kit-01.scc.kit.edu (scc-mailout-kit-01.scc.kit.edu [129.13.231.81]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTP id 00bdb251 for ; Mon, 13 Mar 2017 10:32:44 -0500 (EST) Received: from asta-nat.asta.uni-karlsruhe.de ([172.22.63.82] helo=hekate.usta.de) by scc-mailout-kit-01.scc.kit.edu with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (envelope-from ) id 1cnRxh-000592-SE; Mon, 13 Mar 2017 16:32:43 +0100 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.77) (envelope-from ) id 1cnRxe-0000ta-GX; Mon, 13 Mar 2017 16:32:38 +0100 Received: from athene.usta.de ([172.24.96.10]) by donnerwolke.usta.de with esmtp (Exim 4.84_2) (envelope-from ) id 1cnRxe-0003Wm-CD; Mon, 13 Mar 2017 16:32:38 +0100 Received: from localhost (athene.usta.de [local]) by athene.usta.de (OpenSMTPD) with ESMTPA id 0c10183c; Mon, 13 Mar 2017 16:32:38 +0100 (CET) Date: Mon, 13 Mar 2017 16:32:38 +0100 From: Ingo Schwarze To: Thomas Guettler Cc: discuss@mdocml.bsd.lv Subject: Re: Links into HTML page would be great Message-ID: <20170313153238.GA33078@athene.usta.de> References: <8ffc686a-f898-4952-ae6f-3b8881469f17@thomas-guettler.de> <20170312180832.GE69791@athene.usta.de> <20170312193940.GA91520@athene.usta.de> <0dbf9b44-499d-dabc-f759-17c5a0f2f6da@thomas-guettler.de> <52d83eb6-052a-0f71-5c01-650956753c76@thomas-guettler.de> X-Mailinglist: mdocml-discuss Reply-To: discuss@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52d83eb6-052a-0f71-5c01-650956753c76@thomas-guettler.de> User-Agent: Mutt/1.6.2 (2016-07-01) Hi Thomas, Thomas Guettler wrote on Mon, Mar 13, 2017 at 10:59:24AM +0100: > I discovered, that this works for systemd man page, too: > https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type= That page is written in a completely different language and formatted by completely different technology. Near the top, you see: So this not a proper manual page, but generated from DocBook input. Overall, this results in lower-quality HTML: https://validator.w3.org/check?uri=https%3A%2F%2Fwww.freedesktop.org%2Fsoftware%2Fsystemd%2Fman%2Fsystemd.service.html It does not even have a valid . Besides, while it does have some id= attributes, they appear sparsely, and most contain HTML syntax errors. > I am unsure, but I think this is new. I have no idea. DocBook is not really worth wasting time on. It is low-quality corporate bloatware. > The above systemd page makes it easy for you to create a link > inclusive "#....". If you click on this sign 6, then your browser > gets pointed to this part in the page.... nice. That's an interesting idea, but the implementation is rather ugly. You see this HTML code:
Type= �B6;
together with this this embedded CSS (shortened deleting useless attributes): a.headerlink { visibility: hidden; } dt:hover > a.headerlink { visibility: visible; } At the very least, the CSS could be moved to the main stylesheet, it is not document-specific. You do not see that anything is special about the word before you hover over it, and if you do, the text appearing inline may mess up the right margin. It would probably be better to simply wrap the .Cm element in an element pointing to the .Cm element itself. See below for a simple implementation, also installed on man.openbsd.org such that you can see it in action: You see that there is something special about the .Cm right away because of the dotted bottom border, so maybe you become curious and hover, and then you see the link and can copy it, but without any change in the displayed text. I think now i know how to implement all this. Off to the workbench... Thanks again, Ingo Index: mandoc.css =================================================================== RCS file: /cvs/src/usr.bin/mandoc/mandoc.css,v retrieving revision 1.4 diff -u -p -r1.4 mandoc.css --- mandoc.css 5 Feb 2017 21:00:18 -0000 1.4 +++ mandoc.css 13 Mar 2017 15:15:47 -0000 @@ -14,6 +14,11 @@ ul, ol, dl { margin-top: 0em; margin-bottom: 0em; } li, dt { margin-top: 1em; } +a.selflink { color: inherit; + font: inherit; + text-decoration: inherit; + border-bottom: thin dotted; } + /* Search form and search results. */ fieldset { border: thin solid silver; Index: mdoc_html.c =================================================================== RCS file: /cvs/src/usr.bin/mandoc/mdoc_html.c,v retrieving revision 1.148 diff -u -p -r1.148 mdoc_html.c --- mdoc_html.c 3 Mar 2017 13:55:06 -0000 1.148 +++ mdoc_html.c 13 Mar 2017 15:15:47 -0000 @@ -46,6 +46,7 @@ struct htmlmdoc { void (*post)(MDOC_ARGS); }; +static const char *cond_id(const struct roff_node *); static char *make_id(const struct roff_node *); static void print_mdoc_head(MDOC_ARGS); static void print_mdoc_node(MDOC_ARGS); @@ -496,6 +497,22 @@ make_id(const struct roff_node *n) return buf; } +static const char * +cond_id(const struct roff_node *n) +{ + if (n->child != NULL && + n->child->type == ROFFT_TEXT && + (n->prev == NULL || + (n->prev->type == ROFFT_TEXT && + strcmp(n->prev->string, "|") == 0)) && + (n->parent->tok == MDOC_It || + (n->parent->tok == MDOC_Xo && + n->parent->parent->prev == NULL && + n->parent->parent->parent->tok == MDOC_It))) + return n->child->string; + return NULL; +} + static int mdoc_sh_pre(MDOC_ARGS) { @@ -549,7 +566,12 @@ mdoc_fl_pre(MDOC_ARGS) static int mdoc_cm_pre(MDOC_ARGS) { - print_otag(h, TAG_B, "c", "Cm"); + const char *id; + + id = cond_id(n); + if (id != NULL) + print_otag(h, TAG_A, "chR", "selflink", id); + print_otag(h, TAG_B, "ci", "Cm", id); return 1; } -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv