Parsing reStructuredText into HTML

后端 未结 1 1221
独厮守ぢ
独厮守ぢ 2020-12-12 16:08

I\'m making a framework in which I let developers describe their package using reStructuredText. I want to parse that reStructuredText into HTML so I can show it in a GUI.

相关标签:
1条回答
  • 2020-12-12 17:01

    Try something like this:

    >>> from docutils.core import publish_string
    >>> publish_string("*anurag*", writer_name='html')
    

    publish_string accepts a strings and outputs a string or you can use publish_parts to get specific parts of html document e.g.

    >>> from docutils.core import publish_parts
    >>> print publish_parts("*anurag*", writer_name='html')['html_body']
    <p><em>anurag</em></p>
    
    0 讨论(0)
提交回复
热议问题