Properly handle callbacks returned by pre- and postfilter hooks.
This commit is contained in:
parent
05c7aace26
commit
f0c0c6386e
|
@ -1284,15 +1284,16 @@ junk = null;
|
|||
Translate: function (script) {
|
||||
var mml, math = MathJax.HTML.getScript(script);
|
||||
var data = {math:math, script:script};
|
||||
this.prefilterHooks.Execute(data); math = data.math;
|
||||
var callback = this.prefilterHooks.Execute(data); if (callback) return callback;
|
||||
math = data.math;
|
||||
try {
|
||||
mml = this.AM.parseMath(math);
|
||||
} catch(err) {
|
||||
if (!err.asciimathError) {throw err}
|
||||
mml = this.formatError(err,math);
|
||||
}
|
||||
data.math = MML(mml); this.postfilterHooks.Execute(data);
|
||||
return data.math;
|
||||
data.math = MML(mml);
|
||||
return this.postfilterHooks.Execute(data) || data.math;
|
||||
},
|
||||
formatError: function (err,math,script) {
|
||||
var message = err.message.replace(/\n.*/,"");
|
||||
|
|
|
@ -247,20 +247,21 @@
|
|||
if (script.firstChild &&
|
||||
script.firstChild.nodeName.toLowerCase().replace(/^[a-z]+:/,"") === "math") {
|
||||
data.math = script.firstChild;
|
||||
this.prefilterHooks.Execute(data); math = data.math;
|
||||
} else {
|
||||
math = MathJax.HTML.getScript(script);
|
||||
if (BROWSER.isMSIE) {math = math.replace(/( )+$/,"")}
|
||||
data.math = math; this.prefilterHooks.Execute(data); math = data.math;
|
||||
data.math = math;
|
||||
}
|
||||
var callback = this.prefilterHooks.Execute(data); if (callback) return callback;
|
||||
math = data.math;
|
||||
try {
|
||||
mml = MATHML.Parse(math).mml;
|
||||
} catch(err) {
|
||||
if (!err.mathmlError) {throw err}
|
||||
mml = this.formatError(err,math,script);
|
||||
}
|
||||
data.math = MML(mml); this.postfilterHooks.Execute(data);
|
||||
return data.math;
|
||||
data.math = MML(mml);
|
||||
return this.postfilterHooks.Execute(data) || data.math;
|
||||
},
|
||||
prefilterMath: function (math,script) {return math},
|
||||
prefilterMathML: function (math,script) {return math},
|
||||
|
|
|
@ -2086,7 +2086,8 @@
|
|||
var mml, isError = false, math = MathJax.HTML.getScript(script);
|
||||
var display = (script.type.replace(/\n/g," ").match(/(;|\s|\n)mode\s*=\s*display(;|\s|\n|$)/) != null);
|
||||
var data = {math:math, display:display, script:script};
|
||||
this.prefilterHooks.Execute(data); math = data.math;
|
||||
var callback = this.prefilterHooks.Execute(data); if (callback) return callback;
|
||||
math = data.math;
|
||||
try {
|
||||
mml = TEX.Parse(math).mml();
|
||||
} catch(err) {
|
||||
|
@ -2097,8 +2098,8 @@
|
|||
if (mml.inferred) {mml = MML.apply(MathJax.ElementJax,mml.data)} else {mml = MML(mml)}
|
||||
if (display) {mml.root.display = "block"}
|
||||
if (isError) {mml.texError = true}
|
||||
data.math = mml; this.postfilterHooks.Execute(data);
|
||||
return data.math;
|
||||
data.math = mml;
|
||||
return this.postfilterHooks.Execute(data) || data.math;
|
||||
},
|
||||
prefilterMath: function (math,displaystyle,script) {
|
||||
return math;
|
||||
|
|
Loading…
Reference in New Issue
Block a user