/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*************************************************************
*
* MathJax/extensions/mml2jax.js
*
* Implements the MathML to Jax preprocessor that locates )
if (node.outerHTML != null && node.outerHTML.match(/(.<\/[A-Z]+>|\/>)$/)) {
for (i = 0, m = node.childNodes.length; i < m; i++)
{html += this.OuterHTML(node.childNodes[i])}
html += ""+node.nodeName.toLowerCase()+">";
}
}
return html;
},
OuterHTML: function (node) {
if (node.nodeName.charAt(0) === "#") {return this.NodeHTML(node)}
if (!this.AttributeBug) {return node.outerHTML}
var html = this.NodeHTML(node);
for (var i = 0, m = node.childNodes.length; i < m; i++)
{html += this.OuterHTML(node.childNodes[i]);}
html += ""+node.nodeName.toLowerCase()+">";
return html;
},
quoteHTML: function (string) {
if (string == null) {string = ""}
return string.replace(/&/g,"&").replace(//g,">").replace(/\"/g,""");
},
createPreview: function (math,script) {
var preview = this.config.preview;
if (preview === "none") return;
if (preview === "alttext") {
var text = math.getAttribute("alttext");
if (text != null) {preview = [this.filterPreview(text)]} else {preview = null}
}
if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
script.parentNode.insertBefore(preview,script);
}
},
filterPreview: function (text) {return text},
InitBrowser: function () {
var test = MathJax.HTML.Element("span",{id:"<", className: "mathjax", innerHTML: "x"});
var html = test.outerHTML || "";
this.AttributeBug = html !== "" && !(
html.match(/id="<"/) && // "<" should convert to "<"
html.match(/class="mathjax"/) && // IE leaves out quotes
html.match(/<\/math>/) // Opera 9 drops tags after self-closing tags
);
this.MathTagBug = test.childNodes.length > 1; // IE < 9 flattens unknown tags
this.CleanupHTML = MathJax.Hub.Browser.isMSIE; // remove namespace and other added tags
}
};
MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.mml2jax]);
MathJax.Ajax.loadComplete("[MathJax]/extensions/mml2jax.js");