Comparing version 0.2.13 to 0.2.15
@@ -1,1 +0,1 @@ | ||
var K=new Map([["nonumber",""],["vec","arrow"],["neq","eq.not"],["dot","dot"],["ddot","dot.double"],["doteq","dot(eq)"],["dots","dots.h"],["ldots","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"],["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","\u224D"],["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.l"],["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"]]),l=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"],["mupalpha","alpha"],["mupbeta","beta"],["mupchi","chi"],["mupdelta","delta"],["mupvarepsilon","epsilon"],["mupepsilon","epsilon.alt"],["mupeta","eta"],["mupgamma","gamma"],["mupiota","iota"],["mupkappa","kappa"],["mupvarkappa","kappa.alt"],["muplambda","lambda"],["mupmu","mu"],["mupnu","nu"],["mho","ohm.inv"],["mupomega","omega"],["mupomicron","omicron"],["mupvarphi","phi"],["mupphi","phi.alt"],["muppi","pi"],["mupvarpi","pi.alt"],["muppsi","psi"],["muprho","rho"],["mupvarrho","rho.alt"],["mupsigma","sigma"],["mupvarsigma","sigma.alt"],["muptau","tau"],["muptheta","theta"],["mupvartheta","theta.alt"],["mupupsilon","upsilon"],["mupxi","xi"],["mupzeta","zeta"],["mupAlpha","Alpha"],["mupBeta","Beta"],["mupChi","Chi"],["mupDelta","Delta"],["mupEpsilon","Epsilon"],["mupEta","Eta"],["mupGamma","Gamma"],["mupIota","Iota"],["mupKappa","Kappa"],["mupLambda","Lambda"],["mupMu","Mu"],["mupNu","Nu"],["mupOmega","Omega"],["mupOmicron","Omicron"],["mupPhi","Phi"],["mupPi","Pi"],["mupPsi","Psi"],["mupRho","Rho"],["mupSigma","Sigma"],["mupTau","Tau"],["mupTheta","Theta"],["mupUpsilon","Upsilon"],["mupXi","Xi"],["mupZeta","Zeta"],["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[z,V]of l)if(!K.has(z))K.set(z,V);function W(z,V=""){if(!z)throw new q(V)}function d(z){if(_.includes(z))return 1;else if(i.includes(z))return 2;else return 0}function T(z,V){W(z[V].eq(Y));let J=1,X=V+1;while(J>0){if(X>=z.length)throw new q("Unmatched curly brackets");if(z[X].eq(Y))J+=1;else if(z[X].eq(B))J-=1;X+=1}return X-1}function k(z,V){W(z[V].eq(M));let J=1,X=V+1;while(J>0){if(X>=z.length)throw new q("Unmatched square brackets");if(z[X].eq(M))J+=1;else if(z[X].eq(p))J-=1;X+=1}return X-1}function y(z){return"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(z)}function P(z){return"0123456789".includes(z)}function f(z,V){let J=V;while(J<z.length&&[4,5].includes(z[J].type))J++;return z.slice(V,J)}function L(z,V){const J=z[V];if(J.type===0&&["(",")","[","]","|","\\{","\\}"].includes(J.value))return J;else if(J.type===1&&["lfloor","rfloor","lceil","rceil","langle","rangle"].includes(J.value.slice(1)))return J;else return null}function D(z,V){let J=V;while(J<z.length&&z[J].eq(new Q(0,"'")))J+=1;return J-V}function a(z,V){let J=V;while(J<z.length&&y(z[J]))J+=1;return z.substring(V,J)}function n(z,V){let J=1,X=V;while(J>0){if(X>=z.length)return-1;if(z[X].eq(R))J+=1;else if(z[X].eq(r))J-=1;X+=1}return X-1}function s(z,V){let J=1,X=V;while(J>0){if(X>=z.length)return-1;if(z[X].eq(h))J+=1;else if(z[X].eq(t))J-=1;X+=1}return X-1}function o(z,V){W(z[V]==="{");let J=1,X=V+1;while(J>0){if(X>=z.length)throw new q("Unmatched curly brackets");if(X+1<z.length&&["\\{","\\}"].includes(z.substring(X,X+2))){X+=2;continue}if(z[X]==="{")J+=1;else if(z[X]==="}")J-=1;X+=1}return X-1}function m(z){const V=[];let J=0;while(J<z.length){const X=z[J];let $;switch(X){case"%":{let Z=J+1;while(Z<z.length&&z[Z]!=="\n")Z+=1;$=new Q(3,z.slice(J+1,Z)),J=Z;break}case"{":case"}":case"_":case"^":case"&":$=new Q(6,X),J++;break;case"\n":$=new Q(5,X),J++;break;case"\r":{if(J+1<z.length&&z[J+1]==="\n")$=new Q(5,"\n"),J+=2;else $=new Q(5,"\n"),J++;break}case" ":{let Z=J;while(Z<z.length&&z[Z]===" ")Z+=1;$=new Q(4,z.slice(J,Z)),J=Z;break}case"\\":{if(J+1>=z.length)throw new q("Expecting command name after \\");const Z=z.slice(J,J+2);if(["\\\\","\\,"].includes(Z))$=new Q(6,Z);else if(["\\{","\\}","\\%","\\$","\\&","\\#","\\_","\\|"].includes(Z))$=new Q(0,Z);else{const j=a(z,J+1);$=new Q(1,"\\"+j)}J+=$.value.length;break}default:{if(P(X)){let Z=J;while(Z<z.length&&P(z[Z]))Z+=1;$=new Q(0,z.slice(J,Z))}else if(y(X))$=new Q(0,X);else if("+-*/=\'<>!.,;?()[]|".includes(X))$=new Q(0,X);else $=new Q(7,X);J+=$.value.length}}if(V.push($),$.type===1&&["\\text","\\operatorname","\\begin","\\end"].includes($.value)){if(J>=z.length||z[J]!=="{")throw new q(`No content for ${$.value} command`);V.push(new Q(6,"{"));const Z=o(z,J);J++;let j=z.slice(J,Z);const H=["{","}","\\","$","&","#","_","%"];for(let F of H)j=j.replaceAll("\\"+F,F);V.push(new Q(2,j)),V.push(new Q(6,"}")),J=Z+1}}return V}function e(z){const V=(X)=>X.eq(w)||X.eq(b);let J=[];for(let X=0;X<z.length;X++){if(z[X].type===4&&X+1<z.length&&V(z[X+1]))continue;if(z[X].type===4&&X-1>=0&&V(z[X-1]))continue;J.push(z[X])}return J}function z2(z,V){let J=[];for(let X of z)if(X.type===1&&V[X.value]){const $=m(V[X.value]);J=J.concat($)}else J.push(X);return J}function E(z,V){const J=new u;let X=m(z);return X=e(X),X=z2(X,V),J.parse(X)}var _=["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"],i=["frac","tfrac","binom","dbinom","dfrac","tbinom","overset"];class Q{type;value;constructor(z,V){this.type=z,this.value=V}eq(z){return this.type===z.type&&this.value===z.value}}var I={type:"empty",content:""},Y=new Q(6,"{"),B=new Q(6,"}"),M=new Q(0,"["),p=new Q(0,"]"),R=new Q(1,"\\left"),r=new Q(1,"\\right"),h=new Q(1,"\\begin"),t=new Q(1,"\\end");class q extends Error{constructor(z){super(z);this.name="LatexParserError"}}var w=new Q(6,"_"),b=new Q(6,"^");class u{space_sensitive;newline_sensitive;constructor(z=!1,V=!0){this.space_sensitive=z,this.newline_sensitive=V}parse(z){const V=[];let J=0;while(J<z.length){const X=[];let $=0;while($<z.length){const[Z,j]=this.parseNextExpr(z,$);if($=j,!this.space_sensitive&&Z.type==="whitespace")continue;if(!this.newline_sensitive&&Z.type==="newline")continue;if(Z.type==="control"&&Z.content==="&")throw new q("Unexpected & outside of an alignment");X.push(Z)}if(X.length===0)return I;else if(X.length===1)return X[0];else return{type:"ordgroup",content:"",args:X}}if(V.length===0)return I;else if(V.length===1)return V[0];else return{type:"ordgroup",content:"",args:V}}parseNextExpr(z,V){let[J,X]=this.parseNextExprWithoutSupSub(z,V),$=null,Z=null,j=0;if(j+=D(z,X),X+=j,X<z.length&&z[X].eq(w)){if([$,X]=this.parseNextExprWithoutSupSub(z,X+1),j+=D(z,X),X+=j,X<z.length&&z[X].eq(b)){if([Z,X]=this.parseNextExprWithoutSupSub(z,X+1),D(z,X)>0)throw new q("Double superscript")}}else if(X<z.length&&z[X].eq(b)){if([Z,X]=this.parseNextExprWithoutSupSub(z,X+1),D(z,X)>0)throw new q("Double superscript");if(X<z.length&&z[X].eq(w)){if([$,X]=this.parseNextExprWithoutSupSub(z,X+1),D(z,X)>0)throw new q("Double superscript")}}if($!==null||Z!==null||j>0){const H={base:J};if($)H.sub=$;if(j>0){H.sup={type:"ordgroup",content:"",args:[]};for(let F=0;F<j;F++)H.sup.args.push({type:"element",content:"'"});if(Z)H.sup.args.push(Z);if(H.sup.args.length===1)H.sup=H.sup.args[0]}else if(Z)H.sup=Z;return[{type:"supsub",content:"",data:H},X]}else return[J,X]}parseNextExprWithoutSupSub(z,V){const J=z[V];switch(J.type){case 0:return[{type:"element",content:J.value},V+1];case 2:return[{type:"text",content:J.value},V+1];case 3:return[{type:"comment",content:J.value},V+1];case 4:return[{type:"whitespace",content:J.value},V+1];case 5:return[{type:"newline",content:J.value},V+1];case 1:if(J.eq(h))return this.parseBeginEndExpr(z,V);else if(J.eq(R))return this.parseLeftRightExpr(z,V);else return this.parseCommandExpr(z,V);case 6:switch(J.value){case"{":const Z=T(z,V),j=z.slice(V+1,Z);return[this.parse(j),Z+1];case"}":throw new q("Unmatched '}'");case"\\\\":return[{type:"control",content:"\\\\"},V+1];case"\\,":return[{type:"control",content:"\\,"},V+1];case"_":return[I,V];case"^":return[I,V];case"&":return[{type:"control",content:"&"},V+1];default:throw new q("Unknown control sequence")}default:throw new q("Unknown token type")}}parseCommandExpr(z,V){W(z[V].type===1);const J=z[V].value;let X=V+1;if(["left","right","begin","end"].includes(J.slice(1)))throw new q("Unexpected command: "+J);switch(d(J.slice(1))){case 0:if(!K.has(J.slice(1)))return[{type:"unknownMacro",content:J},X];return[{type:"symbol",content:J},X];case 1:{if(J==="\\sqrt"&&X<z.length&&z[X].eq(M)){const H=X,F=k(z,X),U=z.slice(H+1,F),N=this.parse(U),[A,v]=this.parseNextExprWithoutSupSub(z,F+1);return[{type:"unaryFunc",content:J,args:[A],data:N},v]}else if(J==="\\text"){if(X+2>=z.length)throw new q("Expecting content for \\text command");return W(z[X].eq(Y)),W(z[X+1].type===2),W(z[X+2].eq(B)),[{type:"text",content:z[X+1].value},X+3]}let[Z,j]=this.parseNextExprWithoutSupSub(z,X);return[{type:"unaryFunc",content:J,args:[Z]},j]}case 2:{const[Z,j]=this.parseNextExprWithoutSupSub(z,X),[H,F]=this.parseNextExprWithoutSupSub(z,j);return[{type:"binaryFunc",content:J,args:[Z,H]},F]}default:throw new Error("Invalid number of parameters")}}parseLeftRightExpr(z,V){W(z[V].eq(R));let J=V+1;if(J+=f(z,J).length,J>=z.length)throw new q("Expecting delimiter after \\left");const X=L(z,J);if(X===null)throw new q("Invalid delimiter after \\left");J++;const $=J,Z=n(z,J);if(Z===-1)throw new q("No matching \\right");const j=Z;if(J=Z+1,J+=f(z,J).length,J>=z.length)throw new q("Expecting \\right after \\left");const H=L(z,J);if(H===null)throw new q("Invalid delimiter after \\right");J++;const F=z.slice($,j),U=this.parse(F);return[{type:"leftright",content:"",args:[{type:"element",content:X.value},U,{type:"element",content:H.value}]},J]}parseBeginEndExpr(z,V){W(z[V].eq(h));let J=V+1;W(z[J].eq(Y)),W(z[J+1].type===2),W(z[J+2].eq(B));const X=z[J+1].value;J+=3,J+=f(z,J).length;const $=J,Z=s(z,J);if(Z===-1)throw new q("No matching \\end");const j=Z;if(J=Z+1,W(z[J].eq(Y)),W(z[J+1].type===2),W(z[J+2].eq(B)),z[J+1].value!==X)throw new q("Mismatched \\begin and \\end environments");J+=3;const H=z.slice($,j);while(H.length>0&&[4,5].includes(H[H.length-1].type))H.pop();const F=this.parseAligned(H);return[{type:"beginend",content:X,data:F},J]}parseAligned(z){let V=0;const J=[];let X=[];J.push(X);let $={type:"ordgroup",content:"",args:[]};X.push($);while(V<z.length){const[Z,j]=this.parseNextExpr(z,V);if(V=j,Z.type==="whitespace")continue;else if(Z.type==="newline"&&!this.newline_sensitive)continue;else if(Z.type==="control"&&Z.content==="\\\\")X=[],$={type:"ordgroup",content:"",args:[]},X.push($),J.push(X);else if(Z.type==="control"&&Z.content==="&")$={type:"ordgroup",content:"",args:[]},X.push($);else $.args.push(Z)}return J}}function c(z){return z.type==="atom"&&["(",")","[","]","{","}","|","\u230A","\u230B","\u2308","\u2309"].includes(z.content)}function g(z,V){return z.type===V.type&&z.content===V.content}function V2(z){const[V,J]=z.args,X=(j)=>{if(j.type==="text"&&j.content==="def")return!0;if(j.type==="ordgroup"&&j.args.length===3){const[H,F,U]=j.args,N={type:"element",content:"d"},A={type:"element",content:"e"},v={type:"element",content:"f"};if(g(H,N)&&g(F,A)&&g(U,v))return!0}return!1},$=(j)=>j.type==="element"&&j.content==="=";if(X(V)&&$(J))return{type:"symbol",content:"eq.def"};return{type:"supsub",content:"",data:{base:{type:"unaryFunc",content:"op",args:[G(J)],options:{limits:"#true"}},sup:G(V)}}}function G(z){switch(z.type){case"empty":case"whitespace":return{type:"empty",content:""};case"ordgroup":return{type:"group",content:"",args:z.args.map(G)};case"element":return{type:"atom",content:S(z.content)};case"symbol":return{type:"symbol",content:S(z.content)};case"text":return{type:"text",content:z.content};case"comment":return{type:"comment",content:z.content};case"supsub":{let{base:V,sup:J,sub:X}=z.data;if(V&&V.type==="unaryFunc"&&V.content==="\\overbrace"&&J)return{type:"binaryFunc",content:"overbrace",args:[G(V.args[0]),G(J)]};else if(V&&V.type==="unaryFunc"&&V.content==="\\underbrace"&&X)return{type:"binaryFunc",content:"underbrace",args:[G(V.args[0]),G(X)]};const $={base:G(V)};if($.base.type==="empty")$.base={type:"text",content:""};if(J)$.sup=G(J);if(X)$.sub=G(X);return{type:"supsub",content:"",data:$}}case"leftright":{const[V,J,X]=z.args,$={type:"group",content:"",args:z.args.map(G)};if(["[]","()","\\{\\}","\\lfloor\\rfloor","\\lceil\\rceil","\\lfloor\\rceil"].includes(V.content+X.content))return $;return{type:"unaryFunc",content:"lr",args:[$]}}case"binaryFunc":{if(z.content==="\\overset")return V2(z);return{type:"binaryFunc",content:S(z.content),args:z.args.map(G)}}case"unaryFunc":{const V=G(z.args[0]);if(z.content==="\\sqrt"&&z.data)return{type:"binaryFunc",content:"root",args:[G(z.data),V]};if(z.content==="\\mathbf")return{type:"unaryFunc",content:"upright",args:[{type:"unaryFunc",content:"bold",args:[V]}]};if(z.content==="\\mathbb"&&V.type==="atom"&&/^[A-Z]$/.test(V.content))return{type:"symbol",content:V.content+V.content};if(z.content==="\\operatorname"){const J=z.args;if(J.length!==1||J[0].type!=="text")throw new O("Expecting body of \\operatorname to be text but got",z);const X=J[0].content;if(J2.includes(X))return{type:"symbol",content:X};else return{type:"unaryFunc",content:"op",args:[{type:"text",content:X}]}}return{type:"unaryFunc",content:S(z.content),args:z.args.map(G)}}case"newline":return{type:"newline",content:"\n"};case"beginend":{const J=z.data.map((X)=>X.map(G));if(z.content.startsWith("align"))return{type:"align",content:"",data:J};else return{type:"matrix",content:"mat",data:J}}case"unknownMacro":return{type:"unknown",content:S(z.content)};case"control":if(z.content==="\\\\")return{type:"symbol",content:"\\"};else if(z.content==="\\,")return{type:"symbol",content:"thin"};else throw new O(`Unknown control sequence: ${z.content}`,z);default:throw new O(`Unimplemented node type: ${z.type}`,z)}}function S(z){if(/^[a-zA-Z0-9]$/.test(z))return z;else if(z==="/")return"\\/";else if(z==="\\|")return"parallel";else if(z==="\\\\")return"\\";else if(["\\$","\\#","\\&","\\_"].includes(z))return z;else if(z.startsWith("\\")){const V=z.slice(1);if(K.has(V))return K.get(V);else return V}return z}var J2=["dim","id","im","mod","Pr","sech","csch"];class O extends Error{node;constructor(z,V){super(z);this.name="TypstWriterError",this.node=V}}class C{nonStrict;preferTypstIntrinsic;buffer="";queue=[];needSpaceAfterSingleItemScript=!1;insideFunctionDepth=0;constructor(z,V){this.nonStrict=z,this.preferTypstIntrinsic=V}writeBuffer(z){if(this.needSpaceAfterSingleItemScript&&/^[0-9a-zA-Z\(]/.test(z))this.buffer+=" ";else{let V=!1;if(V||=/[\(\|]$/.test(this.buffer)&&/^\w/.test(z),V||=/^[}()_^,;!\|]$/.test(z),V||=z==="'",V||=/[0-9]$/.test(this.buffer)&&/^[0-9]/.test(z),V||=/[\(\[{]\s*(-|\+)$/.test(this.buffer)||this.buffer==="-"||this.buffer==="+",V||=z.startsWith("\n"),V||=this.buffer==="",V||=/[\s_^{\(]$/.test(this.buffer),!V)this.buffer+=" "}if(this.needSpaceAfterSingleItemScript)this.needSpaceAfterSingleItemScript=!1;this.buffer+=z}append(z){switch(z.type){case"empty":break;case"atom":{if(z.content===","&&this.insideFunctionDepth>0)this.queue.push({type:"symbol",content:"comma"});else this.queue.push({type:"atom",content:z.content});break}case"symbol":case"text":case"comment":case"newline":this.queue.push(z);break;case"group":for(let V of z.args)this.append(V);break;case"supsub":{let{base:V,sup:J,sub:X}=z.data;this.appendWithBracketsIfNeeded(V);let $=!1;const Z=J&&J.type==="atom"&&J.content==="\'";if(Z)this.queue.push({type:"atom",content:"\'"}),$=!1;if(X)this.queue.push({type:"atom",content:"_"}),$=this.appendWithBracketsIfNeeded(X);if(J&&!Z)this.queue.push({type:"atom",content:"^"}),$=this.appendWithBracketsIfNeeded(J);if($)this.queue.push({type:"softSpace",content:""});break}case"binaryFunc":{const V={type:"symbol",content:z.content},[J,X]=z.args;this.queue.push(V),this.insideFunctionDepth++,this.queue.push({type:"atom",content:"("}),this.append(J),this.queue.push({type:"atom",content:","}),this.append(X),this.queue.push({type:"atom",content:")"}),this.insideFunctionDepth--;break}case"unaryFunc":{const V={type:"symbol",content:z.content},J=z.args[0];if(this.queue.push(V),this.insideFunctionDepth++,this.queue.push({type:"atom",content:"("}),this.append(J),z.options)for(let[X,$]of Object.entries(z.options))this.queue.push({type:"symbol",content:`, ${X}: ${$}`});this.queue.push({type:"atom",content:")"}),this.insideFunctionDepth--;break}case"align":{const V=z.data;V.forEach((J,X)=>{if(J.forEach(($,Z)=>{if(Z>0)this.queue.push({type:"atom",content:"&"});this.append($)}),X<V.length-1)this.queue.push({type:"symbol",content:"\\"})});break}case"matrix":{const V=z.data;this.queue.push({type:"symbol",content:"mat"}),this.insideFunctionDepth++,this.queue.push({type:"atom",content:"("}),this.queue.push({type:"symbol",content:"delim: #none, "}),V.forEach((J,X)=>{J.forEach(($,Z)=>{if(this.append($),Z<J.length-1)this.queue.push({type:"atom",content:","});else if(X<V.length-1)this.queue.push({type:"atom",content:";"})})}),this.queue.push({type:"atom",content:")"}),this.insideFunctionDepth--;break}case"unknown":{if(this.nonStrict)this.queue.push({type:"symbol",content:z.content});else throw new O(`Unknown macro: ${z.content}`,z);break}default:throw new O(`Unimplemented node type to append: ${z.type}`,z)}}appendWithBracketsIfNeeded(z){let V=["group","supsub","empty"].includes(z.type);if(z.type==="group"){const J=z.args[0],X=z.args[z.args.length-1];if(c(J)&&c(X))V=!1}if(V)this.queue.push({type:"atom",content:"("}),this.append(z),this.queue.push({type:"atom",content:")"});else this.append(z);return!V}flushQueue(){this.queue.forEach((z)=>{let V="";switch(z.type){case"atom":case"symbol":V=z.content;break;case"text":V=`"${z.content}"`;break;case"softSpace":this.needSpaceAfterSingleItemScript=!0,V="";break;case"comment":V=`//${z.content}`;break;case"newline":V="\n";break;default:throw new O(`Unexpected node type to stringify: ${z.type}`,z)}if(V!=="")this.writeBuffer(V)}),this.queue=[]}finalize(){this.flushQueue();const X=[function($){let Z=$.replace(/floor\.l\s*(.*?)\s*floor\.r/g,"floor($1)");return Z=Z.replace(/floor\(\)/g,'floor("")'),Z},function($){let Z=$.replace(/ceil\.l\s*(.*?)\s*ceil\.r/g,"ceil($1)");return Z=Z.replace(/ceil\(\)/g,'ceil("")'),Z},function($){let Z=$.replace(/floor\.l\s*(.*?)\s*ceil\.r/g,"round($1)");return Z=Z.replace(/round\(\)/g,'round("")'),Z}];for(let $ of X)this.buffer=$(this.buffer);return this.buffer}}function x(z,V){const J={nonStrict:!0,preferTypstIntrinsic:!0,customTexMacros:{}};if(V){if(V.nonStrict)J.nonStrict=V.nonStrict;if(V.preferTypstIntrinsic)J.preferTypstIntrinsic=V.preferTypstIntrinsic;if(V.customTexMacros)J.customTexMacros=V.customTexMacros}const X=E(z,J.customTexMacros),$=G(X),Z=new C(J.nonStrict,J.preferTypstIntrinsic);return Z.append($),Z.finalize()}if(typeof window!=="undefined")window.tex2typst=x; | ||
var H=new Map([["nonumber",""],["vec","arrow"],["neq","eq.not"],["dot","dot"],["ddot","dot.double"],["doteq","dot(eq)"],["dots","dots.h"],["ldots","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"],["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","\u224D"],["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.l"],["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"]]),a=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"],["mupalpha","alpha"],["mupbeta","beta"],["mupchi","chi"],["mupdelta","delta"],["mupvarepsilon","epsilon"],["mupepsilon","epsilon.alt"],["mupeta","eta"],["mupgamma","gamma"],["mupiota","iota"],["mupkappa","kappa"],["mupvarkappa","kappa.alt"],["muplambda","lambda"],["mupmu","mu"],["mupnu","nu"],["mho","ohm.inv"],["mupomega","omega"],["mupomicron","omicron"],["mupvarphi","phi"],["mupphi","phi.alt"],["muppi","pi"],["mupvarpi","pi.alt"],["muppsi","psi"],["muprho","rho"],["mupvarrho","rho.alt"],["mupsigma","sigma"],["mupvarsigma","sigma.alt"],["muptau","tau"],["muptheta","theta"],["mupvartheta","theta.alt"],["mupupsilon","upsilon"],["mupxi","xi"],["mupzeta","zeta"],["mupAlpha","Alpha"],["mupBeta","Beta"],["mupChi","Chi"],["mupDelta","Delta"],["mupEpsilon","Epsilon"],["mupEta","Eta"],["mupGamma","Gamma"],["mupIota","Iota"],["mupKappa","Kappa"],["mupLambda","Lambda"],["mupMu","Mu"],["mupNu","Nu"],["mupOmega","Omega"],["mupOmicron","Omicron"],["mupPhi","Phi"],["mupPi","Pi"],["mupPsi","Psi"],["mupRho","Rho"],["mupSigma","Sigma"],["mupTau","Tau"],["mupTheta","Theta"],["mupUpsilon","Upsilon"],["mupXi","Xi"],["mupZeta","Zeta"],["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[z,V]of a)if(!H.has(z))H.set(z,V);class Q{type;content;args;data;constructor(z,V,J,X){this.type=z,this.content=V,this.args=J,this.data=X}eq_shallow(z){return this.type===z.type&&this.content===z.content}toString(){switch(this.type){case"text":return`\\text{${this.content}}`;default:throw new Error(`toString() is not implemented for type ${this.type}`)}}}class K{type;content;constructor(z,V){this.type=z,this.content=V}eq(z){return this.type===z.type&&this.content===z.content}isOneOf(z){let V=!1;for(let J of z)if(this.eq(J)){V=!0;break}return V}}class q{type;content;args;data;options;constructor(z,V,J,X){this.type=z,this.content=V,this.args=J,this.data=X}setOptions(z){this.options=z}eq_shallow(z){return this.type===z.type&&this.content===z.content}}function D(z,V=""){if(!z)throw new F(V)}function r(z){if(p.includes(z))return 1;else if(k.includes(z))return 2;else return 0}function T(z,V){D(z[V].eq(M));let J=1,X=V+1;while(J>0){if(X>=z.length)throw new F("Unmatched curly brackets");if(z[X].eq(M))J+=1;else if(z[X].eq(h))J-=1;X+=1}return X-1}function t(z,V){D(z[V].eq(g));let J=1,X=V+1;while(J>0){if(X>=z.length)throw new F("Unmatched square brackets");if(z[X].eq(g))J+=1;else if(z[X].eq(n))J-=1;X+=1}return X-1}function l(z){return"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(z)}function E(z){return"0123456789".includes(z)}function R(z,V){let J=V;while(J<z.length&&[4,5].includes(z[J].type))J++;return z.slice(V,J)}function c(z,V){const J=z[V];if(J.type===0&&["(",")","[","]","|","\\{","\\}"].includes(J.value))return J;else if(J.type===1&&["lfloor","rfloor","lceil","rceil","langle","rangle"].includes(J.value.slice(1)))return J;else return null}function f(z,V){let J=V;while(J<z.length&&z[J].eq(new G(0,"'")))J+=1;return J-V}function s(z,V){let J=V;while(J<z.length&&l(z[J]))J+=1;return z.substring(V,J)}function e(z,V){let J=1,X=V;while(J>0){if(X>=z.length)return-1;if(z[X].eq(L))J+=1;else if(z[X].eq(o))J-=1;X+=1}return X-1}function Jz(z,V){let J=1,X=V;while(J>0){if(X>=z.length)return-1;if(z[X].eq(P))J+=1;else if(z[X].eq(zz))J-=1;X+=1}return X-1}function Vz(z,V){D(z[V]==="{");let J=1,X=V+1;while(J>0){if(X>=z.length)throw new F("Unmatched curly brackets");if(X+1<z.length&&["\\{","\\}"].includes(z.substring(X,X+2))){X+=2;continue}if(z[X]==="{")J+=1;else if(z[X]==="}")J-=1;X+=1}return X-1}function _(z){const V=[];let J=0;while(J<z.length){const X=z[J];let $;switch(X){case"%":{let Z=J+1;while(Z<z.length&&z[Z]!=="\n")Z+=1;$=new G(3,z.slice(J+1,Z)),J=Z;break}case"{":case"}":case"_":case"^":case"&":$=new G(6,X),J++;break;case"\n":$=new G(5,X),J++;break;case"\r":{if(J+1<z.length&&z[J+1]==="\n")$=new G(5,"\n"),J+=2;else $=new G(5,"\n"),J++;break}case" ":{let Z=J;while(Z<z.length&&z[Z]===" ")Z+=1;$=new G(4,z.slice(J,Z)),J=Z;break}case"\\":{if(J+1>=z.length)throw new F("Expecting command name after \\");const Z=z.slice(J,J+2);if(["\\\\","\\,"].includes(Z))$=new G(6,Z);else if(["\\{","\\}","\\%","\\$","\\&","\\#","\\_","\\|"].includes(Z))$=new G(0,Z);else{const j=s(z,J+1);$=new G(1,"\\"+j)}J+=$.value.length;break}default:{if(E(X)){let Z=J;while(Z<z.length&&E(z[Z]))Z+=1;$=new G(0,z.slice(J,Z))}else if(l(X))$=new G(0,X);else if("+-*/=\'<>!.,;?()[]|".includes(X))$=new G(0,X);else $=new G(7,X);J+=$.value.length}}if(V.push($),$.type===1&&["\\text","\\operatorname","\\begin","\\end"].includes($.value)){if(J>=z.length||z[J]!=="{")throw new F(`No content for ${$.value} command`);V.push(new G(6,"{"));const Z=Vz(z,J);J++;let j=z.slice(J,Z);const W=["{","}","\\","$","&","#","_","%"];for(let O of W)j=j.replaceAll("\\"+O,O);V.push(new G(2,j)),V.push(new G(6,"}")),J=Z+1}}return V}function Xz(z){const V=(X)=>X.eq(N)||X.eq(m);let J=[];for(let X=0;X<z.length;X++){if(z[X].type===4&&X+1<z.length&&V(z[X+1]))continue;if(z[X].type===4&&X-1>=0&&V(z[X-1]))continue;J.push(z[X])}return J}function Zz(z,V){let J=[];for(let X of z)if(X.type===1&&V[X.value]){const $=_(V[X.value]);J=J.concat($)}else J.push(X);return J}function y(z,V){const J=new i;let X=_(z);return X=Xz(X),X=Zz(X,V),J.parse(X)}var p=["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"],k=["frac","tfrac","binom","dbinom","dfrac","tbinom","overset"];class G{type;value;constructor(z,V){this.type=z,this.value=V}eq(z){return this.type===z.type&&this.value===z.value}}var I=new Q("empty",""),M=new G(6,"{"),h=new G(6,"}"),g=new G(0,"["),n=new G(0,"]"),L=new G(1,"\\left"),o=new G(1,"\\right"),P=new G(1,"\\begin"),zz=new G(1,"\\end");class F extends Error{constructor(z){super(z);this.name="LatexParserError"}}var N=new G(6,"_"),m=new G(6,"^");class i{space_sensitive;newline_sensitive;constructor(z=!1,V=!0){this.space_sensitive=z,this.newline_sensitive=V}parse(z){const V=[];let J=0;while(J<z.length){const X=[];let $=0;while($<z.length){const[Z,j]=this.parseNextExpr(z,$);if($=j,Z.type==="whitespace"){if(!this.space_sensitive&&Z.content.replace(/ /g,"").length===0)continue;if(!this.newline_sensitive&&Z.content==="\n")continue}if(Z.type==="control"&&Z.content==="&")throw new F("Unexpected & outside of an alignment");X.push(Z)}if(X.length===0)return I;else if(X.length===1)return X[0];else return new Q("ordgroup","",X)}if(V.length===0)return I;else if(V.length===1)return V[0];else return new Q("ordgroup","",V)}parseNextExpr(z,V){let[J,X]=this.parseNextExprWithoutSupSub(z,V),$=null,Z=null,j=0;if(j+=f(z,X),X+=j,X<z.length&&z[X].eq(N)){if([$,X]=this.parseNextExprWithoutSupSub(z,X+1),j+=f(z,X),X+=j,X<z.length&&z[X].eq(m)){if([Z,X]=this.parseNextExprWithoutSupSub(z,X+1),f(z,X)>0)throw new F("Double superscript")}}else if(X<z.length&&z[X].eq(m)){if([Z,X]=this.parseNextExprWithoutSupSub(z,X+1),f(z,X)>0)throw new F("Double superscript");if(X<z.length&&z[X].eq(N)){if([$,X]=this.parseNextExprWithoutSupSub(z,X+1),f(z,X)>0)throw new F("Double superscript")}}if($!==null||Z!==null||j>0){const W={base:J};if($)W.sub=$;if(j>0){W.sup=new Q("ordgroup","",[]);for(let O=0;O<j;O++)W.sup.args.push(new Q("element","'"));if(Z)W.sup.args.push(Z);if(W.sup.args.length===1)W.sup=W.sup.args[0]}else if(Z)W.sup=Z;return[new Q("supsub","",[],W),X]}else return[J,X]}parseNextExprWithoutSupSub(z,V){const J=z[V];switch(J.type){case 0:return[new Q("element",J.value),V+1];case 2:return[new Q("text",J.value),V+1];case 3:return[new Q("comment",J.value),V+1];case 4:case 5:return[new Q("whitespace",J.value),V+1];case 1:if(J.eq(P))return this.parseBeginEndExpr(z,V);else if(J.eq(L))return this.parseLeftRightExpr(z,V);else return this.parseCommandExpr(z,V);case 6:switch(J.value){case"{":const Z=T(z,V),j=z.slice(V+1,Z);return[this.parse(j),Z+1];case"}":throw new F("Unmatched '}'");case"\\\\":return[new Q("control","\\\\"),V+1];case"\\,":return[new Q("control","\\,"),V+1];case"_":return[I,V];case"^":return[I,V];case"&":return[new Q("control","&"),V+1];default:throw new F("Unknown control sequence")}default:throw new F("Unknown token type")}}parseCommandExpr(z,V){D(z[V].type===1);const J=z[V].value;let X=V+1;if(["left","right","begin","end"].includes(J.slice(1)))throw new F("Unexpected command: "+J);switch(r(J.slice(1))){case 0:if(!H.has(J.slice(1)))return[new Q("unknownMacro",J),X];return[new Q("symbol",J),X];case 1:{if(J==="\\sqrt"&&X<z.length&&z[X].eq(g)){const W=X,O=t(z,X),B=z.slice(W+1,O),v=this.parse(B),[b,C]=this.parseNextExprWithoutSupSub(z,O+1);return[new Q("unaryFunc",J,[b],v),C]}else if(J==="\\text"){if(X+2>=z.length)throw new F("Expecting content for \\text command");D(z[X].eq(M)),D(z[X+1].type===2),D(z[X+2].eq(h));const W=z[X+1].value;return[new Q("text",W),X+3]}let[Z,j]=this.parseNextExprWithoutSupSub(z,X);return[new Q("unaryFunc",J,[Z]),j]}case 2:{const[Z,j]=this.parseNextExprWithoutSupSub(z,X),[W,O]=this.parseNextExprWithoutSupSub(z,j);return[new Q("binaryFunc",J,[Z,W]),O]}default:throw new Error("Invalid number of parameters")}}parseLeftRightExpr(z,V){D(z[V].eq(L));let J=V+1;if(J+=R(z,J).length,J>=z.length)throw new F("Expecting delimiter after \\left");const X=c(z,J);if(X===null)throw new F("Invalid delimiter after \\left");J++;const $=J,Z=e(z,J);if(Z===-1)throw new F("No matching \\right");const j=Z;if(J=Z+1,J+=R(z,J).length,J>=z.length)throw new F("Expecting \\right after \\left");const W=c(z,J);if(W===null)throw new F("Invalid delimiter after \\right");J++;const O=z.slice($,j),B=this.parse(O),v=[new Q("element",X.value),B,new Q("element",W.value)];return[new Q("leftright","",v),J]}parseBeginEndExpr(z,V){D(z[V].eq(P));let J=V+1;D(z[J].eq(M)),D(z[J+1].type===2),D(z[J+2].eq(h));const X=z[J+1].value;J+=3,J+=R(z,J).length;const $=J,Z=Jz(z,J);if(Z===-1)throw new F("No matching \\end");const j=Z;if(J=Z+1,D(z[J].eq(M)),D(z[J+1].type===2),D(z[J+2].eq(h)),z[J+1].value!==X)throw new F("Mismatched \\begin and \\end environments");J+=3;const W=z.slice($,j);while(W.length>0&&[4,5].includes(W[W.length-1].type))W.pop();const O=this.parseAligned(W);return[new Q("beginend",X,[],O),J]}parseAligned(z){let V=0;const J=[];let X=[];J.push(X);let $=new Q("ordgroup","",[]);X.push($);while(V<z.length){const[Z,j]=this.parseNextExpr(z,V);if(V=j,Z.type==="whitespace"){if(!this.space_sensitive&&Z.content.replace(/ /g,"").length===0)continue;if(!this.newline_sensitive&&Z.content==="\n")continue}if(Z.type==="control"&&Z.content==="\\\\")X=[],$=new Q("ordgroup","",[]),X.push($),J.push(X);else if(Z.type==="control"&&Z.content==="&")$=new Q("ordgroup","",[]),X.push($);else $.args.push(Z)}return J}}function x(z){return z.type==="atom"&&["(",")","[","]","{","}","|","\u230A","\u230B","\u2308","\u2309"].includes(z.content)}function jz(z){const[V,J]=z.args,X=(j)=>{if(j.eq_shallow(new Q("text","def")))return!0;if(j.type==="ordgroup"&&j.args.length===3){const[W,O,B]=j.args,v=new Q("element","d"),b=new Q("element","e"),C=new Q("element","f");if(W.eq_shallow(v)&&O.eq_shallow(b)&&B.eq_shallow(C))return!0}return!1},$=(j)=>j.eq_shallow(new Q("element","="));if(X(V)&&$(J))return new q("symbol","eq.def");const Z=new q("unaryFunc","op",[U(J)]);return Z.setOptions({limits:"#true"}),new q("supsub","",[],{base:Z,sup:U(V)})}function U(z){switch(z.type){case"empty":return new q("empty","");case"whitespace":return new q("whitespace",z.content);case"ordgroup":return new q("group","",z.args.map(U));case"element":return new q("atom",w(z.content));case"symbol":return new q("symbol",w(z.content));case"text":return new q("text",z.content);case"comment":return new q("comment",z.content);case"supsub":{let{base:V,sup:J,sub:X}=z.data;if(V&&V.type==="unaryFunc"&&V.content==="\\overbrace"&&J)return new q("binaryFunc","overbrace",[U(V.args[0]),U(J)]);else if(V&&V.type==="unaryFunc"&&V.content==="\\underbrace"&&X)return new q("binaryFunc","underbrace",[U(V.args[0]),U(X)]);const $={base:U(V)};if($.base.type==="empty")$.base=new q("text","");if(J)$.sup=U(J);if(X)$.sub=U(X);return new q("supsub","",[],$)}case"leftright":{const[V,J,X]=z.args,$=new q("group","",z.args.map(U));if(["[]","()","\\{\\}","\\lfloor\\rfloor","\\lceil\\rceil","\\lfloor\\rceil"].includes(V.content+X.content))return $;return new q("unaryFunc","lr",[$])}case"binaryFunc":{if(z.content==="\\overset")return jz(z);return new q("binaryFunc",w(z.content),z.args.map(U))}case"unaryFunc":{const V=U(z.args[0]);if(z.content==="\\sqrt"&&z.data){const J=U(z.data);return new q("binaryFunc","root",[J,V])}if(z.content==="\\mathbf"){const J=new q("unaryFunc","bold",[V]);return new q("unaryFunc","upright",[J])}if(z.content==="\\mathbb"&&V.type==="atom"&&/^[A-Z]$/.test(V.content))return new q("symbol",V.content+V.content);if(z.content==="\\operatorname"){const J=z.args;if(J.length!==1||J[0].type!=="text")throw new Y("Expecting body of \\operatorname to be text but got",z);const X=J[0].content;if($z.includes(X))return new q("symbol",X);else return new q("unaryFunc","op",[new q("text",X)])}return new q("unaryFunc",w(z.content),z.args.map(U))}case"beginend":{const J=z.data.map((X)=>X.map(U));if(z.content.startsWith("align"))return new q("align","",[],J);else{const X=new q("matrix","",[],J);return X.setOptions({delim:"#none"}),X}}case"unknownMacro":return new q("unknown",w(z.content));case"control":if(z.content==="\\\\")return new q("symbol","\\");else if(z.content==="\\,")return new q("symbol","thin");else throw new Y(`Unknown control sequence: ${z.content}`,z);default:throw new Y(`Unimplemented node type: ${z.type}`,z)}}function w(z){if(/^[a-zA-Z0-9]$/.test(z))return z;else if(z==="/")return"\\/";else if(z==="\\|")return"parallel";else if(z==="\\colon")return":";else if(z==="\\\\")return"\\";else if(["\\$","\\#","\\&","\\_"].includes(z))return z;else if(z.startsWith("\\")){const V=z.slice(1);if(H.has(V))return H.get(V);else return V}return z}var $z=["dim","id","im","mod","Pr","sech","csch"],S=new K(1,"("),A=new K(1,")"),Qz=new K(1,","),qz=new K(0,"\n");class Y extends Error{node;constructor(z,V){super(z);this.name="TypstWriterError",this.node=V}}class u{nonStrict;preferTypstIntrinsic;keepSpaces;buffer="";queue=[];insideFunctionDepth=0;constructor(z,V,J){this.nonStrict=z,this.preferTypstIntrinsic=V,this.keepSpaces=J}writeBuffer(z){const V=z.content;if(V==="")return;let J=!1;if(J||=/[\(\|]$/.test(this.buffer)&&/^\w/.test(V),J||=/^[}()_^,;!\|]$/.test(V),J||=V==="'",J||=/[0-9]$/.test(this.buffer)&&/^[0-9]/.test(V),J||=/[\(\[{]\s*(-|\+)$/.test(this.buffer)||this.buffer==="-"||this.buffer==="+",J||=V.startsWith("\n"),J||=this.buffer==="",J||=/^\s/.test(V),J||=/[\s_^{\(]$/.test(this.buffer),!J)this.buffer+=" ";this.buffer+=V}serialize(z){switch(z.type){case"empty":break;case"atom":{if(z.content===","&&this.insideFunctionDepth>0)this.queue.push(new K(0,"comma"));else this.queue.push(new K(1,z.content));break}case"symbol":this.queue.push(new K(0,z.content));break;case"text":this.queue.push(new K(2,`"${z.content}"`));break;case"comment":this.queue.push(new K(3,`//${z.content}`));break;case"whitespace":for(let V of z.content)if(V===" "){if(this.keepSpaces)this.queue.push(new K(4,V))}else if(V==="\n")this.queue.push(new K(0,V));else throw new Y(`Unexpected whitespace character: ${V}`,z);break;case"group":for(let V of z.args)this.serialize(V);break;case"supsub":{let{base:V,sup:J,sub:X}=z.data;this.appendWithBracketsIfNeeded(V);let $=!1;const Z=J&&J.type==="atom"&&J.content==="\'";if(Z)this.queue.push(new K(1,"\'")),$=!1;if(X)this.queue.push(new K(1,"_")),$=this.appendWithBracketsIfNeeded(X);if(J&&!Z)this.queue.push(new K(1,"^")),$=this.appendWithBracketsIfNeeded(J);if($)this.queue.push(new K(6," "));break}case"binaryFunc":{const V=new K(0,z.content),[J,X]=z.args;this.queue.push(V),this.insideFunctionDepth++,this.queue.push(S),this.serialize(J),this.queue.push(new K(1,",")),this.serialize(X),this.queue.push(A),this.insideFunctionDepth--;break}case"unaryFunc":{const V=new K(0,z.content),J=z.args[0];if(this.queue.push(V),this.insideFunctionDepth++,this.queue.push(S),this.serialize(J),z.options)for(let[X,$]of Object.entries(z.options))this.queue.push(new K(0,`, ${X}: ${$}`));this.queue.push(A),this.insideFunctionDepth--;break}case"align":{const V=z.data;V.forEach((J,X)=>{if(J.forEach(($,Z)=>{if(Z>0)this.queue.push(new K(1,"&"));this.serialize($)}),X<V.length-1)this.queue.push(new K(0,"\\"))});break}case"matrix":{const V=z.data;if(this.queue.push(new K(0,"mat")),this.insideFunctionDepth++,this.queue.push(S),z.options)for(let[J,X]of Object.entries(z.options))this.queue.push(new K(0,`${J}: ${X}, `));V.forEach((J,X)=>{J.forEach(($,Z)=>{if(this.serialize($),Z<J.length-1)this.queue.push(new K(1,","));else if(X<V.length-1)this.queue.push(new K(1,";"))})}),this.queue.push(A),this.insideFunctionDepth--;break}case"unknown":{if(this.nonStrict)this.queue.push(new K(0,z.content));else throw new Y(`Unknown macro: ${z.content}`,z);break}default:throw new Y(`Unimplemented node type to append: ${z.type}`,z)}}appendWithBracketsIfNeeded(z){let V=["group","supsub","empty"].includes(z.type);if(z.type==="group"){const J=z.args[0],X=z.args[z.args.length-1];if(x(J)&&x(X))V=!1}if(V)this.queue.push(S),this.serialize(z),this.queue.push(A);else this.serialize(z);return!V}flushQueue(){const z=new K(6," ");for(let V=0;V<this.queue.length;V++)if(this.queue[V].eq(z)){if(V===this.queue.length-1)this.queue[V].content="";else if(this.queue[V+1].isOneOf([A,Qz,qz]))this.queue[V].content=""}this.queue.forEach((V)=>{this.writeBuffer(V)}),this.queue=[]}finalize(){this.flushQueue();const X=[function($){let Z=$.replace(/floor\.l\s*(.*?)\s*floor\.r/g,"floor($1)");return Z=Z.replace(/floor\(\)/g,'floor("")'),Z},function($){let Z=$.replace(/ceil\.l\s*(.*?)\s*ceil\.r/g,"ceil($1)");return Z=Z.replace(/ceil\(\)/g,'ceil("")'),Z},function($){let Z=$.replace(/floor\.l\s*(.*?)\s*ceil\.r/g,"round($1)");return Z=Z.replace(/round\(\)/g,'round("")'),Z}];for(let $ of X)this.buffer=$(this.buffer);return this.buffer}}function d(z,V){const J={nonStrict:!0,preferTypstIntrinsic:!0,keepSpaces:!1,customTexMacros:{}};if(V){if(V.nonStrict)J.nonStrict=V.nonStrict;if(V.preferTypstIntrinsic)J.preferTypstIntrinsic=V.preferTypstIntrinsic;if(V.customTexMacros)J.customTexMacros=V.customTexMacros}const X=y(z,J.customTexMacros),$=U(X),Z=new u(J.nonStrict,J.preferTypstIntrinsic,J.keepSpaces);return Z.serialize($),Z.finalize()}if(typeof window!=="undefined")window.tex2typst=d; |
@@ -1,2 +0,2 @@ | ||
export declare enum TokenType { | ||
export declare enum TexTokenType { | ||
ELEMENT = 0, | ||
@@ -6,3 +6,3 @@ COMMAND = 1, | ||
COMMENT = 3, | ||
WHITESPACE = 4, | ||
SPACE = 4, | ||
NEWLINE = 5, | ||
@@ -19,8 +19,38 @@ CONTROL = 6, | ||
export type TexArrayData = TexNode[][]; | ||
export interface TexNode { | ||
type: 'element' | 'text' | 'comment' | 'whitespace' | 'newline' | 'control' | 'ordgroup' | 'supsub' | 'unaryFunc' | 'binaryFunc' | 'leftright' | 'beginend' | 'symbol' | 'empty' | 'unknownMacro'; | ||
/** | ||
* element: 0-9, a-z, A-Z, punctuations such as +-/*,:; etc. | ||
* symbol: LaTeX macro with no parameter. e.g. \sin \cos \int \sum | ||
* unaryFunc: LaTeX macro with 1 parameter. e.g. \sqrt{3} \log{x} \exp{x} | ||
* binaryFunc: LaTeX macro with 2 parameters. e.g. \frac{1}{2} | ||
* text: text enclosed by braces. e.g. \text{hello world} | ||
* empty: special type when something is empty. e.g. the base of _{a} or ^{a} | ||
* whitespace: space, tab, newline | ||
*/ | ||
type TexNodeType = 'element' | 'text' | 'comment' | 'whitespace' | 'control' | 'ordgroup' | 'supsub' | 'unaryFunc' | 'binaryFunc' | 'leftright' | 'beginend' | 'symbol' | 'empty' | 'unknownMacro'; | ||
export declare class TexNode { | ||
type: TexNodeType; | ||
content: string; | ||
args?: TexNode[]; | ||
data?: TexSqrtData | TexSupsubData | TexArrayData; | ||
constructor(type: TexNodeType, content: string, args?: TexNode[], data?: TexSqrtData | TexSupsubData | TexArrayData); | ||
eq_shallow(other: TexNode): boolean; | ||
toString(): string; | ||
} | ||
export declare enum TypstTokenType { | ||
SYMBOL = 0, | ||
ATOM = 1, | ||
TEXT = 2, | ||
COMMENT = 3, | ||
SPACE = 4, | ||
SOFT_SPACE = 5, | ||
CONTROL = 6, | ||
NEWLINE = 7 | ||
} | ||
export declare class TypstToken { | ||
type: TypstTokenType; | ||
content: string; | ||
constructor(type: TypstTokenType, content: string); | ||
eq(other: TypstToken): boolean; | ||
isOneOf(tokens: TypstToken[]): boolean; | ||
} | ||
export interface TypstSupsubData { | ||
@@ -32,4 +62,5 @@ base: TypstNode; | ||
export type TypstArrayData = TypstNode[][]; | ||
export interface TypstNode { | ||
type: 'atom' | 'symbol' | 'text' | 'softSpace' | 'comment' | 'newline' | 'empty' | 'group' | 'supsub' | 'unaryFunc' | 'binaryFunc' | 'align' | 'matrix' | 'unknown'; | ||
type TypstNodeType = 'atom' | 'symbol' | 'text' | 'softSpace' | 'comment' | 'whitespace' | 'empty' | 'group' | 'supsub' | 'unaryFunc' | 'binaryFunc' | 'align' | 'matrix' | 'unknown'; | ||
export declare class TypstNode { | ||
type: TypstNodeType; | ||
content: string; | ||
@@ -41,2 +72,7 @@ args?: TypstNode[]; | ||
}; | ||
constructor(type: TypstNodeType, content: string, args?: TypstNode[], data?: TypstSupsubData | TypstArrayData); | ||
setOptions(options: { | ||
[key: string]: string; | ||
}): void; | ||
eq_shallow(other: TypstNode): boolean; | ||
} | ||
@@ -46,2 +82,3 @@ export interface Tex2TypstOptions { | ||
preferTypstIntrinsic?: boolean; | ||
keepSpaces?: boolean; | ||
customTexMacros?: { | ||
@@ -51,1 +88,2 @@ [key: string]: string; | ||
} | ||
export {}; |
@@ -1,5 +0,5 @@ | ||
import { TexNode, TypstNode } from "./types"; | ||
import { TexNode, TypstNode, TypstToken } from "./types"; | ||
export declare class TypstWriterError extends Error { | ||
node: TexNode | TypstNode; | ||
constructor(message: string, node: TexNode | TypstNode); | ||
node: TexNode | TypstNode | TypstToken; | ||
constructor(message: string, node: TexNode | TypstNode | TypstToken); | ||
} | ||
@@ -9,9 +9,9 @@ export declare class TypstWriter { | ||
private preferTypstIntrinsic; | ||
private keepSpaces; | ||
protected buffer: string; | ||
protected queue: TypstNode[]; | ||
private needSpaceAfterSingleItemScript; | ||
protected queue: TypstToken[]; | ||
private insideFunctionDepth; | ||
constructor(nonStrict: boolean, preferTypstIntrinsic: boolean); | ||
constructor(nonStrict: boolean, preferTypstIntrinsic: boolean, keepSpaces: boolean); | ||
private writeBuffer; | ||
append(node: TypstNode): void; | ||
serialize(node: TypstNode): void; | ||
private appendWithBracketsIfNeeded; | ||
@@ -18,0 +18,0 @@ protected flushQueue(): void; |
{ | ||
"name": "tex2typst", | ||
"version": "0.2.13", | ||
"version": "0.2.15", | ||
"description": "JavaScript library for converting TeX code to Typst", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -1,2 +0,2 @@ | ||
import { parseTex } from "./parser"; | ||
import { parseTex } from "./tex-parser"; | ||
import { Tex2TypstOptions } from "./types"; | ||
@@ -11,2 +11,3 @@ import { convertTree, TypstWriter } from "./writer"; | ||
preferTypstIntrinsic: true, | ||
keepSpaces: false, | ||
customTexMacros: {} | ||
@@ -27,4 +28,4 @@ }; | ||
const typstTree = convertTree(texTree); | ||
const writer = new TypstWriter(opt.nonStrict!, opt.preferTypstIntrinsic!); | ||
writer.append(typstTree); | ||
const writer = new TypstWriter(opt.nonStrict!, opt.preferTypstIntrinsic!, opt.keepSpaces!); | ||
writer.serialize(typstTree); | ||
return writer.finalize(); | ||
@@ -31,0 +32,0 @@ } |
107
src/types.ts
@@ -1,2 +0,2 @@ | ||
export enum TokenType { | ||
export enum TexTokenType { | ||
ELEMENT, | ||
@@ -6,3 +6,3 @@ COMMAND, | ||
COMMENT, | ||
WHITESPACE, | ||
SPACE, | ||
NEWLINE, | ||
@@ -25,14 +25,81 @@ CONTROL, | ||
export interface TexNode { | ||
type: 'element' | 'text' | 'comment' | 'whitespace' | 'newline' | 'control' | 'ordgroup' | 'supsub' | ||
/** | ||
* element: 0-9, a-z, A-Z, punctuations such as +-/*,:; etc. | ||
* symbol: LaTeX macro with no parameter. e.g. \sin \cos \int \sum | ||
* unaryFunc: LaTeX macro with 1 parameter. e.g. \sqrt{3} \log{x} \exp{x} | ||
* binaryFunc: LaTeX macro with 2 parameters. e.g. \frac{1}{2} | ||
* text: text enclosed by braces. e.g. \text{hello world} | ||
* empty: special type when something is empty. e.g. the base of _{a} or ^{a} | ||
* whitespace: space, tab, newline | ||
*/ | ||
type TexNodeType = 'element' | 'text' | 'comment' | 'whitespace' | 'control' | 'ordgroup' | 'supsub' | ||
| 'unaryFunc' | 'binaryFunc' | 'leftright' | 'beginend' | 'symbol' | 'empty' | 'unknownMacro'; | ||
export class TexNode { | ||
type: TexNodeType; | ||
content: string; | ||
args?: TexNode[]; | ||
// position?: Position; | ||
// For type="sqrt", it's additional argument wrapped square bracket. e.g. 3 in \sqrt[3]{x} | ||
// For type="supsub", it's base, sup, and sub. | ||
// For type="array", it's the 2-dimensional matrix. | ||
// For type="beginend", it's the 2-dimensional matrix. | ||
data?: TexSqrtData | TexSupsubData | TexArrayData; | ||
constructor(type: TexNodeType, content: string, args?: TexNode[], | ||
data?: TexSqrtData | TexSupsubData | TexArrayData) { | ||
this.type = type; | ||
this.content = content; | ||
this.args = args; | ||
this.data = data; | ||
} | ||
public eq_shallow(other: TexNode): boolean { | ||
return this.type === other.type && this.content === other.content; | ||
} | ||
public toString(): string { | ||
switch (this.type) { | ||
case 'text': | ||
return `\\text{${this.content}}`; | ||
default: | ||
throw new Error(`toString() is not implemented for type ${this.type}`); | ||
} | ||
} | ||
} | ||
export enum TypstTokenType { | ||
SYMBOL, | ||
ATOM, | ||
TEXT, | ||
COMMENT, | ||
SPACE, | ||
SOFT_SPACE, | ||
CONTROL, | ||
NEWLINE, | ||
} | ||
export class TypstToken { | ||
type: TypstTokenType; | ||
content: string; | ||
constructor(type: TypstTokenType, content: string) { | ||
this.type = type; | ||
this.content = content; | ||
} | ||
eq(other: TypstToken): boolean { | ||
return this.type === other.type && this.content === other.content; | ||
} | ||
isOneOf(tokens: TypstToken[]): boolean { | ||
let found = false; | ||
for (const token of tokens) { | ||
if (this.eq(token)) { | ||
found = true; | ||
break; | ||
} | ||
} | ||
return found; | ||
} | ||
} | ||
export interface TypstSupsubData { | ||
@@ -46,5 +113,8 @@ base: TypstNode; | ||
export interface TypstNode { | ||
type: 'atom' | 'symbol' | 'text' | 'softSpace' | 'comment' | 'newline' | ||
type TypstNodeType = 'atom' | 'symbol' | 'text' | 'softSpace' | 'comment' | 'whitespace' | ||
| 'empty' | 'group' | 'supsub' | 'unaryFunc' | 'binaryFunc' | 'align' | 'matrix' | 'unknown'; | ||
export class TypstNode { | ||
type: TypstNodeType; | ||
content: string; | ||
@@ -55,9 +125,26 @@ args?: TypstNode[]; | ||
options?: { [key: string]: string }; | ||
constructor(type: TypstNodeType, content: string, args?: TypstNode[], | ||
data?: TypstSupsubData | TypstArrayData) { | ||
this.type = type; | ||
this.content = content; | ||
this.args = args; | ||
this.data = data; | ||
} | ||
public setOptions(options: { [key: string]: string }) { | ||
this.options = options; | ||
} | ||
public eq_shallow(other: TypstNode): boolean { | ||
return this.type === other.type && this.content === other.content; | ||
} | ||
} | ||
export interface Tex2TypstOptions { | ||
nonStrict?: boolean; // default is false | ||
preferTypstIntrinsic?: boolean; // default is false, | ||
nonStrict?: boolean; // default is true | ||
preferTypstIntrinsic?: boolean; // default is true, | ||
keepSpaces?: boolean; // default is false | ||
customTexMacros?: { [key: string]: string }; | ||
// TODO: custom typst functions | ||
} |
import { symbolMap } from "./map"; | ||
import { TexNode, TexSqrtData, TexSupsubData, TypstNode, TypstSupsubData } from "./types"; | ||
import { TexNode, TexSqrtData, TexSupsubData, TypstNode, TypstSupsubData, TypstToken, TypstTokenType } from "./types"; | ||
@@ -22,5 +22,2 @@ | ||
function text_node_shallow_eq(a: TexNode, b: TexNode): boolean { | ||
return (a.type === b.type) && (a.content === b.content); | ||
} | ||
@@ -33,12 +30,12 @@ // \overset{X}{Y} -> op(Y, limits: #true)^X | ||
const is_def = (n: TexNode): boolean => { | ||
if(n.type === 'text' && n.content === 'def') { | ||
if (n.eq_shallow(new TexNode('text', 'def'))) { | ||
return true; | ||
} | ||
// \overset{def}{=} is also considered as eq.def | ||
if(n.type === 'ordgroup' && n.args!.length === 3) { | ||
if (n.type === 'ordgroup' && n.args!.length === 3) { | ||
const [a1, a2, a3] = n.args!; | ||
const d: TexNode = { type: 'element', content: 'd' }; | ||
const e: TexNode = { type: 'element', content: 'e' }; | ||
const f: TexNode = { type: 'element', content: 'f' }; | ||
if(text_node_shallow_eq(a1, d) && text_node_shallow_eq(a2, e) && text_node_shallow_eq(a3, f)) { | ||
const d = new TexNode('element', 'd'); | ||
const e = new TexNode('element', 'e'); | ||
const f = new TexNode('element', 'f'); | ||
if (a1.eq_shallow(d) && a2.eq_shallow(e) && a3.eq_shallow(f)) { | ||
return true; | ||
@@ -49,29 +46,32 @@ } | ||
}; | ||
const is_eq = (n: TexNode): boolean => (n.type === 'element' && n.content === '='); | ||
if(is_def(sup) && is_eq(base)) { | ||
return { | ||
type: 'symbol', | ||
content: 'eq.def', | ||
}; | ||
const is_eq = (n: TexNode): boolean => n.eq_shallow(new TexNode('element', '=')); | ||
if (is_def(sup) && is_eq(base)) { | ||
return new TypstNode('symbol', 'eq.def'); | ||
} | ||
const op_call: TypstNode = { | ||
type: 'unaryFunc', | ||
content: 'op', | ||
args: [convertTree(base)], | ||
options: { limits: '#true' }, | ||
}; | ||
return { | ||
type: 'supsub', | ||
content: '', | ||
data: { | ||
const op_call = new TypstNode( | ||
'unaryFunc', | ||
'op', | ||
[convertTree(base)] | ||
); | ||
op_call.setOptions({ limits: '#true' }); | ||
return new TypstNode( | ||
'supsub', | ||
'', | ||
[], | ||
{ | ||
base: op_call, | ||
sup: convertTree(sup), | ||
}, | ||
} | ||
} | ||
); | ||
} | ||
const TYPST_LEFT_PARENTHESIS: TypstToken = new TypstToken(TypstTokenType.ATOM, '('); | ||
const TYPST_RIGHT_PARENTHESIS: TypstToken = new TypstToken(TypstTokenType.ATOM, ')'); | ||
const TYPST_COMMA: TypstToken = new TypstToken(TypstTokenType.ATOM, ','); | ||
const TYPST_NEWLINE: TypstToken = new TypstToken(TypstTokenType.SYMBOL, '\n'); | ||
export class TypstWriterError extends Error { | ||
node: TexNode | TypstNode; | ||
node: TexNode | TypstNode | TypstToken; | ||
constructor(message: string, node: TexNode | TypstNode) { | ||
constructor(message: string, node: TexNode | TypstNode | TypstToken) { | ||
super(message); | ||
@@ -86,43 +86,44 @@ this.name = "TypstWriterError"; | ||
private preferTypstIntrinsic: boolean; | ||
private keepSpaces: boolean; | ||
protected buffer: string = ""; | ||
protected queue: TypstNode[] = []; | ||
protected queue: TypstToken[] = []; | ||
private needSpaceAfterSingleItemScript = false; | ||
private insideFunctionDepth = 0; | ||
constructor(nonStrict: boolean, preferTypstIntrinsic: boolean) { | ||
constructor(nonStrict: boolean, preferTypstIntrinsic: boolean, keepSpaces: boolean) { | ||
this.nonStrict = nonStrict; | ||
this.preferTypstIntrinsic = preferTypstIntrinsic; | ||
this.keepSpaces = keepSpaces; | ||
} | ||
private writeBuffer(str: string) { | ||
if (this.needSpaceAfterSingleItemScript && /^[0-9a-zA-Z\(]/.test(str)) { | ||
this.buffer += ' '; | ||
} else { | ||
let no_need_space = false; | ||
// starting clause | ||
no_need_space ||= /[\(\|]$/.test(this.buffer) && /^\w/.test(str); | ||
// putting punctuation | ||
no_need_space ||= /^[}()_^,;!\|]$/.test(str); | ||
// putting a prime | ||
no_need_space ||= str === "'"; | ||
// continue a number | ||
no_need_space ||= /[0-9]$/.test(this.buffer) && /^[0-9]/.test(str); | ||
// leading sign | ||
no_need_space ||= /[\(\[{]\s*(-|\+)$/.test(this.buffer) || this.buffer === "-" || this.buffer === "+"; | ||
// new line | ||
no_need_space ||= str.startsWith('\n'); | ||
// buffer is empty | ||
no_need_space ||= this.buffer === ""; | ||
// other cases | ||
no_need_space ||= /[\s_^{\(]$/.test(this.buffer); | ||
if(!no_need_space) { | ||
this.buffer += ' '; | ||
} | ||
private writeBuffer(token: TypstToken) { | ||
const str = token.content; | ||
if (str === '') { | ||
return; | ||
} | ||
if (this.needSpaceAfterSingleItemScript) { | ||
this.needSpaceAfterSingleItemScript = false; | ||
let no_need_space = false; | ||
// starting clause | ||
no_need_space ||= /[\(\|]$/.test(this.buffer) && /^\w/.test(str); | ||
// putting punctuation | ||
no_need_space ||= /^[}()_^,;!\|]$/.test(str); | ||
// putting a prime | ||
no_need_space ||= str === "'"; | ||
// continue a number | ||
no_need_space ||= /[0-9]$/.test(this.buffer) && /^[0-9]/.test(str); | ||
// leading sign. e.g. produce "+1" instead of " +1" | ||
no_need_space ||= /[\(\[{]\s*(-|\+)$/.test(this.buffer) || this.buffer === "-" || this.buffer === "+"; | ||
// new line | ||
no_need_space ||= str.startsWith('\n'); | ||
// buffer is empty | ||
no_need_space ||= this.buffer === ""; | ||
// str is starting with a space itself | ||
no_need_space ||= /^\s/.test(str); | ||
// other cases | ||
no_need_space ||= /[\s_^{\(]$/.test(this.buffer); | ||
if (!no_need_space) { | ||
this.buffer += ' '; | ||
} | ||
@@ -133,3 +134,4 @@ | ||
public append(node: TypstNode) { | ||
// Serialize a tree of TypstNode into a list of TypstToken | ||
public serialize(node: TypstNode) { | ||
switch (node.type) { | ||
@@ -140,5 +142,5 @@ case 'empty': | ||
if (node.content === ',' && this.insideFunctionDepth > 0) { | ||
this.queue.push({ type: 'symbol', content: 'comma' }); | ||
this.queue.push(new TypstToken(TypstTokenType.SYMBOL, 'comma')); | ||
} else { | ||
this.queue.push({ type: 'atom', content: node.content }); | ||
this.queue.push(new TypstToken(TypstTokenType.ATOM, node.content)); | ||
} | ||
@@ -148,10 +150,26 @@ break; | ||
case 'symbol': | ||
this.queue.push(new TypstToken(TypstTokenType.SYMBOL, node.content)); | ||
break; | ||
case 'text': | ||
this.queue.push(new TypstToken(TypstTokenType.TEXT, `"${node.content}"`)); | ||
break; | ||
case 'comment': | ||
case 'newline': | ||
this.queue.push(node); | ||
this.queue.push(new TypstToken(TypstTokenType.COMMENT, `//${node.content}`)); | ||
break; | ||
case 'whitespace': | ||
for (const c of node.content) { | ||
if (c === ' ') { | ||
if (this.keepSpaces) { | ||
this.queue.push(new TypstToken(TypstTokenType.SPACE, c)); | ||
} | ||
} else if (c === '\n') { | ||
this.queue.push(new TypstToken(TypstTokenType.SYMBOL, c)); | ||
} else { | ||
throw new TypstWriterError(`Unexpected whitespace character: ${c}`, node); | ||
} | ||
} | ||
break; | ||
case 'group': | ||
for (const item of node.args!) { | ||
this.append(item); | ||
this.serialize(item); | ||
} | ||
@@ -170,15 +188,15 @@ break; | ||
// y_{a_1}' -> y'_{a_1} | ||
this.queue.push({ type: 'atom', content: '\''}); | ||
this.queue.push(new TypstToken(TypstTokenType.ATOM, '\'')); | ||
trailing_space_needed = false; | ||
} | ||
if (sub) { | ||
this.queue.push({ type: 'atom', content: '_'}); | ||
this.queue.push(new TypstToken(TypstTokenType.ATOM, '_')); | ||
trailing_space_needed = this.appendWithBracketsIfNeeded(sub); | ||
} | ||
if (sup && !has_prime) { | ||
this.queue.push({ type: 'atom', content: '^'}); | ||
this.queue.push(new TypstToken(TypstTokenType.ATOM, '^')); | ||
trailing_space_needed = this.appendWithBracketsIfNeeded(sup); | ||
} | ||
if (trailing_space_needed) { | ||
this.queue.push({ type: 'softSpace', content: ''}); | ||
this.queue.push(new TypstToken(TypstTokenType.CONTROL, ' ')); | ||
} | ||
@@ -188,28 +206,28 @@ break; | ||
case 'binaryFunc': { | ||
const func_symbol: TypstNode = { type: 'symbol', content: node.content }; | ||
const func_symbol: TypstToken = new TypstToken(TypstTokenType.SYMBOL, node.content); | ||
const [arg0, arg1] = node.args!; | ||
this.queue.push(func_symbol); | ||
this.insideFunctionDepth ++; | ||
this.queue.push({ type: 'atom', content: '('}); | ||
this.append(arg0); | ||
this.queue.push({ type: 'atom', content: ','}); | ||
this.append(arg1); | ||
this.queue.push({ type: 'atom', content: ')'}); | ||
this.insideFunctionDepth --; | ||
this.insideFunctionDepth++; | ||
this.queue.push(TYPST_LEFT_PARENTHESIS); | ||
this.serialize(arg0); | ||
this.queue.push(new TypstToken(TypstTokenType.ATOM, ',')); | ||
this.serialize(arg1); | ||
this.queue.push(TYPST_RIGHT_PARENTHESIS); | ||
this.insideFunctionDepth--; | ||
break; | ||
} | ||
case 'unaryFunc': { | ||
const func_symbol: TypstNode = { type: 'symbol', content: node.content }; | ||
const func_symbol: TypstToken = new TypstToken(TypstTokenType.SYMBOL, node.content); | ||
const arg0 = node.args![0]; | ||
this.queue.push(func_symbol); | ||
this.insideFunctionDepth ++; | ||
this.queue.push({ type: 'atom', content: '('}); | ||
this.append(arg0); | ||
if(node.options) { | ||
this.insideFunctionDepth++; | ||
this.queue.push(TYPST_LEFT_PARENTHESIS); | ||
this.serialize(arg0); | ||
if (node.options) { | ||
for (const [key, value] of Object.entries(node.options)) { | ||
this.queue.push({ type: 'symbol', content: `, ${key}: ${value}`}); | ||
this.queue.push(new TypstToken(TypstTokenType.SYMBOL, `, ${key}: ${value}`)); | ||
} | ||
} | ||
this.queue.push({ type: 'atom', content: ')'}); | ||
this.insideFunctionDepth --; | ||
this.queue.push(TYPST_RIGHT_PARENTHESIS); | ||
this.insideFunctionDepth--; | ||
break; | ||
@@ -222,8 +240,8 @@ } | ||
if (j > 0) { | ||
this.queue.push({ type: 'atom', content: '&' }); | ||
this.queue.push(new TypstToken(TypstTokenType.ATOM, '&')); | ||
} | ||
this.append(cell); | ||
this.serialize(cell); | ||
}); | ||
if (i < matrix.length - 1) { | ||
this.queue.push({ type: 'symbol', content: '\\' }); | ||
this.queue.push(new TypstToken(TypstTokenType.SYMBOL, '\\')); | ||
} | ||
@@ -235,6 +253,10 @@ }); | ||
const matrix = node.data as TypstNode[][]; | ||
this.queue.push({ type: 'symbol', content: 'mat' }); | ||
this.insideFunctionDepth ++; | ||
this.queue.push({ type: 'atom', content: '('}); | ||
this.queue.push({type: 'symbol', content: 'delim: #none, '}); | ||
this.queue.push(new TypstToken(TypstTokenType.SYMBOL, 'mat')); | ||
this.insideFunctionDepth++; | ||
this.queue.push(TYPST_LEFT_PARENTHESIS); | ||
if (node.options) { | ||
for (const [key, value] of Object.entries(node.options)) { | ||
this.queue.push(new TypstToken(TypstTokenType.SYMBOL, `${key}: ${value}, `)); | ||
} | ||
} | ||
matrix.forEach((row, i) => { | ||
@@ -244,15 +266,15 @@ row.forEach((cell, j) => { | ||
// if (cell.type === 'ordgroup' && cell.args!.length === 0) { | ||
// this.queue.push({ type: 'atom', content: ',' }); | ||
// return; | ||
// this.queue.push(new TypstNode('atom', ',')); | ||
// return; | ||
// } | ||
// if (j == 0 && cell.type === 'newline' && cell.content === '\n') { | ||
// return; | ||
// return; | ||
// } | ||
this.append(cell); | ||
this.serialize(cell); | ||
// cell.args!.forEach((n) => this.append(n)); | ||
if (j < row.length - 1) { | ||
this.queue.push({ type: 'atom', content: ',' }); | ||
this.queue.push(new TypstToken(TypstTokenType.ATOM, ',')); | ||
} else { | ||
if (i < matrix.length - 1) { | ||
this.queue.push({ type: 'atom', content: ';' }); | ||
this.queue.push(new TypstToken(TypstTokenType.ATOM, ';')); | ||
} | ||
@@ -262,4 +284,4 @@ } | ||
}); | ||
this.queue.push({ type: 'atom', content: ')'}); | ||
this.insideFunctionDepth --; | ||
this.queue.push(TYPST_RIGHT_PARENTHESIS); | ||
this.insideFunctionDepth--; | ||
break; | ||
@@ -269,3 +291,3 @@ } | ||
if (this.nonStrict) { | ||
this.queue.push({ type: 'symbol', content: node.content }); | ||
this.queue.push(new TypstToken(TypstTokenType.SYMBOL, node.content)); | ||
} else { | ||
@@ -293,7 +315,7 @@ throw new TypstWriterError(`Unknown macro: ${node.content}`, node); | ||
if (need_to_wrap) { | ||
this.queue.push({ type: 'atom', content: '(' }); | ||
this.append(node); | ||
this.queue.push({ type: 'atom', content: ')' }); | ||
this.queue.push(TYPST_LEFT_PARENTHESIS); | ||
this.serialize(node); | ||
this.queue.push(TYPST_RIGHT_PARENTHESIS); | ||
} else { | ||
this.append(node); | ||
this.serialize(node); | ||
} | ||
@@ -305,29 +327,20 @@ | ||
protected flushQueue() { | ||
this.queue.forEach((node) => { | ||
let str = ""; | ||
switch (node.type) { | ||
case 'atom': | ||
case 'symbol': | ||
str = node.content; | ||
break; | ||
case 'text': | ||
str = `"${node.content}"`; | ||
break; | ||
case 'softSpace': | ||
this.needSpaceAfterSingleItemScript = true; | ||
str = ''; | ||
break; | ||
case 'comment': | ||
str = `//${node.content}`; | ||
break; | ||
case 'newline': | ||
str = '\n'; | ||
break; | ||
default: | ||
throw new TypstWriterError(`Unexpected node type to stringify: ${node.type}`, node) | ||
const SOFT_SPACE = new TypstToken(TypstTokenType.CONTROL, ' '); | ||
// delete soft spaces if they are not needed | ||
for(let i = 0; i < this.queue.length; i++) { | ||
let token = this.queue[i]; | ||
if (token.eq(SOFT_SPACE)) { | ||
if (i === this.queue.length - 1) { | ||
this.queue[i].content = ''; | ||
} else if (this.queue[i + 1].isOneOf([TYPST_RIGHT_PARENTHESIS, TYPST_COMMA, TYPST_NEWLINE])) { | ||
this.queue[i].content = ''; | ||
} | ||
} | ||
if (str !== '') { | ||
this.writeBuffer(str); | ||
} | ||
} | ||
this.queue.forEach((token) => { | ||
this.writeBuffer(token) | ||
}); | ||
this.queue = []; | ||
@@ -367,21 +380,23 @@ } | ||
// Convert a tree of TexNode into a tree of TypstNode | ||
export function convertTree(node: TexNode): TypstNode { | ||
switch (node.type) { | ||
case 'empty': | ||
return new TypstNode('empty', ''); | ||
case 'whitespace': | ||
return { type: 'empty', content: '' }; | ||
return new TypstNode('whitespace', node.content); | ||
case 'ordgroup': | ||
return { | ||
type: 'group', | ||
content: '', | ||
args: node.args!.map(convertTree), | ||
}; | ||
return new TypstNode( | ||
'group', | ||
'', | ||
node.args!.map(convertTree), | ||
); | ||
case 'element': | ||
return { type: 'atom', content: convertToken(node.content) }; | ||
return new TypstNode('atom', convertToken(node.content)); | ||
case 'symbol': | ||
return { type: 'symbol', content: convertToken(node.content) }; | ||
return new TypstNode('symbol', convertToken(node.content)); | ||
case 'text': | ||
return { type: 'text', content: node.content }; | ||
return new TypstNode('text', node.content); | ||
case 'comment': | ||
return { type: 'comment', content: node.content }; | ||
return new TypstNode('comment', node.content); | ||
case 'supsub': { | ||
@@ -392,13 +407,13 @@ let { base, sup, sub } = node.data as TexSupsubData; | ||
if (base && base.type === 'unaryFunc' && base.content === '\\overbrace' && sup) { | ||
return { | ||
type: 'binaryFunc', | ||
content: 'overbrace', | ||
args: [convertTree(base.args![0]), convertTree(sup)], | ||
}; | ||
return new TypstNode( | ||
'binaryFunc', | ||
'overbrace', | ||
[convertTree(base.args![0]), convertTree(sup)], | ||
); | ||
} else if (base && base.type === 'unaryFunc' && base.content === '\\underbrace' && sub) { | ||
return { | ||
type: 'binaryFunc', | ||
content: 'underbrace', | ||
args: [convertTree(base.args![0]), convertTree(sub)], | ||
}; | ||
return new TypstNode( | ||
'binaryFunc', | ||
'underbrace', | ||
[convertTree(base.args![0]), convertTree(sub)], | ||
); | ||
} | ||
@@ -410,3 +425,3 @@ | ||
if (data.base.type === 'empty') { | ||
data.base = { type: 'text', content: '' }; | ||
data.base = new TypstNode('text', ''); | ||
} | ||
@@ -422,7 +437,3 @@ | ||
return { | ||
type: 'supsub', | ||
content: '', | ||
data: data, | ||
}; | ||
return new TypstNode('supsub', '', [], data); | ||
} | ||
@@ -432,20 +443,20 @@ case 'leftright': { | ||
// These pairs will be handled by Typst compiler by default. No need to add lr() | ||
const group: TypstNode = { | ||
type: 'group', | ||
content: '', | ||
args: node.args!.map(convertTree), | ||
}; | ||
const group: TypstNode = new TypstNode( | ||
'group', | ||
'', | ||
node.args!.map(convertTree), | ||
); | ||
if ([ | ||
"[]", "()", "\\{\\}", | ||
"\\lfloor\\rfloor", | ||
"\\lceil\\rceil", | ||
"\\lfloor\\rceil", | ||
].includes(left.content + right.content)) { | ||
"[]", "()", "\\{\\}", | ||
"\\lfloor\\rfloor", | ||
"\\lceil\\rceil", | ||
"\\lfloor\\rceil", | ||
].includes(left.content + right.content)) { | ||
return group; | ||
} | ||
return { | ||
type: 'unaryFunc', | ||
content: 'lr', | ||
args: [group], | ||
}; | ||
return new TypstNode( | ||
'unaryFunc', | ||
'lr', | ||
[group], | ||
); | ||
} | ||
@@ -456,7 +467,7 @@ case 'binaryFunc': { | ||
} | ||
return { | ||
type: 'binaryFunc', | ||
content: convertToken(node.content), | ||
args: node.args!.map(convertTree), | ||
}; | ||
return new TypstNode( | ||
'binaryFunc', | ||
convertToken(node.content), | ||
node.args!.map(convertTree), | ||
); | ||
} | ||
@@ -468,27 +479,24 @@ case 'unaryFunc': { | ||
const data = convertTree(node.data as TexSqrtData); // the number of times to take the root | ||
return { | ||
type: 'binaryFunc', | ||
content: 'root', | ||
args: [data, arg0], | ||
}; | ||
return new TypstNode( | ||
'binaryFunc', | ||
'root', | ||
[data, arg0], | ||
); | ||
} | ||
// \mathbf{a} -> upright(mathbf(a)) | ||
if (node.content === '\\mathbf') { | ||
const inner: TypstNode = { | ||
type: 'unaryFunc', | ||
content: 'bold', | ||
args: [arg0], | ||
}; | ||
return { | ||
type: 'unaryFunc', | ||
content: 'upright', | ||
args: [inner], | ||
}; | ||
const inner: TypstNode = new TypstNode( | ||
'unaryFunc', | ||
'bold', | ||
[arg0], | ||
); | ||
return new TypstNode( | ||
'unaryFunc', | ||
'upright', | ||
[inner], | ||
); | ||
} | ||
// \mathbb{R} -> RR | ||
if (node.content === '\\mathbb' && arg0.type === 'atom' && /^[A-Z]$/.test(arg0.content)) { | ||
return { | ||
type: 'symbol', | ||
content: arg0.content + arg0.content, | ||
}; | ||
return new TypstNode('symbol', arg0.content + arg0.content); | ||
} | ||
@@ -504,12 +512,9 @@ // \operatorname{opname} -> op("opname") | ||
if (TYPST_INTRINSIC_SYMBOLS.includes(text)) { | ||
return { | ||
type: 'symbol', | ||
content: text, | ||
}; | ||
return new TypstNode('symbol', text); | ||
} else { | ||
return { | ||
type: 'unaryFunc', | ||
content: 'op', | ||
args: [{ type: 'text', content: text }], | ||
}; | ||
return new TypstNode( | ||
'unaryFunc', | ||
'op', | ||
[new TypstNode('text', text)], | ||
); | ||
} | ||
@@ -519,10 +524,8 @@ } | ||
// generic case | ||
return { | ||
type: 'unaryFunc', | ||
content: convertToken(node.content), | ||
args: node.args!.map(convertTree), | ||
}; | ||
return new TypstNode( | ||
'unaryFunc', | ||
convertToken(node.content), | ||
node.args!.map(convertTree), | ||
); | ||
} | ||
case 'newline': | ||
return { type: 'newline', content: '\n' }; | ||
case 'beginend': { | ||
@@ -534,22 +537,16 @@ const matrix = node.data as TexNode[][]; | ||
// align, align*, alignat, alignat*, aligned, etc. | ||
return { | ||
type: 'align', | ||
content: '', | ||
data: data, | ||
}; | ||
return new TypstNode( 'align', '', [], data); | ||
} else { | ||
return { | ||
type: 'matrix', | ||
content: 'mat', | ||
data: data, | ||
}; | ||
const res = new TypstNode('matrix', '', [], data); | ||
res.setOptions({'delim': '#none'}); | ||
return res; | ||
} | ||
} | ||
case 'unknownMacro': | ||
return { type: 'unknown', content: convertToken(node.content) }; | ||
return new TypstNode('unknown', convertToken(node.content)); | ||
case 'control': | ||
if (node.content === '\\\\') { | ||
return { type: 'symbol', content: '\\' }; | ||
return new TypstNode('symbol', '\\'); | ||
} else if (node.content === '\\,') { | ||
return { type: 'symbol', content: 'thin' }; | ||
return new TypstNode('symbol', 'thin'); | ||
} else { | ||
@@ -571,3 +568,5 @@ throw new TypstWriterError(`Unknown control sequence: ${node.content}`, node); | ||
// \| in LaTeX is double vertical bar looks like || | ||
return 'parallel'; | ||
return 'parallel'; | ||
} else if (token === '\\colon') { | ||
return ':'; | ||
} else if (token === '\\\\') { | ||
@@ -574,0 +573,0 @@ return '\\'; |
Sorry, the diff of this file is too big to display
255118
5002