Update math processing errors to include original format and actual error message in the Show Math As menu. Resolves issue #450.
This commit is contained in:
parent
9178a9af0e
commit
8c16f656ac
|
@ -33,7 +33,7 @@ if (!window.MathJax) {window.MathJax= {}}
|
|||
if (!MathJax.Hub) { // skip if already loaded
|
||||
|
||||
MathJax.version = "2.1";
|
||||
MathJax.fileversion = "2.1.3";
|
||||
MathJax.fileversion = "2.1.4";
|
||||
|
||||
/**********************************************************/
|
||||
|
||||
|
@ -1633,7 +1633,8 @@ MathJax.Hub = {
|
|||
//
|
||||
// Check that there is an element jax
|
||||
//
|
||||
script = state.scripts[state.i]; if (!script || !script.MathJax) {state.i++; continue}
|
||||
script = state.scripts[state.i];
|
||||
if (!script || !script.MathJax || script.MathJax.error) {state.i++; continue}
|
||||
var jax = script.MathJax.elementJax; if (!jax) {state.i++; continue}
|
||||
//
|
||||
// Call the output Jax's Process method (which will be its Translate()
|
||||
|
@ -1681,8 +1682,23 @@ MathJax.Hub = {
|
|||
},
|
||||
|
||||
formatError: function (script,err) {
|
||||
var error = MathJax.HTML.Element("span",{className:"MathJax_Error"},this.config.errorSettings.message);
|
||||
error.jaxID = "Error";
|
||||
//
|
||||
// Get the error message, URL, and line, and save it for
|
||||
// reporting in the Show Math As Error menu
|
||||
//
|
||||
var message = "Error: "+err.message+"\n";
|
||||
if (err.sourceURL) {message += "\nfile: "+err.sourceURL}
|
||||
if (err.line) {message += "\nline: "+err.line}
|
||||
script.MathJax.error = MathJax.OutputJax.Error.Jax(message,script);
|
||||
|
||||
//
|
||||
// Create the [Math Processing Error] span
|
||||
//
|
||||
var error = MathJax.HTML.Element("span",{className:"MathJax_Error", jaxID: "Error"},
|
||||
this.config.errorSettings.message);
|
||||
//
|
||||
// Attach the menu events
|
||||
//
|
||||
if (MathJax.Extension.MathEvents) {
|
||||
error.oncontextmenu = MathJax.Extension.MathEvents.Event.Menu;
|
||||
error.onmousedown = MathJax.Extension.MathEvents.Event.Mousedown;
|
||||
|
@ -1692,8 +1708,15 @@ MathJax.Hub = {
|
|||
error.onmousedown = MathJax.Extension.MathEvents.Event.Mousedown;
|
||||
});
|
||||
}
|
||||
//
|
||||
// Insert the error into the page and remove any preview
|
||||
//
|
||||
script.parentNode.insertBefore(error,script);
|
||||
if (script.MathJax.preview) {script.MathJax.preview.innerHTML = ""}
|
||||
//
|
||||
// Save the error for debugging purposes
|
||||
// Report the error as a signal
|
||||
//
|
||||
this.lastError = err;
|
||||
this.signal.Post(["Math Processing Error",script,err]);
|
||||
},
|
||||
|
@ -2220,6 +2243,7 @@ MathJax.Hub.Startup = {
|
|||
inputID: null,
|
||||
originalText: "",
|
||||
mimeType: "",
|
||||
sourceMenuTitle: "MathML Code",
|
||||
|
||||
Text: function (text,callback) {
|
||||
var script = this.SourceElement();
|
||||
|
@ -2309,14 +2333,23 @@ MathJax.Hub.Startup = {
|
|||
// Some "Fake" jax used to allow menu access for "Math Processing Error" messages
|
||||
//
|
||||
BASE.OutputJax.Error = {
|
||||
id: "Error", version: "2.1", config: {},
|
||||
id: "Error", version: "2.1.1", config: {},
|
||||
ContextMenu: function () {return BASE.Extension.MathEvents.Event.ContextMenu.apply(BASE.Extension.MathEvents.Event,arguments)},
|
||||
Mousedown: function () {return BASE.Extension.MathEvents.Event.AltContextMenu.apply(BASE.Extension.MathEvents.Event,arguments)},
|
||||
getJaxFromMath: function () {return {inputJax:"Error", outputJax:"Error", originalText:"Math Processing Error"}}
|
||||
getJaxFromMath: function (math) {return (math.nextSibling.MathJax||{}).error},
|
||||
Jax: function (text,script) {
|
||||
var jax = MathJax.Hub.inputJax[script.type.replace(/ *;(.|\s)*/,"")];
|
||||
return {
|
||||
inputJax: (jax||{id:"Error"}).id, // Use Error InputJax as fallback
|
||||
outputJax: "Error",
|
||||
sourceMenuTitle: "Error Message", sourceMenuFormat: "Error",
|
||||
originalText: MathJax.HTML.getScript(script),
|
||||
errorText: text
|
||||
}
|
||||
}
|
||||
};
|
||||
BASE.InputJax.Error = {
|
||||
id: "Error", version: "2.1", config: {},
|
||||
sourceMenuTitle: "Error Message"
|
||||
id: "Error", version: "2.1.1", config: {}
|
||||
};
|
||||
|
||||
})("MathJax");
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
(function (HUB,HTML,AJAX,CALLBACK,OUTPUT,INPUT) {
|
||||
var VERSION = "2.1";
|
||||
var VERSION = "2.1.1";
|
||||
|
||||
var EXTENSION = MathJax.Extension;
|
||||
var ME = EXTENSION.MathEvents = {version: VERSION};
|
||||
|
@ -148,8 +148,9 @@
|
|||
if (MENU) {
|
||||
MENU.jax = jax;
|
||||
var source = MENU.menu.Find("Show Math As").menu;
|
||||
source.items[0].name = (jax.sourceMenuTitle||"MathML Code");
|
||||
source.items[0].format = (jax.sourceMenuFormat||"MathML");
|
||||
source.items[1].name = (INPUT[jax.inputJax].sourceMenuTitle||"Original Form");
|
||||
source.items[0].hidden = (jax.inputJax === "Error"); // hide MathML choice for error messages
|
||||
var MathPlayer = MENU.menu.Find("Math Settings","MathPlayer");
|
||||
MathPlayer.hidden = !(jax.outputJax === "NativeMML" && HUB.Browser.hasMathPlayer);
|
||||
return MENU.menu.Post(event);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
(function (HUB,HTML,AJAX,CALLBACK,OUTPUT) {
|
||||
var VERSION = "2.1";
|
||||
var VERSION = "2.1.1";
|
||||
|
||||
var SIGNAL = MathJax.Callback.Signal("menu") // signal for menu events
|
||||
|
||||
|
@ -689,6 +689,8 @@
|
|||
);
|
||||
return;
|
||||
}
|
||||
} else if (this.format === "Error") {
|
||||
MENU.ShowSource.Text(MENU.jax.errorText,event);
|
||||
} else {
|
||||
if (MENU.jax.originalText == null) {alert("No original form available"); return}
|
||||
MENU.ShowSource.Text(MENU.jax.originalText,event);
|
||||
|
|
Loading…
Reference in New Issue
Block a user