From: David G. <go...@py...> - 2015-01-08 02:29:35
|
On Wed, Jan 7, 2015 at 7:52 PM, Ben Finney <ben...@be...> wrote: > David Goodger <go...@py...> writes: > >> On Tue, Jan 6, 2015 at 11:20 PM, Ben Finney <ben...@be...> wrote: >> > What I want is: >> > >> > ===== >> > $ rst2pseudoxml < foo.txt >> > <document source="<stdin>"> >> > <section ids="first-section" names="first\ section"> >> > <title> >> > First Section >> > <paragraph> >> > Lorem ipsum, dolor sit amet. >> > ===== >> > >> > In fact, I'm accessing this document programmatically using a custom >> > Writer. How can I get the parsing result I want? >> >> http://docutils.sourceforge.net/docs/user/config.html#doctitle-xform > > Thanks. Okay, that is a setting on the Publisher (and, according to the > docs, normally set by configuration file or command-line). > > For the task at hand (if it matters, I am transforming a changelog > document to structured release data), I want all the settings to be > internally managed. > > So far I've only needed to make a custom Writer class and a custom > Translator class. Unit tests for those are already cumbersome; I would > really prefer not to need creating yet another custom class. > > In order to modify that setting (‘doctitle_xform’), do I need to make a > custom Publisher class too? Or can I have the Writer somehow override > it? Just pass the configuration setting to the standard Publisher or convenience function: http://docutils.sourceforge.net/docs/api/publisher.html#configuration -- David Goodger <http://python.net/~goodger> |