1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- /* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
- /* vim: set ts=2 et sw=2 tw=80: */
- /*************************************************************
- *
- * MathJax/extensions/TeX/noErrors.js
- *
- * Prevents the TeX error messages from being displayed and shows the
- * original TeX code instead. You can configure whether the dollar signs
- * are shown or not for in-line math, and whether to put all the TeX on
- * one line or use multiple-lines.
- *
- * To configure this extension, use
- *
- * MathJax.Hub.Config({
- * TeX: {
- * noErrors: {
- * inlineDelimiters: ["",""], // or ["$","$"] or ["\\(","\\)"]
- * multiLine: true, // false for TeX on all one line
- * style: {
- * "font-size": "90%",
- * "text-align": "left",
- * "color": "black",
- * "padding": "1px 3px",
- * "border": "1px solid"
- * // add any additional CSS styles that you want
- * // (be sure there is no extra comma at the end of the last item)
- * }
- * }
- * }
- * });
- *
- * Display-style math is always shown in multi-line format, and without
- * delimiters, as it will already be set off in its own centered
- * paragraph, like standard display mathematics.
- *
- * The default settings place the invalid TeX in a multi-line box with a
- * black border. If you want it to look as though the TeX is just part of
- * the paragraph, use
- *
- * MathJax.Hub.Config({
- * TeX: {
- * noErrors: {
- * inlineDelimiters: ["$","$"], // or ["",""] or ["\\(","\\)"]
- * multiLine: false,
- * style: {
- * "font-size": "normal",
- * "border": ""
- * }
- * }
- * }
- * });
- *
- * You may also wish to set the font family, as the default is "serif"
- *
- * ---------------------------------------------------------------------
- *
- * Copyright (c) 2009-2013 The MathJax Consortium
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */(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");
|