Re: Automatically updated Table of Contents with Nroff

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

 



The magic directive is .tm:

.tm string After skipping initial blanks, string (rest of the line) is read in
                        copy mode and written on the standard error.

For anything you want in the table of contents, put in this line at the proper place (or include it in a header macro):

    .tm header level and title . . . . . . \n%

Stick in a line that says

    .so toc.input

where you want the table of contents to go.

    # empty out toc.input
> toc.input
    # run once to get a sample ToC, but page numbers will be off
    nroff file > /dev/null 2> toc.input
    # run again to get proper page numbers into toc.input
    nroff file > /dev/null 2> toc.input
    # run a 3rd time to get the right output, ignoring stderr this time
    nroff file 2>/dev/null

And your output will have a table of contents in the proper place with the proper page numbers.

Note: At least on my linux box, this won't work because nroff is a shell script that calls groff internally and redirects stderr to /dev/null. So you have to use groff directly.

    Tony Hansen

On 12/21/2010 11:43 AM, Julian Reschke wrote:
On 15.07.2009 11:13, Julian Reschke wrote:
Randy Presuhn wrote:
...
No need to manually edit.

Use the macros or awk / sed to spit the toc into a file which can be
inserted
into the correct position by the .so nroff directive. This will result in
a table of contents in the correct position. There is the possibility
that if the number of toc pages has changed from one iteration
to the next that the page numbers will be off by one, but that will
go away the next time the process runs.

For editing a document, particularly a largish one, the availability of
.so is for me nroff's biggest advantage over xml2rfc.
...
...

Randy,

I've been spending some time looking at the feasibility of using NROFF for IDs while retaining features like automatics generation of the TOC in the *right* place.

Funny enough, googling for this topic leads me back to this thread (and nowhere else, it seems).

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? Also, as far as I can tell, the generated ToC will already be paginated, so do you post-process it again so it can be inserted properly?
_______________________________________________
Ietf mailing list
Ietf@xxxxxxxx
https://www.ietf.org/mailman/listinfo/ietf


[Index of Archives]     [IETF Annoucements]     [IETF]     [IP Storage]     [Yosemite News]     [Linux SCTP]     [Linux Newbies]     [Fedora Users]