#1126026 man2html-base: .nf/.fi turns into <pre>...</pre>, but .EX/.EE doesn't

Package:
man2html-base
Source:
man2html-base
Description:
convert man pages into HTML format
Submitter:
Colin Watson
Date:
2026-02-08 22:53:03 UTC
Severity:
normal
#1126026#5
Date:
2026-01-20 15:53:15 UTC
From:
To:
While trying to fix new warnings in xlbiff's autopkgtests with groff
1.24.0~rc1, I thought it would be simplest to use the .EX/.EE macros.
groff_man(7) documents these as follows:

"Begin and end example.  After .EX, filling is disabled and a
constant-width (monospaced) font is selected.  Calling .EE enables
filling and restores the previous font."

(It goes on to mention some portability limitations, although only to
very conservative systems.)

However, while testing this I discovered that man2html doesn't handle
those macros well.  It seems that it turns .nf/.fi into <pre>...</pre>,
which would imply that it should do the same for .EX/.EE (perhaps in
addition to selecting a constant-width font, although I wasn't able to
get man2html to do anything like that in my tests).  Here's a pair of
test cases demonstrating the problem:

$ cat a.1
.TH A 1
.SH NAME
a \- test
.SH DESCRIPTION
.nf
text
.fi
$ man2html a.1
[...]
<H2>DESCRIPTION</H2>

<PRE>
text
</PRE>
[...]

$ cat b.1
.TH A 1
.SH NAME
a \- test
.SH DESCRIPTION
.EX
text
.EE
$ man2html b.1
[...]
<H2>DESCRIPTION</H2>


text
[...]

Thanks,

#1126026#8
Date:
2026-02-08 22:19:08 UTC
From:
To:
Colin wrote:

If man2html is going to fix this, it should so by changing the
conversion of *roff .nf/.fi to HTML <pre>/</pre>, because these are
_not_ equivalent semantically.

.nf turns off filling and that is _all_.

* It is not a verbatim mode.
* Escape sequences are not disabled.
* Control characters (and therefore control lines) are not disabled.
* Inter-sentence spacing is still applied.

Since .EX/.EE are simply wrappers for .nf and .fi that also switch in
(and back out) the font family to a monospace one, the same points hold
for it.

If I knew the right way to "just turn off filling" in HTML, I'd share
the knowledge, but I don't.  My guess is that it requires CSS if it can
be done at all.

I'd point to a discussion I had with Russ Allbery that covered this base
with respect to podlators, but GNU Savannah's giving me HTTP 502 and
GNU's list archive host isn't responding at all, so it will have to
wait.

Yay, LLM crawlers.

Regards,
Branden

#1126026#11
Date:
2026-02-08 22:52:02 UTC
From:
To:
At 2026-02-08T16:19:10-0600, G. Branden Robinson wrote:

Ah, silly me--the information I wanted to point out is already in the
groff_man_style(7) man page, exactly where I'd most want it to be.

       .EX
       .EE    Begin and end example.  After .EX, filling is disabled and
              a constant‐width (monospaced) font is selected.  Calling
              .EE enables filling and restores the previous font.

              Example regions are useful for formatting code, shell
              sessions, and text file contents.  An example region is
              not a “literal mode” of any sort: special character escape
              sequences must still be used to produce correct glyphs for
              ', -, \, ^, `, and ~, and sentence endings are still
              detected and additional inter‐sentence space applied.  If
              the amount of additional inter‐sentence spacing is
              altered, the rendering of, for instance, regular
              expressions using . or ? followed by multiple spaces can
              change.  Use the dummy character escape sequence \& before
              the spaces.

              These macros are extensions introduced in Ninth Edition
              Research Unix.  Systems running that troff, or those from
              Documenter’s Workbench, Heirloom Doctools, or Plan 9 troff
              support them.  To be certain your page will be portable to
              systems that do not, copy their definitions from the
              an-ext.tmac file of a groff installation.

That's the entire description of these macros, but the second paragraph
is the most salient.

I would add that none of this is novel or some sort of recent change in
groff.  This the way the macros have always behaved.

Ninth Edition Unix (1986) sources seem somewhat lost to history, but
those from Research Tenth Edition Unix (1989) survive.

https://minnie.tuhs.org/cgi-bin/utree.pl?file=V10/cmd/mk/export/tmac.an

Scroll down to 'deEX'.

Here's the initial _groff_ implementation, from 2007.

https://cgit.git.savannah.gnu.org/cgit/groff.git/commit/?id=259929625b21595951ed3ef5dba9aaaea359b464

(You'll observe that `nh` and `hy` requests are invoked.  This does not
gainsay my claim.  These control lines were unnecessary; when filling is
disabled, so too is automatic hyphenation, and that's what `hy` and `hy`
configure.  The current _groff_ implementation doesn't bother.)

Regards,
Branden