Nudge needed for rst to html

Stefan Rank list-ener at strank.info
Thu Sep 6 07:37:50 EDT 2007


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).
> 
> I thought that:
> 
> <code>
> import docutils.core
> 
> html = docutils.core.publish_string ("Hello, world!", writer_name="html")
> 
> </code>
> 
> would do the trick, but that produces an entire document with
> an embedded style block.

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

cheers,
stefan




More information about the Python-list mailing list