diff options
| author | Georg Brandl <georg@python.org> | 2010-10-22 11:16:23 +0200 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2010-10-22 11:16:23 +0200 |
| commit | ec3b7290dc64985dfe7a039df5850772c19b1834 (patch) | |
| tree | f51c4e8c7c0582228774969611d1f00c52d0a20e /sphinx/ext/mathbase.py | |
| parent | 590c57c8a16486c4e2cdff6d79f33b3faacf2d68 (diff) | |
| download | sphinx-ec3b7290dc64985dfe7a039df5850772c19b1834.tar.gz | |
Add add_node() support for texinfo and add handlers for nodes in our extensions.
Diffstat (limited to 'sphinx/ext/mathbase.py')
| -rw-r--r-- | sphinx/ext/mathbase.py | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/sphinx/ext/mathbase.py b/sphinx/ext/mathbase.py index 8a5b75d3..6c67265a 100644 --- a/sphinx/ext/mathbase.py +++ b/sphinx/ext/mathbase.py @@ -13,6 +13,7 @@ from docutils import nodes, utils from docutils.parsers.rst import directives from sphinx.util.compat import Directive +from sphinx.writers.texinfo import escape class math(nodes.Inline, nodes.TextElement): @@ -122,6 +123,20 @@ def man_visit_eqref(self, node): raise nodes.SkipNode +def texinfo_visit_math(self, node): + self.body.append('@math{' + escape(node['latex']) + '}') + raise nodes.SkipNode + +def texinfo_visit_displaymath(self, node): + self.visit_paragraph(self, node) +def texinfo_depart_displaymath(self, node): + self.depart_paragraph(self, node) + +def texinfo_visit_eqref(self, node): + self.body.append(node['target']) + raise nodes.SkipNode + + def html_visit_eqref(self, node): self.body.append('<a href="#equation-%s">' % node['target']) @@ -148,20 +163,23 @@ def number_equations(app, doctree, docname): def setup_math(app, htmlinlinevisitors, htmldisplayvisitors): app.add_node(math, - latex=(latex_visit_math, None), - text=(text_visit_math, None), - man=(man_visit_math, None), - html=htmlinlinevisitors) + latex=(latex_visit_math, None), + text=(text_visit_math, None), + man=(man_visit_math, None), + texinfo=(texinfo_visit_math, None), + html=htmlinlinevisitors) app.add_node(displaymath, - latex=(latex_visit_displaymath, None), - text=(text_visit_displaymath, None), - man=(man_visit_displaymath, man_depart_displaymath), - html=htmldisplayvisitors) + latex=(latex_visit_displaymath, None), + text=(text_visit_displaymath, None), + man=(man_visit_displaymath, man_depart_displaymath), + texinfo=(texinfo_visit_displaymath, texinfo_depart_displaymath), + html=htmldisplayvisitors) app.add_node(eqref, - latex=(latex_visit_eqref, None), - text=(text_visit_eqref, None), - man=(man_visit_eqref, None), - html=(html_visit_eqref, html_depart_eqref)) + latex=(latex_visit_eqref, None), + text=(text_visit_eqref, None), + man=(man_visit_eqref, None), + texinfo=(texinfo_visit_eqref, None), + html=(html_visit_eqref, html_depart_eqref)) app.add_role('math', math_role) app.add_role('eq', eq_role) app.add_directive('math', MathDirective) |
