1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-07 12:34:22 +00:00
TiddlyWiki5/plugins/tiddlywiki/katex/files/katex.min.js

4 lines
144 KiB
JavaScript
Raw Normal View History

2015-06-29 20:07:26 +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 n=t[l]={exports:{}};e[l][0].call(n.exports,function(t){var i=e[l][1][t];return h(i?i:t)},n,n.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 n=r(p,e,h).toNode();t.appendChild(n)};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 n=function(e,t){var i=new a(t);var h=l(e,i);return r(h,e,i).toMarkup()};var o=function(e,t){var i=new a(t);return l(e,i)};t.exports={render:p,renderToString:n,__parse:o,ParseError:h}},{"./src/ParseError":5,"./src/Settings":7,"./src/buildTree":12,"./src/parseTree":20,"./src/utils":22}],2:[function(e,t,i){"use strict";function h(e){if(!e.__matchAtRelocatable){var t=e.source+"|()";var i="g"+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"");e.__matchAtRelocatable=new RegExp(t,i)}return e.__matchAtRelocatable}function a(e,t,i){if(e.global||e.sticky){throw new Error("matchAt(...): Only non-global regexes are supported")}var a=h(e);a.lastIndex=i;var r=a.exec(t);if(r[r.length-1]==null){r.length=r.length-1;return r}else{return null}}t.exports=a},{}],3:[function(e,t,i){var h=e("match-at");var a=e("./ParseError");function r(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 p=[/[a-zA-Z0-9`!@*()-=+\[\]'";:?\/.,]/,/[{}]/,/~/,/&/,/\\\\/];var n=/\s*/;var o=/ +|\\ +/;var c=/\\(?:[a-zA-Z]+|.)/;r.prototype._innerLex=function(e,t,i){var r=this._input;var s;if(i){s=h(n,r,e)[0];e+=s.length}else{s=h(o,r,e);if(s!==null){return new l(" ",null,e+s[0].length)}}if(e===r.length){return new l("EOF",null,e)}var p;if(p=h(c,r,e)){return new l(p[0],null,e+p[0].length)}else{for(var g=0;g<t.length;g++){var d=t[g];if(p=h(d,r,e)){return new l(p[0],null,e+p[0].length)}}}throw new a("Unexpected character: '"+r[e]+"'",this,e)};var g=/#[a-z0-9]+|[a-z]+/i;r.prototype._innerLexColor=function(e){var t=this._input;var i=h(n,t,e)[0];e+=i.length;var r;if(r=h(g,t,e)){return new l(r[0],null,e+r[0].length)}else{throw new a("Invalid color",this,e)}};var d=/(-?)\s*(\d+(?:\.\d*)?|\.\d+)\s*([a-z]{2})/;r.prototype._innerLexSize=function(e){var t=this._input;var i=h(n,t,e)[0];e+=i.length;var r;if(r=h(d,t,e)){var s=r[3];if(s!=="em"&&s!=="ex"){throw new a("Invalid unit: '"+s+"'",this,e)}return new l(r[0],{number:+(r[1]+r[2]),unit:s},e+r[0].length)}throw new a("Invalid size",this,e)};r.prototype._innerLexWhitespace=function(e){var t=this._input;var i=h(n,t,e)[0];e+=i.length;return new l(i[0],null,e)};r.prototype.lex=function(e,t){if(t==="math"){return this._innerLex(e,s,true)}else if(t==="text"){return this._innerLex(e,p,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=r},{"./ParseError":5,"match-at":2}],4:[function(e,t,i){function h(e){this.style=e.style;this.color=e.color;this.size=e.size;this.phantom=e.phantom;if(e.parentStyle===undefined){this.parentStyle=e.style}else{this.parentStyle=e.parentStyle}if(e.parentSize===undefined){this.parentSize=e.s
return o};t.exports=y},{"./Options":4,"./ParseError":5,"./Style":8,"./buildCommon":9,"./delimiter":13,"./domTree":14,"./fontMetrics":16,"./utils":22}],11:[function(e,t,i){var h=e("./buildCommon");var a=e("./mathMLTree");var r=e("./ParseError");var l=e("./symbols");var s=h.makeSpan;var p=function(e,t){if(l[t][e]&&l[t][e].replace){e=l[t][e].replace}return new a.TextNode(e)};var n={mathord:function(e){var t=new a.MathNode("mi",[p(e.value,e.mode)]);return t},textord:function(e){var t=p(e.value,e.mode);var i;if(/[0-9]/.test(e.value)){i=new a.MathNode("mn",[t])}else{i=new a.MathNode("mi",[t]);i.setAttribute("mathvariant","normal")}return i},bin:function(e){var t=new a.MathNode("mo",[p(e.value,e.mode)]);return t},rel:function(e){var t=new a.MathNode("mo",[p(e.value,e.mode)]);return t},open:function(e){var t=new a.MathNode("mo",[p(e.value,e.mode)]);return t},close:function(e){var t=new a.MathNode("mo",[p(e.value,e.mode)]);return t},inner:function(e){var t=new a.MathNode("mo",[p(e.value,e.mode)]);return t},punct:function(e){var t=new a.MathNode("mo",[p(e.value,e.mode)]);t.setAttribute("separator","true");return t},ordgroup:function(e){var t=o(e.value);var i=new a.MathNode("mrow",t);return i},text:function(e){var t=o(e.value.body);var i=new a.MathNode("mtext",t);return i},color:function(e){var t=o(e.value.value);var i=new a.MathNode("mstyle",t);i.setAttribute("mathcolor",e.value.color);return i},supsub:function(e){var t=[c(e.value.base)];if(e.value.sub){t.push(c(e.value.sub))}if(e.value.sup){t.push(c(e.value.sup))}var i;if(!e.value.sub){i="msup"}else if(!e.value.sup){i="msub"}else{i="msubsup"}var h=new a.MathNode(i,t);return h},genfrac:function(e){var t=new a.MathNode("mfrac",[c(e.value.numer),c(e.value.denom)]);if(!e.value.hasBarLine){t.setAttribute("linethickness","0px")}if(e.value.leftDelim!=null||e.value.rightDelim!=null){var i=[];if(e.value.leftDelim!=null){var h=new a.MathNode("mo",[new a.TextNode(e.value.leftDelim)]);h.setAttribute("fence","true");i.push(h)}i.push(t);if(e.value.rightDelim!=null){var r=new a.MathNode("mo",[new a.TextNode(e.value.rightDelim)]);r.setAttribute("fence","true");i.push(r)}var l=new a.MathNode("mrow",i);return l}return t},array:function(e){return new a.MathNode("mtable",e.value.body.map(function(e){return new a.MathNode("mtr",e.map(function(e){return new a.MathNode("mtd",[c(e)])}))}))},sqrt:function(e){var t;if(e.value.index){t=new a.MathNode("mroot",[c(e.value.body),c(e.value.index)])}else{t=new a.MathNode("msqrt",[c(e.value.body)])}return t},leftright:function(e){var t=o(e.value.body);if(e.value.left!=="."){var i=new a.MathNode("mo",[p(e.value.left,e.mode)]);i.setAttribute("fence","true");t.unshift(i)}if(e.value.right!=="."){var h=new a.MathNode("mo",[p(e.value.right,e.mode)]);h.setAttribute("fence","true");t.push(h)}var r=new a.MathNode("mrow",t);return r},accent:function(e){var t=new a.MathNode("mo",[p(e.value.accent,e.mode)]);var i=new a.MathNode("mover",[c(e.value.base),t]);i.setAttribute("accent","true");return i},spacing:function(e){var t;if(e.value==="\\ "||e.value==="\\space"||e.value===" "||e.value==="~"){t=new a.MathNode("mtext",[new a.TextNode("\xa0")])}else{t=new a.MathNode("mspace");t.setAttribute("width",h.spacingFunctions[e.value].size)}return t},op:function(e){var t;if(e.value.symbol){t=new a.MathNode("mo",[p(e.value.body,e.mode)])}else{t=new a.MathNode("mi",[new a.TextNode(e.value.body.slice(1))])}return t},katex:function(e){var t=new a.MathNode("mtext",[new a.TextNode("KaTeX")]);return t},delimsizing:function(e){var t=[];if(e.value.value!=="."){t.push(p(e.value.value,e.mode))}var i=new a.MathNode("mo",t);if(e.value.delimType==="open"||e.value.delimType==="close"){i.setAttribute("fence","true")}else{i.setAttribute("fence","false")}return i},styling:function(e){var t=o(e.value.value,t);var i=new a.MathNode("mstyle",t);var h={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]};var r=h[e.value.style];i.setAttribute("scriptlevel",r[0]);i.setAttribute("displaystyle",r[1]);return i},sizing:function(e){var t=o(e.value.value);var i=new a.MathNode("ms
var X=function(e,t){return H[t][e.charCodeAt(0)]};t.exports={metrics:V,getCharacterMetrics:X}},{"./Style":8}],17:[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){return{type:"sqrt",body:i,index:t}}},"\\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,greediness:3,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"}}},"\\phantom":{numArgs:1,handler:function(e,t){var i;if(t.type==="ordgroup"){i=t.value}else{i=[t]}return{type:"phantom",value:i}}}};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","\\blueA","\\blueB","\\blueC","\\blueD","\\blueE","\\tealA","\\tealB","\\tealC","\\tealD","\\tealE","\\greenA","\\greenB","\\greenC","\\greenD","\\greenE","\\goldA","\\goldB","\\goldC","\\goldD","\\goldE","\\redA","\\redB","\\redC","\\redD","\\redE","\\maroonA","\\maroonB","\\maroonC","\\maroonD","\\maroonE","\\purpleA","\\purpleB","\\purpleC","\\purpleD","\\purpleE","\\mintA","\\mintB","\\mintC","\\grayA","\\grayB","\\grayC","\\grayD","\\grayE","\\grayF","\\grayG","\\grayH","\\grayI","\\kaBlue","\\kaGreen"],data:{numArgs:1,allowedInText:true,greediness:3,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,allowedIn
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},{}],22:[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 n=/[&><"']/g;function o(e){return p[e]}function c(e){return(""+e).replace(n,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:c,hyphenate:s,indexOf:a,setTextContent:g,clearNode:u}},{}]},{},[1])(1)});