/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ /************************************************************* * * MathJax/jax/input/AsciiMath/jax.js * * An Input Jax for AsciiMath notation * (see http://www1.chapman.edu/~jipsen/mathml/asciimath.html). * * Originally adapted for MathJax by David Lippman. * Additional work done by Davide P. Cervone. * * A portion of this file is taken from * ASCIIMathML.js Version 1.4.7 Aug 30, 2005, (c) Peter Jipsen http://www.chapman.edu/~jipsen * and is used by permission of Peter Jipsen, who has agreed to allow us to * release it under the Apache2 license (see below). That portion is indicated * via comments. * * The remainder falls under the copyright that follows. * * --------------------------------------------------------------------- * * Copyright (c) 2012-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(u){function x(a){return A?k.createElement(a):k.createElementNS("http://www.w3.org/1999/xhtml",a)}function m(a,b){return a.input>b.input?1:-1}function q(){var a=[],b;for(b=0;b=d.charCodeAt(c);c+=1);return d.slice(c)}function G(a,b,d){if(0==d){var c,e;d=-1;for(c=a.length;d+1>1,a[e]=r[b];L=E;if(""!=e)return E=h[d].ttype,h[d];E=0;b=1;c=a.slice(0,1);for(d=!0;"0"<=c&&"9">=c&&b<=a.length;)c=a.slice(b,b+1),b++;if(c==M&&(c=a.slice(b,b+1),"0"<=c&&"9">=c))for(d=!1,b++;"0"<=c&&"9">=c&&b<=a.length;)c=a.slice(b,b+1),b++;d&&1c||"Z"c||"z"f.charCodeAt(l)?a+String.fromCharCode(b.codes[f.charCodeAt(l)-65]):a+f.charAt(l);"mi"==c[0].nodeName?c[0]=n("mo").appendChild(k.createTextNode(a)):c[0].replaceChild(n("mo").appendChild(k.createTextNode(a)),c[0].childNodes[e])}d=g(b.tag,c[0]);d.setAttribute(b.atname,b.atval)}return[d,c[1]];case 2:a=p(a,b.input.length);c=t(a);if(null==c[0])return[g("mo",k.createTextNode(b.input)),a];w(c[0]);e=t(c[1]);if(null==e[0])return[g("mo",k.createTextNode(b.input)),a];w(e[0]);"root"!=b.input&&"stackrel"!=b.input||l.appendChild(e[0]);l.appendChild(c[0]);"frac"==b.input&&l.appendChild(e[0]);return[g(b.tag,l),e[1]];case 3:return a=p(a,b.input.length),[g("mo",k.createTextNode(b.output)),a];case 6:return a=p(a,b.input.length),d=n("mspace"),d.setAttribute("width","1ex"),l.appendChild(d),l.appendChild(g(b.tag,k.createTextNode(b.output))),d=n("mspace"),d.setAttribute("width","1ex"),l.appendChild(d),[g("mrow",l),a];case 9:y++;a=p(a,b.input.length);c=B(a,!1);y--;f="";null!=c[0].lastChild&&(f=c[0].lastChild.firstChild.nodeValue);if("|"==f)return d=g("mo",k.createTextNode(b.output)),d=g("mrow",d),d.appendChild(c[0]),[d,c[1]];d=g("mo",k.createTextNode(b.output));d=g("mrow",d);return[d,a];default:return a=p(a,b.input.length),[g(b.tag,k.createTextNode(b.output)),a]}}function F(a){var b,d,c,e;a=p(a,0);d=v(a);e=t(a);c=e[0];a=e[1];b=v(a);3==b.ttype&&"/"!=b.input&&(a=p(a,b.input.length),e=t(a),null==e[0]?e[0]=g("mo",k.createTextNode("\u25a1")):w(e[0]),a=e[1],"_"==b.input?(b=v(a),d=7==d.ttype,"^"==b.input?(a=p(a,b.input.length),b=t(a),w(b[0]),a=b[1],c=g(d?"munderover":"msubsup",c),c.appendChild(e[0]),c.appendChild(b[0]),c=g("mrow",c)):(c=g(d?"munder":"msub",c),c.appendChild(e[0]))):(c=g(b.tag,c),c.appendChild(e[0])));return[c,a]}function B(a,b){var d,c,e,f=k.createDocumentFragment();do a=p(a,0),e=F(a),c=e[0],a=e[1],d=v(a),3==d.ttype&&"/"==d.input?(a=p(a,d.input.length),e=F(a),null==e[0]?e[0]=g("mo",k.createTextNode("\u25a1")):w(e[0]),a=e[1],w(c),c=g(d.tag,c),c.appendChild(e[0]),f.appendChild(c),d=v(a)):void 0!=c&&f.appendChild(c);while((5!=d.ttype&&(9!=d.ttype||b)||0==y)&&null!=d&&""!=d.output);if(5==d.ttype||9==d.ttype){c=f.childNodes.length;if(0=c-1&&(this.lastChild=a);this.childNodes[d]=a;a.nextSibling=b.nextSibling;b.nextSibling=b.parent=null;return b},toString:function(){return"{"+this.childNodes.join("")+"}"}}),S=function(){C=MathJax.ElementJax.mml;var a=C.mbase.prototype.Init;C.mbase.Augment({firstChild:null,lastChild:null,nodeValue:"",nextSibling:null,Init:function(){var b=a.apply(this,arguments)||this;b.childNodes=b.data;b.nodeName=b.type;return b},appendChild:function(b){b.parent&&b.parent.removeChild(b);var a=arguments;b.isa(K)&&(a=b.childNodes,b.data=b.childNodes=[],b.firstChild=b.lastChild=null);for(var c=0,e=a.length;c=e-1&&(this.lastChild=b);this.SetData(c,b);b.nextSibling=a.nextSibling;this.nodeValue="";c=0;for(e=this.childNodes.length;c