mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-28 19:10:28 +00:00
3 lines
108 KiB
JavaScript
3 lines
108 KiB
JavaScript
|
(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,p){if(!t[s]){if(!e[s]){var r=typeof require=="function"&&require;if(!p&&r)return r(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 p=function(e,t){s.clearNode(t);var i=l(e);var h=a(i).toNode();t.appendChild(h)};var r=function(e){var t=l(e);return a(t).toMarkup()};t.exports={render:p,renderToString:r,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.type=e;this.text=t;this.position=i}var s=[[/^[/|@."`0-9]/,"textord"],[/^[a-zA-Z]/,"mathord"],[/^[*+-]/,"bin"],[/^[=<>:]/,"rel"],[/^[,;]/,"punct"],[/^'/,"'"],[/^\^/,"^"],[/^_/,"_"],[/^{/,"{"],[/^}/,"}"],[/^[(\[]/,"open"],[/^[)\]?!]/,"close"],[/^~/,"spacing"]];var p=[[/^[a-zA-Z0-9`!@*()-=+\[\]'";:?\/.,]/,"textord"],[/^{/,"{"],[/^}/,"}"],[/^~/,"spacing"]];var r=/^\s*/;var c=/^( +|\\ +)/;var g=/^\\(?:[a-zA-Z]+|.)/;a.prototype._innerLex=function(e,t,i){var a=this._input.slice(e);if(i){var s=a.match(r)[0];e+=s.length;a=a.slice(s.length)}else{var s=a.match(c);if(s!==null){return new l(" "," ",e+s[0].length)}}if(a.length===0){return new l("EOF",null,e)}var p;if(p=a.match(g)){return new l(p[0],p[0],e+p[0].length)}else{for(var d=0;d<t.length;d++){var n=t[d];if(p=a.match(n[0])){return new l(n[1],p[0],e+p[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(r)[0];e+=i.length;t=t.slice(i.length);var a;if(a=t.match(d)){return new l("color",a[0],e+a[0].length)}else{throw new h("Invalid color",this,e)}};var n=/^(\d+(?:\.\d*)?|\.\d+)\s*([a-z]{2})/;a.prototype._innerLexSize=function(e){var t=this._input.slice(e);var i=t.match(r)[0];e+=i.length;t=t.slice(i.length);var a;if(a=t.match(n)){var s=a[2];if(s!=="em"&&s!=="ex"){throw new h("Invalid unit: '"+s+"'",this,e)}return new l("size",{number:+a[1],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(r)[0];e+=i.length;return new l("whitespace",i,e)};a.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=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,t,i){function h(e,t,i){var a="KaTeX parse error: "+e;if(t!==undefined&&i!==undefined){a+=" at position "+i+
|
||
|
}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 p(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}p.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}};p.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:p}},{"./utils":15}],11:[function(e,t,i){var h=.025;var a=0;var l=0;var s=0;var p=.431;var r=1;var c=0;var g=.677;var d=.394;var n=.444;var o=.686;var w=.345;var k=.413;var u=.363;var m=.289;var f=.15;var v=.247;var y=.386;var x=.05;var b=2.39;var z=.101;var S=.25;var T=0;var M=0;var R=0;var C=0;var E=.431;var P=1;var A=0;var L=.04;var I=.111;var O=.166;var q=.2;var D=.6;var B=.1;var F=10;var _={xHeight:p,quad:r,num1:g,num2:d,num3:n,denom1:o,denom2:w,sup1:k,sup2:u,sup3:m,sub1:f,sub2:v,supDrop:y,subDrop:x,delim1:b,delim2:z,axisHeight:S,defaultRuleThickness:L,bigOpSpacing1:I,bigOpSpacing2:O,bigOpSpacing3:q,bigOpSpacing4:D,bigOpSpacing5:B,ptPerEm:F};var N={"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:.04028,skew:0},107:{depth:0,height:.68889,italic:0,skew:0},10731:{depth:.11111,height:.69224,italic:0,skew:0},10846:{depth:.19444,height:.75583,italic:0,skew:0},10877:{depth:.13667,height:.63667,italic:0,skew:0},10878:{depth:.13667,height:.63667,italic:0,skew:0},10885:{depth:.25583,height:.75583,italic:0,skew:0},10886:{depth:.25583,height:.75583,italic:0,skew:0},10887:{depth:.13597,height:.63597,italic:0,skew:0},10888:{depth:.13597,height:.63597,italic:0,skew:0},10889:{depth:.26167,height:.75726,italic:0,skew:0},10890:{depth:.26167,height:.75726,italic:0,skew:0},10891:{depth:.48256,height:.98256,italic:0,skew:0},10892:{depth:.48256,height:.98256,italic:0,skew:0},10901:{depth:.13667,height:.63667,italic:0,skew:0},10902:{depth:.13667,height:.63667,italic:0,skew:0},10933:{depth:.25142,height:.75726,italic:0,skew:0},10934:{depth:.25142,height:.75726,italic:0,skew:0},10935:{depth:.26167,height:.75726,italic:0,skew:0},10936:{depth:.26167,height:.75726,italic:0,skew:0},10937:{depth:.26167,height:.75726,italic:0,skew:0},10938:{depth:.26167,height:.75726,italic:0,skew:0},10949:{depth:.25583,height:.75583,italic:0,skew:0},10950:{depth:.25583,height:.75583,italic:0,skew:0},10955:{depth:.28481,height:.79383,italic:0,skew:0},10956:{depth:.28481,height:.79383,italic:0,skew:0},165:{depth:0,height:.675,italic:.025,skew:0},174:{depth:.15559,height:.69224,italic:0,skew:0},240:{depth:0,height:.68889,italic:0,skew:0},295:{depth:0,height:.68889,italic:0,skew:0},57350:{depth:.08167,height:.58167,italic:0,skew:0},57351:{depth:.08167,height:.58167,italic:0,skew:0},57352:{depth:.08167,height:.58167,italic:0,skew:0},57353:{depth:0,height:.43056,italic:.04028,skew:0},57356:{depth:.25142,height:.75726,italic:0,skew:0},57357:{depth:.25142,height:.75726,italic:0,skew:0},57358:{depth:.41951,height:.91951,italic:0,skew:0},57359:{depth:.30274,height:.79383,italic:0,skew:0},57360:{depth:.30274,height:.79383,italic:0,skew:0},57361:{depth:.41951,height:.91951,italic:0,skew:0},57366:{depth:.25142,height:.75726,italic:0,skew:0},57367:{depth:.25142,height:.75726,italic:0,skew:0},57368:{depth:.
|
||
|
var G=function(e,t){return N[t][e.charCodeAt(0)]};t.exports={metrics:_,getCharacterMetrics:G}},{}],12:[function(e,t,i){var h=e("./utils");var a=e("./ParseError");var l={"\\sqrt":{numArgs:1,handler:function(e,t){return{type:"sqrt",body: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,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,argTypes:["size","size"],handler:function(e,t,i){return{type:"rule",width:t.value,height:i.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 p=["(",")","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\\lceil","\\rceil","<",">","\\langle","\\rangle","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."];var r=[{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"],data:{numArgs:2,greediness:2,handler:function(e,t,i){return{type:"frac",numer:t,denom:i,size:e.slice(1)}}}},{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(p,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","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],data:{numArgs:0}},{funcs:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],data:{numArgs:0}},{funcs:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot"],data:{numArgs:1,handler:function(e,t){return{type:"accent",accent:e,base:t}}}}];var c=function(e,t){for(var i=0;i<e.length;i++){l[e[i]]=t}};for(var g=0;g<r.length;g++){c(r[g].funcs,r[g].data)}var d=function(e){if(l[e].greediness===undefined){return 1}else{return l[e].g
|