1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-15 14:24:51 +00:00
TiddlyWiki5/plugins/tiddlywiki/katex/files/katex.min.js

4 lines
137 KiB
JavaScript
Raw Normal View History

2015-03-14 08:34:16 +00:00
(function(e){if("function"==typeof bootstrap)bootstrap("katex",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeKatex=e}else"undefined"!=typeof window?window.katex=e():global.katex=e()})(function(){var e,t,i,h,a;return function r(e,t,i){function h(l,s){if(!t[l]){if(!e[l]){var p=typeof require=="function"&&require;if(!s&&p)return p(l,!0);if(a)return a(l,!0);throw new Error("Cannot find module '"+l+"'")}var c=t[l]={exports:{}};e[l][0].call(c.exports,function(t){var i=e[l][1][t];return h(i?i:t)},c,c.exports,r,e,t,i)}return t[l].exports}var a=typeof require=="function"&&require;for(var l=0;l<i.length;l++)h(i[l]);return h}({1:[function(e,t,i){var h=e("./src/ParseError");var a=e("./src/Settings");var r=e("./src/buildTree");var l=e("./src/parseTree");var s=e("./src/utils");var p=function(e,t,i){s.clearNode(t);var h=new a(i);var p=l(e,h);var c=r(p,e,h).toNode();t.appendChild(c)};if(typeof document!=="undefined"){if(document.compatMode!=="CSS1Compat"){typeof console!=="undefined"&&console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your "+"website has a suitable doctype.");p=function(){throw new h("KaTeX doesn't work in quirks mode.")}}}var c=function(e,t){var i=new a(t);var h=l(e,i);return r(h,e,i).toMarkup()};t.exports={render:p,renderToString:c,ParseError:h}},{"./src/ParseError":4,"./src/Settings":6,"./src/buildTree":11,"./src/parseTree":17,"./src/utils":19}],2:[function(e,t,i){var h=e("./ParseError");function a(e){this._input=e}function r(e,t,i){this.text=e;this.data=t;this.position=i}var l=[/^[/|@.""`0-9a-zA-Z]/,/^[*+-]/,/^[=<>:]/,/^[,;]/,/^['\^_{}]/,/^[(\[]/,/^[)\]?!]/,/^~/];var s=[/^[a-zA-Z0-9`!@*()-=+\[\]'";:?\/.,]/,/^[{}]/,/^~/];var p=/^\s*/;var c=/^( +|\\ +)/;var o=/^\\(?:[a-zA-Z]+|.)/;a.prototype._innerLex=function(e,t,i){var a=this._input.slice(e);var l;if(i){l=a.match(p)[0];e+=l.length;a=a.slice(l.length)}else{l=a.match(c);if(l!==null){return new r(" ",null,e+l[0].length)}}if(a.length===0){return new r("EOF",null,e)}var s;if(s=a.match(o)){return new r(s[0],null,e+s[0].length)}else{for(var n=0;n<t.length;n++){var g=t[n];if(s=a.match(g)){return new r(s[0],null,e+s[0].length)}}}throw new h("Unexpected character: '"+a[0]+"'",this,e)};var n=/^(#[a-z0-9]+|[a-z]+)/i;a.prototype._innerLexColor=function(e){var t=this._input.slice(e);var i=t.match(p)[0];e+=i.length;t=t.slice(i.length);var a;if(a=t.match(n)){return new r(a[0],null,e+a[0].length)}else{throw new h("Invalid color",this,e)}};var g=/^(-?)\s*(\d+(?:\.\d*)?|\.\d+)\s*([a-z]{2})/;a.prototype._innerLexSize=function(e){var t=this._input.slice(e);var i=t.match(p)[0];e+=i.length;t=t.slice(i.length);var a;if(a=t.match(g)){var l=a[3];if(l!=="em"&&l!=="ex"){throw new h("Invalid unit: '"+l+"'",this,e)}return new r(a[0],{number:+(a[1]+a[2]),unit:l},e+a[0].length)}throw new h("Invalid size",this,e)};a.prototype._innerLexWhitespace=function(e){var t=this._input.slice(e);var i=t.match(p)[0];e+=i.length;return new r(i,null,e)};a.prototype.lex=function(e,t){if(t==="math"){return this._innerLex(e,l,true)}else if(t==="text"){return this._innerLex(e,s,false)}else if(t==="color"){return this._innerLexColor(e)}else if(t==="size"){return this._innerLexSize(e)}else if(t==="whitespace"){return this._innerLexWhitespace(e)}};t.exports=a},{"./ParseError":4}],3:[function(e,t,i){function h(e,t,i,h,a){this.style=e;this.color=i;this.size=t;if(h===undefined){h=e}this.parentStyle=h;if(a===undefined){a=t}this.parentSize=a}h.prototype.withStyle=function(e){return new h(e,this.size,this.color,this.style,this.size)};h.prototype.withSize=function(e){return new h(this.style,e,this.color,this.style,this.size)};h.prototype.withColor=function(e){return new h(this.style,this.size,e,this.style,this.size)};h.prototype.reset=function(){return new h(this.style,this.size,this.color,this.style,this.size)};var a={"katex-blue":"#6495ed","katex-orange":"#ffa500","katex-pink":"#ff00af","katex-red":"#df0030","katex-green":"#28ae7b","katex-gray":"gray","katex-purple":"#9d38bd"};h.pro
t.setAttribute("lspace","-1width");t.setAttribute("width","0px");return t},rlap:function(e){var t=new a.MathNode("mpadded",[n(e.value.body)]);t.setAttribute("width","0px");return t}};var o=function(e){var t=[];for(var i=0;i<e.length;i++){var h=e[i];t.push(n(h))}return t};var n=function(e){if(!e){return new a.MathNode("mrow")}if(c[e.type]){return c[e.type](e)}else{throw new r("Got group of unknown type: '"+e.type+"'")}};var g=function(e,t,i){var h=o(e);var r=new a.MathNode("mrow",h);var l=new a.MathNode("annotation",[new a.TextNode(t)]);l.setAttribute("encoding","application/x-tex");var p=new a.MathNode("semantics",[r,l]);var c=new a.MathNode("math",[p]);return s(["katex-mathml"],[c])};t.exports=g},{"./ParseError":4,"./buildCommon":8,"./mathMLTree":16,"./symbols":18}],11:[function(e,t,i){var h=e("./buildHTML");var a=e("./buildMathML");var r=e("./buildCommon");var l=r.makeSpan;var s=function(e,t,i){var r=a(e,t,i);var s=h(e,i);var p=l(["katex"],[r,s]);if(i.displayMode){return l(["katex-display"],[p])}else{return p}};t.exports=s},{"./buildCommon":8,"./buildHTML":9,"./buildMathML":10}],12:[function(e,t,i){var h=e("./ParseError");var a=e("./Style");var r=e("./buildCommon");var l=e("./fontMetrics");var s=e("./symbols");var p=e("./utils");var c=r.makeSpan;var o=function(e,t){if(s.math[e]&&s.math[e].replace){return l.getCharacterMetrics(s.math[e].replace,t)}else{return l.getCharacterMetrics(e,t)}};var n=function(e,t,i){return r.makeSymbol(e,"Size"+t+"-Regular",i)};var g=function(e,t,i){var h=c(["style-wrap",i.style.reset(),t.cls()],[e]);var a=t.sizeMultiplier/i.style.sizeMultiplier;h.height*=a;h.depth*=a;h.maxFontSize=t.sizeMultiplier;return h};var d=function(e,t,i,h,a){var s=r.makeSymbol(e,"Main-Regular",a);var p=g(s,t,h);if(i){var c=(1-h.style.sizeMultiplier/t.sizeMultiplier)*l.metrics.axisHeight;p.style.top=c+"em";p.height-=c;p.depth+=c}return p};var u=function(e,t,i,h,r){var s=n(e,t,r);var p=g(c(["delimsizing","size"+t],[s],h.getColor()),a.TEXT,h);if(i){var o=(1-h.style.sizeMultiplier)*l.metrics.axisHeight;p.style.top=o+"em";p.height-=o;p.depth+=o}return p};var w=function(e,t,i){var h;if(t==="Size1-Regular"){h="delim-size1"}else if(t==="Size4-Regular"){h="delim-size4"}var a=c(["delimsizinginner",h],[c([],[r.makeSymbol(e,t,i)])]);return{type:"elem",elem:a}};var k=function(e,t,i,h,s){var p,n,d,u;p=d=u=e;n=null;var k="Size1-Regular";if(e==="\\uparrow"){d=u="\u23d0"}else if(e==="\\Uparrow"){d=u="\u2016"}else if(e==="\\downarrow"){p=d="\u23d0"}else if(e==="\\Downarrow"){p=d="\u2016"}else if(e==="\\updownarrow"){p="\\uparrow";d="\u23d0";u="\\downarrow"}else if(e==="\\Updownarrow"){p="\\Uparrow";d="\u2016";u="\\Downarrow"}else if(e==="["||e==="\\lbrack"){p="\u23a1";d="\u23a2";u="\u23a3";k="Size4-Regular"}else if(e==="]"||e==="\\rbrack"){p="\u23a4";d="\u23a5";u="\u23a6";k="Size4-Regular"}else if(e==="\\lfloor"){d=p="\u23a2";u="\u23a3";k="Size4-Regular"}else if(e==="\\lceil"){p="\u23a1";d=u="\u23a2";k="Size4-Regular"}else if(e==="\\rfloor"){d=p="\u23a5";u="\u23a6";k="Size4-Regular"}else if(e==="\\rceil"){p="\u23a4";d=u="\u23a5";k="Size4-Regular"}else if(e==="("){p="\u239b";d="\u239c";u="\u239d";k="Size4-Regular"}else if(e===")"){p="\u239e";d="\u239f";u="\u23a0";k="Size4-Regular"}else if(e==="\\{"||e==="\\lbrace"){p="\u23a7";n="\u23a8";u="\u23a9";d="\u23aa";k="Size4-Regular"}else if(e==="\\}"||e==="\\rbrace"){p="\u23ab";n="\u23ac";u="\u23ad";d="\u23aa";k="Size4-Regular"}else if(e==="\\surd"){p="\ue001";u="\u23b7";d="\ue000";k="Size4-Regular"}var m=o(p,k);var f=m.height+m.depth;var v=o(d,k);var y=v.height+v.depth;var b=o(u,k);var x=b.height+b.depth;var z,S;if(n!==null){z=o(n,k);S=z.height+z.depth}var M=f+x;if(n!==null){M+=S}while(M<t){M+=y;if(n!==null){M+=y}}var q=l.metrics.axisHeight;if(i){q*=h.style.sizeMultiplier}var T=M/2-q;var N=[];N.push(w(u,k,s));var A;if(n===null){var R=M-f-x;var C=Math.ceil(R/y);for(A=0;A<C;A++){N.push(w(d,k,s))}}else{var L=M/2-f-S/2;var E=Math.ceil(L/y);var P=M/2-f-S/2;var D=Math.ceil(P/y);for(A=0;A<E;A++){N.push(w(d,k,s))}N.push(w(n,k,s));for(A=0;A<D;A++){N.push(w(d,k,s))}}N.push(w(p,k,s));var I=r.makeVList(
var V=function(e,t){return H[t][e.charCodeAt(0)]};t.exports={metrics:G,getCharacterMetrics:V}},{"./Style":7}],15:[function(e,t,i){var h=e("./utils");var a=e("./ParseError");var r={"\\sqrt":{numArgs:1,numOptionalArgs:1,handler:function(e,t,i,h){if(t!=null){throw new a("Optional arguments to \\sqrt aren't supported yet",this.lexer,h[1]-1)}return{type:"sqrt",body:i}}},"\\text":{numArgs:1,argTypes:["text"],greediness:2,handler:function(e,t){var i;if(t.type==="ordgroup"){i=t.value}else{i=[t]}return{type:"text",body:i}}},"\\color":{numArgs:2,allowedInText:true,argTypes:["color","original"],handler:function(e,t,i){var h;if(i.type==="ordgroup"){h=i.value}else{h=[i]}return{type:"color",color:t.value,value:h}}},"\\overline":{numArgs:1,handler:function(e,t){return{type:"overline",body:t}}},"\\rule":{numArgs:2,numOptionalArgs:1,argTypes:["size","size","size"],handler:function(e,t,i,h){return{type:"rule",shift:t&&t.value,width:i.value,height:h.value}}},"\\KaTeX":{numArgs:0,handler:function(e){return{type:"katex"}}}};var l={"\\bigl":{type:"open",size:1},"\\Bigl":{type:"open",size:2},"\\biggl":{type:"open",size:3},"\\Biggl":{type:"open",size:4},"\\bigr":{type:"close",size:1},"\\Bigr":{type:"close",size:2},"\\biggr":{type:"close",size:3},"\\Biggr":{type:"close",size:4},"\\bigm":{type:"rel",size:1},"\\Bigm":{type:"rel",size:2},"\\biggm":{type:"rel",size:3},"\\Biggm":{type:"rel",size:4},"\\big":{type:"textord",size:1},"\\Big":{type:"textord",size:2},"\\bigg":{type:"textord",size:3},"\\Bigg":{type:"textord",size:4}};var s=["(",")","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\\lceil","\\rceil","<",">","\\langle","\\rangle","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."];var p=[{funcs:["\\blue","\\orange","\\pink","\\red","\\green","\\gray","\\purple"],data:{numArgs:1,allowedInText:true,handler:function(e,t){var i;if(t.type==="ordgroup"){i=t.value}else{i=[t]}return{type:"color",color:"katex-"+e.slice(1),value:i}}}},{funcs:["\\arcsin","\\arccos","\\arctan","\\arg","\\cos","\\cosh","\\cot","\\coth","\\csc","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\tan","\\tanh"],data:{numArgs:0,handler:function(e){return{type:"op",limits:false,symbol:false,body:e}}}},{funcs:["\\det","\\gcd","\\inf","\\lim","\\liminf","\\limsup","\\max","\\min","\\Pr","\\sup"],data:{numArgs:0,handler:function(e){return{type:"op",limits:true,symbol:false,body:e}}}},{funcs:["\\int","\\iint","\\iiint","\\oint"],data:{numArgs:0,handler:function(e){return{type:"op",limits:false,symbol:true,body:e}}}},{funcs:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcup","\\smallint"],data:{numArgs:0,handler:function(e){return{type:"op",limits:true,symbol:true,body:e}}}},{funcs:["\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom"],data:{numArgs:2,greediness:2,handler:function(e,t,i){var h;var a=null;var r=null;var l="auto";switch(e){case"\\dfrac":case"\\frac":case"\\tfrac":h=true;break;case"\\dbinom":case"\\binom":case"\\tbinom":h=false;a="(";r=")";break;default:throw new Error("Unrecognized genfrac command")}switch(e){case"\\dfrac":case"\\dbinom":l="display";break;case"\\tfrac":case"\\tbinom":l="text";break}return{type:"genfrac",numer:t,denom:i,hasBarLine:h,leftDelim:a,rightDelim:r,size:l}}}},{funcs:["\\llap","\\rlap"],data:{numArgs:1,allowedInText:true,handler:function(e,t){return{type:e.slice(1),body:t}}}},{funcs:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg","\\left","\\right"],data:{numArgs:1,handler:function(e,t,i){if(!h.contains(s,t.value)){throw new a("Invalid delimiter: '"+t.value+"' after '"+e+"'",this.lexer,i[1])}if(e==="\\left"||e==="\\right"){return{type:"leftright",value:t.value}}else{return{type:"delimsizing",size:l[e].size,delimType:l[e].type,value:t.value}}}}},{funcs:["\\tiny","\\scriptsize","\\foo
var a='0123456789/@."';for(var r=0;r<a.length;r++){var l=a.charAt(r);h.math[l]={font:"main",group:"textord"}}var s="0123456789`!@*()-=+[]'\";:?/.,";for(var r=0;r<s.length;r++){var l=s.charAt(r);h.text[l]={font:"main",group:"textord"}}var p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(var r=0;r<p.length;r++){var l=p.charAt(r);h.math[l]={font:"main",group:"mathord"};h.text[l]={font:"main",group:"textord"}}t.exports=h},{}],19:[function(e,t,i){var h=Array.prototype.indexOf;var a=function(e,t){if(e==null){return-1}if(h&&e.indexOf===h){return e.indexOf(t)}var i=0,a=e.length;for(;i<a;i++){if(e[i]===t){return i}}return-1};var r=function(e,t){return a(e,t)!==-1};var l=/([A-Z])/g;var s=function(e){return e.replace(l,"-$1").toLowerCase()};var p={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"};var c=/[&><"']/g;function o(e){return p[e]}function n(e){return(""+e).replace(c,o)}var g;if(typeof document!=="undefined"){var d=document.createElement("span");if("textContent"in d){g=function(e,t){e.textContent=t}}else{g=function(e,t){e.innerText=t}}}function u(e){g(e,"")}t.exports={contains:r,escape:n,hyphenate:s,indexOf:a,setTextContent:g,clearNode:u}},{}]},{},[1])(1)});