groff
[Top][All Lists]
Advanced

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

RE: [Groff] .di behaviour


From: Ted Harding
Subject: RE: [Groff] .di behaviour
Date: Fri, 20 Oct 2000 00:37:06 +0100 (BST)

Hi Werner and all,

This is subtle; but as far as I can tell Werner's examples are consistent
with standard UNIX troff and the behaviour is indeed at least implicitly
documented. The key is in the description of ".di" (Troff User's Manual
section 7):

  .di xx
    "Divert _output_ to macro xx ..."

together with Section 4:

  4.1 Filling and adjusting. Normally, words are collected from input
  text lines and assembled into an output text line until some word
  does not fit. ...

In other words, output does not occur until a line is filled (unless,
of course, a ".br" is encountered, in which case "the filling of the
line currently being collected is stopped and the line is output without
adjustment"). Therefore that part of an input line preceding a diversion
which forms the beginning of an incomplete output line will be included
in the diversion, since output does not begin until the line is filled
or ".br" is encountered. Similarly at the end of a diversion: if the
end of the body of the diversion will be the beginning of an incomplete
output line, then its output has not commenced and it will not be
diverted, since it is the _output_ which is diverted, not the _input_.

A similar description can be found in "Text Processing and Typesetting
with UNIX" by D. Barron and M. Rees (Addison-Wesley 1987), page 180:

  "Note also that no break is performed: this means that any partial
  line awaiting output will become part of the diversion. ... The
  diversion is terminated using [.di] without an argument ... as at
  the start of the diversion, no break is performed. There is therefore
  the possibility of omitting any partially formed output line from the
  diversion body. To avoid this problem, a suitable request which involves
  a break is recommended ... "

The implication is that if you want the entire contents of the diversion
body to be kept together and output at the point where the diversion macro
is called, then it is wise to begin the diversion with a ".br" and also to
end it with a ".br".

I hope this helps (I confess to finding it confusing on occasion ... ).

Ted.
=======================================================================
On 18-Oct-00 Werner LEMBERG wrote:
> 
> Dear friends,
> 
> 
> look at the following input:
> 
> xxx
> .
> .di test
> yyy
> .br
> .di
> .
> zzz
> \*[test]
> 
> This yields:
> 
> zzz xxx yyy
> 
> Another example:
> 
> xxx
> .
> .di test
> yyy
> .br
> zzz
> .di
> .
> aaa
> \*[test]
> 
> This yields:
> 
> zzz aaa xxx yyy
> 
> 
> Where is it documented that (a) at the beginning of a diversion,
> partial input lines are included in the diversion and (b) that a
> diversion must be finished with a line break (which will be dropped)?
> 
> With other words, the right way to write the first example is
> 
> xxx
> .
> .di test
> .br
> yyy
> .br
> .di
> .
> zzz
> \*[test]
> 
> to get
> 
> xxx zzz yyy
> 
> 
> Is this behaviour identical to UNIX troff?
> 
> 
>     Werner
> _______________________________________________
> Groff maillist  -  address@hidden
> http://ffii.org/mailman/listinfo/groff

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 284 7749
Date: 20-Oct-00                                       Time: 00:37:06
------------------------------ XFMail ------------------------------

reply via email to

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