At 2025-08-07T13:04:21+0200, Alejandro Colomar wrote:
> Do we want to diagnose blank lines in input before TH?
> 
>       alx@debian:~/tmp$ cat blank.man | nl -ba
>            1  
>            2  .TH a 2 d f
>            3  .SH foo
>            4  
>            5  foo
>       alx@debian:~/tmp$ groff -man -Tutf8 -wbreak -rCHECKSTYLE=3 blank.man 
>       an.tmac:blank.man:4: style: blank line in input
> 
>       a(2)                          System Calls Manual                       
>   a(2)
> 
>       foo
>              foo
> 
>       f                                      d                                
>   a(2)
> 
> It seems inconsistent to not diagnose that.

At the time that blank line is read, we don't know whether a man(7) or
an mdoc(7) document is being read (and thus whether `CHECKSTYLE` is
meaningful at all).  While you've presumed that with the `-man`
argument, the preponderant mode of usage of the man(7) macro package is
via `nroff -mandoc`, and that via man(1).  So in that preponderant case,
we _don't_ actually know that.

This _could_ be resolved by having the man(7) package invoke `blm` and
`lsm` at initialization as well as within the `TH` macro definition.
"andoc.tmac" already cleans up the traps when changing macro packages so
this probably wouldn't be a difficult to do.

There would remain the risk of the _man_ macro package diagnosing blank
lines at the top of an mdoc(7) document, which could be confusing.

Recall that when multiple pages are formatted, we don't know which macro
package is in use until we see either a `TH` or a `Dd` macro call.

In principle, we could parse the contents of the `.F` register.  But
string parsing in *roff is hard because we don't have a
string/macro/diversion iterator.[1]  And if GNU troff is reading
standard input, `\n[.F]` will tell us nothing useful.

It's also not difficult for a man(7) document maintainer to add a "grep
'^$' *.man" command to some sort of linter target in a Makefile.  ;-)

Regards,
Branden

[1] https://savannah.gnu.org/bugs/?62264

Attachment: signature.asc
Description: PGP signature

Reply via email to