RSTRenderer.py 438 B

12345678910111213141516
  1. from docutils.core import publish_parts
  2. import rst_directive
  3. class RSTRenderer():
  4. """The RSTRenderer uses docutils to render reStructuredText content."""
  5. def __init__(self):
  6. super().__init__()
  7. def render_string(self, astring):
  8. astring = '.. sectnum::\n\n' + astring
  9. # astring = '.. contents:: Table of Contents\n\n' + astring
  10. return publish_parts(astring, writer_name='html')['html_body']