mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #5419: incompatible math_block node has been generated
This commit is contained in:
parent
8c56fd8747
commit
d327daba65
1
CHANGES
1
CHANGES
@ -24,6 +24,7 @@ Bugs fixed
|
||||
* #5495: csv-table directive with file option in included file is broken (refs:
|
||||
#4821)
|
||||
* #5498: autodoc: unable to find type hints for a ``functools.partial``
|
||||
* #5419: incompatible math_block node has been generated
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -64,19 +64,23 @@ class MathNodeMigrator(SphinxTransform):
|
||||
nowrap=node.get('nowrap'),
|
||||
docname=node.get('docname'))
|
||||
node.replace(alt)
|
||||
else:
|
||||
# case: old styled ``displaymath`` node generated by old extensions
|
||||
for node in self.document.traverse(math_block):
|
||||
if len(node) == 0:
|
||||
warnings.warn("math node for Sphinx was replaced by docutils'. "
|
||||
"Please use ``docutils.nodes.math_block`` instead.",
|
||||
RemovedInSphinx30Warning)
|
||||
if isinstance(node, displaymath):
|
||||
newnode = nodes.math_block('', node['latex'], **node.attributes)
|
||||
node.replace_self(newnode)
|
||||
else:
|
||||
latex = node['latex']
|
||||
node += nodes.Text(latex, latex)
|
||||
elif getattr(self.app.builder, 'math_renderer_name', None) == 'unknown':
|
||||
# case: math extension provides old styled math renderer
|
||||
for node in self.document.traverse(nodes.math_block):
|
||||
node['latex'] = node.astext()
|
||||
|
||||
# case: old styled ``displaymath`` node generated by old extensions
|
||||
for node in self.document.traverse(math_block):
|
||||
if len(node) == 0:
|
||||
warnings.warn("math node for Sphinx was replaced by docutils'. "
|
||||
"Please use ``docutils.nodes.math_block`` instead.",
|
||||
RemovedInSphinx30Warning)
|
||||
if isinstance(node, displaymath):
|
||||
newnode = nodes.math_block('', node['latex'], **node.attributes)
|
||||
node.replace_self(newnode)
|
||||
else:
|
||||
latex = node['latex']
|
||||
node += nodes.Text(latex, latex)
|
||||
|
||||
|
||||
def setup(app):
|
||||
|
Loading…
Reference in New Issue
Block a user