Allow preview to be just a plain string (rather than requiring [string]).

This commit is contained in:
Davide P. Cervone 2012-11-27 14:25:32 -05:00
parent ef86d63009
commit d2bbe75499
4 changed files with 10 additions and 13 deletions

View File

@ -201,9 +201,8 @@ MathJax.Extension.asciimath2jax = {
}, },
createPreview: function (mode,asciimath) { createPreview: function (mode,asciimath) {
var preview; var preview = this.config.preview;
if (this.config.preview === "AsciiMath") {preview = [this.filterPreview(asciimath)]} if (preview === "AsciiMath") {preview = [this.filterPreview(asciimath)]}
else if (this.config.preview instanceof Array) {preview = this.config.preview}
if (preview) { if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
this.insertNode(preview); this.insertNode(preview);

View File

@ -70,9 +70,8 @@ MathJax.Extension.jsMath2jax = {
}, },
createPreview: function (node) { createPreview: function (node) {
var preview; var preview = this.config.preview;
if (this.config.preview === "TeX") {preview = [this.filterPreview(node.innerHTML)]} if (preview === "TeX") {preview = [this.filterPreview(node.innerHTML)]}
else if (this.config.preview instanceof Array) {preview = this.config.preview}
if (preview) { if (preview) {
preview = MathJax.HTML.Element("span",{className: MathJax.Hub.config.preRemoveClass},preview); preview = MathJax.HTML.Element("span",{className: MathJax.Hub.config.preRemoveClass},preview);
node.parentNode.insertBefore(preview,node); node.parentNode.insertBefore(preview,node);

View File

@ -172,15 +172,15 @@ MathJax.Extension.mml2jax = {
}, },
quoteHTML: function (string) { quoteHTML: function (string) {
if (string == null) {string = ""} if (string == null) {string = ""}
return string.replace(/&/g,"&#x26;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"); return string.replace(/&/g,"&#x26;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;");
}, },
createPreview: function (math,script) { createPreview: function (math,script) {
var preview; var preview = this.config.preview;
if (this.config.preview === "alttext") { if (preview === "alttext") {
var text = math.getAttribute("alttext"); var text = math.getAttribute("alttext");
if (text != null) {preview = [this.filterPreview(text)]} if (text != null) {preview = [this.filterPreview(text)]}
} else if (this.config.preview instanceof Array) {preview = this.config.preview} }
if (preview) { if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
script.parentNode.insertBefore(preview,script); script.parentNode.insertBefore(preview,script);

View File

@ -271,9 +271,8 @@ MathJax.Extension.tex2jax = {
}, },
createPreview: function (mode,tex) { createPreview: function (mode,tex) {
var preview; var preview = this.config.preview;
if (this.config.preview === "TeX") {preview = [this.filterPreview(tex)]} if (preview === "TeX") {preview = [this.filterPreview(tex)]}
else if (this.config.preview instanceof Array) {preview = this.config.preview}
if (preview) { if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
this.insertNode(preview); this.insertNode(preview);