Nudge needed for rst to html

Tim Golden mail at timgolden.me.uk
Thu Sep 6 07:45:04 EDT 2007


Stefan Rank wrote:

> on 06.09.2007 13:16 Tim Golden said the following:
>> I'm a bit embarrassed about this, but I've scoured
>> the docutils docs and I can't seem to work out how
>> to take a block of ReStructuredText and output a
>> raw HTML fragment, ideally without a surrounding
>> document or embedded/linked css etc. (I'm trying
>> to allow rst in our helpdesk system which can render
>> nicely on the web version and be readable in text).

> try this::
> 
>    import docutils.core
> 
>    parts = docutils.core.publish_parts("Hello!", writer_name="html")
>    html = parts['body']
> 
> tfm: http://docutils.sourceforge.net/docs/api/publisher.html

Exactly the nudge I needed. Thanks very much, Stefan.

TJG



More information about the Python-list mailing list