Comparing version 0.3.0-beta-2 to 0.3.0-beta-4
@@ -1,19 +0,19 @@ | ||
var B=new Map([["nonumber",""],["vec","arrow"],["neq","eq.not"],["dot","dot"],["ddot","dot.double"],["doteq","dot(eq)"],["dots","dots.h"],["vdots","dots.v"],["ddots","dots.down"],["widehat","hat"],["widetilde","tilde"],["quad","quad"],["qquad","wide"],["overbrace","overbrace"],["underbrace","underbrace"],["overline","overline"],["underline","underline"],["bar","macron"],["dbinom","binom"],["tbinom","binom"],["dfrac","frac"],["tfrac","frac"],["operatorname","op"],["boldsymbol","bold"],["mathbb","bb"],["mathbf","bold"],["mathcal","cal"],["mathit","italic"],["mathfrak","frak"],["mathrm","upright"],["mathsf","sans"],["mathtt","mono"],["rm","upright"],["pmb","bold"],["pm","plus.minus"],["mp","minus.plus"],["boxplus","plus.square"],["otimes","times.circle"],["boxtimes","times.square"],["approx","approx"],["cong","tilde.equiv"],["simeq","tilde.eq"],["asymp","≍"],["equiv","equiv"],["propto","prop"],["gets","arrow.l"],["hookleftarrow","arrow.l.hook"],["leftharpoonup","harpoon.lt"],["leftharpoondown","harpoon.lb"],["rightleftharpoons","harpoons.rtlb"],["longleftarrow","arrow.l.long"],["longrightarrow","arrow.r.long"],["longleftrightarrow","arrow.l.r.long"],["Longleftarrow","arrow.l.double.long"],["Longrightarrow","arrow.r.double.long"],["Longleftrightarrow","arrow.l.r.double.long"],["hookrightarrow","arrow.r.hook"],["rightharpoonup","harpoon.rt"],["rightharpoondown","harpoon.rb"],["iff","arrow.l.r.double.long"],["implies","arrow.r.double.long"],["uparrow","arrow.t"],["downarrow","arrow.b"],["updownarrow","arrow.t.b"],["Uparrow","arrow.t.double"],["Downarrow","arrow.b.double"],["Updownarrow","arrow.t.b.double"],["nearrow","arrow.tr"],["searrow","arrow.br"],["swarrow","arrow.bl"],["nwarrow","arrow.tl"],["leadsto","arrow.squiggly"],["leftleftarrows","arrows.ll"],["rightrightarrows","arrows.rr"],["Cap","sect.double"],["Cup","union.double"],["Delta","Delta"],["Gamma","Gamma"],["Join","join"],["Lambda","Lambda"],["Leftarrow","arrow.l.double"],["Leftrightarrow","arrow.l.r.double"],["Longrightarrow","arrow.r.double.long"],["Omega","Omega"],["P","pilcrow"],["Phi","Phi"],["Pi","Pi"],["Psi","Psi"],["Rightarrow","arrow.r.double"],["S","section"],["Sigma","Sigma"],["Theta","Theta"],["aleph","alef"],["alpha","alpha"],["angle","angle"],["approx","approx"],["approxeq","approx.eq"],["beta","beta"],["bigcap","sect.big"],["bigcirc","circle.big"],["bigcup","union.big"],["bigodot","dot.circle.big"],["bigotimes","times.circle.big"],["bigsqcup","union.sq.big"],["biguplus","union.plus.big"],["bigvee","or.big"],["bigwedge","and.big"],["bullet","bullet"],["cap","sect"],["cdot","dot.op"],["cdots","dots.c"],["checkmark","checkmark"],["chi","chi"],["circ","circle.small"],["colon","colon"],["cong","tilde.equiv"],["coprod","product.co"],["copyright","copyright"],["cup","union"],["curlyvee","or.curly"],["curlywedge","and.curly"],["dagger","dagger"],["dashv","tack.l"],["ddagger","dagger.double"],["delta","delta"],["ddots","dots.down"],["diamond","diamond"],["div","div"],["divideontimes","times.div"],["dotplus","plus.dot"],["downarrow","arrow.b"],["ell","ell"],["emptyset","nothing"],["epsilon","epsilon.alt"],["equiv","equiv"],["eta","eta"],["exists","exists"],["forall","forall"],["gamma","gamma"],["ge","gt.eq"],["geq","gt.eq"],["geqslant","gt.eq.slant"],["gg","gt.double"],["hbar","planck.reduce"],["imath","dotless.i"],["iiiint","integral.quad"],["iiint","integral.triple"],["iint","integral.double"],["in","in"],["infty","infinity"],["int","integral"],["intercal","top"],["iota","iota"],["jmath","dotless.j"],["kappa","kappa"],["lambda","lambda"],["land","and"],["langle","angle.l"],["lbrace","brace.l"],["lbrack","bracket.l"],["ldots","dots.h"],["le","lt.eq"],["leadsto","arrow.squiggly"],["leftarrow","arrow.l"],["leftthreetimes","times.three.l"],["leftrightarrow","arrow.l.r"],["leq","lt.eq"],["leqslant","lt.eq.slant"],["lhd","triangle.l"],["ll","lt.double"],["lor","or"],["ltimes","times.l"],["measuredangle","angle.arc"],["mid","divides"],["models","models"],["mp","minus.plus"],["mu","mu"],["nabla","nabla"],["ncong","tilde.equiv.not"],["ne","eq.not"],["neg","not"],["neq","eq.not"],["nexists","exists.not"],["ni","in.rev"],["nleftarrow","arrow.l.not"],["nleq","lt.eq.not"],["nparallel","parallel.not"],["ngeq","gt.eq.not"],["nmid","divides.not"],["notin","in.not"],["nsim","tilde.not"],["nsubseteq","subset.eq.not"],["nu","nu"],["ntriangleleft","lt.tri.not"],["ntriangleright","gt.tri.not"],["nwarrow","arrow.tl"],["odot","dot.circle"],["oint","integral.cont"],["oiint","integral.surf"],["oiiint","integral.vol"],["omega","omega"],["ominus","minus.circle"],["otimes","times.circle"],["parallel","parallel"],["partial","diff"],["perp","perp"],["phi","phi.alt"],["pi","pi"],["pm","plus.minus"],["pounds","pound"],["prec","prec"],["preceq","prec.eq"],["prime","prime"],["prod","product"],["propto","prop"],["psi","psi"],["rangle","angle.r"],["rbrace","brace.r"],["rbrack","bracket.r"],["rhd","triangle"],["rho","rho"],["rightarrow","arrow.r"],["rightthreetimes","times.three.r"],["rtimes","times.r"],["setminus","without"],["sigma","sigma"],["sim","tilde.op"],["simeq","tilde.eq"],["slash","slash"],["smallsetminus","without"],["spadesuit","suit.spade"],["sqcap","sect.sq"],["sqcup","union.sq"],["sqsubseteq","subset.eq.sq"],["sqsupseteq","supset.eq.sq"],["subset","subset"],["subseteq","subset.eq"],["subsetneq","subset.neq"],["succ","succ"],["succeq","succ.eq"],["sum","sum"],["supset","supset"],["supseteq","supset.eq"],["supsetneq","supset.neq"],["swarrow","arrow.bl"],["tau","tau"],["theta","theta"],["times","times"],["to","arrow.r"],["top","top"],["triangle","triangle.t"],["twoheadrightarrow","arrow.r.twohead"],["uparrow","arrow.t"],["updownarrow","arrow.t.b"],["upharpoonright","harpoon.tr"],["uplus","union.plus"],["upsilon","upsilon"],["varepsilon","epsilon"],["varnothing","diameter"],["varphi","phi"],["varpi","pi.alt"],["varrho","rho.alt"],["varsigma","sigma.alt"],["vartheta","theta.alt"],["vdash","tack.r"],["vdots","dots.v"],["vee","or"],["wedge","and"],["wr","wreath"],["xi","xi"],["yen","yen"],["zeta","zeta"],["mathscr","scr"],["LaTeX","#LaTeX"],["TeX","#TeX"]]),D2=new Map([["lparen","paren.l"],["lParen","paren.l.double"],["rparen","paren.r"],["rParen","paren.r.double"],["overparen","paren.t"],["underparen","paren.b"],["lbrace","brace.l"],["lBrace","brace.l.double"],["rbrace","brace.r"],["rBrace","brace.r.double"],["underbrace","brace.b"],["lbrack","bracket.l"],["lBrack","bracket.l.double"],["rbrack","bracket.r"],["rBrack","bracket.r.double"],["overbracket","bracket.t"],["underbracket","bracket.b"],["lbrbrak","shell.l"],["Lbrbrak","shell.l.double"],["rbrbrak","shell.r"],["Rbrbrak","shell.r.double"],["obrbrak","shell.t"],["ubrbrak","shell.b"],["vert","bar.v"],["Vert","bar.v.double"],["Vvert","bar.v.triple"],["circledvert","bar.v.circle"],["horizbar","bar.h"],["lvzigzag","fence.l"],["Lvzigzag","fence.l.double"],["rvzigzag","fence.r"],["Rvzigzag","fence.r.double"],["fourvdots","fence.dotted"],["angle","angle"],["langle","angle.l"],["lcurvyangle","angle.l.curly"],["langledot","angle.l.dot"],["rangle","angle.r"],["rcurvyangle","angle.r.curly"],["rangledot","angle.r.dot"],["angdnr","angle.acute"],["measuredangle","angle.arc"],["measuredangleleft","angle.arc.rev"],["wideangledown","angle.oblique"],["revangle","angle.rev"],["rightangle","angle.right"],["measuredrightangle","angle.right.arc"],["rightanglemdot","angle.right.dot"],["rightanglesqr","angle.right.sq"],["angles","angle.s"],["threedangle","angle.spatial"],["sphericalangle","angle.spheric"],["gtlpar","angle.spheric.rev"],["sphericalangleup","angle.spheric.top"],["lceil","ceil.l"],["rceil","ceil.r"],["lfloor","floor.l"],["rfloor","floor.r"],["mathampersand","amp"],["upand","amp.inv"],["ast","ast.op"],["circledast","ast.circle"],["boxast","ast.square"],["mathatsign","at"],["backslash","backslash"],["obslash","backslash.circle"],["rsolbar","backslash.not"],["mathcolon","colon"],["Colon","colon.double"],["coloneq","colon.eq"],["Coloneq","colon.double.eq"],["mathcomma","comma"],["dagger","dagger"],["ddagger","dagger.double"],["dashcolon","dash.colon"],["circleddash","dash.circle"],["hzigzag","dash.wave.double"],["cdot","dot.op"],["mathperiod","dot.basic"],["cdotp","dot.c"],["odot","dot.circle"],["bigodot","dot.circle.big"],["boxdot","dot.square"],["dddot","dot.triple"],["ddddot","dot.quad"],["mathexclam","excl"],["Exclam","excl.double"],["mathquestion","quest"],["Question","quest.double"],["mathoctothorpe","hash"],["mathhyphen","hyph"],["mathpercent","percent"],["mathparagraph","pilcrow"],["mathsection","section"],["mathsemicolon","semi"],["mathslash","slash"],["sslash","slash.double"],["trslash","slash.triple"],["xsol","slash.big"],["unicodecdots","dots.h.c"],["unicodeellipsis","dots.h"],["vdots","dots.v"],["ddots","dots.down"],["adots","dots.up"],["sim","tilde.op"],["dotsim","tilde.dot"],["sime","tilde.eq"],["nsimeq","tilde.eq.not"],["backsimeq","tilde.eq.rev"],["cong","tilde.equiv"],["ncong","tilde.equiv.not"],["simneqq","tilde.nequiv"],["nsim","tilde.not"],["backsim","tilde.rev"],["backcong","tilde.rev.equiv"],["approxident","tilde.triple"],["caretinsert","caret"],["prime","prime"],["backprime","prime.rev"],["dprime","prime.double"],["backdprime","prime.double.rev"],["trprime","prime.triple"],["backtrprime","prime.triple.rev"],["qprime","prime.quad"],["mathplus","plus"],["oplus","plus.circle"],["rightarrowonoplus","plus.circle.arrow"],["bigoplus","plus.circle.big"],["dotplus","plus.dot"],["doubleplus","plus.double"],["pm","plus.minus"],["boxplus","plus.square"],["triangleplus","plus.triangle"],["tripleplus","plus.triple"],["minus","minus"],["ominus","minus.circle"],["dotminus","minus.dot"],["mp","minus.plus"],["boxminus","minus.square"],["eqsim","minus.tilde"],["triangleminus","minus.triangle"],["div","div"],["odiv","div.circle"],["times","times"],["bigtimes","times.big"],["otimes","times.circle"],["bigotimes","times.circle.big"],["divideontimes","times.div"],["leftthreetimes","times.three.l"],["rightthreetimes","times.three.r"],["ltimes","times.l"],["rtimes","times.r"],["boxtimes","times.square"],["triangletimes","times.triangle"],["mathratio","ratio"],["equal","eq"],["stareq","eq.star"],["circledequal","eq.circle"],["eqcolon","eq.colon"],["eqdef","eq.def"],["triangleq","eq.delta"],["veeeq","eq.equi"],["wedgeq","eq.est"],["eqgtr","eq.gt"],["eqless","eq.lt"],["measeq","eq.m"],["ne","eq.not"],["curlyeqprec","eq.prec"],["questeq","eq.quest"],["curlyeqsucc","eq.succ"],["equiv","eq.triple"],["Equiv","eq.quad"],["greater","gt"],["ogreaterthan","gt.circle"],["gtrdot","gt.dot"],["gtrapprox","gt.approx"],["gg","gt.double"],["geq","gt.eq"],["geqslant","gt.eq.slant"],["gtreqless","gt.eq.lt"],["ngeq","gt.eq.not"],["geqq","gt.equiv"],["gtrless","gt.lt"],["ngtrless","gt.lt.not"],["gneq","gt.neq"],["gnapprox","gt.napprox"],["gneqq","gt.nequiv"],["ngtr","gt.not"],["gnsim","gt.ntilde"],["gtrsim","gt.tilde"],["ngtrsim","gt.tilde.not"],["vartriangleright","gt.tri"],["trianglerighteq","gt.tri.eq"],["ntrianglerighteq","gt.tri.eq.not"],["nvartriangleright","gt.tri.not"],["ggg","gt.triple"],["gggnest","gt.triple.nested"],["less","lt"],["olessthan","lt.circle"],["lessdot","lt.dot"],["lessapprox","lt.approx"],["ll","lt.double"],["leq","lt.eq"],["leqslant","lt.eq.slant"],["lesseqgtr","lt.eq.gt"],["nleq","lt.eq.not"],["leqq","lt.equiv"],["lessgtr","lt.gt"],["nlessgtr","lt.gt.not"],["lneq","lt.neq"],["lnapprox","lt.napprox"],["lneqq","lt.nequiv"],["nless","lt.not"],["lnsim","lt.ntilde"],["lesssim","lt.tilde"],["nlesssim","lt.tilde.not"],["vartriangleleft","lt.tri"],["trianglelefteq","lt.tri.eq"],["ntrianglelefteq","lt.tri.eq.not"],["nvartriangleleft","lt.tri.not"],["lll","lt.triple"],["lllnest","lt.triple.nested"],["approx","approx"],["approxeq","approx.eq"],["napprox","approx.not"],["prec","prec"],["precapprox","prec.approx"],["preccurlyeq","prec.curly.eq"],["npreccurlyeq","prec.curly.eq.not"],["Prec","prec.double"],["preceq","prec.eq"],["preceqq","prec.equiv"],["precnapprox","prec.napprox"],["precneq","prec.neq"],["precneqq","prec.nequiv"],["nprec","prec.not"],["precnsim","prec.ntilde"],["precsim","prec.tilde"],["succ","succ"],["succapprox","succ.approx"],["succcurlyeq","succ.curly.eq"],["nsucccurlyeq","succ.curly.eq.not"],["Succ","succ.double"],["succeq","succ.eq"],["succeqq","succ.equiv"],["succnapprox","succ.napprox"],["succneq","succ.neq"],["succneqq","succ.nequiv"],["nsucc","succ.not"],["succnsim","succ.ntilde"],["succsim","succ.tilde"],["nequiv","equiv.not"],["propto","prop"],["origof","original"],["imageof","image"],["varnothing","emptyset"],["emptysetoarr","emptyset.arrow.r"],["emptysetoarrl","emptyset.arrow.l"],["emptysetobar","emptyset.bar"],["emptysetocirc","emptyset.circle"],["revemptyset","emptyset.rev"],["setminus","without"],["complement","complement"],["in","in"],["notin","in.not"],["ni","in.rev"],["nni","in.rev.not"],["smallni","in.rev.small"],["smallin","in.small"],["subset","subset"],["subsetdot","subset.dot"],["Subset","subset.double"],["subseteq","subset.eq"],["nsubseteq","subset.eq.not"],["sqsubseteq","subset.eq.sq"],["nsqsubseteq","subset.eq.sq.not"],["subsetneq","subset.neq"],["nsubset","subset.not"],["sqsubset","subset.sq"],["sqsubsetneq","subset.sq.neq"],["supset","supset"],["supsetdot","supset.dot"],["Supset","supset.double"],["supseteq","supset.eq"],["nsupseteq","supset.eq.not"],["sqsupseteq","supset.eq.sq"],["nsqsupseteq","supset.eq.sq.not"],["supsetneq","supset.neq"],["nsupset","supset.not"],["sqsupset","supset.sq"],["sqsupsetneq","supset.sq.neq"],["cup","union"],["cupleftarrow","union.arrow"],["bigcup","union.big"],["cupdot","union.dot"],["bigcupdot","union.dot.big"],["Cup","union.double"],["uminus","union.minus"],["cupvee","union.or"],["uplus","union.plus"],["biguplus","union.plus.big"],["sqcup","union.sq"],["bigsqcup","union.sq.big"],["Sqcup","union.sq.double"],["cap","sect"],["capwedge","sect.and"],["bigcap","sect.big"],["capdot","sect.dot"],["Cap","sect.double"],["sqcap","sect.sq"],["bigsqcap","sect.sq.big"],["Sqcap","sect.sq.double"],["infty","infinity"],["nvinfty","infinity.bar"],["iinfin","infinity.incomplete"],["tieinfty","infinity.tie"],["partial","diff"],["nabla","gradient"],["sum","sum"],["sumint","sum.integral"],["prod","product"],["coprod","product.co"],["int","integral"],["intlarhk","integral.arrow.hook"],["awint","integral.ccw"],["oint","integral.cont"],["ointctrclockwise","integral.cont.ccw"],["varointclockwise","integral.cont.cw"],["intclockwise","integral.cw"],["intbar","integral.dash"],["intBar","integral.dash.double"],["iint","integral.double"],["iiiint","integral.quad"],["intcap","integral.sect"],["fint","integral.slash"],["sqint","integral.square"],["oiint","integral.surf"],["intx","integral.times"],["iiint","integral.triple"],["intcup","integral.union"],["oiiint","integral.vol"],["increment","laplace"],["forall","forall"],["exists","exists"],["nexists","exists.not"],["top","top"],["bot","bot"],["neg","not"],["wedge","and"],["bigwedge","and.big"],["curlywedge","and.curly"],["wedgedot","and.dot"],["Wedge","and.double"],["vee","or"],["bigvee","or.big"],["curlyvee","or.curly"],["veedot","or.dot"],["Vee","or.double"],["models","models"],["Vdash","forces"],["nVdash","forces.not"],["therefore","therefore"],["because","because"],["QED","qed"],["vysmwhtcircle","compose"],["multimap","multimap"],["dualmap","multimap.double"],["tplus","tiny"],["tminus","miny"],["mid","divides"],["nmid","divides.not"],["wr","wreath"],["parallel","parallel"],["nhpar","parallel.struck"],["circledparallel","parallel.circle"],["equalparallel","parallel.eq"],["equivVert","parallel.equiv"],["nparallel","parallel.not"],["eparsl","parallel.slanted.eq"],["smeparsl","parallel.slanted.eq.tilde"],["eqvparsl","parallel.slanted.equiv"],["parsim","parallel.tilde"],["perp","perp"],["operp","perp.circle"],["diameter","diameter"],["Join","join"],["rightouterjoin","join.r"],["leftouterjoin","join.l"],["fullouterjoin","join.l.r"],["smashtimes","smash"],["mathdollar","dollar"],["euro","euro"],["mathsterling","pound"],["mathyen","yen"],["checkmark","checkmark"],["maltese","maltese"],["clubsuit","suit.club.filled"],["varclubsuit","suit.club.stroked"],["vardiamondsuit","suit.diamond.filled"],["diamondsuit","suit.diamond.stroked"],["varheartsuit","suit.heart.filled"],["heartsuit","suit.heart.stroked"],["spadesuit","suit.spade.filled"],["varspadesuit","suit.spade.stroked"],["quarternote","note.quarter.alt"],["eighthnote","note.eighth.alt"],["twonotes","note.eighth.beamed"],["natural","natural"],["flat","flat"],["sharp","sharp"],["smblkcircle","bullet"],["mdlgwhtcircle","circle.stroked"],["mdsmwhtcircle","circle.stroked.small"],["lgwhtcircle","circle.stroked.big"],["mdlgblkcircle","circle.filled"],["mdsmblkcircle","circle.filled.tiny"],["vysmblkcircle","circle.filled.small"],["lgblkcircle","circle.filled.big"],["dottedcircle","circle.dotted"],["circledcirc","circle.nested"],["whthorzoval","ellipse.stroked.h"],["whtvertoval","ellipse.stroked.v"],["blkhorzoval","ellipse.filled.h"],["blkvertoval","ellipse.filled.v"],["bigtriangleup","triangle.stroked.t"],["bigtriangledown","triangle.stroked.b"],["triangleright","triangle.stroked.r"],["triangleleft","triangle.stroked.l"],["lltriangle","triangle.stroked.bl"],["lrtriangle","triangle.stroked.br"],["ultriangle","triangle.stroked.tl"],["urtriangle","triangle.stroked.tr"],["vartriangle","triangle.stroked.small.t"],["triangledown","triangle.stroked.small.b"],["smalltriangleright","triangle.stroked.small.r"],["smalltriangleleft","triangle.stroked.small.l"],["whiteinwhitetriangle","triangle.stroked.nested"],["trianglecdot","triangle.stroked.dot"],["bigblacktriangleup","triangle.filled.t"],["bigblacktriangledown","triangle.filled.b"],["blacktriangleright","triangle.filled.r"],["blacktriangleleft","triangle.filled.l"],["llblacktriangle","triangle.filled.bl"],["lrblacktriangle","triangle.filled.br"],["ulblacktriangle","triangle.filled.tl"],["urblacktriangle","triangle.filled.tr"],["blacktriangle","triangle.filled.small.t"],["blacktriangledown","triangle.filled.small.b"],["smallblacktriangleright","triangle.filled.small.r"],["smallblacktriangleleft","triangle.filled.small.l"],["mdlgwhtsquare","square.stroked"],["smwhtsquare","square.stroked.tiny"],["mdsmwhtsquare","square.stroked.small"],["mdwhtsquare","square.stroked.medium"],["lgwhtsquare","square.stroked.big"],["dottedsquare","square.stroked.dotted"],["squoval","square.stroked.rounded"],["mdlgblksquare","square.filled"],["smblksquare","square.filled.tiny"],["mdsmblksquare","square.filled.small"],["mdblksquare","square.filled.medium"],["lgblksquare","square.filled.big"],["hrectangle","rect.stroked.h"],["vrectangle","rect.stroked.v"],["hrectangleblack","rect.filled.h"],["vrectangleblack","rect.filled.v"],["pentagon","penta.stroked"],["pentagonblack","penta.filled"],["varhexagon","hexa.stroked"],["varhexagonblack","hexa.filled"],["mdlgwhtdiamond","diamond.stroked"],["smwhtdiamond","diamond.stroked.small"],["mdwhtdiamond","diamond.stroked.medium"],["diamondcdot","diamond.stroked.dot"],["mdlgblkdiamond","diamond.filled"],["mdblkdiamond","diamond.filled.medium"],["smblkdiamond","diamond.filled.small"],["mdlgwhtlozenge","lozenge.stroked"],["smwhtlozenge","lozenge.stroked.small"],["mdwhtlozenge","lozenge.stroked.medium"],["mdlgblklozenge","lozenge.filled"],["smblklozenge","lozenge.filled.small"],["mdblklozenge","lozenge.filled.medium"],["parallelogram","parallelogram.stroked"],["parallelogramblack","parallelogram.filled"],["star","star.op"],["bigwhitestar","star.stroked"],["bigstar","star.filled"],["rightarrow","arrow.r"],["longmapsto","arrow.r.long.bar"],["mapsto","arrow.r.bar"],["rightdowncurvedarrow","arrow.r.curve"],["rightdasharrow","arrow.r.dashed"],["rightdotarrow","arrow.r.dotted"],["Rightarrow","arrow.r.double"],["Mapsto","arrow.r.double.bar"],["Longrightarrow","arrow.r.double.long"],["Longmapsto","arrow.r.double.long.bar"],["nRightarrow","arrow.r.double.not"],["hookrightarrow","arrow.r.hook"],["longrightarrow","arrow.r.long"],["longrightsquigarrow","arrow.r.long.squiggly"],["looparrowright","arrow.r.loop"],["nrightarrow","arrow.r.not"],["RRightarrow","arrow.r.quad"],["rightsquigarrow","arrow.r.squiggly"],["rightarrowbar","arrow.r.stop"],["rightwhitearrow","arrow.r.stroked"],["rightarrowtail","arrow.r.tail"],["similarrightarrow","arrow.r.tilde"],["Rrightarrow","arrow.r.triple"],["twoheadmapsto","arrow.r.twohead.bar"],["twoheadrightarrow","arrow.r.twohead"],["rightwavearrow","arrow.r.wave"],["leftarrow","arrow.l"],["mapsfrom","arrow.l.bar"],["leftdowncurvedarrow","arrow.l.curve"],["leftdasharrow","arrow.l.dashed"],["leftdotarrow","arrow.l.dotted"],["Leftarrow","arrow.l.double"],["Mapsfrom","arrow.l.double.bar"],["Longleftarrow","arrow.l.double.long"],["Longmapsfrom","arrow.l.double.long.bar"],["nLeftarrow","arrow.l.double.not"],["hookleftarrow","arrow.l.hook"],["longleftarrow","arrow.l.long"],["longmapsfrom","arrow.l.long.bar"],["longleftsquigarrow","arrow.l.long.squiggly"],["looparrowleft","arrow.l.loop"],["nleftarrow","arrow.l.not"],["LLeftarrow","arrow.l.quad"],["leftsquigarrow","arrow.l.squiggly"],["barleftarrow","arrow.l.stop"],["leftwhitearrow","arrow.l.stroked"],["leftarrowtail","arrow.l.tail"],["similarleftarrow","arrow.l.tilde"],["Lleftarrow","arrow.l.triple"],["twoheadmapsfrom","arrow.l.twohead.bar"],["twoheadleftarrow","arrow.l.twohead"],["leftwavearrow","arrow.l.wave"],["uparrow","arrow.t"],["mapsup","arrow.t.bar"],["uprightcurvearrow","arrow.t.curve"],["updasharrow","arrow.t.dashed"],["Uparrow","arrow.t.double"],["UUparrow","arrow.t.quad"],["baruparrow","arrow.t.stop"],["upwhitearrow","arrow.t.stroked"],["Uuparrow","arrow.t.triple"],["twoheaduparrow","arrow.t.twohead"],["downarrow","arrow.b"],["mapsdown","arrow.b.bar"],["downrightcurvedarrow","arrow.b.curve"],["downdasharrow","arrow.b.dashed"],["Downarrow","arrow.b.double"],["DDownarrow","arrow.b.quad"],["downarrowbar","arrow.b.stop"],["downwhitearrow","arrow.b.stroked"],["Ddownarrow","arrow.b.triple"],["twoheaddownarrow","arrow.b.twohead"],["leftrightarrow","arrow.l.r"],["Leftrightarrow","arrow.l.r.double"],["Longleftrightarrow","arrow.l.r.double.long"],["nLeftrightarrow","arrow.l.r.double.not"],["longleftrightarrow","arrow.l.r.long"],["nleftrightarrow","arrow.l.r.not"],["leftrightsquigarrow","arrow.l.r.wave"],["updownarrow","arrow.t.b"],["Updownarrow","arrow.t.b.double"],["nearrow","arrow.tr"],["Nearrow","arrow.tr.double"],["hknearrow","arrow.tr.hook"],["searrow","arrow.br"],["Searrow","arrow.br.double"],["hksearrow","arrow.br.hook"],["nwarrow","arrow.tl"],["Nwarrow","arrow.tl.double"],["hknwarrow","arrow.tl.hook"],["swarrow","arrow.bl"],["Swarrow","arrow.bl.double"],["hkswarrow","arrow.bl.hook"],["nwsearrow","arrow.tl.br"],["neswarrow","arrow.tr.bl"],["acwopencirclearrow","arrow.ccw"],["curvearrowleft","arrow.ccw.half"],["cwopencirclearrow","arrow.cw"],["curvearrowright","arrow.cw.half"],["downzigzagarrow","arrow.zigzag"],["rightrightarrows","arrows.rr"],["leftleftarrows","arrows.ll"],["upuparrows","arrows.tt"],["downdownarrows","arrows.bb"],["leftrightarrows","arrows.lr"],["barleftarrowrightarrowbar","arrows.lr.stop"],["rightleftarrows","arrows.rl"],["updownarrows","arrows.tb"],["downuparrows","arrows.bt"],["rightthreearrows","arrows.rrr"],["leftthreearrows","arrows.lll"],["rightharpoonup","harpoon.rt"],["barrightharpoonup","harpoon.rt.bar"],["rightharpoonupbar","harpoon.rt.stop"],["rightharpoondown","harpoon.rb"],["barrightharpoondown","harpoon.rb.bar"],["rightharpoondownbar","harpoon.rb.stop"],["leftharpoonup","harpoon.lt"],["leftharpoonupbar","harpoon.lt.bar"],["barleftharpoonup","harpoon.lt.stop"],["leftharpoondown","harpoon.lb"],["leftharpoondownbar","harpoon.lb.bar"],["barleftharpoondown","harpoon.lb.stop"],["upharpoonleft","harpoon.tl"],["upharpoonleftbar","harpoon.tl.bar"],["barupharpoonleft","harpoon.tl.stop"],["upharpoonright","harpoon.tr"],["upharpoonrightbar","harpoon.tr.bar"],["barupharpoonright","harpoon.tr.stop"],["downharpoonleft","harpoon.bl"],["bardownharpoonleft","harpoon.bl.bar"],["downharpoonleftbar","harpoon.bl.stop"],["downharpoonright","harpoon.br"],["bardownharpoonright","harpoon.br.bar"],["downharpoonrightbar","harpoon.br.stop"],["leftrightharpoonupup","harpoon.lt.rt"],["leftrightharpoondowndown","harpoon.lb.rb"],["leftrightharpoondownup","harpoon.lb.rt"],["leftrightharpoonupdown","harpoon.lt.rb"],["updownharpoonleftleft","harpoon.tl.bl"],["updownharpoonrightright","harpoon.tr.br"],["updownharpoonleftright","harpoon.tl.br"],["updownharpoonrightleft","harpoon.tr.bl"],["rightharpoonsupdown","harpoons.rtrb"],["downharpoonsleftright","harpoons.blbr"],["downupharpoonsleftright","harpoons.bltr"],["leftrightharpoonsdown","harpoons.lbrb"],["leftharpoonsupdown","harpoons.ltlb"],["leftrightharpoons","harpoons.ltrb"],["leftrightharpoonsup","harpoons.ltrt"],["rightleftharpoonsdown","harpoons.rblb"],["rightleftharpoons","harpoons.rtlb"],["rightleftharpoonsup","harpoons.rtlt"],["updownharpoonsleftright","harpoons.tlbr"],["upharpoonsleftright","harpoons.tltr"],["vdash","tack.r"],["nvdash","tack.r.not"],["vlongdash","tack.r.long"],["assert","tack.r.short"],["vDash","tack.r.double"],["nvDash","tack.r.double.not"],["dashv","tack.l"],["longdashv","tack.l.long"],["shortlefttack","tack.l.short"],["Dashv","tack.l.double"],["bigbot","tack.t.big"],["Vbar","tack.t.double"],["shortuptack","tack.t.short"],["bigtop","tack.b.big"],["barV","tack.b.double"],["shortdowntack","tack.b.short"],["dashVdash","tack.l.r"],["BbbA","AA"],["BbbB","BB"],["BbbC","CC"],["BbbD","DD"],["BbbE","EE"],["BbbF","FF"],["BbbG","GG"],["BbbH","HH"],["BbbI","II"],["BbbJ","JJ"],["BbbK","KK"],["BbbL","LL"],["BbbM","MM"],["BbbN","NN"],["BbbO","OO"],["BbbP","PP"],["BbbQ","QQ"],["BbbR","RR"],["BbbS","SS"],["BbbT","TT"],["BbbU","UU"],["BbbV","VV"],["BbbW","WW"],["BbbX","XX"],["BbbY","YY"],["BbbZ","ZZ"],["ell","ell"],["Planckconst","planck"],["hslash","planck.reduce"],["Angstrom","angstrom"],["Re","Re"],["Im","Im"],["imath","dotless.i"],["jmath","dotless.j"]]);for(let[q,J]of D2)if(!B.has(q))B.set(q,J);var R=new Map;for(let[q,J]of Array.from(B.entries()).reverse())R.set(J,q);R.set("dif","mathrm{d}");var U2=new Map([["top","top"],["frac","frac"],["tilde","tilde"],["hat","hat"],["upright","mathrm"],["bold","boldsymbol"]]);for(let[q,J]of U2)R.set(q,J);function t(q,J,z=0){for(let V=z;V<q.length;V++)if(q[V].eq(J))return V;return-1}function w(q,J){for(let z of q)if(z.eq(J))return!0;return!1}function c(q,J){let z=[],V=[];for(let Z of q)if(Z.eq(J))z.push(V),V=[];else V.push(Z);return z.push(V),z}class j{type;value;constructor(q,J){this.type=q,this.value=J}eq(q){return this.type===q.type&&this.value===q.value}toString(){switch(this.type){case 2:return`\\text{${this.value}}`;case 3:return`%${this.value}`;default:return this.value}}}function O2(q){if(["{","}","%"].includes(q))return"\\"+q;return q}class ${type;content;args;data;constructor(q,J,z,V){this.type=q,this.content=J,this.args=z,this.data=V}eq(q){return this.type===q.type&&this.content===q.content}toString(){switch(this.type){case"text":return`\\text{${this.content}}`;default:throw new Error(`toString() is not implemented for type ${this.type}`)}}serialize(){switch(this.type){case"empty":return[];case"element":{let q=this.content;return q=O2(q),[new j(0,q)]}case"symbol":return[new j(1,this.content)];case"text":return[new j(2,this.content)];case"comment":return[new j(3,this.content)];case"whitespace":{let q=[];for(let J of this.content){let z=J===" "?4:5;q.push(new j(z,J))}return q}case"ordgroup":return this.args.map((q)=>q.serialize()).flat();case"unaryFunc":{let q=[];if(q.push(new j(1,this.content)),this.content==="\\sqrt"&&this.data)q.push(new j(0,"[")),q=q.concat(this.data.serialize()),q.push(new j(0,"]"));if(this.content==="\\operatorname"&&this.args.length===1&&this.args[0].type==="text"){let J=this.args[0].content;return q.push(new j(0,"{")),q.push(new j(1,J)),q.push(new j(0,"}")),q}return q.push(new j(0,"{")),q=q.concat(this.args[0].serialize()),q.push(new j(0,"}")),q}case"binaryFunc":{let q=[];return q.push(new j(1,this.content)),q.push(new j(0,"{")),q=q.concat(this.args[0].serialize()),q.push(new j(0,"}")),q.push(new j(0,"{")),q=q.concat(this.args[1].serialize()),q.push(new j(0,"}")),q}case"supsub":{let q=[],{base:J,sup:z,sub:V}=this.data;if(q=q.concat(J.serialize()),V)if(q.push(new j(6,"_")),V.type==="ordgroup"||V.type==="supsub"||V.type==="empty")q.push(new j(0,"{")),q=q.concat(V.serialize()),q.push(new j(0,"}"));else q=q.concat(V.serialize());if(z)if(q.push(new j(6,"^")),z.type==="ordgroup"||z.type==="supsub"||z.type==="empty")q.push(new j(0,"{")),q=q.concat(z.serialize()),q.push(new j(0,"}"));else q=q.concat(z.serialize());return q}case"control":return[new j(6,this.content)];case"beginend":{let q=[],J=this.data;q.push(new j(1,`\\begin{${this.content}}`)),q.push(new j(5,` | ||
`));for(let z=0;z<J.length;z++){let V=J[z];for(let Z=0;Z<V.length;Z++){let X=V[Z];if(q=q.concat(X.serialize()),Z!==V.length-1)q.push(new j(6,"&"))}if(z!==J.length-1)q.push(new j(6,"\\\\"))}return q.push(new j(5,` | ||
`)),q.push(new j(1,`\\end{${this.content}}`)),q}default:throw new Error("[TexNode.serialize] Unimplemented type: "+this.type)}}}class G{type;value;constructor(q,J){this.type=q,this.value=J}eq(q){return this.type===q.type&&this.value===q.value}isOneOf(q){return w(q,this)}toNode(){switch(this.type){case 2:return new W("text",this.value);case 3:return new W("comment",this.value);case 4:case 7:return new W("whitespace",this.value);case 1:return new W("atom",this.value);case 0:return new W("symbol",this.value);case 6:{let q=this.value;switch(q){case"":case"_":case"^":return new W("empty","");case"&":return new W("control","&");case"\\":return new W("control","\\");default:throw new Error(`Unexpected control character ${q}`)}}default:throw new Error(`Unexpected token type ${this.type}`)}}toString(){switch(this.type){case 2:return`"${this.value}"`;case 3:return`//${this.value}`;default:return this.value}}}class W{type;content;args;data;options;constructor(q,J,z,V){this.type=q,this.content=J,this.args=z,this.data=V}setOptions(q){this.options=q}eq(q){return this.type===q.type&&this.content===q.content}}function I(q){return"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(q)}function f(q){return"0123456789".includes(q)}function D(q,J=""){if(!q)throw new Error(J)}var A2=["sqrt","text","bar","bold","boldsymbol","ddot","dot","hat","mathbb","mathbf","mathcal","mathfrak","mathit","mathrm","mathscr","mathsf","mathtt","operatorname","overbrace","overline","pmb","rm","tilde","underbrace","underline","vec","widehat","widetilde"],B2=["frac","tfrac","binom","dbinom","dfrac","tbinom","overset"],i=new $("empty","");function I2(q){if(A2.includes(q))return 1;else if(B2.includes(q))return 2;else return 0}var L=new j(6,"{"),h=new j(6,"}"),s=new j(0,"["),M2=new j(0,"]");function _(q,J){let z=J;while(z<q.length&&[4,5].includes(q[z].type))z++;return q.slice(J,z)}function o(q,J){let z=q[J];if(z.type===0&&["(",")","[","]","|","\\{","\\}","."].includes(z.value))return z;else if(z.type===1&&["lfloor","rfloor","lceil","rceil","langle","rangle"].includes(z.value.slice(1)))return z;else return null}function S(q,J){let z=J;while(z<q.length&&q[z].eq(new j(0,"'")))z+=1;return z-J}function R2(q,J){let z=J;while(z<q.length&&I(q[z]))z+=1;return q.substring(J,z)}function g(q,J,z,V){D(q[J].eq(z));let Z=1,X=J+1;while(Z>0){if(X>=q.length)return-1;if(q[X].eq(z))Z+=1;else if(q[X].eq(V))Z-=1;X+=1}return X-1}var x=new j(1,"\\left"),f2=new j(1,"\\right");function S2(q,J){return g(q,J,x,f2)}var y=new j(1,"\\begin"),v2=new j(1,"\\end");function C2(q,J){return g(q,J,y,v2)}function b2(q,J){D(q[J]==="{");let z=1,V=J+1;while(z>0){if(V>=q.length)throw new H("Unmatched curly brackets");if(V+1<q.length&&["\\{","\\}"].includes(q.substring(V,V+2))){V+=2;continue}if(q[V]==="{")z+=1;else if(q[V]==="}")z-=1;V+=1}return V-1}function e(q){let J=[],z=0;while(z<q.length){let V=q[z],Z;switch(V){case"%":{let X=z+1;while(X<q.length&&q[X]!==` | ||
`)X+=1;Z=new j(3,q.slice(z+1,X)),z=X;break}case"{":case"}":case"_":case"^":case"&":Z=new j(6,V),z++;break;case` | ||
`:Z=new j(5,V),z++;break;case"\r":{if(z+1<q.length&&q[z+1]===` | ||
`)Z=new j(5,` | ||
`),z+=2;else Z=new j(5,` | ||
`),z++;break}case" ":{let X=z;while(X<q.length&&q[X]===" ")X+=1;Z=new j(4,q.slice(z,X)),z=X;break}case"\\":{if(z+1>=q.length)throw new H("Expecting command name after \\");let X=q.slice(z,z+2);if(["\\\\","\\,"].includes(X))Z=new j(6,X);else if(["\\{","\\}","\\%","\\$","\\&","\\#","\\_","\\|"].includes(X))Z=new j(0,X);else{let Q=R2(q,z+1);Z=new j(1,"\\"+Q)}z+=Z.value.length;break}default:{if(f(V)){let X=z;while(X<q.length&&f(q[X]))X+=1;Z=new j(0,q.slice(z,X))}else if(I(V))Z=new j(0,V);else if("+-*/='<>!.,;:?()[]|".includes(V))Z=new j(0,V);else Z=new j(7,V);z+=Z.value.length}}if(J.push(Z),Z.type===1&&["\\text","\\operatorname","\\begin","\\end"].includes(Z.value)){if(z>=q.length||q[z]!=="{")throw new H(`No content for ${Z.value} command`);J.push(new j(6,"{"));let X=b2(q,z);z++;let Q=q.slice(z,X),K=["{","}","\\","$","&","#","_","%"];for(let F of K)Q=Q.replaceAll("\\"+F,F);J.push(new j(2,Q)),J.push(new j(6,"}")),z=X+1}}return J}class H extends Error{constructor(q){super(q);this.name="LatexParserError"}}var d=new j(6,"_"),a=new j(6,"^");class q2{space_sensitive;newline_sensitive;constructor(q=!1,J=!0){this.space_sensitive=q,this.newline_sensitive=J}parse(q){let J=[],z=0;while(z<q.length){let V=[],Z=0;while(Z<q.length){let[X,Q]=this.parseNextExpr(q,Z);if(Z=Q,X.type==="whitespace"){if(!this.space_sensitive&&X.content.replace(/ /g,"").length===0)continue;if(!this.newline_sensitive&&X.content===` | ||
`)continue}if(X.type==="control"&&X.content==="&")throw new H("Unexpected & outside of an alignment");V.push(X)}if(V.length===0)return i;else if(V.length===1)return V[0];else return new $("ordgroup","",V)}if(J.length===0)return i;else if(J.length===1)return J[0];else return new $("ordgroup","",J)}parseNextExpr(q,J){let[z,V]=this.parseNextExprWithoutSupSub(q,J),Z=null,X=null,Q=0;if(Q+=S(q,V),V+=Q,V<q.length&&q[V].eq(d)){if([Z,V]=this.parseNextExprWithoutSupSub(q,V+1),Q+=S(q,V),V+=Q,V<q.length&&q[V].eq(a)){if([X,V]=this.parseNextExprWithoutSupSub(q,V+1),S(q,V)>0)throw new H("Double superscript")}}else if(V<q.length&&q[V].eq(a)){if([X,V]=this.parseNextExprWithoutSupSub(q,V+1),S(q,V)>0)throw new H("Double superscript");if(V<q.length&&q[V].eq(d)){if([Z,V]=this.parseNextExprWithoutSupSub(q,V+1),S(q,V)>0)throw new H("Double superscript")}}if(Z!==null||X!==null||Q>0){let K={base:z};if(Z)K.sub=Z;if(Q>0){K.sup=new $("ordgroup","",[]);for(let F=0;F<Q;F++)K.sup.args.push(new $("element","'"));if(X)K.sup.args.push(X);if(K.sup.args.length===1)K.sup=K.sup.args[0]}else if(X)K.sup=X;return[new $("supsub","",[],K),V]}else return[z,V]}parseNextExprWithoutSupSub(q,J){let z=q[J];switch(z.type){case 0:return[new $("element",z.value),J+1];case 2:return[new $("text",z.value),J+1];case 3:return[new $("comment",z.value),J+1];case 4:case 5:return[new $("whitespace",z.value),J+1];case 1:if(z.eq(y))return this.parseBeginEndExpr(q,J);else if(z.eq(x))return this.parseLeftRightExpr(q,J);else return this.parseCommandExpr(q,J);case 6:switch(z.value){case"{":let X=g(q,J,L,h);if(X===-1)throw new H("Unmatched '{'");let Q=q.slice(J+1,X);return[this.parse(Q),X+1];case"}":throw new H("Unmatched '}'");case"\\\\":return[new $("control","\\\\"),J+1];case"\\,":return[new $("control","\\,"),J+1];case"_":case"^":return[i,J];case"&":return[new $("control","&"),J+1];default:throw new H("Unknown control sequence")}default:throw new H("Unknown token type")}}parseCommandExpr(q,J){D(q[J].type===1);let z=q[J].value,V=J+1;if(["left","right","begin","end"].includes(z.slice(1)))throw new H("Unexpected command: "+z);switch(I2(z.slice(1))){case 0:if(!B.has(z.slice(1)))return[new $("unknownMacro",z),V];return[new $("symbol",z),V];case 1:{if(V>=q.length)throw new H("Expecting argument for "+z);if(z==="\\sqrt"&&V<q.length&&q[V].eq(s)){let K=V,F=g(q,V,s,M2);if(F===-1)throw new H("No matching right square bracket for [");let Y=q.slice(K+1,F),A=this.parse(Y),[b,l]=this.parseNextExprWithoutSupSub(q,F+1);return[new $("unaryFunc",z,[b],A),l]}else if(z==="\\text"){if(V+2>=q.length)throw new H("Expecting content for \\text command");D(q[V].eq(L)),D(q[V+1].type===2),D(q[V+2].eq(h));let K=q[V+1].value;return[new $("text",K),V+3]}let[X,Q]=this.parseNextExprWithoutSupSub(q,V);return[new $("unaryFunc",z,[X]),Q]}case 2:{let[X,Q]=this.parseNextExprWithoutSupSub(q,V),[K,F]=this.parseNextExprWithoutSupSub(q,Q);return[new $("binaryFunc",z,[X,K]),F]}default:throw new Error("Invalid number of parameters")}}parseLeftRightExpr(q,J){D(q[J].eq(x));let z=J+1;if(z+=_(q,z).length,z>=q.length)throw new H("Expecting delimiter after \\left");let V=o(q,z);if(V===null)throw new H("Invalid delimiter after \\left");z++;let Z=z,X=S2(q,J);if(X===-1)throw new H("No matching \\right");let Q=X;if(z=X+1,z+=_(q,z).length,z>=q.length)throw new H("Expecting \\right after \\left");let K=o(q,z);if(K===null)throw new H("Invalid delimiter after \\right");z++;let F=q.slice(Z,Q),Y=this.parse(F),A=[new $("element",V.value),Y,new $("element",K.value)];return[new $("leftright","",A),z]}parseBeginEndExpr(q,J){D(q[J].eq(y));let z=J+1;D(q[z].eq(L)),D(q[z+1].type===2),D(q[z+2].eq(h));let V=q[z+1].value;z+=3,z+=_(q,z).length;let Z=z,X=C2(q,J);if(X===-1)throw new H("No matching \\end");let Q=X;if(z=X+1,D(q[z].eq(L)),D(q[z+1].type===2),D(q[z+2].eq(h)),q[z+1].value!==V)throw new H("Mismatched \\begin and \\end environments");z+=3;let K=q.slice(Z,Q);while(K.length>0&&[4,5].includes(K[K.length-1].type))K.pop();let F=this.parseAligned(K);return[new $("beginend",V,[],F),z]}parseAligned(q){let J=0,z=[],V=[];z.push(V);let Z=new $("ordgroup","",[]);V.push(Z);while(J<q.length){let[X,Q]=this.parseNextExpr(q,J);if(J=Q,X.type==="whitespace"){if(!this.space_sensitive&&X.content.replace(/ /g,"").length===0)continue;if(!this.newline_sensitive&&X.content===` | ||
`)continue}if(X.type==="control"&&X.content==="\\\\")V=[],Z=new $("ordgroup","",[]),V.push(Z),z.push(V);else if(X.type==="control"&&X.content==="&")Z=new $("ordgroup","",[]),V.push(Z);else Z.args.push(X)}return z}}function w2(q){let J=(V)=>V.eq(d)||V.eq(a),z=[];for(let V=0;V<q.length;V++){if(q[V].type===4&&V+1<q.length&&J(q[V+1]))continue;if(q[V].type===4&&V-1>=0&&J(q[V-1]))continue;z.push(q[V])}return z}function L2(q,J){let z=[];for(let V of q)if(V.type===1&&J[V.value]){let Z=e(J[V.value]);z=z.concat(Z)}else z.push(V);return z}function z2(q,J){let z=new q2,V=e(q);return V=w2(V),V=L2(V,J),z.parse(V)}var g2=["dim","id","im","mod","Pr","sech","csch"];function J2(q){return q.type==="atom"&&["(",")","[","]","{","}","|","⌊","⌋","⌈","⌉"].includes(q.content)}function E2(q){let[J,z]=q.args,V=(Q)=>{if(Q.eq(new $("text","def")))return!0;if(Q.type==="ordgroup"&&Q.args.length===3){let[K,F,Y]=Q.args,A=new $("element","d"),b=new $("element","e"),l=new $("element","f");if(K.eq(A)&&F.eq(b)&&Y.eq(l))return!0}return!1},Z=(Q)=>Q.eq(new $("element","="));if(V(J)&&Z(z))return new W("symbol","eq.def");let X=new W("funcCall","op",[U(z)]);return X.setOptions({limits:"#true"}),new W("supsub","",[],{base:X,sup:U(J)})}var k=new G(1,"("),E=new G(1,")"),P2=new G(1,","),u2=new G(0,` | ||
`);class M extends Error{node;constructor(q,J){super(q);this.name="TypstWriterError",this.node=J}}class p{nonStrict;preferTypstIntrinsic;keepSpaces;buffer="";queue=[];insideFunctionDepth=0;constructor(q,J,z){this.nonStrict=q,this.preferTypstIntrinsic=J,this.keepSpaces=z}writeBuffer(q){let J=q.toString();if(J==="")return;let z=!1;if(z||=/[\(\[\|]$/.test(this.buffer)&&/^\w/.test(J),z||=/^[})\]\|]$/.test(J),z||=/^[(_^,;!]$/.test(J),z||=J==="'",z||=/[0-9]$/.test(this.buffer)&&/^[0-9]/.test(J),z||=/[\(\[{]\s*(-|\+)$/.test(this.buffer)||this.buffer==="-"||this.buffer==="+",z||=J.startsWith(` | ||
`),z||=this.buffer==="",z||=/^\s/.test(J),z||=this.buffer.endsWith("&")&&J==="=",z||=/[\s_^{\(]$/.test(this.buffer),!z)this.buffer+=" ";this.buffer+=J}serialize(q){switch(q.type){case"empty":break;case"atom":{if(q.content===","&&this.insideFunctionDepth>0)this.queue.push(new G(0,"comma"));else this.queue.push(new G(1,q.content));break}case"symbol":this.queue.push(new G(0,q.content));break;case"text":this.queue.push(new G(2,q.content));break;case"comment":this.queue.push(new G(3,q.content));break;case"whitespace":for(let J of q.content)if(J===" "){if(this.keepSpaces)this.queue.push(new G(4,J))}else if(J===` | ||
`)this.queue.push(new G(0,J));else throw new M(`Unexpected whitespace character: ${J}`,q);break;case"group":for(let J of q.args)this.serialize(J);break;case"supsub":{let{base:J,sup:z,sub:V}=q.data;this.appendWithBracketsIfNeeded(J);let Z=!1,X=z&&z.type==="atom"&&z.content==="'";if(X)this.queue.push(new G(1,"'")),Z=!1;if(V)this.queue.push(new G(1,"_")),Z=this.appendWithBracketsIfNeeded(V);if(z&&!X)this.queue.push(new G(1,"^")),Z=this.appendWithBracketsIfNeeded(z);if(Z)this.queue.push(new G(6," "));break}case"funcCall":{let J=new G(0,q.content);this.queue.push(J),this.insideFunctionDepth++,this.queue.push(k);for(let z=0;z<q.args.length;z++)if(this.serialize(q.args[z]),z<q.args.length-1)this.queue.push(new G(1,","));if(q.options)for(let[z,V]of Object.entries(q.options))this.queue.push(new G(0,`, ${z}: ${V}`));this.queue.push(E),this.insideFunctionDepth--;break}case"align":{let J=q.data;J.forEach((z,V)=>{if(z.forEach((Z,X)=>{if(X>0)this.queue.push(new G(1,"&"));this.serialize(Z)}),V<J.length-1)this.queue.push(new G(0,"\\"))});break}case"matrix":{let J=q.data;if(this.queue.push(new G(0,"mat")),this.insideFunctionDepth++,this.queue.push(k),q.options)for(let[z,V]of Object.entries(q.options))this.queue.push(new G(0,`${z}: ${V}, `));J.forEach((z,V)=>{z.forEach((Z,X)=>{if(this.serialize(Z),X<z.length-1)this.queue.push(new G(1,","));else if(V<J.length-1)this.queue.push(new G(1,";"))})}),this.queue.push(E),this.insideFunctionDepth--;break}case"unknown":{if(this.nonStrict)this.queue.push(new G(0,q.content));else throw new M(`Unknown macro: ${q.content}`,q);break}default:throw new M(`Unimplemented node type to append: ${q.type}`,q)}}appendWithBracketsIfNeeded(q){let J=["group","supsub","empty"].includes(q.type);if(q.type==="group"){let z=q.args[0],V=q.args[q.args.length-1];if(J2(z)&&J2(V))J=!1}if(J)this.queue.push(k),this.serialize(q),this.queue.push(E);else this.serialize(q);return!J}flushQueue(){let q=new G(6," ");for(let J=0;J<this.queue.length;J++)if(this.queue[J].eq(q)){if(J===this.queue.length-1)this.queue[J].value="";else if(this.queue[J+1].isOneOf([E,P2,u2]))this.queue[J].value=""}this.queue.forEach((J)=>{this.writeBuffer(J)}),this.queue=[]}finalize(){this.flushQueue();let V=[function(Z){let X=Z.replace(/floor\.l\s*(.*?)\s*floor\.r/g,"floor($1)");return X=X.replace(/floor\(\)/g,'floor("")'),X},function(Z){let X=Z.replace(/ceil\.l\s*(.*?)\s*ceil\.r/g,"ceil($1)");return X=X.replace(/ceil\(\)/g,'ceil("")'),X},function(Z){let X=Z.replace(/floor\.l\s*(.*?)\s*ceil\.r/g,"round($1)");return X=X.replace(/round\(\)/g,'round("")'),X}];for(let Z of V)this.buffer=Z(this.buffer);return this.buffer}}function U(q){switch(q.type){case"empty":return new W("empty","");case"whitespace":return new W("whitespace",q.content);case"ordgroup":return new W("group","",q.args.map(U));case"element":return new W("atom",v(q.content));case"symbol":return new W("symbol",v(q.content));case"text":return new W("text",q.content);case"comment":return new W("comment",q.content);case"supsub":{let{base:J,sup:z,sub:V}=q.data;if(J&&J.type==="unaryFunc"&&J.content==="\\overbrace"&&z)return new W("funcCall","overbrace",[U(J.args[0]),U(z)]);else if(J&&J.type==="unaryFunc"&&J.content==="\\underbrace"&&V)return new W("funcCall","underbrace",[U(J.args[0]),U(V)]);let Z={base:U(J)};if(Z.base.type==="empty")Z.base=new W("text","");if(z)Z.sup=U(z);if(V)Z.sub=U(V);return new W("supsub","",[],Z)}case"leftright":{let[J,z,V]=q.args,Z=new W("group","",q.args.map(U));if(["[]","()","\\{\\}","\\lfloor\\rfloor","\\lceil\\rceil","\\lfloor\\rceil"].includes(J.content+V.content))return Z;if(V.content===".")return Z.args.pop(),Z;else if(J.content===".")return Z.args.shift(),new W("funcCall","lr",[Z]);return new W("funcCall","lr",[Z])}case"binaryFunc":{if(q.content==="\\overset")return E2(q);return new W("funcCall",v(q.content),q.args.map(U))}case"unaryFunc":{let J=U(q.args[0]);if(q.content==="\\sqrt"&&q.data){let z=U(q.data);return new W("funcCall","root",[z,J])}if(q.content==="\\mathbf"){let z=new W("funcCall","bold",[J]);return new W("funcCall","upright",[z])}if(q.content==="\\mathbb"&&J.type==="atom"&&/^[A-Z]$/.test(J.content))return new W("symbol",J.content+J.content);if(q.content==="\\operatorname"){let z=q.args;if(z.length!==1||z[0].type!=="text")throw new M("Expecting body of \\operatorname to be text but got",q);let V=z[0].content;if(g2.includes(V))return new W("symbol",V);else return new W("funcCall","op",[new W("text",V)])}return new W("funcCall",v(q.content),q.args.map(U))}case"beginend":{let z=q.data.map((V)=>V.map(U));if(q.content.startsWith("align"))return new W("align","",[],z);else{let V=new W("matrix","",[],z);return V.setOptions({delim:"#none"}),V}}case"unknownMacro":return new W("unknown",v(q.content));case"control":if(q.content==="\\\\")return new W("symbol","\\");else if(q.content==="\\,")return new W("symbol","thin");else throw new M(`Unknown control sequence: ${q.content}`,q);default:throw new M(`Unimplemented node type: ${q.type}`,q)}}function v(q){if(/^[a-zA-Z0-9]$/.test(q))return q;else if(q==="/")return"\\/";else if(q==="\\|")return"parallel";else if(q==="\\colon")return":";else if(q==="\\\\")return"\\";else if(["\\$","\\#","\\&","\\_"].includes(q))return q;else if(q.startsWith("\\")){let J=q.slice(1);if(B.has(J))return B.get(J);else return J}return q}function V2(q,J){let z=J;while(z<q.length&&q[z].eq(new G(1,"'")))z+=1;return z-J}function m2(q,J){let z=J;while(z<q.length&&(I(q[z])||q[z]==="."))z+=1;return q.substring(J,z)}var u=new W("empty","");function N2(q){let J=[],z=0;while(z<q.length){let V=q[z],Z;switch(V){case"_":case"^":case"&":Z=new G(6,V),z++;break;case` | ||
`:Z=new G(7,V),z++;break;case"\r":{if(z+1<q.length&&q[z+1]===` | ||
`)Z=new G(7,` | ||
`),z+=2;else Z=new G(7,` | ||
`),z++;break}case" ":{let X=z;while(X<q.length&&q[X]===" ")X++;Z=new G(4,q.substring(z,X)),z=X;break}case"/":{if(z<q.length&&q[z+1]==="/"){let X=z+2;while(X<q.length&&q[X]!==` | ||
`)X++;Z=new G(3,q.slice(z+2,X)),z=X}else Z=new G(1,"/"),z++;break}case"\\":{if(z+1>=q.length)throw new Error("Expecting a character after \\");let X=q.substring(z,z+2);if(["\\$","\\&","\\#","\\_"].includes(X))Z=new G(1,X),z+=2;else if(X==="\\\n")Z=new G(6,"\\"),z+=1;else Z=new G(6,""),z++;break}case'"':{let X=z+1;while(X<q.length){if(q[X]==='"'&&q[X-1]!=="\\")break;X++}let Q=q.substring(z+1,X),K=['"',"\\"];for(let F of K)Q=Q.replaceAll("\\"+F,F);Z=new G(2,Q),z=X+1;break}default:{if(f(V)){let X=z;while(X<q.length&&f(q[X]))X+=1;Z=new G(1,q.slice(z,X))}else if("+-*/='<>!.,;?()[]|".includes(V))Z=new G(1,V);else if(I(V)){let X=m2(q,z),Q=X.length===1?1:0;Z=new G(Q,X)}else Z=new G(1,V);z+=Z.value.length}}J.push(Z)}return J}function P(q,J){D(q[J].isOneOf([C,Q2,j2]));let z=1,V=J+1;while(z>0){if(V>=q.length)throw new Error("Unmatched brackets");if(q[V].isOneOf([C,Q2,j2]))z+=1;else if(q[V].isOneOf([_2,x2,y2]))z-=1;V+=1}return V-1}function l2(q,J){let z=new W("atom","("),V=new W("atom",")");D(q[J].eq(z));let Z=1,X=J+1;while(Z>0){if(X>=q.length)throw new Error("Unmatched brackets");if(q[X].eq(z))Z+=1;else if(q[X].eq(V))Z-=1;X+=1}return X-1}function X2(q){let J=[];for(let z=0;z<q;z++)J.push(new W("atom","'"));return J}var m=new W("atom","/");function c2(q,J){let z=J;while(z<q.length&&q[z].type==="whitespace")z++;return z===q.length?u:q[z]}function i2(q){let J=!1,z=[];for(let V=0;V<q.length;V++){let Z=q[V];if(Z.type==="whitespace"){if(J)continue;if(c2(q,V+1).eq(m))continue}if(Z.eq(m))J=!0;else J=!1;z.push(Z)}return z}function T(q,J=!1){q=i2(q);let z=new W("atom","("),V=new W("atom",")"),Z=[],X=[],Q=0;while(Q<q.length){let K=q[Q];if(K.eq(V))throw new r("Unexpected ')'");else if(K.eq(m))Z.push(K),Q++;else{let F;if(K.eq(z)){let Y=l2(q,Q);F=T(q.slice(Q+1,Y),!0),Q=Y+1}else F=K,Q++;if(Z.length>0&&Z[Z.length-1].eq(m)){let Y=F;if(X.length===0)throw new r("Unexpected '/' operator, no numerator before it");let A=X.pop();if(Y.type==="group"&&Y.content==="parenthesis")Y.content="";if(A.type==="group"&&A.content==="parenthesis")A.content="";X.push(new W("fraction","",[A,Y])),Z.pop()}else X.push(F)}}if(J)return new W("group","parenthesis",X);else if(X.length===0)return u;else if(X.length===1)return X[0];else return new W("group","",X)}class r extends Error{constructor(q){super(q);this.name="TypstParserError"}}var Z2=new G(6,"_"),$2=new G(6,"^"),C=new G(1,"("),_2=new G(1,")"),Q2=new G(1,"["),x2=new G(1,"]"),j2=new G(1,"{"),y2=new G(1,"}"),d2=new G(1,","),a2=new G(1,";"),k2=new G(4," ");class W2{space_sensitive;newline_sensitive;constructor(q=!0,J=!0){this.space_sensitive=q,this.newline_sensitive=J}parse(q){let[J,z]=this.parseGroup(q,0,q.length);return J}parseGroup(q,J,z,V=!1){let Z=[],X=J;while(X<z){let[K,F]=this.parseNextExpr(q,X);if(X=F,K.type==="whitespace"){if(!this.space_sensitive&&K.content.replace(/ /g,"").length===0)continue;if(!this.newline_sensitive&&K.content===` | ||
`)continue}Z.push(K)}let Q;if(V)Q=T(Z,!0);else if(Z.length===0)Q=u;else if(Z.length===1)Q=Z[0];else Q=T(Z);return[Q,z+1]}parseNextExpr(q,J){let[z,V]=this.parseNextExprWithoutSupSub(q,J),Z=null,X=null,Q=V2(q,V);if(Q>0)z=new W("group","",[z].concat(X2(Q))),V+=Q;if(V<q.length&&q[V].eq(Z2)){if([Z,V]=this.parseSupOrSub(q,V+1),V<q.length&&q[V].eq($2))[X,V]=this.parseSupOrSub(q,V+1)}else if(V<q.length&&q[V].eq($2)){if([X,V]=this.parseSupOrSub(q,V+1),V<q.length&&q[V].eq(Z2))[Z,V]=this.parseSupOrSub(q,V+1)}if(Z!==null||X!==null){let K={base:z};if(Z)K.sub=Z;if(X)K.sup=X;return[new W("supsub","",[],K),V]}else return[z,V]}parseSupOrSub(q,J){let z,V;if(q[J].eq(C)){let X=P(q,J);[z,V]=this.parseGroup(q,J+1,X)}else[z,V]=this.parseNextExprWithoutSupSub(q,J);let Z=V2(q,V);if(Z>0)z=new W("group","",[z].concat(X2(Z))),V+=Z;return[z,V]}parseNextExprWithoutSupSub(q,J){let z=q[J],V=z.toNode();if(z.eq(C)){let Z=P(q,J);return this.parseGroup(q,J+1,Z,!0)}if(z.type===1&&!I(z.value[0]))return[V,J+1];if([1,0].includes(z.type)){if(J+1<q.length&&q[J+1].eq(C)){if(z.value==="mat"){let[K,F]=this.parseGroupsOfArguments(q,J+1);return[new W("matrix","",[],K),F]}let[Z,X]=this.parseArguments(q,J+1),Q=new W("funcCall",z.value);return Q.args=Z,[Q,X]}}return[V,J+1]}parseArguments(q,J){let z=P(q,J);return[this.parseCommaSeparatedArguments(q,J+1,z),z+1]}parseGroupsOfArguments(q,J){let z=P(q,J),V=[],Z=J+1;while(Z<z)while(Z<z){let X=t(q,a2,Z);if(X===-1)X=z;let Q=this.parseCommaSeparatedArguments(q,Z,X);V.push(Q),Z=X+1}return[V,z+1]}parseCommaSeparatedArguments(q,J,z){let V=[],Z=J;while(Z<z){let X=new W("group","",[]);while(Z<z){if(q[Z].eq(d2)){Z+=1;break}else if(q[Z].eq(k2)){Z+=1;continue}let[Q,K]=this.parseNextExpr(q,Z);Z=K,X.args.push(Q)}if(X.args.length===0)X=u;else if(X.args.length===1)X=X.args[0];V.push(X)}return V}}function G2(q){let J=new W2,z=N2(q);return J.parse(z)}var p2=["sqrt","bold","arrow","upright","lr","op","macron","dot","dot.double","hat","tilde","overline","underline","bb","cal","frak"],T2=["frac","root","overbrace","underbrace"];function K2(q){if(["{","}","%"].includes(q))return"\\"+q;return q}class n{buffer="";queue=[];writeBuffer(q){let J=q.toString(),z=!1;if(q.type===4)z=!0;else z||=/[{\(\[\|]$/.test(this.buffer),z||=/\\\w+$/.test(this.buffer)&&J==="[",z||=/^[\.,;:!\?\(\)\]{}_^]$/.test(J),z||=["\\{","\\}"].includes(J),z||=J==="'",z||=this.buffer.endsWith("_")||this.buffer.endsWith("^"),z||=/\s$/.test(this.buffer),z||=/^\s/.test(J),z||=this.buffer==="",z||=/[\(\[{]\s*(-|\+)$/.test(this.buffer)||this.buffer==="-"||this.buffer==="+",z||=this.buffer.endsWith("&")&&J==="=";if(!z)this.buffer+=" ";this.buffer+=J}append(q){let J=new $("control","&"),z=new $("control","\\\\");if(q.type==="ordgroup"&&w(q.args,J)){let V=c(q.args,z),Z=[];for(let X of V){let Q=c(X,J);Z.push(Q.map((K)=>new $("ordgroup","",K)))}q=new $("beginend","aligned",[],Z)}this.queue=this.queue.concat(q.serialize())}flushQueue(){for(let q=0;q<this.queue.length;q++)this.writeBuffer(this.queue[q]);this.queue=[]}finalize(){return this.flushQueue(),this.buffer}}function O(q){if(q.eq(new W("symbol","eq.def")))return new $("binaryFunc","\\overset",[new $("text","def"),new $("element","=")]);switch(q.type){case"empty":return new $("empty","");case"whitespace":return new $("whitespace",q.content);case"atom":if(q.content===":")return new $("symbol","\\colon");return new $("element",q.content);case"symbol":if(q.content==="comma")return new $("element",",");return new $("symbol",N(q.content));case"text":return new $("text",q.content);case"comment":return new $("comment",q.content);case"group":{let J=q.args.map(O);if(q.content==="parenthesis")J.unshift(new $("element","(")),J.push(new $("element",")"));return new $("ordgroup","",J)}case"funcCall":if(p2.includes(q.content)){if(q.content==="lr"){let z=q.args[0];if(z.type==="group"){let V=z.args[0].content,Z=z.args[z.args.length-1].content;return V=K2(V),Z=K2(Z),new $("ordgroup","",[new $("element","\\left"+V),...z.args.slice(1,z.args.length-1).map(O),new $("element","\\right"+Z)])}}let J=N(q.content);return new $("unaryFunc",J,q.args.map(O))}else if(T2.includes(q.content)){if(q.content==="root"){let[z,V]=q.args,Z=O(z);return new $("unaryFunc","\\sqrt",[O(V)],Z)}if(q.content==="overbrace"||q.content==="underbrace"){let[z,V]=q.args,Z=new $("unaryFunc","\\"+q.content,[O(z)]),X=O(V),Q=q.content==="overbrace"?{base:Z,sup:X}:{base:Z,sub:X};return new $("supsub","",[],Q)}let J=N(q.content);return new $("binaryFunc",J,q.args.map(O))}else return new $("ordgroup","",[new $("symbol",N(q.content)),new $("element","("),...q.args.map(O),new $("element",")")]);case"supsub":{let{base:J,sup:z,sub:V}=q.data,Z=O(J),X,Q;if(z)X=O(z);if(V)Q=O(V);return new $("supsub","",[],{base:Z,sup:X,sub:Q})}case"matrix":{let z=q.data.map((Z)=>Z.map(O)),V=new $("beginend","matrix",[],z);return new $("ordgroup","",[new $("element","\\left("),V,new $("element","\\right)")])}case"control":switch(q.content){case"\\":return new $("control","\\\\");case"&":return new $("control","&");default:throw new Error("[convert_typst_node_to_tex] Unimplemented control: "+q.content)}case"fraction":{let[J,z]=q.args,V=O(J),Z=O(z);return new $("binaryFunc","\\frac",[V,Z])}default:throw new Error("[convert_typst_node_to_tex] Unimplemented type: "+q.type)}}function N(q){if(/^[a-zA-Z0-9]$/.test(q))return q;else if(q==="thin")return"\\,";else if(R.has(q))return"\\"+R.get(q);return"\\"+q}function F2(q,J){let z={nonStrict:!0,preferTypstIntrinsic:!0,keepSpaces:!1,customTexMacros:{}};if(J){if(J.nonStrict)z.nonStrict=J.nonStrict;if(J.preferTypstIntrinsic)z.preferTypstIntrinsic=J.preferTypstIntrinsic;if(J.customTexMacros)z.customTexMacros=J.customTexMacros}let V=z2(q,z.customTexMacros),Z=U(V),X=new p(z.nonStrict,z.preferTypstIntrinsic,z.keepSpaces);return X.serialize(Z),X.finalize()}function H2(q){let J=G2(q),z=O(J),V=new n;return V.append(z),V.finalize()}if(typeof window!=="undefined")window.tex2typst=F2,window.typst2tex=H2; | ||
var I=new Map([["nonumber",""],["vec","arrow"],["neq","eq.not"],["dot","dot"],["ddot","dot.double"],["doteq","dot(eq)"],["dots","dots.h"],["vdots","dots.v"],["ddots","dots.down"],["widehat","hat"],["widetilde","tilde"],["quad","quad"],["qquad","wide"],["overbrace","overbrace"],["underbrace","underbrace"],["overline","overline"],["underline","underline"],["bar","macron"],["dbinom","binom"],["tbinom","binom"],["dfrac","frac"],["tfrac","frac"],["operatorname","op"],["boldsymbol","bold"],["mathbb","bb"],["mathbf","bold"],["mathcal","cal"],["mathit","italic"],["mathfrak","frak"],["mathrm","upright"],["mathsf","sans"],["mathtt","mono"],["rm","upright"],["pmb","bold"],["pm","plus.minus"],["mp","minus.plus"],["boxplus","plus.square"],["otimes","times.circle"],["boxtimes","times.square"],["approx","approx"],["cong","tilde.equiv"],["simeq","tilde.eq"],["asymp","≍"],["equiv","equiv"],["propto","prop"],["gets","arrow.l"],["hookleftarrow","arrow.l.hook"],["leftharpoonup","harpoon.lt"],["leftharpoondown","harpoon.lb"],["rightleftharpoons","harpoons.rtlb"],["longleftarrow","arrow.l.long"],["longrightarrow","arrow.r.long"],["longleftrightarrow","arrow.l.r.long"],["Longleftarrow","arrow.l.double.long"],["Longrightarrow","arrow.r.double.long"],["Longleftrightarrow","arrow.l.r.double.long"],["hookrightarrow","arrow.r.hook"],["rightharpoonup","harpoon.rt"],["rightharpoondown","harpoon.rb"],["iff","arrow.l.r.double.long"],["implies","arrow.r.double.long"],["uparrow","arrow.t"],["downarrow","arrow.b"],["updownarrow","arrow.t.b"],["Uparrow","arrow.t.double"],["Downarrow","arrow.b.double"],["Updownarrow","arrow.t.b.double"],["nearrow","arrow.tr"],["searrow","arrow.br"],["swarrow","arrow.bl"],["nwarrow","arrow.tl"],["leadsto","arrow.squiggly"],["leftleftarrows","arrows.ll"],["rightrightarrows","arrows.rr"],["Cap","sect.double"],["Cup","union.double"],["Delta","Delta"],["Gamma","Gamma"],["Join","join"],["Lambda","Lambda"],["Leftarrow","arrow.l.double"],["Leftrightarrow","arrow.l.r.double"],["Longrightarrow","arrow.r.double.long"],["Omega","Omega"],["P","pilcrow"],["Phi","Phi"],["Pi","Pi"],["Psi","Psi"],["Rightarrow","arrow.r.double"],["S","section"],["Sigma","Sigma"],["Theta","Theta"],["aleph","alef"],["alpha","alpha"],["angle","angle"],["approx","approx"],["approxeq","approx.eq"],["beta","beta"],["bigcap","sect.big"],["bigcirc","circle.big"],["bigcup","union.big"],["bigodot","dot.circle.big"],["bigotimes","times.circle.big"],["bigsqcup","union.sq.big"],["biguplus","union.plus.big"],["bigvee","or.big"],["bigwedge","and.big"],["bullet","bullet"],["cap","sect"],["cdot","dot.op"],["cdots","dots.c"],["checkmark","checkmark"],["chi","chi"],["circ","circle.small"],["colon","colon"],["cong","tilde.equiv"],["coprod","product.co"],["copyright","copyright"],["cup","union"],["curlyvee","or.curly"],["curlywedge","and.curly"],["dagger","dagger"],["dashv","tack.l"],["ddagger","dagger.double"],["delta","delta"],["ddots","dots.down"],["diamond","diamond"],["div","div"],["divideontimes","times.div"],["dotplus","plus.dot"],["downarrow","arrow.b"],["ell","ell"],["emptyset","nothing"],["epsilon","epsilon.alt"],["equiv","equiv"],["eta","eta"],["exists","exists"],["forall","forall"],["gamma","gamma"],["ge","gt.eq"],["geq","gt.eq"],["geqslant","gt.eq.slant"],["gg","gt.double"],["hbar","planck.reduce"],["imath","dotless.i"],["iiiint","integral.quad"],["iiint","integral.triple"],["iint","integral.double"],["in","in"],["infty","infinity"],["int","integral"],["intercal","top"],["iota","iota"],["jmath","dotless.j"],["kappa","kappa"],["lambda","lambda"],["land","and"],["langle","angle.l"],["lbrace","brace.l"],["lbrack","bracket.l"],["ldots","dots.h"],["le","lt.eq"],["leadsto","arrow.squiggly"],["leftarrow","arrow.l"],["leftthreetimes","times.three.l"],["leftrightarrow","arrow.l.r"],["leq","lt.eq"],["leqslant","lt.eq.slant"],["lhd","triangle.l"],["ll","lt.double"],["lor","or"],["ltimes","times.l"],["measuredangle","angle.arc"],["mid","divides"],["models","models"],["mp","minus.plus"],["mu","mu"],["nabla","nabla"],["ncong","tilde.equiv.not"],["ne","eq.not"],["neg","not"],["neq","eq.not"],["nexists","exists.not"],["ni","in.rev"],["nleftarrow","arrow.l.not"],["nleq","lt.eq.not"],["nparallel","parallel.not"],["ngeq","gt.eq.not"],["nmid","divides.not"],["notin","in.not"],["nsim","tilde.not"],["nsubseteq","subset.eq.not"],["nu","nu"],["ntriangleleft","lt.tri.not"],["ntriangleright","gt.tri.not"],["nwarrow","arrow.tl"],["odot","dot.circle"],["oint","integral.cont"],["oiint","integral.surf"],["oiiint","integral.vol"],["omega","omega"],["ominus","minus.circle"],["otimes","times.circle"],["parallel","parallel"],["partial","diff"],["perp","perp"],["phi","phi.alt"],["pi","pi"],["pm","plus.minus"],["pounds","pound"],["prec","prec"],["preceq","prec.eq"],["prime","prime"],["prod","product"],["propto","prop"],["psi","psi"],["rangle","angle.r"],["rbrace","brace.r"],["rbrack","bracket.r"],["rhd","triangle"],["rho","rho"],["rightarrow","arrow.r"],["rightthreetimes","times.three.r"],["rtimes","times.r"],["setminus","without"],["sigma","sigma"],["sim","tilde.op"],["simeq","tilde.eq"],["slash","slash"],["smallsetminus","without"],["spadesuit","suit.spade"],["sqcap","sect.sq"],["sqcup","union.sq"],["sqsubseteq","subset.eq.sq"],["sqsupseteq","supset.eq.sq"],["subset","subset"],["subseteq","subset.eq"],["subsetneq","subset.neq"],["succ","succ"],["succeq","succ.eq"],["sum","sum"],["supset","supset"],["supseteq","supset.eq"],["supsetneq","supset.neq"],["swarrow","arrow.bl"],["tau","tau"],["theta","theta"],["times","times"],["to","arrow.r"],["top","top"],["triangle","triangle.t"],["twoheadrightarrow","arrow.r.twohead"],["uparrow","arrow.t"],["updownarrow","arrow.t.b"],["upharpoonright","harpoon.tr"],["uplus","union.plus"],["upsilon","upsilon"],["varepsilon","epsilon"],["varnothing","diameter"],["varphi","phi"],["varpi","pi.alt"],["varrho","rho.alt"],["varsigma","sigma.alt"],["vartheta","theta.alt"],["vdash","tack.r"],["vdots","dots.v"],["vee","or"],["wedge","and"],["wr","wreath"],["xi","xi"],["yen","yen"],["zeta","zeta"],["mathscr","scr"],["LaTeX","#LaTeX"],["TeX","#TeX"]]),A2=new Map([["lparen","paren.l"],["lParen","paren.l.double"],["rparen","paren.r"],["rParen","paren.r.double"],["overparen","paren.t"],["underparen","paren.b"],["lbrace","brace.l"],["lBrace","brace.l.double"],["rbrace","brace.r"],["rBrace","brace.r.double"],["underbrace","brace.b"],["lbrack","bracket.l"],["lBrack","bracket.l.double"],["rbrack","bracket.r"],["rBrack","bracket.r.double"],["overbracket","bracket.t"],["underbracket","bracket.b"],["lbrbrak","shell.l"],["Lbrbrak","shell.l.double"],["rbrbrak","shell.r"],["Rbrbrak","shell.r.double"],["obrbrak","shell.t"],["ubrbrak","shell.b"],["vert","bar.v"],["Vert","bar.v.double"],["Vvert","bar.v.triple"],["circledvert","bar.v.circle"],["horizbar","bar.h"],["lvzigzag","fence.l"],["Lvzigzag","fence.l.double"],["rvzigzag","fence.r"],["Rvzigzag","fence.r.double"],["fourvdots","fence.dotted"],["angle","angle"],["langle","angle.l"],["lcurvyangle","angle.l.curly"],["langledot","angle.l.dot"],["rangle","angle.r"],["rcurvyangle","angle.r.curly"],["rangledot","angle.r.dot"],["angdnr","angle.acute"],["measuredangle","angle.arc"],["measuredangleleft","angle.arc.rev"],["wideangledown","angle.oblique"],["revangle","angle.rev"],["rightangle","angle.right"],["measuredrightangle","angle.right.arc"],["rightanglemdot","angle.right.dot"],["rightanglesqr","angle.right.sq"],["angles","angle.s"],["threedangle","angle.spatial"],["sphericalangle","angle.spheric"],["gtlpar","angle.spheric.rev"],["sphericalangleup","angle.spheric.top"],["lceil","ceil.l"],["rceil","ceil.r"],["lfloor","floor.l"],["rfloor","floor.r"],["mathampersand","amp"],["upand","amp.inv"],["ast","ast.op"],["circledast","ast.circle"],["boxast","ast.square"],["mathatsign","at"],["backslash","backslash"],["obslash","backslash.circle"],["rsolbar","backslash.not"],["mathcolon","colon"],["Colon","colon.double"],["coloneq","colon.eq"],["Coloneq","colon.double.eq"],["mathcomma","comma"],["dagger","dagger"],["ddagger","dagger.double"],["dashcolon","dash.colon"],["circleddash","dash.circle"],["hzigzag","dash.wave.double"],["cdot","dot.op"],["mathperiod","dot.basic"],["cdotp","dot.c"],["odot","dot.circle"],["bigodot","dot.circle.big"],["boxdot","dot.square"],["dddot","dot.triple"],["ddddot","dot.quad"],["mathexclam","excl"],["Exclam","excl.double"],["mathquestion","quest"],["Question","quest.double"],["mathoctothorpe","hash"],["mathpercent","percent"],["mathparagraph","pilcrow"],["mathsection","section"],["mathsemicolon","semi"],["mathslash","slash"],["sslash","slash.double"],["trslash","slash.triple"],["xsol","slash.big"],["unicodecdots","dots.h.c"],["unicodeellipsis","dots.h"],["vdots","dots.v"],["ddots","dots.down"],["adots","dots.up"],["sim","tilde.op"],["dotsim","tilde.dot"],["sime","tilde.eq"],["nsimeq","tilde.eq.not"],["backsimeq","tilde.eq.rev"],["cong","tilde.equiv"],["ncong","tilde.equiv.not"],["simneqq","tilde.nequiv"],["nsim","tilde.not"],["backsim","tilde.rev"],["backcong","tilde.rev.equiv"],["approxident","tilde.triple"],["caretinsert","caret"],["prime","prime"],["backprime","prime.rev"],["dprime","prime.double"],["backdprime","prime.double.rev"],["trprime","prime.triple"],["backtrprime","prime.triple.rev"],["qprime","prime.quad"],["mathplus","plus"],["oplus","plus.circle"],["rightarrowonoplus","plus.circle.arrow"],["bigoplus","plus.circle.big"],["dotplus","plus.dot"],["doubleplus","plus.double"],["pm","plus.minus"],["boxplus","plus.square"],["triangleplus","plus.triangle"],["tripleplus","plus.triple"],["minus","minus"],["ominus","minus.circle"],["dotminus","minus.dot"],["mp","minus.plus"],["boxminus","minus.square"],["eqsim","minus.tilde"],["triangleminus","minus.triangle"],["div","div"],["odiv","div.circle"],["times","times"],["bigtimes","times.big"],["otimes","times.circle"],["bigotimes","times.circle.big"],["divideontimes","times.div"],["leftthreetimes","times.three.l"],["rightthreetimes","times.three.r"],["ltimes","times.l"],["rtimes","times.r"],["boxtimes","times.square"],["triangletimes","times.triangle"],["mathratio","ratio"],["equal","eq"],["stareq","eq.star"],["circledequal","eq.circle"],["eqcolon","eq.colon"],["eqdef","eq.def"],["triangleq","eq.delta"],["veeeq","eq.equi"],["wedgeq","eq.est"],["eqgtr","eq.gt"],["eqless","eq.lt"],["measeq","eq.m"],["ne","eq.not"],["curlyeqprec","eq.prec"],["questeq","eq.quest"],["curlyeqsucc","eq.succ"],["equiv","eq.triple"],["Equiv","eq.quad"],["greater","gt"],["ogreaterthan","gt.circle"],["gtrdot","gt.dot"],["gtrapprox","gt.approx"],["gg","gt.double"],["geq","gt.eq"],["geqslant","gt.eq.slant"],["gtreqless","gt.eq.lt"],["ngeq","gt.eq.not"],["geqq","gt.equiv"],["gtrless","gt.lt"],["ngtrless","gt.lt.not"],["gneq","gt.neq"],["gnapprox","gt.napprox"],["gneqq","gt.nequiv"],["ngtr","gt.not"],["gnsim","gt.ntilde"],["gtrsim","gt.tilde"],["ngtrsim","gt.tilde.not"],["vartriangleright","gt.tri"],["trianglerighteq","gt.tri.eq"],["ntrianglerighteq","gt.tri.eq.not"],["nvartriangleright","gt.tri.not"],["ggg","gt.triple"],["gggnest","gt.triple.nested"],["less","lt"],["olessthan","lt.circle"],["lessdot","lt.dot"],["lessapprox","lt.approx"],["ll","lt.double"],["leq","lt.eq"],["leqslant","lt.eq.slant"],["lesseqgtr","lt.eq.gt"],["nleq","lt.eq.not"],["leqq","lt.equiv"],["lessgtr","lt.gt"],["nlessgtr","lt.gt.not"],["lneq","lt.neq"],["lnapprox","lt.napprox"],["lneqq","lt.nequiv"],["nless","lt.not"],["lnsim","lt.ntilde"],["lesssim","lt.tilde"],["nlesssim","lt.tilde.not"],["vartriangleleft","lt.tri"],["trianglelefteq","lt.tri.eq"],["ntrianglelefteq","lt.tri.eq.not"],["nvartriangleleft","lt.tri.not"],["lll","lt.triple"],["lllnest","lt.triple.nested"],["approx","approx"],["approxeq","approx.eq"],["napprox","approx.not"],["prec","prec"],["precapprox","prec.approx"],["preccurlyeq","prec.curly.eq"],["npreccurlyeq","prec.curly.eq.not"],["Prec","prec.double"],["preceq","prec.eq"],["preceqq","prec.equiv"],["precnapprox","prec.napprox"],["precneq","prec.neq"],["precneqq","prec.nequiv"],["nprec","prec.not"],["precnsim","prec.ntilde"],["precsim","prec.tilde"],["succ","succ"],["succapprox","succ.approx"],["succcurlyeq","succ.curly.eq"],["nsucccurlyeq","succ.curly.eq.not"],["Succ","succ.double"],["succeq","succ.eq"],["succeqq","succ.equiv"],["succnapprox","succ.napprox"],["succneq","succ.neq"],["succneqq","succ.nequiv"],["nsucc","succ.not"],["succnsim","succ.ntilde"],["succsim","succ.tilde"],["nequiv","equiv.not"],["propto","prop"],["origof","original"],["imageof","image"],["varnothing","emptyset"],["emptysetoarr","emptyset.arrow.r"],["emptysetoarrl","emptyset.arrow.l"],["emptysetobar","emptyset.bar"],["emptysetocirc","emptyset.circle"],["revemptyset","emptyset.rev"],["setminus","without"],["complement","complement"],["in","in"],["notin","in.not"],["ni","in.rev"],["nni","in.rev.not"],["smallni","in.rev.small"],["smallin","in.small"],["subset","subset"],["subsetdot","subset.dot"],["Subset","subset.double"],["subseteq","subset.eq"],["nsubseteq","subset.eq.not"],["sqsubseteq","subset.eq.sq"],["nsqsubseteq","subset.eq.sq.not"],["subsetneq","subset.neq"],["nsubset","subset.not"],["sqsubset","subset.sq"],["sqsubsetneq","subset.sq.neq"],["supset","supset"],["supsetdot","supset.dot"],["Supset","supset.double"],["supseteq","supset.eq"],["nsupseteq","supset.eq.not"],["sqsupseteq","supset.eq.sq"],["nsqsupseteq","supset.eq.sq.not"],["supsetneq","supset.neq"],["nsupset","supset.not"],["sqsupset","supset.sq"],["sqsupsetneq","supset.sq.neq"],["cup","union"],["cupleftarrow","union.arrow"],["bigcup","union.big"],["cupdot","union.dot"],["bigcupdot","union.dot.big"],["Cup","union.double"],["uminus","union.minus"],["cupvee","union.or"],["uplus","union.plus"],["biguplus","union.plus.big"],["sqcup","union.sq"],["bigsqcup","union.sq.big"],["Sqcup","union.sq.double"],["cap","sect"],["capwedge","sect.and"],["bigcap","sect.big"],["capdot","sect.dot"],["Cap","sect.double"],["sqcap","sect.sq"],["bigsqcap","sect.sq.big"],["Sqcap","sect.sq.double"],["infty","infinity"],["nvinfty","infinity.bar"],["iinfin","infinity.incomplete"],["tieinfty","infinity.tie"],["partial","diff"],["nabla","gradient"],["sum","sum"],["sumint","sum.integral"],["prod","product"],["coprod","product.co"],["int","integral"],["intlarhk","integral.arrow.hook"],["awint","integral.ccw"],["oint","integral.cont"],["ointctrclockwise","integral.cont.ccw"],["varointclockwise","integral.cont.cw"],["intclockwise","integral.cw"],["intbar","integral.dash"],["intBar","integral.dash.double"],["iint","integral.double"],["iiiint","integral.quad"],["intcap","integral.sect"],["fint","integral.slash"],["sqint","integral.square"],["oiint","integral.surf"],["intx","integral.times"],["iiint","integral.triple"],["intcup","integral.union"],["oiiint","integral.vol"],["increment","laplace"],["forall","forall"],["exists","exists"],["nexists","exists.not"],["top","top"],["bot","bot"],["neg","not"],["wedge","and"],["bigwedge","and.big"],["curlywedge","and.curly"],["wedgedot","and.dot"],["Wedge","and.double"],["vee","or"],["bigvee","or.big"],["curlyvee","or.curly"],["veedot","or.dot"],["Vee","or.double"],["models","models"],["Vdash","forces"],["nVdash","forces.not"],["therefore","therefore"],["because","because"],["QED","qed"],["vysmwhtcircle","compose"],["multimap","multimap"],["dualmap","multimap.double"],["tplus","tiny"],["tminus","miny"],["mid","divides"],["nmid","divides.not"],["wr","wreath"],["parallel","parallel"],["nhpar","parallel.struck"],["circledparallel","parallel.circle"],["equalparallel","parallel.eq"],["equivVert","parallel.equiv"],["nparallel","parallel.not"],["eparsl","parallel.slanted.eq"],["smeparsl","parallel.slanted.eq.tilde"],["eqvparsl","parallel.slanted.equiv"],["parsim","parallel.tilde"],["perp","perp"],["operp","perp.circle"],["diameter","diameter"],["Join","join"],["rightouterjoin","join.r"],["leftouterjoin","join.l"],["fullouterjoin","join.l.r"],["smashtimes","smash"],["mathdollar","dollar"],["euro","euro"],["mathsterling","pound"],["mathyen","yen"],["checkmark","checkmark"],["maltese","maltese"],["clubsuit","suit.club.filled"],["varclubsuit","suit.club.stroked"],["vardiamondsuit","suit.diamond.filled"],["diamondsuit","suit.diamond.stroked"],["varheartsuit","suit.heart.filled"],["heartsuit","suit.heart.stroked"],["spadesuit","suit.spade.filled"],["varspadesuit","suit.spade.stroked"],["quarternote","note.quarter.alt"],["eighthnote","note.eighth.alt"],["twonotes","note.eighth.beamed"],["natural","natural"],["flat","flat"],["sharp","sharp"],["smblkcircle","bullet"],["mdlgwhtcircle","circle.stroked"],["mdsmwhtcircle","circle.stroked.small"],["lgwhtcircle","circle.stroked.big"],["mdlgblkcircle","circle.filled"],["mdsmblkcircle","circle.filled.tiny"],["vysmblkcircle","circle.filled.small"],["lgblkcircle","circle.filled.big"],["dottedcircle","circle.dotted"],["circledcirc","circle.nested"],["whthorzoval","ellipse.stroked.h"],["whtvertoval","ellipse.stroked.v"],["blkhorzoval","ellipse.filled.h"],["blkvertoval","ellipse.filled.v"],["bigtriangleup","triangle.stroked.t"],["bigtriangledown","triangle.stroked.b"],["triangleright","triangle.stroked.r"],["triangleleft","triangle.stroked.l"],["lltriangle","triangle.stroked.bl"],["lrtriangle","triangle.stroked.br"],["ultriangle","triangle.stroked.tl"],["urtriangle","triangle.stroked.tr"],["vartriangle","triangle.stroked.small.t"],["triangledown","triangle.stroked.small.b"],["smalltriangleright","triangle.stroked.small.r"],["smalltriangleleft","triangle.stroked.small.l"],["whiteinwhitetriangle","triangle.stroked.nested"],["trianglecdot","triangle.stroked.dot"],["bigblacktriangleup","triangle.filled.t"],["bigblacktriangledown","triangle.filled.b"],["blacktriangleright","triangle.filled.r"],["blacktriangleleft","triangle.filled.l"],["llblacktriangle","triangle.filled.bl"],["lrblacktriangle","triangle.filled.br"],["ulblacktriangle","triangle.filled.tl"],["urblacktriangle","triangle.filled.tr"],["blacktriangle","triangle.filled.small.t"],["blacktriangledown","triangle.filled.small.b"],["smallblacktriangleright","triangle.filled.small.r"],["smallblacktriangleleft","triangle.filled.small.l"],["mdlgwhtsquare","square.stroked"],["smwhtsquare","square.stroked.tiny"],["mdsmwhtsquare","square.stroked.small"],["mdwhtsquare","square.stroked.medium"],["lgwhtsquare","square.stroked.big"],["dottedsquare","square.stroked.dotted"],["squoval","square.stroked.rounded"],["mdlgblksquare","square.filled"],["smblksquare","square.filled.tiny"],["mdsmblksquare","square.filled.small"],["mdblksquare","square.filled.medium"],["lgblksquare","square.filled.big"],["hrectangle","rect.stroked.h"],["vrectangle","rect.stroked.v"],["hrectangleblack","rect.filled.h"],["vrectangleblack","rect.filled.v"],["pentagon","penta.stroked"],["pentagonblack","penta.filled"],["varhexagon","hexa.stroked"],["varhexagonblack","hexa.filled"],["mdlgwhtdiamond","diamond.stroked"],["smwhtdiamond","diamond.stroked.small"],["mdwhtdiamond","diamond.stroked.medium"],["diamondcdot","diamond.stroked.dot"],["mdlgblkdiamond","diamond.filled"],["mdblkdiamond","diamond.filled.medium"],["smblkdiamond","diamond.filled.small"],["mdlgwhtlozenge","lozenge.stroked"],["smwhtlozenge","lozenge.stroked.small"],["mdwhtlozenge","lozenge.stroked.medium"],["mdlgblklozenge","lozenge.filled"],["smblklozenge","lozenge.filled.small"],["mdblklozenge","lozenge.filled.medium"],["parallelogram","parallelogram.stroked"],["parallelogramblack","parallelogram.filled"],["star","star.op"],["bigwhitestar","star.stroked"],["bigstar","star.filled"],["rightarrow","arrow.r"],["longmapsto","arrow.r.long.bar"],["mapsto","arrow.r.bar"],["rightdowncurvedarrow","arrow.r.curve"],["rightdasharrow","arrow.r.dashed"],["rightdotarrow","arrow.r.dotted"],["Rightarrow","arrow.r.double"],["Mapsto","arrow.r.double.bar"],["Longrightarrow","arrow.r.double.long"],["Longmapsto","arrow.r.double.long.bar"],["nRightarrow","arrow.r.double.not"],["hookrightarrow","arrow.r.hook"],["longrightarrow","arrow.r.long"],["longrightsquigarrow","arrow.r.long.squiggly"],["looparrowright","arrow.r.loop"],["nrightarrow","arrow.r.not"],["RRightarrow","arrow.r.quad"],["rightsquigarrow","arrow.r.squiggly"],["rightarrowbar","arrow.r.stop"],["rightwhitearrow","arrow.r.stroked"],["rightarrowtail","arrow.r.tail"],["similarrightarrow","arrow.r.tilde"],["Rrightarrow","arrow.r.triple"],["twoheadmapsto","arrow.r.twohead.bar"],["twoheadrightarrow","arrow.r.twohead"],["rightwavearrow","arrow.r.wave"],["leftarrow","arrow.l"],["mapsfrom","arrow.l.bar"],["leftdowncurvedarrow","arrow.l.curve"],["leftdasharrow","arrow.l.dashed"],["leftdotarrow","arrow.l.dotted"],["Leftarrow","arrow.l.double"],["Mapsfrom","arrow.l.double.bar"],["Longleftarrow","arrow.l.double.long"],["Longmapsfrom","arrow.l.double.long.bar"],["nLeftarrow","arrow.l.double.not"],["hookleftarrow","arrow.l.hook"],["longleftarrow","arrow.l.long"],["longmapsfrom","arrow.l.long.bar"],["longleftsquigarrow","arrow.l.long.squiggly"],["looparrowleft","arrow.l.loop"],["nleftarrow","arrow.l.not"],["LLeftarrow","arrow.l.quad"],["leftsquigarrow","arrow.l.squiggly"],["barleftarrow","arrow.l.stop"],["leftwhitearrow","arrow.l.stroked"],["leftarrowtail","arrow.l.tail"],["similarleftarrow","arrow.l.tilde"],["Lleftarrow","arrow.l.triple"],["twoheadmapsfrom","arrow.l.twohead.bar"],["twoheadleftarrow","arrow.l.twohead"],["leftwavearrow","arrow.l.wave"],["uparrow","arrow.t"],["mapsup","arrow.t.bar"],["uprightcurvearrow","arrow.t.curve"],["updasharrow","arrow.t.dashed"],["Uparrow","arrow.t.double"],["UUparrow","arrow.t.quad"],["baruparrow","arrow.t.stop"],["upwhitearrow","arrow.t.stroked"],["Uuparrow","arrow.t.triple"],["twoheaduparrow","arrow.t.twohead"],["downarrow","arrow.b"],["mapsdown","arrow.b.bar"],["downrightcurvedarrow","arrow.b.curve"],["downdasharrow","arrow.b.dashed"],["Downarrow","arrow.b.double"],["DDownarrow","arrow.b.quad"],["downarrowbar","arrow.b.stop"],["downwhitearrow","arrow.b.stroked"],["Ddownarrow","arrow.b.triple"],["twoheaddownarrow","arrow.b.twohead"],["leftrightarrow","arrow.l.r"],["Leftrightarrow","arrow.l.r.double"],["Longleftrightarrow","arrow.l.r.double.long"],["nLeftrightarrow","arrow.l.r.double.not"],["longleftrightarrow","arrow.l.r.long"],["nleftrightarrow","arrow.l.r.not"],["leftrightsquigarrow","arrow.l.r.wave"],["updownarrow","arrow.t.b"],["Updownarrow","arrow.t.b.double"],["nearrow","arrow.tr"],["Nearrow","arrow.tr.double"],["hknearrow","arrow.tr.hook"],["searrow","arrow.br"],["Searrow","arrow.br.double"],["hksearrow","arrow.br.hook"],["nwarrow","arrow.tl"],["Nwarrow","arrow.tl.double"],["hknwarrow","arrow.tl.hook"],["swarrow","arrow.bl"],["Swarrow","arrow.bl.double"],["hkswarrow","arrow.bl.hook"],["nwsearrow","arrow.tl.br"],["neswarrow","arrow.tr.bl"],["acwopencirclearrow","arrow.ccw"],["curvearrowleft","arrow.ccw.half"],["cwopencirclearrow","arrow.cw"],["curvearrowright","arrow.cw.half"],["downzigzagarrow","arrow.zigzag"],["rightrightarrows","arrows.rr"],["leftleftarrows","arrows.ll"],["upuparrows","arrows.tt"],["downdownarrows","arrows.bb"],["leftrightarrows","arrows.lr"],["barleftarrowrightarrowbar","arrows.lr.stop"],["rightleftarrows","arrows.rl"],["updownarrows","arrows.tb"],["downuparrows","arrows.bt"],["rightthreearrows","arrows.rrr"],["leftthreearrows","arrows.lll"],["rightharpoonup","harpoon.rt"],["barrightharpoonup","harpoon.rt.bar"],["rightharpoonupbar","harpoon.rt.stop"],["rightharpoondown","harpoon.rb"],["barrightharpoondown","harpoon.rb.bar"],["rightharpoondownbar","harpoon.rb.stop"],["leftharpoonup","harpoon.lt"],["leftharpoonupbar","harpoon.lt.bar"],["barleftharpoonup","harpoon.lt.stop"],["leftharpoondown","harpoon.lb"],["leftharpoondownbar","harpoon.lb.bar"],["barleftharpoondown","harpoon.lb.stop"],["upharpoonleft","harpoon.tl"],["upharpoonleftbar","harpoon.tl.bar"],["barupharpoonleft","harpoon.tl.stop"],["upharpoonright","harpoon.tr"],["upharpoonrightbar","harpoon.tr.bar"],["barupharpoonright","harpoon.tr.stop"],["downharpoonleft","harpoon.bl"],["bardownharpoonleft","harpoon.bl.bar"],["downharpoonleftbar","harpoon.bl.stop"],["downharpoonright","harpoon.br"],["bardownharpoonright","harpoon.br.bar"],["downharpoonrightbar","harpoon.br.stop"],["leftrightharpoonupup","harpoon.lt.rt"],["leftrightharpoondowndown","harpoon.lb.rb"],["leftrightharpoondownup","harpoon.lb.rt"],["leftrightharpoonupdown","harpoon.lt.rb"],["updownharpoonleftleft","harpoon.tl.bl"],["updownharpoonrightright","harpoon.tr.br"],["updownharpoonleftright","harpoon.tl.br"],["updownharpoonrightleft","harpoon.tr.bl"],["rightharpoonsupdown","harpoons.rtrb"],["downharpoonsleftright","harpoons.blbr"],["downupharpoonsleftright","harpoons.bltr"],["leftrightharpoonsdown","harpoons.lbrb"],["leftharpoonsupdown","harpoons.ltlb"],["leftrightharpoons","harpoons.ltrb"],["leftrightharpoonsup","harpoons.ltrt"],["rightleftharpoonsdown","harpoons.rblb"],["rightleftharpoons","harpoons.rtlb"],["rightleftharpoonsup","harpoons.rtlt"],["updownharpoonsleftright","harpoons.tlbr"],["upharpoonsleftright","harpoons.tltr"],["vdash","tack.r"],["nvdash","tack.r.not"],["vlongdash","tack.r.long"],["assert","tack.r.short"],["vDash","tack.r.double"],["nvDash","tack.r.double.not"],["dashv","tack.l"],["longdashv","tack.l.long"],["shortlefttack","tack.l.short"],["Dashv","tack.l.double"],["bigbot","tack.t.big"],["Vbar","tack.t.double"],["shortuptack","tack.t.short"],["bigtop","tack.b.big"],["barV","tack.b.double"],["shortdowntack","tack.b.short"],["dashVdash","tack.l.r"],["BbbA","AA"],["BbbB","BB"],["BbbC","CC"],["BbbD","DD"],["BbbE","EE"],["BbbF","FF"],["BbbG","GG"],["BbbH","HH"],["BbbI","II"],["BbbJ","JJ"],["BbbK","KK"],["BbbL","LL"],["BbbM","MM"],["BbbN","NN"],["BbbO","OO"],["BbbP","PP"],["BbbQ","QQ"],["BbbR","RR"],["BbbS","SS"],["BbbT","TT"],["BbbU","UU"],["BbbV","VV"],["BbbW","WW"],["BbbX","XX"],["BbbY","YY"],["BbbZ","ZZ"],["ell","ell"],["Planckconst","planck"],["hslash","planck.reduce"],["Angstrom","angstrom"],["Re","Re"],["Im","Im"],["imath","dotless.i"],["jmath","dotless.j"]]);for(let[q,J]of A2)if(!I.has(q))I.set(q,J);var w=new Map;for(let[q,J]of Array.from(I.entries()).reverse())w.set(J,q);w.set("dif","mathrm{d}");var B2=new Map([["top","top"],["frac","frac"],["tilde","tilde"],["hat","hat"],["upright","mathrm"],["bold","boldsymbol"],["hyph.minus","\\text{-}"]]);for(let[q,J]of B2)w.set(q,J);function d(q,J,z=0){for(let V=z;V<q.length;V++)if(q[V].eq(J))return V;return-1}function P(q,J){for(let z of q)if(z.eq(J))return!0;return!1}function a(q,J){let z=[],V=[];for(let Z of q)if(Z.eq(J))z.push(V),V=[];else V.push(Z);return z.push(V),z}class W{type;value;constructor(q,J){this.type=q,this.value=J}eq(q){return this.type===q.type&&this.value===q.value}toString(){switch(this.type){case 2:return`\\text{${this.value}}`;case 3:return`%${this.value}`;default:return this.value}}}function I2(q){if(["{","}","%"].includes(q))return"\\"+q;return q}class Q{type;content;args;data;constructor(q,J,z,V){this.type=q,this.content=J,this.args=z,this.data=V}eq(q){return this.type===q.type&&this.content===q.content}toString(){switch(this.type){case"text":return`\\text{${this.content}}`;default:throw new Error(`toString() is not implemented for type ${this.type}`)}}serialize(){switch(this.type){case"empty":return[];case"element":{let q=this.content;return q=I2(q),[new W(0,q)]}case"symbol":return[new W(1,this.content)];case"text":return[new W(2,this.content)];case"comment":return[new W(3,this.content)];case"whitespace":{let q=[];for(let J of this.content){let z=J===" "?4:5;q.push(new W(z,J))}return q}case"ordgroup":return this.args.map((q)=>q.serialize()).flat();case"unaryFunc":{let q=[];if(q.push(new W(1,this.content)),this.content==="\\sqrt"&&this.data)q.push(new W(0,"[")),q=q.concat(this.data.serialize()),q.push(new W(0,"]"));if(this.content==="\\operatorname"&&this.args.length===1&&this.args[0].type==="text"){let J=this.args[0].content;return q.push(new W(0,"{")),q.push(new W(1,J)),q.push(new W(0,"}")),q}return q.push(new W(0,"{")),q=q.concat(this.args[0].serialize()),q.push(new W(0,"}")),q}case"binaryFunc":{let q=[];return q.push(new W(1,this.content)),q.push(new W(0,"{")),q=q.concat(this.args[0].serialize()),q.push(new W(0,"}")),q.push(new W(0,"{")),q=q.concat(this.args[1].serialize()),q.push(new W(0,"}")),q}case"supsub":{let Z=function(X){if(X.type==="ordgroup"||X.type==="supsub"||X.type==="empty")return!0;else if(X.type==="element"&&/\d+(\.\d+)?/.test(X.content)&&X.content.length>1)return!0;else return!1},q=[],{base:J,sup:z,sub:V}=this.data;if(q=q.concat(J.serialize()),V)if(q.push(new W(6,"_")),Z(V))q.push(new W(0,"{")),q=q.concat(V.serialize()),q.push(new W(0,"}"));else q=q.concat(V.serialize());if(z)if(q.push(new W(6,"^")),Z(z))q.push(new W(0,"{")),q=q.concat(z.serialize()),q.push(new W(0,"}"));else q=q.concat(z.serialize());return q}case"control":return[new W(6,this.content)];case"beginend":{let q=[],J=this.data;q.push(new W(1,`\\begin{${this.content}}`)),q.push(new W(5,` | ||
`));for(let z=0;z<J.length;z++){let V=J[z];for(let Z=0;Z<V.length;Z++){let X=V[Z];if(q=q.concat(X.serialize()),Z!==V.length-1)q.push(new W(6,"&"))}if(z!==J.length-1)q.push(new W(6,"\\\\"))}return q.push(new W(5,` | ||
`)),q.push(new W(1,`\\end{${this.content}}`)),q}default:throw new Error("[TexNode.serialize] Unimplemented type: "+this.type)}}}class K{type;value;constructor(q,J){this.type=q,this.value=J}eq(q){return this.type===q.type&&this.value===q.value}isOneOf(q){return P(q,this)}toNode(){switch(this.type){case 2:return new j("text",this.value);case 3:return new j("comment",this.value);case 4:case 7:return new j("whitespace",this.value);case 1:return new j("atom",this.value);case 0:return new j("symbol",this.value);case 6:{let q=this.value;switch(q){case"":case"_":case"^":return new j("empty","");case"&":return new j("control","&");case"\\":return new j("control","\\");default:throw new Error(`Unexpected control character ${q}`)}}default:throw new Error(`Unexpected token type ${this.type}`)}}toString(){switch(this.type){case 2:return`"${this.value}"`;case 3:return`//${this.value}`;default:return this.value}}}class j{type;content;args;data;options;constructor(q,J,z,V){this.type=q,this.content=J,this.args=z,this.data=V}setOptions(q){this.options=q}eq(q){return this.type===q.type&&this.content===q.content}}function v(q){return"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(q)}function f(q){return"0123456789".includes(q)}function O(q,J=""){if(!q)throw new Error(J)}var R2=["sqrt","text","bar","bold","boldsymbol","ddot","dot","hat","mathbb","mathbf","mathcal","mathfrak","mathit","mathrm","mathscr","mathsf","mathtt","operatorname","overbrace","overline","pmb","rm","tilde","underbrace","underline","vec","widehat","widetilde"],S2=["frac","tfrac","binom","dbinom","dfrac","tbinom","overset"],k=new Q("empty","");function v2(q){if(R2.includes(q))return 1;else if(S2.includes(q))return 2;else return 0}var u=new W(6,"{"),N=new W(6,"}"),z2=new W(0,"["),f2=new W(0,"]");function p(q,J){let z=J;while(z<q.length&&[4,5].includes(q[z].type))z++;return q.slice(J,z)}function J2(q,J){let z=q[J];if(z.type===0&&["(",")","[","]","|","\\{","\\}","."].includes(z.value))return z;else if(z.type===1&&["lfloor","rfloor","lceil","rceil","langle","rangle"].includes(z.value.slice(1)))return z;else return null}function h(q,J){let z=J;while(z<q.length&&q[z].eq(new W(0,"'")))z+=1;return z-J}function C2(q,J){let z=J;while(z<q.length&&v(q[z]))z+=1;return q.substring(J,z)}function m(q,J,z,V){O(q[J].eq(z));let Z=1,X=J+1;while(Z>0){if(X>=q.length)return-1;if(q[X].eq(z))Z+=1;else if(q[X].eq(V))Z-=1;X+=1}return X-1}var T=new W(1,"\\left"),b2=new W(1,"\\right");function L2(q,J){return m(q,J,T,b2)}var r=new W(1,"\\begin"),w2=new W(1,"\\end");function h2(q,J){return m(q,J,r,w2)}function g2(q,J){O(q[J]==="{");let z=1,V=J+1;while(z>0){if(V>=q.length)throw new H("Unmatched curly brackets");if(V+1<q.length&&["\\{","\\}"].includes(q.substring(V,V+2))){V+=2;continue}if(q[V]==="{")z+=1;else if(q[V]==="}")z-=1;V+=1}return V-1}function V2(q){let J=[],z=0;while(z<q.length){let V=q[z],Z;switch(V){case"%":{let X=z+1;while(X<q.length&&q[X]!==` | ||
`)X+=1;Z=new W(3,q.slice(z+1,X)),z=X;break}case"{":case"}":case"_":case"^":case"&":Z=new W(6,V),z++;break;case` | ||
`:Z=new W(5,V),z++;break;case"\r":{if(z+1<q.length&&q[z+1]===` | ||
`)Z=new W(5,` | ||
`),z+=2;else Z=new W(5,` | ||
`),z++;break}case" ":{let X=z;while(X<q.length&&q[X]===" ")X+=1;Z=new W(4,q.slice(z,X)),z=X;break}case"\\":{if(z+1>=q.length)throw new H("Expecting command name after \\");let X=q.slice(z,z+2);if(["\\\\","\\,"].includes(X))Z=new W(6,X);else if(["\\{","\\}","\\%","\\$","\\&","\\#","\\_","\\|"].includes(X))Z=new W(0,X);else{let $=C2(q,z+1);Z=new W(1,"\\"+$)}z+=Z.value.length;break}default:{if(f(V)){let X=z;while(X<q.length&&f(q[X]))X+=1;Z=new W(0,q.slice(z,X))}else if(v(V))Z=new W(0,V);else if("+-*/='<>!.,;:?()[]|".includes(V))Z=new W(0,V);else Z=new W(7,V);z+=Z.value.length}}if(J.push(Z),Z.type===1&&["\\text","\\operatorname","\\begin","\\end"].includes(Z.value)){if(z>=q.length||q[z]!=="{")throw new H(`No content for ${Z.value} command`);J.push(new W(6,"{"));let X=g2(q,z);z++;let $=q.slice(z,X),G=["{","}","\\","$","&","#","_","%"];for(let F of G)$=$.replaceAll("\\"+F,F);J.push(new W(2,$)),J.push(new W(6,"}")),z=X+1}}return J}class H extends Error{constructor(q){super(q);this.name="LatexParserError"}}var n=new W(6,"_"),t=new W(6,"^");class X2{space_sensitive;newline_sensitive;constructor(q=!1,J=!0){this.space_sensitive=q,this.newline_sensitive=J}parse(q){let J=[],z=0;while(z<q.length){let V=[],Z=0;while(Z<q.length){let[X,$]=this.parseNextExpr(q,Z);if(Z=$,X.type==="whitespace"){if(!this.space_sensitive&&X.content.replace(/ /g,"").length===0)continue;if(!this.newline_sensitive&&X.content===` | ||
`)continue}if(X.type==="control"&&X.content==="&")throw new H("Unexpected & outside of an alignment");V.push(X)}if(V.length===0)return k;else if(V.length===1)return V[0];else return new Q("ordgroup","",V)}if(J.length===0)return k;else if(J.length===1)return J[0];else return new Q("ordgroup","",J)}parseNextExpr(q,J){let[z,V]=this.parseNextExprWithoutSupSub(q,J),Z=null,X=null,$=0;if($+=h(q,V),V+=$,V<q.length&&q[V].eq(n)){if([Z,V]=this.parseNextExprWithoutSupSub(q,V+1),$+=h(q,V),V+=$,V<q.length&&q[V].eq(t)){if([X,V]=this.parseNextExprWithoutSupSub(q,V+1),h(q,V)>0)throw new H("Double superscript")}}else if(V<q.length&&q[V].eq(t)){if([X,V]=this.parseNextExprWithoutSupSub(q,V+1),h(q,V)>0)throw new H("Double superscript");if(V<q.length&&q[V].eq(n)){if([Z,V]=this.parseNextExprWithoutSupSub(q,V+1),h(q,V)>0)throw new H("Double superscript")}}if(Z!==null||X!==null||$>0){let G={base:z};if(Z)G.sub=Z;if($>0){G.sup=new Q("ordgroup","",[]);for(let F=0;F<$;F++)G.sup.args.push(new Q("element","'"));if(X)G.sup.args.push(X);if(G.sup.args.length===1)G.sup=G.sup.args[0]}else if(X)G.sup=X;return[new Q("supsub","",[],G),V]}else return[z,V]}parseNextExprWithoutSupSub(q,J){let z=q[J];switch(z.type){case 0:return[new Q("element",z.value),J+1];case 2:return[new Q("text",z.value),J+1];case 3:return[new Q("comment",z.value),J+1];case 4:case 5:return[new Q("whitespace",z.value),J+1];case 1:if(z.eq(r))return this.parseBeginEndExpr(q,J);else if(z.eq(T))return this.parseLeftRightExpr(q,J);else return this.parseCommandExpr(q,J);case 6:switch(z.value){case"{":let X=m(q,J,u,N);if(X===-1)throw new H("Unmatched '{'");let $=q.slice(J+1,X);return[this.parse($),X+1];case"}":throw new H("Unmatched '}'");case"\\\\":return[new Q("control","\\\\"),J+1];case"\\,":return[new Q("control","\\,"),J+1];case"_":case"^":return[k,J];case"&":return[new Q("control","&"),J+1];default:throw new H("Unknown control sequence")}default:throw new H("Unknown token type")}}parseCommandExpr(q,J){O(q[J].type===1);let z=q[J].value,V=J+1;if(["left","right","begin","end"].includes(z.slice(1)))throw new H("Unexpected command: "+z);switch(v2(z.slice(1))){case 0:if(!I.has(z.slice(1)))return[new Q("unknownMacro",z),V];return[new Q("symbol",z),V];case 1:{if(V>=q.length)throw new H("Expecting argument for "+z);if(z==="\\sqrt"&&V<q.length&&q[V].eq(z2)){let G=V,F=m(q,V,z2,f2);if(F===-1)throw new H("No matching right square bracket for [");let U=q.slice(G+1,F),D=this.parse(U),[L,R]=this.parseNextExprWithoutSupSub(q,F+1);return[new Q("unaryFunc",z,[L],D),R]}else if(z==="\\text"){if(V+2>=q.length)throw new H("Expecting content for \\text command");O(q[V].eq(u)),O(q[V+1].type===2),O(q[V+2].eq(N));let G=q[V+1].value;return[new Q("text",G),V+3]}let[X,$]=this.parseNextExprWithoutSupSub(q,V);return[new Q("unaryFunc",z,[X]),$]}case 2:{let[X,$]=this.parseNextExprWithoutSupSub(q,V),[G,F]=this.parseNextExprWithoutSupSub(q,$);return[new Q("binaryFunc",z,[X,G]),F]}default:throw new Error("Invalid number of parameters")}}parseLeftRightExpr(q,J){O(q[J].eq(T));let z=J+1;if(z+=p(q,z).length,z>=q.length)throw new H("Expecting delimiter after \\left");let V=J2(q,z);if(V===null)throw new H("Invalid delimiter after \\left");z++;let Z=z,X=L2(q,J);if(X===-1)throw new H("No matching \\right");let $=X;if(z=X+1,z+=p(q,z).length,z>=q.length)throw new H("Expecting \\right after \\left");let G=J2(q,z);if(G===null)throw new H("Invalid delimiter after \\right");z++;let F=q.slice(Z,$),U=this.parse(F),D=[new Q("element",V.value),U,new Q("element",G.value)];return[new Q("leftright","",D),z]}parseBeginEndExpr(q,J){O(q[J].eq(r));let z=J+1;O(q[z].eq(u)),O(q[z+1].type===2),O(q[z+2].eq(N));let V=q[z+1].value;z+=3,z+=p(q,z).length;let Z=z,X=h2(q,J);if(X===-1)throw new H("No matching \\end");let $=X;if(z=X+1,O(q[z].eq(u)),O(q[z+1].type===2),O(q[z+2].eq(N)),q[z+1].value!==V)throw new H("Mismatched \\begin and \\end environments");z+=3;let G=q.slice(Z,$);while(G.length>0&&[4,5].includes(G[G.length-1].type))G.pop();let F=this.parseAligned(G);return[new Q("beginend",V,[],F),z]}parseAligned(q){let J=0,z=[],V=[];z.push(V);let Z=new Q("ordgroup","",[]);V.push(Z);while(J<q.length){let[X,$]=this.parseNextExpr(q,J);if(J=$,X.type==="whitespace"){if(!this.space_sensitive&&X.content.replace(/ /g,"").length===0)continue;if(!this.newline_sensitive&&X.content===` | ||
`)continue}if(X.type==="control"&&X.content==="\\\\")V=[],Z=new Q("ordgroup","",[]),V.push(Z),z.push(V);else if(X.type==="control"&&X.content==="&")Z=new Q("ordgroup","",[]),V.push(Z);else Z.args.push(X)}return z}}function E2(q){let J=(V)=>V.eq(n)||V.eq(t),z=[];for(let V=0;V<q.length;V++){if(q[V].type===4&&V+1<q.length&&J(q[V+1]))continue;if(q[V].type===4&&V-1>=0&&J(q[V-1]))continue;z.push(q[V])}return z}function P2(q,J){let z=[];for(let V of q)if(V.type===1&&J[V.value]){let Z=V2(J[V.value]);z=z.concat(Z)}else z.push(V);return z}function Z2(q,J){let z=new X2,V=V2(q);return V=E2(V),V=P2(V,J),z.parse(V)}var N2=["dim","id","im","mod","Pr","sech","csch"];function $2(q){return q.type==="atom"&&["(",")","[","]","{","}","|","⌊","⌋","⌈","⌉"].includes(q.content)}function m2(q){let[J,z]=q.args,V=($)=>{if($.eq(new Q("text","def")))return!0;if($.type==="ordgroup"&&$.args.length===3){let[G,F,U]=$.args,D=new Q("element","d"),L=new Q("element","e"),R=new Q("element","f");if(G.eq(D)&&F.eq(L)&&U.eq(R))return!0}return!1},Z=($)=>$.eq(new Q("element","="));if(V(J)&&Z(z))return new j("symbol","eq.def");let X=new j("funcCall","op",[Y(z)]);return X.setOptions({limits:"#true"}),new j("supsub","",[],{base:X,sup:Y(J)})}var s=new K(1,"("),l=new K(1,")"),l2=new K(1,","),c2=new K(0,` | ||
`);class C extends Error{node;constructor(q,J){super(q);this.name="TypstWriterError",this.node=J}}class o{nonStrict;preferTypstIntrinsic;keepSpaces;buffer="";queue=[];insideFunctionDepth=0;constructor(q,J,z){this.nonStrict=q,this.preferTypstIntrinsic=J,this.keepSpaces=z}writeBuffer(q){let J=q.toString();if(J==="")return;let z=!1;if(z||=/[\(\[\|]$/.test(this.buffer)&&/^\w/.test(J),z||=/^[})\]\|]$/.test(J),z||=/^[(_^,;!]$/.test(J),z||=J==="'",z||=/[0-9]$/.test(this.buffer)&&/^[0-9]/.test(J),z||=/[\(\[{]\s*(-|\+)$/.test(this.buffer)||this.buffer==="-"||this.buffer==="+",z||=J.startsWith(` | ||
`),z||=this.buffer==="",z||=/^\s/.test(J),z||=this.buffer.endsWith("&")&&J==="=",z||=/[\s_^{\(]$/.test(this.buffer),!z)this.buffer+=" ";this.buffer+=J}serialize(q){switch(q.type){case"empty":break;case"atom":{if(q.content===","&&this.insideFunctionDepth>0)this.queue.push(new K(0,"comma"));else this.queue.push(new K(1,q.content));break}case"symbol":this.queue.push(new K(0,q.content));break;case"text":this.queue.push(new K(2,q.content));break;case"comment":this.queue.push(new K(3,q.content));break;case"whitespace":for(let J of q.content)if(J===" "){if(this.keepSpaces)this.queue.push(new K(4,J))}else if(J===` | ||
`)this.queue.push(new K(0,J));else throw new C(`Unexpected whitespace character: ${J}`,q);break;case"group":for(let J of q.args)this.serialize(J);break;case"supsub":{let{base:J,sup:z,sub:V}=q.data;this.appendWithBracketsIfNeeded(J);let Z=!1,X=z&&z.type==="atom"&&z.content==="'";if(X)this.queue.push(new K(1,"'")),Z=!1;if(V)this.queue.push(new K(1,"_")),Z=this.appendWithBracketsIfNeeded(V);if(z&&!X)this.queue.push(new K(1,"^")),Z=this.appendWithBracketsIfNeeded(z);if(Z)this.queue.push(new K(6," "));break}case"funcCall":{let J=new K(0,q.content);this.queue.push(J),this.insideFunctionDepth++,this.queue.push(s);for(let z=0;z<q.args.length;z++)if(this.serialize(q.args[z]),z<q.args.length-1)this.queue.push(new K(1,","));if(q.options)for(let[z,V]of Object.entries(q.options))this.queue.push(new K(0,`, ${z}: ${V}`));this.queue.push(l),this.insideFunctionDepth--;break}case"align":{let J=q.data;J.forEach((z,V)=>{if(z.forEach((Z,X)=>{if(X>0)this.queue.push(new K(1,"&"));this.serialize(Z)}),V<J.length-1)this.queue.push(new K(0,"\\"))});break}case"matrix":{let J=q.data;if(this.queue.push(new K(0,"mat")),this.insideFunctionDepth++,this.queue.push(s),q.options)for(let[z,V]of Object.entries(q.options))this.queue.push(new K(0,`${z}: ${V}, `));J.forEach((z,V)=>{z.forEach((Z,X)=>{if(this.serialize(Z),X<z.length-1)this.queue.push(new K(1,","));else if(V<J.length-1)this.queue.push(new K(1,";"))})}),this.queue.push(l),this.insideFunctionDepth--;break}case"unknown":{if(this.nonStrict)this.queue.push(new K(0,q.content));else throw new C(`Unknown macro: ${q.content}`,q);break}default:throw new C(`Unimplemented node type to append: ${q.type}`,q)}}appendWithBracketsIfNeeded(q){let J=["group","supsub","empty"].includes(q.type);if(q.type==="group"){let z=q.args[0],V=q.args[q.args.length-1];if($2(z)&&$2(V))J=!1}if(J)this.queue.push(s),this.serialize(q),this.queue.push(l);else this.serialize(q);return!J}flushQueue(){let q=new K(6," ");for(let J=0;J<this.queue.length;J++)if(this.queue[J].eq(q)){if(J===this.queue.length-1)this.queue[J].value="";else if(this.queue[J+1].isOneOf([l,l2,c2]))this.queue[J].value=""}this.queue.forEach((J)=>{this.writeBuffer(J)}),this.queue=[]}finalize(){this.flushQueue();let V=[function(Z){let X=Z.replace(/floor\.l\s*(.*?)\s*floor\.r/g,"floor($1)");return X=X.replace(/floor\(\)/g,'floor("")'),X},function(Z){let X=Z.replace(/ceil\.l\s*(.*?)\s*ceil\.r/g,"ceil($1)");return X=X.replace(/ceil\(\)/g,'ceil("")'),X},function(Z){let X=Z.replace(/floor\.l\s*(.*?)\s*ceil\.r/g,"round($1)");return X=X.replace(/round\(\)/g,'round("")'),X}];for(let Z of V)this.buffer=Z(this.buffer);return this.buffer}}function Y(q){switch(q.type){case"empty":return new j("empty","");case"whitespace":return new j("whitespace",q.content);case"ordgroup":return new j("group","",q.args.map(Y));case"element":return new j("atom",g(q.content));case"symbol":return new j("symbol",g(q.content));case"text":return new j("text",q.content);case"comment":return new j("comment",q.content);case"supsub":{let{base:J,sup:z,sub:V}=q.data;if(J&&J.type==="unaryFunc"&&J.content==="\\overbrace"&&z)return new j("funcCall","overbrace",[Y(J.args[0]),Y(z)]);else if(J&&J.type==="unaryFunc"&&J.content==="\\underbrace"&&V)return new j("funcCall","underbrace",[Y(J.args[0]),Y(V)]);let Z={base:Y(J)};if(Z.base.type==="empty")Z.base=new j("text","");if(z)Z.sup=Y(z);if(V)Z.sub=Y(V);return new j("supsub","",[],Z)}case"leftright":{let[J,z,V]=q.args,Z=new j("group","",q.args.map(Y));if(["[]","()","\\{\\}","\\lfloor\\rfloor","\\lceil\\rceil","\\lfloor\\rceil"].includes(J.content+V.content))return Z;if(V.content===".")return Z.args.pop(),Z;else if(J.content===".")return Z.args.shift(),new j("funcCall","lr",[Z]);return new j("funcCall","lr",[Z])}case"binaryFunc":{if(q.content==="\\overset")return m2(q);return new j("funcCall",g(q.content),q.args.map(Y))}case"unaryFunc":{let J=Y(q.args[0]);if(q.content==="\\sqrt"&&q.data){let z=Y(q.data);return new j("funcCall","root",[z,J])}if(q.content==="\\mathbf"){let z=new j("funcCall","bold",[J]);return new j("funcCall","upright",[z])}if(q.content==="\\mathbb"&&J.type==="atom"&&/^[A-Z]$/.test(J.content))return new j("symbol",J.content+J.content);if(q.content==="\\operatorname"){let z=q.args;if(z.length!==1||z[0].type!=="text")throw new C("Expecting body of \\operatorname to be text but got",q);let V=z[0].content;if(N2.includes(V))return new j("symbol",V);else return new j("funcCall","op",[new j("text",V)])}return new j("funcCall",g(q.content),q.args.map(Y))}case"beginend":{let z=q.data.map((V)=>V.map(Y));if(q.content.startsWith("align"))return new j("align","",[],z);else{let V=new j("matrix","",[],z);return V.setOptions({delim:"#none"}),V}}case"unknownMacro":return new j("unknown",g(q.content));case"control":if(q.content==="\\\\")return new j("symbol","\\");else if(q.content==="\\,")return new j("symbol","thin");else throw new C(`Unknown control sequence: ${q.content}`,q);default:throw new C(`Unimplemented node type: ${q.type}`,q)}}function g(q){if(/^[a-zA-Z0-9]$/.test(q))return q;else if(q==="/")return"\\/";else if(q==="\\|")return"parallel";else if(q==="\\\\")return"\\";else if(["\\$","\\#","\\&","\\_"].includes(q))return q;else if(q.startsWith("\\")){let J=q.slice(1);if(I.has(J))return I.get(J);else return J}return q}function Q2(q,J){let z=J;while(z<q.length&&q[z].eq(new K(1,"'")))z+=1;return z-J}function i2(q,J){let z=J;while(z<q.length&&(v(q[z])||q[z]==="."))z+=1;return q.substring(J,z)}var i=new j("empty","");function x2(q){let J=[],z=0;while(z<q.length){let V=q[z],Z;switch(V){case"_":case"^":case"&":Z=new K(6,V),z++;break;case` | ||
`:Z=new K(7,V),z++;break;case"\r":{if(z+1<q.length&&q[z+1]===` | ||
`)Z=new K(7,` | ||
`),z+=2;else Z=new K(7,` | ||
`),z++;break}case" ":{let X=z;while(X<q.length&&q[X]===" ")X++;Z=new K(4,q.substring(z,X)),z=X;break}case"/":{if(z<q.length&&q[z+1]==="/"){let X=z+2;while(X<q.length&&q[X]!==` | ||
`)X++;Z=new K(3,q.slice(z+2,X)),z=X}else Z=new K(1,"/"),z++;break}case"\\":{if(z+1>=q.length)throw new Error("Expecting a character after \\");let X=q.substring(z,z+2);if(["\\$","\\&","\\#","\\_"].includes(X))Z=new K(1,X),z+=2;else if(["\\\n","\\ "].includes(X))Z=new K(6,"\\"),z+=1;else Z=new K(6,""),z++;break}case'"':{let X=z+1;while(X<q.length){if(q[X]==='"'&&q[X-1]!=="\\")break;X++}let $=q.substring(z+1,X),G=['"',"\\"];for(let F of G)$=$.replaceAll("\\"+F,F);Z=new K(2,$),z=X+1;break}default:{if(f(V)){let X=z;while(X<q.length&&f(q[X]))X+=1;if(X<q.length&&q[X]==="."){X+=1;while(X<q.length&&f(q[X]))X+=1}Z=new K(1,q.slice(z,X))}else if("+-*/='<>!.,;?()[]|".includes(V))Z=new K(1,V);else if(v(V)){let X=i2(q,z),$=X.length===1?1:0;Z=new K($,X)}else Z=new K(1,V);z+=Z.value.length}}J.push(Z)}return J}function c(q,J){O(q[J].isOneOf([E,K2,F2]));let z=1,V=J+1;while(z>0){if(V>=q.length)throw new Error("Unmatched brackets");if(q[V].isOneOf([E,K2,F2]))z+=1;else if(q[V].isOneOf([a2,k2,p2]))z-=1;V+=1}return V-1}function _2(q,J){let z=new j("atom","("),V=new j("atom",")");O(q[J].eq(z));let Z=1,X=J+1;while(Z>0){if(X>=q.length)throw new Error("Unmatched brackets");if(q[X].eq(z))Z+=1;else if(q[X].eq(V))Z-=1;X+=1}return X-1}function j2(q){let J=[];for(let z=0;z<q;z++)J.push(new j("atom","'"));return J}var x=new j("atom","/");function y2(q,J){let z=J;while(z<q.length&&q[z].type==="whitespace")z++;return z===q.length?i:q[z]}function d2(q){let J=!1,z=[];for(let V=0;V<q.length;V++){let Z=q[V];if(Z.type==="whitespace"){if(J)continue;if(y2(q,V+1).eq(x))continue}if(Z.eq(x))J=!0;else J=!1;z.push(Z)}return z}function e(q,J=!1){q=d2(q);let z=new j("atom","("),V=new j("atom",")"),Z=[],X=[],$=0;while($<q.length){let G=q[$];if(G.eq(V))throw new b("Unexpected ')'");else if(G.eq(x))Z.push(G),$++;else{let F;if(G.eq(z)){let U=_2(q,$);F=e(q.slice($+1,U),!0),$=U+1}else F=G,$++;if(Z.length>0&&Z[Z.length-1].eq(x)){let U=F;if(X.length===0)throw new b("Unexpected '/' operator, no numerator before it");let D=X.pop();if(U.type==="group"&&U.content==="parenthesis")U.content="";if(D.type==="group"&&D.content==="parenthesis")D.content="";X.push(new j("fraction","",[D,U])),Z.pop()}else X.push(F)}}if(J)return new j("group","parenthesis",X);else if(X.length===0)return i;else if(X.length===1)return X[0];else return new j("group","",X)}class b extends Error{constructor(q){super(q);this.name="TypstParserError"}}var W2=new K(6,"_"),G2=new K(6,"^"),E=new K(1,"("),a2=new K(1,")"),K2=new K(1,"["),k2=new K(1,"]"),F2=new K(1,"{"),p2=new K(1,"}"),T2=new K(1,","),r2=new K(1,";"),n2=new K(4," ");class H2{space_sensitive;newline_sensitive;constructor(q=!0,J=!0){this.space_sensitive=q,this.newline_sensitive=J}parse(q){let[J,z]=this.parseGroup(q,0,q.length);return J}parseGroup(q,J,z,V=!1){let Z=[],X=J;while(X<z){let[G,F]=this.parseNextExpr(q,X);if(X=F,G.type==="whitespace"){if(!this.space_sensitive&&G.content.replace(/ /g,"").length===0)continue;if(!this.newline_sensitive&&G.content===` | ||
`)continue}Z.push(G)}let $;if(V)$=e(Z,!0);else if(Z.length===0)$=i;else if(Z.length===1)$=Z[0];else $=e(Z);return[$,z+1]}parseNextExpr(q,J){let[z,V]=this.parseNextExprWithoutSupSub(q,J),Z=null,X=null,$=Q2(q,V);if($>0)z=new j("group","",[z].concat(j2($))),V+=$;if(V<q.length&&q[V].eq(W2)){if([Z,V]=this.parseSupOrSub(q,V+1),V<q.length&&q[V].eq(G2))[X,V]=this.parseSupOrSub(q,V+1)}else if(V<q.length&&q[V].eq(G2)){if([X,V]=this.parseSupOrSub(q,V+1),V<q.length&&q[V].eq(W2))[Z,V]=this.parseSupOrSub(q,V+1)}if(Z!==null||X!==null){let G={base:z};if(Z)G.sub=Z;if(X)G.sup=X;return[new j("supsub","",[],G),V]}else return[z,V]}parseSupOrSub(q,J){let z,V;if(q[J].eq(E)){let X=c(q,J);[z,V]=this.parseGroup(q,J+1,X)}else[z,V]=this.parseNextExprWithoutSupSub(q,J);let Z=Q2(q,V);if(Z>0)z=new j("group","",[z].concat(j2(Z))),V+=Z;return[z,V]}parseNextExprWithoutSupSub(q,J){let z=q[J],V=z.toNode();if(z.eq(E)){let Z=c(q,J);return this.parseGroup(q,J+1,Z,!0)}if(z.type===1&&!v(z.value[0]))return[V,J+1];if([1,0].includes(z.type)){if(J+1<q.length&&q[J+1].eq(E)){if(z.value==="mat"){let[G,F,U]=this.parseGroupsOfArguments(q,J+1),D=new j("matrix","",[],G);return D.setOptions(F),[D,U]}let[Z,X]=this.parseArguments(q,J+1),$=new j("funcCall",z.value);return $.args=Z,[$,X]}}return[V,J+1]}parseArguments(q,J){let z=c(q,J);return[this.parseCommaSeparatedArguments(q,J+1,z),z+1]}parseGroupsOfArguments(q,J){let z=c(q,J);q=q.slice(0,z);let V=[],Z={},X=J+1;while(X<z)while(X<z){let U=function(D){let L=new j("atom",":"),R={},y=[];for(let B=0;B<D.length;B++){if(D[B].type!=="group")continue;let M=D[B],S=d(M.args,L);if(S===-1||S===0)continue;if(y.push(B),M.args[S-1].eq(new j("symbol","delim")))if(M.args[S+1].type==="text"){if(R.delim=M.args[S+1].content,M.args.length!==3)throw new b("Invalid number of arguments for delim")}else if(M.args[S+1].eq(new j("atom","#"))){if(M.args.length!==4||!M.args[S+2].eq(new j("symbol","none")))throw new b("Invalid number of arguments for delim");R.delim="#none"}else throw new b("Not implemented for other types of delim");else throw new b("Not implemented for other named parameters")}for(let B=y.length-1;B>=0;B--)D.splice(y[B],1);return[D,R]},$=d(q,r2,X);if($===-1)$=z;let G=this.parseCommaSeparatedArguments(q,X,$),F={};[G,F]=U(G),V.push(G),Object.assign(Z,F),X=$+1}return[V,Z,z+1]}parseCommaSeparatedArguments(q,J,z){let V=[],Z=J;while(Z<z){let X=new j("group","",[]);while(Z<z){if(q[Z].eq(T2)){Z+=1;break}else if(q[Z].eq(n2)){Z+=1;continue}let[$,G]=this.parseNextExpr(q,Z);Z=G,X.args.push($)}if(X.args.length===0)X=i;else if(X.args.length===1)X=X.args[0];V.push(X)}return V}}function D2(q){let J=new H2,z=x2(q);return J.parse(z)}var t2=["sqrt","bold","arrow","upright","lr","op","macron","dot","dot.double","hat","tilde","overline","underline","bb","cal","frak"],s2=["frac","root","overbrace","underbrace"];function U2(q){if(["{","}","%"].includes(q))return"\\"+q;return q}class q2{buffer="";queue=[];writeBuffer(q){let J=q.toString(),z=!1;if(q.type===4)z=!0;else z||=/[{\(\[\|]$/.test(this.buffer),z||=/\\\w+$/.test(this.buffer)&&J==="[",z||=/^[\.,;:!\?\(\)\]{}_^]$/.test(J),z||=["\\{","\\}"].includes(J),z||=J==="'",z||=this.buffer.endsWith("_")||this.buffer.endsWith("^"),z||=/\s$/.test(this.buffer),z||=/^\s/.test(J),z||=this.buffer==="",z||=/[\(\[{]\s*(-|\+)$/.test(this.buffer)||this.buffer==="-"||this.buffer==="+",z||=this.buffer.endsWith("&")&&J==="=";if(!z)this.buffer+=" ";this.buffer+=J}append(q){let J=new Q("control","&"),z=new Q("control","\\\\");if(q.type==="ordgroup"&&P(q.args,J)){let V=a(q.args,z),Z=[];for(let X of V){let $=a(X,J);Z.push($.map((G)=>new Q("ordgroup","",G)))}q=new Q("beginend","aligned",[],Z)}this.queue=this.queue.concat(q.serialize())}flushQueue(){for(let q=0;q<this.queue.length;q++)this.writeBuffer(this.queue[q]);this.queue=[]}finalize(){return this.flushQueue(),this.buffer}}function A(q){if(q.eq(new j("symbol","eq.def")))return new Q("binaryFunc","\\overset",[new Q("text","def"),new Q("element","=")]);switch(q.type){case"empty":return new Q("empty","");case"whitespace":return new Q("whitespace",q.content);case"atom":return new Q("element",q.content);case"symbol":switch(q.content){case"comma":return new Q("element",",");case"hyph":case"hyph.minus":return new Q("text","-");default:return new Q("symbol",_(q.content))}case"text":return new Q("text",q.content);case"comment":return new Q("comment",q.content);case"group":{let J=q.args.map(A);if(q.content==="parenthesis")J.unshift(new Q("element","(")),J.push(new Q("element",")"));return new Q("ordgroup","",J)}case"funcCall":if(t2.includes(q.content)){if(q.content==="lr"){let z=q.args[0];if(z.type==="group"){let V=z.args[0].content,Z=z.args[z.args.length-1].content;return V=U2(V),Z=U2(Z),new Q("ordgroup","",[new Q("element","\\left"+V),...z.args.slice(1,z.args.length-1).map(A),new Q("element","\\right"+Z)])}}let J=_(q.content);return new Q("unaryFunc",J,q.args.map(A))}else if(s2.includes(q.content)){if(q.content==="root"){let[z,V]=q.args,Z=A(z);return new Q("unaryFunc","\\sqrt",[A(V)],Z)}if(q.content==="overbrace"||q.content==="underbrace"){let[z,V]=q.args,Z=new Q("unaryFunc","\\"+q.content,[A(z)]),X=A(V),$=q.content==="overbrace"?{base:Z,sup:X}:{base:Z,sub:X};return new Q("supsub","",[],$)}let J=_(q.content);return new Q("binaryFunc",J,q.args.map(A))}else return new Q("ordgroup","",[new Q("symbol",_(q.content)),new Q("element","("),...q.args.map(A),new Q("element",")")]);case"supsub":{let{base:J,sup:z,sub:V}=q.data,Z=A(J),X,$;if(z)X=A(z);if(V)$=A(V);return new Q("supsub","",[],{base:Z,sup:X,sub:$})}case"matrix":{let z=q.data.map(($)=>$.map(A)),V=new Q("beginend","matrix",[],z),Z="\\left(",X="\\right)";if(q.options){if("delim"in q.options)switch(q.options.delim){case"#none":return V;case"[":Z="\\left[",X="\\right]";break;case"]":Z="\\left]",X="\\right[";break;case"{":Z="\\left\\{",X="\\right\\}";break;case"}":Z="\\left\\}",X="\\right\\{";break;case"|":Z="\\left|",X="\\right|";break;case")":Z="\\left)",X="\\right(";case"(":default:Z="\\left(",X="\\right)";break}}return new Q("ordgroup","",[new Q("element",Z),V,new Q("element",X)])}case"control":switch(q.content){case"\\":return new Q("control","\\\\");case"&":return new Q("control","&");default:throw new Error("[convert_typst_node_to_tex] Unimplemented control: "+q.content)}case"fraction":{let[J,z]=q.args,V=A(J),Z=A(z);return new Q("binaryFunc","\\frac",[V,Z])}default:throw new Error("[convert_typst_node_to_tex] Unimplemented type: "+q.type)}}function _(q){if(/^[a-zA-Z0-9]$/.test(q))return q;else if(q==="thin")return"\\,";else if(w.has(q))return"\\"+w.get(q);return"\\"+q}function O2(q,J){let z={nonStrict:!0,preferTypstIntrinsic:!0,keepSpaces:!1,customTexMacros:{}};if(J){if(J.nonStrict)z.nonStrict=J.nonStrict;if(J.preferTypstIntrinsic)z.preferTypstIntrinsic=J.preferTypstIntrinsic;if(J.customTexMacros)z.customTexMacros=J.customTexMacros}let V=Z2(q,z.customTexMacros),Z=Y(V),X=new o(z.nonStrict,z.preferTypstIntrinsic,z.keepSpaces);return X.serialize(Z),X.finalize()}function Y2(q){let J=D2(q),z=A(J),V=new q2;return V.append(z),V.finalize()}if(typeof window!=="undefined")window.tex2typst=O2,window.typst2tex=Y2; |
@@ -71,2 +71,5 @@ export declare enum TexTokenType { | ||
type TypstNodeType = 'atom' | 'symbol' | 'text' | 'control' | 'comment' | 'whitespace' | 'empty' | 'group' | 'supsub' | 'funcCall' | 'fraction' | 'align' | 'matrix' | 'unknown'; | ||
export type TypstNamedParams = { | ||
[key: string]: string; | ||
}; | ||
export declare class TypstNode { | ||
@@ -77,5 +80,3 @@ type: TypstNodeType; | ||
data?: TypstSupsubData | TypstArrayData; | ||
options?: { | ||
[key: string]: string; | ||
}; | ||
options?: TypstNamedParams; | ||
constructor(type: TypstNodeType, content: string, args?: TypstNode[], data?: TypstSupsubData | TypstArrayData); | ||
@@ -82,0 +83,0 @@ setOptions(options: { |
@@ -1,2 +0,2 @@ | ||
import { TypstNode, TypstToken } from "./types"; | ||
import { TypstNamedParams, TypstNode, TypstToken } from "./types"; | ||
export declare function tokenize_typst(typst: string): TypstToken[]; | ||
@@ -17,3 +17,3 @@ export declare class TypstParserError extends Error { | ||
parseArguments(tokens: TypstToken[], start: number): [TypstNode[], number]; | ||
parseGroupsOfArguments(tokens: TypstToken[], start: number): [TypstNode[][], number]; | ||
parseGroupsOfArguments(tokens: TypstToken[], start: number): [TypstNode[][], TypstNamedParams, number]; | ||
parseCommaSeparatedArguments(tokens: TypstToken[], start: number, end: number): TypstNode[]; | ||
@@ -20,0 +20,0 @@ } |
{ | ||
"name": "tex2typst", | ||
"version": "0.3.0-beta-2", | ||
"version": "0.3.0-beta-4", | ||
"description": "JavaScript library for converting TeX code to Typst", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -411,3 +411,3 @@ const symbolMap = new Map<string, string>([ | ||
['mathoctothorpe', 'hash'], | ||
['mathhyphen', 'hyph'], | ||
// ['mathhyphen', 'hyph'], | ||
['mathpercent', 'percent'], | ||
@@ -1099,2 +1099,4 @@ ['mathparagraph', 'pilcrow'], | ||
['bold', 'boldsymbol'], | ||
['hyph.minus', '\\text{-}'], | ||
]); | ||
@@ -1101,0 +1103,0 @@ |
@@ -123,13 +123,15 @@ import { array_includes, array_split } from "./generic"; | ||
case 'atom': | ||
// special hook for colon | ||
if (node.content === ':') { | ||
return new TexNode('symbol', '\\colon'); | ||
} | ||
return new TexNode('element', node.content); | ||
case 'symbol': | ||
// special hook for comma | ||
if (node.content === 'comma') { | ||
return new TexNode('element', ','); | ||
switch(node.content) { | ||
// special hook for comma | ||
case 'comma': | ||
return new TexNode('element', ','); | ||
// special hook for hyph and hyph.minus | ||
case 'hyph': | ||
case 'hyph.minus': | ||
return new TexNode('text', '-'); | ||
default: | ||
return new TexNode('symbol', typst_token_to_tex(node.content)); | ||
} | ||
return new TexNode('symbol', typst_token_to_tex(node.content)); | ||
case 'text': | ||
@@ -214,6 +216,44 @@ return new TexNode('text', node.content); | ||
const matrix = new TexNode('beginend', 'matrix', [], tex_data); | ||
let left_delim = "\\left("; | ||
let right_delim = "\\right)"; | ||
if (node.options) { | ||
if('delim' in node.options) { | ||
switch (node.options.delim) { | ||
case '#none': | ||
return matrix; | ||
case '[': | ||
left_delim = "\\left["; | ||
right_delim = "\\right]"; | ||
break; | ||
case ']': | ||
left_delim = "\\left]"; | ||
right_delim = "\\right["; | ||
break; | ||
case '{': | ||
left_delim = "\\left\\{"; | ||
right_delim = "\\right\\}"; | ||
break; | ||
case '}': | ||
left_delim = "\\left\\}"; | ||
right_delim = "\\right\\{"; | ||
break; | ||
case '|': | ||
left_delim = "\\left|"; | ||
right_delim = "\\right|"; | ||
break; | ||
case ')': | ||
left_delim = "\\left)"; | ||
right_delim = "\\right("; | ||
case '(': | ||
default: | ||
left_delim = "\\left("; | ||
right_delim = "\\right)"; | ||
break; | ||
} | ||
} | ||
} | ||
return new TexNode('ordgroup', '', [ | ||
new TexNode('element', '\\left('), | ||
new TexNode('element', left_delim), | ||
matrix, | ||
new TexNode('element', '\\right)') | ||
new TexNode('element', right_delim) | ||
]); | ||
@@ -220,0 +260,0 @@ } |
@@ -168,5 +168,18 @@ import { array_includes } from "./generic"; | ||
tokens = tokens.concat(base.serialize()); | ||
// TODO: should return true for more cases e.g. a_{\theta} instead of a_\theta | ||
function should_wrap_in_braces(node: TexNode): boolean { | ||
if(node.type === 'ordgroup' || node.type === 'supsub' || node.type === 'empty') { | ||
return true; | ||
} else if(node.type === 'element' && /\d+(\.\d+)?/.test(node.content) && node.content.length > 1) { | ||
// a number with more than 1 digit as a subscript/superscript should be wrapped in braces | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
if (sub) { | ||
tokens.push(new TexToken(TexTokenType.CONTROL, '_')); | ||
if (sub.type === 'ordgroup' || sub.type === 'supsub' || sub.type === 'empty') { | ||
if (should_wrap_in_braces(sub)) { | ||
tokens.push(new TexToken(TexTokenType.ELEMENT, '{')); | ||
@@ -181,3 +194,3 @@ tokens = tokens.concat(sub.serialize()); | ||
tokens.push(new TexToken(TexTokenType.CONTROL, '^')); | ||
if (sup.type === 'ordgroup' || sup.type === 'supsub' || sup.type === 'empty') { | ||
if (should_wrap_in_braces(sup)) { | ||
tokens.push(new TexToken(TexTokenType.ELEMENT, '{')); | ||
@@ -307,2 +320,3 @@ tokens = tokens.concat(sup.serialize()); | ||
export type TypstNamedParams = { [key: string]: string }; | ||
@@ -315,3 +329,3 @@ export class TypstNode { | ||
// Some Typst functions accept additional options. e.g. mat() has option "delim", op() has option "limits" | ||
options?: { [key: string]: string }; | ||
options?: TypstNamedParams; | ||
@@ -318,0 +332,0 @@ constructor(type: TypstNodeType, content: string, args?: TypstNode[], |
import { array_find } from "./generic"; | ||
import { TypstNode, TypstSupsubData, TypstToken, TypstTokenType } from "./types"; | ||
import { TypstNamedParams, TypstNode, TypstSupsubData, TypstToken, TypstTokenType } from "./types"; | ||
import { assert, isalpha, isdigit } from "./util"; | ||
@@ -89,6 +89,5 @@ | ||
pos += 2; | ||
} else if (firstTwoChars === '\\\n') { | ||
} else if (['\\\n', '\\ '].includes(firstTwoChars)) { | ||
token = new TypstToken(TypstTokenType.CONTROL, '\\'); | ||
pos += 1; | ||
} else { | ||
@@ -125,2 +124,8 @@ // this backslash is dummy and will be ignored in later stages | ||
} | ||
if(newPos < typst.length && typst[newPos] === '.') { | ||
newPos += 1; | ||
while (newPos < typst.length && isdigit(typst[newPos])) { | ||
newPos += 1; | ||
} | ||
} | ||
token = new TypstToken(TypstTokenType.ELEMENT, typst.slice(pos, newPos)); | ||
@@ -432,4 +437,5 @@ } else if ('+-*/=\'<>!.,;?()[]|'.includes(firstChar)) { | ||
if(firstToken.value === 'mat') { | ||
const [matrix, newPos] = this.parseGroupsOfArguments(tokens, start + 1); | ||
const [matrix, named_params, newPos] = this.parseGroupsOfArguments(tokens, start + 1); | ||
const mat = new TypstNode('matrix', '', [], matrix); | ||
mat.setOptions(named_params); | ||
return [mat, newPos]; | ||
@@ -455,6 +461,9 @@ } | ||
// start: the position of the left parentheses | ||
parseGroupsOfArguments(tokens: TypstToken[], start: number): [TypstNode[][], number] { | ||
parseGroupsOfArguments(tokens: TypstToken[], start: number): [TypstNode[][], TypstNamedParams, number] { | ||
const end = find_closing_match(tokens, start); | ||
tokens = tokens.slice(0, end); | ||
const matrix: TypstNode[][] = []; | ||
let named_params: TypstNamedParams = {}; | ||
let pos = start + 1; | ||
@@ -467,4 +476,51 @@ while (pos < end) { | ||
} | ||
const row = this.parseCommaSeparatedArguments(tokens, pos, next_stop); | ||
let row = this.parseCommaSeparatedArguments(tokens, pos, next_stop); | ||
let np: TypstNamedParams = {}; | ||
function extract_named_params(arr: TypstNode[]): [TypstNode[], TypstNamedParams] { | ||
const COLON = new TypstNode('atom', ':'); | ||
const np: TypstNamedParams = {}; | ||
const to_delete: number[] = []; | ||
for(let i = 0; i < arr.length; i++) { | ||
if(arr[i].type !== 'group') { | ||
continue; | ||
} | ||
const g = arr[i]; | ||
const pos_colon = array_find(g.args!, COLON); | ||
if(pos_colon === -1 || pos_colon === 0) { | ||
continue; | ||
} | ||
to_delete.push(i); | ||
const param_name = g.args![pos_colon - 1]; | ||
if(param_name.eq(new TypstNode('symbol', 'delim'))) { | ||
if(g.args![pos_colon + 1].type === 'text') { | ||
np['delim'] = g.args![pos_colon + 1].content; | ||
if(g.args!.length !== 3) { | ||
throw new TypstParserError('Invalid number of arguments for delim'); | ||
} | ||
} else if(g.args![pos_colon + 1].eq(new TypstNode('atom', '#'))) { | ||
// TODO: should parse #none properly | ||
if(g.args!.length !== 4 || !g.args![pos_colon + 2].eq(new TypstNode('symbol', 'none'))) { | ||
throw new TypstParserError('Invalid number of arguments for delim'); | ||
} | ||
np['delim'] = "#none"; | ||
} else { | ||
throw new TypstParserError('Not implemented for other types of delim'); | ||
} | ||
} else { | ||
throw new TypstParserError('Not implemented for other named parameters'); | ||
} | ||
} | ||
for(let i = to_delete.length - 1; i >= 0; i--) { | ||
arr.splice(to_delete[i], 1); | ||
} | ||
return [arr, np]; | ||
} | ||
[row, np] = extract_named_params(row); | ||
matrix.push(row); | ||
Object.assign(named_params, np); | ||
pos = next_stop + 1; | ||
@@ -474,3 +530,3 @@ } | ||
return [matrix, end + 1]; | ||
return [matrix, named_params, end + 1]; | ||
} | ||
@@ -477,0 +533,0 @@ |
@@ -547,4 +547,2 @@ import { symbolMap } from "./map"; | ||
return 'parallel'; | ||
} else if (token === '\\colon') { | ||
return ':'; | ||
} else if (token === '\\\\') { | ||
@@ -551,0 +549,0 @@ return '\\'; |
Sorry, the diff of this file is too big to display
341321
6986