Quantcast

Pandoc: Javascript at standalone HTML + MathML

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Pandoc: Javascript at standalone HTML + MathML

Raniere Silva
Hi all,

I was playing with convert Markdown + LaTeX to HTML + MathML with Pandoc.
I notice that the standalone HTML template used by Pandoc has a Javascript
function to convert MathML elements.

I ask at Pandoc list and John said that the Javascript was there for years. I
believe that we don't need it anymore but want to check with you.

Cheers,
Raniere

----- Forwarded message from Raniere Silva <[hidden email]> -----

Date: Tue, 16 Dec 2014 09:37:22 -0200
From: Raniere Silva <[hidden email]>
To: [hidden email]
Subject: Javascript at standalone HTML + MathML
User-Agent: Mutt/1.5.23 (2014-03-12)

When I ran
   
    $ cat sample.tex
    foo $x$ bar
    $ pandoc -v | head -n 1
    pandoc 1.13.2
    $ pandoc -s -f latex -t html --mathml sample.tex | head -n 33
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="Content-Style-Type" content="text/css" />
      <meta name="generator" content="pandoc" />
      <title></title>
      <style type="text/css">code{white-space: pre;}</style>
      <script type="text/javascript">/*<![CDATA[*/
      /*
      March 19, 2004 MathHTML (c) Peter Jipsen http://www.chapman.edu/~jipsen
      Released under the GNU General Public License version 2 or later.
      See the GNU General Public License (at http://www.gnu.org/copyleft/gpl.html)
      for more details.
      */
     
      function convertMath(node) {// for Gecko
        if (node.nodeType==1) {
          var newnode =
            document.createElementNS("http://www.w3.org/1998/Math/MathML",
              node.nodeName.toLowerCase());
          for(var i=0; i < node.attributes.length; i++)
            newnode.setAttribute(node.attributes[i].nodeName,
              node.attributes[i].value);
          for (var i=0; i<node.childNodes.length; i++) {
            var st = node.childNodes[i].nodeValue;
            if (st==null || st.slice(0,1)!=" " && st.slice(0,1)!="\n")
              newnode.appendChild(convertMath(node.childNodes[i]));
          }
          return newnode;
        }
        else return node;
      }

I notice the Javascript function convertMath for Firefox/Gecko. Wasn't clear to
me why we need this. Anyone can give me a explanation?

Thanks,
Raniere



----- End forwarded message -----

_______________________________________________
dev-tech-mathml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-mathml

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pandoc: Javascript at standalone HTML + MathML

David Carlisle
On 19/12/2014 13:09, Raniere Silva wrote:
> I notice the Javascript function convertMath for Firefox/Gecko. Wasn't clear to
> me why we need this. Anyone can give me a explanation?

originally math elements only parsed into the mathml namespace and got
rendered in XHTML parsing, the HTML4 parser just rendered them as
unknown elements. That function allowed rendering in text/html by
lifting them out and replacing each math element with a a "copy" using
mathml namespace elements.

So it's not needed since the HTML5 parser does this automatically.

David

_______________________________________________
dev-tech-mathml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-mathml
Loading...