bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#53977: Improve markup in man pages


From: Mario Blättermann
Subject: bug#53977: Improve markup in man pages
Date: Mon, 14 Feb 2022 14:52:08 +0100

Hello Pádraig,

Am Mo., 14. Feb. 2022 um 13:15 Uhr schrieb Pádraig Brady <P@draigbrady.com>:
>
> On 13/02/2022 13:19, Mario Blättermann wrote:
> > Hello,
> >
> > the SEE ALSO sections in the man pages contain links which will be
> > pulled in from *.x files by help2man. While help2man evaluates the
> > Groff markup from --help and --version output, it doesn't bother with
> > the markup in the *.x files. See the attached patch. The bold
> > formatting of the links is especially useful in HTML output (but also
> > in terminal output); the links become clickable and point to the
> > respective man page in online collections [1]. You can test the
> > behavior in the German version, where the links are already properly
> > formatted [2].
> >
> > [1] https://man.archlinux.org/man/cat.1
> > [2] https://man.archlinux.org/man/cat.1.de
>
> Sorry. I'm still not convinced on this.
> It seems like a layering violation to stipulate a style here.
> The renderer should have enough context to highlight appropriately.
> See for example:
>
> https://man7.org/linux/man-pages/man1/sort.1.html
>

Maybe some renderers are smart enough to highlight this. But it
shouldn't be up to the developers of such renderers to apply missing
formattings virtually.

> Note the man7.org renderer only highlights the SEE ALSO references,
> when ideally it would highlight all instances of this pattern.
> Anyway handling references outside of the SEE ALSO section,
> is another reason to have the renderer do this consistently.
> See for example all the appropriately highlighted references in:
>
> http://man.he.net/?topic=sort&section=all
> https://man.cx/sort
>
Yes, but this doesn't work in all imaginable cases, because the
renderer needs to be able to evaluate if it is a link or not. In your
example, "shuf" is a link because it is tagged with the section
number, but this wouldn't, then "shuf" would be as plain as other
words. See the "diff3.1" man page [1]:

-e, --ed
output ed script incorporating changes from OLDFILE to YOURFILE into MYFILE

If "ed" would be "ed(1)" then it would be detected as a command name
here, but it isn't. Well, the best solution would be to dig in the
Help2man code and try to improve the detection of parts worth to be
formatted - provided solid Perl skills. But this would be outside of
the topic of this bug report; let's go back to the SEE ALSO links. The
man page man-pages(7) says [2]:

»The name of the command, and its options, should always be formatted in bold.«

In fact, the SEE ALSO links are also command names, although not the
command the current man page describes. Let's have a look at other
projects. The GRUB developers also use Help2man to generate man pages
dynamically, and they use *.h2m files to feed Help2man, like
Coreutils' *.x files do. An example [3]:

[NAME]
grub-editenv \- edit GRUB environment block
[SEE ALSO]
.BR grub-reboot (8),
.BR grub-set-default (8)

It seems to be obvious for them to format the links bold. But it is
not special to Help2man-based projects to do so. Example from GNU Grep
[4], which uses a static man page:

.SH "SEE ALSO"
.SS "Regular Manual Pages"
.BR awk (1),
.BR cmp (1),
.BR diff (1),
.BR find (1),
.BR perl (1),
...

Another example from the kernel's man pages [5]:

.SH SEE ALSO
.BR memusage (1),
.BR mtrace (3)

And last but not least, an example from an Mdoc based man page from FreeBSD [6]:

.Sh SEE ALSO
.Xr comm 1 ,
.Xr join 1 ,
.Xr uniq 1


I could mention lots of similar examples, but just open an arbitrary
man page in your terminal with "man", not in Vim; you will see that
(almost …) all SEE ALSO links are formatted bold. With the bold
formatting (and correct placing of the section number), you make sure
that *all* renderers, both the simple ones like "man" in the terminal
and the advanced HTML/DVI/PDF/whatever renderers, format the links
correctly. The additional lines in the *.x files don't eat up lots of
disk space or other resources. Please think about to apply my patch
once again.

[1] https://man.cx/diff3#heading3
[2] 
https://man.archlinux.org/man/man-pages.7.en#Formatting_conventions_for_manual_pages_describing_commands
[3] https://git.savannah.gnu.org/cgit/grub.git/tree/docs/man/grub-editenv.h2m
[4] https://git.savannah.gnu.org/cgit/grep.git/tree/doc/grep.in.1#n1359
[5] 
https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/man1/mtrace.1#n64
[6] https://github.com/freebsd/freebsd-src/blob/main/usr.bin/sort/sort.1.in#L580

Best Regards,
Mario





reply via email to

[Prev in Thread] Current Thread [Next in Thread]