Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to render MathML content in Google Chrome

I have some MathML contents in HTML page and the page needs to be rendered in Google Chrome over HTTPS connection. So i tried to follow the approach said in the below link

Displaying Mathml equations

but it did not work (I copied the script in my HTML page). Then I tried to install the MathJax plugin for chrome as an extension to Google Chrome. That seemed to render some of MathML in my file but for some I got an error. I found that MathJax can render Presentation MathML contents but cannot render Content MathML contents (I have both types of contents in my page). Also it did not work over HTTPS connection. It will be very helpful if I get some workarounds to solve this problem.

Regards, Anirban

like image 882
Anirban Avatar asked Apr 16 '15 17:04

Anirban


2 Answers

The question linked to in the OP is somewhat dated and describes how to include MathML in xhtml (not html since that was not actually valid back then). With HTML5, it's much easier to include MathML.

Chrome does not support MathML so you'll need a polyfill. MathJax can render both Presentation and Content MathML; see the relevant documentation at http://docs.mathjax.org/en/latest/ .

However, the author needs to configure MathJax correctly to do so. FYI, plugins in the Chrome store are made by third parties; also, MathJax works over https just fine if done correctly.

Below is an example that shows how to enable all MathML features MathJax can provide, including the mml3.js extension for experimental features.

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Fullest MathML support using MathJax</title>
  <script>window.MathJax = { MathML: { extensions: ["mml3.js", "content-mathml.js"]}};</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=MML_HTMLorMML"></script>
</head>
<body>
  <math display="block"> 
    <apply> 
      <plus/> 
      <ci>a</ci> 
      <apply> 
        <minus/> 
        <ci>b</ci> 
        <ci>c</ci> 
      </apply> 
    </apply> 
  </math> 
  <math display="block">
    <mrow>
      <mi>a</mi>
      <mo>+</mo>
      <mrow>
        <mi>b</mi>
        <mo>-</mo>
        <mi>c</mi>
      </mrow>
    </mrow>
  </math>

</body>
</html>
like image 108
Peter Krautzberger Avatar answered Sep 29 '22 23:09

Peter Krautzberger


This worked really well for me when i was in a similar situation..

Add these scripts in the <head>

<script type="text/x-mathjax-config">MathJax.Hub.Config({
  config: ["MMLorHTML.js"],
  jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML"],
  extensions: ["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js"],
  TeX: {
    extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
  }
});</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/2.0-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

Then,

add this <script> after the closing of the <body> tag

<script type="text/javascript">
  MathJax.Hub.Configured()
</script>

See the documentation

or

you can see this wonderfull example.. https://math.stackexchange.com/ .. Check the source of math.stackexchange..It will be really helpfull..

UPDATE

See page no 54 in this link..It says

MathJax supports the MathML3.0 mathematics tags, with some limitations. The MathML support is still under active development, so some tags are not yet implemented, and some features are not fully developed, but are coming. The deficiencies include:

• No support for alignment groups in tables.

• Not all attributes are supported for tables. E.g., columnspan and rowspan are not implemented yet.

•Experimental support for the elementary math tags: mstack, mlongdiv, msgroup, msrow, mscarries, and mscarry. (Via the mml3 extension, see below.)

• Experimental support for bidirectional mathematics.

like image 28
Lal Avatar answered Sep 29 '22 23:09

Lal