Merge "(bug 35188) Do not poison the tex formula with markup"

This commit is contained in:
jenkins-bot 2013-04-27 19:19:47 +00:00 committed by Gerrit Code Review
commit 691d1b3186

View File

@ -20,6 +20,7 @@ MathJax.Extension.wiki2jax = {
if (this.config.Augment) {MathJax.Hub.Insert(this,this.config.Augment)}
this.previewClass = MathJax.Hub.config.preRemoveClass;
this.setupPrefilter();
this.configured = true;
}
var that = this;
@ -28,6 +29,16 @@ MathJax.Extension.wiki2jax = {
});
},
setupPrefilter: function() { // used to fix a number of common wiki math hacks
MathJax.Hub.Register.StartupHook("TeX Jax Ready", function() {
MathJax.InputJax.TeX.prefilterHooks.Add( function(data) {
data.math = data.math.replace(/^\s*\\scriptstyle(\W)/,"\\textstyle$1").replace(/^\s*\\scriptscriptstyle(\W)/,"\\scriptstyle$1");
if (data.script.type.match(/(;|\s|\n)mode\s*=\s*display-nobreak(;|\s|\n|$)/) != null)
data.math = "\\displaystyle " + data.math;
});
});
},
ConvertMath: function (node) {
var parent = node.parentNode,
mode = parent.tagName === "DD" && parent.childNodes.length === 1 ? "; mode=display" : "",
@ -43,10 +54,8 @@ MathJax.Extension.wiki2jax = {
tex = tex.replace(/([^\\])%/g, "$1\\%" );
tex = tex.replace(/\\iiint([^!]*)!\\!\\!\\!\\!.*\\subset\\!\\supset/g,"\\iiint$1mkern-2.5em\\subset\\!\\supset").replace(/\\iint([^!]*)!\\!\\!\\!\\!\\!\\!\\!\\!\\!\\!(.*)\\subset\\!\\supset/g,"\\iint$1mkern-1.65em$2\\subset\\!\\!\\supset").replace(/\\int\\!\\!\\!(\\!)+\\int\\!\\!\\!(\\!)+\\int([^!]*)!\\!\\!\\!\\!.*\\bigcirc(\\,)*/g,"\\iiint$3mkern-2.5em\\subset\\!\\supset").replace(/\\int\\!\\!\\!(\\!)+\\int([^!]*)!\\!\\!\\!\\!\\!\\!\\!\\!(.*)\\bigcirc(\\,)*/g,"\\iint$2mkern-1.65em$3\\subset\\!\\!\\supset");
if (mode === "") {
tex = tex.replace(/ *\\scriptstyle(\W)/g,"\\textstyle$1").replace(/ *\\scriptscriptstyle(\W)/g,"\\scriptstyle$1");
if (parent.firstChild === node) tex = "\\displaystyle "+tex;
}
if (mode === "" && parent.firstChild === node) mode = "; mode=display-nobreak";
var script = document.createElement("script");
script.type = "math/tex" + mode;