12345678910111213 |
- /*
- * /MathJax/extensions/TeX/noErrors.js
- *
- * Copyright (c) 2009-2013 The MathJax Consortium
- *
- * Part of the MathJax library.
- * See http://www.mathjax.org for details.
- *
- * Licensed under the Apache License, Version 2.0;
- * you may not use this file except in compliance with the License.
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- */(function(c,h){var g=c.CombineConfig("TeX.noErrors",{disabled:!1,multiLine:!0,inlineDelimiters:["",""],style:{"font-size":"90%","text-align":"left",color:"black",padding:"1px 3px",border:"1px solid"}});MathJax.Extension["TeX/noErrors"]={version:"2.2",config:g};c.Register.StartupHook("TeX Jax Ready",function(){var a=MathJax.InputJax.TeX.formatError;MathJax.InputJax.TeX.Augment({formatError:function(l,f,k,b){if(g.disabled)return a.apply(this,arguments);var d=l.message.replace(/\n.*/,"");c.signal.Post(["TeX Jax - parse error",d,f,k,b]);var d=g.inlineDelimiters,e=k||g.multiLine;k||(f=d[0]+f+d[1]);f=e?f.replace(/ /g,"\u00a0"):f.replace(/\n/g," ");return MathJax.ElementJax.mml.merror(f).With({isError:!0,multiLine:e})}})});c.Register.StartupHook("HTML-CSS Jax Config",function(){c.Config({"HTML-CSS":{styles:{".MathJax .noError":c.Insert({"vertical-align":c.Browser.isMSIE&&g.multiLine?"-2px":""},g.style)}}})});c.Register.StartupHook("HTML-CSS Jax Ready",function(){var a=MathJax.ElementJax.mml,c=MathJax.OutputJax["HTML-CSS"],f=a.math.prototype.toHTML,k=a.merror.prototype.toHTML;a.math.Augment({toHTML:function(b,d){var e=this.data[0];e&&e.data[0]&&e.data[0].isError?(b.style.fontSize="",b=this.HTMLcreateSpan(b),b.bbox=e.data[0].toHTML(b).bbox):b=f.call(this,b,d);return b}});a.merror.Augment({toHTML:function(b){if(!this.isError)return k.call(this,b);b=this.HTMLcreateSpan(b);b.className="noError";this.multiLine&&(b.style.display="inline-block");for(var d=this.data[0].data[0].data.join("").split(/\n/),e=0,a=d.length;e<a;e++)c.addText(b,d[e]),e!==a-1&&c.addElement(b,"br",{isMathJax:!0});d=c.getHD(b.parentNode);e=c.getW(b.parentNode);if(1<a){var a=(d.h+d.d)/2,f=c.TeX.x_height/2;b.parentNode.style.verticalAlign=c.Em(d.d+(f-a));d.h=f+a;d.d=a-f}b.bbox={h:d.h,d:d.d,w:e,lw:0,rw:e};return b}})});c.Register.StartupHook("SVG Jax Config",function(){c.Config({SVG:{styles:{".MathJax_SVG .noError":c.Insert({"vertical-align":c.Browser.isMSIE&&g.multiLine?"-2px":""},g.style)}}})});c.Register.StartupHook("SVG Jax Ready",function(){var a=MathJax.ElementJax.mml,c=a.math.prototype.toSVG,f=a.merror.prototype.toSVG;a.math.Augment({toSVG:function(a,b){var d=this.data[0];return a=d&&d.data[0]&&d.data[0].isError?d.data[0].toSVG(a):c.call(this,a,b)}});a.merror.Augment({toSVG:function(a){if(!this.isError||"math"!==this.Parent().type)return f.call(this,a);a=h.addElement(a,"span",{className:"noError",isMathJax:!0});this.multiLine&&(a.style.display="inline-block");for(var b=this.data[0].data[0].data.join("").split(/\n/),d=0,e=b.length;d<e;d++)h.addText(a,b[d]),d!==e-1&&h.addElement(a,"br",{isMathJax:!0});1<e&&(b=a.offsetHeight/2,a.style.verticalAlign=-b+b/e+"px");return a}})});c.Register.StartupHook("NativeMML Jax Ready",function(){var a=MathJax.ElementJax.mml,c=MathJax.Extension["TeX/noErrors"].config,f=a.math.prototype.toNativeMML,g=a.merror.prototype.toNativeMML;a.math.Augment({toNativeMML:function(b){var a=this.data[0];return b=a&&a.data[0]&&a.data[0].isError?a.data[0].toNativeMML(b):f.call(this,b)}});a.merror.Augment({toNativeMML:function(b){if(!this.isError)return g.call(this,b);b=b.appendChild(document.createElement("span"));for(var a=this.data[0].data[0].data.join("").split(/\n/),e=0,f=a.length;e<f;e++)b.appendChild(document.createTextNode(a[e])),e!==f-1&&b.appendChild(document.createElement("br"));this.multiLine&&(b.style.display="inline-block",1<f&&(b.style.verticalAlign="middle"));for(var h in c.style)c.style.hasOwnProperty(h)&&(a=h.replace(/-./g,function(a){return a.charAt(1).toUpperCase()}),b.style[a]=c.style[h]);return b}})});c.Startup.signal.Post("TeX noErrors Ready")})(MathJax.Hub,MathJax.HTML);MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/noErrors.js");
|