Add more signals for error conditions (so error reporting software can track it easier)

This commit is contained in:
Davide P. Cervone 2012-01-06 17:09:37 -05:00
parent f35661b83a
commit 77c8a54da6
20 changed files with 54 additions and 40 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,5 +12,5 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/
(function(){var c="1.1.1";var a=MathJax.Hub.CombineConfig("TeX.noErrors",{multiLine:true,inlineDelimiters:["",""],style:{"font-size":"80%","text-align":"left",color:"black",padding:"1px 3px",border:"1px solid"}});var b="\u00A0";MathJax.Extension["TeX/noErrors"]={version:c,config:a};MathJax.Hub.Register.StartupHook("TeX Jax Ready",function(){MathJax.InputJax.TeX.Augment({formatError:function(f,e,g,d){var i=a.inlineDelimiters;var h=(g||a.multiLine);if(!g){e=i[0]+e+i[1]}if(h){e=e.replace(/ /g,b)}else{e=e.replace(/\n/g," ")}return MathJax.ElementJax.mml.merror(e).With({isError:true,multiLine:h})}})});MathJax.Hub.Register.StartupHook("HTML-CSS Jax Config",function(){MathJax.Hub.Config({"HTML-CSS":{styles:{".MathJax .merror":MathJax.Hub.Insert({"font-style":null,"background-color":null,"vertical-align":(MathJax.Hub.Browser.isMSIE&&a.multiLine?"-2px":"")},a.style)}}})})})();MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function(){var a=MathJax.ElementJax.mml;var b=MathJax.OutputJax["HTML-CSS"];var c=a.math.prototype.toHTML;a.math.Augment({toHTML:function(d,e){if(this.data[0]&&this.data[0].data[0]&&this.data[0].data[0].isError){d=this.HTMLcreateSpan(d);d.bbox=this.data[0].data[0].toHTML(d).bbox;return d}return c.call(this,d,e)}});a.merror.Augment({toHTML:function(j){if(!this.isError){return a.mbase.prototype.toHTML.call(this,j)}j=this.HTMLcreateSpan(j);if(this.multiLine){j.style.display="inline-block"}var l=this.data[0].data[0].data.join("").split(/\n/);for(var g=0,e=l.length;g<e;g++){b.addText(j,l[g]);if(g!==e-1){b.addElement(j,"br",{isMathJax:true})}}var n=b.getHD(j.parentNode),d=b.getW(j.parentNode);if(e>1){var k=(n.h+n.d)/2,h=b.TeX.x_height/2;var f=b.config.styles[".MathJax .merror"]["font-size"];if(f&&f.match(/%/)){h*=parseInt(f)/100}j.parentNode.style.verticalAlign=b.Em(n.d+(h-k));n.h=h+k;n.d=k-h}j.bbox={h:n.h,d:n.d,w:d,lw:0,rw:d};return j}});MathJax.Hub.Startup.signal.Post("TeX noErrors Ready")});MathJax.Hub.Register.StartupHook("NativeMML Jax Ready",function(){var b=MathJax.ElementJax.mml;var a=MathJax.Extension["TeX/noErrors"].config;var c=b.math.prototype.toNativeMML;b.math.Augment({toNativeMML:function(d){if(this.data[0]&&this.data[0].data[0]&&this.data[0].data[0].isError){return this.data[0].data[0].toNativeMML(d)}return c.call(this,d)}});b.merror.Augment({toNativeMML:function(g){if(!this.isError){return b.mbase.prototype.toNativeMML.call(this,g)}g=g.appendChild(document.createElement("span"));var h=this.data[0].data[0].data.join("").split(/\n/);for(var f=0,e=h.length;f<e;f++){g.appendChild(document.createTextNode(h[f]));if(f!==e-1){g.appendChild(document.createElement("br"))}}if(this.multiLine){g.style.display="inline-block";if(e>1){g.style.verticalAlign="middle"}}for(var j in a.style){if(a.style.hasOwnProperty(j)){var d=j.replace(/-./g,function(i){return i.charAt(1).toUpperCase()});g.style[d]=a.style[j]}}return g}});MathJax.Hub.Startup.signal.Post("TeX noErrors Ready")});MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/noErrors.js");
(function(){var c="1.1.1";var a=MathJax.Hub.CombineConfig("TeX.noErrors",{multiLine:true,inlineDelimiters:["",""],style:{"font-size":"80%","text-align":"left",color:"black",padding:"1px 3px",border:"1px solid"}});var b="\u00A0";MathJax.Extension["TeX/noErrors"]={version:c,config:a};MathJax.Hub.Register.StartupHook("TeX Jax Ready",function(){MathJax.InputJax.TeX.Augment({formatError:function(g,f,h,d){var e=g.message.replace(/\n.*/,"");MathJax.Hub.signal.Post(["TeX Jax - parse error",e,f,h,d]);var j=a.inlineDelimiters;var i=(h||a.multiLine);if(!h){f=j[0]+f+j[1]}if(i){f=f.replace(/ /g,b)}else{f=f.replace(/\n/g," ")}return MathJax.ElementJax.mml.merror(f).With({isError:true,multiLine:i})}})});MathJax.Hub.Register.StartupHook("HTML-CSS Jax Config",function(){MathJax.Hub.Config({"HTML-CSS":{styles:{".MathJax .merror":MathJax.Hub.Insert({"font-style":null,"background-color":null,"vertical-align":(MathJax.Hub.Browser.isMSIE&&a.multiLine?"-2px":"")},a.style)}}})})})();MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function(){var a=MathJax.ElementJax.mml;var b=MathJax.OutputJax["HTML-CSS"];var c=a.math.prototype.toHTML;a.math.Augment({toHTML:function(d,e){if(this.data[0]&&this.data[0].data[0]&&this.data[0].data[0].isError){d=this.HTMLcreateSpan(d);d.bbox=this.data[0].data[0].toHTML(d).bbox;return d}return c.call(this,d,e)}});a.merror.Augment({toHTML:function(j){if(!this.isError){return a.mbase.prototype.toHTML.call(this,j)}j=this.HTMLcreateSpan(j);if(this.multiLine){j.style.display="inline-block"}var l=this.data[0].data[0].data.join("").split(/\n/);for(var g=0,e=l.length;g<e;g++){b.addText(j,l[g]);if(g!==e-1){b.addElement(j,"br",{isMathJax:true})}}var n=b.getHD(j.parentNode),d=b.getW(j.parentNode);if(e>1){var k=(n.h+n.d)/2,h=b.TeX.x_height/2;var f=b.config.styles[".MathJax .merror"]["font-size"];if(f&&f.match(/%/)){h*=parseInt(f)/100}j.parentNode.style.verticalAlign=b.Em(n.d+(h-k));n.h=h+k;n.d=k-h}j.bbox={h:n.h,d:n.d,w:d,lw:0,rw:d};return j}});MathJax.Hub.Startup.signal.Post("TeX noErrors Ready")});MathJax.Hub.Register.StartupHook("NativeMML Jax Ready",function(){var b=MathJax.ElementJax.mml;var a=MathJax.Extension["TeX/noErrors"].config;var c=b.math.prototype.toNativeMML;b.math.Augment({toNativeMML:function(d){if(this.data[0]&&this.data[0].data[0]&&this.data[0].data[0].isError){return this.data[0].data[0].toNativeMML(d)}return c.call(this,d)}});b.merror.Augment({toNativeMML:function(g){if(!this.isError){return b.mbase.prototype.toNativeMML.call(this,g)}g=g.appendChild(document.createElement("span"));var h=this.data[0].data[0].data.join("").split(/\n/);for(var f=0,e=h.length;f<e;f++){g.appendChild(document.createTextNode(h[f]));if(f!==e-1){g.appendChild(document.createElement("br"))}}if(this.multiLine){g.style.display="inline-block";if(e>1){g.style.verticalAlign="middle"}}for(var j in a.style){if(a.style.hasOwnProperty(j)){var d=j.replace(/-./g,function(i){return i.charAt(1).toUpperCase()});g.style[d]=a.style[j]}}return g}});MathJax.Hub.Startup.signal.Post("TeX noErrors Ready")});MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/noErrors.js");

