groff
[Top][All Lists]
Advanced

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

Re: [Groff] add extra footer with running page numbers


From: Jeremy C. Reed
Subject: Re: [Groff] add extra footer with running page numbers
Date: Fri, 5 Sep 2008 14:40:34 -0500 (CDT)

On Fri, 5 Sep 2008, Nick Stoughton wrote:

> If I understand your problem correctly, when we build the POSIX spec we
> have a similar problem. I have a macro that I ensure is called at the
> end of any run. This uses .tm to print a macro (.pn) to stderr with the
> final page number which I then save to a separate file. This file is an
> input to the next run, setting the initial page number.
> 
> This is a somewhat stripped down version:
>    1. create a file called "last_page" which has the following 2 lines:
>       .bp
>       .tm .pn %
> 
>    2. create a file called "first_page" with the single line:
>         .pn 1
> 
>    3. Assume your text is in foo.man:
>         tbl foo.man | groff -Tps -man first_page - last_page 2>
> first_page.new > foo.ps
> 
>    4. mv first_page.new first_page
> 
> The above is a grossly simplified and untested version of what the POSIX
> build operation does, but I hope it serves to point you in the right
> direction!

Thank you Nick.

After one time, the first_page contains:

.pn %

So then groff later complains and the warning is saved to new 
first_page.new:

first_page:1: warning: numeric expression expected (got newline)
.pn %

Then it is changed to be first_page:2: (because the first line was added).


My script is here:

:>man8pages.tmp
cp first_page.1 first_page

for f in `cat man8` ; do
        if [ ! -f ${f} ]; then
                continue ;
        fi ;
        tbl ${f} | troff -msafer -man -Tps first_page - last_page 
2>first_page.new > foo.ps;
        mv first_page.new first_page
        cat foo.ps >> man8pages.tmp
done ;

cat man8pages.tmp | grep -v '^x stop' | grops >man8pages.ps

The new generated pages don't have new page numbers, plus the first of 
each new individual man page (after the first) has the warning printed.

I also tested without -msafer. And I tried groff instead of troff but that 
caused grops error:

grops:<standard input>:1:fatal error: the first command must be `x T'

And viewing it only showed the first man page and not all merged.

As you can guess I don't know groff/troff well, other than I have authored 
and maintained many man and mdoc files for several years.




reply via email to

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