Merge branch 'issue450' into develop. Resolves issue #450.
This commit is contained in:
commit
53e76213b0
|
@ -2094,7 +2094,8 @@ MathJax.Hub = {
|
||||||
//
|
//
|
||||||
// Check that there is an element jax
|
// 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}
|
var jax = script.MathJax.elementJax; if (!jax) {state.i++; continue}
|
||||||
//
|
//
|
||||||
// Call the output Jax's Process method (which will be its Translate()
|
// Call the output Jax's Process method (which will be its Translate()
|
||||||
|
@ -2143,10 +2144,24 @@ MathJax.Hub = {
|
||||||
},
|
},
|
||||||
|
|
||||||
formatError: function (script,err) {
|
formatError: function (script,err) {
|
||||||
|
//
|
||||||
|
// 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 errorSettings = this.config.errorSettings;
|
var errorSettings = this.config.errorSettings;
|
||||||
var errorText = MathJax.Localization._(errorSettings.messageId,errorSettings.message);
|
var errorText = MathJax.Localization._(errorSettings.messageId,errorSettings.message);
|
||||||
var error = MathJax.HTML.Element("span",{className:"MathJax_Error"},errorText);
|
var error = MathJax.HTML.Element("span",{className:"MathJax_Error",jaxID:"Error"},errorText);
|
||||||
error.jaxID = "Error";
|
//
|
||||||
|
// Attach the menu events
|
||||||
|
//
|
||||||
if (MathJax.Extension.MathEvents) {
|
if (MathJax.Extension.MathEvents) {
|
||||||
error.oncontextmenu = MathJax.Extension.MathEvents.Event.Menu;
|
error.oncontextmenu = MathJax.Extension.MathEvents.Event.Menu;
|
||||||
error.onmousedown = MathJax.Extension.MathEvents.Event.Mousedown;
|
error.onmousedown = MathJax.Extension.MathEvents.Event.Mousedown;
|
||||||
|
@ -2156,8 +2171,15 @@ MathJax.Hub = {
|
||||||
error.onmousedown = MathJax.Extension.MathEvents.Event.Mousedown;
|
error.onmousedown = MathJax.Extension.MathEvents.Event.Mousedown;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// Insert the error into the page and remove any preview
|
||||||
|
//
|
||||||
script.parentNode.insertBefore(error,script);
|
script.parentNode.insertBefore(error,script);
|
||||||
if (script.MathJax.preview) {script.MathJax.preview.innerHTML = ""}
|
if (script.MathJax.preview) {script.MathJax.preview.innerHTML = ""}
|
||||||
|
//
|
||||||
|
// Save the error for debugging purposes
|
||||||
|
// Report the error as a signal
|
||||||
|
//
|
||||||
this.lastError = err;
|
this.lastError = err;
|
||||||
this.signal.Post(["Math Processing Error",script,err]);
|
this.signal.Post(["Math Processing Error",script,err]);
|
||||||
},
|
},
|
||||||
|
@ -2695,6 +2717,7 @@ MathJax.Hub.Startup = {
|
||||||
inputID: null,
|
inputID: null,
|
||||||
originalText: "",
|
originalText: "",
|
||||||
mimeType: "",
|
mimeType: "",
|
||||||
|
sourceMenuTitle: "MathML Code",
|
||||||
|
|
||||||
Text: function (text,callback) {
|
Text: function (text,callback) {
|
||||||
var script = this.SourceElement();
|
var script = this.SourceElement();
|
||||||
|
@ -2784,19 +2807,24 @@ MathJax.Hub.Startup = {
|
||||||
// Some "Fake" jax used to allow menu access for "Math Processing Error" messages
|
// Some "Fake" jax used to allow menu access for "Math Processing Error" messages
|
||||||
//
|
//
|
||||||
BASE.OutputJax.Error = {
|
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)},
|
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)},
|
Mousedown: function () {return BASE.Extension.MathEvents.Event.AltContextMenu.apply(BASE.Extension.MathEvents.Event,arguments)},
|
||||||
getJaxFromMath: function () {
|
getJaxFromMath: function (math) {return (math.nextSibling.MathJax||{}).error},
|
||||||
|
Jax: function (text,script) {
|
||||||
|
var jax = MathJax.Hub.inputJax[script.type.replace(/ *;(.|\s)*/,"")];
|
||||||
return {
|
return {
|
||||||
inputJax: "Error", outputJax: "Error",
|
inputJax: (jax||{id:"Error"}).id, // Use Error InputJax as fallback
|
||||||
originalText: BASE.Localization._("MathProcessingError","Math Processing Error")
|
outputJax: "Error",
|
||||||
};
|
sourceMenuTitle: /*_(MathMenu)*/ ["ErrorMessage","Error Message"],
|
||||||
|
sourceMenuFormat: "Error",
|
||||||
|
originalText: MathJax.HTML.getScript(script),
|
||||||
|
errorText: text
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
BASE.InputJax.Error = {
|
BASE.InputJax.Error = {
|
||||||
id: "Error", version: "2.1", config: {},
|
id: "Error", version: "2.1.1", config: {}
|
||||||
sourceMenuTitle: /*_(MathMenu)*/ ["ErrorMessage","Error Message"]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
})("MathJax");
|
})("MathJax");
|
||||||
|
|
|
@ -155,8 +155,9 @@
|
||||||
if (!load) {
|
if (!load) {
|
||||||
MENU.jax = jax;
|
MENU.jax = jax;
|
||||||
var source = MENU.menu.Find("Show Math As").menu;
|
var source = MENU.menu.Find("Show Math As").menu;
|
||||||
|
source.items[0].name = jax.sourceMenuTitle;
|
||||||
|
source.items[0].format = (jax.sourceMenuFormat||"MathML");
|
||||||
source.items[1].name = INPUT[jax.inputJax].sourceMenuTitle;
|
source.items[1].name = INPUT[jax.inputJax].sourceMenuTitle;
|
||||||
source.items[0].hidden = (jax.inputJax === "Error"); // hide MathML choice for error messages
|
|
||||||
var MathPlayer = MENU.menu.Find("Math Settings","MathPlayer");
|
var MathPlayer = MENU.menu.Find("Math Settings","MathPlayer");
|
||||||
MathPlayer.hidden = !(jax.outputJax === "NativeMML" && HUB.Browser.hasMathPlayer);
|
MathPlayer.hidden = !(jax.outputJax === "NativeMML" && HUB.Browser.hasMathPlayer);
|
||||||
return MENU.menu.Post(event);
|
return MENU.menu.Post(event);
|
||||||
|
|
|
@ -715,6 +715,8 @@
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (this.format === "Error") {
|
||||||
|
MENU.ShowSource.Text(MENU.jax.errorText,event);
|
||||||
} else {
|
} else {
|
||||||
if (MENU.jax.originalText == null) {
|
if (MENU.jax.originalText == null) {
|
||||||
alert(_("NoOriginalForm","No original form available"));
|
alert(_("NoOriginalForm","No original form available"));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user