Address review comments. #557
This commit is contained in:
parent
aad3a6edc2
commit
a9d812398b
|
@ -53,12 +53,12 @@ MathJax.Extension.mml2jax = {
|
||||||
//
|
//
|
||||||
// Handle all math tags with no namespaces
|
// Handle all math tags with no namespaces
|
||||||
//
|
//
|
||||||
this.AppendMathElements(mathArray,element.getElementsByTagName("math"));
|
mathArray.push.apply(mathArray,element.getElementsByTagName("math"));
|
||||||
//
|
//
|
||||||
// Handle math with namespaces in XHTML
|
// Handle math with namespaces in XHTML
|
||||||
//
|
//
|
||||||
if (element.getElementsByTagNameNS)
|
if (element.getElementsByTagNameNS)
|
||||||
{this.AppendMathElements(mathArray,element.getElementsByTagNameNS(this.MMLnamespace,"math"))}
|
{mathArray.push.apply(mathArray,element.getElementsByTagNameNS(this.MMLnamespace,"math"))}
|
||||||
//
|
//
|
||||||
// Handle math with namespaces in HTML
|
// Handle math with namespaces in HTML
|
||||||
//
|
//
|
||||||
|
@ -71,7 +71,7 @@ MathJax.Extension.mml2jax = {
|
||||||
for (i = 0, m = document.namespaces.length; i < m; i++) {
|
for (i = 0, m = document.namespaces.length; i < m; i++) {
|
||||||
var ns = document.namespaces[i];
|
var ns = document.namespaces[i];
|
||||||
if (ns.urn === this.MMLnamespace)
|
if (ns.urn === this.MMLnamespace)
|
||||||
{this.AppendMathElements(mathArray,element.getElementsByTagName(ns.name+":math"))}
|
{mathArray.push.apply(mathArray,element.getElementsByTagName(ns.name+":math"))}
|
||||||
}
|
}
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,36 +83,30 @@ MathJax.Extension.mml2jax = {
|
||||||
for (i = 0, m = html.attributes.length; i < m; i++) {
|
for (i = 0, m = html.attributes.length; i < m; i++) {
|
||||||
var attr = html.attributes[i];
|
var attr = html.attributes[i];
|
||||||
if (attr.nodeName.substr(0,6) === "xmlns:" && attr.nodeValue === this.MMLnamespace)
|
if (attr.nodeName.substr(0,6) === "xmlns:" && attr.nodeValue === this.MMLnamespace)
|
||||||
{this.AppendMathElements(mathArray,element.getElementsByTagName(attr.nodeName.substr(6)+":math"))}
|
{mathArray.push.apply(mathArray,element.getElementsByTagName(attr.nodeName.substr(6)+":math"))}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.ProcessMathArray(mathArray);
|
this.ProcessMathArray(mathArray);
|
||||||
},
|
},
|
||||||
|
|
||||||
AppendMathElements: function(mathArray, math) {
|
|
||||||
if (math.length) {
|
|
||||||
for (var i = math.length-1; i >= 0; i--) {mathArray.push(math[i])}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
ProcessMathArray: function (math) {
|
ProcessMathArray: function (math) {
|
||||||
var i;
|
var i, m = math.length;
|
||||||
if (math.length) {
|
if (m) {
|
||||||
if (this.MathTagBug) {
|
if (this.MathTagBug) {
|
||||||
for (i = math.length-1; i >= 0; i--) {
|
for (i = 0; i < m; i++) {
|
||||||
if (math[i].nodeName === "MATH") {this.ProcessMathFlattened(math[i])}
|
if (math[i].nodeName === "MATH") {this.ProcessMathFlattened(math[i])}
|
||||||
else {this.ProcessMath(math[i])}
|
else {this.ProcessMath(math[i])}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = math.length-1; i >= 0; i--) {this.ProcessMath(math[i])}
|
for (i = 0; i < m; i++) {this.ProcessMath(math[i])}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
ProcessMath: function (math) {
|
ProcessMath: function (math) {
|
||||||
var parent = math.parentNode;
|
var parent = math.parentNode;
|
||||||
if (!parent || parent.className === "MathJax_Preview") return;
|
if (!parent || parent.className === MathJax.Hub.config.preRemoveClass) return;
|
||||||
var script = document.createElement("script");
|
var script = document.createElement("script");
|
||||||
script.type = "math/mml";
|
script.type = "math/mml";
|
||||||
parent.insertBefore(script,math);
|
parent.insertBefore(script,math);
|
||||||
|
@ -132,7 +126,7 @@ MathJax.Extension.mml2jax = {
|
||||||
|
|
||||||
ProcessMathFlattened: function (math) {
|
ProcessMathFlattened: function (math) {
|
||||||
var parent = math.parentNode;
|
var parent = math.parentNode;
|
||||||
if (!parent || parent.className === "MathJax_Preview") return;
|
if (!parent || parent.className === MathJax.Hub.config.preRemoveClass) return;
|
||||||
var script = document.createElement("script");
|
var script = document.createElement("script");
|
||||||
script.type = "math/mml";
|
script.type = "math/mml";
|
||||||
parent.insertBefore(script,math);
|
parent.insertBefore(script,math);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user