def render_rst(blob, path):
doc = publish_doctree(blob.as_raw_string())
for node in doc.traverse(nodes.reference):
uri = urlparse.urlparse(node['refuri'])
if not uri.netloc and os.path.basename(uri.path) == "README.rst":
node['refuri'] = urlparse.urlunparse(
(uri.scheme, uri.netloc, uri.path[:-10] or "./", uri.params, uri.query, uri.fragment))
output = publish_from_doctree(
doc,
destination_path=path,
writer=MyWriter(),
settings_overrides = {
'embed_stylesheet': False,
'xml_declaration': False,
'math_output': 'mathjax'})
new_blob = Blob.from_string(output)
store.add_object(new_blob)
return new_blob.id
评论列表
文章目录