[comp.unix.wizards] Help with man macros

rp@osc.COM (Rich Patterson) (07/28/89)

Hi,
	I have a question about the man macros.  The version of nroff and man
macros I have are those that come with System V rel 3.0 for the 386.
	When I nroff a man page, like the ones that come with smail, gcc,
in other words ones that I didn't create,  I get interesting output for the
header:  (Command line: nroff -man pathalias.8 >pa.out; vi pa.out)

	P^HP^HP^HP^HA^HA^HA^H ... so on for the header

	What I assume is that the overstrike or backspacing is being used
for boldfacing.  I'm trying to get nroff not to output those overstrike
characters.  However, when I try the '-u' option for nroff, to set the
"emboldening factor",(the default is zero) it doesn't change the output.
I've also tried different -T output devices, and have compared the
Sys V man macros to Sun man macros (which don't output the overstrike
sequence) to no avail.  Can someone help ???  Any ideas or workarounds
would be great.  Please e-mail to me directly.  Thanks in advance.

Rich P.
{pacbell,amdcad}!osc!rp
osc!rp@pacbell.com	(usually works for internet)

jiii@visdc.UUCP (John E Van Deusen III) (08/04/89)

In article <434@osc.COM> rp@osc.COM (Rich Patterson) writes:
> I have a question about the man macros.
> ...
> I assume is that the overstrike or backspacing is being used for
> boldfacing.  I'm trying to get nroff not to output those overstrike
> characters.
> ...
>osc!rp@pacbell.com

Actually your question has nothing to do with man macros: it has to do
with nroff.  It is my understanding that certain newer versions of nroff
use terminfo, but the older versions are driven by a terminal-specific
table located in the /usr/lib/term directory.  Most systems do not
provide the source code for users to compile their own driving tables.
Even when this is possible the table functions are fairly limited.  For
example, it is possible to specify a character sequence to put the
printer into an underline mode, and this sequence is output when .ft2
(or .ft i, \fI, \f2, .ul, .cu, .i, .I), Italics mode, is invoked.  The
problem is that italics mode should not underline blanks, but the
underline mode of a printer does.

The solution that I have used is to create a filter, using yacc & lex,
to recognize the various overstrike sequences that are output by nroff
for the default terminal, usually a model 37 Teletype.  The filter then
outputs the escape sequences for some desired printer instead.  This
filter is incorporated into the interface program that is associated
with a given printer device in the lp system.  See lpadmin(1M).
--
John E Van Deusen III, PO Box 9283, Boise, ID  83707, (208) 343-1865

uunet!visdc!jiii

rcd@ico.ISC.COM (Dick Dunn) (08/10/89)

jiii@visdc.UUCP (John E Van Deusen III) writes about nroff in response to
a question about man macros:
> ...It is my understanding that certain newer versions of nroff
> use terminfo, but the older versions are driven by a terminal-specific
> table located in the /usr/lib/term directory.  Most systems do not
> provide the source code for users to compile their own driving tables...

No, nroff does not use terminfo.  However, there have been several
variations on the format of the table which nroff uses.  The older versions
used files in /usr/lib/term (unfortunately, the same directory name was
used through more than one file format); the current version uses
/usr/lib/nterm.

Circa V7, the file was just a data-initialization statement in a .c file;
you compiled it and moved it into place.  Nroff read the file, discarding
the header and figuring out offsets and such.  A more recent version (but
still older-style nroff) had you compile the data initialization and link
it with a special program which generated a more convenient output file--
which was pure data instead of a.out format.

The current (DWB 2.0) format is (radical idea!) a text file; thus the only
tool you need to build it is a text editor, starting from an existing file.
IMHO this is a great improvement.  It's simple, and the extra startup time
is negligible.

> Even when [building the table] is possible the table functions are
> fairly limited...

They have improved slightly, but there are still some awkward cases.
John's example of underlining vs italics is one.  Another is that there's
no form feed--nroff assumes it can use multiple line feeds to get from one
page to the next, which won't work when you're dealing with a printer
that's more helpful than smart.

> The solution that I have used is to create a filter, using yacc & lex,
> to recognize the various overstrike sequences that are output by nroff
> for the default terminal, usually a model 37 Teletype.  The filter then
> outputs the escape sequences for some desired printer instead...

This will work, but it's probably easier to develop the filter if you use a
different terminal type--create one of your own which is adapted to produce
easily-parsed data for the things the filter has to re-hack and which
minimizes the number of sequences the filter has to handle.
-- 
Dick Dunn     rcd@ico.isc.com    uucp: {ncar,nbires}!ico!rcd     (303)449-2870
   ...Simpler is better.

jiii@visdc.UUCP (John E Van Deusen III) (08/14/89)

In article <16001@vail.ICO.ISC.COM> rcd@ico.ISC.COM (Dick Dunn) writes:
>
> ...it's probably easier to develop the filter if you use a different
> terminal type--create one of your own which is adapted to produce
> easily-parsed data for the things the filter has to re-hack and which
> minimizes the number of sequences the filter has to handle.
>-- 
>Dick Dunn     rcd@ico.isc.com    uucp: {ncar,nbires}!ico!rcd     (303)449-2870
>   ...Simpler is better.

As was discussed earlier, there really isn't that much that modifying
the nroff driving tables enables you to do.  Although you can accomplish
quite a bit toward making perfect, terminal-specific \(dg and \(bu
special fonts, the italic font is always produced by the sequence  _^Hx,
(where x is the underlined character).  Likewise, the bold font is
always produced by repetitions of x^Hx.  From my experience it is both
possible and desirable to create a filter that can intercept the
specific escape sequences for ALL of the terminal types in use on the
machine.

It is desirable to be able to do this, because nroff does produce other
escape codes that are incompatible with certain printers.  For instance,
the half-line up sequence for the default Teletype 37 is Esc 9.  If that
sequence is sent to a Diablo 630, it will reset the left margin to the
current print position.  Thus, a user forgetting to specify -Tlp when
invoking the man(1) command, with the output directed to lp(1), could
screw up not only his own output, but also everything printed
thereafter.

The trick is for the filter to try to determine the terminal type for
which the nroff output was generated by examining the data stream.
For example, the Teletype 37 output, as supplied with my system, does
not output anything at the start of the data set.  In contrast, the
-T450 data stream begins with an Esc 4.  Thus, a filter can know to
convert Esc 9 to Esc D if there is not an Esc 4 at the beginning of the
data.

Since the filter is device specific, it should be invoked by the
/usr/spool/lp/interface/xxx program, (where xxx is the name of the
printer), because these programs are also bound to a particular device.
A more important function than correctly interpreting nroff escape
sequences is for the filter to protect the printer from random data.
It should definately recognize the escape sequences that do system
resets or change the number of lines per page and exit if those
sequences are encountered in a "normal" data stream.
--
John E Van Deusen III, PO Box 9283, Boise, ID  83707, (208) 343-1865

uunet!visdc!jiii