Parsing reStructuredText into HTML

后端 未结 1 1222
独厮守ぢ
独厮守ぢ 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']
    

    anurag

    0 讨论(0)
提交回复
热议问题