groff
[Top][All Lists]
Advanced

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

Re: Groff examples repository


From: Douglas McIlroy
Subject: Re: Groff examples repository
Date: Sat, 28 Aug 2021 12:14:17 -0400

https://froude.eu/groff/examples/reflow.html is a very cleanly written and
interesting demo. The following comments might perfect it even further.

It would be helpful to remark that .YY is a dumping ground, never to be
used.

Point out that EB need not be defined. It carries the .tm for the demo, but
is irrelevant to the underlying purpose. Nevertheless, it's useful to
illustrate that the macro-end indicator will be expanded if it's defined.
(But see below.)

At first glance I read "Text before" and "Text after" as headings for
paragraphs that show how the processed text would look before and after
expansion to 2cm height. A change to "Preceding text" and "Following text"
would avert this mistake.

-----------------------------------------------------------------

A small anomaly. Consider

    .de .
    .tm Hi
    ,..
    ..

The second .. emits "Hi". This fragment also emits "Hi":

    .de end end
    .tm Hi
    .end

But this (with macro . not previously defined)
does not:

    .de . .
    .tm Hi
    ..

Doug

For the record, here's the reflow example.

.\" ----------------------------------------------------------------
.\" begin block of text for multiple processing
.de BB
.tm starting to read text...
.de XX EB
..
.\" ----------------------------------------------------------------
.\" end block
.de EB
.tm finished reading text.
..
.\" ----------------------------------------------------------------
.\" delayed space macro, counts occurrences as well
.de SP
.nr NN +1
.sp \\n(QQu
..
.\" ----------------------------------------------------------------
.\" now gather text
.BB
This text can be
.SP
processed
.SP
multiple
.SP
times.
.EB
.\" ----------------------------------------------------------------
.\" process text once to determine height
.nr QQ 0
.nr NN 0
.di YY
.XX
.br
.di
.tm the text has a height of \n(dn units
.\" ----------------------------------------------------------------
.\" now make text fit into exactly 2 cm
.nr QQ 2c-\n(dnu/\n(NNu \" note left-to-right, no precedence rules
.\" reprocessing to verify is not really necessary, just for demo
.di YY
.XX
.br
.di
.nr OO 2c
.tm the text now has a height of \n(dn units, 2 cm is \n(OO units
.\" ----------------------------------------------------------------
.\" output text
.sp 3c
Text before.
.br
\M[yellow]\h'-.1c'\v'-.75v'\D'P 0 2c \n(dlu+.2c 0 0 -2c'
This yellow box has a height of 2 cm.
.sp -1
.XX
.br
Text after.


reply via email to

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