groff
[Top][All Lists]
Advanced

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

Re: [Groff] Copying blocks of troff input to a file


From: Ralph Corderoy
Subject: Re: [Groff] Copying blocks of troff input to a file
Date: Wed, 24 Dec 2003 16:09:35 +0000

Hi Ted,

> ... this is not what's wanted, since

Sorry for not being accurate in my example.

> b) What I want copied into the auxiliary file by .TO/.../.TQ is
> 
>    .XS 1
>    merry
>    christmas
>    .XE

Tadziu has already replied with a troff solution, but I think the
preprocessor idea is still possible since you're just trying to save on
some typing.

    $ cat ted
    #! /usr/bin/awk -f

    /^\.TE$/ { $0 = ".append_to_toc .XE"; f = 0 }
    f { $0 = ".append_to_toc " $0 "\n" $0 }
    /^\.TO$/ { $0 = ".append_to_toc .XS \\\\n[PN]"; f = 1 }
    1
    $
    $ echo before/.TO/one/two/.TE/after | tr / \\012 | ./ted
    before
    .append_to_toc .XS \\n[PN]
    .append_to_toc one
    one
    .append_to_toc two
    two
    .append_to_toc .XE
    after
    $ 

If you wanted `one' and `two' to be blocked together then the lines
could be saved in an awk array and output on `.TE'.

Cheers,


Ralph.


reply via email to

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