groff
[Top][All Lists]
Advanced

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

Re: [Groff] .br after .box *invariably* generates an output line?


From: Werner LEMBERG
Subject: Re: [Groff] .br after .box *invariably* generates an output line?
Date: Fri, 01 Mar 2013 08:12:31 +0100 (CET)

>>> groff -Tascii <<'EOF'
>>> .nf
>>  ^^^
>>This instruction causes the empty line.  Just try to insert three
>>`.br' lines to get three line breaks.
>>[snip]
>>Only use .nf while replaying a diversion (to avoid reformatting),
>>not while defining it.
> 
> Thanks for responding... I'm still not quite getting it, and hoping
> you can find another way to explain.  A .br doesn't -create- a
> pending line, it just flushes a pending partial line if there is one
> (right?)

No, see below.

> Inserting three .br in a row does not create three blank lines.
> Clearly something besides a break has to happen to create a pending
> line.

Well, as soon as you say `.nf', real newline characters (either in the
input file or inserted by groff itself while formatting a diversion)
are emitted as-is.  In other words, the newline after `.br' causes the
linebreak.

> What I don't get is where the "pending" line comes from in a
> diversion which contains absolutely no text at all, just a solitary
> ".br".  See example below.  The final .br is necessary to capture
> the last partial line _if_ there is one.  But if there is _not_
> anything formatted before the .br, why does the .br output a line
> anyway?  What puts something into the pending buffer?
> 
> groff -Tascii <<'EOF'
> .box xxx
> .\"There is nothing here, so I expected nothing in the diversion
> .br
> .box
> .nf
> .xxx
> After the box.
> EOF
> 
> =>(blank line)
>   After the box.

In your code, `xxx' is *not* empty!  Due to the `.br' line, you get
four elements:

  line start node
  vertical size node
  vertical size node
  `\n'

The first three nodes are inserted by `gtroff'; the latter two (which
are always present) specify the vertical extent of the last line,
possibly modified by `\x'.  The `br' request finishes the current
partial line, inserting a newline input token which is subsequently
converted to a space when the diversion is reread.

Have a look into groff's info file, section

  `gtroff' internals

for more details.  In other words, it is not possible to create an
empty diversion; it contains at least a newline.  However, you can
remove that using `.chop':

  .box xxx
  .br
  .box
  .chop xxx
  .nf
  .xxx
  After the box.

  => After the box.

Of course, if you have a non-empty box, you then have to take care of
inserting a final linebreak by yourself.


    Werner



reply via email to

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