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)
评论列表
文章目录