View File

@ -12,5 +12,5 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.Extension["TeX/noUndefined"]={version:"1.1",config:MathJax.Hub.CombineConfig("TeX.noUndefined",{attributes:{mathcolor:"red"}})};MathJax.Hub.Register.StartupHook("TeX Jax Ready",function(){var b=MathJax.Extension["TeX/noUndefined"].config;var a=MathJax.ElementJax.mml;MathJax.InputJax.TeX.Parse.Augment({csUndefined:function(c){this.Push(a.mtext(c).With(b.attributes))}});MathJax.Hub.Startup.signal.Post("TeX noUndefined Ready")});MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/noUndefined.js");
MathJax.Extension["TeX/noUndefined"]={version:"1.1",config:MathJax.Hub.CombineConfig("TeX.noUndefined",{attributes:{mathcolor:"red"}})};MathJax.Hub.Register.StartupHook("TeX Jax Ready",function(){var b=MathJax.Extension["TeX/noUndefined"].config;var a=MathJax.ElementJax.mml;MathJax.InputJax.TeX.Parse.Augment({csUndefined:function(c){MathJax.Hub.signal.Post(["TeX Jax - undefined control sequence",c]);this.Push(a.mtext(c).With(b.attributes))}});MathJax.Hub.Startup.signal.Post("TeX noUndefined Ready")});MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/noUndefined.js");

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -877,7 +877,10 @@ MathJax.fileversion = "1.1.17";
//
// The default error hook for file load failures
//
loadError: function (file) {BASE.Message.Set("File failed to load: "+file,null,2000)},
loadError: function (file) {
BASE.Message.Set("File failed to load: "+file,null,2000);
BASE.Hub.signal.Post(["file load error",file]);
},
//
// Defines a style sheet from a hash of style declarations (key:value pairs

