Discussion:
[Docutils-users] generating & embedding reStructuredText
philip grabner
2013-09-26 22:34:50 UTC
Permalink
hello docutils-users,

i'm working on a tool that generates reStructuredText
(https://pypi.python.org/pypi/pyramid_describe) which embeds rST text
from external sources. the other sources can potentially define titled
sections, which is leading to a "SystemMessage: (SEVERE/4) Title level
inconsistent" error.

the "obvious to me" way to solve this is to parse the embedded source
into a doctree using docutils, insert the result into the appropriate
place in the doctree generated by the tool, and then write the whole
thing out to rST.

unfortunately, there does not seem to be a "docutils.writers.rst" module
that takes a doctree and generates rST output...

what is the best way to do this?

thanks!

ps: i'm not subscribed to docutils-users, so please keep me in the cc-list.
Stefan Merten
2013-09-29 11:24:58 UTC
Permalink
Hi Philip!
Post by philip grabner
unfortunately, there does not seem to be a "docutils.writers.rst" module
that takes a doctree and generates rST output...
what is the best way to do this?
There is `xml2rst` in the sandbox
(http://svn.code.sf.net/p/docutils/code/trunk/sandbox/xml2rst/) which
transforms Docutils XML into reStructuredText source. Though it
doesn't accept a Docutils tree there is a Docutils XML writer which in
combination may solve your problem.


Grüße

Stefan

Loading...