Hi John,
thanks a *lot* for the explanations. More below.
On 21.12.2010 19:59, John Levine wrote:
So, I do understand how generate the ToC at the end, and I'll probably
grok .so, but what is needed to extract the ToC into a separate file? Is
there anything in nroff supporting that, or were you just referring to a
set of homegrown tools?
Nroff isn't a document formatter, it's an interpretive programming
language in which one can write document formatters. Everything is
either home grown, or borrowed from someone else who homegrew it. As
you might expect, there is a great deal of folklore in the nroff
community about the ways you implement stuff using the stone axes and
chisels that nroff provides. (I guess I qualify, having been using it
since about 1973.)
The usual way to generate a TOC is to use .tm directives which write
the TOC to the standard error, which you capture in a file using
the usual Unix shell redirection. Then you rerun nroff using .so
to include that file up at the front where the TOC goes.
That's what I understood from previous threads, but I had no idea how to
get that second output stream (I was staring at ".open" earlier today).
Rather than trying to format the TOC as it's generated, I always write
out macro calls which will be expanded as the included file is read,
e.g.:
.Tc 2 4.2 12 "Efficient lossless packet compression"
In this example, this is second level heading 4.2 on page 12. It's
easy enough to generate whatever sort of TOC you want, and the usual
nroff page break stuff does the pagination.
So is .TC plain nroff or in some package?
Now, of course, this means that the TOC in your ouput is actually the
TOC from the last time you ran nroff, so there's the possibility of
version skew. It's not hard to have your script or makefile compare
the old and new TOC files, notice that the current TOC is different
from the one you used, and tell you to run it again.
Understood (been there with Tex a few decades ago).
If this all seems like a gross complicated crock, well, yeah, what do
you expect from something designed to run on PDP-11s in the 1970s?
That's why we love it so.
And that's why I'm so totally excited that people seriously consider
writing new code to *produce* NROFF output, instead of simply formatting
directly to plain text.
R's,
John
PS: When I write books, I write and proof them in nroff and use a
little perl script to translate it to docbook before sending it off
to the publisher.
Best regards, Julian
_______________________________________________
Ietf mailing list
Ietf@xxxxxxxx
https://www.ietf.org/mailman/listinfo/ietf