Fix #5419: incompatible math_block node has been generated

This commit is contained in:
Takeshi KOMIYA 2018-10-15 21:45:43 +09:00
parent 8c56fd8747
commit d327daba65
2 changed files with 18 additions and 13 deletions

View File

@ -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
--------

View File

@ -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):