Skip to content

Instantly share code, notes, and snippets.

@ikasamt
Created January 25, 2012 03:27
Show Gist options
  • Save ikasamt/1674544 to your computer and use it in GitHub Desktop.
Save ikasamt/1674544 to your computer and use it in GitHub Desktop.
RestructuredTextを構築する関数
import docutils.core
def render_restructured_text(src):
settings = {
"stylesheet": "",
"stylesheet_path": None,
}
html = docutils.core.publish_string(src, writer_name='html', settings_overrides=settings)
html = html[html.find('<body>')+6:html.find('</body>')].strip()
return html
def read_as_restructured_text(filename):
text = open("memo/%s" % filename).read()
html = render_restructured_text(text)
return html
if __name__ == '__main__':
src = """\
* foo
* bar
* baz
"""
print render_restructured_text(src)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment