From: Ingo Schwarze Subject: Hyperlinks to RFCs in man(1) HTML output, was: bgpd To: Stuart Henderson Cc: Theo Buehler , tech@openbsd.org Date: Sat, 18 Jan 2025 04:22:16 +0100 Hi Stuart, Stuart Henderson wrote on Fri, Jan 17, 2025 at 01:31:18PM +0000: > I looked to see if there was a sensible way to add links to the RFCs > in HTML output, which would make it easier to look them up if wanted - > but I don't think there is, at least without the URL also showing up > in the console output which makes things much worse there). If you are a browser, use this for testing: $ man -T html bgpd Otherwise, try something like $ MANPAGER=lynx man -T html bgpd Or if you have unveil(2)ed /tmp/ to canines (i haven't), this *might* also work: $ MANPAGER=firefox man -T html bgpd Does this make sense to you? Admittedly, the patch is somewhat pedestrian. Then again, we really don't need and don't want manual page authors to learn new syntax for this purpose, so let's not touch the parsers. The task is for HTML only, so the code isn't misplaced in the HTML formatter. Yours, Ingo P.S. While i do sometimes add author names to STANDARDS sections when there are only one or two refences with only one or two authors each, in which case those few words do no harm and may occasionally even be useful, i realize that people have a point that stuff like bgpd(8) and ssh(1) looks less concise than it could, so i do not object to using a broom there. Index: mdoc_html.c =================================================================== RCS file: /cvs/src/usr.bin/mandoc/mdoc_html.c,v diff -u -p -r1.225 mdoc_html.c --- mdoc_html.c 6 Jul 2022 16:02:52 -0000 1.225 +++ mdoc_html.c 18 Jan 2025 03:02:18 -0000 @@ -1492,10 +1492,13 @@ static int mdoc__x_pre(MDOC_ARGS) { struct roff_node *nn; - const char *cattr; + const unsigned char *cp; + const char *cattr, *arg; + char *url; enum htmltag t; t = TAG_SPAN; + arg = n->child->string; switch (n->tok) { case MDOC__A: @@ -1535,13 +1538,25 @@ mdoc__x_pre(MDOC_ARGS) cattr = "RsQ"; break; case MDOC__R: + if (strncmp(arg, "RFC ", 4) == 0) { + cp = arg += 4; + while (isdigit(*cp)) + cp++; + if (*cp == '\0') { + mandoc_asprintf(&url, "https://www.rfc-" + "editor.org/rfc/rfc%s.html", arg); + print_otag(h, TAG_A, "ch", "RsR", url); + free(url); + return 1; + } + } cattr = "RsR"; break; case MDOC__T: cattr = "RsT"; break; case MDOC__U: - print_otag(h, TAG_A, "ch", "RsU", n->child->string); + print_otag(h, TAG_A, "ch", "RsU", arg); return 1; case MDOC__V: cattr = "RsV";