17 lines
46 KiB
JavaScript
17 lines
46 KiB
JavaScript
|
/*
|
||
|
* /MathJax/jax/input/TeX/jax.js
|
||
|
*
|
||
|
* Copyright (c) 2012 Design Science, Inc.
|
||
|
*
|
||
|
* 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(d,c,i){var h,g="\u00A0";var e=MathJax.Object.Subclass({Init:function(l,k){this.global={isInner:k};this.data=[b.start(this.global)];if(l){this.data[0].env=l}this.env=this.data[0].env},Push:function(){var l,k,n,o;for(l=0,k=arguments.length;l<k;l++){n=arguments[l];if(n instanceof h.mbase){n=b.mml(n)}n.global=this.global;o=(this.data.length?this.Top().checkItem(n):true);if(o instanceof Array){this.Pop();this.Push.apply(this,o)}else{if(o instanceof b){this.Pop();this.Push(o)}else{if(o){this.data.push(n);if(n.env){for(var p in this.env){if(this.env.hasOwnProperty(p)){n.env[p]=this.env[p]}}this.env=n.env}else{n.env=this.env}}}}}},Pop:function(){var k=this.data.pop();if(!k.isOpen){delete k.env}this.env=(this.data.length?this.Top().env:{});return k},Top:function(k){if(k==null){k=1}if(this.data.length<k){return null}return this.data[this.data.length-k]},Prev:function(k){var l=this.Top();if(k){return l.data[l.data.length-1]}else{return l.Pop()}},toString:function(){return"stack[\n "+this.data.join("\n ")+"\n]"}});var b=e.Item=MathJax.Object.Subclass({type:"base",closeError:"Extra close brace or missing open brace",rightError:"Missing \\left or extra \\right",Init:function(){if(this.isOpen){this.env={}}this.data=[];this.Push.apply(this,arguments)},Push:function(){this.data.push.apply(this.data,arguments)},Pop:function(){return this.data.pop()},mmlData:function(k,l){if(k==null){k=true}if(this.data.length===1&&!l){return this.data[0]}return h.mrow.apply(h,this.data).With((k?{inferred:true}:{}))},checkItem:function(k){if(k.type==="over"&&this.isOpen){k.num=this.mmlData(false);this.data=[]}if(k.type==="cell"&&this.isOpen){if(k.linebreak){return false}d.Error("Misplaced "+k.name)}if(k.isClose&&this[k.type+"Error"]){d.Error(this[k.type+"Error"])}if(!k.isNotStack){return true}this.Push(k.data[0]);return false},With:function(k){for(var l in k){if(k.hasOwnProperty(l)){this[l]=k[l]}}return this},toString:function(){return this.type+"["+this.data.join("; ")+"]"}});b.start=b.Subclass({type:"start",isOpen:true,Init:function(k){this.SUPER(arguments).Init.call(this);this.global=k},checkItem:function(k){if(k.type==="stop"){return b.mml(this.mmlData())}return this.SUPER(arguments).checkItem.call(this,k)}});b.stop=b.Subclass({type:"stop",isClose:true});b.open=b.Subclass({type:"open",isOpen:true,stopError:"Extra open brace or missing close brace",checkItem:function(l){if(l.type==="close"){var k=this.mmlData();return b.mml(h.TeXAtom(k))}return this.SUPER(arguments).checkItem.call(this,l)}});b.close=b.Subclass({type:"close",isClose:true});b.prime=b.Subclass({type:"prime",checkItem:function(k){if(this.data[0].type!=="msubsup"){return[h.msup(this.data[0],this.data[1]),k]}this.data[0].SetData(this.data[0].sup,this.data[1]);return[this.data[0],k]}});b.subsup=b.Subclass({type:"subsup",stopError:"Missing superscript or subscript argument",checkItem:function(l){var k=["","subscript","superscript"][this.position];if(l.type==="open"||l.type==="left"){return true}if(l.type==="mml"){if(this.primes){if(this.position!==2){this.data[0].SetData(2,this.primes)}else{l.data[0]=h.mrow(this.primes.With({variantForm:true}),l.data[0])}}this.data[0].SetData(this.position,l.data[0]);return b.mml(this.data[0])}if(this.SUPER(arguments).checkItem.call(this,l)){d.Error("Missing open brace for "+k)}},Pop:function(){}});b.over=b.Subclass({type:"over",isClose:true,name:"\\over",checkItem:function(m,k){if(m.type==="over"){d.Error("Ambiguous use of "+m.name)}if(m.isClose){var l=h.mfrac(this.num,this.mmlData(false));if(this.thickness!=null){l.linethickness=this.thickness}if(this.open||this.close){l.texClass=h.TEXCLASS.INNER;l.texWithDelims=true;l=h.mfenced(l).With({open:this.open,close:this.close})}return[b.mml(l),m]}return this.SUPER(arguments).checkItem.call(this,m)},toString:function(){return"over["+this.num+" / "+this.data.join("; ")+"]"}});b.left=b.Subclass({type:"left",isOpen:true,delim:"(",stopError:"Extra \\left or missing \\right",checkItem:function(l){if(l.type==="right"){var k=h.mfenced(this.data.length===1?this.data[0]:h.mrow.apply(h,this.data));return b.mml(k.W
|
||
|
|