mathml.py 文件源码

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

项目:scipy-lecture-notes-zh-CN 作者: jayleicn 项目源码 文件源码
def setup(app):
    app.add_node(latex_math)
    app.add_role('math', math_role)

    # Add visit/depart methods to HTML-Translator:
    def visit_latex_math_html(self, node):
        mathml = ''.join(node['mathml_tree'].xml())
        self.body.append(mathml)
    def depart_latex_math_html(self, node):
            pass
    HTMLTranslator.visit_latex_math = visit_latex_math_html
    HTMLTranslator.depart_latex_math = depart_latex_math_html

    # Add visit/depart methods to LaTeX-Translator:
    def visit_latex_math_latex(self, node):
        inline = isinstance(node.parent, nodes.TextElement)
        if inline:
            self.body.append('$%s$' % node['latex'])
        else:
            self.body.extend(['\\begin{equation}',
                              node['latex'],
                              '\\end{equation}'])
    def depart_latex_math_latex(self, node):
            pass
    LaTeXTranslator.visit_latex_math = visit_latex_math_latex
    LaTeXTranslator.depart_latex_math = depart_latex_math_latex


# LaTeX to MathML translation stuff:
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号