Hi John, At 2023-02-06T18:53:10+1100, John Gardner wrote: > So the exact URL format *does* need to be configurable,
Please review, apply, and test the attached patch. > preferably with a separate string for apropos(1) links, if supported > (which would logically default to the `an*MR-scheme` string, or > whatever we decide to name it. apropos(1) is not in groff's department. If you want hyperlinked apropos output (a good idea, by the way), man-db author and maintainer Colin Watson is the person to talk to. That said, I have proposed lightening his plate (except for what he'll have to retain for portability, which is probably "everything") by suggesting that groff's man(7) and mdoc(7) could be run in a mode such that they would produce the "apropos line" themselves. In man-db, a tool called "lexgrog(1)" has to do that, and it is fundamentally limited by not being a 900-lb. full implementation of a *roff interpreter. (Nevertheless it does an excellent job on well-behaved input.) It baffles me that this hasn't been done before. Nothing but *roff should be trying to interpret *roff, but people kept trying... It _should_ be easy. Test one string or register, and if it's true, divert the output, then wait to hit a `SH` call with an argument of "NAME" or "Name", end the diversion, format normally, then when you hit `SH` again, invoke `nx` to skip to the next input file. (N.B., the diversion is never emitted. It is thrown away, just as Doug McIlroy indirectly taught me with "divert(-1)" in m4.) Maybe for some reason this _isn't_ easy and I'll be laughing out the other side of my face. But its _seems_ plausible... And of course the same could and should be done for mdoc(7), which already performs tests its `SH` arguments far more than man(7) ever dreamed of doing. Regards, Branden
diff --git a/tmac/an.tmac b/tmac/an.tmac index a00340573..4fa7451b2 100644 --- a/tmac/an.tmac +++ b/tmac/an.tmac @@ -1,6 +1,6 @@ .\" groff implementation of man(7) package .\" -.\" Copyright (C) 1989-2022 Free Software Foundation, Inc. +.\" Copyright (C) 1989-2023 Free Software Foundation, Inc. .\" Written by James Clark (j...@jclark.com) .\" Enhanced by: Werner Lemberg <w...@gnu.org> .\" Larry Kollar <kol...@alltel.net> @@ -1161,17 +1161,30 @@ contains unsupported escape sequence . rm an*prefix .. . +.\" There is no standardized scheme for man pages, but this is expected +.\" to work (or be harmlessly ignored) everywhere except macOS. +.\" Override in man.local if desired. +.nr an*MR-URL-format 1 +. .\" Set a man page cross reference. .\" .MR page-topic page-section [trailing-text] .de1 MR . if ((\\n[.$] < 2) : (\\n[.$] > 3)) \ . an-style-warn .\\$0 expects 2 or 3 arguments, got \\n[.$] +. if (\\n[an*MR-URL-format] = 1) \ +. ds an*url man:\\$1(\\$2)\" used everywhere but macOS +. if (\\n[an*MR-URL-format] = 2) \ +. ds an*url man:\\$1.\\$2\" Bwana (macOS) +. if (\\n[an*MR-URL-format] = 3) \ +. ds an*url x-man-doc://\\$2/\\$1(\\$2)\" ManOpen (macOS) +. if (\\n[an*MR-URL-format] = 4) \ +. ds an*url x-man-page://\\$2/\\$1\" Terminal.app (macOS) . nh . if \\n[an*do-hyperlink] \{\ . if \\n[an*is-output-html] \ -. nop \X^html:<a href="man:\\$1(\\$2)">^\c +. nop \X^html:<a href="\\*[an*url]">^\c . if \\n[an*is-output-terminal] \ -. nop \X^tty: link man:\\$1(\\$2)^\c +. nop \X^tty: link \\*[an*url]^\c . \} . nop \&\\*[an-lic]\f[\\*[MF]]\\$1\\*[an-ic]\f[R](\\$2)\c . if \\n[an*do-hyperlink] \{\ diff --git a/tmac/man.local b/tmac/man.local index ed5706b41..ff7159ac3 100644 --- a/tmac/man.local +++ b/tmac/man.local @@ -14,6 +14,16 @@ .\" might prefer to remap it to bold ("B") instead. .\" .if n .ftr CW R .\" +.\" A de facto standard URL format for man pages is recognized +.\" everywhere except Apple, where three different macOS applications +.\" each expect a different format. +.\" 1: man:groff(1) -- used everywhere but macOS +.\" 2: man:groff.1 -- Bwana (macOS) +.\" 3: x-man-doc://1/groff(1) -- ManOpen (macOS) +.\" 4: x-man-page://1/groff -- Terminal.app (macOS) +.\" Set this register to configure which the `MR` macro uses. +.\" .nr an*MR-URL-format 1 +.\" .\" Local Variables: .\" mode: nroff .\" fill-column: 72
signature.asc
Description: PGP signature