All of lore.kernel.org
 help / color / mirror / Atom feed
* Linux man-pages PDF book
@ 2024-04-14 11:37 Alejandro Colomar
  2024-04-14 11:41 ` Alejandro Colomar
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-14 11:37 UTC (permalink / raw)
  To: Deri James; +Cc: linux-man

[-- Attachment #1: Type: text/plain, Size: 1661 bytes --]

Hi Deri,

Since the conversation in groff's bug report was getting off-topic, I'm
opening this email thread.

The makefile target was recently renamed from build-book to
build-pdf-book (for consistency reasons).

I also reorganized the files to put them inside the build system.  Here
are now the files most relevant for generating the book:

	$ find \
		share/mk/configure/build-depends/texlive-fonts-extra/ \
		share/mk/build/fonts/ \
		share/mk/build/pdf/book/ \
		-type f;
	share/mk/configure/build-depends/texlive-fonts-extra/Tinos.pfb.mk
	share/mk/build/fonts/_.mk
	share/mk/build/fonts/TINOR
	share/mk/build/fonts/tinos.mk
	share/mk/build/pdf/book/_.mk
	share/mk/build/pdf/book/prepare.pl
	share/mk/build/pdf/book/front.roff
	share/mk/build/pdf/book/an.tmac

I removed the Tinos.pfa file, since now I generate it at build time
from the Tinos.pfb file (installed with Debian's texlive-fonts-extra).

Either the reorganization, or the generation of the font results in a
new warning:

troff:<standard input>:1649: error: cannot load font 'TINOR' to mark it as special

Since I didn't notice any changes in the PDF visually, and I removed a
gigantic binary file, I proceeded with it, even with the new warning.
It would be great if we can do something similar to get rid of the TINOR
file, and generate it at build time.
I would also like to do the same with the Unifont font, which I haven't
yet added because I hate adding gigantic binary files to the repo.

There's also the page issue.  Now it seems to reset the page number for
every TH.

Have a lovely day!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 11:37 Linux man-pages PDF book Alejandro Colomar
@ 2024-04-14 11:41 ` Alejandro Colomar
  2024-04-14 12:01   ` G. Branden Robinson
  2024-04-14 11:57 ` G. Branden Robinson
  2024-04-14 14:50 ` Alejandro Colomar
  2 siblings, 1 reply; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-14 11:41 UTC (permalink / raw)
  To: Deri James; +Cc: linux-man

[-- Attachment #1: Type: text/plain, Size: 2099 bytes --]

On Sun, Apr 14, 2024 at 01:37:15PM +0200, Alejandro Colomar wrote:
> Hi Deri,
> 
> Since the conversation in groff's bug report was getting off-topic, I'm
> opening this email thread.
> 
> The makefile target was recently renamed from build-book to
> build-pdf-book (for consistency reasons).
> 
> I also reorganized the files to put them inside the build system.  Here
> are now the files most relevant for generating the book:
> 
> 	$ find \
> 		share/mk/configure/build-depends/texlive-fonts-extra/ \
> 		share/mk/build/fonts/ \
> 		share/mk/build/pdf/book/ \
> 		-type f;
> 	share/mk/configure/build-depends/texlive-fonts-extra/Tinos.pfb.mk
> 	share/mk/build/fonts/_.mk
> 	share/mk/build/fonts/TINOR
> 	share/mk/build/fonts/tinos.mk
> 	share/mk/build/pdf/book/_.mk
> 	share/mk/build/pdf/book/prepare.pl
> 	share/mk/build/pdf/book/front.roff
> 	share/mk/build/pdf/book/an.tmac

Another thing I want to do, as mentioned in the groff bug, is to remove
our an.tmac.  Is there any change we can use a minimal definition that
we can cat(1) to the system an.tmac?  Or maybe instead of cat(1)ing it,
tell groff(1) to use our definition in addition to -man.

> 
> I removed the Tinos.pfa file, since now I generate it at build time
> from the Tinos.pfb file (installed with Debian's texlive-fonts-extra).
> 
> Either the reorganization, or the generation of the font results in a
> new warning:
> 
> troff:<standard input>:1649: error: cannot load font 'TINOR' to mark it as special
> 
> Since I didn't notice any changes in the PDF visually, and I removed a
> gigantic binary file, I proceeded with it, even with the new warning.
> It would be great if we can do something similar to get rid of the TINOR
> file, and generate it at build time.
> I would also like to do the same with the Unifont font, which I haven't
> yet added because I hate adding gigantic binary files to the repo.
> 
> There's also the page issue.  Now it seems to reset the page number for
> every TH.
> 
> Have a lovely day!
> Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 11:37 Linux man-pages PDF book Alejandro Colomar
  2024-04-14 11:41 ` Alejandro Colomar
@ 2024-04-14 11:57 ` G. Branden Robinson
  2024-04-14 12:32   ` Alejandro Colomar
  2024-04-14 14:50 ` Alejandro Colomar
  2 siblings, 1 reply; 31+ messages in thread
From: G. Branden Robinson @ 2024-04-14 11:57 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: Deri James, linux-man

[-- Attachment #1: Type: text/plain, Size: 513 bytes --]

At 2024-04-14T13:37:15+0200, Alejandro Colomar wrote:
> There's also the page issue.  Now it seems to reset the page number for
> every TH.

This might be a simple issue.  Make sure that you're passing groff (or
troff) an option to set the `C` register to a true value.

groff_man(7):
     -rC1     Number output pages consecutively, in strictly increasing
              sequence, rather than resetting the page number to 1 (or
              the value of register P) with each new man document.

Regards,
Branden

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 11:41 ` Alejandro Colomar
@ 2024-04-14 12:01   ` G. Branden Robinson
  2024-04-14 12:25     ` Alejandro Colomar
  0 siblings, 1 reply; 31+ messages in thread
From: G. Branden Robinson @ 2024-04-14 12:01 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: Deri James, linux-man

