Skip to content

Commit

Permalink
Merge pull request #506 from maximiliank/master
Browse files Browse the repository at this point in the history
Fixed creation of LaTeX math formulas (#502)
  • Loading branch information
vermeeren authored Apr 18, 2020
2 parents 5c0416e + 0834acf commit 83f9ca8
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,35 +805,26 @@ def visit_docformula(self, node):

latex = item.getValue()

# Somewhat hacky if statements to strip out the doxygen markup that slips through

rst_node = None

docname = self.state.document.settings.env.docname
# Strip out the doxygen markup that slips through
# Either inline
if latex.startswith("$") and latex.endswith("$"):
latex = latex[1:-1]

# If we're inline create a math node like the :math: role
rst_node = self.node_factory.math()
nodelist.append(self.node_factory.math(text=latex,
label=None,
nowrap=False,
docname=docname,
number=None))
# Else we're multiline
else:
# Else we're multiline
rst_node = self.node_factory.math_block()

# Or multiline
if latex.startswith("\\[") and latex.endswith("\\]"):
latex = latex[2:-2:]

# Here we steal the core of the mathbase "math" directive handling code from:
# sphinx.ext.mathbase
rst_node["latex"] = latex

# Required parameters which we don't have values for
rst_node["label"] = None
rst_node["nowrap"] = False
rst_node["docname"] = self.state.document.settings.env.docname
rst_node["number"] = None

nodelist.append(rst_node)
if latex.startswith("\\[") and latex.endswith("\\]"):
latex = latex[2:-2:]

nodelist.append(self.node_factory.math_block(text=latex,
label=None,
nowrap=False,
docname=docname,
number=None))

return nodelist

Expand Down

0 comments on commit 83f9ca8

Please sign in to comment.