[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff] Re: Available for small pdfmark project help
From: |
Keith Marshall |
Subject: |
[Groff] Re: Available for small pdfmark project help |
Date: |
Wed, 10 Jun 2009 17:43:40 +0100 |
User-agent: |
KMail/1.9.10 |
On Monday 08 June 2009 01:10:45 address@hidden wrote:
> Here is what I would like to do:
>
> groff -mpdfmark mymacrofile mytitle myfile mybiblio > myfile.ps
>
> I do not us ms macros, nor any other macro package. I use a
> custom package.
Ok. No problem with that. Just take care to complete the .pdfsync
actions, at the end of each formatting pass; (use an end macro).
> I would like the TOC to appear after the output from mytitle,
Ok.
> though I understand this is appended to the file at the end.
It is, if you use the standard TOC generation macros in ms; since you
are using your own custom macro package, it's placed wherever you
have provided for it.
> So I strip N .ps pages of TOC off the end of the postscript file,
> and insert it after mytitle output, before myfile output begins.
Yuk! That's precisely the sort of collation nightmare you want to
avoid; (it's more or less what pdfroff does, but it isn't nice).
> Seems to me I could also insert between mytitle and myfile a
> mytoc file which contains all the necessary info to have a
> linkable toc, thus no striping, no inserting required,
Yes, that's the strategy to strive for; consider:
<input name="mymaster">
.so mymacrofile
.so mytitle
.so mytoc
.open toc mytoc
.so myfile
.so mybiblio
.close toc
</input>
<input name="myfile">
...
.write toc markup to create TOC entry
...
.write toc markup for another TOC entry
...
</input>
$ touch mytoc
$ groff -mpdfmark mymaster > myfile.ps
> perhaps a multiple pass to gather the necessary data.
At least three passes are required; (page numbers will change between
first and second passes, so a correctly generated mytoc will not be
available until the third pass begins, at the earliest).
> I see pdfroff uses awk to find .pdfhref D -N lines and saves
> this to a file.
Uhm; not quite! The pdfmark macros emit some cryptically formatted
information on standard error. pdfroff captures this, and filters
out particular patterns. It uses one class of such patterns as a
basis from which it *creates* ".pdfhref D" markup; this represents
the exported reference dictionary, derived from ".pdfhref M -X"
markup in the original document source.
> I see pdfroff uses awk again to find .pdfhref Z $2 $3 $4 and
> appends this to a file.
Again, not quite. Once more, it *creates* the ".pdfhref Z" markup,
on the basis of grohtml patterns filtered from standard error; these
represent the page co-ordinates of any ".pdfhref L" markup in the
source.
> Question remains, how do I create this auxiliary file you speak
> of that contains the info necessary to create functional toc
> links ?!?
You can use groff's open, write and close requests, as indicated in
the outline above.
> And what ought this file look like ?!?
Plain text, containing troff markup; likely no more than something
along the lines of:
.pdfhref L -D <tag1> -- "Introduction\0\0\a\t7"
.pdfhref L -D <tag2> -- "Another Heading\0\0\a\t9"
.pdfhref L -D <tag3> -- ...
> I prefer to stay within a perl environment to do this if possible.
Sorry. Can't help you there. What's wrong with staying within a
*groff* environment? I've attached a couple of toy document samples
which illustrate the principles. They are based on ms macros, but
actually use only SH to create the section headings, (and LP for the
following paragraphs, but this plays no part in the TOC generation);
you will need to adapt them, to work with your own macro set.
--
Regards,
Keith.
toc-example-1.ms.zip
Description: Zip archive
toc-example-2.ms.zip
Description: Zip archive