grohtml: confused about constant-width font handling

Colin Watson <[email protected]>
Newsgroups gmane.comp.printing.groff.general
Message-ID <[email protected]>
I'm working through some Debian packages whose tests fail with groff 
1.24.0.rc1.  One of those is xlbiff, where there was a previous attempt 
to improve the handling of constant-width font selection in 
https://github.com/edsantiago/xlbiff/commit/e0987fbbcd2304b389f70bbedb9ab9201c8bd7f1.

My current plan is to add the following preamble to the affected pages:

   .ie n .ds CR R
   .el .ds CR CR

... and then just use `.ft \*(CR` in each of the places where it 
currently has a conditional.  This seems to work fine for utf8, ps, and 
pdf output.

However, when I tested with -Thtml I found that the expected <pre> or 
<tt> tag was missing.  I don't exactly remember how this works, so I 
poked around in src/devices/grohtml/post-html.cpp and found this:

   void html_printer::start_font (const char *fontname)
   {
     assert(fontname != 0 /* nullptr */);
     [...]
     } else if (strcmp(fontname, "CR") == 0) {
       if ((! fill_on)
           && is_courier_until_eol()
           && is_line_start(! fill_on)) {
         current_paragraph->do_pre();
       }
       current_paragraph->do_tt();
     [...]
     }
   }

So that should work, right?  CR is meant to turn into a <pre> or <tt> 
tag depending on the context.  But even with current git master, it 
doesn't seem to:

   $ cat t.1
   .TH T 1
   .SH NAME
   t \- a test
   .SH DESCRIPTION
   .ft CR
   constant-width text
   $ ./test-groff -ww -man -Thtml t.1
   [...]
   <p style="margin-left:6%; margin-top: 1em">constant-width
   text</p>

So there's no warning, but also no actual constant-width output.  Am I 
holding it wrong somehow, or is this broken?

Thanks,

-- 
Colin Watson (he/him)                              [[email protected]]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.