1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-04 15:29:56 +00:00
TiddlyWiki5/plugins/tiddlywiki/katex/files/katex.min.js

3 lines
113 KiB
JavaScript
Raw Normal View History

2014-10-17 19:10:38 +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 l(e,t,i){function h(s,r){if(!t[s]){if(!e[s]){var p=typeof require=="function"&&require;if(!r&&p)return p(s,!0);if(a)return a(s,!0);throw new Error("Cannot find module '"+s+"'")}var c=t[s]={exports:{}};e[s][0].call(c.exports,function(t){var i=e[s][1][t];return h(i?i:t)},c,c.exports,l,e,t,i)}return t[s].exports}var a=typeof require=="function"&&require;for(var s=0;s<i.length;s++)h(i[s]);return h}({1:[function(e,t,i){var h=e("./src/ParseError");var a=e("./src/buildTree");var l=e("./src/parseTree");var s=e("./src/utils");var r=function(e,t){s.clearNode(t);var i=l(e);var h=a(i).toNode();t.appendChild(h)};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.");r=function(){throw new h("KaTeX doesn't work in quirks mode.")}}}var p=function(e){var t=l(e);return a(t).toMarkup()};t.exports={render:r,renderToString:p,ParseError:h}},{"./src/ParseError":4,"./src/buildTree":8,"./src/parseTree":13,"./src/utils":15}],2:[function(e,t,i){var h=e("./ParseError");function a(e){this._input=e}function l(e,t,i){this.text=e;this.data=t;this.position=i}var s=[/^[/|@.""`0-9a-zA-Z]/,/^[*+-]/,/^[=<>:]/,/^[,;]/,/^['\^_{}]/,/^[(\[]/,/^[)\]?!]/,/^~/];var r=[/^[a-zA-Z0-9`!@*()-=+\[\]'";:?\/.,]/,/^[{}]/,/^~/];var p=/^\s*/;var c=/^( +|\\ +)/;var g=/^\\(?:[a-zA-Z]+|.)/;a.prototype._innerLex=function(e,t,i){var a=this._input.slice(e);var s;if(i){s=a.match(p)[0];e+=s.length;a=a.slice(s.length)}else{s=a.match(c);if(s!==null){return new l(" ",null,e+s[0].length)}}if(a.length===0){return new l("EOF",null,e)}var r;if(r=a.match(g)){return new l(r[0],null,e+r[0].length)}else{for(var d=0;d<t.length;d++){var n=t[d];if(r=a.match(n)){return new l(r[0],null,e+r[0].length)}}}throw new h("Unexpected character: '"+a[0]+"'",this,e)};var d=/^(#[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(d)){return new l(a[0],null,e+a[0].length)}else{throw new h("Invalid color",this,e)}};var n=/^(-?)\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(n)){var s=a[3];if(s!=="em"&&s!=="ex"){throw new h("Invalid unit: '"+s+"'",this,e)}return new l(a[0],{number:+(a[1]+a[2]),unit:s},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 l(i,null,e)};a.prototype.lex=function(e,t){if(t==="math"){return this._innerLex(e,s,true)}else if(t==="text"){return this._innerLex(e,r,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.prototype.getColor=function(){return a[this.color]||this.color};t.exports=h},{}],4:[function(e,
}if(r>t){return i[l]}}return i[i.length-1]};var R=function(e,t,i,h,a){if(e==="<"){e="\\langle"}else if(e===">"){e="\\rangle"}var l;if(p.contains(v,e)){l=b}else if(p.contains(m,e)){l=S}else{l=z}var s=M(e,t,l,h);if(s.type==="small"){return o(e,s.style,i,h,a)}else if(s.type==="large"){return w(e,s.size,i,h,a)}else if(s.type==="stack"){return u(e,t,i,h,a)}};var C=function(e,t,i,h,a){var l=s.metrics.axisHeight*h.style.sizeMultiplier;var r=901;var p=5/s.metrics.ptPerEm;var c=Math.max(t-l,i+l);var g=Math.max(c/500*r,2*c-p);return R(e,g,true,h,a)};t.exports={sizedDelim:x,customSizedDelim:R,leftRightDelim:C}},{"./ParseError":4,"./Style":6,"./buildCommon":7,"./fontMetrics":11,"./symbols":14,"./utils":15}],10:[function(e,t,i){var h=e("./utils");var a=function(e){e=e.slice();for(var t=e.length-1;t>=0;t--){if(!e[t]){e.splice(t,1)}}return e.join(" ")};function l(e,t,i,h,a,l){this.classes=e||[];this.children=t||[];this.height=i||0;this.depth=h||0;this.maxFontSize=a||0;this.style=l||{}}l.prototype.toNode=function(){var e=document.createElement("span");e.className=a(this.classes);for(var t in this.style){if(this.style.hasOwnProperty(t)){e.style[t]=this.style[t]}}for(var i=0;i<this.children.length;i++){e.appendChild(this.children[i].toNode())}return e};l.prototype.toMarkup=function(){var e="<span";if(this.classes.length){e+=' class="';e+=h.escape(a(this.classes));e+='"'}var t="";for(var i in this.style){if(this.style.hasOwnProperty(i)){t+=h.hyphenate(i)+":"+this.style[i]+";"}}if(t){e+=' style="'+h.escape(t)+'"'}e+=">";for(var l=0;l<this.children.length;l++){e+=this.children[l].toMarkup()}e+="</span>";return e};function s(e,t,i,h){this.children=e||[];this.height=t||0;this.depth=i||0;this.maxFontSize=h||0}s.prototype.toNode=function(){var e=document.createDocumentFragment();for(var t=0;t<this.children.length;t++){e.appendChild(this.children[t].toNode())}return e};s.prototype.toMarkup=function(){var e="";for(var t=0;t<this.children.length;t++){e+=this.children[t].toMarkup()}return e};function r(e,t,i,h,a,l,s){this.value=e||"";this.height=t||0;this.depth=i||0;this.italic=h||0;this.skew=a||0;this.classes=l||[];this.style=s||{};this.maxFontSize=0}r.prototype.toNode=function(){var e=document.createTextNode(this.value);var t=null;if(this.italic>0){t=document.createElement("span");t.style.marginRight=this.italic+"em"}if(this.classes.length>0){t=t||document.createElement("span");t.className=a(this.classes)}for(var i in this.style){if(this.style.hasOwnProperty(i)){t=t||document.createElement("span");t.style[i]=this.style[i]}}if(t){t.appendChild(e);return t}else{return e}};r.prototype.toMarkup=function(){var e=false;var t="<span";if(this.classes.length){e=true;t+=' class="';t+=h.escape(a(this.classes));t+='"'}var i="";if(this.italic>0){i+="margin-right:"+this.italic+"em;"}for(var l in this.style){if(this.style.hasOwnProperty(l)){i+=h.hyphenate(l)+":"+this.style[l]+";"}}if(i){e=true;t+=' style="'+h.escape(i)+'"'}var s=h.escape(this.value);if(e){t+=">";t+=s;t+="</span>";return t}else{return s}};t.exports={span:l,documentFragment:s,symbolNode:r}},{"./utils":15}],11:[function(e,t,i){var h=e("./Style");var a=.025;var l=0;var s=0;var r=0;var p=.431;var c=1;var g=0;var d=.677;var n=.394;var o=.444;var w=.686;var k=.345;var u=.413;var m=.363;var f=.289;var v=.15;var y=.247;var x=.386;var b=.05;var z=2.39;var S=1.01;var T=.81;var M=.71;var R=.25;var C=0;var A=0;var E=0;var P=0;var I=.431;var L=1;var O=0;var D=.04;var q=.111;var F=.166;var _=.2;var B=.6;var G=.1;var N=10;var X={xHeight:p,quad:c,num1:d,num2:n,num3:o,denom1:w,denom2:k,sup1:u,sup2:m,sup3:f,sub1:v,sub2:y,supDrop:x,subDrop:b,axisHeight:R,defaultRuleThickness:D,bigOpSpacing1:q,bigOpSpacing2:F,bigOpSpacing3:_,bigOpSpacing4:B,bigOpSpacing5:G,ptPerEm:N,delim1:z,getDelim2:function(e){if(e.size===h.TEXT.size){return S}else if(e.size===h.SCRIPT.size){return T}else if(e.size===h.SCRIPTSCRIPT.size){return M}throw new Error("Unexpected style size: "+e.size)}};var H={"AMS-Regular":{10003:{depth:0,height:.69224,italic:0,skew:0},10016:{depth:0,height:.69224,italic:0,skew:0},1008:{depth:0,height:.43056,italic:.
var V=function(e,t){return H[t][e.charCodeAt(0)]};t.exports={metrics:X,getCharacterMetrics:V}},{"./Style":6}],12:[function(e,t,i){var h=e("./utils");var a=e("./ParseError");var l={"\\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 s={"\\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 r=["(",")","[","\\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 l=null;var s="auto";switch(e){case"\\dfrac":case"\\frac":case"\\tfrac":h=true;break;case"\\dbinom":case"\\binom":case"\\tbinom":h=false;a="(";l=")";break;default:throw new Error("Unrecognized genfrac command")}switch(e){case"\\dfrac":case"\\dbinom":s="display";break;case"\\tfrac":case"\\tbinom":s="text";break}return{type:"genfrac",numer:t,denom:i,hasBarLine:h,leftDelim:a,rightDelim:l,size:s}}}},{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(r,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:s[e].size,delimType:s[e].type,value:t.value}}}}},{funcs:["\\tiny","\\scriptsize","\\foo