[Doc-SIG] simple use of docutils
Michael Hudson
mwh@python.net
10 Oct 2002 20:12:37 +0100
I have an application where I want to programmatically use docutils.
So, I have a chuck of text (or a file, both are equally easy) in rst
format that I want to turn into html (again, either a file, or as
text).
This doesn't seem to be totally straightforward.
I have code like this:
from docutils.core import Publisher
from docutils.io import FileInput
pub = Publisher(source=FileInput(None, source_path=filename),
destination=htname)
pub.set_options()
pub.set_reader('standalone', None, 'restructuredtext')
pub.set_writer('html')
pub.publish()
But that's not enough -- I have to cook up mythical 'option' objects
from somewhere.
Clearly, I haven't really read the docs.
Is there an easy way of doing what I want?
There should be.
Cheers,
M.
--
Sufficiently advanced political correctness is indistinguishable
from irony. -- Erik Naggum