groff
[Top][All Lists]
Advanced

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

[Groff] removing environments


From: Werner LEMBERG
Subject: [Groff] removing environments
Date: Tue, 23 May 2006 17:30:54 +0200 (CEST)

For the first time ever I've encountered a situation where the removal
of environments would be a good thing, thus I'm going to implement it,
I think :-)

The snippet below has been taken from the forthcoming groff_hdtbl.man,
with minor simplifications.  The main idea is to wrap the `.I' man
macro so that the font family is temporarily switched to `C'.

Note that the `.I' macro uses an input trap which forces us to find a
solution within a single line.

This is probably something for the Wiki...


.  \" We have to solve the following problem.  In the following code
.  \"
.  \"   foo
.  \"   .CI bar
.  \"   foo
.  \"
.  \" the space immediately after `bar' should not be taken from the `C'
.  \" family.  At the same time, this
.  \"
.  \"   foo
.  \"   .CI bar\c
.  \"   foo
.  \"
.  \" should work also.  To make both constraints work with a single macro
.  \" we need a means to test whether there is a `\c' in the arguments. 
.  \" The only solution I'm aware of is to switch to an environment with
.  \" an empty `current partial line' and emitting the arguments, then
.  \" testing the \n[.int] register.  Since it is not possible currently
.  \" to remove environments we use a counter to guarantee empty
.  \" environments.
.
.  nr env-count 0 1
.
.  de CI
.    ev e-\\n+[env-count]
.    nop \&\\$*
.    nr have-int \\n[.int]
.    ev
.    fam C
.    ie \\n[have-int] \{\
.      I \&\\$*
.      fam
.    \}
.    el \
.      I \&\\$*\F[]
..


    Werner




reply via email to

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