def html_visit_displaymath(self: HTMLTranslator, node: nodes.math_block) -> None: """Override for sphinx.ext.mathjax.html_visit_displaymath to handle amsmath. By default displaymath, are normally wrapped in a prefix/suffix, defined by mathjax_display, and labelled nodes are numbered. However, this is not the case if the math_block is set as 'nowrap', as for amsmath. Therefore, we need to override this behaviour. """ if "amsmath" in node.get("classes", []): self.body.append( self.starttag(node, "div", CLASS="math notranslate nohighlight amsmath")) if node["number"]: number = get_node_equation_number(self, node) self.body.append('<span class="eqno">(%s)' % number) self.add_permalink_ref(node, _("Permalink to this equation")) self.body.append("</span>") prefix, suffix = self.builder.config.mathjax_display self.body.append(prefix) self.body.append(self.encode(node.astext())) self.body.append(suffix) self.body.append("</div>\n") raise nodes.SkipNode return mathjax.html_visit_displaymath(self, node)
def ext_html_visit_displaymath(self, node): html_transform_math_xref(node) html_visit_displaymath(self, node)