[-- Attachment #1: Type: text/plain, Size: 718 bytes --]

At 2024-04-14T13:41:24+0200, Alejandro Colomar wrote:
> Another thing I want to do, as mentioned in the groff bug, is to
> remove our an.tmac.  Is there any change we can use a minimal
> definition that we can cat(1) to the system an.tmac?  Or maybe instead
> of cat(1)ing it, tell groff(1) to use our definition in addition to
> -man.

Deri had been using the cover page document to append to man(7) macros
definitions, which basically accomplished this.

I've since refactored everything that hyperlinked book generation needed
in that respect into groff's "an.tmac" (in Git), leaving the cover page
to do only cover page things.

https://git.savannah.gnu.org/cgit/groff.git/tree/doc/GMPfront.t.in

Regards,
Branden

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 12:01   ` G. Branden Robinson
@ 2024-04-14 12:25     ` Alejandro Colomar
       [not found]       ` <3935722.768hzMJKAL@pip>
  0 siblings, 1 reply; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-14 12:25 UTC (permalink / raw)
  To: G. Branden Robinson; +Cc: Deri James, linux-man

[-- Attachment #1: Type: text/plain, Size: 2073 bytes --]

Hi Branden!

On Sun, Apr 14, 2024 at 07:01:45AM -0500, G. Branden Robinson wrote:
> At 2024-04-14T13:41:24+0200, Alejandro Colomar wrote:
> > Another thing I want to do, as mentioned in the groff bug, is to
> > remove our an.tmac.  Is there any change we can use a minimal
> > definition that we can cat(1) to the system an.tmac?  Or maybe instead
> > of cat(1)ing it, tell groff(1) to use our definition in addition to
> > -man.
> 
> Deri had been using the cover page document to append to man(7) macros
> definitions, which basically accomplished this.
> 
> I've since refactored everything that hyperlinked book generation needed
> in that respect into groff's "an.tmac" (in Git), leaving the cover page
> to do only cover page things.
> 
> https://git.savannah.gnu.org/cgit/groff.git/tree/doc/GMPfront.t.in

Hmmm.  I notice that your cover page has a few things that we have as
part of the prepare.pl script:
<https://git.savannah.gnu.org/cgit/groff.git/tree/doc/GMPfront.t.in#n7>
<https://git.savannah.gnu.org/cgit/groff.git/tree/doc/GMPfront.t.in#n42>
<https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/share/mk/build/pdf/book/prepare.pl#n86>

Maybe we could do the same, to reduce the work of prepare.pl?


Our front page is also clean from an.tmac stuff.  We have the an.tmac
fork here:
<https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/share/mk/build/pdf/book/an.tmac>
And the front page is:
<https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/share/mk/build/pdf/book/front.roff>

However, our an.tmac is not for appending, but for replacing man(7).  :(
I'd like to get rid of that an.tmac fork.  Does your message mean that
if I use groff git HEAD to build our book I can just drop the fork and
use man(7), and groff(1) will do the right thing?


Also, what does .t mean (in GMPfront.t.in)?  I changed the file
extension to .roff (so, <front.roff>) in the Linux man-pages, as it's
just a roff(7) file.

Have a lovely day!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 11:57 ` G. Branden Robinson
@ 2024-04-14 12:32   ` Alejandro Colomar
  2024-04-14 12:42     ` Alejandro Colomar
  2024-04-14 12:56     ` G. Branden Robinson
  0 siblings, 2 replies; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-14 12:32 UTC (permalink / raw)
  To: G. Branden Robinson; +Cc: Deri James, linux-man

[-- Attachment #1: Type: text/plain, Size: 933 bytes --]

Hi Branden,

On Sun, Apr 14, 2024 at 06:57:43AM -0500, G. Branden Robinson wrote:
> At 2024-04-14T13:37:15+0200, Alejandro Colomar wrote:
> > There's also the page issue.  Now it seems to reset the page number for
> > every TH.
> 
> This might be a simple issue.  Make sure that you're passing groff (or
> troff) an option to set the `C` register to a true value.
> 
> groff_man(7):
>      -rC1     Number output pages consecutively, in strictly increasing
>               sequence, rather than resetting the page number to 1 (or
>               the value of register P) with each new man document.

Hmmmm.  Maybe I should follow v7's tradition and restart the page number
at each TH.  Let's call it an accidental improvement, and not a
regression.  :)

Although it would be interesting to learn when/why this changed.

Thanks!
Alex

> 
> Regards,
> Branden



-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 12:32   ` Alejandro Colomar
@ 2024-04-14 12:42     ` Alejandro Colomar
  2024-04-14 13:00       ` G. Branden Robinson
  2024-04-14 12:56     ` G. Branden Robinson
  1 sibling, 1 reply; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-14 12:42 UTC (permalink / raw)
  To: G. Branden Robinson; +Cc: Deri James, linux-man

[-- Attachment #1: Type: text/plain, Size: 3172 bytes --]

On Sun, Apr 14, 2024 at 02:32:25PM +0200, Alejandro Colomar wrote:
> Hi Branden,
> 
> On Sun, Apr 14, 2024 at 06:57:43AM -0500, G. Branden Robinson wrote:
> > At 2024-04-14T13:37:15+0200, Alejandro Colomar wrote:
> > > There's also the page issue.  Now it seems to reset the page number for
> > > every TH.
> > 
> > This might be a simple issue.  Make sure that you're passing groff (or
> > troff) an option to set the `C` register to a true value.
> > 
> > groff_man(7):
> >      -rC1     Number output pages consecutively, in strictly increasing
> >               sequence, rather than resetting the page number to 1 (or
> >               the value of register P) with each new man document.
> 
> Hmmmm.  Maybe I should follow v7's tradition and restart the page number
> at each TH.  Let's call it an accidental improvement, and not a
> regression.  :)
> 
> Although it would be interesting to learn when/why this changed.

It seems to have been here:

$ git show 6d87a75a6df0 -- scripts/LinuxManBook/build.sh;
commit 6d87a75a6df0696e780255d865bf65da09f36f01
Author: Alejandro Colomar <alx@kernel.org>
Date:   Fri Dec 1 00:55:11 2023 +0100

    scripts/LinuxManBook/: Simplify pipeline
    
    Call the groff(1) pipeline only once.  This optimizes around 2 seconds,
    while also simplifying the code.
    
    This change was originally written by Deri, with some parts written by
    Brian.  I took the script that Deri sent, and split it so that the
    groff(1) pipeline is called from the shell script, and the Perl script
    is limited to editing the man(7) pages.  This helps me understand the
    process, since my understanding of Perl is very limited.  It also makes
    this change smaller, so that it's less of a big-bang.
    
    Link: <https://lore.kernel.org/linux-man/ZWkO4qPC4BxkwBNm@debian/T/#m3d453440b02dd189bc12d2e629c4026206025b40>
    Co-developed-by: Deri James <deri@chuzzlewit.myzen.co.uk>
    Co-developed-by: Brian Inglis <Brian.Inglis@Shaw.ca>
    Signed-off-by: Alejandro Colomar <alx@kernel.org>

diff --git a/scripts/LinuxManBook/build.sh b/scripts/LinuxManBook/build.sh
index a6e578f64..8e373c073 100755
--- a/scripts/LinuxManBook/build.sh
+++ b/scripts/LinuxManBook/build.sh
@@ -3,25 +3,13 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 
 (
-       "$(dirname "$0")"/prepare.pl "$1" \
-       | preconv \
-       | pic \
-       | tbl \
-       | eqn -Tpdf \
-       | troff -Tpdf -dPDF.EXPORT=1 -dLABEL.REFS=1 -dpaper=a4 \
-               -M"$(dirname "$0")" -mandoc -manmark -rC1 -rCHECKSTYLE=3 \
-               2>&1 >/dev/null \
-       | LC_ALL=C grep '^\. *ds ';
-
+       cat "$(dirname "$0")"/LMBfront.roff;
+       cat "$(dirname "$0")"/an.tmac;
        "$(dirname "$0")"/prepare.pl "$1";
 ) \
 | preconv \
 | pic \
 | tbl \
 | eqn -Tpdf \
-| (
-       troff -Tpdf -ms <"$(dirname "$0")"/LMBfront.ms;
-       troff -Tpdf -M"$(dirname "$0")" -mandoc -manmark \
-               -F"$(dirname "$0")" -dpaper=a4;
-) \
+| troff -Tpdf -F"$(dirname "$0")" -dpaper=a4 \
 | gropdf -F"$(dirname "$0")" -pa4;

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 12:32   ` Alejandro Colomar
  2024-04-14 12:42     ` Alejandro Colomar
@ 2024-04-14 12:56     ` G. Branden Robinson
  2024-04-14 15:58       ` Alejandro Colomar
  1 sibling, 1 reply; 31+ messages in thread
From: G. Branden Robinson @ 2024-04-14 12:56 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: Deri James, linux-man

[-- Attachment #1: Type: text/plain, Size: 3447 bytes --]

Hi Alex,

At 2024-04-14T14:25:28+0200, Alejandro Colomar wrote:
> On Sun, Apr 14, 2024 at 07:01:45AM -0500, G. Branden Robinson wrote:
> > I've since refactored everything that hyperlinked book generation
> > needed in that respect into groff's "an.tmac" (in Git), leaving the
> > cover page to do only cover page things.
> > 
> > https://git.savannah.gnu.org/cgit/groff.git/tree/doc/GMPfront.t.in
> 
> Hmmm.  I notice that your cover page has a few things that we have as
> part of the prepare.pl script:
> <https://git.savannah.gnu.org/cgit/groff.git/tree/doc/GMPfront.t.in#n7>
> <https://git.savannah.gnu.org/cgit/groff.git/tree/doc/GMPfront.t.in#n42>
> <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/share/mk/build/pdf/book/prepare.pl#n86>
> 
> Maybe we could do the same, to reduce the work of prepare.pl?

I didn't look closely at that complicated Perl script, but it seems
likely.  Essentially, anything that didn't need to be parameterized
(i.e., lines you write out with Perl but don't need to do any Perl
variable interpolation in), I would keep in a plain text document.

> Our front page is also clean from an.tmac stuff.  We have the an.tmac
> fork here:
> <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/share/mk/build/pdf/book/an.tmac>

Might be worth diffing that with groff Git HEAD.

> And the front page is:
> <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/share/mk/build/pdf/book/front.roff>

Yup, that's pretty clean and focused.

> However, our an.tmac is not for appending, but for replacing man(7).
> :( I'd like to get rid of that an.tmac fork.  Does your message mean
> that if I use groff git HEAD to build our book I can just drop the
> fork and use man(7), and groff(1) will do the right thing?

I think so, and want to know if it doesn't.  Also, fair warning, Deri
said he observed a CRAZY bad performance regression when building the
Linux man-pages book with groff Git HEAD.  If you can reproduce that,
then I have some work to do.  Let me know.

> Also, what does .t mean (in GMPfront.t.in)?  I changed the file
> extension to .roff (so, <front.roff>) in the Linux man-pages, as it's
> just a roff(7) file.

It was Deri's choice.  Some people have historically used the `t` suffix
to indicate a "troff" file.  I don't employ that practice, personally,
because it's also popular as a suffix for "test script", and troff
documents can also be rendered with nroff.

Personally, I use `.roff` for *roff documents I intend to be portable
between AT&T/DWB troff and GNU troff, and `.groff` for ones that use GNU
extensions.

At 2024-04-14T14:32:25+0200, Alejandro Colomar wrote:
> Hmmmm.  Maybe I should follow v7's tradition and restart the page
> number at each TH.  Let's call it an accidental improvement, and not a
> regression.  :)

I think it's a matter of taste.  This issue came up last month on the
groff list.  As often happens with me, it turned into an episode of Unix
History Detectives.  :-|

https://lists.gnu.org/archive/html/groff/2024-03/msg00163.html

> Although it would be interesting to learn when/why this changed.

The default has never changed in groff as far as I know, and I'm certain
I haven't personally touched it--I'd remember writing the usual 20,000
word essay with 2 dozen citations that usually accompanies my breaks
with tradition.

Regards,
Branden

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 12:42     ` Alejandro Colomar
@ 2024-04-14 13:00       ` G. Branden Robinson
  0 siblings, 0 replies; 31+ messages in thread
From: G. Branden Robinson @ 2024-04-14 13:00 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: Deri James, linux-man

[-- Attachment #1: Type: text/plain, Size: 1282 bytes --]

Hi Alex,

At 2024-04-14T14:42:51+0200, Alejandro Colomar wrote:
> On Sun, Apr 14, 2024 at 02:32:25PM +0200, Alejandro Colomar wrote:
> > > groff_man(7):
> > >      -rC1     Number output pages consecutively, in strictly increasing
> > >               sequence, rather than resetting the page number to 1 (or
> > >               the value of register P) with each new man document.
> > 
> > Hmmmm.  Maybe I should follow v7's tradition and restart the page
> > number at each TH.  Let's call it an accidental improvement, and not
> > a regression.  :)
> > 
> > Although it would be interesting to learn when/why this changed.
> 
> It seems to have been here:
[...]
> -       | troff -Tpdf -dPDF.EXPORT=1 -dLABEL.REFS=1 -dpaper=a4 \
> -               -M"$(dirname "$0")" -mandoc -manmark -rC1 -rCHECKSTYLE=3 \
> -               2>&1 >/dev/null \
> -       | LC_ALL=C grep '^\. *ds ';
> -
> +       cat "$(dirname "$0")"/LMBfront.roff;
> +       cat "$(dirname "$0")"/an.tmac;
>         "$(dirname "$0")"/prepare.pl "$1";

I don't think there's one right choice here.  I _would_ make sure that
the PDF page numbering (visible in the PDF viewer's outline pane)
matches that used by the document.  To do otherwise will frustrate
users.

Regards,
Branden

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 11:37 Linux man-pages PDF book Alejandro Colomar
  2024-04-14 11:41 ` Alejandro Colomar
  2024-04-14 11:57 ` G. Branden Robinson
@ 2024-04-14 14:50 ` Alejandro Colomar
  2 siblings, 0 replies; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-14 14:50 UTC (permalink / raw)
  To: branden; +Cc: Deri James, linux-man

[-- Attachment #1: Type: text/plain, Size: 1000 bytes --]

Hi Branden,

On Sun, Apr 14, 2024 at 01:37:15PM +0200, Alejandro Colomar wrote:
> The makefile target was recently renamed from build-book to
> build-pdf-book (for consistency reasons).
> 
> I also reorganized the files to put them inside the build system.  Here
> are now the files most relevant for generating the book:
> 
> 	$ find \
> 		share/mk/configure/build-depends/texlive-fonts-extra/ \
> 		share/mk/build/fonts/ \
> 		share/mk/build/pdf/book/ \
> 		-type f;
> 	share/mk/configure/build-depends/texlive-fonts-extra/Tinos.pfb.mk
> 	share/mk/build/fonts/_.mk
> 	share/mk/build/fonts/TINOR
> 	share/mk/build/fonts/tinos.mk
> 	share/mk/build/pdf/book/_.mk
> 	share/mk/build/pdf/book/prepare.pl
> 	share/mk/build/pdf/book/front.roff
> 	share/mk/build/pdf/book/an.tmac

Branden, could you list all files in groff.git that are similarly
responsible for the generation of your book, so I can compare?

Have a lovely day!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 12:56     ` G. Branden Robinson
@ 2024-04-14 15:58       ` Alejandro Colomar
  2024-04-14 19:55         ` Alejandro Colomar
  0 siblings, 1 reply; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-14 15:58 UTC (permalink / raw)
  To: G. Branden Robinson; +Cc: Deri James, linux-man


[-- Attachment #1.1: Type: text/plain, Size: 4578 bytes --]

Hi Branden, Deri,

On Sun, Apr 14, 2024 at 07:56:53AM -0500, G. Branden Robinson wrote:
> Hi Alex,
> 
> At 2024-04-14T14:25:28+0200, Alejandro Colomar wrote:
> > On Sun, Apr 14, 2024 at 07:01:45AM -0500, G. Branden Robinson wrote:
> > > I've since refactored everything that hyperlinked book generation
> > > needed in that respect into groff's "an.tmac" (in Git), leaving the
> > > cover page to do only cover page things.
> > > 
> > > https://git.savannah.gnu.org/cgit/groff.git/tree/doc/GMPfront.t.in
> > 
> > Hmmm.  I notice that your cover page has a few things that we have as
> > part of the prepare.pl script:
> > <https://git.savannah.gnu.org/cgit/groff.git/tree/doc/GMPfront.t.in#n7>
> > <https://git.savannah.gnu.org/cgit/groff.git/tree/doc/GMPfront.t.in#n42>
> > <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/share/mk/build/pdf/book/prepare.pl#n86>
> > 
> > Maybe we could do the same, to reduce the work of prepare.pl?
> 
> I didn't look closely at that complicated Perl script, but it seems
> likely.  Essentially, anything that didn't need to be parameterized
> (i.e., lines you write out with Perl but don't need to do any Perl
> variable interpolation in), I would keep in a plain text document.

I'd like to see how you build your book.

> > Our front page is also clean from an.tmac stuff.  We have the an.tmac
> > fork here:
> > <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/share/mk/build/pdf/book/an.tmac>
> 
> Might be worth diffing that with groff Git HEAD.

Attached are diffs against HEAD and against 1.23.0.

> > And the front page is:
> > <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/share/mk/build/pdf/book/front.roff>
> 
> Yup, that's pretty clean and focused.
> 
> > However, our an.tmac is not for appending, but for replacing man(7).
> > :( I'd like to get rid of that an.tmac fork.  Does your message mean
> > that if I use groff git HEAD to build our book I can just drop the
> > fork and use man(7), and groff(1) will do the right thing?
> 
> I think so, and want to know if it doesn't.  Also, fair warning, Deri
> said he observed a CRAZY bad performance regression when building the
> Linux man-pages book with groff Git HEAD.  If you can reproduce that,
> then I have some work to do.  Let me know.

Can't reproduce.  I've removed the an.tmac fork, and added -man to
troff(1)'s invocation, and get the same times.

$ time make build-pdf-book 2>/dev/null
GROPDF		.tmp/man-pages-6.7-53-g5125d867d.pdf

real	0m13.307s
user	0m16.229s
sys	0m0.481s

$ time make build-pdf-book 2>/dev/null
GROPDF		.tmp/man-pages-6.7-53-g5125d867d-dirty.pdf

real	0m13.564s
user	0m17.060s
sys	0m0.510s

(I've built all the dependencies before hand, so that only the PDF is
 built in these invocations.)
(The -dirty one uses -man.)

> 
> > Also, what does .t mean (in GMPfront.t.in)?  I changed the file
> > extension to .roff (so, <front.roff>) in the Linux man-pages, as it's
> > just a roff(7) file.
> 
> It was Deri's choice.  Some people have historically used the `t` suffix
> to indicate a "troff" file.  I don't employ that practice, personally,
> because it's also popular as a suffix for "test script", and troff
> documents can also be rendered with nroff.
> 
> Personally, I use `.roff` for *roff documents I intend to be portable
> between AT&T/DWB troff and GNU troff, and `.groff` for ones that use GNU
> extensions.

Hmmm.  Does the front use GNU features?  Should I change the extension?

> At 2024-04-14T14:32:25+0200, Alejandro Colomar wrote:
> > Hmmmm.  Maybe I should follow v7's tradition and restart the page
> > number at each TH.  Let's call it an accidental improvement, and not a
> > regression.  :)
> 
> I think it's a matter of taste.  This issue came up last month on the
> groff list.  As often happens with me, it turned into an episode of Unix
> History Detectives.  :-|
> 
> https://lists.gnu.org/archive/html/groff/2024-03/msg00163.html

Hmmm.  Your obvservation about matching the PDF navigator makes sense.
Deri, was the removal of -rC1 on purpose?

> > Although it would be interesting to learn when/why this changed.
> 
> The default has never changed in groff as far as I know, and I'm certain
> I haven't personally touched it--I'd remember writing the usual 20,000
> word essay with 2 dozen citations that usually accompanies my breaks
> with tradition.
> 
> Regards,
> Branden

Have a lovely day!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #1.2: 1.23.0.diff --]
[-- Type: text/x-diff, Size: 5900 bytes --]

--- /home/alx/src/gnu/groff/1.23.0/tmac/an.tmac	2024-04-14 17:36:42.193578307 +0200
+++ /home/alx/src/linux/man-pages/man-pages/contrib/share/mk/build/pdf/book/an.tmac	2024-03-29 18:34:19.737411869 +0100
@@ -203,9 +203,25 @@
 .  ds an*section9 Kernel Developer's Manual\"
 ..
 .
+.de an*cln
+.  ds \\$1
+.  als an*cln:res \\$1
+.  shift
+.  ds an*cln:res \\$*\"
+.  ds an*cln:char \\*[an*cln:res]
+.  stringdown an*cln:res
+.  substring an*cln:char 0 0
+.  if '\\*[an*cln:char]'\%' .substring an*cln:res 1
+.  rm an*cln:char
+..
+.
 .\" Write a bookmark/anchor/link target $2 at hierarchical depth $1.
 .de an*bookmark
-.  if \\n[an*is-output-pdf] .pdfbookmark \\$1 \\$2
+.  if \\n[an*is-output-pdf] \{\
+.    if (\\n[.$]>2) .an*cln an*page-ref-nm \\$3\"
+.    ie (\\$1=1) .pdfbookmark -T "\\*[an*page-ref-nm]" \\$1 \\$2
+.    el .pdfbookmark \\$1 \\$2
+.  \}
 ..
 .
 .\" Begin man page.
@@ -293,7 +309,11 @@
 .    \" Simulate switch/case in roff.
 .          ie '\\$2'1' .ds an-extra3 \\*[an*section1]\"
 .    el \{.ie '\\$2'2' .ds an-extra3 \\*[an*section2]\"
+.    el \{.ie '\\$2'2type' .ds an-extra3 \\*[an*section2type]\"
 .    el \{.ie '\\$2'3' .ds an-extra3 \\*[an*section3]\"
+.    el \{.ie '\\$2'3const' .ds an-extra3 \\*[an*section3const]\"
+.    el \{.ie '\\$2'3head' .ds an-extra3 \\*[an*section3head]\"
+.    el \{.ie '\\$2'3type' .ds an-extra3 \\*[an*section3type]\"
 .    el \{.ie '\\$2'4' .ds an-extra3 \\*[an*section4]\"
 .    el \{.ie '\\$2'5' .ds an-extra3 \\*[an*section5]\"
 .    el \{.ie '\\$2'6' .ds an-extra3 \\*[an*section6]\"
@@ -301,7 +321,7 @@
 .    el \{.ie '\\$2'8' .ds an-extra3 \\*[an*section8]\"
 .    el \{.ie '\\$2'9' .ds an-extra3 \\*[an*section9]\"
 .    el                .ds an-extra3 \" empty
-.    \}\}\}\}\}\}\}\}
+.    \}\}\}\}\}\}\}\}\}\}\}\}
 .  \}
 .
 .  ds an-extra1 "\\$3\"
@@ -420,7 +440,7 @@
 .  ie \\n[cR] .pl +1v
 .  el         .sp .5i
 .  if !\\n[an*was-TH-bookmark-emitted] \{\
-.    an*bookmark 1 \E*[an*page-ref-string]
+.\" .    an*bookmark 2 \E*[an*page-ref-string]
 .    nr an*was-TH-bookmark-emitted 1
 .  \}
 .  tl '\\*[an-pageref]'\\*[an-extra3]'\\*[an-pageref]'
@@ -458,6 +478,8 @@
 .  \" PDF bookmarks.
 .  ds an*page-ref-string \\*[an*topic](\\*[an*section])\"
 .  ds an-pageref \\*[an*topic-abbv](\\*[an*section])\"
+.  an*cln an*page-ref-bm-nm \\*[an*topic]_\\*[an*section]\"
+.  stringdown an*page-ref-bm-nm
 .  nr an-header-width \\w'\\*[an-pageref]\\*[an-extra3]\\*[an-pageref]'
 .  while (\\n[an-header-width] >= \\n[.lt]) \{\
 .    \" The page topic is too long; trim some bits out of the middle.
@@ -695,8 +717,8 @@
 .  if \\n[.$] \{\
 .    ds an-section-heading \\$*\"
 .    if \\n[CS] .stringup an-section-heading
-.    an*bookmark 2 \E*[an-section-heading]
-.    nop \&\\*[an-section-heading]
+.    an*bookmark 3 "\\*[an-section-heading]"
+\&\\*[an-section-heading]
 .  \}
 .  if \\n[an-remap-I-style-in-headings] .ftr I I
 ..
@@ -721,7 +743,7 @@
 .  if \\n[an-remap-I-style-in-headings] .ftr I \\*[an-heading-family]BI
 .  if \\n[.$] \{\
 .    ds an*subsection-heading \\$*\"
-.    an*bookmark 3 \E*[an*subsection-heading]
+.    an*bookmark 4 "\\*[an*subsection-heading]"
 .    nop \&\\$*
 .  \}
 .  if \\n[an-remap-I-style-in-headings] .ftr I I
@@ -1169,30 +1191,45 @@
 .\" 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[.$]
-.  ds an*url man:\\$1(\\$2)\" used everywhere but macOS
-.  if (\\n[an*MR-URL-format] = 2) \
-.    ds an*url x-man-page://\\$2/\\$1\" macOS/Mac OS X since 10.3
-.  if (\\n[an*MR-URL-format] = 3) \
-.    ds an*url man:\\$1.\\$2\" Bwana (Mac OS X)
-.  if (\\n[an*MR-URL-format] = 4) \
-.    ds an*url x-man-doc://\\$2/\\$1\" ManOpen (Mac OS X pre-2005)
-.  nh
-.  if \\n[an*do-hyperlink] \{\
-.    if \\n[an*is-output-html] \
-.      nop \X^html:<a href="\\*[an*url]">^\c
-.    if \\n[an*is-output-terminal] \
-.      nop \X^tty: link \\*[an*url]^\c
-.  \}
-.      nop \&\\*[an-lic]\f[\\*[MF]]\\$1\\*[an-ic]\f[R](\\$2)\c
-.  if \\n[an*do-hyperlink] \{\
-.    if \\n[an*is-output-html] \
-.      nop \X^html:</a>^\c
-.    if \\n[an*is-output-terminal] \
-.      nop \X^tty: link^\c
+.  if ((\\n[.$] < 2) : (\\n[.$] > 4)) \
+.    an-style-warn .\\$0 expects 2 to 4 arguments, got \\n[.$]
+.  ie \\n[an*is-output-pdf] \{\
+.    nh
+.    ds an*title \\\\$4
+.    if '\\\\*[an*title]'' .ds an*title \\\\$1
+.    ie \\n(.$=1 \
+.      I \\$1
+.    el \{\
+.      an*cln an*page-ref-nm \\*[an*title]_\\$2
+.      ie d pdf:look(\\*[an*page-ref-nm]) .pdfhref L -D \\*[an*page-ref-nm] -A "\\$3" -- \fI\\$1\fP(\\$2)
+.      el .IR \\$1 (\\$2)\\$3
+.    \}
+.    hy \\n(mJ
+.  \}
+.  el \{\
+.    ds an*url man:\\$1(\\$2)\" used everywhere but macOS
+.    if (\\n[an*MR-URL-format] = 2) \
+.      ds an*url x-man-page://\\$2/\\$1\" macOS/Mac OS X since 10.3
+.    if (\\n[an*MR-URL-format] = 3) \
+.      ds an*url man:\\$1.\\$2\" Bwana (Mac OS X)
+.    if (\\n[an*MR-URL-format] = 4) \
+.      ds an*url x-man-doc://\\$2/\\$1\" ManOpen (Mac OS X pre-2005)
+.    nh
+.    if \\n[an*do-hyperlink] \{\
+.      if \\n[an*is-output-html] \
+.        nop \X^html:<a href="\\*[an*url]">^\c
+.      if \\n[an*is-output-terminal] \
+.        nop \X^tty: link \\*[an*url]^\c
+.    \}
+.        nop \&\\*[an-lic]\f[\\*[MF]]\\$1\\*[an-ic]\f[R](\\$2)\c
+.    if \\n[an*do-hyperlink] \{\
+.      if \\n[an*is-output-html] \
+.        nop \X^html:</a>^\c
+.      if \\n[an*is-output-terminal] \
+.        nop \X^tty: link^\c
+.    \}
+.    nop \&\\$3
 .  \}
-.  nop \&\\$3
 .  hy \\n[an*hyphenation-mode]
 ..
 .
@@ -1294,7 +1331,7 @@
      : \n[an*is-output-terminal]) \
 .  nr an*can-hyperlink 1
 .
-.ds an*body-family T \" Times
+.ds an*body-family \n[.fam] \" Times
 .ds an*example-family C \" Courier
 .
 .\" Map monospaced fonts to standard styles for groff's nroff devices.

[-- Attachment #1.3: HEAD.diff --]
[-- Type: text/x-diff, Size: 28709 bytes --]

--- /home/alx/src/gnu/groff/master/tmac/an.tmac	2024-04-14 17:34:47.972728399 +0200
+++ /home/alx/src/linux/man-pages/man-pages/contrib/share/mk/build/pdf/book/an.tmac	2024-03-29 18:34:19.737411869 +0100
@@ -1,6 +1,6 @@
 .\" groff implementation of man(7) package
 .\"
-.\" Copyright (C) 1989-2024 Free Software Foundation, Inc.
+.\" Copyright (C) 1989-2023 Free Software Foundation, Inc.
 .\"      Written by James Clark (jjc@jclark.com)
 .\" Enhanced by: Werner Lemberg <wl@gnu.org>
 .\"              Larry Kollar <kollar@alltel.net>
@@ -110,8 +110,6 @@
 .\" continuous rendering mode.
 .de1 an-end
 .  if !r an-TH-was-called .return
-.  an-input-trap
-.  if '\\n[.z]'an*paragraph-tag' .an*TP-trap
 .  if \\n[cR] \{\
 .    \" We might have a pending output line that is not yet broken, and
 .    \" also be 1v from the bottom of the page.  If we break (or flush)
@@ -130,14 +128,11 @@
 .      pl +1v
 .      nf
 .      ti 0
-.      nr an*rule-length (\\n[LL]u - 1n)
-.      nop \D'l \\n[an*rule-length]u 0'
-.      rr an*rule-length
+.      nop \D'l \\n[LL]u 0'
 .      fi
 .    \}
 .  \}
 .  rr an-TH-was-called
-.  ds an*previous-page-ref-string \" empty
 .  ch an-header
 .  an*break-page-with-new-number
 ..
@@ -148,6 +143,7 @@
 .  rn bp an-real-bp
 .  rn an-ne ne
 .  rn an-bp bp
+.  em an-end
 ..
 .
 .de an*reset-hyphenation-mode
@@ -170,17 +166,14 @@
 .de an-reset-paragraph-spacing
 .  ie \\n[.$] .nr PD (v;\\$1)
 .  el         .nr PD (.4v >? \n[.V])
-.  \" Restore spacing to handle a "belated" `PD` call immediately after
-.  \" a paragraphing macro (`P`, `HP`, or `IP` with no marker argument).
-.  rs
 ..
 .
 .de an-reset-margin-and-inset-level
 .  nr an-inset-level 1
-.  nr an-margin \\n[BP]
-.  nr an-saved-margin!1 \\n[BP]
+.  nr an-margin \\n[IN]
+.  nr an-saved-margin1 \\n[IN]
 .  nr an-prevailing-indent \\n[IN]
-.  nr an-saved-prevailing-indent!1 \\n[IN]
+.  nr an-saved-prevailing-indent1 \\n[IN]
 ..
 .
 .\" Break the page and update its number depending on the C (consecutive
@@ -210,33 +203,27 @@
 .  ds an*section9 Kernel Developer's Manual\"
 ..
 .
-.\" Customize this at the command line to, for example, group multiple
-.\" man pages within a collection or containing document.
-.nr an*bookmark-base-level 0
+.de an*cln
+.  ds \\$1
+.  als an*cln:res \\$1
+.  shift
+.  ds an*cln:res \\$*\"
+.  ds an*cln:char \\*[an*cln:res]
+.  stringdown an*cln:res
+.  substring an*cln:char 0 0
+.  if '\\*[an*cln:char]'\%' .substring an*cln:res 1
+.  rm an*cln:char
+..
 .
 .\" Write a bookmark/anchor/link target $2 at hierarchical depth $1.
 .de an*bookmark
-.  an*bookmark*\*[.T] \\$@
-..
-.
-.ds an*bookmark*ascii \" empty
-.ds an*bookmark*cp1047 \" empty
-.ds an*bookmark*dvi \" empty
-.ds an*bookmark*html \" empty
-.ds an*bookmark*latin1 \" empty
-.ds an*bookmark*lbp \" empty
-.ds an*bookmark*lj4 \" empty
-.ds an*bookmark*ps \" empty
-.ds an*bookmark*utf8 \" empty
-.
-.de an*bookmark*pdf
-.  ie (\\$1 = 1) \
-.    pdfbookmark -T "\\$2" \\$1 \\$2
-.  el \
-.    pdfbookmark \\$1 \\$2
+.  if \\n[an*is-output-pdf] \{\
+.    if (\\n[.$]>2) .an*cln an*page-ref-nm \\$3\"
+.    ie (\\$1=1) .pdfbookmark -T "\\*[an*page-ref-nm]" \\$1 \\$2
+.    el .pdfbookmark \\$1 \\$2
+.  \}
 ..
 .
-.
 .\" Begin man page.
 .\" .TH topic section[ extra1[ extra2[ extra3]]]
 .de1 TH
@@ -291,7 +278,7 @@
 .  \}
 .
 .  \" The previous document rendered in a batch may have been in a
-.  \" different language.
+.  \" different language.  If this one is in English, (re-)init strings.
 .  if '\\*[locale]'english' .an*localize-strings
 .
 .  ps \\n[PS]u
@@ -308,11 +295,11 @@
 .  an-reset-paragraph-spacing
 .  an-reset-margin-and-inset-level
 .
+.  nr an-tag-separation 1n
 .  nr an-need-no-space-mode 0
 .  nr an-need-break 0
-.  nr an*have-paragraph-tag 0
+.  nr an-is-in-diversion 0
 .  nr an*is-in-example 0
-.  nr an*is-in-link-text-diversion 0
 .
 .  ds an*topic "\\$1\"
 .  if \\n[CT] .stringup an*topic
@@ -322,7 +309,11 @@
 .    \" Simulate switch/case in roff.
 .          ie '\\$2'1' .ds an-extra3 \\*[an*section1]\"
 .    el \{.ie '\\$2'2' .ds an-extra3 \\*[an*section2]\"
+.    el \{.ie '\\$2'2type' .ds an-extra3 \\*[an*section2type]\"
 .    el \{.ie '\\$2'3' .ds an-extra3 \\*[an*section3]\"
+.    el \{.ie '\\$2'3const' .ds an-extra3 \\*[an*section3const]\"
+.    el \{.ie '\\$2'3head' .ds an-extra3 \\*[an*section3head]\"
+.    el \{.ie '\\$2'3type' .ds an-extra3 \\*[an*section3type]\"
 .    el \{.ie '\\$2'4' .ds an-extra3 \\*[an*section4]\"
 .    el \{.ie '\\$2'5' .ds an-extra3 \\*[an*section5]\"
 .    el \{.ie '\\$2'6' .ds an-extra3 \\*[an*section6]\"
@@ -330,7 +321,7 @@
 .    el \{.ie '\\$2'8' .ds an-extra3 \\*[an*section8]\"
 .    el \{.ie '\\$2'9' .ds an-extra3 \\*[an*section9]\"
 .    el                .ds an-extra3 \" empty
-.    \}\}\}\}\}\}\}\}
+.    \}\}\}\}\}\}\}\}\}\}\}\}
 .  \}
 .
 .  ds an-extra1 "\\$3\"
@@ -376,19 +367,21 @@
 .    DEVTAG-EO-TL
 .  \}
 .
+.  \" A bookmark is attached to the page header, but only on the first
+.  \" page of the document.
+.  nr an*was-TH-bookmark-emitted 0
 .  an-header
 .
 .  if !\\n[cR] \{\
 .    wh 0 an-header
 .    ie r FT .nr an*footer-location \\n[FT]
-.    el      .nr an*footer-location (-.5i - 1v)
+.    el      .nr an*footer-location (-.5i)
 .    wh \\n[an*footer-location]u an-footer
 .    wh (\\n[an*footer-location]u - .5i) an-break-body-text
 .    rr an*footer-location
 .    \}
 .  \}
 .
-.  em an-end
 .  nr an*need-titles-reset 1
 ..
 .
@@ -445,20 +438,17 @@
 .if d PT .ig
 .de1 PT
 .  ie \\n[cR] .pl +1v
-.  el         .sp (.5i - .5m)
-.  \" Attach a bookmark to the page header on the first page of a new
-.  \" man(7) document; a changed identifier and section indicates this.
-.  if !'\\*[an*page-ref-string]'\\*[an*previous-page-ref-string]' \{\
-.    nr an*bookmark-level (\\n[an*bookmark-base-level] + 1)
-.    an*bookmark \\n[an*bookmark-level]  "\\*[an*page-ref-string]"
-.    ds an*previous-page-ref-string "\\*[an*page-ref-string]
+.  el         .sp .5i
+.  if !\\n[an*was-TH-bookmark-emitted] \{\
+.\" .    an*bookmark 2 \E*[an*page-ref-string]
+.    nr an*was-TH-bookmark-emitted 1
 .  \}
 .  tl '\\*[an-pageref]'\\*[an-extra3]'\\*[an-pageref]'
 .  ie \\n[cR] \{\
 .    pl +1v
 .    sp 1v
 .  \}
-.  el .sp |(1i - 1m)
+.  el .sp |1i
 ..
 .
 .\" Write the page footer; can be redefined by man.local.
@@ -488,6 +478,8 @@
 .  \" PDF bookmarks.
 .  ds an*page-ref-string \\*[an*topic](\\*[an*section])\"
 .  ds an-pageref \\*[an*topic-abbv](\\*[an*section])\"
+.  an*cln an*page-ref-bm-nm \\*[an*topic]_\\*[an*section]\"
+.  stringdown an*page-ref-bm-nm
 .  nr an-header-width \\w'\\*[an-pageref]\\*[an-extra3]\\*[an-pageref]'
 .  while (\\n[an-header-width] >= \\n[.lt]) \{\
 .    \" The page topic is too long; trim some bits out of the middle.
@@ -537,9 +529,9 @@
 .  while (\\n[an*index] < \\n[an*max-index]) \{\
 .    ds an*char \\$*
 .    substring an*char \\n[an*index] \\n[an*index]
-.    ec \x7f
+.    ec @
 .    \" Use a weird delimiter to reduce lexical colorizer confusion.
-.    if _\x7f*[an*char]_\\_ .nr an*string-contains-backslash 1
+.    if _@*[an*char]_\\_ .nr an*string-contains-backslash 1
 .    ec
 .    if \\n[an*string-contains-backslash] .break
 .    nr an*index +1
@@ -616,7 +608,6 @@
 .  PT
 .  ev
 .  ns
-.  if '\*[.T]'pdf' .pdfmarkrestart
 ..
 .
 .\" Schedule a page break when the next output line is written (not
@@ -628,7 +619,6 @@
 .\" Prepare the footer for a page of the document.
 .de1 an-footer
 .  if \\n[an-suppress-header-and-footer] .return
-.  if '\*[.T]'pdf' .pdfmarksuspend
 .  ev an*env-header-and-footer
 .  ie \\n[cR] \
 .    ds an*ofoot "\\*[an-pageref]\"
@@ -649,9 +639,14 @@
 .\" Output the tag of a tagged paragraph, or of an indented paragraph
 .\" (IP) that has a tag.  Whether we break depends on the tag width.
 .de an-write-paragraph-tag
+.  br
+.  di
+.  ad \\*[AD]
+.  nr an-is-in-diversion 0
+.  ll
 .  \" We must emit the diversion in a separate environment to ensure
 .  \" that a possible margin character is printed correctly.
-.  ev an*temporary-env
+.  ev an-env-paragraph-tag
 .  evc 0
 .  mc
 .  nf
@@ -660,12 +655,9 @@
 .  ne (2v + 1u)
 .  \" Does the tag fit within the paragraph indentation?
 .  nr an-tag-fits \
-     (\\n[dl] + (\\n[TS]*\\n[an*enforce-tag-separation]) \
-        <= \\n[an-prevailing-indent])
+     (\\n[dl] + \\n[an-tag-separation] <= \\n[an-prevailing-indent])
 .  if \\n[an-tag-fits] .DEVTAG-COL 1
-.  an*paragraph-tag
-.  rm an*paragraph-tag
-.  nr an*have-paragraph-tag 0
+.  an-div
 .  if \\n[an-tag-fits] .sp -1v
 .  ev
 .  in (\\n[an-margin]u + \\n[an-prevailing-indent]u)
@@ -674,8 +666,8 @@
 ..
 .
 .\" Handle macros that may take an "argument" on the next input line
-.\" producing written or drawn output: .SH, .SS, .B, .I, .SM, .SB.
-.\" For .TP, see below.
+.\" producing written or drawn output: .SH, .SS, .B, .I, .SM, .SB--and
+.\" .TP, which does so mandatorily.
 .de1 an-input-trap
 .  if \\n[an-devtag-needs-end-of-heading] .DEVTAG-EO-H
 .  nr an-devtag-needs-end-of-heading 0
@@ -692,24 +684,7 @@
 .    ns
 .    nr an-need-no-space-mode 0
 .  \}
-.  \" Handle nested traps, as with
-.  \"   .TP
-.  \"   .B foo
-.  \" for instance.
-.  if '\\n[.z]'an*paragraph-tag' \{\
-.    an*TP-trap
-.    gcolor \m[default]
-.  \}
-..
-.
-.\" The TP macro _requires_ a one-line input trap.
-.de1 an*TP-trap
-.  br
-.  di
-.  ad \\n[an*saved-adjustment-mode]
-.  rr an*saved-adjustment-mode
-.  ll
-.  if \\n[an*have-paragraph-tag] .an-write-paragraph-tag
+.  if \\n[an-is-in-diversion] .an-write-paragraph-tag
 ..
 .
 .\" Break a paragraph.  Restore defaults, except for indentation.
@@ -728,7 +703,7 @@
 .  an-break-paragraph
 .  an-reset-margin-and-inset-level
 .  fi
-.  in \\n[BP]u
+.  in \\n[an-margin]u
 .  ti 0
 .  nr an-devtag-needs-end-of-heading 1
 .  DEVTAG-SH 1
@@ -741,11 +716,10 @@
 .  if \\n[an-remap-I-style-in-headings] .ftr I \\*[an-heading-family]BI
 .  if \\n[.$] \{\
 .    ds an-section-heading \\$*\"
-.    if \\n[CS] \
-.      stringup an-section-heading
-.    nr an*bookmark-level (\\n[an*bookmark-base-level] + 2)
-.    an*bookmark \\n[an*bookmark-level] "\\*[an-section-heading]"
-.    nop \&\\*[an-section-heading]
+.    if \\n[CS] .stringup an-section-heading
+.    an*bookmark 3 "\\*[an-section-heading]"
+\&\\*[an-section-heading]
+.  \}
 .  if \\n[an-remap-I-style-in-headings] .ftr I I
 ..
 .
@@ -756,7 +730,7 @@
 .  an-break-paragraph
 .  an-reset-margin-and-inset-level
 .  fi
-.  in \\n[BP]u
+.  in \\n[IN]u
 .  ti \\n[SN]u
 .  nr an-devtag-needs-end-of-heading 1
 .  DEVTAG-SH 2
@@ -769,8 +743,7 @@
 .  if \\n[an-remap-I-style-in-headings] .ftr I \\*[an-heading-family]BI
 .  if \\n[.$] \{\
 .    ds an*subsection-heading \\$*\"
-.    nr an*bookmark-level (\\n[an*bookmark-base-level] + 3)
-.    an*bookmark \\n[an*bookmark-level] "\\*[an*subsection-heading]"
+.    an*bookmark 4 "\\*[an*subsection-heading]"
 .    nop \&\\$*
 .  \}
 .  if \\n[an-remap-I-style-in-headings] .ftr I I
@@ -800,24 +773,9 @@
 .  if \\n[.$] \&\\$*
 ..
 .
-.\" Deprecated: Set arguments (or next input line producing written or
-.\" drawn output if none) in bold style at smaller type size.
-.\"
-.\" This is a SunOS 4.0 extension.
-.\"
-.\" Instead of
-.\"   .SB whatever
-.\" say
-.\"   .SM
-.\"   .B whatever
-.\" or
-.\"   .B
-.\"   .SM whatever
-.\" to portably get an identical effect.
-.\"
-.\" .SB [text]
+.\" Set arguments (or next input line producing written or drawn output
+.\" if none) in bold style at smaller type size.
 .de1 SB
-.  nop \\*[an-deprecation-warn]\\
 .  it 1 an-input-trap
 .  ps -1
 .  ft B
@@ -841,23 +799,19 @@
 .de1 TP
 .  an-break-paragraph
 .  if \\n[.$] .nr an-prevailing-indent (n;\\$1)
-.  if '\\n[.z]'an*paragraph-tag' \{\
-.    an-warn cannot nest .\\$0 or .TQ inside .\\$0; supply a tag
-.    return
-.  \}
-.  nr an*have-paragraph-tag 1
 .  itc 1 an-input-trap
 .  in 0
-.  ll -\\n[an-margin]u
-.  nr an*saved-adjustment-mode \\n[.j]
-.  di an*paragraph-tag
-.  na
+.  if !\\n[an-is-in-diversion] \{\
+.    ll -\\n[an-margin]u
+.    di an-div
+.    na
+.  \}
+.  nr an-is-in-diversion 1
 ..
 .
 .\" Set an indented paragraph.
 .\" .IP [marker[ indentation-amount]]
 .de1 IP
-.  nr an*enforce-tag-separation 0
 .  an-break-paragraph
 .  ie !\\n[.$] \{\
 .    ne (1v + 1u)
@@ -868,13 +822,12 @@
 .    el               .TP
 .    nop \&\\$1
 .  \}
-.  nr an*enforce-tag-separation 1
 ..
 .
 .\" Set a paragraph with a hanging indentation.
 .\" .HP [indent]
 .de1 HP
-.  if !\\n[mS] \\*[an-deprecation-warn]\\
+.  if !\\n[mS] \\*[an-deprecation-warn]\c
 .  an-break-paragraph
 .  ne (1v + 1u)
 .  if \\n[.$] .nr an-prevailing-indent (n;\\$1)
@@ -1019,8 +972,8 @@
 .\" Start a relative inset level (by the amount given in the argument).
 .\" .RS [inset-amount]
 .de1 RS
-.  nr an-saved-margin!\\n[an-inset-level] \\n[an-margin]
-.  nr an-saved-prevailing-indent!\\n[an-inset-level] \
+.  nr an-saved-margin\\n[an-inset-level] \\n[an-margin]
+.  nr an-saved-prevailing-indent\\n[an-inset-level] \
      \\n[an-prevailing-indent]
 .  ie \\n[.$] .nr an-margin +(n;\\$1)
 .  el         .nr an-margin +\\n[an-prevailing-indent]
@@ -1051,19 +1004,14 @@
 .  ie \\n[.$] .nr an-inset-level ((;\\$1) <? \\n[an-inset-level])
 .  el         .nr an-inset-level -1
 .  nr an-inset-level (1 >? \\n[an-inset-level])
-.  nr an-margin \\n[an-saved-margin!\\n[an-inset-level]]
+.  nr an-margin \\n[an-saved-margin\\n[an-inset-level]]
 .  nr an-prevailing-indent \
-     \\n[an-saved-prevailing-indent!\\n[an-inset-level]]
+     \\n[an-saved-prevailing-indent\\n[an-inset-level]]
 .  in \\n[an-margin]u
 ..
 .
 .\" Deprecated: Style an option with an argument (mandatory if
 .\" specified) for a command synopsis.
-.\"
-.\" This is a Documenter's Workbench troff extension.  It is not
-.\" flexible enough to handle GNU-style options like
-.\" `--input=file-name`.  Use font alternation macros instead.
-.\"
 .\" .OP flag [option-parameter]
 .de1 OP
 .  nop \\*[an-deprecation-warn]\\
@@ -1087,29 +1035,16 @@
 .  nr an*saved-paragraph-distance \\n[PD]
 .  nr PD 1v
 .  nf
-.  nr an*unmap-fonts 0
 .  \" If using the DVI output device, we have no constant-width fonts of
 .  \" bold weight and, relatedly, no constant-width family (because that
 .  \" requires all four styles).  Remap the bold styles to normal ones.
-.  \"
-.  \" Use the "switch/case" style of nested `ie`/`el` requests.
-.        ie '\*[.T]'dvi' \{\
+.  ie '\*[.T]'dvi' \{\
 .    ftr R CW
 .    ftr B CW
 .    ftr I CWI
 .    ftr BI CWI
-.    nr an*unmap-fonts 1
-.  \}
-.  \" The LBP output device lacks a Courier bold-italic face.
-.  el \{.ie '\*[.T]'lbp' \{\
-.    ftr R CR
-.    ftr B CB
-.    ftr I CI
-.    ftr BI CI
-.    nr an*unmap-fonts 1
-.  \}
-.  el                    .fam \\*[an*example-family]
 .  \}
+.  el .fam \\*[an*example-family]
 .  ft R
 .  nr an*is-in-example 1
 ..
@@ -1122,12 +1057,11 @@
 .    return
 .  \}
 .  \" Undo the remappings from `EX`.
-.  if \\n[an*unmap-fonts] \{\
+.  ie '\*[.T]'dvi' \{\
 .    ftr R
 .    ftr B
 .    ftr I
 .    ftr BI
-.    rr an*unmap-fonts
 .  \}
 .  fam \\*[an*saved-family]
 .  ft \\n[an*saved-font]
@@ -1141,20 +1075,22 @@
 .
 .\" Store the argument and begin a diversion for link text.
 .de an*begin-hyperlink
-.  ds an*hyperlink \\*[an*prefix]\\$1\"
-.  ds an*visible-hyperlink \\$1\" in case there is no link text
+.  ds an*hyperlink \\$1\"
 .  \" We want the diversion to format as if it has an indentation of
 .  \" zero (that comes for free when we switch environments), and we
-.  \" want the line length reduced by the amount of indentation in
-.  \" effect at the start of the link text.
+.  \" want the line length reduced by the amount of indentation that
+.  \" obtains when we output it.
 .  nr an*saved-line-length \\n[.l]
 .  nr an*saved-indentation \\n[.i]
-.  if \\n[an*do-hyperlink] \{\
+.  \" We can only hyperlink if we're not in a diversion.
+.  \" XXX: There's no fundamental reason for that, just a simple matter
+.  \" of macro programming.
+.  nr an*is-in-link-text-diversion 0
+.  if '\\n(.z'' .nr an*is-in-link-text-diversion 1
+.  if (\\n[an*is-in-link-text-diversion] & \\n[an*do-hyperlink]) \{\
 .    \" Start diversion in a new environment.
-.    nr an*is-in-link-text-diversion 1
 .    ev an*link-text-env
-.    if '\*[.T]'pdf' \&\m[\\*[PDFHREF.TEXT.COLOUR]]\c
-.    di an*link-text
+.    di an*link-text-div
 .    ll (\\n[an*saved-line-length]u - \\n[an*saved-indentation]u)
 .  \}
 .  rr an*saved-indentation
@@ -1168,73 +1104,55 @@
 .\" "mailto:", but this need not be visible when rendering an email
 .\" address on a device incapable of hyperlinking.
 .de an*end-hyperlink
-.  ds an*trailing-text \\$1\"
 .  ie (\\n[an*is-in-link-text-diversion] & \\n[an*do-hyperlink]) \{\
 .    br
 .    di
 .    ev
-.    nr an*is-in-link-text-diversion 0
-.    \" If the diversion width is nonzero, assume there was link text.
-.    ie \\n[dl] \{\
-.      if '\*[.T]'html' \
-.        nop \X'html:<a href="\\*[an*hyperlink]">'\c
-.      if '\*[.T]'pdf' \
-.        pdfhref W -S -D \\*[an*hyperlink]
+.
+.    \" Was any link text present?
+.    ie \\n[dn] \{\
+.      if \\n[an*is-output-html] \
+.        nop \X^html:<a href="\\*[an*prefix]\\*[an*hyperlink]">^\c
 .      if \\n[an*is-output-terminal] \
-.        nop \X'tty: link \\*[an*hyperlink]'\c
-.      unformat an*link-text \" ...so it adjusts in its new context.
-.      \" Replace the final newline of the diversion.
-.      chop an*link-text
-.      as an*link-text \&\c
-.      an*link-text
-.      nop \"
-.      if '\*[.T]'html' \
-.        nop \X'html:</a>'\c
+.        nop \X^tty: link \\*[an*prefix]\\*[an*hyperlink]^\c
+.      \" Strip off the final newline of the diversion and emit it.
+.      chop an*link-text-div
+.      an*link-text-div
+\c\" XXX: If we .nop this, HTML output is corrupted (Savannah #63470).
+.      if \\n[an*is-output-html] \
+.        nop \X^html:</a>^\c
 .      if \\n[an*is-output-terminal] \
-.        nop \X'tty: link'\c
-.      if '\*[.T]'pdf' \X'pdf: markend'\m[default]\c
-.      nop \&\\*[an*trailing-text]\"
+.        nop \X^tty: link^\c
 .    \}
 .    \" If there was no link text, format URI as its own link text.  We
-.    \" don't add angle brackets here; we assume that the application
-.    \" uses some means of indicating the hyperlinked text.
+.    \" don't add angle brackets here.
 .    el \{\
-.      if '\*[.T]'html' \
-.        nop \X'html:<a href="\\*[an*hyperlink]">\
-\\*[an*visible-hyperlink]</a>'\c
-.      if '\*[.T]'pdf' \
-.        pdfhref W -D \\*[an*hyperlink] -A "\\*[an*trailing-text]" \
--- \\*[an*visible-hyperlink]\c
+.      if \\n[an*is-output-html] \
+.        nop \X^html:<a href="\\*[an*prefix]\\*[an*hyperlink]">\
+\\*[an*hyperlink]</a>^\c
 .      if \\n[an*is-output-terminal] \
-.        nop \X'tty: link \\*[an*hyperlink]'\
-\\*[an*visible-hyperlink]\X'tty: link'\c
-.      if !'\*[.T]'pdf' \
-.        nop \&\\*[an*trailing-text]\"
+.        nop \X^tty: link \\*[an*prefix]\\*[an*hyperlink]^\
+\\*[an*hyperlink]\X^tty: link^\c
 .    \}
+.    nop \&\\$1\"
 .  \}
 .  \" If not hyperlinking, format URI in angle brackets.  There was no
 .  \" diversion, so the link text has already been formatted normally.
 .  el \{\
 .    nh
-.    nop \\[la]\\*[an*visible-hyperlink]\\[ra]\\*[an*trailing-text]
+.    nop \\[la]\\*[an*hyperlink]\\[ra]\\$1
 .    hy \\n[an*hyphenation-mode]
 .  \}
-.  rm an*link-text
-.  rm an*hyperlink
-.  rm an*visible-hyperlink
-.  rm an*trailing-text
+.
+.  rr an*is-in-link-text-diversion
 ..
 .
 .\" Begin email hyperlink.  Input until the next `ME` call is stored in
 .\" a diversion; it becomes the link text for the hyperlinked address.
 .\" .MT nobody@example.com
 .de1 MT
-.  if d an*prefix \{\
-.    an-warn cannot nest .\\$0 inside .MT or .UR
-.    return
-.  \}
 .  if !(\\n[.$] = 1) \
-.    an-warn .\\$0 expects 1 argument, got \\n[.$]
+.    an-style-warn .\\$0 expects 1 argument, got \\n[.$]
 .  ds an*prefix mailto:
 .  an*begin-hyperlink \\$1
 ..
@@ -1243,24 +1161,16 @@
 .\" punctuation (or, rarely, other text) after link text.
 .\" .ME [trailing-text]
 .de1 ME
-.  if !d an*prefix \{\
-.    an-warn .\\$0 requires a preceding .MT
-.    return
-.  \}
 .  an*end-hyperlink \\$1
 .  rm an*prefix
 ..
 .
 .\" Begin web hyperlink.  Input until the next `UE` call is stored in
 .\" a diversion; it becomes the link text for the hyperlinked address.
-.\" .UR http://example.com/
+.\" .UR nobody@example.com
 .de1 UR
-.  if d an*prefix \{\
-.    an-warn cannot nest .\\$0 inside .MT or .UR
-.    return
-.  \}
 .  if !(\\n[.$] = 1) \
-.    an-warn .\\$0 expects 1 argument, got \\n[.$]
+.    an-style-warn .\\$0 expects 1 argument, got \\n[.$]
 .  ds an*prefix \" empty
 .  an*begin-hyperlink \\$1
 ..
@@ -1269,10 +1179,6 @@
 .\" punctuation (or, rarely, other text) after link text.
 .\" .UE [trailing-text]
 .de1 UE
-.  if !d an*prefix \{\
-.    an-warn .\\$0 requires a preceding .UR
-.    return
-.  \}
 .  an*end-hyperlink \\$1
 .  rm an*prefix
 ..
@@ -1280,63 +1186,50 @@
 .\" There is no standardized format for man page URLs, but the default
 .\" is expected to work (or be harmlessly ignored) everywhere except
 .\" macOS.  Override in man.local if desired.
-.\"
-.\" Given a man page reference id(section) (like ls(1)), we have these.
-.\"
-.\" man:id(section)                  - GNOME, KDE   (Linux)
-.\" x-man-page://section/id          - Terminal.app (macOS 10.3+)
-.\" man:id.section                   - Bwana        (macOS)
-.\" x-man-doc://section/id(section)  - ManOpen      (macOS)
-.\"
-.\" A configurable prefix/schema string is inadequate because the
-.\" arrangement of the rest of the URL is variable.  Further, the schema
-.\" doesn't unambiguously indicate the remainder of the URL format.
 .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[.$]
-.  ds an*url man:\\$1(\\$2)\"
-.  if (\\n[an*MR-URL-format] = 2) \
-.    ds an*url x-man-page://\\$2/\\$1\"
-.  if (\\n[an*MR-URL-format] = 3) \
-.    ds an*url man:\\$1.\\$2\"
-.  if (\\n[an*MR-URL-format] = 4) \
-.    ds an*url x-man-doc://\\$2/\\$1(\\$2)\"
-.  nh
-.  ie (\\n[.$] = 1) \
-.    nop \&\\*[an-lic]\f[\\*[MF]]\\$1\\*[an-ic]\f[]\c
+.  if ((\\n[.$] < 2) : (\\n[.$] > 4)) \
+.    an-style-warn .\\$0 expects 2 to 4 arguments, got \\n[.$]
+.  ie \\n[an*is-output-pdf] \{\
+.    nh
+.    ds an*title \\\\$4
+.    if '\\\\*[an*title]'' .ds an*title \\\\$1
+.    ie \\n(.$=1 \
+.      I \\$1
+.    el \{\
+.      an*cln an*page-ref-nm \\*[an*title]_\\$2
+.      ie d pdf:look(\\*[an*page-ref-nm]) .pdfhref L -D \\*[an*page-ref-nm] -A "\\$3" -- \fI\\$1\fP(\\$2)
+.      el .IR \\$1 (\\$2)\\$3
+.    \}
+.    hy \\n(mJ
+.  \}
 .  el \{\
+.    ds an*url man:\\$1(\\$2)\" used everywhere but macOS
+.    if (\\n[an*MR-URL-format] = 2) \
+.      ds an*url x-man-page://\\$2/\\$1\" macOS/Mac OS X since 10.3
+.    if (\\n[an*MR-URL-format] = 3) \
+.      ds an*url man:\\$1.\\$2\" Bwana (Mac OS X)
+.    if (\\n[an*MR-URL-format] = 4) \
+.      ds an*url x-man-doc://\\$2/\\$1\" ManOpen (Mac OS X pre-2005)
+.    nh
 .    if \\n[an*do-hyperlink] \{\
-.      if '\*[.T]'html' \
-.        nop \X'html:<a href="\\*[an*url]">'\c
-.      if '\*[.T]'pdf' \{\
-.        ds an*destination-bookmark-tag \\$1(\\$2)\"
-.        pdf:lookup \\*[an*destination-bookmark-tag]
-.        ie !'\\*[pdf:lookup-result]'' \
-.          pdfhref L -S -D \\*[an*destination-bookmark-tag]
-.        el \{\
-.          nop \&\m[\\*[PDFHREF.TEXT.COLOUR]]\c
-.          pdfhref W -S -D \\*[an*url]
-.        \}
-.      \}
+.      if \\n[an*is-output-html] \
+.        nop \X^html:<a href="\\*[an*url]">^\c
 .      if \\n[an*is-output-terminal] \
-.        nop \X'tty: link \\*[an*url]'\c
+.        nop \X^tty: link \\*[an*url]^\c
 .    \}
-.    nop \&\\*[an-lic]\f[\\*[MF]]\\$1\\*[an-ic]\f[R](\\$2)\c
+.        nop \&\\*[an-lic]\f[\\*[MF]]\\$1\\*[an-ic]\f[R](\\$2)\c
 .    if \\n[an*do-hyperlink] \{\
-.      if '\*[.T]'html' \
-.        nop \X'html:</a>'\c
-.      if '\*[.T]'pdf' \{\
-.        nop \X'pdf: markend'\m[default]\c
-.      \}
+.      if \\n[an*is-output-html] \
+.        nop \X^html:</a>^\c
 .      if \\n[an*is-output-terminal] \
-.        nop \X'tty: link'\c
+.        nop \X^tty: link^\c
 .    \}
+.    nop \&\\$3
 .  \}
-.  nop \&\\$3
 .  hy \\n[an*hyphenation-mode]
 ..
 .
@@ -1417,22 +1310,15 @@
 .nr an-devtag-needs-end-of-heading 0
 .nr an-devtag-needs-second-column 0
 .
-.ds an*previous-page-ref-string \" empty
-.
-.nr an*enforce-tag-separation 1
-.
 .\" Track whether the strings that set header and footer text need to be
 .\" reconfigured.  This happens when batch-rendering and starting a new
 .\" page.
 .nr an*need-titles-reset 0
 .
-.\" We don't have to worry about "xhtml" (it's mapped to "html"), but we
-.\" do need to account for pre-grohtml(1)'s use of "groff -Tps".
 .nr an*is-output-html 0
 .if '\*[.T]'html' .nr an*is-output-html 1
-.if r ps4html     .nr an*is-output-html 1
-.
-.\" For most purposes, we treat the nroff devices equivalently.
+.nr an*is-output-pdf 0
+.if '\*[.T]'pdf' .nr an*is-output-pdf 1
 .nr an*is-output-terminal 0
 .if '\*(.T'ascii'  .nr an*is-output-terminal 1
 .if '\*(.T'cp1047' .nr an*is-output-terminal 1
@@ -1441,13 +1327,11 @@
 .
 .nr an*can-hyperlink 0
 .if (  \n[an*is-output-html] \
+     : \n[an*is-output-pdf] \
      : \n[an*is-output-terminal]) \
 .  nr an*can-hyperlink 1
 .
-.if '\*[.T]'pdf' \
-.  nr an*can-hyperlink 1
-.
-.ds an*body-family \n[.fam]
+.ds an*body-family \n[.fam] \" Times
 .ds an*example-family C \" Courier
 .
 .\" Map monospaced fonts to standard styles for groff's nroff devices.
@@ -1471,16 +1355,12 @@
 .\" Set each rendering parameter only if its -[dr] option or man.local
 .\" did not.
 .
-.if '\*[.T]'pdf' \{\
+.if \n[an*is-output-pdf] \{\
 .  \" FIXME: The following registers are documented only in pdf.tmac.
 .  if !r PDFOUTLINE.FOLDLEVEL .nr PDFOUTLINE.FOLDLEVEL 1
 .  if !r PDFHREF.VIEW.LEADING .nr PDFHREF.VIEW.LEADING 10p
 .\}
 .
-.\" base paragraph indentation
-.if !r BP \
-.  nr BP 5n
-.
 .\" continuous rendering (one long page)
 .if !r cR \{\
 .  ie n .nr cR 1
@@ -1491,7 +1371,8 @@
 .\"
 .\" We must use consecutive page numbers when using PostScript to
 .\" generate HTML images; we must not reset the page number at the
-.\" beginning of each document.
+.\" beginning of each document (the 'ps4html' register is automatically
+.\" added to the command line by the pre-HTML preprocessor).
 .ie !r C \
 .  nr C 0
 .el \
@@ -1502,6 +1383,8 @@
 .    \}
 .if \n[an*is-output-html] \
 .  nr C 1
+.if r ps4html \
+.  nr C 1
 .
 .\" diagnostics desired for man page style problems
 .if !r CHECKSTYLE \
@@ -1581,7 +1464,7 @@
 .  \" If in troff mode, respect device default.
 .  ie t .nr LL \n[.l]
 .  \" Otherwise, override nroff mode default of 65n.
-.  el   .nr LL 80n
+.  el   .nr LL 78n
 .\}
 .
 .\" title (header, footer) length
@@ -1620,7 +1503,7 @@
 .\" and whose state is shared with mdoc (and andoc.tmac, if necessary).
 .\"
 .\" Also, we can't use the `P` register with grohtml at all.
-.ie \n[an*is-output-html] \{\
+.ie r ps4html \{\
 .  if r P \{\
 .     tm \*[an]: ignoring starting page number in HTML output
 .     rr P
@@ -1633,10 +1516,6 @@
 .  \}
 .\}
 .
-.\" page offset
-.if r PO \
-.  po \n[PO]u
-.
 .\" type size
 .if !r S \{\
 .  nr S 10
@@ -1646,10 +1525,6 @@
 .    nr S 12
 .\}
 .
-.\" required paragraph tag separation
-.if !r TS \
-.  nr TS 2n
-.
 .\" subsection indentation
 .if !r SN \
 .  nr SN 3n
@@ -1724,6 +1599,7 @@
 .\" If rendering HTML, suppress headers and footers.
 .nr an-suppress-header-and-footer 0
 .if \n[an*is-output-html] .nr an-suppress-header-and-footer 1
+.if r ps4html             .nr an-suppress-header-and-footer 1
 .
 .cp \n[*groff_an_tmac_C]
 .do rr *groff_an_tmac_C

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 15:58       ` Alejandro Colomar
@ 2024-04-14 19:55         ` Alejandro Colomar
  2024-04-14 20:25           ` G. Branden Robinson
  0 siblings, 1 reply; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-14 19:55 UTC (permalink / raw)
  To: G. Branden Robinson; +Cc: Deri James, linux-man


[-- Attachment #1.1: Type: text/plain, Size: 1622 bytes --]

Hi Branden,

On Sun, Apr 14, 2024 at 05:58:09PM +0200, Alejandro Colomar wrote:
> > > However, our an.tmac is not for appending, but for replacing man(7).
> > > :( I'd like to get rid of that an.tmac fork.  Does your message mean
> > > that if I use groff git HEAD to build our book I can just drop the
> > > fork and use man(7), and groff(1) will do the right thing?
> > 
> > I think so, and want to know if it doesn't.  Also, fair warning, Deri
> > said he observed a CRAZY bad performance regression when building the
> > Linux man-pages book with groff Git HEAD.  If you can reproduce that,
> > then I have some work to do.  Let me know.
> 
> Can't reproduce.  I've removed the an.tmac fork, and added -man to
> troff(1)'s invocation, and get the same times.

I forgot to mention that while I can't reproduce the performance
regression, I see a regression in the navigation panel.  When using
groff.git HEAD's an.tmac, the navigation panel doesn't allow collapsing
an entire chapter, while the Linux man-pages fork of it does allow.
Both PDF books are attached to this message.

> $ time make build-pdf-book 2>/dev/null
> GROPDF		.tmp/man-pages-6.7-53-g5125d867d.pdf
> 
> real	0m13.307s
> user	0m16.229s
> sys	0m0.481s
> 
> $ time make build-pdf-book 2>/dev/null
> GROPDF		.tmp/man-pages-6.7-53-g5125d867d-dirty.pdf
> 
> real	0m13.564s
> user	0m17.060s
> sys	0m0.510s
> 
> (I've built all the dependencies before hand, so that only the PDF is
>  built in these invocations.)
> (The -dirty one uses -man.)

Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #1.2: man-pages-6.7-53-g5125d867d.pdf --]
[-- Type: application/pdf, Size: 8848415 bytes --]

[-- Attachment #1.3: man-pages-6.7-53-g5125d867d-dirty.pdf --]
[-- Type: application/pdf, Size: 8886213 bytes --]

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 19:55         ` Alejandro Colomar
@ 2024-04-14 20:25           ` G. Branden Robinson
  2024-04-14 21:06             ` Alejandro Colomar
  0 siblings, 1 reply; 31+ messages in thread
From: G. Branden Robinson @ 2024-04-14 20:25 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: Deri James, linux-man

[-- Attachment #1: Type: text/plain, Size: 2431 bytes --]

Hi Alex,

Wow, I'm envious.  For you, lore let those gigantic attachments through.

At 2024-04-14T21:55:00+0200, Alejandro Colomar wrote:
> I forgot to mention that while I can't reproduce the performance
> regression, I see a regression in the navigation panel.  When using
> groff.git HEAD's an.tmac, the navigation panel doesn't allow
> collapsing an entire chapter, while the Linux man-pages fork of it
> does allow.  Both PDF books are attached to this message.

I see what you mean.

One bet is that I messed something up here and Deri's first or second
hypothesis will be correct.

Here's mine.

You might need to set a register I added in this commit.

commit 5fbc22d022c07f517bc83aa9b8c97ea5536efd18
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sun Mar 3 23:57:38 2024 -0600

    [man]: Add `an*bookmark-base-level` register.

    * tmac/an.tmac: Add experimental feature to support increasing the base
      level of PDF bookmarks.  Define register `an*bookmark-base-level`,
      initialized to zero.

      (PT): Add 1 to it when producing document bookmark.

      (SH): Add 2 to it when producing section heading bookmark.

      (SS): Add 3 to it when producing subsection heading bookmark.

I don't know what you're using to produce the chapter headings in the
navigation panel, but that likely needs to be at level 0 (or 1,
depending on the convention the PDF spec uses).

I added the foregoing feature because it was obvious to me that someone
might want to incorporate a man page collection into a larger work.

I admit I didn't think of the chapter organization application.

So you'd likely do something like this when building with groff Git
HEAD.

  '-r an*bookmark-base-level=1'

Let me know if that works out.

The foregoing is not documented because it needs field testing.  Now
maybe it will get some.

> > $ time make build-pdf-book 2>/dev/null
> > GROPDF		.tmp/man-pages-6.7-53-g5125d867d.pdf
> > 
> > real	0m13.307s
> > user	0m16.229s
> > sys	0m0.481s
> > 
> > $ time make build-pdf-book 2>/dev/null
> > GROPDF		.tmp/man-pages-6.7-53-g5125d867d-dirty.pdf
> > 
> > real	0m13.564s
> > user	0m17.060s
> > sys	0m0.510s
> > 
> > (I've built all the dependencies before hand, so that only the PDF
> > is built in these invocations.)
> > (The -dirty one uses -man.)

This is very good news.

Regards,
Branden

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-14 20:25           ` G. Branden Robinson
@ 2024-04-14 21:06             ` Alejandro Colomar
  0 siblings, 0 replies; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-14 21:06 UTC (permalink / raw)
  To: G. Branden Robinson; +Cc: Deri James, linux-man

[-- Attachment #1: Type: text/plain, Size: 4534 bytes --]

Hi Branden,

On Sun, Apr 14, 2024 at 03:25:28PM -0500, G. Branden Robinson wrote:
> Hi Alex,
> 
> Wow, I'm envious.  For you, lore let those gigantic attachments through.

They've recently changed the infrastructure; maybe something has
changed.  I remember the limit was 100k in the past, while my
attachments were 8.8M each, so it clearly seems to have been lifted.  I
didn't really think too much; we probably don't want to abuse that.
I'll try to be careful.

> At 2024-04-14T21:55:00+0200, Alejandro Colomar wrote:
> > I forgot to mention that while I can't reproduce the performance
> > regression, I see a regression in the navigation panel.  When using
> > groff.git HEAD's an.tmac, the navigation panel doesn't allow
> > collapsing an entire chapter, while the Linux man-pages fork of it
> > does allow.  Both PDF books are attached to this message.
> 
> I see what you mean.
> 
> One bet is that I messed something up here and Deri's first or second
> hypothesis will be correct.
> 
> Here's mine.
> 
> You might need to set a register I added in this commit.
> 
> commit 5fbc22d022c07f517bc83aa9b8c97ea5536efd18
> Author: G. Branden Robinson <g.branden.robinson@gmail.com>
> Date:   Sun Mar 3 23:57:38 2024 -0600
> 
>     [man]: Add `an*bookmark-base-level` register.
> 
>     * tmac/an.tmac: Add experimental feature to support increasing the base
>       level of PDF bookmarks.  Define register `an*bookmark-base-level`,
>       initialized to zero.
> 
>       (PT): Add 1 to it when producing document bookmark.
> 
>       (SH): Add 2 to it when producing section heading bookmark.
> 
>       (SS): Add 3 to it when producing subsection heading bookmark.
> 
> I don't know what you're using to produce the chapter headings in the
> navigation panel, but that likely needs to be at level 0 (or 1,
> depending on the convention the PDF spec uses).
> 
> I added the foregoing feature because it was obvious to me that someone
> might want to incorporate a man page collection into a larger work.
> 
> I admit I didn't think of the chapter organization application.

If you often open the Linux man-pages book you'll realize why you want
it.  If you want to navigate to a page in chapter 7, you don't want to
scroll down 1000+ bookmarks.  You want to close the navigation for the
first 6 chapters (and their subchapters), and easily arrive to
chapter 7.

> 
> So you'd likely do something like this when building with groff Git
> HEAD.
> 
>   '-r an*bookmark-base-level=1'

It doesn't seem to work.  I did the following.  I don't see a behavior
change at all.


diff --git a/share/mk/build/pdf/book/_.mk b/share/mk/build/pdf/book/_.mk
index 166cd28a6..46ede414a 100644
--- a/share/mk/build/pdf/book/_.mk
+++ b/share/mk/build/pdf/book/_.mk
@@ -31,20 +31,21 @@ _PDF_BOOK := $(_PDFDIR)/$(PDF_BOOK)
 
 
 $(_PDF_BOOK): $(_MANPAGES) $(_TINOS) $(MKBOOK) $(MK) | $$(@D)/
	$(info  $(INFO_)GROPDF          $@)
	$(MKBOOKDIR)/prepare.pl $(_MANDIR) \
	| $(CAT) $(MKBOOKDIR)/front.roff /dev/stdin \
	| $(PRECONV) \
	| $(PIC) \
	| $(TBL) \
	| $(EQN) -Tpdf \
-       | $(TROFF) -man -Tpdf -F$(_FONTSDIR) -dpaper=a4 $(TROFFFLAGS) \
+       | $(TROFF) -man -Tpdf -F$(_FONTSDIR) -dpaper=a4 \
+               '-r an*bookmark-base-level=1' $(TROFFFLAGS) \
	| $(GROPDF) -F$(_FONTSDIR) -pa4 $(GROPDFFLAGS) \
	| $(SPONGE) $@
 
 
 .PHONY: build-pdf-book
 build-pdf-book: $(_PDF_BOOK);
 
 
 endif  # include guard


> Let me know if that works out.
> 
> The foregoing is not documented because it needs field testing.  Now
> maybe it will get some.
> 
> > > $ time make build-pdf-book 2>/dev/null
> > > GROPDF		.tmp/man-pages-6.7-53-g5125d867d.pdf
> > > 
> > > real	0m13.307s
> > > user	0m16.229s
> > > sys	0m0.481s
> > > 
> > > $ time make build-pdf-book 2>/dev/null
> > > GROPDF		.tmp/man-pages-6.7-53-g5125d867d-dirty.pdf
> > > 
> > > real	0m13.564s
> > > user	0m17.060s
> > > sys	0m0.510s
> > > 
> > > (I've built all the dependencies before hand, so that only the PDF
> > > is built in these invocations.)
> > > (The -dirty one uses -man.)
> 
> This is very good news.

:-)

BTW, the bookmarks for section headings and subsections don't have a
friendly name; they are of the form `#pdf:bm6`.  Maybe you could form a
name of the form `#intro.1:NOTES:Login`, or whatever form makes sense to
you, but based on the actual text of the bookmark.

Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
       [not found]       ` <3935722.768hzMJKAL@pip>
@ 2024-04-16  1:02         ` Alejandro Colomar
  2024-04-16  2:08           ` G. Branden Robinson
       [not found]           ` <44896690.SEQk1G1hEZ@pip>
  2024-04-16 20:57         ` Alejandro Colomar
                           ` (2 subsequent siblings)
  3 siblings, 2 replies; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-16  1:02 UTC (permalink / raw)
  To: Deri; +Cc: G. Branden Robinson, linux-man

[-- Attachment #1: Type: text/plain, Size: 6204 bytes --]

[CC += linux-man@]

Hi Deri,

On Tue, Apr 16, 2024 at 01:14:12AM +0100, Deri wrote:
> > Maybe we could do the same, to reduce the work of prepare.pl?
> 
> Hi Alex,
> 
> Feel free to have a go. These are the main differences between groff-man-pages 
> (GM) and your book (LM):-
> 
> GM uses -mandoc not -man (by piping custom an.tmac).

I thought of using -mandoc too, for supporting other's pages, possibly
written in mdoc(7).  It shouldn't hurt.

> LM has separate sections so .TH should use bookmark level 2 (not 1).

Hmm.

> (git an.tmac now has:-
> 
> .\" Customize this at the command line to, for example, group multiple
> .\" man pages within a collection or containing document.
> .nr an*bookmark-base-level 0
> 
> so maybe the last stopper from using git head's an.tmac can be circumvented 
> (except of course it won't work - overwritten by zero!!!)).
> 
> GM uses .MR to handle intra-page links, LM uses .pdfhref L. As your desperate 
> to use Branden's code rather than mine,

It's not about using Branden's code or yours.  It's about not having to
effectively maintain a fork of a huge file in the Linux man-pages git
repository, of which I understand little.

> I'll attach a patch which drops 
> an.tmac and uses the HEAD version - you may be disappointed.

I applied a patch earlier today to do this:
<https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib&id=a5c977a5bd3b7b705f4b91f3b375cc68d7122331>

I know the behavior is worse than with the fork that you contributed,
but I've reported the bug to Branden, and I expect he should fix it soon
(especially when you have explained the reason and the fix (and the
reason why his fix didn't work) in your email).

> I don't understand what your doing with the font, why convert to .pfa, why 
> move it - if you have the font just put texlive path into the download file in 
> .tmp/font/devpdf with TINOSR.

I don't understand it either.  That was the reason.  :)
Since you sent me a .pfa file, I kept having a .pfa file.  Nobody told
me I could just use a .pfb.

> The an.patch can be applied to groff, to restore your original section 
> hierarchy.

Thanks!  Branden, would you mind picking it?

> The shadow.patch can be applied to shadow which allows the book to 
> be built without my custom an.tmac, using the patched version.

I see that your patch does more than mine.  It uses pdfmom(1) instead of
troff(1), and it also changes prepare.pl.  Would you mind explaining why
is that done, or why is it necessary?  My patch, which is as simple as
using -man and droping an.tmac, seems to be working as well as before
(except for the section bookmarks).  Although I didn't check thoroughly
the shadow PDF; I may find more problems there, maybe?

> > Hmmm.  Your obvservation about matching the PDF navigator makes sense.
> > Deri, was the removal of -rC1 on purpose?
> 
> I don't really know, since you removed it, so I can't answer as to your 
> intention. The original single perl script which did the whole job had it in:-
> 
>  open(BK,"| ./test-pdfmake -Tpdf -k -pet -M. -mandoc -fTINO -F/usr/share/
> groff/site-font -manmark -rC1 -rCHECKSTYLE=3 > LinuxManBook.pdf");
> 
> You then deconstructed the script for your own edification, and at one stage 
> this was the result:-
> 
> #!/bin/sh
> # Copyright 2023, Alejandro Colomar <alx@kernel.org>
> # SPDX-License-Identifier: GPL-3.0-or-later
> 
> (
>         "$(dirname "$0")"/prepare_linux_man_book.pl "$1" \
>         | preconv \
>         | pic \
>         | tbl \
>         | eqn -Tpdf \
>         | troff -Tpdf -dPDF.EXPORT=1 -dLABEL.REFS=1 -dpaper=a4 \
>                 -M"$(dirname "$0")" -mandoc -manmark -rC1 -rCHECKSTYLE=3 \
>                 2>&1 >/dev/null \
>         | LC_ALL=C grep '^\. *ds ';
> 
>         "$(dirname "$0")"/prepare_linux_man_book.pl "$1";
> ) \
> | preconv \
> | pic \
> | tbl \
> | eqn -Tpdf \
> | (
>         troff -Tpdf -ms <"$(dirname "$0")"/LMBfront.ms;
>         troff -Tpdf -M"$(dirname "$0")" -mandoc -manmark \
>                 -F"$(dirname "$0")" -dpaper=a4 ;
> ) \
> | gropdf -F"$(dirname "$0")" -pa4;
> 
> You can see you have chosen to omit the -rC1 from the second run.

Hmmm, my bad.  I didn't know that it was necessary to specify it in
both runs.

> Then when 
> you decided a need for speed, I rewrote again a single pass version which did 
> not rely on Branden's .MR code at all. Now you want to use similar code as 
> used for the groff_man_pages book (back to using calls to .MR and using pdfmom 
> --roff to satisfy forward references).

Not really.  What I want is to have the script be as simple as possible.
The main problem is that I need to maintain it, but I have little
knowledge of perl(1) (or of PDF or roff(7), BTW).

> > I removed the Tinos.pfa file, since now I generate it at build time
> > from the Tinos.pfb file (installed with Debian's texlive-fonts-extra).
> 
> Completely unnecessary! Gropdf can use .pfb files.

Hmmm.  Didn't know.  Thanks!

> > Either the reorganization, or the generation of the font results in a
> > new warning:
> > 
> > troff:<standard input>:1649: error: cannot load font 'TINOR' to mark it as
> > special
> > 
> 
> Your _FONTSDIR must point to a directory which has a subdirectory called 
> 'devpdf' which holds TINOR and UnifontM and a suitable 'download' file which 
> gives the location of the actual .pf[ab] files (i.e. within texlive - no need 
> to copy it). The difference, with/without, is in the number of glyphs not 
> found messages.

I also need to understand what's that TINOR file, what type of file it
is, and how I can get it.  You gave me two files: the .pfa, and TINOR.
So I can use a .pfb instead of the .pfa; but what about the TINOR file?
How can I get it without maintaining a fork of it?  Also, how can I get
the Unifont files?  I don't see any .pfa or .pfb in any unifont
packages.

alx@debian:~$ apt-file show -x .*unifont.* | grep -i -e pfa -e pfb
alx@debian:~$ 

> 
> Cheers
> 
> Deri

Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-16  1:02         ` Alejandro Colomar
@ 2024-04-16  2:08           ` G. Branden Robinson
  2024-04-16  2:42             ` Alejandro Colomar
       [not found]           ` <44896690.SEQk1G1hEZ@pip>
  1 sibling, 1 reply; 31+ messages in thread
From: G. Branden Robinson @ 2024-04-16  2:08 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: Deri, linux-man

[-- Attachment #1: Type: text/plain, Size: 1996 bytes --]

At 2024-04-16T03:02:28+0200, Alejandro Colomar wrote:
> > > troff:<standard input>:1649: error: cannot load font 'TINOR' to
> > > mark it as special
> > 
> > Your _FONTSDIR must point to a directory which has a subdirectory
> > called 'devpdf' which holds TINOR and UnifontM and a suitable
> > 'download' file which gives the location of the actual .pf[ab] files
> > (i.e. within texlive - no need to copy it). The difference,
> > with/without, is in the number of glyphs not found messages.
> 
> I also need to understand what's that TINOR file, what type of file it
> is, and how I can get it.

This, I can answer.  It is a device-independent troff font description
file.  It is a plain text file in a format documented by Brian Kernighan
originally in CSTR #97 in about 1982, then in the 1992 revision of CSTR
#54, and of course also in the groff_font(5) man page.

The reason for the font description file is that traditionally digital
fonts were (1) restrictively licensed and (2) programs that used fonts
often didn't need the fonts themselves, but just descriptions of what
glyphs they contained and the dimensions ("metrics") of each glyph.  It
is a rendering device that uses a digital font.  A typesetter (or
graphical display system[1]) needs only to know the metrics of the
glyphs to that it can position them appropriately relative to each
other.

This is why when PDF renderers substitute fonts, the result is often so
terribly ugly.  The glyphs of the substituted font are placed in
positions appropriate to a font that may have different metrics.  So
they are crowded or spaced out weirdly, the kerning is off, and so on.

Regards,
Branden

[1] Historically in the X Window System there was a transition from
    "server-side" font rendering to "client-side".  I suspect
    server-side rendering was implemented in the first place to work
    around the expense of digital font licensing.  Someone like Jim
    Gettys would know for sure.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-16  2:08           ` G. Branden Robinson
@ 2024-04-16  2:42             ` Alejandro Colomar
  0 siblings, 0 replies; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-16  2:42 UTC (permalink / raw)
  To: G. Branden Robinson; +Cc: Deri, linux-man

[-- Attachment #1: Type: text/plain, Size: 2130 bytes --]

Hi Branden,

On Mon, Apr 15, 2024 at 09:08:22PM -0500, G. Branden Robinson wrote:
> At 2024-04-16T03:02:28+0200, Alejandro Colomar wrote:
> > > > troff:<standard input>:1649: error: cannot load font 'TINOR' to
> > > > mark it as special
> > > 
> > > Your _FONTSDIR must point to a directory which has a subdirectory
> > > called 'devpdf' which holds TINOR and UnifontM and a suitable
> > > 'download' file which gives the location of the actual .pf[ab] files
> > > (i.e. within texlive - no need to copy it). The difference,
> > > with/without, is in the number of glyphs not found messages.
> > 
> > I also need to understand what's that TINOR file, what type of file it
> > is, and how I can get it.
> 
> This, I can answer.  It is a device-independent troff font description
> file.  It is a plain text file in a format documented by Brian Kernighan
> originally in CSTR #97 in about 1982, then in the 1992 revision of CSTR
> #54, and of course also in the groff_font(5) man page.
> 
> The reason for the font description file is that traditionally digital
> fonts were (1) restrictively licensed and (2) programs that used fonts
> often didn't need the fonts themselves, but just descriptions of what
> glyphs they contained and the dimensions ("metrics") of each glyph.  It
> is a rendering device that uses a digital font.  A typesetter (or
> graphical display system[1]) needs only to know the metrics of the
> glyphs to that it can position them appropriately relative to each
> other.
> 
> This is why when PDF renderers substitute fonts, the result is often so
> terribly ugly.  The glyphs of the substituted font are placed in
> positions appropriate to a font that may have different metrics.  So
> they are crowded or spaced out weirdly, the kerning is off, and so on.

Thanks.  Althoguh this doesn't answer how I can get it in Debian.  And
now I also wonder if I really need this file.  groff(1) is reporting
warnings that it's not able to use it, and it all still works.  Maybe I
don't need it at all?

Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
       [not found]             ` <20240416165157.ml3ntjoozh3mpyzo@illithid>
@ 2024-04-16 20:15               ` Alejandro Colomar
  0 siblings, 0 replies; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-16 20:15 UTC (permalink / raw)
  To: G. Branden Robinson; +Cc: Deri, linux-man

[-- Attachment #1: Type: text/plain, Size: 2435 bytes --]

[CC += linux-man]

Hi Branden,

On Tue, Apr 16, 2024 at 11:51:57AM -0500, G. Branden Robinson wrote:
> At 2024-04-16T15:06:47+0100, Deri wrote:
> > On Tuesday, 16 April 2024 02:02:28 BST Alejandro Colomar wrote:
> > Also I rewrote prepare.pl to not use calls to .MR, to make it faster,
> > which is why you notice no slow down in the run since Branden released
> > code to pdf.tmac, which affected the speed of .MR.
> 
> I want to keep an eye on this.  As soon as I observe/reproduce a major
> performance hit (with _any_ man page collection), I mean to do something
> about it.

I'll let you know how bad it is in the Linux man-pages, once I have
something stable that I understand.

> > > Also, how can I get
> > > the Unifont files?  I don't see any .pfa or .pfb in any unifont
> > > packages.
> > 
> > Do a bit of research on Peter Schaffter's "install-font.sh".
> 
> I forgot to mention afmtodit(1).  The grops(1) and gropdf(1) man pages
> also contain step-by-step procedures 

Some feedback from gropdf(1):

     The  following is a step‐by‐step font installation guide for
     gropdf.

     •  Convert your font to something groff  understands.   This

The first step is already assuming I already have a font.  Too bad.  I
don't have one.  Where's my font?

        is  a  PostScript  Type  1 font in PFA or PFB format, to‐
        gether with an AFM file.  A PFA file begins as follows.

If there any Debian package that provides either a PFA or PFB font for
Unifont?  I haven't found it.  So I don't have a font.  Does it mean
that this procedure doesn't apply to my case?

               %!PS-AdobeFont-1.0:
        A PFB file contains this string as well, preceded by some
        non‐printing bytes.  In the following steps, we will con‐
        sider the use of CTAN’s BrushScriptX‐Italic font  in  PFA
        format.


> for supporting "external" fonts.

(sigh) I guess I need to clarify.  I don't know what's an "external"
font.

> But Peter's script is vastly more convenient for pretty much everyone
> (except maybe distro package maintainers, who have not, as far as I
> know, tried to tackle the problem at all).

Why?  What does it do better or worse?  I find it more convenient to use
something that I can apt-get(1) install, and that's not the case here.


Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
       [not found]       ` <3935722.768hzMJKAL@pip>
  2024-04-16  1:02         ` Alejandro Colomar
@ 2024-04-16 20:57         ` Alejandro Colomar
  2024-04-16 23:17           ` Deri
  2024-04-18  0:44         ` Alejandro Colomar
  2024-04-18  1:08         ` Alejandro Colomar
  3 siblings, 1 reply; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-16 20:57 UTC (permalink / raw)
  To: Deri; +Cc: G. Branden Robinson, linux-man

[-- Attachment #1: Type: text/plain, Size: 659 bytes --]

Hi Deri,

On Tue, Apr 16, 2024 at 01:14:12AM +0100, Deri wrote:
> I don't understand what your doing with the font, why convert to .pfa, why 
> move it - if you have the font just put texlive path into the download file in 
> .tmp/font/devpdf with TINOSR.

Something is inconsistent here.  The file is named TINOR, not TINOSR.
Was that a typo?  Should I rename it?  I've moved it to .../devpdf and
added the download file, and it still doesn't work.

<https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib&id=d8d06c9c66bf32fb88e860219bd66149e5813948>

Cheers,
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-16 20:57         ` Alejandro Colomar
@ 2024-04-16 23:17           ` Deri
  2024-04-17  9:54             ` Alejandro Colomar
  0 siblings, 1 reply; 31+ messages in thread
From: Deri @ 2024-04-16 23:17 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: G. Branden Robinson, linux-man

[-- Attachment #1: Type: text/plain, Size: 1033 bytes --]

On Tuesday, 16 April 2024 21:57:41 BST Alejandro Colomar wrote:
>  I've moved it to .../devpdf and
> added the download file, and it still doesn't work.
 Hi Alex,

What was not clear when I wrote:-

"Your _FONTSDIR must point to a directory which has a subdirectory called 
'devpdf' which holds TINOR and UnifontM and a suitable 'download' file which 
gives the location of the actual .pf[ab] files (i.e. within texlive - no need 
to copy it). The difference, with/without, is in the number of glyphs not 
found messages."

But instead you changed _FONTSDIR to point to devpdf.

The difference in the pages between having working and non-working fonts is 
seen in the attached example pages (compare with your book). These in fact are 
using UnifontM. TINOR provides the cyrillic glyphs and greek of the iso_8859 
pages if I remember.

You can still see some gaps (which should not happen using UnifontM) they 
appear to be caused by an issue in one of Branden's commits, see:-

https://savannah.gnu.org/bugs/?65601

Cheers

Deri




[-- Attachment #2: LMB-working-fonts.pdf --]
[-- Type: application/pdf, Size: 122654 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-16 23:17           ` Deri
@ 2024-04-17  9:54             ` Alejandro Colomar
  2024-04-17  9:56               ` Alejandro Colomar
  0 siblings, 1 reply; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-17  9:54 UTC (permalink / raw)
  To: Deri; +Cc: G. Branden Robinson, linux-man

[-- Attachment #1: Type: text/plain, Size: 1437 bytes --]

Hi Deri,

On Wed, Apr 17, 2024 at 12:17:18AM +0100, Deri wrote:
> On Tuesday, 16 April 2024 21:57:41 BST Alejandro Colomar wrote:
> >  I've moved it to .../devpdf and
> > added the download file, and it still doesn't work.
>  Hi Alex,
> 
> What was not clear when I wrote:-
> 
> "Your _FONTSDIR must point to a directory which has a subdirectory called 
> 'devpdf' which holds TINOR and UnifontM and a suitable 'download' file which 
> gives the location of the actual .pf[ab] files (i.e. within texlive - no need 
> to copy it). The difference, with/without, is in the number of glyphs not 
> found messages."
> 
> But instead you changed _FONTSDIR to point to devpdf.

Sorry, I misread.  Fixed:
<https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib>

Now I get some new warnings.  :)

> The difference in the pages between having working and non-working fonts is 
> seen in the attached example pages (compare with your book). These in fact are 
> using UnifontM. TINOR provides the cyrillic glyphs and greek of the iso_8859 
> pages if I remember.
> 
> You can still see some gaps (which should not happen using UnifontM) they 
> appear to be caused by an issue in one of Branden's commits, see:-
> 
> https://savannah.gnu.org/bugs/?65601

Thanks!

Have a lovely day!
Alex

> 
> Cheers
> 
> Deri
> 
> 
> 



-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-17  9:54             ` Alejandro Colomar
@ 2024-04-17  9:56               ` Alejandro Colomar
  2024-04-17 10:28                 ` Deri
  0 siblings, 1 reply; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-17  9:56 UTC (permalink / raw)
  To: Deri; +Cc: G. Branden Robinson, linux-man

[-- Attachment #1: Type: text/plain, Size: 1708 bytes --]

On Wed, Apr 17, 2024 at 11:54:21AM +0200, Alejandro Colomar wrote:
> Hi Deri,
> 
> On Wed, Apr 17, 2024 at 12:17:18AM +0100, Deri wrote:
> > On Tuesday, 16 April 2024 21:57:41 BST Alejandro Colomar wrote:
> > >  I've moved it to .../devpdf and
> > > added the download file, and it still doesn't work.
> >  Hi Alex,
> > 
> > What was not clear when I wrote:-
> > 
> > "Your _FONTSDIR must point to a directory which has a subdirectory called 
> > 'devpdf' which holds TINOR and UnifontM and a suitable 'download' file which 
> > gives the location of the actual .pf[ab] files (i.e. within texlive - no need 
> > to copy it). The difference, with/without, is in the number of glyphs not 
> > found messages."
> > 
> > But instead you changed _FONTSDIR to point to devpdf.
> 
> Sorry, I misread.  Fixed:
> <https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib>
> 
> Now I get some new warnings.  :)

(I guess that I'll need to regenerate TINOR too.)

> 
> > The difference in the pages between having working and non-working fonts is 
> > seen in the attached example pages (compare with your book). These in fact are 
> > using UnifontM. TINOR provides the cyrillic glyphs and greek of the iso_8859 
> > pages if I remember.
> > 
> > You can still see some gaps (which should not happen using UnifontM) they 
> > appear to be caused by an issue in one of Branden's commits, see:-
> > 
> > https://savannah.gnu.org/bugs/?65601
> 
> Thanks!
> 
> Have a lovely day!
> Alex
> 
> > 
> > Cheers
> > 
> > Deri
> > 
> > 
> > 
> 
> 
> 
> -- 
> <https://www.alejandro-colomar.es/>



-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-17  9:56               ` Alejandro Colomar
@ 2024-04-17 10:28                 ` Deri
  2024-04-17 10:33                   ` Alejandro Colomar
  0 siblings, 1 reply; 31+ messages in thread
From: Deri @ 2024-04-17 10:28 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: G. Branden Robinson, linux-man

On Wednesday, 17 April 2024 10:56:00 BST Alejandro Colomar wrote:
> On Wed, Apr 17, 2024 at 11:54:21AM +0200, Alejandro Colomar wrote:
> > Hi Deri,

Hi Alex,

[...]
> > Now I get some new warnings.  :)

Is it a secret?

> (I guess that I'll need to regenerate TINOR too.)

Its not a good idea when you are guessing.

Cheers

Deri




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-17 10:28                 ` Deri
@ 2024-04-17 10:33                   ` Alejandro Colomar
  2024-04-17 20:01                     ` Deri
  0 siblings, 1 reply; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-17 10:33 UTC (permalink / raw)
  To: Deri; +Cc: G. Branden Robinson, linux-man

[-- Attachment #1: Type: text/plain, Size: 335 bytes --]

Hi Deri,

On Wed, Apr 17, 2024 at 11:28:07AM +0100, Deri wrote:
> [...]
> > > Now I get some new warnings.  :)
> 
> Is it a secret?

No, but they contain binary.  Here's an example:

gropdf:zic.8: warning: Don't understand 'dup 0 11 -| �����B4fD�" |'

Cheers,
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-17 10:33                   ` Alejandro Colomar
@ 2024-04-17 20:01                     ` Deri
  2024-04-17 20:48                       ` Alejandro Colomar
  0 siblings, 1 reply; 31+ messages in thread
From: Deri @ 2024-04-17 20:01 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: G. Branden Robinson, linux-man

On Wednesday, 17 April 2024 11:33:58 BST Alejandro Colomar wrote:
> No, but they contain binary.  Here's an example:
> 
> gropdf:zic.8: warning: Don't understand 'dup 0 11 -| �����B4fD�" |'
> 
> Cheers,
> Alex

Aah, this comes from the new font subsetting code in gropdf. I have not seen a 
font quite like this before, most fonts used with groff have been converted 
from a .ttf/.otf by running it through fontforge.If you are interested in the 
gory details look at the git log for the fix just committed to the groff git.

Cheers 

Deri




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-17 20:01                     ` Deri
@ 2024-04-17 20:48                       ` Alejandro Colomar
  2024-04-18  0:26                         ` Deri
  0 siblings, 1 reply; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-17 20:48 UTC (permalink / raw)
  To: Deri; +Cc: G. Branden Robinson, linux-man

[-- Attachment #1: Type: text/plain, Size: 1992 bytes --]

Hi Deri,

On Wed, Apr 17, 2024 at 09:01:01PM +0100, Deri wrote:
> On Wednesday, 17 April 2024 11:33:58 BST Alejandro Colomar wrote:
> > No, but they contain binary.  Here's an example:
> > 
> > gropdf:zic.8: warning: Don't understand 'dup 0 11 -| �����B4fD�" |'
> 
> Aah, this comes from the new font subsetting code in gropdf. I have not seen a 
> font quite like this before, most fonts used with groff have been converted 
> from a .ttf/.otf by running it through fontforge.If you are interested in the 
> gory details look at the git log for the fix just committed to the groff git.

Thanks!  However, I can still see that warning.  I've installed groff
from git HEAD:

	$ git describe 
	1.23.0-1149-g5589bcd18
	$ git log -1 | head
	commit 5589bcd18776c6d236c53226a0ee30506180e6b6
	Author: Deri James <deri@chuzzlewit.myzen.co.uk>
	Date:   Wed Apr 17 19:25:03 2024 +0100

	    Improve font parsing.
	    
	    The usual (for fontforge converted ttf fonts) is to use the RD, ND
	    and NP operators within charstring definitions, however these are
	    just named in the private subrs dictionary so could be assigned
	    any name.


And here's the warning in the man-pages' contrib branch:

	$ make clean
	RM -rf		.tmp
	$ groff --version | head -n1
	GNU groff version 1.23.0.1149-5589
	$ make build-pdf-book -j24 >/dev/null 2>&1
	$ rm .tmp/man-pages-6.7-63-ga4f3afd28.pdf 
	$ make build-pdf-book
	GROPDF		.tmp/man-pages-6.7-63-ga4f3afd28.pdf
	troff:fanotify_init.2:322: warning [page 192, 4.2i]: cannot adjust line
	troff:membarrier.2:272: warning [page 475, 3.0i]: cannot adjust line
	statx.2:240: warning: table wider than line length minus indentation
	troff:syscall.2:171: warning: cannot select font 'CW'
	troff:syscall.2:301: warning: cannot select font 'CW'
	...
	gropdf:zic.8: warning: Don't understand 'dup 0 11 -| �����B4fD�" |'


Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-17 20:48                       ` Alejandro Colomar
@ 2024-04-18  0:26                         ` Deri
  2024-04-18  1:09                           ` Alejandro Colomar
  0 siblings, 1 reply; 31+ messages in thread
From: Deri @ 2024-04-18  0:26 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: G. Branden Robinson, linux-man

On Wednesday, 17 April 2024 21:48:04 BST Alejandro Colomar wrote:
> Hi Deri,
> 
> On Wed, Apr 17, 2024 at 09:01:01PM +0100, Deri wrote:
> > On Wednesday, 17 April 2024 11:33:58 BST Alejandro Colomar wrote:
> > > No, but they contain binary.  Here's an example:
> > > 
> > > gropdf:zic.8: warning: Don't understand 'dup 0 11 -| �����B4fD�" |'
> > 
> > Aah, this comes from the new font subsetting code in gropdf. I have not
> > seen a font quite like this before, most fonts used with groff have been
> > converted from a .ttf/.otf by running it through fontforge.If you are
> > interested in the gory details look at the git log for the fix just
> > committed to the groff git.
> Thanks!  However, I can still see that warning.  I've installed groff
> from git HEAD:
> 
> 	$ git describe
> 	1.23.0-1149-g5589bcd18
> 	$ git log -1 | head
> 	commit 5589bcd18776c6d236c53226a0ee30506180e6b6
> 	Author: Deri James <deri@chuzzlewit.myzen.co.uk>
> 	Date:   Wed Apr 17 19:25:03 2024 +0100
> 
> 	    Improve font parsing.
> 
> 	    The usual (for fontforge converted ttf fonts) is to use the RD, ND
> 	    and NP operators within charstring definitions, however these are
> 	    just named in the private subrs dictionary so could be assigned
> 	    any name.
> 
> 
> And here's the warning in the man-pages' contrib branch:
> 
> 	$ make clean
> 	RM -rf		.tmp
> 	$ groff --version | head -n1
> 	GNU groff version 1.23.0.1149-5589
> 	$ make build-pdf-book -j24 >/dev/null 2>&1
> 	$ rm .tmp/man-pages-6.7-63-ga4f3afd28.pdf
> 	$ make build-pdf-book
> 	GROPDF		.tmp/man-pages-6.7-63-ga4f3afd28.pdf
> 	troff:fanotify_init.2:322: warning [page 192, 4.2i]: cannot adjust 
line
> 	troff:membarrier.2:272: warning [page 475, 3.0i]: cannot adjust line
> 	statx.2:240: warning: table wider than line length minus indentation
> 	troff:syscall.2:171: warning: cannot select font 'CW'
> 	troff:syscall.2:301: warning: cannot select font 'CW'
> 	...
> 	gropdf:zic.8: warning: Don't understand 'dup 0 11 -| �����B4fD�" |'
> 
> 
> Have a lovely night!
> Alex

Hi Alex,

While testing I used a document just using the debian TinosR font, no problem. 
Issue occurs when both types of font are used in one document. I have now 
pushed the fix to groff. Please try again.

Cheers 

Deri







^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
       [not found]       ` <3935722.768hzMJKAL@pip>
  2024-04-16  1:02         ` Alejandro Colomar
  2024-04-16 20:57         ` Alejandro Colomar
@ 2024-04-18  0:44         ` Alejandro Colomar
  2024-04-18  1:08         ` Alejandro Colomar
  3 siblings, 0 replies; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-18  0:44 UTC (permalink / raw)
  To: Deri; +Cc: G. Branden Robinson, linux-man

[-- Attachment #1: Type: text/plain, Size: 5128 bytes --]

Hi Deri,

On Tue, Apr 16, 2024 at 01:14:12AM +0100, Deri wrote:
> diff --git a/share/mk/build/pdf/book/prepare.pl b/share/mk/build/pdf/book/prepare.pl
> index e23f149c6..bc922bd88 100755
> --- a/share/mk/build/pdf/book/prepare.pl
> +++ b/share/mk/build/pdf/book/prepare.pl
> @@ -1,4 +1,4 @@
> -#!/usr/bin/perl -w
> +#!/usr/bin/perl -wd
>  #
>  #	BuildLinuxMan.pl		: Build Linux manpages book
>  #	Deri James (& Brian Inglis)	: 15 Dec 2022
> @@ -49,16 +49,16 @@ my $dir2=$dir;
>  $dir2=~tr[.][_];
>  my %files;
>  my %aliases;
> -my %target;
> +my %revalias;
>  
>  foreach my $al (`find "$dir"/man*/ -type f \\
>  		| grep "\\.[[:digit:]]\\([[:alpha:]][[:alnum:]]*\\)\\?\\>\$" \\
>  		| xargs grep '^\\.so' /dev/null;`)
>  {
>  	#$al=~tr[.][_];
> -	$al=~m/^$dir\/man\d[a-z]*\/(.*):\.\s*so\s*man\d[a-z]*\/(.*)/o;
> +	$al=~m/^$dir\/man\d[a-z]*\/(.*):\.\s*so\s*man\d[a-z]*\/(.*?)\.(.*)/o;

Your annotation said:

	-	$al=~m/^$dir\/man\d[a-z]*\/(.*):\.\s*so\s*man\d[a-z]*\/(.*)/o;
	+	$al=~m/^$dir\/man\d[a-z]*\/(.*):\.\s*so\s*man\d[a-z]*\/(.*?)\.(.*)/o;
	Example:-
	./man2/rt_sigaction.2:.so man2/sigaction.2
	==============
	========= =
	$1
	$2
	$3
	Capture the file name extension in $3.

But the regex is wrong, I think.  Consider this part of the regex:

	(.*?)\.(.*)

For a page like gai.conf.5, the section would be 'conf.5'.  The '?' is
spurious, I think.

>  
> -	$aliases{$1}=$2;
> +	$aliases{$1}="$2($3)";
>  }
>  
>  while (my ($k,$v)=each %aliases)
> @@ -68,13 +68,18 @@ while (my ($k,$v)=each %aliases)
>  	}
>  }
>  
> +while (my ($k,$v)=each %aliases)
> +{
> +	push(@{$revalias{$v}},$k);
> +}
> +
>  foreach my $fn (`find "$dir"/man*/ -type f \\
>  		| grep "\\.[[:digit:]]\\([[:alpha:]][[:alnum:]]*\\)\\?\\>\$";`)
>  {
>  	$fn=~s/\n//;
>  
>  	my ($nm,$sec)=GetNmSec($fn,qr/\.\d[a-z]*/);
> -	$files{"${nm}.$sec"}=[$fn,(exists($aliases{"${nm}.$sec"}))?$aliases{"${nm}.$sec"}:"${nm}.$sec"];
> +	$files{"${nm}.$sec"}=[$fn,(exists($aliases{"${nm}.$sec"}))?$aliases{"${nm}.$sec"}:"${nm}($sec)"];
>  }
>  
>  my $Section='';
> @@ -97,7 +102,7 @@ sub BuildPage
>  	my $fn=$files{$bkmark}->[0];
>  	my ($nm,$sec,$srt)=GetNmSec($bkmark,qr/\.[\da-z]+/);
>  
> -	my $title= "$nm\\($sec\\)";
> +	my $title= "$nm($sec)";
>  
>  	print ".\\\" >>>>>> $nm($sec) <<<<<<\n.lf 0 $bkmark\n";
>  
> @@ -112,8 +117,10 @@ sub BuildPage
>  		$Section=$sec;
>  	}
>  
> -	if (exists($aliases{$bkmark})) {
> +	if (exists($aliases{$bkmark}))
> +	{
>  		print ".eo\n.device ps:exec [/Dest /$aliases{$bkmark} /Title ($title) /Level 2 /OUT pdfmark\n.ec\n.fl\n";
> +# 		print ".pdfbookmark 2 $nm($sec)";
>  		return;
>  	}
>  
> @@ -137,7 +144,7 @@ sub BuildPage
>  
>  			s/\\-/-/g if /^\.[BM]R\s+/;
>  
> -			if (m/^\.BR\s+([-\w\\.]+)\s+\((.+?)\)(.*)/ or m/^\.MR\s+([-\w\\.]+)\s+(\w+)\s+(.*)/ or m/^\\fB([-\w\\.]+)\\fR\((.+?)\)(.*)$/) {
> +			if (m/^\.BR\s+([-\w\\.]+)\s+\(([\d\w]+?)\)(.*)/ or m/^\.MR\s+([-\w\\.]+)\s+(\w+)\s+(.*)/ or m/^\\fB([-\w\\.]+)\\fR\((.+?)\)(.*)$/) {

This regex might have similar issues (although they aren't being
introduced now).  And there might be others too.

BTW, your annotation was:

	Not completely sure if this change is necessary, just nervous
	about (.+?) as a pattern.

Agree; but there are more (.+?) in the same regex.


Have a lovely night!
Alex

>  				my $bkmark="$1";
>  				my $sec=$2;
>  				my $after=$3;
> @@ -145,12 +152,7 @@ sub BuildPage
>  				my $dest=$bkmark;
>  				$dest=~s/\\-/-/g;
>  
> -				if (exists($files{"${bkmark}.$sec"})) {
> -					my $dest=$files{"${bkmark}.$sec"}->[1];
> -					$_=".pdfhref L -D \"$dest\" -A \"$after\" -- \\fI$bkmark\\fP($sec)";
> -				} else {
> -					$_=".IR $bkmark ($sec)\\c\n$after";
> -				}
> +				$_=".MR \"$bkmark\" $sec $after";
>  			}
>  
>  			s/^\.BI \\fB/.BI /;
> @@ -175,16 +177,20 @@ sub BuildPage
>  				s/\n\n/\n/g;
>  			}
>  
> -			s/\\&\././ if m/^.TH /;
> -
> -			if (m/^\.TH\s+"?([-\w\\.]+)"?\s+"?(\w+)"?/) {
> -
> -				print "$_\n";
> -
> -				# Add a level two bookmark. We don't set it in the TH macro since the name passed
> -				# may be different from the filename, i.e. file = unimplemented.2, TH = UNIMPLEMENTED 2
> -
> -				print ".pdfbookmark -T $bkmark 2 $nm($sec)\n";
> +# 			s/\\&\././ if m/^.TH /;
> +#
> + 			if (m/^\.TH\s+"?([-\w\\.]+)"?\s+"?(\w+)"?(.*)/)
> + 			{
> +				print ".TH \"$nm\" \"$2\" $3\n";
> +
> +				if (exists($revalias{"$nm($sec)"}))
> +				{
> +					foreach my $dest (@{$revalias{"$nm($sec)"}})
> +					{
> +						my ($nm,$sec,$srt)=GetNmSec($dest,qr/\.[\da-z]+/);
> +						print ".pdfhref M -D $nm($sec)\n";
> +					}
> +				}
>  
>  				next;
>  			}
> @@ -199,11 +205,8 @@ sub doMR
>  	my $nm=shift;
>  	my $sec=shift;
>  
> -	if (exists($files{"${nm}.$sec"})) {
> -		return("\n.pdfhref L -D \"$files{\"${nm}.$sec\"}->[1]\" -A \"\\c\" -- \\fI$nm\\fP($sec)\n");
> -	} else {
> -		return("\\fI$nm\\fP($sec)");
> -	}
> +	return "\n.MR $nm $sec";
> +
>  }
>  
>  sub GetNmSec


-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
       [not found]       ` <3935722.768hzMJKAL@pip>
                           ` (2 preceding siblings ...)
  2024-04-18  0:44         ` Alejandro Colomar
@ 2024-04-18  1:08         ` Alejandro Colomar
  3 siblings, 0 replies; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-18  1:08 UTC (permalink / raw)
  To: G. Branden Robinson; +Cc: Deri, linux-man

[-- Attachment #1: Type: text/plain, Size: 6148 bytes --]

Hi Branden,

After applying Deri's patches, I can see the turtle.

real	2m20.018s
user	2m34.825s
sys	0m0.571s

Before that patch, it's

real	0m14.576s
user	0m18.171s
sys	0m0.464s


That means groff(1) is being ~9x slower.

Have a lovely night!
Alex

On Tue, Apr 16, 2024 at 01:14:12AM +0100, Deri wrote:
> diff --git a/tmac/an.tmac b/tmac/an.tmac
> index d9e8232f8..46934fd62 100644
> --- a/tmac/an.tmac
> +++ b/tmac/an.tmac
> @@ -212,7 +212,7 @@
>  .
>  .\" Customize this at the command line to, for example, group multiple
>  .\" man pages within a collection or containing document.
> -.nr an*bookmark-base-level 0
> +.nr an*bookmark-base-level \n[an*bookmark-base-level]+0
>  .
>  .\" Write a bookmark/anchor/link target $2 at hierarchical depth $1.
>  .de an*bookmark
> @@ -230,7 +230,8 @@
>  .ds an*bookmark*utf8 \" empty
>  .
>  .de an*bookmark*pdf
> -.  ie (\\$1 = 1) \
> +.nr an:lev \\n[an*bookmark-base-level]+1
> +.  ie (\\$1 = \\n[an:lev]) \
>  .    pdfbookmark -T "\\$2" \\$1 \\$2
>  .  el \
>  .    pdfbookmark \\$1 \\$2

> diff --git a/share/mk/build/pdf/book/_.mk b/share/mk/build/pdf/book/_.mk
> index 3395e67e9..9f1cdc520 100644
> --- a/share/mk/build/pdf/book/_.mk
> +++ b/share/mk/build/pdf/book/_.mk
> @@ -33,12 +33,12 @@ _PDF_BOOK := $(_PDFDIR)/$(PDF_BOOK)
>  $(_PDF_BOOK): $(_MANPAGES) $(_TINOS) $(MKBOOK) $(MK) | $$(@D)/
>  	$(info	$(INFO_)GROPDF		$@)
>  	$(MKBOOKDIR)/prepare.pl $(_MANDIR) \
> -	| $(CAT) $(MKBOOKDIR)/front.roff $(MKBOOKDIR)/an.tmac /dev/stdin \
> +	| $(CAT) $(MKBOOKDIR)/front.roff /dev/stdin \
>  	| $(PRECONV) \
>  	| $(PIC) \
>  	| $(TBL) \
>  	| $(EQN) -Tpdf \
> -	| $(TROFF) -Tpdf -F$(_FONTSDIR) -dpaper=a4 $(TROFFFLAGS) \
> +	| pdfmom --roff -F$(_FONTSDIR) -man -r an*bookmark-base-level=1 -dpaper=a4 $(TROFFFLAGS) -Z \
>  	| $(GROPDF) -F$(_FONTSDIR) -pa4 $(GROPDFFLAGS) \
>  	| $(SPONGE) $@
>  
> diff --git a/share/mk/build/pdf/book/prepare.pl b/share/mk/build/pdf/book/prepare.pl
> index e23f149c6..bc922bd88 100755
> --- a/share/mk/build/pdf/book/prepare.pl
> +++ b/share/mk/build/pdf/book/prepare.pl
> @@ -1,4 +1,4 @@
> -#!/usr/bin/perl -w
> +#!/usr/bin/perl -wd
>  #
>  #	BuildLinuxMan.pl		: Build Linux manpages book
>  #	Deri James (& Brian Inglis)	: 15 Dec 2022
> @@ -49,16 +49,16 @@ my $dir2=$dir;
>  $dir2=~tr[.][_];
>  my %files;
>  my %aliases;
> -my %target;
> +my %revalias;
>  
>  foreach my $al (`find "$dir"/man*/ -type f \\
>  		| grep "\\.[[:digit:]]\\([[:alpha:]][[:alnum:]]*\\)\\?\\>\$" \\
>  		| xargs grep '^\\.so' /dev/null;`)
>  {
>  	#$al=~tr[.][_];
> -	$al=~m/^$dir\/man\d[a-z]*\/(.*):\.\s*so\s*man\d[a-z]*\/(.*)/o;
> +	$al=~m/^$dir\/man\d[a-z]*\/(.*):\.\s*so\s*man\d[a-z]*\/(.*?)\.(.*)/o;
>  
> -	$aliases{$1}=$2;
> +	$aliases{$1}="$2($3)";
>  }
>  
>  while (my ($k,$v)=each %aliases)
> @@ -68,13 +68,18 @@ while (my ($k,$v)=each %aliases)
>  	}
>  }
>  
> +while (my ($k,$v)=each %aliases)
> +{
> +	push(@{$revalias{$v}},$k);
> +}
> +
>  foreach my $fn (`find "$dir"/man*/ -type f \\
>  		| grep "\\.[[:digit:]]\\([[:alpha:]][[:alnum:]]*\\)\\?\\>\$";`)
>  {
>  	$fn=~s/\n//;
>  
>  	my ($nm,$sec)=GetNmSec($fn,qr/\.\d[a-z]*/);
> -	$files{"${nm}.$sec"}=[$fn,(exists($aliases{"${nm}.$sec"}))?$aliases{"${nm}.$sec"}:"${nm}.$sec"];
> +	$files{"${nm}.$sec"}=[$fn,(exists($aliases{"${nm}.$sec"}))?$aliases{"${nm}.$sec"}:"${nm}($sec)"];
>  }
>  
>  my $Section='';
> @@ -97,7 +102,7 @@ sub BuildPage
>  	my $fn=$files{$bkmark}->[0];
>  	my ($nm,$sec,$srt)=GetNmSec($bkmark,qr/\.[\da-z]+/);
>  
> -	my $title= "$nm\\($sec\\)";
> +	my $title= "$nm($sec)";
>  
>  	print ".\\\" >>>>>> $nm($sec) <<<<<<\n.lf 0 $bkmark\n";
>  
> @@ -112,8 +117,10 @@ sub BuildPage
>  		$Section=$sec;
>  	}
>  
> -	if (exists($aliases{$bkmark})) {
> +	if (exists($aliases{$bkmark}))
> +	{
>  		print ".eo\n.device ps:exec [/Dest /$aliases{$bkmark} /Title ($title) /Level 2 /OUT pdfmark\n.ec\n.fl\n";
> +# 		print ".pdfbookmark 2 $nm($sec)";
>  		return;
>  	}
>  
> @@ -137,7 +144,7 @@ sub BuildPage
>  
>  			s/\\-/-/g if /^\.[BM]R\s+/;
>  
> -			if (m/^\.BR\s+([-\w\\.]+)\s+\((.+?)\)(.*)/ or m/^\.MR\s+([-\w\\.]+)\s+(\w+)\s+(.*)/ or m/^\\fB([-\w\\.]+)\\fR\((.+?)\)(.*)$/) {
> +			if (m/^\.BR\s+([-\w\\.]+)\s+\(([\d\w]+?)\)(.*)/ or m/^\.MR\s+([-\w\\.]+)\s+(\w+)\s+(.*)/ or m/^\\fB([-\w\\.]+)\\fR\((.+?)\)(.*)$/) {
>  				my $bkmark="$1";
>  				my $sec=$2;
>  				my $after=$3;
> @@ -145,12 +152,7 @@ sub BuildPage
>  				my $dest=$bkmark;
>  				$dest=~s/\\-/-/g;
>  
> -				if (exists($files{"${bkmark}.$sec"})) {
> -					my $dest=$files{"${bkmark}.$sec"}->[1];
> -					$_=".pdfhref L -D \"$dest\" -A \"$after\" -- \\fI$bkmark\\fP($sec)";
> -				} else {
> -					$_=".IR $bkmark ($sec)\\c\n$after";
> -				}
> +				$_=".MR \"$bkmark\" $sec $after";
>  			}
>  
>  			s/^\.BI \\fB/.BI /;
> @@ -175,16 +177,20 @@ sub BuildPage
>  				s/\n\n/\n/g;
>  			}
>  
> -			s/\\&\././ if m/^.TH /;
> -
> -			if (m/^\.TH\s+"?([-\w\\.]+)"?\s+"?(\w+)"?/) {
> -
> -				print "$_\n";
> -
> -				# Add a level two bookmark. We don't set it in the TH macro since the name passed
> -				# may be different from the filename, i.e. file = unimplemented.2, TH = UNIMPLEMENTED 2
> -
> -				print ".pdfbookmark -T $bkmark 2 $nm($sec)\n";
> +# 			s/\\&\././ if m/^.TH /;
> +#
> + 			if (m/^\.TH\s+"?([-\w\\.]+)"?\s+"?(\w+)"?(.*)/)
> + 			{
> +				print ".TH \"$nm\" \"$2\" $3\n";
> +
> +				if (exists($revalias{"$nm($sec)"}))
> +				{
> +					foreach my $dest (@{$revalias{"$nm($sec)"}})
> +					{
> +						my ($nm,$sec,$srt)=GetNmSec($dest,qr/\.[\da-z]+/);
> +						print ".pdfhref M -D $nm($sec)\n";
> +					}
> +				}
>  
>  				next;
>  			}
> @@ -199,11 +205,8 @@ sub doMR
>  	my $nm=shift;
>  	my $sec=shift;
>  
> -	if (exists($files{"${nm}.$sec"})) {
> -		return("\n.pdfhref L -D \"$files{\"${nm}.$sec\"}->[1]\" -A \"\\c\" -- \\fI$nm\\fP($sec)\n");
> -	} else {
> -		return("\\fI$nm\\fP($sec)");
> -	}
> +	return "\n.MR $nm $sec";
> +
>  }
>  
>  sub GetNmSec


-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-18  0:26                         ` Deri
@ 2024-04-18  1:09                           ` Alejandro Colomar
  2024-04-18 14:45                             ` Deri
  0 siblings, 1 reply; 31+ messages in thread
From: Alejandro Colomar @ 2024-04-18  1:09 UTC (permalink / raw)
  To: Deri; +Cc: G. Branden Robinson, linux-man

[-- Attachment #1: Type: text/plain, Size: 439 bytes --]

On Thu, Apr 18, 2024 at 01:26:28AM +0100, Deri wrote:
> Hi Alex,

Hi Deri,

> While testing I used a document just using the debian TinosR font, no problem. 
> Issue occurs when both types of font are used in one document. I have now 
> pushed the fix to groff. Please try again.

Thanks!  It works now.  How can I use Debian's TinosR font?  Where is it?

Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: Linux man-pages PDF book
  2024-04-18  1:09                           ` Alejandro Colomar
@ 2024-04-18 14:45                             ` Deri
  0 siblings, 0 replies; 31+ messages in thread
From: Deri @ 2024-04-18 14:45 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: G. Branden Robinson, linux-man

On Thursday, 18 April 2024 02:09:59 BST Alejandro Colomar wrote:
> On Thu, Apr 18, 2024 at 01:26:28AM +0100, Deri wrote:
> > Hi Alex,
> 
> Hi Deri,
> 
> > While testing I used a document just using the debian TinosR font, no
> > problem. Issue occurs when both types of font are used in one document. I
> > have now pushed the fix to groff. Please try again.
> 
> Thanks!  It works now.  How can I use Debian's TinosR font?  Where is it?
> 
> Have a lovely night!
> Alex

Hi Alex,

I was referring to the debian package texlive-extra-fonts (or something 
similar) which contains the Tinos fonts in .pfb format. Google's font download 
site only offers the font as a .ttf which I installed using the install-
fonts.sh script you have been told about, which uses fontforge and afmtodit to 
create the Tinos.pfb and TINOR files, and installs them in a suitable place 
for groff to use.

Cheers 

Deri




^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2024-04-18 14:46 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-14 11:37 Linux man-pages PDF book Alejandro Colomar
2024-04-14 11:41 ` Alejandro Colomar
2024-04-14 12:01   ` G. Branden Robinson
2024-04-14 12:25     ` Alejandro Colomar
     [not found]       ` <3935722.768hzMJKAL@pip>
2024-04-16  1:02         ` Alejandro Colomar
2024-04-16  2:08           ` G. Branden Robinson
2024-04-16  2:42             ` Alejandro Colomar
     [not found]           ` <44896690.SEQk1G1hEZ@pip>
     [not found]             ` <20240416165157.ml3ntjoozh3mpyzo@illithid>
2024-04-16 20:15               ` Alejandro Colomar
2024-04-16 20:57         ` Alejandro Colomar
2024-04-16 23:17           ` Deri
2024-04-17  9:54             ` Alejandro Colomar
2024-04-17  9:56               ` Alejandro Colomar
2024-04-17 10:28                 ` Deri
2024-04-17 10:33                   ` Alejandro Colomar
2024-04-17 20:01                     ` Deri
2024-04-17 20:48                       ` Alejandro Colomar
2024-04-18  0:26                         ` Deri
2024-04-18  1:09                           ` Alejandro Colomar
2024-04-18 14:45                             ` Deri
2024-04-18  0:44         ` Alejandro Colomar
2024-04-18  1:08         ` Alejandro Colomar
2024-04-14 11:57 ` G. Branden Robinson
2024-04-14 12:32   ` Alejandro Colomar
2024-04-14 12:42     ` Alejandro Colomar
2024-04-14 13:00       ` G. Branden Robinson
2024-04-14 12:56     ` G. Branden Robinson
2024-04-14 15:58       ` Alejandro Colomar
2024-04-14 19:55         ` Alejandro Colomar
2024-04-14 20:25           ` G. Branden Robinson
2024-04-14 21:06             ` Alejandro Colomar
2024-04-14 14:50 ` Alejandro Colomar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.