Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pandoc: Javascript at standalone HTML + MathML

37 views
Skip to first unread message

Raniere Silva

unread,
Dec 19, 2014, 9:21:47 AM12/19/14
to dev-tec...@lists.mozilla.org
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 <ran...@ime.unicamp.br> -----

Date: Tue, 16 Dec 2014 09:37:22 -0200
From: Raniere Silva <ran...@ime.unicamp.br>
To: pandoc-...@googlegroups.com
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 -----
signature.asc

David Carlisle

unread,
Dec 19, 2014, 9:31:58 AM12/19/14
to dev-tec...@lists.mozilla.org
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

0 new messages