How to make nroff boldface on a terminal that can highlight?
Ubben Greg
bink at aplcen.apl.jhu.edu
Sun Aug 6 02:34:01 AEST 1989
In article <537 at anasaz.UUCP> duane at anasaz.UUCP (Duane Morse) writes:
> In article <20477 at adm.BRL.MIL>, justice at dao.nrc.ca (Gerald Justice) writes:
> > I am writing some local man pages and was wondering if it was possible
> > to have nroff pass information about boldfaced text to a user's terminal
> > to have it appear as highlighted text.
>...
> Some terminals are smart enough to take the standard char-backspace-char
> sequence and do boldface. The public domain 'less' program is smart
> enough to take these sequences and use inverse video for highlighting.
> We keep formatted man pages under /usr/catman, like a lot of other
> systems, to avoid the overhead of formatting the pages every time someone
> wants to look something up.
>...
Jan Anderson also mentions a BSD filter called "ul" which converts the
italics and bolding overstrikes used in default (-T37) nroff output into
highlighting commands for a particular output device. If you don't have
access to this program (System V users), I've found that one can easily
create a filter for any particular device using a simple lex(1) program.
As an example, the following lex program (eproff.l) will create a filter
to format nroff output for an Epson printer:
%start ITALIC BOLD
%%
<INITIAL>_\b { printf("\0334"); BEGIN ITALIC; }
<INITIAL>.\b { printf("\033E"); BEGIN BOLD; }
.\b ;
<ITALIC>./[^_] { ECHO; printf("\0335"); BEGIN INITIAL; }
<BOLD>./[\t\n ]*([!-~][^\b]|_\b) { ECHO; printf("\033F"); BEGIN INITIAL; }
You would compile it by
lex eproff.l && cc lex.yy.c -ll -o eproff
and might use it as
man lex | eproff | lp -dep ...
If the input were:
It does _^Hi_^Ht_^Ha_^Hl_^Hi_^Hc_^Hs
_^Ht_^He_^Hx_^Ht and b^Hb^Hb^Hbo^Ho^Ho^Hol^Hl^Hl^Hld^Hd^Hd^Hd
t^Ht^Ht^Hte^He^He^Hex^Hx^Hx^Hxt^Ht^Ht^Ht correctly.
The output would be:
It does ^[4italics^[5
^[4text^[5 and ^[Ebold
text^[F correctly.
Notice the program maximizes the text between bolding commands in order to
simplify the output -- this might be undesirable for reverse-video on display
devices. It doesn't do so for italics because this was converted from a
version which changed italics to continuous underlining for a Xerox 2700-II
laser printer.
You can create a filter for other devices by simply changing the printf()
arguments. Or make it more general by adding a main() which looks up TERM
or a -T argument in the terminfo to get the appropriate codes. My laser
printer version also recognizes the line motions ^[7, ^[8, and ^[9.
E-mail questions or feedback are welcome.
-- Greg Ubben
bink at aplcen.apl.jhu.edu
More information about the Comp.unix.questions
mailing list