Package: groff
Version: 1.22.4-3
Severity: minor

The Groff documentation is fairly adamant that the default behaviour for
text output is to use control-characters for highlighting.  For example,

grotty(1):
       By  default,  grotty  emits  SGR  escape sequences (from ISO 6429, also
       called ANSI color escapes) to change  text  attributes  (bold,  italic,
       colors).  This makes it possible to have eight different background and
       foreground colors; additionally, bold and italic attributes can be used
       at the same time (by using the BI font).

       [...]

       Use the -c switch to revert to the old behaviour, printing a bold char‐
       acter  c with the sequence “c BACKSPACE c” and an italic character c by
       the sequence “_ BACKSPACE c”.  At the same time, color output  is  dis‐
       abled.   The  same  effect  can  be  achieved  by  setting  either  the
       GROFF_NO_SGR environment variable or using the ‘sgr’ X command (see be‐
       low).

       [...]

       \X'tty: sgr n'
              If  n is non-zero or missing, enable SGR output (this is the de‐
              fault), otherwise use the old drawing scheme for bold and under‐
              line.

nroff(1):
       Whitespace is not permitted between an option and its argument.  The -h
       and -c options are equivalent to grotty's options -h (using tabs in the
       output)  and  -c (using the old output scheme instead of SGR escape se‐
       quences).

But!

        [spirit ~]nroff -man <<EOF | cat -v | tail -n+5 | head -n6
        .TH example 1 "22 June 2020" "Command-line example"
        .SH NAME
        example \- demonstrate overstriking behaviour
        .SH BUGS
        Boldface is indicated by overstriking,
        rather than using SGR control sequences
        as documented in the manual.
        EOF
        N^HNA^HAM^HME^HE
               example - demonstrate overstriking behaviour

        B^HBU^HUG^HGS^HS
               Boldface  is  indicated  by overstriking, rather than using SGR 
control
               sequences as documented in the manual.

because

        [spirit ~]troff -Tascii -man <<EOF | grep sgr
        .TH example 1 "22 June 2020" "Command-line example"
        .SH NAME
        example \- demonstrate overstriking behaviour
        .SH BUGS
        Boldface is indicated by overstriking,
        rather than using SGR control sequences
        as documented in the manual.
        EOF
        x X tty: sgr 0

I eventuallly tracked this down by grepping the source code, which found

        [spirit ~t/groff (dgit/sid)]git grep "tty: sgr 0"
        PROBLEMS:.        nop \X'tty: sgr 0'
        PROBLEMS:.      nop \X'tty: sgr 0'
        debian/mandoc.local:.    output x X tty: sgr 0

which revealed

        .  \" Debian: Disable the use of SGR (ANSI colour) escape sequences by
        .  \" grotty.
        .  if '\V[GROFF_SGR]'' \
        .    output x X tty: sgr 0

Alas,

        [spirit ~t/groff (dgit/sid)]git grep GROFF_SGR
        debian/changelog:    /etc/groff/mdoc.local, or by setting the 
environment variable GROFF_SGR
        debian/mandoc.local:.  if '\V[GROFF_SGR]'' \

this is only documented in the middle of the changelog file.

I can totally see why this override is in place.  But it's not always the
right answer.  In particular, the old overstriking output is ambiguous
regarding the status of `_^H_': less(1) attempts to interpret this by looking
at its context, but if the characters to the left and right disagree about
whether they're bold or underlined then less(1) must guess, gets subtle cases
wrong like

        .IB x _mid_ y

Since I have configured my pager correctly (and Emacs seems to cope by magic)
I'd like to avoid this situation, and it would have been nice not to have
wasted a couple of hours trying to figure out why Groff wasn't behaviing like
the manual said.  Maybe others can be spared this annoyance.

-- System Information:
Debian Release: 10.4
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'stable-updates'), (500, 
'oldstable-updates'), (500, 'testing'), (500, 'oldstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.4.0-4-amd64 (SMP w/8 CPU cores)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages groff depends on:
ii  groff-base  1.22.4-3
ii  libc6       2.28-10
ii  libgcc1     1:8.3.0-6
ii  libice6     2:1.0.9-2
ii  libsm6      2:1.2.3-1
ii  libstdc++6  8.3.0-6
ii  libx11-6    2:1.6.7-1
ii  libxaw7     2:1.0.13-1+b2
ii  libxmu6     2:1.1.2-2+b3
ii  libxt6      1:1.1.5-1+b3

Versions of packages groff recommends:
ii  ghostscript                      9.27~dfsg-2+deb10u3
ii  imagemagick                      8:6.9.10.23+dfsg-2.1
ii  imagemagick-6.q16 [imagemagick]  8:6.9.10.23+dfsg-2.1
ii  libpaper1                        1.1.28
ii  netpbm                           2:10.0-15.3+b2
ii  perl                             5.28.1-6
ii  psutils                          1.17.dfsg-4

groff suggests no packages.

-- no debconf information

Reply via email to