def _unescape_math(xml):
    """Unescapes Math from Mathjax to MathML."""
    xpath_math_script = etree.XPath(
            '//x:script[@type="math/mml"]',
            namespaces={'x': 'http://www.w3.org/1999/xhtml'})
    math_script_list = xpath_math_script(xml)
    for mathscript in math_script_list:
        math = mathscript.text
        # some browsers double escape like e.g. Firefox
        math = unescape(unescape(math))
        mathscript.clear()
        mathscript.set('type', 'math/mml')
        new_math = etree.fromstring(math)
        mathscript.append(new_math)
    return xml
def _unescape_math ( xml ) : xpath_math_script = etree . XPath ( '//x:script[@type="math/mml"]' , namespaces = { 'x' : 'http://www.w3.org/1999/xhtml' } ) math_script_list = xpath_math_script ( xml ) for mathscript in math_script_list : math = mathscript . text math = unescape ( unescape ( math ) ) mathscript . clear ( ) mathscript . set ( 'type' , 'math/mml' ) new_math = etree . fromstring ( math ) mathscript . append ( new_math ) return xml
Unescapes Math from Mathjax to MathML.