From 47a7f1f36b69e7dc4921b206f6b204138155a70c Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sun, 21 Aug 2016 12:08:08 -0400 Subject: [PATCH 1/2] Fix incorrect assignments content-mathml extension, and don't modify original document. Resolves issue #1575. --- unpacked/extensions/MathML/content-mathml.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unpacked/extensions/MathML/content-mathml.js b/unpacked/extensions/MathML/content-mathml.js index 666300b19..ab9df08fe 100644 --- a/unpacked/extensions/MathML/content-mathml.js +++ b/unpacked/extensions/MathML/content-mathml.js @@ -1317,9 +1317,11 @@ MathJax.Extension["MathML/content-mathml"] = (function(HUB) { } else if (arg.nodeName === 'apply' && children.length === 2 && children[0].nodeName === 'minus') { CToP.appendToken(mrow,'mo','\u2212'); CToP.applyTransform(mrow,children[1],2); - } else if (arg.nodeName === 'apply' && children.length>2 && children[0].nodeName === 'times' && children[1].nodeName === 'cn' && ( n = Number(CToP.getTextContent(children[1])) < 0)) { + } else if (arg.nodeName === 'apply' && children.length>2 && children[0].nodeName === 'times' && children[1].nodeName === 'cn' && (n = Number(CToP.getTextContent(children[1]))) < 0) { CToP.appendToken(mrow,'mo','\u2212'); - CToP.getTextContent(children[1]) = -n;// fix me: modifying document + arg = arg.cloneNode(true); + children = CToP.getChildren(arg); + children[1].textContent = -n; CToP.applyTransform(mrow,arg,2); } else{ CToP.appendToken(mrow,'mo','+'); From 2f5b3eebc303832487782bdaa1d5bb6e0074e7a8 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 24 Aug 2016 10:11:56 -0400 Subject: [PATCH 2/2] It's OK to change the original 'document', since it is a temporary MathML tree that is used to create the internal JS version and then is discarded. It is replaced by the result of content-mathml anyway. --- unpacked/extensions/MathML/content-mathml.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/unpacked/extensions/MathML/content-mathml.js b/unpacked/extensions/MathML/content-mathml.js index ab9df08fe..874e69fff 100644 --- a/unpacked/extensions/MathML/content-mathml.js +++ b/unpacked/extensions/MathML/content-mathml.js @@ -1319,9 +1319,7 @@ MathJax.Extension["MathML/content-mathml"] = (function(HUB) { CToP.applyTransform(mrow,children[1],2); } else if (arg.nodeName === 'apply' && children.length>2 && children[0].nodeName === 'times' && children[1].nodeName === 'cn' && (n = Number(CToP.getTextContent(children[1]))) < 0) { CToP.appendToken(mrow,'mo','\u2212'); - arg = arg.cloneNode(true); - children = CToP.getChildren(arg); - children[1].textContent = -n; + children[1].textContent = -n; // OK to change MathML since it is being discarded afterward CToP.applyTransform(mrow,arg,2); } else{ CToP.appendToken(mrow,'mo','+');