|
From: David G. <go...@us...> - 2002-07-11 01:58:38
|
Adam Chodorowski wrote: > ... I want to do have news items on the same page for which I > intended to utilize the bibliographic fields repeatedly (once for > each news item, for since the author of each news item can vary and > definately the date). Be careful: although you can use "field lists" repeatedly in a document, only the first field list (before anything but the document title/subtitle) is converted into a **bibliographic** field list. >> I can think of several ways to do what you describe: ... >> Which were you thinking of? > > Something along the lines of (1), although I did not intend to write > the index page in reST with special directives but rather write a > script that calls the docutils tools to generate the full documents > and extract the abstracts into files, which would then be > concatenated with some extra HTML inserted before/after and between > them. Sounds reasonable. You'll still need a specialized front-end to write out both the full processed file and just the abstract. No need for a "transform" per se. Perhaps a subclass of the HTML writer, which knows how to special-case the abstract. Either way, it would be a customization that probably only you would use, and therefore doesn't belong in Docutils. >> The HTML writer already exposes the components, so you can just >> grab the document body (everything inside but not including <body> >> & </body>). Use ``docutils.io.StringIO`` for the >> "destination_class" parameter of >> ``docutils.core.Publisher.__init__`` to avoid writing a file. > > Care to explain a little more? After processing to HTML, ``writer.body`` (attribute "body" of the Writer object) will contain the text (Unicode string) of the HTML between <body> & </body> (excluding any output of the "header" and "footer" nodes). Combine that with a "docutils.io.StringIO" object (or a soon-to-be-implemented "NullIO" object), and you can get just the processed document body that you want. > Perhaps I should take a closer look at the relevant sources. Always helpful! >> However, the idea of custom headers & footers is what inspired the >> "decoration" element (which contains "header" & "footer" elements). >> It hasn't been fully developed yet. > > Isn't that supposed to be a generic part of docutils for all kinds > of writers? I am not so interested in that, since the "decorations" > that I want for my online HTML version differ very greatly from the > decorations I wish to have in the PDF (for example) version. If that's the case, you'll have to do some custom coding. Either custom writers for your application, or custom format-sensitive transforms activated via a "pending" element in the header/footer. See "docutils.parsers.rst.directives.parts.contents" for an example. Or a templating engine. -- David Goodger <go...@us...> Open-source projects: - Python Docutils: http://docutils.sourceforge.net/ (includes reStructuredText: http://docutils.sf.net/rst.html) - The Go Tools Project: http://gotools.sourceforge.net/ |