From 53293faf4403a04fc38027f76c60369695606cd8 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Mon, 18 Mar 2024 20:45:04 -0700 Subject: [PATCH] Force ragged-right justification with groff 1.23.0 groff 1.23.0 added code to the an macro underlying .IP and .TP that resets the justification to the AD register, which defaults to b (full justification). Pod::Man attempts to force ragged-right justification under nroff with .if n .ad l after .TH, but that change was reverted in the first =item list, resulting in strange-looking formatted manual pages in a terminal. Work around this by setting the AD string to l if the formatter is nroff in the preamble of each page. This undermines the intended upstream use of AD as a way for the user to override the formatting, but Pod::Man-generated man pages already didn't support that and there currently is no clean way to support the AD string while still changing the default under nroff to ragged-right justification, as has been the practice of Pod::Man since its first release in 1999. Fixes #23 --- Changes | 4 ++++ THANKS | 8 +++++--- lib/Pod/Man.pm | 3 +++ t/data/man/encoding.groff | 3 +++ t/data/man/encoding.roff | 3 +++ t/data/man/encoding.utf8 | 3 +++ 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 3996907..924c5b4 100644 --- a/Changes +++ b/Changes @@ -32,6 +32,10 @@ v6.0.0 - Not Released at build time. Thanks to Marco Sirabella for the analysis and an initial patch. (GitHub #21) + - Add a workaround to Pod::Man to force persistent ragged-right + justification under nroff with groff 1.23.0. Thanks to Guillem Jover + for the report and G. Branden Robinson for the analysis. (GitHub #23) + - Fix wrapping of text with S<> markup in all subclasses of Pod::Text. Thanks to Jim Avera for the report. (GitHub #24) diff --git a/THANKS b/THANKS index 143329e..20f7cdf 100644 --- a/THANKS +++ b/THANKS @@ -197,9 +197,10 @@ title of a simple module and for how best to suppress Encode warnings during Perl core builds. Guillem Jover, for the formatting change for manual page references and -function names to match the Linux manual page standard, and reporting a +function names to match the Linux manual page standard, reporting a diagnostic bug when pod2man or pod2text gets empty input on standard -input. +input, and reporting a groff 1.23.0 regression with ragged-right +justification. Zefram, for analyzing and fixing a problem with the UTF-8 layer detection code in Pod::Man. @@ -237,7 +238,8 @@ continued farther than they should in Pod::Man output if they were combined with C<> and fixed-width fonts, and for finding a subtle spacing bug with nested =items without bodies. -G. Branden Robinson, for his assistance in understanding *roff syntax. +G. Branden Robinson, for his assistance in understanding *roff syntax and +analysis of groff justification changes. youpong, for reporting a double-encoding bug with a :utf8 output layer. diff --git a/lib/Pod/Man.pm b/lib/Pod/Man.pm index f837ee9..9488878 100644 --- a/lib/Pod/Man.pm +++ b/lib/Pod/Man.pm @@ -1620,6 +1620,9 @@ sub preamble_template { . \} .\} .rr rF +.\" +.\" Required to disable full justification in groff 1.23.0. +.if n .ds AD l ----END OF PREAMBLE---- if ($$self{ENCODING} eq 'roff') { diff --git a/t/data/man/encoding.groff b/t/data/man/encoding.groff index 52d99b2..e581114 100644 --- a/t/data/man/encoding.groff +++ b/t/data/man/encoding.groff @@ -50,6 +50,9 @@ . \} .\} .rr rF +.\" +.\" Required to disable full justification in groff 1.23.0. +.if n .ds AD l .\" ======================================================================== .\" .IX Title "ENCODING 1" diff --git a/t/data/man/encoding.roff b/t/data/man/encoding.roff index 7700585..98585f1 100644 --- a/t/data/man/encoding.roff +++ b/t/data/man/encoding.roff @@ -51,6 +51,9 @@ .\} .rr rF .\" +.\" Required to disable full justification in groff 1.23.0. +.if n .ds AD l +.\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff diff --git a/t/data/man/encoding.utf8 b/t/data/man/encoding.utf8 index 5ab5687..de7158a 100644 --- a/t/data/man/encoding.utf8 +++ b/t/data/man/encoding.utf8 @@ -51,6 +51,9 @@ . \} .\} .rr rF +.\" +.\" Required to disable full justification in groff 1.23.0. +.if n .ds AD l .\" ======================================================================== .\" .IX Title "ENCODING 1"