diff --git a/breathe/renderer/sphinxrenderer.py b/breathe/renderer/sphinxrenderer.py index 60a8b7dc..56ebd932 100644 --- a/breathe/renderer/sphinxrenderer.py +++ b/breathe/renderer/sphinxrenderer.py @@ -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