mathjax/MathJax — Issue #190: MathML in XHTML not parsing in IE
Author: bthomale
Created: 2012-02-06 20:12:38+00:00
State: open

We are trying to use MathJax to process MathML embedded in xhtml content.

I noticed that with Internet Explorer 9, all of our attempts to process MathML fail with the generic [Math Processing Error] message. I did some debugging and I think I've narrowed it down. It looks like when it calls innerHTML on a script element containing mathml markup, IE returns "escaped" markup (&lt; instead of < for example) when the current document is XHTML. If its HTML, the markup is not escaped and MathJax works fine.

I've put together an example to demonstrate the bug:

http://okthomale.net/Downloads/MathJax_IE_BUG.zip

If you will download and open the .zip file, you'll see a trivial HTML example and a trivial XHTML sample. Open each of these with IE 9. The HTML one works, the XHTML one fails.

When I put a breakpoint on line 145 of MathML/jax.js, the value of the "math" variable in the XHTML case is:

math	"&lt;m:math xmlns:m=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"&gt;&lt;m:mrow&gt;&lt;m:msub&gt;&lt;m:mi&gt;r&lt;/m:mi&gt;&lt;m:mi&gt;g&lt;/m:mi&gt;&lt;/m:msub&gt;&lt;m:mo&gt;≅&lt;/m:mo&gt;&lt;m:msub&gt;&lt;m:mi&gt;r&lt;/m:mi&gt;&lt;m:mi&gt;a&lt;/m:mi&gt;&lt;/m:msub&gt;&lt;m:mo&gt;−&lt;/m:mo&gt;&lt;/m:mrow&gt;&lt;m:mrow&gt;&lt;m:mfrac&gt;&lt;m:msup&gt;&lt;m:mi&gt;σ&lt;/m:mi&gt;&lt;m:mn&gt;2&lt;/m:mn&gt;&lt;/m:msup&gt;&lt;m:mn&gt;2&lt;/m:mn&gt;&lt;/m:mfrac&gt;&lt;/m:mrow&gt;&lt;/m:math&gt;"	String

When it calls mml = MATHML.Parse(math).mml; on line 145, this causes it to throw an exception when it parses this XML.

In the html version of the document, the value of math on this line is:

math	"<math display=\"block\"><mrow><msub><mi>r</mi><mi>g</mi></msub><mo>≅</mo><msub><mi>r</mi><mi>a</mi></msub><mo>−</mo></mrow><mrow><mfrac><msup><mi>σ</mi><mn>2</mn></msup><mn>2</mn></mfrac></mrow></math>"	String

And this works just fine.

I was debugging this with the current release of MathJax (1.1a) - the line number referenced here is the line number in the download distribution.