Hi Collin,

At 2026-01-21T20:33:49-0800, Collin Funk wrote:
> I do like NO_COLOR since it is widely supported.
>
> "G. Branden Robinson" <[email protected]> writes:
> > It would also be straightforward to make `NO_COLOR` in the
> > environment a synonym for grotty's `-c` option if the initiative
> > really catches fire.  `GROFF_NO_SGR` is already there and does the
> > same thing.  (Strictly, grotty would "go too far" per the Q&A's
> > above, but at present that doesn't concern me.  You ask for
> > monochrome, you get it.)
> 
> Yeah, I kind of feel the same way. But I would probably try to stick
> to the standard to avoid suprising people.

Fair.  For now I can stick to grotty's status quo and see if anyone ever
actually _asks_ for `NO_COLOR` support.  :)

> By the way, I assume there is no need to mention my lack of
> understanding of groff, man, etc., but is there a more standard way to
> invoke groff to remove links than this?
> 
>     $ groff -Z -Tutf8 -man man/ls.1 | grotty -c

Yes, on two levels.

First, it's never^Wseldom necessary to tell groff `-Z` only to pipe its
output to an output driver by hand.[1]  If you want to pass an option to
the output driver, use groff's `-P` option.

groff(1):

Options
...
   groff‐specific options
     The following options either do not exist in GNU troff or are
     interpreted differently by groff.
...
     -P arg   Pass arg to the postprocessor.  If multiple args are
              required, pass each with a separate -P option.  groff does
              not prefix an option dash to arg before passing it to the
              postprocessor.

So you could simplify:

>     $ groff -Z -Tutf8 -man man/ls.1 | grotty -c

as:

$ groff -man -Tutf8 -P -c man/ls.1

...but that kills off SGR, too.  Say you want SGR but not OSC 8-encoded
URLs.  In that case, tell the man(7) package not to produce them.

groff_man(7):

Options
     The following groff options set registers (with -r) and strings
     (with -d) recognized and used by the man macro package.  To ensure
     rendering consistent with output device capabilities and reader
     preferences, man pages should never manipulate them.
...
     -rU0     Disable generation of URI hyperlinks in output drivers
              capable of them, making the arguments to MT and UR calls
              visible as formatted text.  grohtml(1), gropdf(1), and
              grotty(1) enable hyperlinks by default (the last only if
              not in its legacy output mode).

So you could simplify:

$ groff -man -Tutf8 -P -c man/ls.1

as:

$ groff -rU0 -man -Tutf8 man/ls.1

Notes:
* groff uses `getopt_long()`, so of course you can put options in
  whatever order you like.
* The man page quotes are from the groff 1.24.0.rc1 release candidate.
* It's also possible to disable hyperlinks in groff man(7) and groff
  mdoc(7) globally.  See section "Files" of the corresponding man pages.

Regards,
Branden

[1] Unless you wanted to pass that output to a non-groff postprocessor,
    or to a different output driver than that for which it was prepared,
    which mostly cannot be expected to work, but see gxditview(1).

Attachment: signature.asc
Description: PGP signature

Reply via email to