Merge pull request #1524 from dpvc/issue1445

Don't make a preview if there already is one.  #1445
This commit is contained in:
Davide P. Cervone 2016-07-06 14:05:32 -04:00 committed by GitHub
commit dd32c56008
4 changed files with 14 additions and 5 deletions

View File

@ -207,11 +207,13 @@ MathJax.Extension.asciimath2jax = {
},
createPreview: function (mode,asciimath) {
var previewClass = MathJax.Hub.config.preRemoveClass;
var preview = this.config.preview;
if (preview === "none") return;
if ((this.search.close.previousSibling||{}).className === previewClass) return;
if (preview === "AsciiMath") {preview = [this.filterPreview(asciimath)]}
if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
preview = MathJax.HTML.Element("span",{className:previewClass},preview);
this.insertNode(preview);
}
},

View File

@ -73,10 +73,13 @@ MathJax.Extension.jsMath2jax = {
},
createPreview: function (node) {
var previewClass = MathJax.Hub.config.preRemoveClass;
var preview = this.config.preview;
if (preview === "none") return;
if ((node.previousSibling||{}).className === previewClass) return;
if (preview === "TeX") {preview = [this.filterPreview(node.innerHTML)]}
if (preview) {
preview = MathJax.HTML.Element("span",{className: MathJax.Hub.config.preRemoveClass},preview);
preview = MathJax.HTML.Element("span",{className:previewClass},preview);
node.parentNode.insertBefore(preview,node);
}
},

View File

@ -203,6 +203,8 @@ MathJax.Extension.mml2jax = {
var preview = this.config.preview;
if (preview === "none") return;
var isNodePreview = false;
var previewClass = MathJax.Hub.config.preRemoveClass;
if ((script.previousSibling||{}).className === previewClass) return;
if (preview === "mathml") {
isNodePreview = true;
// mathml preview does not work with IE < 9, so fallback to alttext.
@ -225,10 +227,10 @@ MathJax.Extension.mml2jax = {
if (preview) {
var span;
if (isNodePreview) {
span = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass});
span = MathJax.HTML.Element("span",{className:previewClass});
span.appendChild(preview);
} else {
span = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
span = MathJax.HTML.Element("span",{className:previewClass},preview);
}
script.parentNode.insertBefore(span,script);
}

View File

@ -277,11 +277,13 @@ MathJax.Extension.tex2jax = {
},
createPreview: function (mode,tex) {
var previewClass = MathJax.Hub.config.preRemoveClass;
var preview = this.config.preview;
if (preview === "none") return;
if ((this.search.close.previousSibling||{}).className === previewClass) return;
if (preview === "TeX") {preview = [this.filterPreview(tex)]}
if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
preview = MathJax.HTML.Element("span",{className:previewClass},preview);
this.insertNode(preview);
}
},