mathmpl.py 文件源码

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

项目:scipy-lecture-notes-zh-CN 作者: jayleicn 项目源码 文件源码
def latex2html(node, source):
    inline = isinstance(node.parent, nodes.TextElement)
    latex = node['latex']
    name = 'math-%s' % md5(latex).hexdigest()[-10:]
    dest = '_static/%s.png' % name
    depth = latex2png(latex, dest, node['fontset'])

    path = '_static'
    count = source.split('/doc/')[-1].count('/')
    for i in range(count):
        if os.path.exists(path): break
        path = '../'+path
    path = '../'+path #specifically added for matplotlib
    if inline:
        cls = ''
    else:
        cls = 'class="center" '
    if inline and depth != 0:
        style = 'style="position: relative; bottom: -%dpx"' % (depth + 1)
    else:
        style = ''

    return '<img src="%s/%s.png" %s%s/>' % (path, name, cls, style)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号