View File

@ -99,6 +99,8 @@
// multi-line TeX, make spaces non-breakable (to get formatting right)
//
formatError: function (err,math,displaystyle,script) {
var message = err.message.replace(/\n.*/,"");
MathJax.Hub.signal.Post(["TeX Jax - parse error",message,math,displaystyle,script]);
var delim = CONFIG.inlineDelimiters;
var multiLine = (displaystyle || CONFIG.multiLine);
if (!displaystyle) {math = delim[0] + math + delim[1]}

View File

@ -39,7 +39,7 @@
//
// The configuration defaults, augmented by the user settings
//
//
MathJax.Extension["TeX/noUndefined"] = {
version: "1.1",
config: MathJax.Hub.CombineConfig("TeX.noUndefined",{
@ -55,6 +55,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
MathJax.InputJax.TeX.Parse.Augment({
csUndefined: function (name) {
MathJax.Hub.signal.Post(["TeX Jax - undefined control sequence",name]);
this.Push(MML.mtext(name).With(CONFIG.attributes));
}
});

View File

@ -66,8 +66,10 @@
//
MakeMML: function (node) {
var type = node.nodeName.toLowerCase().replace(/^[a-z]+:/,"");
if (!(MML[type] && MML[type].isa && MML[type].isa(MML.mbase)))
{return MML.merror("Unknown node type: "+type)}
if (!(MML[type] && MML[type].isa && MML[type].isa(MML.mbase))) {
MathJax.Hub.signal.Post(["MathML Jax - unknown node type",type]);
return MML.merror("Unknown node type: "+type);
}
var mml = MML[type](), i, m, name, value;
mml.mmlAttributes = [];
for (i = 0, m = node.attributes.length; i < m; i++) {
@ -162,7 +164,9 @@
prefilterMath: function (math,script) {return math},
prefilterMathML: function (math) {return math},
formatError: function (err,math,script) {
return MML.merror(err.message.replace(/\n.*/,""));
var message = err.message.replace(/\n.*/,"");
MathJax.Hub.signal.Post(["MathML Jax - parse error",message,math,script]);
return MML.merror(message);
},
Error: function (message) {
throw MathJax.Hub.Insert(Error(message),{mathmlError: true});

View File

@ -1910,7 +1910,9 @@
return math;
},
formatError: function (err,math,display,script) {
return MML.merror(err.message.replace(/\n.*/,""));
var message = err.message.replace(/\n.*/,"");
HUB.signal.Post(["TeX Jax - parse error",message,math,display,script]);
return MML.merror(message);
},
//

View File

@ -151,9 +151,11 @@
},
loadError: function (font) {
MathJax.Message.Set("Can't load web font "+HTMLCSS.fontInUse+"/"+font.directory,null,2000);
HUB.Startup.signal.Post(["HTML-CSS Jax - web font error",HTMLCSS.fontInUse+"/"+font.directory,font]);
},
firefoxFontError: function (font) {
MathJax.Message.Set("Firefox can't load web fonts from a remote host",null,3000);
HUB.Startup.signal.Post("HTML-CSS Jax - Firefox web fonts on remote host error");
},
checkWebFont: function (check,font,callback) {