From bc3f4a79d52e0f62b93628fd8b35516eb6c4f44b Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 28 May 2018 19:02:53 +0200 Subject: Add Nix derivation for KaTeX One step closer to a fully declarative website build environment. --- InputXSLT.nix | 18 ----------------- pkgs/InputXSLT.nix | 20 +++++++++++++++++++ pkgs/KaTeX.nix | 50 ++++++++++++++++++++++++++++++++++++++++++++++ shell.nix | 5 +++-- utility/formatter.xsl | 2 +- utility/katex/katex.min.js | 1 - utility/katex/wrapper | 16 --------------- 7 files changed, 74 insertions(+), 38 deletions(-) delete mode 100644 InputXSLT.nix create mode 100644 pkgs/InputXSLT.nix create mode 100644 pkgs/KaTeX.nix delete mode 100644 utility/katex/katex.min.js delete mode 100755 utility/katex/wrapper diff --git a/InputXSLT.nix b/InputXSLT.nix deleted file mode 100644 index 6c1f473..0000000 --- a/InputXSLT.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ stdenv, fetchFromGitHub, cmake, boost, xalanc, xercesc, discount }: - -stdenv.mkDerivation rec { - name = "InputXSLT"; - - src = fetchFromGitHub { - owner = "KnairdA"; - repo = "InputXSLT"; - rev = "master"; - sha256 = "1j9fld3sh1jyscnsx6ab9jn5x6q67rjh9p3bgsh5na1qrs40dql0"; - }; - - buildInputs = [ cmake boost xalanc xercesc discount ]; - - meta = with stdenv.lib; { - homepage = https://github.com/KnairdA/InputXSLT/; - }; -} diff --git a/pkgs/InputXSLT.nix b/pkgs/InputXSLT.nix new file mode 100644 index 0000000..a85bc37 --- /dev/null +++ b/pkgs/InputXSLT.nix @@ -0,0 +1,20 @@ +{ stdenv, fetchFromGitHub, cmake, boost, xalanc, xercesc, discount }: + +stdenv.mkDerivation rec { + name = "InputXSLT"; + + src = fetchFromGitHub { + owner = "KnairdA"; + repo = "InputXSLT"; + rev = "master"; + sha256 = "1j9fld3sh1jyscnsx6ab9jn5x6q67rjh9p3bgsh5na1qrs40dql0"; + }; + + buildInputs = [ cmake boost xalanc xercesc discount ]; + + meta = with stdenv.lib; { + description = "InputXSLT"; + homepage = https://github.com/KnairdA/InputXSLT/; + license = stdenv.lib.licenses.asl20; + }; +} diff --git a/pkgs/KaTeX.nix b/pkgs/KaTeX.nix new file mode 100644 index 0000000..6565b13 --- /dev/null +++ b/pkgs/KaTeX.nix @@ -0,0 +1,50 @@ +{ stdenv, pkgs, ... }: + +let + katex-src = stdenv.mkDerivation rec { + name = "katex-src"; + + src = pkgs.fetchzip { + url = "https://github.com/Khan/KaTeX/releases/download/v0.10.0-alpha/katex.zip"; + sha256 = "002dzyf3wcyjxv4m6vv0v99gf82a9k7rxsnlvf93h9fhcda2vj7l"; + }; + + buildInputs = [ pkgs.nodejs ]; + + installPhase = '' + mkdir -p $out/share/katex + + cp katex.min.js $out/share/katex/ + ''; + + meta = { + description = "KaTeX"; + homepage = https://github.com/Khan/KaTeX; + license = stdenv.lib.licenses.mit; + platforms = stdenv.lib.platforms.all; + }; + }; +in pkgs.writeTextFile { + name = "katex-wrapper"; + executable = true; + destination = "/bin/katex"; + + text = '' + #!${pkgs.nodejs}/bin/node + + var katex = require("${katex-src}/share/katex/katex.min.js"); + var input = ""; + + var args = process.argv.slice(2); + + process.stdin.on("data", function(chunk) { + input += chunk.toString(); + }); + + process.stdin.on("end", function() { + var options = { displayMode: args.indexOf("--display-mode") !== -1 }; + var output = katex.renderToString(input, options); + console.log(output); + }); + ''; +} diff --git a/shell.nix b/shell.nix index bd65829..706a893 100644 --- a/shell.nix +++ b/shell.nix @@ -4,12 +4,13 @@ stdenv.mkDerivation rec { name = "env"; env = buildEnv { name = name; paths = buildInputs; }; buildInputs = let - InputXSLT = callPackage ./InputXSLT.nix {}; + InputXSLT = callPackage ./pkgs/InputXSLT.nix {}; + KaTeX = callPackage ./pkgs/KaTeX.nix {}; in [ InputXSLT pandoc highlight - nodejs + KaTeX python3 ]; } diff --git a/utility/formatter.xsl b/utility/formatter.xsl index 9198f36..606a764 100644 --- a/utility/formatter.xsl +++ b/utility/formatter.xsl @@ -25,7 +25,7 @@ - ./utility/katex/wrapper + katex diff --git a/utility/katex/katex.min.js b/utility/katex/katex.min.js deleted file mode 100644 index d574cc3..0000000 --- a/utility/katex/katex.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.katex=t():e.katex=t()}(this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=79)}([function(e,t,r){"use strict";var n=r(31),a=r.n(n),i=r(70),o=r.n(i),s=r(13),l=r(36),u=r(28),c=r(8),h=r(141),p=r(21),m=["\\imath","\u0131","\\jmath","\u0237","\\pounds","\\mathsterling","\\textsterling","\xa3"],f=function(e,t,r){return u.a[r][e]&&u.a[r][e].replace&&(e=u.a[r][e].replace),{value:e,metrics:l.a.getCharacterMetrics(e,t,r)}},d=function(e,t,r,n,a){var i=f(e,t,r),o=i.metrics;e=i.value;var l=void 0;if(o){var u=o.italic;"text"===r&&(u=0),l=new s.a.symbolNode(e,o.height,o.depth,u,o.skew,o.width,a)}else"undefined"!=typeof console&&console.warn("No character metrics for '"+e+"' in style '"+t+"'"),l=new s.a.symbolNode(e,0,0,0,0,0,a);if(n){l.maxFontSize=n.sizeMultiplier,n.style.isTight()&&l.classes.push("mtight");var c=n.getColor();c&&(l.style.color=c)}return l},v=function(e,t,r,n,a){if("mathord"===a){var i=g(e,t,r,n);return d(e,i.fontName,t,r,n.concat([i.fontClass]))}if("textord"===a){if("ams"===(u.a[t][e]&&u.a[t][e].font)){var o=w("amsrm",r.fontWeight,r.fontShape);return d(e,o,t,r,n.concat("amsrm",r.fontWeight,r.fontShape))}var s=w("textrm",r.fontWeight,r.fontShape);return d(e,s,t,r,n.concat(r.fontWeight,r.fontShape))}throw new Error("unexpected type: "+a+" in mathDefault")},g=function(e,t,r,n){return/[0-9]/.test(e.charAt(0))||c.a.contains(m,e)?{fontName:"Main-Italic",fontClass:"mainit"}:{fontName:"Math-Italic",fontClass:"mathit"}},b=function(e){var t=0,r=0,n=0,i=!0,o=!1,s=void 0;try{for(var l,u=a()(e.children);!(i=(l=u.next()).done);i=!0){var c=l.value;c.height>t&&(t=c.height),c.depth>r&&(r=c.depth),c.maxFontSize>n&&(n=c.maxFontSize)}}catch(e){o=!0,s=e}finally{try{!i&&u.return&&u.return()}finally{if(o)throw s}}e.height=t,e.depth=r,e.maxFontSize=n},y=function(e,t,r,n){var a=new s.a.span(e,t,r,n);return b(a),a},x=function(e,t,r,n){return new s.a.span(e,t,r,n)},w=function(e,t,r){var n="";switch(e){case"amsrm":n="AMS";break;case"textrm":n="Main";break;case"textsf":n="SansSerif";break;case"texttt":n="Typewriter";break;default:throw new Error("Invalid font provided: "+e)}return n+"-"+("textbf"===t&&"textit"===r?"BoldItalic":"textbf"===t?"Bold":"textit"===t?"Italic":"Regular")},k={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},S={vec:["vec",.471,.714]};t.a={fontMap:k,makeSymbol:d,mathsym:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return r&&r.font&&"boldsymbol"===r.font&&f(e,"Main-Bold",t).metrics?d(e,"Main-Bold",t,r,n.concat(["mathbf"])):"\\"===e||"main"===u.a[t][e].font?d(e,"Main-Regular",t,r,n):d(e,"AMS-Regular",t,r,n.concat(["amsrm"]))},makeSpan:y,makeSvgSpan:x,makeLineSpan:function(e,t,r){var n=y([e],[],t);return n.height=r||t.fontMetrics().defaultRuleThickness,n.style.borderBottomWidth=n.height+"em",n.maxFontSize=1,n},makeAnchor:function(e,t,r,n){var a=new s.a.anchor(e,t,r,n);return b(a),a},makeFragment:function(e){var t=new s.a.documentFragment(e);return b(t),t},makeVList:function(e,t){var r=function(e){if("individualShift"===e.positionType){for(var t=e.children,r=[t[0]],n=-t[0].shift-t[0].elem.depth,i=n,o=1;o"}},{key:"toText",value:function(){return"mspace"===this.type?"0.16667em"===this.attributes.width?"\u2006":" ":this.children.map(function(e){return e.toText()}).join("")}}]),e}(),h=function(){function e(t){o()(this,e),this.text=t}return l()(e,[{key:"toNode",value:function(){return document.createTextNode(this.text)}},{key:"toMarkup",value:function(){return u.a.escape(this.text)}},{key:"toText",value:function(){return this.text}}]),e}();t.a={MathNode:c,TextNode:h}},function(e,t,r){"use strict";r.d(t,"e",function(){return h}),r.d(t,"f",function(){return p}),r.d(t,"d",function(){return f}),r.d(t,"a",function(){return v}),r.d(t,"b",function(){return g}),t.c=function(e,t,r){var a=v(e,r),o=void 0;o=1===a.length&&u.a.contains(["mrow","mtable"],a[0].type)?a[0]:new i.a.MathNode("mrow",a);var s=new i.a.MathNode("annotation",[new i.a.TextNode(t)]);s.setAttribute("encoding","application/x-tex");var l=new i.a.MathNode("semantics",[o,s]),c=new i.a.MathNode("math",[l]);return n.a.makeSpan(["katex-mathml"],[c])};var n=r(0),a=r(36),i=r(2),o=r(5),s=r(12),l=r(28),u=r(8),c=r(32),h=function(e,t){return l.a[t][e]&&l.a[t][e].replace&&55349!==e.charCodeAt(0)&&(e=l.a[t][e].replace),new i.a.TextNode(e)},p=function(e,t){for(var r=[],n=null,a=0;a2&&void 0!==arguments[2]&&arguments[2];if(!e)return new i.a.MathNode("mrow");if(f[e.type]){var n=f[e.type](e,t);return r&&"mrow"===n.type&&1===n.children.length?n.children[0]:n}throw new o.a("Got group of unknown type: '"+e.type+"'")}},function(e,t,r){"use strict";r.d(t,"a",function(){return g}),r.d(t,"e",function(){return w}),r.d(t,"d",function(){return k}),r.d(t,"b",function(){return S}),t.c=function(e,t){var r=null;1===(e=JSON.parse(a()(e))).length&&"tag"===e[0].type&&(r=e[0].value.tag,e=e[0].value.body);for(var n=g(e,t,!0),i=[],o=[],s=0;s0&&(i.push(M(o,t)),o=[]),i.push(n[s]));o.length>0&&i.push(M(o,t));var u=void 0;r&&((u=M(g(r,t,!0))).classes=["tag"],i.push(u));var c=d(["katex-html"],i);if(c.setAttribute("aria-hidden","true"),r){var h=u.children[0];h.style.height=c.height+c.depth+"em",h.style.verticalAlign=-c.depth+"em"}return c};var n=r(90),a=r.n(n),i=r(42),o=r.n(i),s=r(5),l=r(12),u=r(0),c=r(13),h=r(21),p=r(8),m=r(32),f=r(142),d=u.a.makeSpan,v={display:l.a.DISPLAY,text:l.a.TEXT,script:l.a.SCRIPT,scriptscript:l.a.SCRIPTSCRIPT},g=function(e,t,r){for(var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[null,null],a=[],i=0;i1&&void 0!==arguments[1]?arguments[1]:"right";if((t instanceof c.a.documentFragment||t instanceof c.a.anchor)&&t.children.length){if("right"===r)return e(t.children[t.children.length-1]);if("left"===r)return e(t.children[0])}return t},y=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"right";return e?(e=b(e,t),p.a.contains(["mord","mop","mbin","mrel","mopen","mclose","mpunct","minner"],e.classes[0])?e.classes[0]:null):null},x=function(e){return(e=b(e,"left")).hasClass("mtight")},w=function(e,t){var r=["nulldelimiter"].concat(e.baseSizingClasses());return d(t.concat(r))},k={mathord:function(e,t){return u.a.makeOrd(e,t,"mathord")},textord:function(e,t){return u.a.makeOrd(e,t,"textord")},bin:function(e,t){return u.a.mathsym(e.value,e.mode,t,["mbin"])},rel:function(e,t){return u.a.mathsym(e.value,e.mode,t,["mrel"])},open:function(e,t){return u.a.mathsym(e.value,e.mode,t,["mopen"])},close:function(e,t){return u.a.mathsym(e.value,e.mode,t,["mclose"])},inner:function(e,t){return u.a.mathsym(e.value,e.mode,t,["minner"])},punct:function(e,t){return u.a.mathsym(e.value,e.mode,t,["mpunct"])},ordgroup:function(e,t){return d(["mord"],g(e.value,t,!0),t)},supsub:function(e,t){if(n=t,(a=(r=e).value.base)&&("op"===a.type?a.value.limits&&(n.style.size===l.a.DISPLAY.size||a.value.alwaysHandleSupSub):"accent"===a.type?p.a.isCharacterBox(a.value.base):"horizBrace"===a.type&&!r.value.sub===a.value.isOver))return k[e.value.base.type](e,t);var r,n,a,i=S(e.value.base,t),o=void 0,s=void 0,h=t.fontMetrics(),m=void 0,f=0,v=0;e.value.sup&&(m=t.havingStyle(t.style.sup()),o=S(e.value.sup,m,t),p.a.isCharacterBox(e.value.base)||(f=i.height-m.fontMetrics().supDrop*m.sizeMultiplier/t.sizeMultiplier)),e.value.sub&&(m=t.havingStyle(t.style.sub()),s=S(e.value.sub,m,t),p.a.isCharacterBox(e.value.base)||(v=i.depth+m.fontMetrics().subDrop*m.sizeMultiplier/t.sizeMultiplier));var g=void 0;g=t.style===l.a.DISPLAY?h.sup1:t.style.cramped?h.sup3:h.sup2;var b=t.sizeMultiplier,x=.5/h.ptPerEm/b+"em",w=void 0;if(e.value.sup)if(e.value.sub){f=Math.max(f,g,o.depth+.25*h.xHeight),v=Math.max(v,h.sub2);var M=4*h.defaultRuleThickness;if(f-o.depth-(s.height-v)0&&(f+=z,v-=z)}var T=[{type:"elem",elem:s,shift:v,marginRight:x},{type:"elem",elem:o,shift:-f,marginRight:x}];i instanceof c.a.symbolNode&&(T[0].marginLeft=-i.italic+"em"),w=u.a.makeVList({positionType:"individualShift",children:T},t)}else f=Math.max(f,g,o.depth+.25*h.xHeight),w=u.a.makeVList({positionType:"shift",positionData:-f,children:[{type:"elem",elem:o,marginRight:x}]},t);else{v=Math.max(v,h.sub1,s.height-.8*h.xHeight);var O=[{type:"elem",elem:s,marginRight:x}];i instanceof c.a.symbolNode&&(O[0].marginLeft=-i.italic+"em"),w=u.a.makeVList({positionType:"shift",positionData:v,children:O},t)}var A=y(i)||"mord";return d([A],[i,d(["msupsub"],[w])],t)},spacing:function(e,t){if(u.a.regularSpace.hasOwnProperty(e.value)){var r=u.a.regularSpace[e.value].className;if("text"===e.mode){var n=u.a.makeOrd(e,t,"textord");return n.classes.push(r),n}return d(["mspace",r],[u.a.mathsym(e.value,e.mode,t)],t)}return d(["mspace",u.a.spacingFunctions[e.value].className],[],t)},horizBrace:function(e,t){var r=t.style,n="supsub"===e.type,a=void 0,i=void 0;n&&(e.value.sup?(i=t.havingStyle(r.sup()),a=S(e.value.sup,i,t)):(i=t.havingStyle(r.sub()),a=S(e.value.sub,i,t)),e=e.value.base);var o=S(e.value.base,t.havingBaseStyle(l.a.DISPLAY)),s=m.a.svgSpan(e,t),c=void 0;if(e.value.isOver?(c=u.a.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:o},{type:"kern",size:.1},{type:"elem",elem:s}]},t)).children[0].children[0].children[1].classes.push("svg-align"):(c=u.a.makeVList({positionType:"bottom",positionData:o.depth+.1+s.height,children:[{type:"elem",elem:s},{type:"kern",size:.1},{type:"elem",elem:o}]},t)).children[0].children[0].children[0].classes.push("svg-align"),n){var h=d(["mord",e.value.isOver?"mover":"munder"],[c],t);c=e.value.isOver?u.a.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:h},{type:"kern",size:.2},{type:"elem",elem:a}]},t):u.a.makeVList({positionType:"bottom",positionData:h.depth+.2+a.height+a.depth,children:[{type:"elem",elem:a},{type:"kern",size:.2},{type:"elem",elem:h}]},t)}return d(["mord",e.value.isOver?"mover":"munder"],[c],t)},xArrow:function(e,t){var r=t.style,n=t.havingStyle(r.sup()),a=S(e.value.body,n,t);a.classes.push("x-arrow-pad");var i=void 0;e.value.below&&(n=t.havingStyle(r.sub()),(i=S(e.value.below,n,t)).classes.push("x-arrow-pad"));var o=m.a.svgSpan(e,t),s=-t.fontMetrics().axisHeight+.5*o.height,l=-t.fontMetrics().axisHeight-.5*o.height-.111;(a.depth>.25||"\\xleftequilibrium"===e.value.label)&&(l-=a.depth);var c=void 0;if(e.value.below){var h=-t.fontMetrics().axisHeight+i.height+.5*o.height+.111;c=u.a.makeVList({positionType:"individualShift",children:[{type:"elem",elem:a,shift:l},{type:"elem",elem:o,shift:s},{type:"elem",elem:i,shift:h}]},t)}else c=u.a.makeVList({positionType:"individualShift",children:[{type:"elem",elem:a,shift:l},{type:"elem",elem:o,shift:s}]},t);return c.children[0].children[0].children[1].classes.push("svg-align"),d(["mrel","x-arrow"],[c],t)},raisebox:function(e,t){var r=k.sizing({value:{value:[{type:"text",value:{body:e.value.value,font:"mathrm"}}],size:6}},t),n=Object(h.a)(e.value.dy.value,t);return u.a.makeVList({positionType:"shift",positionData:-n,children:[{type:"elem",elem:r}]},t)}},S=function(e,t,r){if(!e)return d();if(k[e.type]){var n=k[e.type](e,t);if(r&&t.size!==r.size){n=d(t.sizingClasses(r),[n],t);var a=t.sizeMultiplier/r.sizeMultiplier;n.height*=a,n.depth*=a}return n}throw new s.a("Got group of unknown type: '"+e.type+"'")};function M(e,t){var r=d(["base"],e,t),n=d(["strut"]);return n.style.height=r.height+r.depth+"em",n.style.verticalAlign=-r.depth+"em",r.children.unshift(n),r}},function(e,t,r){"use strict";var n=r(9),a=r.n(n),i=(r(6),r(25),function e(t,r){a()(this,e);var n="KaTeX parse error: "+t,i=void 0,o=r&&r.loc;if(o&&o.start<=o.end){var s=o.lexer.input;i=o.start;var l=o.end;i===s.length?n+=" at end of input: ":n+=" at position "+(i+1)+": ";var u=s.slice(i,l).replace(/[^]/g,"$&\u0332");n+=(i>15?"\u2026"+s.slice(i-15,i):s.slice(0,i))+u+(l+15":">","<":"<",'"':""","'":"'"},s=/[&><"']/g;var l=void 0;if("undefined"!=typeof document){var u=document.createElement("span");l="textContent"in u?function(e,t){e.textContent=t}:function(e,t){e.innerText=t}}var c=function e(t){return!!t&&("ordgroup"===t.type?1===t.value.length?e(t.value[0]):t:"color"===t.type?1===t.value.value.length?e(t.value.value[0]):t:"font"===t.type?e(t.value.body):t)};t.a={contains:function(e,t){return-1!==a(e,t)},deflt:function(e,t){return void 0===e?t:e},escape:function(e){return String(e).replace(s,function(e){return o[e]})},hyphenate:function(e){return e.replace(i,"-$1").toLowerCase()},indexOf:a,setTextContent:l,clearNode:function(e){l(e,"")},getBaseElem:c,isCharacterBox:function(e){var t=c(e);return"mathord"===t.type||"textord"===t.type||"bin"===t.type||"rel"===t.type||"inner"===t.type||"open"===t.type||"close"===t.type||"punct"===t.type}}},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t,r){var n=r(49)("wks"),a=r(33),i=r(15).Symbol,o="function"==typeof i;(e.exports=function(e){return n[e]||(n[e]=o&&i[e]||(o?i:a)("Symbol."+e))}).store=n},function(e,t,r){"use strict";t.__esModule=!0;var n,a=r(86),i=(n=a)&&n.__esModule?n:{default:n};t.default=function(){function e(e,t){for(var r=0;r=2}}]),e}(),l=[new s(0,0,!1),new s(1,0,!0),new s(2,1,!1),new s(3,1,!0),new s(4,2,!1),new s(5,2,!0),new s(6,3,!1),new s(7,3,!0)],u=[4,5,4,5,6,7,6,7],c=[5,5,5,5,7,7,7,7],h=[2,3,4,5,6,7,6,7],p=[3,3,5,5,7,7,7,7],m=[1,1,3,3,5,5,7,7],f=[0,1,2,3,2,3,2,3];t.a={DISPLAY:l[0],TEXT:l[2],SCRIPT:l[4],SCRIPTSCRIPT:l[6]}},function(e,t,r){"use strict";var n=r(113),a=r.n(n),i=r(116),o=r.n(i),s=r(129),l=r.n(s),u=r(74),c=r.n(u),h=r(9),p=r.n(h),m=r(11),f=r.n(m),d=r(56),v=r(8),g=r(140),b=function(e){for(var t=(e=e.slice()).length-1;t>=0;t--)e[t]||e.splice(t,1);return e.join(" ")},y=function(){function e(t,r,n,a){if(p()(this,e),this.classes=t||[],this.children=r||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=c()({},a),n){n.style.isTight()&&this.classes.push("mtight");var i=n.getColor();i&&(this.style.color=i)}}return f()(e,[{key:"setAttribute",value:function(e,t){this.attributes[e]=t}},{key:"hasClass",value:function(e){return v.a.contains(this.classes,e)}},{key:"tryCombine",value:function(e){return!1}},{key:"tagName",value:function(){throw new Error("use of generic HtmlDomContainer tagName")}},{key:"toNode",value:function(){var e=document.createElement(this.tagName());e.className=b(this.classes);for(var t in this.style)Object.prototype.hasOwnProperty.call(this.style,t)&&(e.style[t]=this.style[t]);for(var r in this.attributes)this.attributes.hasOwnProperty(r)&&e.setAttribute(r,this.attributes[r]);for(var n=0;n"}}]),e}(),x=function(e){function t(e,r,n,i){return p()(this,t),o()(this,(t.__proto__||a()(t)).call(this,e,r,n,i))}return l()(t,e),f()(t,[{key:"tagName",value:function(){return"span"}}]),t}(y),w=function(e){function t(e,r,n,i){p()(this,t);var s=o()(this,(t.__proto__||a()(t)).call(this,r,n,i));return s.setAttribute("href",e),s}return l()(t,e),f()(t,[{key:"tagName",value:function(){return"a"}}]),t}(y),k=function(){function e(t){p()(this,e),this.children=t||[],this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0}return f()(e,[{key:"hasClass",value:function(e){return v.a.contains(this.classes,e)}},{key:"tryCombine",value:function(e){return!1}},{key:"toNode",value:function(){for(var e=document.createDocumentFragment(),t=0;t0||b(this.classes)!==b(t.classes)||this.skew!==t.skew||this.maxFontSize!==t.maxFontSize)return!1;for(var r in this.style)if(this.style.hasOwnProperty(r)&&this.style[r]!==t.style[r])return!1;for(var n in t.style)if(t.style.hasOwnProperty(n)&&this.style[n]!==t.style[n])return!1;return this.value+=t.value,this.height=Math.max(this.height,t.height),this.depth=Math.max(this.depth,t.depth),this.italic=t.italic,!0}},{key:"toNode",value:function(){var e=document.createTextNode(this.value),t=null;this.italic>0&&((t=document.createElement("span")).style.marginRight=this.italic+"em"),this.classes.length>0&&((t=t||document.createElement("span")).className=b(this.classes));for(var r in this.style)this.style.hasOwnProperty(r)&&((t=t||document.createElement("span")).style[r]=this.style[r]);return t?(t.appendChild(e),t):e}},{key:"toMarkup",value:function(){var e=!1,t="0&&(r+="margin-right:"+this.italic+"em;");for(var n in this.style)this.style.hasOwnProperty(n)&&(r+=v.a.hyphenate(n)+":"+this.style[n]+";");r&&(e=!0,t+=' style="'+v.a.escape(r)+'"');var a=v.a.escape(this.value);return e?(t+=">",t+=a,t+=""):a}}]),e}(),z=function(){function e(t,r){p()(this,e),this.children=t||[],this.attributes=r||{}}return f()(e,[{key:"toNode",value:function(){var e=document.createElementNS("http://www.w3.org/2000/svg","svg");for(var t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);for(var r=0;r":""}}]),e}(),O=function(){function e(t){p()(this,e),this.attributes=t||{}}return f()(e,[{key:"toNode",value:function(){var e=document.createElementNS("http://www.w3.org/2000/svg","line");for(var t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);return e}},{key:"toMarkup",value:function(){var e="",">"),a(i,s,g,":",":"),a(i,s,g,"\u2248","\\approx",!0),a(i,s,g,"\u2245","\\cong",!0),a(i,s,g,"\u2265","\\ge"),a(i,s,g,"\u2265","\\geq",!0),a(i,s,g,"\u2190","\\gets"),a(i,s,g,">","\\gt"),a(i,s,g,"\u2208","\\in",!0),a(i,s,g,"\u2209","\\notin",!0),a(i,s,g,"\u0338","\\not"),a(i,s,g,"\u2282","\\subset",!0),a(i,s,g,"\u2283","\\supset",!0),a(i,s,g,"\u2286","\\subseteq",!0),a(i,s,g,"\u2287","\\supseteq",!0),a(i,l,g,"\u2288","\\nsubseteq",!0),a(i,l,g,"\u2289","\\nsupseteq",!0),a(i,s,g,"\u22a8","\\models"),a(i,s,g,"\u2190","\\leftarrow",!0),a(i,s,g,"\u2264","\\le"),a(i,s,g,"\u2264","\\leq",!0),a(i,s,g,"<","\\lt"),a(i,s,g,"\u2260","\\ne",!0),a(i,s,g,"\u2260","\\neq"),a(i,s,g,"\u2192","\\rightarrow",!0),a(i,s,g,"\u2192","\\to"),a(i,l,g,"\u2271","\\ngeq",!0),a(i,l,g,"\u2270","\\nleq",!0),a(i,s,b,null,"\\!"),a(i,s,b,"\xa0","\\ "),a(i,s,b,"\xa0","~"),a(i,s,b,null,"\\,"),a(i,s,b,null,"\\:"),a(i,s,b,null,"\\;"),a(i,s,b,null,"\\enspace"),a(i,s,b,null,"\\qquad"),a(i,s,b,null,"\\quad"),a(i,s,b,"\xa0","\\space"),a(i,s,b,"\xa0","\\nobreakspace"),a(o,s,b,null,"\\!"),a(o,s,b,"\xa0","\\ "),a(o,s,b,"\xa0","~"),a(o,s,b,null,"\\,"),a(o,s,b,null,"\\:"),a(o,s,b,null,"\\;"),a(o,s,b,null,"\\enspace"),a(o,s,b,null,"\\qquad"),a(o,s,b,null,"\\quad"),a(o,s,b,"\xa0","\\space"),a(o,s,b,"\xa0","\\nobreakspace"),a(i,s,b,null,"\\nobreak"),a(i,s,b,null,"\\allowbreak"),a(i,s,v,",",","),a(i,s,v,";",";"),a(i,s,v,":","\\colon"),a(i,l,c,"\u22bc","\\barwedge",!0),a(i,l,c,"\u22bb","\\veebar",!0),a(i,s,c,"\u2299","\\odot",!0),a(i,s,c,"\u2295","\\oplus",!0),a(i,s,c,"\u2297","\\otimes",!0),a(i,s,y,"\u2202","\\partial",!0),a(i,s,c,"\u2298","\\oslash",!0),a(i,l,c,"\u229a","\\circledcirc",!0),a(i,l,c,"\u22a1","\\boxdot",!0),a(i,s,c,"\u25b3","\\bigtriangleup"),a(i,s,c,"\u25bd","\\bigtriangledown"),a(i,s,c,"\u2020","\\dagger"),a(i,s,c,"\u22c4","\\diamond"),a(i,s,c,"\u22c6","\\star"),a(i,s,c,"\u25c3","\\triangleleft"),a(i,s,c,"\u25b9","\\triangleright"),a(i,s,d,"{","\\{"),a(o,s,y,"{","\\{"),a(o,s,y,"{","\\textbraceleft"),a(i,s,h,"}","\\}"),a(o,s,y,"}","\\}"),a(o,s,y,"}","\\textbraceright"),a(i,s,d,"{","\\lbrace"),a(i,s,h,"}","\\rbrace"),a(i,s,d,"[","\\lbrack"),a(i,s,h,"]","\\rbrack"),a(o,s,y,"<","\\textless"),a(o,s,y,">","\\textgreater"),a(i,s,d,"\u230a","\\lfloor",!0),a(i,s,h,"\u230b","\\rfloor",!0),a(i,s,d,"\u2308","\\lceil",!0),a(i,s,h,"\u2309","\\rceil",!0),a(i,s,y,"\\","\\backslash"),a(i,s,y,"\u2223","|"),a(i,s,y,"\u2223","\\vert"),a(o,s,y,"|","\\textbar"),a(i,s,y,"\u2225","\\|"),a(i,s,y,"\u2225","\\Vert"),a(o,s,y,"\u2225","\\textbardbl"),a(o,s,y,"~","\\textasciitilde"),a(i,s,g,"\u2191","\\uparrow",!0),a(i,s,g,"\u21d1","\\Uparrow",!0),a(i,s,g,"\u2193","\\downarrow",!0),a(i,s,g,"\u21d3","\\Downarrow",!0),a(i,s,g,"\u2195","\\updownarrow",!0),a(i,s,g,"\u21d5","\\Updownarrow",!0),a(i,s,f,"\u2210","\\coprod"),a(i,s,f,"\u22c1","\\bigvee"),a(i,s,f,"\u22c0","\\bigwedge"),a(i,s,f,"\u2a04","\\biguplus"),a(i,s,f,"\u22c2","\\bigcap"),a(i,s,f,"\u22c3","\\bigcup"),a(i,s,f,"\u222b","\\int"),a(i,s,f,"\u222b","\\intop"),a(i,s,f,"\u222c","\\iint"),a(i,s,f,"\u222d","\\iiint"),a(i,s,f,"\u220f","\\prod"),a(i,s,f,"\u2211","\\sum"),a(i,s,f,"\u2a02","\\bigotimes"),a(i,s,f,"\u2a01","\\bigoplus"),a(i,s,f,"\u2a00","\\bigodot"),a(i,s,f,"\u222e","\\oint"),a(i,s,f,"\u2a06","\\bigsqcup"),a(i,s,f,"\u222b","\\smallint"),a(o,s,p,"\u2026","\\textellipsis"),a(i,s,p,"\u2026","\\mathellipsis"),a(o,s,p,"\u2026","\\ldots",!0),a(i,s,p,"\u2026","\\ldots",!0),a(i,s,p,"\u22ef","\\@cdots",!0),a(i,s,p,"\u22f1","\\ddots",!0),a(i,s,y,"\u22ee","\\vdots",!0),a(i,s,u,"\u02ca","\\acute"),a(i,s,u,"\u02cb","\\grave"),a(i,s,u,"\xa8","\\ddot"),a(i,s,u,"~","\\tilde"),a(i,s,u,"\u02c9","\\bar"),a(i,s,u,"\u02d8","\\breve"),a(i,s,u,"\u02c7","\\check"),a(i,s,u,"^","\\hat"),a(i,s,u,"\u20d7","\\vec"),a(i,s,u,"\u02d9","\\dot"),a(i,s,u,"\u02da","\\mathring"),a(i,s,m,"\u0131","\\imath",!0),a(i,s,m,"\u0237","\\jmath",!0),a(o,s,y,"\u0131","\\i",!0),a(o,s,y,"\u0237","\\j",!0),a(o,s,y,"\xdf","\\ss",!0),a(o,s,y,"\xe6","\\ae",!0),a(o,s,y,"\xe6","\\ae",!0),a(o,s,y,"\u0153","\\oe",!0),a(o,s,y,"\xf8","\\o",!0),a(o,s,y,"\xc6","\\AE",!0),a(o,s,y,"\u0152","\\OE",!0),a(o,s,y,"\xd8","\\O",!0),a(o,s,u,"\u02ca","\\'"),a(o,s,u,"\u02cb","\\`"),a(o,s,u,"\u02c6","\\^"),a(o,s,u,"\u02dc","\\~"),a(o,s,u,"\u02c9","\\="),a(o,s,u,"\u02d8","\\u"),a(o,s,u,"\u02d9","\\."),a(o,s,u,"\u02da","\\r"),a(o,s,u,"\u02c7","\\v"),a(o,s,u,"\xa8",'\\"'),a(o,s,u,"\u02dd","\\H"),a(o,s,u,"\u25ef","\\textcircled"),a(o,s,y,"\u2013","--"),a(o,s,y,"\u2013","\\textendash"),a(o,s,y,"\u2014","---"),a(o,s,y,"\u2014","\\textemdash"),a(o,s,y,"\u2018","`"),a(o,s,y,"\u2018","\\textquoteleft"),a(o,s,y,"\u2019","'"),a(o,s,y,"\u2019","\\textquoteright"),a(o,s,y,"\u201c","``"),a(o,s,y,"\u201c","\\textquotedblleft"),a(o,s,y,"\u201d","''"),a(o,s,y,"\u201d","\\textquotedblright"),a(i,s,y,"\xb0","\\degree",!0),a(o,s,y,"\xb0","\\degree"),a(o,s,y,"\xb0","\\textdegree",!0),a(i,s,m,"\xa3","\\pounds"),a(i,s,m,"\xa3","\\mathsterling",!0),a(o,s,m,"\xa3","\\pounds"),a(o,s,m,"\xa3","\\textsterling",!0),a(i,l,y,"\u2720","\\maltese"),a(o,l,y,"\u2720","\\maltese"),a(o,s,b,"\xa0","\\ "),a(o,s,b,"\xa0"," "),a(o,s,b,"\xa0","~");for(var x='0123456789/@."',w=0;w5)u="widehat"===n?420:312,r="widehat"===n?2364:2340,m="widehat"===n?.42:.34,p=("widehat"===n?"widehat":"tilde")+"4";else{var f=[1,1,2,2,3,3][s];"widehat"===n?(r=[0,1062,2364,2364,2364][f],u=[0,239,300,360,420][f],m=[0,.24,.3,.3,.36,.42][f],p="widehat"+f):(r