Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying Mathml equations

Tags:

mathml

My browser, Firefox 3.6, seems to display the Mathml equations in the W3C test suite just fine. But if I copy the code into my webpage, like from here, all Firefox produces is something like x y x y instead of how it correctly rendered the W3C page. What am I missing here>

EDIT: I just tried it in Chrome and Chrome failed the test itself by rendering it as x y x y. Needless to say, it rendered the math in my own webpage the same.

EDIT 2: I tried it on a new html document. Doesn't work:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title></title>
  </head>
  <body>
<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML" mode="display">
  <mfrac>
    <mi>x</mi>
    <mi>y</mi>
  </mfrac>
    </math>
    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML" mode="inline">
  <mfrac>
    <mi>x</mi>
    <mi>y</mi>
      </mfrac>
    </math>
  </body>
</html>

I swear the W3C equations render just fine though...

like image 768
wrongusername Avatar asked Nov 13 '10 19:11

wrongusername


2 Answers

Including

<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=MML_HTMLorMML"></script>

and then using

    <math xmlns="http://www.w3.org/1998/Math/MathML">
        <mroot>
            <mrow>
                <mi>x</mi>
            </mrow>
            <mn>4</mn>
        </mroot>
    </math>

works in Chrome and Firefox

Update:

Since the mathjax cdn is shutting down, change

<script type="text/javascript" async
  src="https://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...">
</script>

to

<script type="text/javascript" async
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?...">
</script>
like image 89
gaitat Avatar answered Oct 06 '22 17:10

gaitat


as others have said you need to serve as xml for FF3, if you want to use mathml-in-html5 served as text/html you need firefox 4 (or webkit nightlies)

like image 39
David Carlisle Avatar answered Oct 06 '22 17:10

David Carlisle