Hi Paul,

Paul Pace wrote on Sun, Dec 24, 2023 at 05:25:55AM -0800:

> I have this vague memory of reading someone who posted a script, IIRC, 
> to convert the system's man pages to HTML, or similar, into somewhere 
> under /var/www and the pages worked just like the highly useful 
> man.openbsd.org, and not like the plain text pages that everyone always 
> posts to their websites.
> 
> Does someone happen to know where that is?

I don't know about any such "script" and believe using a script for it
would be a bad idea - a dirty hack at best.

Converting a whole tree of manual pages to a different format
sounds like the job for the tradition catman(8) utility program
that Christoph Robitschko first implemented in 1993.  NetBSD
and FreeBSD contain implementations by various other authors.

OpenBSD does not contain the catman(8) utility because it is rarely
needed by ordinary users and we tend to only include code in the base
system that is useful for many people.

However, the portable mandoc distribution does contain a version
that i wrote together with Michael Stapelberg (of the Debian project)
in 2017:

  https://mandoc.bsd.lv/
  https://mandoc.bsd.lv/man/catman.8.html

For your purpose, you may want to replace to line

        options.fragment = 1;

in mandocd.c by something like

        { char style[] = "/usr/share/misc/mandoc.css";
        options.style = style; }

before compiling such that you get complete HTML code including
<html>, <head>, <link rel="stylesheet">, and <body> elements.

Be careful to not clobber the system mandoc(1) installation by blindly
running "make install".  Instead, just manually installing the
binary "mandocd" anywhere in the $PATH is enough.  Installing
the "catman" binary in not necessary but won't hurt either.

Also note that viewing the results with a monster browser like
firefox or chrome may require some tweaking with respect to unveil(2),
see the respective files below /usr/local/share/doc/pkg-readmes/.

I freely admit all this is not particularly user-friendly but more
geared towards the needs of server admins.  For example, the
server manpages.debian.org is essentially using something similar
to this method.  For them, it's critical that this implementation
of catman(8) is much more efficient than the NetBSD and FreeBSD
implementations: it saves lots of time because it does *not* fork
and exec a new parser/formatter process for every manual page
but instead merely reinitialized and resuses the same parser and
formatter process over and over again, which is *much* faster.
With the huge amount of manual pages Debian has to format very
often, their server would not be able to keep up without that
optimization.

Yours,
  Ingo

Reply via email to