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