publish.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:lift-tutorial 作者: bhuztez 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号