groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] Nesting font macros in man pages


From: G. Branden Robinson
Subject: Re: [Groff] Nesting font macros in man pages
Date: Mon, 24 Apr 2017 11:41:22 -0400
User-agent: NeoMutt/20170113 (1.7.2)

At 2017-04-24T16:22:37+0100, Ralph Corderoy wrote:
> .SM affect the next input line as it uses an input trap, `.it'.  `\c'
> doesn't make an input line continue to the next as far as input traps
> are concerned;  groff has .itc for that.  So the .SM is over by the `)'.

That's exactly the hack I wanted to make to the TP macro.  I want to
change its .it to an itc, thus:

.de1 TP
.  sp \\n[PD]u
.  if \\n[.$] .nr an-prevailing-indent (n;\\$1)
.  itc 1 an-trap
.  in 0
.  if !\\n[an-div?] \{\
.    ll -\\n[an-margin]u
.    di an-div
.  \}
.  nr an-div? 1
..

My objective is to enable us to migrate from ugly markup like this,
which is frequently seen in documentation of Unix command options that
take arguments:

.TP
.B \-scale \fIxfac\fR[\fB,\fIyfac\fR]
Multiply the horizontal and vertical window size by
.I xfac
and
.IR yfac ,
respectively.

to the more readable (and, I submit, more writable-by-the-novice):

.TP
.B \-scale \c
.IR xfac [, yfac ]
Multiply the horizontal and vertical window size by
.I xfac
and
.IR yfac ,
respectively.

I used the following technique to see what kind of impact this would
have on rendered man pages.

$ cd /usr/share/man
$ find man* -type f | wc -l
6939
$ for d in man*; do mkdir -p ~/tmp/stock-tp-macro/$d; for f in $d/*; \
do echo $f;  man -Tutf8 -l $f > ~/tmp/stock-tp-macro/${f/%.gz/.utf8.txt}; \
done; done
[install hacked macro to /etc/groff/man.local]
$ for d in man*; do mkdir -p ~/tmp/hacked-tp-macro/$d; for f in $d/*; \
do echo $f;  man -Tutf8 -l $f > ~/tmp/hacked-tp-macro/${f/%.gz/.utf8.txt}; \
done; done
$ cd ~/tmp
$ diff -urN stock-tp-macro hacked-tp-macro > tp.diff
$ diffstat tp.diff
 man1/apropos.1.utf8.txt     |    2 +-
 man1/eqn.1.utf8.txt         |   13 ++++++-------
 man1/geqn.1.utf8.txt        |   13 ++++++-------
 man1/grodvi.1.utf8.txt      |    4 ++--
 man1/ksh.1.utf8.txt         |    2 +-
 man1/ksh93.1.utf8.txt       |    2 +-
 man1/man.1.utf8.txt         |    2 +-
 man1/manpath.1.utf8.txt     |    2 +-
 man1/rksh.1.utf8.txt        |    2 +-
 man1/rksh93.1.utf8.txt      |    2 +-
 man1/ttf2pk.1.utf8.txt      |    2 +-
 man1/whatis.1.utf8.txt      |    2 +-
 man5/groff_out.5.utf8.txt   |    6 +++---
 man7/groff_hdtbl.7.utf8.txt |   18 +++++++++---------
 man7/groff_mm.7.utf8.txt    |   20 ++++++++++----------
 man7/groff_ms.7.utf8.txt    |    2 +-
 16 files changed, 46 insertions(+), 48 deletions(-)

Some of these are dupes due to the fact that I overlooked symlinked
manpages.

...and some of those look like source bugs exposed by my macro change.
I already have patches ready for them, except for the ksh93 page.

Is my idea to change the definition of TP a lunatic one?

And even if it is, is it worth doing given the apparently very low
impact on existing man pages?

Regards,
Branden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]