tex2typst 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +346 -178
- package/dist/tex-parser.d.ts +1 -0
- package/dist/tex2typst.min.js +20 -19
- package/dist/types.d.ts +6 -4
- package/package.json +5 -5
- package/src/convert.ts +45 -5
- package/src/index.ts +1 -1
- package/src/tex-parser.ts +33 -44
- package/src/tex-writer.ts +0 -1
- package/src/types.ts +8 -2
- package/src/typst-parser.ts +2 -3
- package/src/typst-writer.ts +23 -3
package/dist/tex-parser.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare class LatexParser {
|
|
|
9
9
|
newline_sensitive: boolean;
|
|
10
10
|
constructor(space_sensitive?: boolean, newline_sensitive?: boolean);
|
|
11
11
|
parse(tokens: TexToken[]): TexNode;
|
|
12
|
+
parseGroup(tokens: TexToken[], start: number, end: number): ParseResult;
|
|
12
13
|
parseNextExpr(tokens: TexToken[], start: number): ParseResult;
|
|
13
14
|
parseNextExprWithoutSupSub(tokens: TexToken[], start: number): ParseResult;
|
|
14
15
|
parseCommandExpr(tokens: TexToken[], start: number): ParseResult;
|
package/dist/tex2typst.min.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
var I=new Map([["nonumber",""],["vec","arrow"],["neq","eq.not"],["dot","dot"],["ddot","dot.double"],["doteq","dot(eq)"],["dots","dots.h"],["vdots","dots.v"],["ddots","dots.down"],["widehat","hat"],["widetilde","tilde"],["quad","quad"],["qquad","wide"],["overbrace","overbrace"],["underbrace","underbrace"],["overline","overline"],["underline","underline"],["bar","macron"],["dbinom","binom"],["tbinom","binom"],["dfrac","frac"],["tfrac","frac"],["operatorname","op"],["boldsymbol","bold"],["mathbb","bb"],["mathbf","bold"],["mathcal","cal"],["mathit","italic"],["mathfrak","frak"],["mathrm","upright"],["mathsf","sans"],["mathtt","mono"],["rm","upright"],["pmb","bold"],["pm","plus.minus"],["mp","minus.plus"],["boxplus","plus.square"],["otimes","times.circle"],["boxtimes","times.square"],["approx","approx"],["cong","tilde.equiv"],["simeq","tilde.eq"],["asymp","≍"],["equiv","equiv"],["propto","prop"],["gets","arrow.l"],["hookleftarrow","arrow.l.hook"],["leftharpoonup","harpoon.lt"],["leftharpoondown","harpoon.lb"],["rightleftharpoons","harpoons.rtlb"],["longleftarrow","arrow.l.long"],["longrightarrow","arrow.r.long"],["longleftrightarrow","arrow.l.r.long"],["Longleftarrow","arrow.l.double.long"],["Longrightarrow","arrow.r.double.long"],["Longleftrightarrow","arrow.l.r.double.long"],["hookrightarrow","arrow.r.hook"],["rightharpoonup","harpoon.rt"],["rightharpoondown","harpoon.rb"],["iff","arrow.l.r.double.long"],["implies","arrow.r.double.long"],["uparrow","arrow.t"],["downarrow","arrow.b"],["updownarrow","arrow.t.b"],["Uparrow","arrow.t.double"],["Downarrow","arrow.b.double"],["Updownarrow","arrow.t.b.double"],["nearrow","arrow.tr"],["searrow","arrow.br"],["swarrow","arrow.bl"],["nwarrow","arrow.tl"],["leadsto","arrow.squiggly"],["leftleftarrows","arrows.ll"],["rightrightarrows","arrows.rr"],["Cap","sect.double"],["Cup","union.double"],["Delta","Delta"],["Gamma","Gamma"],["Join","join"],["Lambda","Lambda"],["Leftarrow","arrow.l.double"],["Leftrightarrow","arrow.l.r.double"],["Longrightarrow","arrow.r.double.long"],["Omega","Omega"],["P","pilcrow"],["Phi","Phi"],["Pi","Pi"],["Psi","Psi"],["Rightarrow","arrow.r.double"],["S","section"],["Sigma","Sigma"],["Theta","Theta"],["aleph","alef"],["alpha","alpha"],["angle","angle"],["approx","approx"],["approxeq","approx.eq"],["beta","beta"],["bigcap","sect.big"],["bigcirc","circle.big"],["bigcup","union.big"],["bigodot","dot.circle.big"],["bigotimes","times.circle.big"],["bigsqcup","union.sq.big"],["biguplus","union.plus.big"],["bigvee","or.big"],["bigwedge","and.big"],["bullet","bullet"],["cap","sect"],["cdot","dot.op"],["cdots","dots.c"],["checkmark","checkmark"],["chi","chi"],["circ","circle.small"],["colon","colon"],["cong","tilde.equiv"],["coprod","product.co"],["copyright","copyright"],["cup","union"],["curlyvee","or.curly"],["curlywedge","and.curly"],["dagger","dagger"],["dashv","tack.l"],["ddagger","dagger.double"],["delta","delta"],["ddots","dots.down"],["diamond","diamond"],["div","div"],["divideontimes","times.div"],["dotplus","plus.dot"],["downarrow","arrow.b"],["ell","ell"],["emptyset","nothing"],["epsilon","epsilon.alt"],["equiv","equiv"],["eta","eta"],["exists","exists"],["forall","forall"],["gamma","gamma"],["ge","gt.eq"],["geq","gt.eq"],["geqslant","gt.eq.slant"],["gg","gt.double"],["hbar","planck.reduce"],["imath","dotless.i"],["iiiint","integral.quad"],["iiint","integral.triple"],["iint","integral.double"],["in","in"],["infty","infinity"],["int","integral"],["intercal","top"],["iota","iota"],["jmath","dotless.j"],["kappa","kappa"],["lambda","lambda"],["land","and"],["langle","angle.l"],["lbrace","brace.l"],["lbrack","bracket.l"],["ldots","dots.h"],["le","lt.eq"],["leadsto","arrow.squiggly"],["leftarrow","arrow.l"],["leftthreetimes","times.three.l"],["leftrightarrow","arrow.l.r"],["leq","lt.eq"],["leqslant","lt.eq.slant"],["lhd","triangle.l"],["ll","lt.double"],["lor","or"],["ltimes","times.l"],["measuredangle","angle.arc"],["mid","divides"],["models","models"],["mp","minus.plus"],["mu","mu"],["nabla","nabla"],["ncong","tilde.equiv.not"],["ne","eq.not"],["neg","not"],["neq","eq.not"],["nexists","exists.not"],["ni","in.rev"],["nleftarrow","arrow.l.not"],["nleq","lt.eq.not"],["nparallel","parallel.not"],["ngeq","gt.eq.not"],["nmid","divides.not"],["notin","in.not"],["nsim","tilde.not"],["nsubseteq","subset.eq.not"],["nu","nu"],["ntriangleleft","lt.tri.not"],["ntriangleright","gt.tri.not"],["nwarrow","arrow.tl"],["odot","dot.circle"],["oint","integral.cont"],["oiint","integral.surf"],["oiiint","integral.vol"],["omega","omega"],["ominus","minus.circle"],["otimes","times.circle"],["parallel","parallel"],["partial","diff"],["perp","perp"],["phi","phi.alt"],["pi","pi"],["pm","plus.minus"],["pounds","pound"],["prec","prec"],["preceq","prec.eq"],["prime","prime"],["prod","product"],["propto","prop"],["psi","psi"],["rangle","angle.r"],["rbrace","brace.r"],["rbrack","bracket.r"],["rhd","triangle"],["rho","rho"],["rightarrow","arrow.r"],["rightthreetimes","times.three.r"],["rtimes","times.r"],["setminus","without"],["sigma","sigma"],["sim","tilde.op"],["simeq","tilde.eq"],["slash","slash"],["smallsetminus","without"],["spadesuit","suit.spade"],["sqcap","sect.sq"],["sqcup","union.sq"],["sqsubseteq","subset.eq.sq"],["sqsupseteq","supset.eq.sq"],["subset","subset"],["subseteq","subset.eq"],["subsetneq","subset.neq"],["succ","succ"],["succeq","succ.eq"],["sum","sum"],["supset","supset"],["supseteq","supset.eq"],["supsetneq","supset.neq"],["swarrow","arrow.bl"],["tau","tau"],["theta","theta"],["times","times"],["to","arrow.r"],["top","top"],["triangle","triangle.t"],["twoheadrightarrow","arrow.r.twohead"],["uparrow","arrow.t"],["updownarrow","arrow.t.b"],["upharpoonright","harpoon.tr"],["uplus","union.plus"],["upsilon","upsilon"],["varepsilon","epsilon"],["varnothing","diameter"],["varphi","phi"],["varpi","pi.alt"],["varrho","rho.alt"],["varsigma","sigma.alt"],["vartheta","theta.alt"],["vdash","tack.r"],["vdots","dots.v"],["vee","or"],["wedge","and"],["wr","wreath"],["xi","xi"],["yen","yen"],["zeta","zeta"],["mathscr","scr"],["LaTeX","#LaTeX"],["TeX","#TeX"]]),A2=new Map([["lparen","paren.l"],["lParen","paren.l.double"],["rparen","paren.r"],["rParen","paren.r.double"],["overparen","paren.t"],["underparen","paren.b"],["lbrace","brace.l"],["lBrace","brace.l.double"],["rbrace","brace.r"],["rBrace","brace.r.double"],["underbrace","brace.b"],["lbrack","bracket.l"],["lBrack","bracket.l.double"],["rbrack","bracket.r"],["rBrack","bracket.r.double"],["overbracket","bracket.t"],["underbracket","bracket.b"],["lbrbrak","shell.l"],["Lbrbrak","shell.l.double"],["rbrbrak","shell.r"],["Rbrbrak","shell.r.double"],["obrbrak","shell.t"],["ubrbrak","shell.b"],["vert","bar.v"],["Vert","bar.v.double"],["Vvert","bar.v.triple"],["circledvert","bar.v.circle"],["horizbar","bar.h"],["lvzigzag","fence.l"],["Lvzigzag","fence.l.double"],["rvzigzag","fence.r"],["Rvzigzag","fence.r.double"],["fourvdots","fence.dotted"],["angle","angle"],["langle","angle.l"],["lcurvyangle","angle.l.curly"],["langledot","angle.l.dot"],["rangle","angle.r"],["rcurvyangle","angle.r.curly"],["rangledot","angle.r.dot"],["angdnr","angle.acute"],["measuredangle","angle.arc"],["measuredangleleft","angle.arc.rev"],["wideangledown","angle.oblique"],["revangle","angle.rev"],["rightangle","angle.right"],["measuredrightangle","angle.right.arc"],["rightanglemdot","angle.right.dot"],["rightanglesqr","angle.right.sq"],["angles","angle.s"],["threedangle","angle.spatial"],["sphericalangle","angle.spheric"],["gtlpar","angle.spheric.rev"],["sphericalangleup","angle.spheric.top"],["lceil","ceil.l"],["rceil","ceil.r"],["lfloor","floor.l"],["rfloor","floor.r"],["mathampersand","amp"],["upand","amp.inv"],["ast","ast.op"],["circledast","ast.circle"],["boxast","ast.square"],["mathatsign","at"],["backslash","backslash"],["obslash","backslash.circle"],["rsolbar","backslash.not"],["mathcolon","colon"],["Colon","colon.double"],["coloneq","colon.eq"],["Coloneq","colon.double.eq"],["mathcomma","comma"],["dagger","dagger"],["ddagger","dagger.double"],["dashcolon","dash.colon"],["circleddash","dash.circle"],["hzigzag","dash.wave.double"],["cdot","dot.op"],["mathperiod","dot.basic"],["cdotp","dot.c"],["odot","dot.circle"],["bigodot","dot.circle.big"],["boxdot","dot.square"],["dddot","dot.triple"],["ddddot","dot.quad"],["mathexclam","excl"],["Exclam","excl.double"],["mathquestion","quest"],["Question","quest.double"],["mathoctothorpe","hash"],["mathpercent","percent"],["mathparagraph","pilcrow"],["mathsection","section"],["mathsemicolon","semi"],["mathslash","slash"],["sslash","slash.double"],["trslash","slash.triple"],["xsol","slash.big"],["unicodecdots","dots.h.c"],["unicodeellipsis","dots.h"],["vdots","dots.v"],["ddots","dots.down"],["adots","dots.up"],["sim","tilde.op"],["dotsim","tilde.dot"],["sime","tilde.eq"],["nsimeq","tilde.eq.not"],["backsimeq","tilde.eq.rev"],["cong","tilde.equiv"],["ncong","tilde.equiv.not"],["simneqq","tilde.nequiv"],["nsim","tilde.not"],["backsim","tilde.rev"],["backcong","tilde.rev.equiv"],["approxident","tilde.triple"],["caretinsert","caret"],["prime","prime"],["backprime","prime.rev"],["dprime","prime.double"],["backdprime","prime.double.rev"],["trprime","prime.triple"],["backtrprime","prime.triple.rev"],["qprime","prime.quad"],["mathplus","plus"],["oplus","plus.circle"],["rightarrowonoplus","plus.circle.arrow"],["bigoplus","plus.circle.big"],["dotplus","plus.dot"],["doubleplus","plus.double"],["pm","plus.minus"],["boxplus","plus.square"],["triangleplus","plus.triangle"],["tripleplus","plus.triple"],["minus","minus"],["ominus","minus.circle"],["dotminus","minus.dot"],["mp","minus.plus"],["boxminus","minus.square"],["eqsim","minus.tilde"],["triangleminus","minus.triangle"],["div","div"],["odiv","div.circle"],["times","times"],["bigtimes","times.big"],["otimes","times.circle"],["bigotimes","times.circle.big"],["divideontimes","times.div"],["leftthreetimes","times.three.l"],["rightthreetimes","times.three.r"],["ltimes","times.l"],["rtimes","times.r"],["boxtimes","times.square"],["triangletimes","times.triangle"],["mathratio","ratio"],["equal","eq"],["stareq","eq.star"],["circledequal","eq.circle"],["eqcolon","eq.colon"],["eqdef","eq.def"],["triangleq","eq.delta"],["veeeq","eq.equi"],["wedgeq","eq.est"],["eqgtr","eq.gt"],["eqless","eq.lt"],["measeq","eq.m"],["ne","eq.not"],["curlyeqprec","eq.prec"],["questeq","eq.quest"],["curlyeqsucc","eq.succ"],["equiv","eq.triple"],["Equiv","eq.quad"],["greater","gt"],["ogreaterthan","gt.circle"],["gtrdot","gt.dot"],["gtrapprox","gt.approx"],["gg","gt.double"],["geq","gt.eq"],["geqslant","gt.eq.slant"],["gtreqless","gt.eq.lt"],["ngeq","gt.eq.not"],["geqq","gt.equiv"],["gtrless","gt.lt"],["ngtrless","gt.lt.not"],["gneq","gt.neq"],["gnapprox","gt.napprox"],["gneqq","gt.nequiv"],["ngtr","gt.not"],["gnsim","gt.ntilde"],["gtrsim","gt.tilde"],["ngtrsim","gt.tilde.not"],["vartriangleright","gt.tri"],["trianglerighteq","gt.tri.eq"],["ntrianglerighteq","gt.tri.eq.not"],["nvartriangleright","gt.tri.not"],["ggg","gt.triple"],["gggnest","gt.triple.nested"],["less","lt"],["olessthan","lt.circle"],["lessdot","lt.dot"],["lessapprox","lt.approx"],["ll","lt.double"],["leq","lt.eq"],["leqslant","lt.eq.slant"],["lesseqgtr","lt.eq.gt"],["nleq","lt.eq.not"],["leqq","lt.equiv"],["lessgtr","lt.gt"],["nlessgtr","lt.gt.not"],["lneq","lt.neq"],["lnapprox","lt.napprox"],["lneqq","lt.nequiv"],["nless","lt.not"],["lnsim","lt.ntilde"],["lesssim","lt.tilde"],["nlesssim","lt.tilde.not"],["vartriangleleft","lt.tri"],["trianglelefteq","lt.tri.eq"],["ntrianglelefteq","lt.tri.eq.not"],["nvartriangleleft","lt.tri.not"],["lll","lt.triple"],["lllnest","lt.triple.nested"],["approx","approx"],["approxeq","approx.eq"],["napprox","approx.not"],["prec","prec"],["precapprox","prec.approx"],["preccurlyeq","prec.curly.eq"],["npreccurlyeq","prec.curly.eq.not"],["Prec","prec.double"],["preceq","prec.eq"],["preceqq","prec.equiv"],["precnapprox","prec.napprox"],["precneq","prec.neq"],["precneqq","prec.nequiv"],["nprec","prec.not"],["precnsim","prec.ntilde"],["precsim","prec.tilde"],["succ","succ"],["succapprox","succ.approx"],["succcurlyeq","succ.curly.eq"],["nsucccurlyeq","succ.curly.eq.not"],["Succ","succ.double"],["succeq","succ.eq"],["succeqq","succ.equiv"],["succnapprox","succ.napprox"],["succneq","succ.neq"],["succneqq","succ.nequiv"],["nsucc","succ.not"],["succnsim","succ.ntilde"],["succsim","succ.tilde"],["nequiv","equiv.not"],["propto","prop"],["origof","original"],["imageof","image"],["varnothing","emptyset"],["emptysetoarr","emptyset.arrow.r"],["emptysetoarrl","emptyset.arrow.l"],["emptysetobar","emptyset.bar"],["emptysetocirc","emptyset.circle"],["revemptyset","emptyset.rev"],["setminus","without"],["complement","complement"],["in","in"],["notin","in.not"],["ni","in.rev"],["nni","in.rev.not"],["smallni","in.rev.small"],["smallin","in.small"],["subset","subset"],["subsetdot","subset.dot"],["Subset","subset.double"],["subseteq","subset.eq"],["nsubseteq","subset.eq.not"],["sqsubseteq","subset.eq.sq"],["nsqsubseteq","subset.eq.sq.not"],["subsetneq","subset.neq"],["nsubset","subset.not"],["sqsubset","subset.sq"],["sqsubsetneq","subset.sq.neq"],["supset","supset"],["supsetdot","supset.dot"],["Supset","supset.double"],["supseteq","supset.eq"],["nsupseteq","supset.eq.not"],["sqsupseteq","supset.eq.sq"],["nsqsupseteq","supset.eq.sq.not"],["supsetneq","supset.neq"],["nsupset","supset.not"],["sqsupset","supset.sq"],["sqsupsetneq","supset.sq.neq"],["cup","union"],["cupleftarrow","union.arrow"],["bigcup","union.big"],["cupdot","union.dot"],["bigcupdot","union.dot.big"],["Cup","union.double"],["uminus","union.minus"],["cupvee","union.or"],["uplus","union.plus"],["biguplus","union.plus.big"],["sqcup","union.sq"],["bigsqcup","union.sq.big"],["Sqcup","union.sq.double"],["cap","sect"],["capwedge","sect.and"],["bigcap","sect.big"],["capdot","sect.dot"],["Cap","sect.double"],["sqcap","sect.sq"],["bigsqcap","sect.sq.big"],["Sqcap","sect.sq.double"],["infty","infinity"],["nvinfty","infinity.bar"],["iinfin","infinity.incomplete"],["tieinfty","infinity.tie"],["partial","diff"],["nabla","gradient"],["sum","sum"],["sumint","sum.integral"],["prod","product"],["coprod","product.co"],["int","integral"],["intlarhk","integral.arrow.hook"],["awint","integral.ccw"],["oint","integral.cont"],["ointctrclockwise","integral.cont.ccw"],["varointclockwise","integral.cont.cw"],["intclockwise","integral.cw"],["intbar","integral.dash"],["intBar","integral.dash.double"],["iint","integral.double"],["iiiint","integral.quad"],["intcap","integral.sect"],["fint","integral.slash"],["sqint","integral.square"],["oiint","integral.surf"],["intx","integral.times"],["iiint","integral.triple"],["intcup","integral.union"],["oiiint","integral.vol"],["increment","laplace"],["forall","forall"],["exists","exists"],["nexists","exists.not"],["top","top"],["bot","bot"],["neg","not"],["wedge","and"],["bigwedge","and.big"],["curlywedge","and.curly"],["wedgedot","and.dot"],["Wedge","and.double"],["vee","or"],["bigvee","or.big"],["curlyvee","or.curly"],["veedot","or.dot"],["Vee","or.double"],["models","models"],["Vdash","forces"],["nVdash","forces.not"],["therefore","therefore"],["because","because"],["QED","qed"],["vysmwhtcircle","compose"],["multimap","multimap"],["dualmap","multimap.double"],["tplus","tiny"],["tminus","miny"],["mid","divides"],["nmid","divides.not"],["wr","wreath"],["parallel","parallel"],["nhpar","parallel.struck"],["circledparallel","parallel.circle"],["equalparallel","parallel.eq"],["equivVert","parallel.equiv"],["nparallel","parallel.not"],["eparsl","parallel.slanted.eq"],["smeparsl","parallel.slanted.eq.tilde"],["eqvparsl","parallel.slanted.equiv"],["parsim","parallel.tilde"],["perp","perp"],["operp","perp.circle"],["diameter","diameter"],["Join","join"],["rightouterjoin","join.r"],["leftouterjoin","join.l"],["fullouterjoin","join.l.r"],["smashtimes","smash"],["mathdollar","dollar"],["euro","euro"],["mathsterling","pound"],["mathyen","yen"],["checkmark","checkmark"],["maltese","maltese"],["clubsuit","suit.club.filled"],["varclubsuit","suit.club.stroked"],["vardiamondsuit","suit.diamond.filled"],["diamondsuit","suit.diamond.stroked"],["varheartsuit","suit.heart.filled"],["heartsuit","suit.heart.stroked"],["spadesuit","suit.spade.filled"],["varspadesuit","suit.spade.stroked"],["quarternote","note.quarter.alt"],["eighthnote","note.eighth.alt"],["twonotes","note.eighth.beamed"],["natural","natural"],["flat","flat"],["sharp","sharp"],["smblkcircle","bullet"],["mdlgwhtcircle","circle.stroked"],["mdsmwhtcircle","circle.stroked.small"],["lgwhtcircle","circle.stroked.big"],["mdlgblkcircle","circle.filled"],["mdsmblkcircle","circle.filled.tiny"],["vysmblkcircle","circle.filled.small"],["lgblkcircle","circle.filled.big"],["dottedcircle","circle.dotted"],["circledcirc","circle.nested"],["whthorzoval","ellipse.stroked.h"],["whtvertoval","ellipse.stroked.v"],["blkhorzoval","ellipse.filled.h"],["blkvertoval","ellipse.filled.v"],["bigtriangleup","triangle.stroked.t"],["bigtriangledown","triangle.stroked.b"],["triangleright","triangle.stroked.r"],["triangleleft","triangle.stroked.l"],["lltriangle","triangle.stroked.bl"],["lrtriangle","triangle.stroked.br"],["ultriangle","triangle.stroked.tl"],["urtriangle","triangle.stroked.tr"],["vartriangle","triangle.stroked.small.t"],["triangledown","triangle.stroked.small.b"],["smalltriangleright","triangle.stroked.small.r"],["smalltriangleleft","triangle.stroked.small.l"],["whiteinwhitetriangle","triangle.stroked.nested"],["trianglecdot","triangle.stroked.dot"],["bigblacktriangleup","triangle.filled.t"],["bigblacktriangledown","triangle.filled.b"],["blacktriangleright","triangle.filled.r"],["blacktriangleleft","triangle.filled.l"],["llblacktriangle","triangle.filled.bl"],["lrblacktriangle","triangle.filled.br"],["ulblacktriangle","triangle.filled.tl"],["urblacktriangle","triangle.filled.tr"],["blacktriangle","triangle.filled.small.t"],["blacktriangledown","triangle.filled.small.b"],["smallblacktriangleright","triangle.filled.small.r"],["smallblacktriangleleft","triangle.filled.small.l"],["mdlgwhtsquare","square.stroked"],["smwhtsquare","square.stroked.tiny"],["mdsmwhtsquare","square.stroked.small"],["mdwhtsquare","square.stroked.medium"],["lgwhtsquare","square.stroked.big"],["dottedsquare","square.stroked.dotted"],["squoval","square.stroked.rounded"],["mdlgblksquare","square.filled"],["smblksquare","square.filled.tiny"],["mdsmblksquare","square.filled.small"],["mdblksquare","square.filled.medium"],["lgblksquare","square.filled.big"],["hrectangle","rect.stroked.h"],["vrectangle","rect.stroked.v"],["hrectangleblack","rect.filled.h"],["vrectangleblack","rect.filled.v"],["pentagon","penta.stroked"],["pentagonblack","penta.filled"],["varhexagon","hexa.stroked"],["varhexagonblack","hexa.filled"],["mdlgwhtdiamond","diamond.stroked"],["smwhtdiamond","diamond.stroked.small"],["mdwhtdiamond","diamond.stroked.medium"],["diamondcdot","diamond.stroked.dot"],["mdlgblkdiamond","diamond.filled"],["mdblkdiamond","diamond.filled.medium"],["smblkdiamond","diamond.filled.small"],["mdlgwhtlozenge","lozenge.stroked"],["smwhtlozenge","lozenge.stroked.small"],["mdwhtlozenge","lozenge.stroked.medium"],["mdlgblklozenge","lozenge.filled"],["smblklozenge","lozenge.filled.small"],["mdblklozenge","lozenge.filled.medium"],["parallelogram","parallelogram.stroked"],["parallelogramblack","parallelogram.filled"],["star","star.op"],["bigwhitestar","star.stroked"],["bigstar","star.filled"],["rightarrow","arrow.r"],["longmapsto","arrow.r.long.bar"],["mapsto","arrow.r.bar"],["rightdowncurvedarrow","arrow.r.curve"],["rightdasharrow","arrow.r.dashed"],["rightdotarrow","arrow.r.dotted"],["Rightarrow","arrow.r.double"],["Mapsto","arrow.r.double.bar"],["Longrightarrow","arrow.r.double.long"],["Longmapsto","arrow.r.double.long.bar"],["nRightarrow","arrow.r.double.not"],["hookrightarrow","arrow.r.hook"],["longrightarrow","arrow.r.long"],["longrightsquigarrow","arrow.r.long.squiggly"],["looparrowright","arrow.r.loop"],["nrightarrow","arrow.r.not"],["RRightarrow","arrow.r.quad"],["rightsquigarrow","arrow.r.squiggly"],["rightarrowbar","arrow.r.stop"],["rightwhitearrow","arrow.r.stroked"],["rightarrowtail","arrow.r.tail"],["similarrightarrow","arrow.r.tilde"],["Rrightarrow","arrow.r.triple"],["twoheadmapsto","arrow.r.twohead.bar"],["twoheadrightarrow","arrow.r.twohead"],["rightwavearrow","arrow.r.wave"],["leftarrow","arrow.l"],["mapsfrom","arrow.l.bar"],["leftdowncurvedarrow","arrow.l.curve"],["leftdasharrow","arrow.l.dashed"],["leftdotarrow","arrow.l.dotted"],["Leftarrow","arrow.l.double"],["Mapsfrom","arrow.l.double.bar"],["Longleftarrow","arrow.l.double.long"],["Longmapsfrom","arrow.l.double.long.bar"],["nLeftarrow","arrow.l.double.not"],["hookleftarrow","arrow.l.hook"],["longleftarrow","arrow.l.long"],["longmapsfrom","arrow.l.long.bar"],["longleftsquigarrow","arrow.l.long.squiggly"],["looparrowleft","arrow.l.loop"],["nleftarrow","arrow.l.not"],["LLeftarrow","arrow.l.quad"],["leftsquigarrow","arrow.l.squiggly"],["barleftarrow","arrow.l.stop"],["leftwhitearrow","arrow.l.stroked"],["leftarrowtail","arrow.l.tail"],["similarleftarrow","arrow.l.tilde"],["Lleftarrow","arrow.l.triple"],["twoheadmapsfrom","arrow.l.twohead.bar"],["twoheadleftarrow","arrow.l.twohead"],["leftwavearrow","arrow.l.wave"],["uparrow","arrow.t"],["mapsup","arrow.t.bar"],["uprightcurvearrow","arrow.t.curve"],["updasharrow","arrow.t.dashed"],["Uparrow","arrow.t.double"],["UUparrow","arrow.t.quad"],["baruparrow","arrow.t.stop"],["upwhitearrow","arrow.t.stroked"],["Uuparrow","arrow.t.triple"],["twoheaduparrow","arrow.t.twohead"],["downarrow","arrow.b"],["mapsdown","arrow.b.bar"],["downrightcurvedarrow","arrow.b.curve"],["downdasharrow","arrow.b.dashed"],["Downarrow","arrow.b.double"],["DDownarrow","arrow.b.quad"],["downarrowbar","arrow.b.stop"],["downwhitearrow","arrow.b.stroked"],["Ddownarrow","arrow.b.triple"],["twoheaddownarrow","arrow.b.twohead"],["leftrightarrow","arrow.l.r"],["Leftrightarrow","arrow.l.r.double"],["Longleftrightarrow","arrow.l.r.double.long"],["nLeftrightarrow","arrow.l.r.double.not"],["longleftrightarrow","arrow.l.r.long"],["nleftrightarrow","arrow.l.r.not"],["leftrightsquigarrow","arrow.l.r.wave"],["updownarrow","arrow.t.b"],["Updownarrow","arrow.t.b.double"],["nearrow","arrow.tr"],["Nearrow","arrow.tr.double"],["hknearrow","arrow.tr.hook"],["searrow","arrow.br"],["Searrow","arrow.br.double"],["hksearrow","arrow.br.hook"],["nwarrow","arrow.tl"],["Nwarrow","arrow.tl.double"],["hknwarrow","arrow.tl.hook"],["swarrow","arrow.bl"],["Swarrow","arrow.bl.double"],["hkswarrow","arrow.bl.hook"],["nwsearrow","arrow.tl.br"],["neswarrow","arrow.tr.bl"],["acwopencirclearrow","arrow.ccw"],["curvearrowleft","arrow.ccw.half"],["cwopencirclearrow","arrow.cw"],["curvearrowright","arrow.cw.half"],["downzigzagarrow","arrow.zigzag"],["rightrightarrows","arrows.rr"],["leftleftarrows","arrows.ll"],["upuparrows","arrows.tt"],["downdownarrows","arrows.bb"],["leftrightarrows","arrows.lr"],["barleftarrowrightarrowbar","arrows.lr.stop"],["rightleftarrows","arrows.rl"],["updownarrows","arrows.tb"],["downuparrows","arrows.bt"],["rightthreearrows","arrows.rrr"],["leftthreearrows","arrows.lll"],["rightharpoonup","harpoon.rt"],["barrightharpoonup","harpoon.rt.bar"],["rightharpoonupbar","harpoon.rt.stop"],["rightharpoondown","harpoon.rb"],["barrightharpoondown","harpoon.rb.bar"],["rightharpoondownbar","harpoon.rb.stop"],["leftharpoonup","harpoon.lt"],["leftharpoonupbar","harpoon.lt.bar"],["barleftharpoonup","harpoon.lt.stop"],["leftharpoondown","harpoon.lb"],["leftharpoondownbar","harpoon.lb.bar"],["barleftharpoondown","harpoon.lb.stop"],["upharpoonleft","harpoon.tl"],["upharpoonleftbar","harpoon.tl.bar"],["barupharpoonleft","harpoon.tl.stop"],["upharpoonright","harpoon.tr"],["upharpoonrightbar","harpoon.tr.bar"],["barupharpoonright","harpoon.tr.stop"],["downharpoonleft","harpoon.bl"],["bardownharpoonleft","harpoon.bl.bar"],["downharpoonleftbar","harpoon.bl.stop"],["downharpoonright","harpoon.br"],["bardownharpoonright","harpoon.br.bar"],["downharpoonrightbar","harpoon.br.stop"],["leftrightharpoonupup","harpoon.lt.rt"],["leftrightharpoondowndown","harpoon.lb.rb"],["leftrightharpoondownup","harpoon.lb.rt"],["leftrightharpoonupdown","harpoon.lt.rb"],["updownharpoonleftleft","harpoon.tl.bl"],["updownharpoonrightright","harpoon.tr.br"],["updownharpoonleftright","harpoon.tl.br"],["updownharpoonrightleft","harpoon.tr.bl"],["rightharpoonsupdown","harpoons.rtrb"],["downharpoonsleftright","harpoons.blbr"],["downupharpoonsleftright","harpoons.bltr"],["leftrightharpoonsdown","harpoons.lbrb"],["leftharpoonsupdown","harpoons.ltlb"],["leftrightharpoons","harpoons.ltrb"],["leftrightharpoonsup","harpoons.ltrt"],["rightleftharpoonsdown","harpoons.rblb"],["rightleftharpoons","harpoons.rtlb"],["rightleftharpoonsup","harpoons.rtlt"],["updownharpoonsleftright","harpoons.tlbr"],["upharpoonsleftright","harpoons.tltr"],["vdash","tack.r"],["nvdash","tack.r.not"],["vlongdash","tack.r.long"],["assert","tack.r.short"],["vDash","tack.r.double"],["nvDash","tack.r.double.not"],["dashv","tack.l"],["longdashv","tack.l.long"],["shortlefttack","tack.l.short"],["Dashv","tack.l.double"],["bigbot","tack.t.big"],["Vbar","tack.t.double"],["shortuptack","tack.t.short"],["bigtop","tack.b.big"],["barV","tack.b.double"],["shortdowntack","tack.b.short"],["dashVdash","tack.l.r"],["BbbA","AA"],["BbbB","BB"],["BbbC","CC"],["BbbD","DD"],["BbbE","EE"],["BbbF","FF"],["BbbG","GG"],["BbbH","HH"],["BbbI","II"],["BbbJ","JJ"],["BbbK","KK"],["BbbL","LL"],["BbbM","MM"],["BbbN","NN"],["BbbO","OO"],["BbbP","PP"],["BbbQ","QQ"],["BbbR","RR"],["BbbS","SS"],["BbbT","TT"],["BbbU","UU"],["BbbV","VV"],["BbbW","WW"],["BbbX","XX"],["BbbY","YY"],["BbbZ","ZZ"],["ell","ell"],["Planckconst","planck"],["hslash","planck.reduce"],["Angstrom","angstrom"],["Re","Re"],["Im","Im"],["imath","dotless.i"],["jmath","dotless.j"]]);for(let[q,J]of A2)if(!I.has(q))I.set(q,J);var w=new Map;for(let[q,J]of Array.from(I.entries()).reverse())w.set(J,q);w.set("dif","mathrm{d}");var I2=new Map([["top","top"],["frac","frac"],["tilde","tilde"],["hat","hat"],["upright","mathrm"],["bold","boldsymbol"],["hyph.minus","\\text{-}"]]);for(let[q,J]of I2)w.set(q,J);function a(q,J,z=0){for(let V=z;V<q.length;V++)if(q[V].eq(J))return V;return-1}function m(q,J){for(let z of q)if(z.eq(J))return!0;return!1}function k(q,J){let z=[],V=[];for(let Z of q)if(Z.eq(J))z.push(V),V=[];else V.push(Z);return z.push(V),z}class W{type;value;constructor(q,J){this.type=q,this.value=J}eq(q){return this.type===q.type&&this.value===q.value}toString(){switch(this.type){case 2:return`\\text{${this.value}}`;case 3:return`%${this.value}`;default:return this.value}}}function M2(q){if(["{","}","%"].includes(q))return"\\"+q;return q}class Q{type;content;args;data;constructor(q,J,z,V){this.type=q,this.content=J,this.args=z,this.data=V}eq(q){return this.type===q.type&&this.content===q.content}toString(){switch(this.type){case"text":return`\\text{${this.content}}`;default:throw new Error(`toString() is not implemented for type ${this.type}`)}}serialize(){switch(this.type){case"empty":return[];case"element":{let q=this.content;return q=M2(q),[new W(0,q)]}case"symbol":return[new W(1,this.content)];case"text":return[new W(2,this.content)];case"comment":return[new W(3,this.content)];case"whitespace":{let q=[];for(let J of this.content){let z=J===" "?4:5;q.push(new W(z,J))}return q}case"ordgroup":{let q=this.args.map((J)=>J.serialize()).flat();if(this.content==="parenthesis"){let J=this.isOverHigh(),z=J?"\\left(":"(",V=J?"\\right)":")";q.unshift(new W(0,z)),q.push(new W(0,V))}return q}case"unaryFunc":{let q=[];if(q.push(new W(1,this.content)),this.content==="\\sqrt"&&this.data)q.push(new W(0,"[")),q=q.concat(this.data.serialize()),q.push(new W(0,"]"));if(this.content==="\\operatorname"&&this.args.length===1&&this.args[0].type==="text"){let J=this.args[0].content;return q.push(new W(0,"{")),q.push(new W(1,J)),q.push(new W(0,"}")),q}return q.push(new W(0,"{")),q=q.concat(this.args[0].serialize()),q.push(new W(0,"}")),q}case"binaryFunc":{let q=[];return q.push(new W(1,this.content)),q.push(new W(0,"{")),q=q.concat(this.args[0].serialize()),q.push(new W(0,"}")),q.push(new W(0,"{")),q=q.concat(this.args[1].serialize()),q.push(new W(0,"}")),q}case"supsub":{let Z=function(X){if(X.type==="ordgroup"||X.type==="supsub"||X.type==="empty")return!0;else if(X.type==="element"&&/\d+(\.\d+)?/.test(X.content)&&X.content.length>1)return!0;else return!1},q=[],{base:J,sup:z,sub:V}=this.data;if(q=q.concat(J.serialize()),V)if(q.push(new W(6,"_")),Z(V))q.push(new W(0,"{")),q=q.concat(V.serialize()),q.push(new W(0,"}"));else q=q.concat(V.serialize());if(z)if(q.push(new W(6,"^")),Z(z))q.push(new W(0,"{")),q=q.concat(z.serialize()),q.push(new W(0,"}"));else q=q.concat(z.serialize());return q}case"control":return[new W(6,this.content)];case"beginend":{let q=[],J=this.data;q.push(new W(1,`\\begin{${this.content}}`)),q.push(new W(5,`
|
|
2
|
-
`));for(let
|
|
3
|
-
`)),
|
|
4
|
-
|
|
5
|
-
`:
|
|
6
|
-
|
|
7
|
-
`),
|
|
8
|
-
`),
|
|
9
|
-
`)
|
|
10
|
-
`)
|
|
11
|
-
`);class
|
|
12
|
-
`),
|
|
13
|
-
`)this.queue.push(new
|
|
14
|
-
`:
|
|
15
|
-
|
|
16
|
-
`),
|
|
17
|
-
`),
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
"use strict";(()=>{var E=new Map([["nonumber",""],["vec","arrow"],["neq","eq.not"],["dot","dot"],["ddot","dot.double"],["doteq","dot(eq)"],["dots","dots.h"],["vdots","dots.v"],["ddots","dots.down"],["widehat","hat"],["widetilde","tilde"],["quad","quad"],["qquad","wide"],["overbrace","overbrace"],["underbrace","underbrace"],["overline","overline"],["underline","underline"],["bar","macron"],["dbinom","binom"],["tbinom","binom"],["dfrac","frac"],["tfrac","frac"],["operatorname","op"],["boldsymbol","bold"],["mathbb","bb"],["mathbf","bold"],["mathcal","cal"],["mathit","italic"],["mathfrak","frak"],["mathrm","upright"],["mathsf","sans"],["mathtt","mono"],["rm","upright"],["pmb","bold"],["pm","plus.minus"],["mp","minus.plus"],["boxplus","plus.square"],["otimes","times.circle"],["boxtimes","times.square"],["approx","approx"],["cong","tilde.equiv"],["simeq","tilde.eq"],["asymp","\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.h"],["le","lt.eq"],["leadsto","arrow.squiggly"],["leftarrow","arrow.l"],["leftthreetimes","times.three.l"],["leftrightarrow","arrow.l.r"],["leq","lt.eq"],["leqslant","lt.eq.slant"],["lhd","triangle.l"],["ll","lt.double"],["lor","or"],["ltimes","times.l"],["measuredangle","angle.arc"],["mid","divides"],["models","models"],["mp","minus.plus"],["mu","mu"],["nabla","nabla"],["ncong","tilde.equiv.not"],["ne","eq.not"],["neg","not"],["neq","eq.not"],["nexists","exists.not"],["ni","in.rev"],["nleftarrow","arrow.l.not"],["nleq","lt.eq.not"],["nparallel","parallel.not"],["ngeq","gt.eq.not"],["nmid","divides.not"],["notin","in.not"],["nsim","tilde.not"],["nsubseteq","subset.eq.not"],["nu","nu"],["ntriangleleft","lt.tri.not"],["ntriangleright","gt.tri.not"],["nwarrow","arrow.tl"],["odot","dot.circle"],["oint","integral.cont"],["oiint","integral.surf"],["oiiint","integral.vol"],["omega","omega"],["ominus","minus.circle"],["otimes","times.circle"],["parallel","parallel"],["partial","diff"],["perp","perp"],["phi","phi.alt"],["pi","pi"],["pm","plus.minus"],["pounds","pound"],["prec","prec"],["preceq","prec.eq"],["prime","prime"],["prod","product"],["propto","prop"],["psi","psi"],["rangle","angle.r"],["rbrace","brace.r"],["rbrack","bracket.r"],["rhd","triangle"],["rho","rho"],["rightarrow","arrow.r"],["rightthreetimes","times.three.r"],["rtimes","times.r"],["setminus","without"],["sigma","sigma"],["sim","tilde.op"],["simeq","tilde.eq"],["slash","slash"],["smallsetminus","without"],["spadesuit","suit.spade"],["sqcap","sect.sq"],["sqcup","union.sq"],["sqsubseteq","subset.eq.sq"],["sqsupseteq","supset.eq.sq"],["subset","subset"],["subseteq","subset.eq"],["subsetneq","subset.neq"],["succ","succ"],["succeq","succ.eq"],["sum","sum"],["supset","supset"],["supseteq","supset.eq"],["supsetneq","supset.neq"],["swarrow","arrow.bl"],["tau","tau"],["theta","theta"],["times","times"],["to","arrow.r"],["top","top"],["triangle","triangle.t"],["twoheadrightarrow","arrow.r.twohead"],["uparrow","arrow.t"],["updownarrow","arrow.t.b"],["upharpoonright","harpoon.tr"],["uplus","union.plus"],["upsilon","upsilon"],["varepsilon","epsilon"],["varnothing","diameter"],["varphi","phi"],["varpi","pi.alt"],["varrho","rho.alt"],["varsigma","sigma.alt"],["vartheta","theta.alt"],["vdash","tack.r"],["vdots","dots.v"],["vee","or"],["wedge","and"],["wr","wreath"],["xi","xi"],["yen","yen"],["zeta","zeta"],["mathscr","scr"],["LaTeX","#LaTeX"],["TeX","#TeX"]]),Ne=new Map([["lparen","paren.l"],["lParen","paren.l.double"],["rparen","paren.r"],["rParen","paren.r.double"],["overparen","paren.t"],["underparen","paren.b"],["lbrace","brace.l"],["lBrace","brace.l.double"],["rbrace","brace.r"],["rBrace","brace.r.double"],["underbrace","brace.b"],["lbrack","bracket.l"],["lBrack","bracket.l.double"],["rbrack","bracket.r"],["rBrack","bracket.r.double"],["overbracket","bracket.t"],["underbracket","bracket.b"],["lbrbrak","shell.l"],["Lbrbrak","shell.l.double"],["rbrbrak","shell.r"],["Rbrbrak","shell.r.double"],["obrbrak","shell.t"],["ubrbrak","shell.b"],["vert","bar.v"],["Vert","bar.v.double"],["Vvert","bar.v.triple"],["circledvert","bar.v.circle"],["horizbar","bar.h"],["lvzigzag","fence.l"],["Lvzigzag","fence.l.double"],["rvzigzag","fence.r"],["Rvzigzag","fence.r.double"],["fourvdots","fence.dotted"],["angle","angle"],["langle","angle.l"],["lcurvyangle","angle.l.curly"],["langledot","angle.l.dot"],["rangle","angle.r"],["rcurvyangle","angle.r.curly"],["rangledot","angle.r.dot"],["angdnr","angle.acute"],["measuredangle","angle.arc"],["measuredangleleft","angle.arc.rev"],["wideangledown","angle.oblique"],["revangle","angle.rev"],["rightangle","angle.right"],["measuredrightangle","angle.right.arc"],["rightanglemdot","angle.right.dot"],["rightanglesqr","angle.right.sq"],["angles","angle.s"],["threedangle","angle.spatial"],["sphericalangle","angle.spheric"],["gtlpar","angle.spheric.rev"],["sphericalangleup","angle.spheric.top"],["lceil","ceil.l"],["rceil","ceil.r"],["lfloor","floor.l"],["rfloor","floor.r"],["mathampersand","amp"],["upand","amp.inv"],["ast","ast.op"],["circledast","ast.circle"],["boxast","ast.square"],["mathatsign","at"],["backslash","backslash"],["obslash","backslash.circle"],["rsolbar","backslash.not"],["mathcolon","colon"],["Colon","colon.double"],["coloneq","colon.eq"],["Coloneq","colon.double.eq"],["mathcomma","comma"],["dagger","dagger"],["ddagger","dagger.double"],["dashcolon","dash.colon"],["circleddash","dash.circle"],["hzigzag","dash.wave.double"],["cdot","dot.op"],["mathperiod","dot.basic"],["cdotp","dot.c"],["odot","dot.circle"],["bigodot","dot.circle.big"],["boxdot","dot.square"],["dddot","dot.triple"],["ddddot","dot.quad"],["mathexclam","excl"],["Exclam","excl.double"],["mathquestion","quest"],["Question","quest.double"],["mathoctothorpe","hash"],["mathpercent","percent"],["mathparagraph","pilcrow"],["mathsection","section"],["mathsemicolon","semi"],["mathslash","slash"],["sslash","slash.double"],["trslash","slash.triple"],["xsol","slash.big"],["unicodecdots","dots.h.c"],["unicodeellipsis","dots.h"],["vdots","dots.v"],["ddots","dots.down"],["adots","dots.up"],["sim","tilde.op"],["dotsim","tilde.dot"],["sime","tilde.eq"],["nsimeq","tilde.eq.not"],["backsimeq","tilde.eq.rev"],["cong","tilde.equiv"],["ncong","tilde.equiv.not"],["simneqq","tilde.nequiv"],["nsim","tilde.not"],["backsim","tilde.rev"],["backcong","tilde.rev.equiv"],["approxident","tilde.triple"],["caretinsert","caret"],["prime","prime"],["backprime","prime.rev"],["dprime","prime.double"],["backdprime","prime.double.rev"],["trprime","prime.triple"],["backtrprime","prime.triple.rev"],["qprime","prime.quad"],["mathplus","plus"],["oplus","plus.circle"],["rightarrowonoplus","plus.circle.arrow"],["bigoplus","plus.circle.big"],["dotplus","plus.dot"],["doubleplus","plus.double"],["pm","plus.minus"],["boxplus","plus.square"],["triangleplus","plus.triangle"],["tripleplus","plus.triple"],["minus","minus"],["ominus","minus.circle"],["dotminus","minus.dot"],["mp","minus.plus"],["boxminus","minus.square"],["eqsim","minus.tilde"],["triangleminus","minus.triangle"],["div","div"],["odiv","div.circle"],["times","times"],["bigtimes","times.big"],["otimes","times.circle"],["bigotimes","times.circle.big"],["divideontimes","times.div"],["leftthreetimes","times.three.l"],["rightthreetimes","times.three.r"],["ltimes","times.l"],["rtimes","times.r"],["boxtimes","times.square"],["triangletimes","times.triangle"],["mathratio","ratio"],["equal","eq"],["stareq","eq.star"],["circledequal","eq.circle"],["eqcolon","eq.colon"],["eqdef","eq.def"],["triangleq","eq.delta"],["veeeq","eq.equi"],["wedgeq","eq.est"],["eqgtr","eq.gt"],["eqless","eq.lt"],["measeq","eq.m"],["ne","eq.not"],["curlyeqprec","eq.prec"],["questeq","eq.quest"],["curlyeqsucc","eq.succ"],["equiv","eq.triple"],["Equiv","eq.quad"],["greater","gt"],["ogreaterthan","gt.circle"],["gtrdot","gt.dot"],["gtrapprox","gt.approx"],["gg","gt.double"],["geq","gt.eq"],["geqslant","gt.eq.slant"],["gtreqless","gt.eq.lt"],["ngeq","gt.eq.not"],["geqq","gt.equiv"],["gtrless","gt.lt"],["ngtrless","gt.lt.not"],["gneq","gt.neq"],["gnapprox","gt.napprox"],["gneqq","gt.nequiv"],["ngtr","gt.not"],["gnsim","gt.ntilde"],["gtrsim","gt.tilde"],["ngtrsim","gt.tilde.not"],["vartriangleright","gt.tri"],["trianglerighteq","gt.tri.eq"],["ntrianglerighteq","gt.tri.eq.not"],["nvartriangleright","gt.tri.not"],["ggg","gt.triple"],["gggnest","gt.triple.nested"],["less","lt"],["olessthan","lt.circle"],["lessdot","lt.dot"],["lessapprox","lt.approx"],["ll","lt.double"],["leq","lt.eq"],["leqslant","lt.eq.slant"],["lesseqgtr","lt.eq.gt"],["nleq","lt.eq.not"],["leqq","lt.equiv"],["lessgtr","lt.gt"],["nlessgtr","lt.gt.not"],["lneq","lt.neq"],["lnapprox","lt.napprox"],["lneqq","lt.nequiv"],["nless","lt.not"],["lnsim","lt.ntilde"],["lesssim","lt.tilde"],["nlesssim","lt.tilde.not"],["vartriangleleft","lt.tri"],["trianglelefteq","lt.tri.eq"],["ntrianglelefteq","lt.tri.eq.not"],["nvartriangleleft","lt.tri.not"],["lll","lt.triple"],["lllnest","lt.triple.nested"],["approx","approx"],["approxeq","approx.eq"],["napprox","approx.not"],["prec","prec"],["precapprox","prec.approx"],["preccurlyeq","prec.curly.eq"],["npreccurlyeq","prec.curly.eq.not"],["Prec","prec.double"],["preceq","prec.eq"],["preceqq","prec.equiv"],["precnapprox","prec.napprox"],["precneq","prec.neq"],["precneqq","prec.nequiv"],["nprec","prec.not"],["precnsim","prec.ntilde"],["precsim","prec.tilde"],["succ","succ"],["succapprox","succ.approx"],["succcurlyeq","succ.curly.eq"],["nsucccurlyeq","succ.curly.eq.not"],["Succ","succ.double"],["succeq","succ.eq"],["succeqq","succ.equiv"],["succnapprox","succ.napprox"],["succneq","succ.neq"],["succneqq","succ.nequiv"],["nsucc","succ.not"],["succnsim","succ.ntilde"],["succsim","succ.tilde"],["nequiv","equiv.not"],["propto","prop"],["origof","original"],["imageof","image"],["varnothing","emptyset"],["emptysetoarr","emptyset.arrow.r"],["emptysetoarrl","emptyset.arrow.l"],["emptysetobar","emptyset.bar"],["emptysetocirc","emptyset.circle"],["revemptyset","emptyset.rev"],["setminus","without"],["complement","complement"],["in","in"],["notin","in.not"],["ni","in.rev"],["nni","in.rev.not"],["smallni","in.rev.small"],["smallin","in.small"],["subset","subset"],["subsetdot","subset.dot"],["Subset","subset.double"],["subseteq","subset.eq"],["nsubseteq","subset.eq.not"],["sqsubseteq","subset.eq.sq"],["nsqsubseteq","subset.eq.sq.not"],["subsetneq","subset.neq"],["nsubset","subset.not"],["sqsubset","subset.sq"],["sqsubsetneq","subset.sq.neq"],["supset","supset"],["supsetdot","supset.dot"],["Supset","supset.double"],["supseteq","supset.eq"],["nsupseteq","supset.eq.not"],["sqsupseteq","supset.eq.sq"],["nsqsupseteq","supset.eq.sq.not"],["supsetneq","supset.neq"],["nsupset","supset.not"],["sqsupset","supset.sq"],["sqsupsetneq","supset.sq.neq"],["cup","union"],["cupleftarrow","union.arrow"],["bigcup","union.big"],["cupdot","union.dot"],["bigcupdot","union.dot.big"],["Cup","union.double"],["uminus","union.minus"],["cupvee","union.or"],["uplus","union.plus"],["biguplus","union.plus.big"],["sqcup","union.sq"],["bigsqcup","union.sq.big"],["Sqcup","union.sq.double"],["cap","sect"],["capwedge","sect.and"],["bigcap","sect.big"],["capdot","sect.dot"],["Cap","sect.double"],["sqcap","sect.sq"],["bigsqcap","sect.sq.big"],["Sqcap","sect.sq.double"],["infty","infinity"],["nvinfty","infinity.bar"],["iinfin","infinity.incomplete"],["tieinfty","infinity.tie"],["partial","diff"],["nabla","gradient"],["sum","sum"],["sumint","sum.integral"],["prod","product"],["coprod","product.co"],["int","integral"],["intlarhk","integral.arrow.hook"],["awint","integral.ccw"],["oint","integral.cont"],["ointctrclockwise","integral.cont.ccw"],["varointclockwise","integral.cont.cw"],["intclockwise","integral.cw"],["intbar","integral.dash"],["intBar","integral.dash.double"],["iint","integral.double"],["iiiint","integral.quad"],["intcap","integral.sect"],["fint","integral.slash"],["sqint","integral.square"],["oiint","integral.surf"],["intx","integral.times"],["iiint","integral.triple"],["intcup","integral.union"],["oiiint","integral.vol"],["increment","laplace"],["forall","forall"],["exists","exists"],["nexists","exists.not"],["top","top"],["bot","bot"],["neg","not"],["wedge","and"],["bigwedge","and.big"],["curlywedge","and.curly"],["wedgedot","and.dot"],["Wedge","and.double"],["vee","or"],["bigvee","or.big"],["curlyvee","or.curly"],["veedot","or.dot"],["Vee","or.double"],["models","models"],["Vdash","forces"],["nVdash","forces.not"],["therefore","therefore"],["because","because"],["QED","qed"],["vysmwhtcircle","compose"],["multimap","multimap"],["dualmap","multimap.double"],["tplus","tiny"],["tminus","miny"],["mid","divides"],["nmid","divides.not"],["wr","wreath"],["parallel","parallel"],["nhpar","parallel.struck"],["circledparallel","parallel.circle"],["equalparallel","parallel.eq"],["equivVert","parallel.equiv"],["nparallel","parallel.not"],["eparsl","parallel.slanted.eq"],["smeparsl","parallel.slanted.eq.tilde"],["eqvparsl","parallel.slanted.equiv"],["parsim","parallel.tilde"],["perp","perp"],["operp","perp.circle"],["diameter","diameter"],["Join","join"],["rightouterjoin","join.r"],["leftouterjoin","join.l"],["fullouterjoin","join.l.r"],["smashtimes","smash"],["mathdollar","dollar"],["euro","euro"],["mathsterling","pound"],["mathyen","yen"],["checkmark","checkmark"],["maltese","maltese"],["clubsuit","suit.club.filled"],["varclubsuit","suit.club.stroked"],["vardiamondsuit","suit.diamond.filled"],["diamondsuit","suit.diamond.stroked"],["varheartsuit","suit.heart.filled"],["heartsuit","suit.heart.stroked"],["spadesuit","suit.spade.filled"],["varspadesuit","suit.spade.stroked"],["quarternote","note.quarter.alt"],["eighthnote","note.eighth.alt"],["twonotes","note.eighth.beamed"],["natural","natural"],["flat","flat"],["sharp","sharp"],["smblkcircle","bullet"],["mdlgwhtcircle","circle.stroked"],["mdsmwhtcircle","circle.stroked.small"],["lgwhtcircle","circle.stroked.big"],["mdlgblkcircle","circle.filled"],["mdsmblkcircle","circle.filled.tiny"],["vysmblkcircle","circle.filled.small"],["lgblkcircle","circle.filled.big"],["dottedcircle","circle.dotted"],["circledcirc","circle.nested"],["whthorzoval","ellipse.stroked.h"],["whtvertoval","ellipse.stroked.v"],["blkhorzoval","ellipse.filled.h"],["blkvertoval","ellipse.filled.v"],["bigtriangleup","triangle.stroked.t"],["bigtriangledown","triangle.stroked.b"],["triangleright","triangle.stroked.r"],["triangleleft","triangle.stroked.l"],["lltriangle","triangle.stroked.bl"],["lrtriangle","triangle.stroked.br"],["ultriangle","triangle.stroked.tl"],["urtriangle","triangle.stroked.tr"],["vartriangle","triangle.stroked.small.t"],["triangledown","triangle.stroked.small.b"],["smalltriangleright","triangle.stroked.small.r"],["smalltriangleleft","triangle.stroked.small.l"],["whiteinwhitetriangle","triangle.stroked.nested"],["trianglecdot","triangle.stroked.dot"],["bigblacktriangleup","triangle.filled.t"],["bigblacktriangledown","triangle.filled.b"],["blacktriangleright","triangle.filled.r"],["blacktriangleleft","triangle.filled.l"],["llblacktriangle","triangle.filled.bl"],["lrblacktriangle","triangle.filled.br"],["ulblacktriangle","triangle.filled.tl"],["urblacktriangle","triangle.filled.tr"],["blacktriangle","triangle.filled.small.t"],["blacktriangledown","triangle.filled.small.b"],["smallblacktriangleright","triangle.filled.small.r"],["smallblacktriangleleft","triangle.filled.small.l"],["mdlgwhtsquare","square.stroked"],["smwhtsquare","square.stroked.tiny"],["mdsmwhtsquare","square.stroked.small"],["mdwhtsquare","square.stroked.medium"],["lgwhtsquare","square.stroked.big"],["dottedsquare","square.stroked.dotted"],["squoval","square.stroked.rounded"],["mdlgblksquare","square.filled"],["smblksquare","square.filled.tiny"],["mdsmblksquare","square.filled.small"],["mdblksquare","square.filled.medium"],["lgblksquare","square.filled.big"],["hrectangle","rect.stroked.h"],["vrectangle","rect.stroked.v"],["hrectangleblack","rect.filled.h"],["vrectangleblack","rect.filled.v"],["pentagon","penta.stroked"],["pentagonblack","penta.filled"],["varhexagon","hexa.stroked"],["varhexagonblack","hexa.filled"],["mdlgwhtdiamond","diamond.stroked"],["smwhtdiamond","diamond.stroked.small"],["mdwhtdiamond","diamond.stroked.medium"],["diamondcdot","diamond.stroked.dot"],["mdlgblkdiamond","diamond.filled"],["mdblkdiamond","diamond.filled.medium"],["smblkdiamond","diamond.filled.small"],["mdlgwhtlozenge","lozenge.stroked"],["smwhtlozenge","lozenge.stroked.small"],["mdwhtlozenge","lozenge.stroked.medium"],["mdlgblklozenge","lozenge.filled"],["smblklozenge","lozenge.filled.small"],["mdblklozenge","lozenge.filled.medium"],["parallelogram","parallelogram.stroked"],["parallelogramblack","parallelogram.filled"],["star","star.op"],["bigwhitestar","star.stroked"],["bigstar","star.filled"],["rightarrow","arrow.r"],["longmapsto","arrow.r.long.bar"],["mapsto","arrow.r.bar"],["rightdowncurvedarrow","arrow.r.curve"],["rightdasharrow","arrow.r.dashed"],["rightdotarrow","arrow.r.dotted"],["Rightarrow","arrow.r.double"],["Mapsto","arrow.r.double.bar"],["Longrightarrow","arrow.r.double.long"],["Longmapsto","arrow.r.double.long.bar"],["nRightarrow","arrow.r.double.not"],["hookrightarrow","arrow.r.hook"],["longrightarrow","arrow.r.long"],["longrightsquigarrow","arrow.r.long.squiggly"],["looparrowright","arrow.r.loop"],["nrightarrow","arrow.r.not"],["RRightarrow","arrow.r.quad"],["rightsquigarrow","arrow.r.squiggly"],["rightarrowbar","arrow.r.stop"],["rightwhitearrow","arrow.r.stroked"],["rightarrowtail","arrow.r.tail"],["similarrightarrow","arrow.r.tilde"],["Rrightarrow","arrow.r.triple"],["twoheadmapsto","arrow.r.twohead.bar"],["twoheadrightarrow","arrow.r.twohead"],["rightwavearrow","arrow.r.wave"],["leftarrow","arrow.l"],["mapsfrom","arrow.l.bar"],["leftdowncurvedarrow","arrow.l.curve"],["leftdasharrow","arrow.l.dashed"],["leftdotarrow","arrow.l.dotted"],["Leftarrow","arrow.l.double"],["Mapsfrom","arrow.l.double.bar"],["Longleftarrow","arrow.l.double.long"],["Longmapsfrom","arrow.l.double.long.bar"],["nLeftarrow","arrow.l.double.not"],["hookleftarrow","arrow.l.hook"],["longleftarrow","arrow.l.long"],["longmapsfrom","arrow.l.long.bar"],["longleftsquigarrow","arrow.l.long.squiggly"],["looparrowleft","arrow.l.loop"],["nleftarrow","arrow.l.not"],["LLeftarrow","arrow.l.quad"],["leftsquigarrow","arrow.l.squiggly"],["barleftarrow","arrow.l.stop"],["leftwhitearrow","arrow.l.stroked"],["leftarrowtail","arrow.l.tail"],["similarleftarrow","arrow.l.tilde"],["Lleftarrow","arrow.l.triple"],["twoheadmapsfrom","arrow.l.twohead.bar"],["twoheadleftarrow","arrow.l.twohead"],["leftwavearrow","arrow.l.wave"],["uparrow","arrow.t"],["mapsup","arrow.t.bar"],["uprightcurvearrow","arrow.t.curve"],["updasharrow","arrow.t.dashed"],["Uparrow","arrow.t.double"],["UUparrow","arrow.t.quad"],["baruparrow","arrow.t.stop"],["upwhitearrow","arrow.t.stroked"],["Uuparrow","arrow.t.triple"],["twoheaduparrow","arrow.t.twohead"],["downarrow","arrow.b"],["mapsdown","arrow.b.bar"],["downrightcurvedarrow","arrow.b.curve"],["downdasharrow","arrow.b.dashed"],["Downarrow","arrow.b.double"],["DDownarrow","arrow.b.quad"],["downarrowbar","arrow.b.stop"],["downwhitearrow","arrow.b.stroked"],["Ddownarrow","arrow.b.triple"],["twoheaddownarrow","arrow.b.twohead"],["leftrightarrow","arrow.l.r"],["Leftrightarrow","arrow.l.r.double"],["Longleftrightarrow","arrow.l.r.double.long"],["nLeftrightarrow","arrow.l.r.double.not"],["longleftrightarrow","arrow.l.r.long"],["nleftrightarrow","arrow.l.r.not"],["leftrightsquigarrow","arrow.l.r.wave"],["updownarrow","arrow.t.b"],["Updownarrow","arrow.t.b.double"],["nearrow","arrow.tr"],["Nearrow","arrow.tr.double"],["hknearrow","arrow.tr.hook"],["searrow","arrow.br"],["Searrow","arrow.br.double"],["hksearrow","arrow.br.hook"],["nwarrow","arrow.tl"],["Nwarrow","arrow.tl.double"],["hknwarrow","arrow.tl.hook"],["swarrow","arrow.bl"],["Swarrow","arrow.bl.double"],["hkswarrow","arrow.bl.hook"],["nwsearrow","arrow.tl.br"],["neswarrow","arrow.tr.bl"],["acwopencirclearrow","arrow.ccw"],["curvearrowleft","arrow.ccw.half"],["cwopencirclearrow","arrow.cw"],["curvearrowright","arrow.cw.half"],["downzigzagarrow","arrow.zigzag"],["rightrightarrows","arrows.rr"],["leftleftarrows","arrows.ll"],["upuparrows","arrows.tt"],["downdownarrows","arrows.bb"],["leftrightarrows","arrows.lr"],["barleftarrowrightarrowbar","arrows.lr.stop"],["rightleftarrows","arrows.rl"],["updownarrows","arrows.tb"],["downuparrows","arrows.bt"],["rightthreearrows","arrows.rrr"],["leftthreearrows","arrows.lll"],["rightharpoonup","harpoon.rt"],["barrightharpoonup","harpoon.rt.bar"],["rightharpoonupbar","harpoon.rt.stop"],["rightharpoondown","harpoon.rb"],["barrightharpoondown","harpoon.rb.bar"],["rightharpoondownbar","harpoon.rb.stop"],["leftharpoonup","harpoon.lt"],["leftharpoonupbar","harpoon.lt.bar"],["barleftharpoonup","harpoon.lt.stop"],["leftharpoondown","harpoon.lb"],["leftharpoondownbar","harpoon.lb.bar"],["barleftharpoondown","harpoon.lb.stop"],["upharpoonleft","harpoon.tl"],["upharpoonleftbar","harpoon.tl.bar"],["barupharpoonleft","harpoon.tl.stop"],["upharpoonright","harpoon.tr"],["upharpoonrightbar","harpoon.tr.bar"],["barupharpoonright","harpoon.tr.stop"],["downharpoonleft","harpoon.bl"],["bardownharpoonleft","harpoon.bl.bar"],["downharpoonleftbar","harpoon.bl.stop"],["downharpoonright","harpoon.br"],["bardownharpoonright","harpoon.br.bar"],["downharpoonrightbar","harpoon.br.stop"],["leftrightharpoonupup","harpoon.lt.rt"],["leftrightharpoondowndown","harpoon.lb.rb"],["leftrightharpoondownup","harpoon.lb.rt"],["leftrightharpoonupdown","harpoon.lt.rb"],["updownharpoonleftleft","harpoon.tl.bl"],["updownharpoonrightright","harpoon.tr.br"],["updownharpoonleftright","harpoon.tl.br"],["updownharpoonrightleft","harpoon.tr.bl"],["rightharpoonsupdown","harpoons.rtrb"],["downharpoonsleftright","harpoons.blbr"],["downupharpoonsleftright","harpoons.bltr"],["leftrightharpoonsdown","harpoons.lbrb"],["leftharpoonsupdown","harpoons.ltlb"],["leftrightharpoons","harpoons.ltrb"],["leftrightharpoonsup","harpoons.ltrt"],["rightleftharpoonsdown","harpoons.rblb"],["rightleftharpoons","harpoons.rtlb"],["rightleftharpoonsup","harpoons.rtlt"],["updownharpoonsleftright","harpoons.tlbr"],["upharpoonsleftright","harpoons.tltr"],["vdash","tack.r"],["nvdash","tack.r.not"],["vlongdash","tack.r.long"],["assert","tack.r.short"],["vDash","tack.r.double"],["nvDash","tack.r.double.not"],["dashv","tack.l"],["longdashv","tack.l.long"],["shortlefttack","tack.l.short"],["Dashv","tack.l.double"],["bigbot","tack.t.big"],["Vbar","tack.t.double"],["shortuptack","tack.t.short"],["bigtop","tack.b.big"],["barV","tack.b.double"],["shortdowntack","tack.b.short"],["dashVdash","tack.l.r"],["BbbA","AA"],["BbbB","BB"],["BbbC","CC"],["BbbD","DD"],["BbbE","EE"],["BbbF","FF"],["BbbG","GG"],["BbbH","HH"],["BbbI","II"],["BbbJ","JJ"],["BbbK","KK"],["BbbL","LL"],["BbbM","MM"],["BbbN","NN"],["BbbO","OO"],["BbbP","PP"],["BbbQ","QQ"],["BbbR","RR"],["BbbS","SS"],["BbbT","TT"],["BbbU","UU"],["BbbV","VV"],["BbbW","WW"],["BbbX","XX"],["BbbY","YY"],["BbbZ","ZZ"],["ell","ell"],["Planckconst","planck"],["hslash","planck.reduce"],["Angstrom","angstrom"],["Re","Re"],["Im","Im"],["imath","dotless.i"],["jmath","dotless.j"]]);for(let[n,t]of Ne)E.has(n)||E.set(n,t);var M=new Map;for(let[n,t]of Array.from(E.entries()).reverse())M.set(t,n);M.set("dif","mathrm{d}");var ve=new Map([["top","top"],["frac","frac"],["tilde","tilde"],["hat","hat"],["upright","mathrm"],["bold","boldsymbol"],["hyph.minus","\\text{-}"]]);for(let[n,t]of ve)M.set(n,t);function j(n,t,e=0){for(let r=e;r<n.length;r++)if(n[r].eq(t))return r;return-1}function B(n,t){for(let e of n)if(e.eq(t))return!0;return!1}function K(n,t){let e=[],r=[];for(let s of n)s.eq(t)?(e.push(r),r=[]):r.push(s);return e.push(r),e}var c=class{constructor(t,e){this.type=t,this.value=e}eq(t){return this.type===t.type&&this.value===t.value}toString(){switch(this.type){case 2:return`\\text{${this.value}}`;case 3:return`%${this.value}`;default:return this.value}}};function ke(n){return["{","}","%"].includes(n)?"\\"+n:n}var l=class{constructor(t,e,r,s){this.type=t,this.content=e,this.args=r,this.data=s}eq(t){return this.type===t.type&&this.content===t.content}toString(){switch(this.type){case"text":return`\\text{${this.content}}`;default:throw new Error(`toString() is not implemented for type ${this.type}`)}}serialize(){switch(this.type){case"empty":return[];case"element":{let e=this.content;return e=ke(e),[new c(0,e)]}case"symbol":return[new c(1,this.content)];case"text":return[new c(2,this.content)];case"comment":return[new c(3,this.content)];case"whitespace":{let e=[];for(let r of this.content){let s=r===" "?4:5;e.push(new c(s,r))}return e}case"ordgroup":{let e=this.args.map(r=>r.serialize()).flat();if(this.content==="parenthesis"){let r=this.isOverHigh(),s=r?"\\left(":"(",o=r?"\\right)":")";e.unshift(new c(0,s)),e.push(new c(0,o))}return e}case"unaryFunc":{let e=[];if(e.push(new c(1,this.content)),this.content==="\\sqrt"&&this.data&&(e.push(new c(0,"[")),e=e.concat(this.data.serialize()),e.push(new c(0,"]"))),this.content==="\\operatorname"&&this.args.length===1&&this.args[0].type==="text"){let r=this.args[0].content;return e.push(new c(0,"{")),e.push(new c(1,r)),e.push(new c(0,"}")),e}return e.push(new c(0,"{")),e=e.concat(this.args[0].serialize()),e.push(new c(0,"}")),e}case"binaryFunc":{let e=[];return e.push(new c(1,this.content)),e.push(new c(0,"{")),e=e.concat(this.args[0].serialize()),e.push(new c(0,"}")),e.push(new c(0,"{")),e=e.concat(this.args[1].serialize()),e.push(new c(0,"}")),e}case"supsub":{let a=function(i){return i.type==="ordgroup"||i.type==="supsub"||i.type==="empty"?!0:!!(i.type==="element"&&/\d+(\.\d+)?/.test(i.content)&&i.content.length>1)};var t=a;let e=[],{base:r,sup:s,sub:o}=this.data;return e=e.concat(r.serialize()),o&&(e.push(new c(6,"_")),a(o)?(e.push(new c(0,"{")),e=e.concat(o.serialize()),e.push(new c(0,"}"))):e=e.concat(o.serialize())),s&&(e.push(new c(6,"^")),a(s)?(e.push(new c(0,"{")),e=e.concat(s.serialize()),e.push(new c(0,"}"))):e=e.concat(s.serialize())),e}case"control":return[new c(6,this.content)];case"beginend":{let e=[],r=this.data;e.push(new c(1,`\\begin{${this.content}}`)),e.push(new c(5,`
|
|
2
|
+
`));for(let s=0;s<r.length;s++){let o=r[s];for(let a=0;a<o.length;a++){let i=o[a];e=e.concat(i.serialize()),a!==o.length-1&&e.push(new c(6,"&"))}s!==r.length-1&&e.push(new c(6,"\\\\"))}return e.push(new c(5,`
|
|
3
|
+
`)),e.push(new c(1,`\\end{${this.content}}`)),e}default:throw new Error("[TexNode.serialize] Unimplemented type: "+this.type)}}isOverHigh(){switch(this.type){case"element":case"symbol":case"text":case"control":case"empty":return!1;case"binaryFunc":if(this.content==="\\frac")return!0;case"unaryFunc":case"ordgroup":return this.args.some(t=>t.isOverHigh());case"supsub":return this.data.base.isOverHigh();case"beginend":return!0;default:return!1}}};var h=class{constructor(t,e){this.type=t,this.value=e}eq(t){return this.type===t.type&&this.value===t.value}isOneOf(t){return B(t,this)}toNode(){switch(this.type){case 2:return new u("text",this.value);case 3:return new u("comment",this.value);case 4:case 7:return new u("whitespace",this.value);case 1:return new u("atom",this.value);case 0:return new u("symbol",this.value);case 6:{let t=this.value;switch(t){case"":case"_":case"^":return new u("empty","");case"&":return new u("control","&");case"\\":return new u("control","\\");default:throw new Error(`Unexpected control character ${t}`)}}default:throw new Error(`Unexpected token type ${this.type}`)}}toString(){switch(this.type){case 2:return`"${this.value}"`;case 3:return`//${this.value}`;default:return this.value}}},L=null,oe=!0;var u=class{constructor(t,e,r,s){this.type=t,this.content=e,this.args=r,this.data=s}setOptions(t){this.options=t}eq(t){return this.type===t.type&&this.content===t.content}};function _(n){return"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(n)}function S(n){return"0123456789".includes(n)}function b(n,t=""){if(!n)throw new Error(t)}var Se=["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"],Me=["frac","tfrac","binom","dbinom","dfrac","tbinom","overset"],ae=new l("empty","");function Le(n){return Se.includes(n)?1:Me.includes(n)?2:0}var I=new c(6,"{"),z=new c(6,"}"),ie=new c(0,"["),Oe=new c(0,"]");function Q(n,t){let e=t;for(;e<n.length&&[4,5].includes(n[e].type);)e++;return n.slice(t,e)}function le(n,t){let e=n[t];return e.type===0&&["(",")","[","]","|","\\{","\\}","."].includes(e.value)||e.type===1&&["lfloor","rfloor","lceil","rceil","langle","rangle"].includes(e.value.slice(1))?e:null}function P(n,t){let e=t;for(;e<n.length&&n[e].eq(new c(0,"'"));)e+=1;return e-t}function Ce(n,t){let e=t;for(;e<n.length&&_(n[e]);)e+=1;return n.substring(t,e)}function U(n,t,e,r){b(n[t].eq(e));let s=1,o=t+1;for(;s>0;){if(o>=n.length)return-1;n[o].eq(e)?s+=1:n[o].eq(r)&&(s-=1),o+=1}return o-1}var Z=new c(1,"\\left"),Pe=new c(1,"\\right");function Re(n,t){return U(n,t,Z,Pe)}var J=new c(1,"\\begin"),Ae=new c(1,"\\end");function De(n,t){return U(n,t,J,Ae)}function Be(n,t){b(n[t]==="{");let e=1,r=t+1;for(;e>0;){if(r>=n.length)throw new g("Unmatched curly brackets");if(r+1<n.length&&["\\{","\\}"].includes(n.substring(r,r+2))){r+=2;continue}n[r]==="{"?e+=1:n[r]==="}"&&(e-=1),r+=1}return r-1}function ue(n){let t=[],e=0;for(;e<n.length;){let r=n[e],s;switch(r){case"%":{let o=e+1;for(;o<n.length&&n[o]!==`
|
|
4
|
+
`;)o+=1;s=new c(3,n.slice(e+1,o)),e=o;break}case"{":case"}":case"_":case"^":case"&":s=new c(6,r),e++;break;case`
|
|
5
|
+
`:s=new c(5,r),e++;break;case"\r":{e+1<n.length&&n[e+1]===`
|
|
6
|
+
`?(s=new c(5,`
|
|
7
|
+
`),e+=2):(s=new c(5,`
|
|
8
|
+
`),e++);break}case" ":{let o=e;for(;o<n.length&&n[o]===" ";)o+=1;s=new c(4,n.slice(e,o)),e=o;break}case"\\":{if(e+1>=n.length)throw new g("Expecting command name after \\");let o=n.slice(e,e+2);if(["\\\\","\\,"].includes(o))s=new c(6,o);else if(["\\{","\\}","\\%","\\$","\\&","\\#","\\_","\\|"].includes(o))s=new c(0,o);else{let a=Ce(n,e+1);s=new c(1,"\\"+a)}e+=s.value.length;break}default:{if(S(r)){let o=e;for(;o<n.length&&S(n[o]);)o+=1;s=new c(0,n.slice(e,o))}else _(r)?s=new c(0,r):"+-*/='<>!.,;:?()[]|".includes(r)?s=new c(0,r):s=new c(7,r);e+=s.value.length}}if(t.push(s),s.type===1&&["\\text","\\operatorname","\\begin","\\end"].includes(s.value)){if(e>=n.length||n[e]!=="{")throw new g(`No content for ${s.value} command`);t.push(new c(6,"{"));let o=Be(n,e);e++;let a=n.slice(e,o),i=["{","}","\\","$","&","#","_","%"];for(let p of i)a=a.replaceAll("\\"+p,p);t.push(new c(2,a)),t.push(new c(6,"}")),e=o+1}}return t}var g=class extends Error{constructor(t){super(t),this.name="LatexParserError"}},ee=new c(6,"_"),te=new c(6,"^"),re=class{constructor(t=!1,e=!0){this.space_sensitive=t,this.newline_sensitive=e}parse(t){let[e,r]=this.parseGroup(t,0,t.length);return e}parseGroup(t,e,r){let s=[],o=e;for(;o<r;){let[i,p]=this.parseNextExpr(t,o);if(o=p,!(i.type==="whitespace"&&(!this.space_sensitive&&i.content.replace(/ /g,"").length===0||!this.newline_sensitive&&i.content===`
|
|
9
|
+
`))){if(i.type==="control"&&i.content==="&")throw new g("Unexpected & outside of an alignment");s.push(i)}}let a;return s.length===0?a=ae:s.length===1?a=s[0]:a=new l("ordgroup","",s),[a,r+1]}parseNextExpr(t,e){let[r,s]=this.parseNextExprWithoutSupSub(t,e),o=null,a=null,i=0;if(i+=P(t,s),s+=i,s<t.length&&t[s].eq(ee)){if([o,s]=this.parseNextExprWithoutSupSub(t,s+1),i+=P(t,s),s+=i,s<t.length&&t[s].eq(te)&&([a,s]=this.parseNextExprWithoutSupSub(t,s+1),P(t,s)>0))throw new g("Double superscript")}else if(s<t.length&&t[s].eq(te)){if([a,s]=this.parseNextExprWithoutSupSub(t,s+1),P(t,s)>0)throw new g("Double superscript");if(s<t.length&&t[s].eq(ee)&&([o,s]=this.parseNextExprWithoutSupSub(t,s+1),P(t,s)>0))throw new g("Double superscript")}if(o!==null||a!==null||i>0){let p={base:r};if(o&&(p.sub=o),i>0){p.sup=new l("ordgroup","",[]);for(let d=0;d<i;d++)p.sup.args.push(new l("element","'"));a&&p.sup.args.push(a),p.sup.args.length===1&&(p.sup=p.sup.args[0])}else a&&(p.sup=a);return[new l("supsub","",[],p),s]}else return[r,s]}parseNextExprWithoutSupSub(t,e){let r=t[e];switch(r.type){case 0:return[new l("element",r.value),e+1];case 2:return[new l("text",r.value),e+1];case 3:return[new l("comment",r.value),e+1];case 4:case 5:return[new l("whitespace",r.value),e+1];case 1:return r.eq(J)?this.parseBeginEndExpr(t,e):r.eq(Z)?this.parseLeftRightExpr(t,e):this.parseCommandExpr(t,e);case 6:switch(r.value){case"{":let o=U(t,e,I,z);if(o===-1)throw new g("Unmatched '{'");return this.parseGroup(t,e+1,o);case"}":throw new g("Unmatched '}'");case"\\\\":return[new l("control","\\\\"),e+1];case"\\,":return[new l("control","\\,"),e+1];case"_":case"^":return[ae,e];case"&":return[new l("control","&"),e+1];default:throw new g("Unknown control sequence")}default:throw new g("Unknown token type")}}parseCommandExpr(t,e){b(t[e].type===1);let r=t[e].value,s=e+1;if(["left","right","begin","end"].includes(r.slice(1)))throw new g("Unexpected command: "+r);switch(Le(r.slice(1))){case 0:return E.has(r.slice(1))?[new l("symbol",r),s]:[new l("unknownMacro",r),s];case 1:{if(s>=t.length)throw new g("Expecting argument for "+r);if(r==="\\sqrt"&&s<t.length&&t[s].eq(ie)){let p=s,d=U(t,s,ie,Oe);if(d===-1)throw new g("No matching right square bracket for [");let[f,q]=this.parseGroup(t,p+1,d),[y,C]=this.parseNextExprWithoutSupSub(t,d+1);return[new l("unaryFunc",r,[y],f),C]}else if(r==="\\text"){if(s+2>=t.length)throw new g("Expecting content for \\text command");b(t[s].eq(I)),b(t[s+1].type===2),b(t[s+2].eq(z));let p=t[s+1].value;return[new l("text",p),s+3]}let[a,i]=this.parseNextExprWithoutSupSub(t,s);return[new l("unaryFunc",r,[a]),i]}case 2:{let[a,i]=this.parseNextExprWithoutSupSub(t,s),[p,d]=this.parseNextExprWithoutSupSub(t,i);return[new l("binaryFunc",r,[a,p]),d]}default:throw new Error("Invalid number of parameters")}}parseLeftRightExpr(t,e){b(t[e].eq(Z));let r=e+1;if(r+=Q(t,r).length,r>=t.length)throw new g("Expecting delimiter after \\left");let s=le(t,r);if(s===null)throw new g("Invalid delimiter after \\left");r++;let o=r,a=Re(t,e);if(a===-1)throw new g("No matching \\right");let i=a;if(r=a+1,r+=Q(t,r).length,r>=t.length)throw new g("Expecting \\right after \\left");let p=le(t,r);if(p===null)throw new g("Invalid delimiter after \\right");r++;let[d,f]=this.parseGroup(t,o,i),q=[new l("element",s.value),d,new l("element",p.value)];return[new l("leftright","",q),r]}parseBeginEndExpr(t,e){b(t[e].eq(J));let r=e+1;b(t[r].eq(I)),b(t[r+1].type===2),b(t[r+2].eq(z));let s=t[r+1].value;r+=3,r+=Q(t,r).length;let o=r,a=De(t,e);if(a===-1)throw new g("No matching \\end");let i=a;if(r=a+1,b(t[r].eq(I)),b(t[r+1].type===2),b(t[r+2].eq(z)),t[r+1].value!==s)throw new g("Mismatched \\begin and \\end environments");r+=3;let p=t.slice(o,i);for(;p.length>0&&[4,5].includes(p[p.length-1].type);)p.pop();let d=this.parseAligned(p);return[new l("beginend",s,[],d),r]}parseAligned(t){let e=0,r=[],s=[];r.push(s);let o=new l("ordgroup","",[]);for(s.push(o);e<t.length;){let[a,i]=this.parseNextExpr(t,e);e=i,!(a.type==="whitespace"&&(!this.space_sensitive&&a.content.replace(/ /g,"").length===0||!this.newline_sensitive&&a.content===`
|
|
10
|
+
`))&&(a.type==="control"&&a.content==="\\\\"?(s=[],o=new l("ordgroup","",[]),s.push(o),r.push(s)):a.type==="control"&&a.content==="&"?(o=new l("ordgroup","",[]),s.push(o)):o.args.push(a))}return r}};function Ie(n){let t=r=>r.eq(ee)||r.eq(te),e=[];for(let r=0;r<n.length;r++)n[r].type===4&&r+1<n.length&&t(n[r+1])||n[r].type===4&&r-1>=0&&t(n[r-1])||e.push(n[r]);return e}function ze(n,t){let e=[];for(let r of n)if(r.type===1&&t[r.value]){let s=ue(t[r.value]);e=e.concat(s)}else e.push(r);return e}function ce(n,t){let e=new re,r=ue(n);return r=Ie(r),r=ze(r,t),e.parse(r)}var de=["dim","id","im","mod","Pr","sech","csch"];function pe(n){return n.type==="atom"&&["(",")","[","]","{","}","|","\u230A","\u230B","\u2308","\u2309"].includes(n.content)}var R=new h(1,"("),O=new h(1,")"),We=new h(1,","),Ye=new h(0,`
|
|
11
|
+
`);function he(n){switch(typeof n){case"string":return`"${n}"`;case"number":return n.toString();case"boolean":return n?"#true":"#false";default:if(n===null)return"#none";throw new T(`Invalid primitive value: ${n}`,n)}}var T=class extends Error{constructor(t,e){super(t),this.name="TypstWriterError",this.node=e}},W=class{constructor(t,e,r){this.buffer="";this.queue=[];this.insideFunctionDepth=0;this.nonStrict=t,this.preferTypstIntrinsic=e,this.keepSpaces=r}writeBuffer(t){let e=t.toString();if(e==="")return;let r=!1;r||=/[\(\[\|]$/.test(this.buffer)&&/^\w/.test(e),r||=/^[})\]\|]$/.test(e),r||=/[^=]$/.test(this.buffer)&&e==="(",r||=/^[_^,;!]$/.test(e),r||=e==="'",r||=/[0-9]$/.test(this.buffer)&&/^[0-9]/.test(e),r||=/[\(\[{]\s*(-|\+)$/.test(this.buffer)||this.buffer==="-"||this.buffer==="+",r||=e.startsWith(`
|
|
12
|
+
`),r||=this.buffer==="",r||=/^\s/.test(e),r||=this.buffer.endsWith("&")&&e==="=",r||=this.buffer.endsWith("/")||e==="/",r||=/[\s_^{\(]$/.test(this.buffer),r||(this.buffer+=" "),this.buffer+=e}serialize(t){switch(t.type){case"empty":break;case"atom":{t.content===","&&this.insideFunctionDepth>0?this.queue.push(new h(0,"comma")):this.queue.push(new h(1,t.content));break}case"symbol":this.queue.push(new h(0,t.content));break;case"text":this.queue.push(new h(2,t.content));break;case"comment":this.queue.push(new h(3,t.content));break;case"whitespace":for(let e of t.content)if(e===" ")this.keepSpaces&&this.queue.push(new h(4,e));else if(e===`
|
|
13
|
+
`)this.queue.push(new h(0,e));else throw new T(`Unexpected whitespace character: ${e}`,t);break;case"group":for(let e of t.args)this.serialize(e);break;case"supsub":{let{base:e,sup:r,sub:s}=t.data;this.appendWithBracketsIfNeeded(e);let o=!1,a=r&&r.type==="atom"&&r.content==="'";a&&(this.queue.push(new h(1,"'")),o=!1),s&&(this.queue.push(new h(1,"_")),o=this.appendWithBracketsIfNeeded(s)),r&&!a&&(this.queue.push(new h(1,"^")),o=this.appendWithBracketsIfNeeded(r)),o&&this.queue.push(new h(6," "));break}case"funcCall":{let e=new h(0,t.content);this.queue.push(e),this.insideFunctionDepth++,this.queue.push(R);for(let r=0;r<t.args.length;r++)this.serialize(t.args[r]),r<t.args.length-1&&this.queue.push(new h(1,","));if(t.options)for(let[r,s]of Object.entries(t.options)){let o=he(s);this.queue.push(new h(0,`, ${r}: ${o}`))}this.queue.push(O),this.insideFunctionDepth--;break}case"fraction":{let[e,r]=t.args;e.type==="group"?(this.queue.push(R),this.serialize(e),this.queue.push(O)):this.serialize(e),this.queue.push(new h(1,"/")),r.type==="group"?(this.queue.push(R),this.serialize(r),this.queue.push(O)):this.serialize(r);break}case"align":{let e=t.data;e.forEach((r,s)=>{r.forEach((o,a)=>{a>0&&this.queue.push(new h(1,"&")),this.serialize(o)}),s<e.length-1&&this.queue.push(new h(0,"\\"))});break}case"matrix":{let e=t.data;if(this.queue.push(new h(0,"mat")),this.insideFunctionDepth++,this.queue.push(R),t.options)for(let[r,s]of Object.entries(t.options)){let o=he(s);this.queue.push(new h(0,`${r}: ${o}, `))}e.forEach((r,s)=>{r.forEach((o,a)=>{this.serialize(o),a<r.length-1?this.queue.push(new h(1,",")):s<e.length-1&&this.queue.push(new h(1,";"))})}),this.queue.push(O),this.insideFunctionDepth--;break}case"unknown":{if(this.nonStrict)this.queue.push(new h(0,t.content));else throw new T(`Unknown macro: ${t.content}`,t);break}default:throw new T(`Unimplemented node type to append: ${t.type}`,t)}}appendWithBracketsIfNeeded(t){let e=["group","supsub","empty"].includes(t.type);if(t.type==="group"){let r=t.args[0],s=t.args[t.args.length-1];pe(r)&&pe(s)&&(e=!1)}return e?(this.queue.push(R),this.serialize(t),this.queue.push(O)):this.serialize(t),!e}flushQueue(){let t=new h(6," ");for(let e=0;e<this.queue.length;e++)this.queue[e].eq(t)&&(e===this.queue.length-1?this.queue[e].value="":this.queue[e+1].isOneOf([O,We,Ye])&&(this.queue[e].value=""));this.queue.forEach(e=>{this.writeBuffer(e)}),this.queue=[]}finalize(){this.flushQueue();let s=[function(o){let a=o.replace(/floor\.l\s*(.*?)\s*floor\.r/g,"floor($1)");return a=a.replace(/floor\(\)/g,'floor("")'),a},function(o){let a=o.replace(/ceil\.l\s*(.*?)\s*ceil\.r/g,"ceil($1)");return a=a.replace(/ceil\(\)/g,'ceil("")'),a},function(o){let a=o.replace(/floor\.l\s*(.*?)\s*ceil\.r/g,"round($1)");return a=a.replace(/round\(\)/g,'round("")'),a}];for(let o of s)this.buffer=o(this.buffer);return this.buffer}};function A(n){if(/^[a-zA-Z0-9]$/.test(n))return n;if(n==="/")return"\\/";if(n==="\\|")return"parallel";if(n==="\\\\")return"\\";if(["\\$","\\#","\\&","\\_"].includes(n))return n;if(n.startsWith("\\")){let t=n.slice(1);return E.has(t)?E.get(t):t}return n}function $e(n,t){let[e,r]=n.args,s=i=>{if(i.eq(new l("text","def")))return!0;if(i.type==="ordgroup"&&i.args.length===3){let[p,d,f]=i.args,q=new l("element","d"),y=new l("element","e"),C=new l("element","f");if(p.eq(q)&&d.eq(y)&&f.eq(C))return!0}return!1},o=i=>i.eq(new l("element","="));if(s(e)&&o(r))return new u("symbol","eq.def");let a=new u("funcCall","op",[w(r,t)]);return a.setOptions({limits:oe}),new u("supsub","",[],{base:a,sup:w(e,t)})}function w(n,t={}){switch(n.type){case"empty":return new u("empty","");case"whitespace":return new u("whitespace",n.content);case"ordgroup":return new u("group","",n.args.map(e=>w(e,t)));case"element":return new u("atom",A(n.content));case"symbol":return new u("symbol",A(n.content));case"text":return new u("text",n.content);case"comment":return new u("comment",n.content);case"supsub":{let{base:e,sup:r,sub:s}=n.data;if(e&&e.type==="unaryFunc"&&e.content==="\\overbrace"&&r)return new u("funcCall","overbrace",[w(e.args[0],t),w(r,t)]);if(e&&e.type==="unaryFunc"&&e.content==="\\underbrace"&&s)return new u("funcCall","underbrace",[w(e.args[0],t),w(s,t)]);let o={base:w(e,t)};return o.base.type==="empty"&&(o.base=new u("text","")),r&&(o.sup=w(r,t)),s&&(o.sub=w(s,t)),new u("supsub","",[],o)}case"leftright":{let[e,r,s]=n.args,o=new u("group","",n.args.map(a=>w(a,t)));return["[]","()","\\{\\}","\\lfloor\\rfloor","\\lceil\\rceil","\\lfloor\\rceil"].includes(e.content+s.content)?o:s.content==="."?(o.args.pop(),o):e.content==="."?(o.args.shift(),new u("funcCall","lr",[o])):new u("funcCall","lr",[o])}case"binaryFunc":return n.content==="\\overset"?$e(n,t):n.content==="\\frac"&&t.fracToSlash?new u("fraction","",n.args.map(e=>w(e,t))):new u("funcCall",A(n.content),n.args.map(e=>w(e,t)));case"unaryFunc":{let e=w(n.args[0],t);if(n.content==="\\sqrt"&&n.data){let r=w(n.data,t);return new u("funcCall","root",[r,e])}if(n.content==="\\mathbf"){let r=new u("funcCall","bold",[e]);return new u("funcCall","upright",[r])}if(n.content==="\\mathbb"&&e.type==="atom"&&/^[A-Z]$/.test(e.content))return new u("symbol",e.content+e.content);if(n.content==="\\operatorname"){let r=n.args;if(r.length!==1||r[0].type!=="text")throw new T("Expecting body of \\operatorname to be text but got",n);let s=r[0].content;return de.includes(s)?new u("symbol",s):new u("funcCall","op",[new u("text",s)])}return new u("funcCall",A(n.content),n.args.map(r=>w(r,t)))}case"beginend":{let r=n.data.map(s=>s.map(o=>w(o,t)));if(n.content.startsWith("align"))return new u("align","",[],r);if(n.content.endsWith("matrix")){let s=null;switch(n.content){case"matrix":s=L;break;case"pmatrix":s="(";break;case"bmatrix":s="[";break;case"Bmatrix":s="{";break;case"vmatrix":s="|";break;case"Vmatrix":{let a=new u("matrix","",[],r);a.setOptions({delim:L});let i=new u("group","",[new u("symbol","||"),a,new u("symbol","||")]);return new u("funcCall","lr",[i])}default:throw new T(`Unimplemented beginend: ${n.content}`,n)}let o=new u("matrix","",[],r);return o.setOptions({delim:s}),o}throw new T(`Unimplemented beginend: ${n.content}`,n)}case"unknownMacro":return new u("unknown",A(n.content));case"control":if(n.content==="\\\\")return new u("symbol","\\");if(n.content==="\\,")return new u("symbol","thin");throw new T(`Unknown control sequence: ${n.content}`,n);default:throw new T(`Unimplemented node type: ${n.type}`,n)}}var Fe=["sqrt","bold","arrow","upright","lr","op","macron","dot","dot.double","hat","tilde","overline","underline","bb","cal","frak"],Ge=["frac","root","overbrace","underbrace"];function ge(n){return["{","}","%"].includes(n)?"\\"+n:n}function Y(n){return/^[a-zA-Z0-9]$/.test(n)?n:n==="thin"?"\\,":M.has(n)?"\\"+M.get(n):"\\"+n}function m(n){if(n.eq(new u("symbol","eq.def")))return new l("binaryFunc","\\overset",[new l("text","def"),new l("element","=")]);switch(n.type){case"empty":return new l("empty","");case"whitespace":return new l("whitespace",n.content);case"atom":return new l("element",n.content);case"symbol":switch(n.content){case"comma":return new l("element",",");case"hyph":case"hyph.minus":return new l("text","-");default:return new l("symbol",Y(n.content))}case"text":return new l("text",n.content);case"comment":return new l("comment",n.content);case"group":{let t=n.args.map(m);return new l("ordgroup",n.content,t)}case"funcCall":if(Fe.includes(n.content)){if(n.content==="lr"){let e=n.args[0];if(e.type==="group"){let r=e.args[0].content,s=e.args[e.args.length-1].content;return r=ge(r),s=ge(s),new l("ordgroup","",[new l("element","\\left"+r),...e.args.slice(1,e.args.length-1).map(m),new l("element","\\right"+s)])}}let t=Y(n.content);return new l("unaryFunc",t,n.args.map(m))}else if(Ge.includes(n.content)){if(n.content==="root"){let[e,r]=n.args,s=m(e);return new l("unaryFunc","\\sqrt",[m(r)],s)}if(n.content==="overbrace"||n.content==="underbrace"){let[e,r]=n.args,s=new l("unaryFunc","\\"+n.content,[m(e)]),o=m(r),a=n.content==="overbrace"?{base:s,sup:o}:{base:s,sub:o};return new l("supsub","",[],a)}let t=Y(n.content);return new l("binaryFunc",t,n.args.map(m))}else return new l("ordgroup","",[new l("symbol",Y(n.content)),new l("element","("),...n.args.map(m),new l("element",")")]);case"supsub":{let{base:t,sup:e,sub:r}=n.data,s=m(t),o,a;return e&&(o=m(e)),r&&(a=m(r)),new l("supsub","",[],{base:s,sup:o,sub:a})}case"matrix":{let e=n.data.map(a=>a.map(m)),r=new l("beginend","matrix",[],e),s="\\left(",o="\\right)";if(n.options&&"delim"in n.options)switch(n.options.delim){case L:return r;case"[":s="\\left[",o="\\right]";break;case"]":s="\\left]",o="\\right[";break;case"{":s="\\left\\{",o="\\right\\}";break;case"}":s="\\left\\}",o="\\right\\{";break;case"|":s="\\left|",o="\\right|";break;case")":s="\\left)",o="\\right(";case"(":default:s="\\left(",o="\\right)";break}return new l("ordgroup","",[new l("element",s),r,new l("element",o)])}case"control":switch(n.content){case"\\":return new l("control","\\\\");case"&":return new l("control","&");default:throw new Error("[convert_typst_node_to_tex] Unimplemented control: "+n.content)}case"fraction":{let[t,e]=n.args,r=m(t),s=m(e);return new l("binaryFunc","\\frac",[r,s])}default:throw new Error("[convert_typst_node_to_tex] Unimplemented type: "+n.type)}}function we(n,t){let e=t;for(;e<n.length&&n[e].eq(new h(1,"'"));)e+=1;return e-t}function Ve(n,t){let e=t;for(;e<n.length&&(_(n[e])||n[e]===".");)e+=1;return n.substring(t,e)}var F=new u("empty","");function Xe(n){let t=[],e=0;for(;e<n.length;){let r=n[e],s;switch(r){case"_":case"^":case"&":s=new h(6,r),e++;break;case`
|
|
14
|
+
`:s=new h(7,r),e++;break;case"\r":{e+1<n.length&&n[e+1]===`
|
|
15
|
+
`?(s=new h(7,`
|
|
16
|
+
`),e+=2):(s=new h(7,`
|
|
17
|
+
`),e++);break}case" ":{let o=e;for(;o<n.length&&n[o]===" ";)o++;s=new h(4,n.substring(e,o)),e=o;break}case"/":{if(e<n.length&&n[e+1]==="/"){let o=e+2;for(;o<n.length&&n[o]!==`
|
|
18
|
+
`;)o++;s=new h(3,n.slice(e+2,o)),e=o}else s=new h(1,"/"),e++;break}case"\\":{if(e+1>=n.length)throw new Error("Expecting a character after \\");let o=n.substring(e,e+2);["\\$","\\&","\\#","\\_"].includes(o)?(s=new h(1,o),e+=2):[`\\
|
|
19
|
+
`,"\\ "].includes(o)?(s=new h(6,"\\"),e+=1):(s=new h(6,""),e++);break}case'"':{let o=e+1;for(;o<n.length&&!(n[o]==='"'&&n[o-1]!=="\\");)o++;let a=n.substring(e+1,o),i=['"',"\\"];for(let p of i)a=a.replaceAll("\\"+p,p);s=new h(2,a),e=o+1;break}default:{if(S(r)){let o=e;for(;o<n.length&&S(n[o]);)o+=1;if(o<n.length&&n[o]===".")for(o+=1;o<n.length&&S(n[o]);)o+=1;s=new h(1,n.slice(e,o))}else if("+-*/='<>!.,;?()[]|".includes(r))s=new h(1,r);else if(_(r)){let o=Ve(n,e),a=o.length===1?1:0;s=new h(a,o)}else s=new h(1,r);e+=s.value.length}}t.push(s)}return t}function $(n,t){b(n[t].isOneOf([D,Te,qe]));let e=1,r=t+1;for(;e>0;){if(r>=n.length)throw new Error("Unmatched brackets");n[r].isOneOf([D,Te,qe])?e+=1:n[r].isOneOf([Qe,Ze,Je])&&(e-=1),r+=1}return r-1}function He(n,t){let e=new u("atom","("),r=new u("atom",")");b(n[t].eq(e));let s=1,o=t+1;for(;s>0;){if(o>=n.length)throw new Error("Unmatched brackets");n[o].eq(e)?s+=1:n[o].eq(r)&&(s-=1),o+=1}return o-1}function be(n){let t=[];for(let e=0;e<n;e++)t.push(new u("atom","'"));return t}var G=new u("atom","/");function je(n,t){let e=t;for(;e<n.length&&n[e].type==="whitespace";)e++;return e===n.length?F:n[e]}function Ke(n){let t=!1,e=[];for(let r=0;r<n.length;r++){let s=n[r];s.type==="whitespace"&&(t||je(n,r+1).eq(G))||(s.eq(G)?t=!0:t=!1,e.push(s))}return e}function ne(n,t=!1){n=Ke(n);let e=new u("atom","("),r=new u("atom",")"),s=[],o=[],a=0;for(;a<n.length;){let i=n[a];if(i.eq(r))throw new v("Unexpected ')'");if(i.eq(G))s.push(i),a++;else{let p;if(i.eq(e)){let d=He(n,a);p=ne(n.slice(a+1,d),!0),a=d+1}else p=i,a++;if(s.length>0&&s[s.length-1].eq(G)){let d=p;if(o.length===0)throw new v("Unexpected '/' operator, no numerator before it");let f=o.pop();d.type==="group"&&d.content==="parenthesis"&&(d.content=""),f.type==="group"&&f.content==="parenthesis"&&(f.content=""),o.push(new u("fraction","",[f,d])),s.pop()}else o.push(p)}}return t?new u("group","parenthesis",o):o.length===0?F:o.length===1?o[0]:new u("group","",o)}var v=class extends Error{constructor(t){super(t),this.name="TypstParserError"}},me=new h(6,"_"),fe=new h(6,"^"),D=new h(1,"("),Qe=new h(1,")"),Te=new h(1,"["),Ze=new h(1,"]"),qe=new h(1,"{"),Je=new h(1,"}"),et=new h(1,","),tt=new h(1,";"),rt=new h(4," "),se=class{constructor(t=!0,e=!0){this.space_sensitive=t,this.newline_sensitive=e}parse(t){let[e,r]=this.parseGroup(t,0,t.length);return e}parseGroup(t,e,r,s=!1){let o=[],a=e;for(;a<r;){let[p,d]=this.parseNextExpr(t,a);a=d,!(p.type==="whitespace"&&(!this.space_sensitive&&p.content.replace(/ /g,"").length===0||!this.newline_sensitive&&p.content===`
|
|
20
|
+
`))&&o.push(p)}let i;return s?i=ne(o,!0):o.length===0?i=F:o.length===1?i=o[0]:i=ne(o),[i,r+1]}parseNextExpr(t,e){let[r,s]=this.parseNextExprWithoutSupSub(t,e),o=null,a=null,i=we(t,s);if(i>0&&(r=new u("group","",[r].concat(be(i))),s+=i),s<t.length&&t[s].eq(me)?([o,s]=this.parseSupOrSub(t,s+1),s<t.length&&t[s].eq(fe)&&([a,s]=this.parseSupOrSub(t,s+1))):s<t.length&&t[s].eq(fe)&&([a,s]=this.parseSupOrSub(t,s+1),s<t.length&&t[s].eq(me)&&([o,s]=this.parseSupOrSub(t,s+1))),o!==null||a!==null){let p={base:r};return o&&(p.sub=o),a&&(p.sup=a),[new u("supsub","",[],p),s]}else return[r,s]}parseSupOrSub(t,e){let r,s;if(t[e].eq(D)){let a=$(t,e);[r,s]=this.parseGroup(t,e+1,a)}else[r,s]=this.parseNextExprWithoutSupSub(t,e);let o=we(t,s);return o>0&&(r=new u("group","",[r].concat(be(o))),s+=o),[r,s]}parseNextExprWithoutSupSub(t,e){let r=t[e],s=r.toNode();if(r.eq(D)){let o=$(t,e);return this.parseGroup(t,e+1,o,!0)}if(r.type===1&&!_(r.value[0]))return[s,e+1];if([1,0].includes(r.type)&&e+1<t.length&&t[e+1].eq(D)){if(r.value==="mat"){let[p,d,f]=this.parseGroupsOfArguments(t,e+1),q=new u("matrix","",[],p);return q.setOptions(d),[q,f]}let[o,a]=this.parseArguments(t,e+1),i=new u("funcCall",r.value);return i.args=o,[i,a]}return[s,e+1]}parseArguments(t,e){let r=$(t,e);return[this.parseCommaSeparatedArguments(t,e+1,r),r+1]}parseGroupsOfArguments(t,e){let r=$(t,e);t=t.slice(0,r);let s=[],o={},a=e+1;for(;a<r;)for(;a<r;){let q=function(y){let C=new u("atom",":"),X={},H=[];for(let x=0;x<y.length;x++){if(y[x].type!=="group")continue;let N=y[x],k=j(N.args,C);if(k===-1||k===0)continue;if(H.push(x),N.args[k-1].eq(new u("symbol","delim")))if(N.args[k+1].type==="text"){if(X.delim=N.args[k+1].content,N.args.length!==3)throw new v("Invalid number of arguments for delim")}else if(N.args[k+1].eq(new u("atom","#"))){if(N.args.length!==4||!N.args[k+2].eq(new u("symbol","none")))throw new v("Invalid number of arguments for delim");X.delim=L}else throw new v("Not implemented for other types of delim");else throw new v("Not implemented for other named parameters")}for(let x=H.length-1;x>=0;x--)y.splice(H[x],1);return[y,X]};var i=q;let p=j(t,tt,a);p===-1&&(p=r);let d=this.parseCommaSeparatedArguments(t,a,p),f={};[d,f]=q(d),s.push(d),Object.assign(o,f),a=p+1}return[s,o,r+1]}parseCommaSeparatedArguments(t,e,r){let s=[],o=e;for(;o<r;){let a=new u("group","",[]);for(;o<r;){if(t[o].eq(et)){o+=1;break}else if(t[o].eq(rt)){o+=1;continue}let[i,p]=this.parseNextExpr(t,o);o=p,a.args.push(i)}a.args.length===0?a=F:a.args.length===1&&(a=a.args[0]),s.push(a)}return s}};function ye(n){let t=new se,e=Xe(n);return t.parse(e)}var V=class{constructor(){this.buffer="";this.queue=[]}writeBuffer(t){let e=t.toString(),r=!1;t.type===4?r=!0:(r||=/[{\(\[\|]$/.test(this.buffer),r||=/\\\w+$/.test(this.buffer)&&e==="[",r||=/^[\.,;:!\?\(\)\]{}_^]$/.test(e),r||=["\\{","\\}"].includes(e),r||=e==="'",r||=this.buffer.endsWith("_")||this.buffer.endsWith("^"),r||=/\s$/.test(this.buffer),r||=/^\s/.test(e),r||=this.buffer==="",r||=/[\(\[{]\s*(-|\+)$/.test(this.buffer)||this.buffer==="-"||this.buffer==="+",r||=this.buffer.endsWith("&")&&e==="="),r||(this.buffer+=" "),this.buffer+=e}append(t){let e=new l("control","&"),r=new l("control","\\\\");if(t.type==="ordgroup"&&B(t.args,e)){let s=K(t.args,r),o=[];for(let a of s){let i=K(a,e);o.push(i.map(p=>new l("ordgroup","",p)))}t=new l("beginend","aligned",[],o)}this.queue=this.queue.concat(t.serialize())}flushQueue(){for(let t=0;t<this.queue.length;t++)this.writeBuffer(this.queue[t]);this.queue=[]}finalize(){return this.flushQueue(),this.buffer}};function xe(n,t){let e={nonStrict:!0,preferTypstIntrinsic:!0,keepSpaces:!1,fracToSlash:!0,customTexMacros:{}};t&&(t.nonStrict&&(e.nonStrict=t.nonStrict),t.preferTypstIntrinsic&&(e.preferTypstIntrinsic=t.preferTypstIntrinsic),t.customTexMacros&&(e.customTexMacros=t.customTexMacros),t.fracToSlash!==void 0&&(e.fracToSlash=t.fracToSlash));let r=ce(n,e.customTexMacros),s=w(r,e),o=new W(e.nonStrict,e.preferTypstIntrinsic,e.keepSpaces);return o.serialize(s),o.finalize()}function Ee(n){let t=ye(n),e=m(t),r=new V;return r.append(e),r.finalize()}typeof window<"u"&&(window.tex2typst=xe,window.typst2tex=Ee);})();
|
package/dist/types.d.ts
CHANGED
|
@@ -69,9 +69,13 @@ export interface TypstSupsubData {
|
|
|
69
69
|
}
|
|
70
70
|
export type TypstArrayData = TypstNode[][];
|
|
71
71
|
type TypstNodeType = 'atom' | 'symbol' | 'text' | 'control' | 'comment' | 'whitespace' | 'empty' | 'group' | 'supsub' | 'funcCall' | 'fraction' | 'align' | 'matrix' | 'unknown';
|
|
72
|
+
export type TypstPrimitiveValue = string | boolean | null;
|
|
72
73
|
export type TypstNamedParams = {
|
|
73
|
-
[key: string]:
|
|
74
|
+
[key: string]: TypstPrimitiveValue;
|
|
74
75
|
};
|
|
76
|
+
export declare const TYPST_NONE: TypstPrimitiveValue;
|
|
77
|
+
export declare const TYPST_TRUE: TypstPrimitiveValue;
|
|
78
|
+
export declare const TYPST_FALSE: TypstPrimitiveValue;
|
|
75
79
|
export declare class TypstNode {
|
|
76
80
|
type: TypstNodeType;
|
|
77
81
|
content: string;
|
|
@@ -79,9 +83,7 @@ export declare class TypstNode {
|
|
|
79
83
|
data?: TypstSupsubData | TypstArrayData;
|
|
80
84
|
options?: TypstNamedParams;
|
|
81
85
|
constructor(type: TypstNodeType, content: string, args?: TypstNode[], data?: TypstSupsubData | TypstArrayData);
|
|
82
|
-
setOptions(options:
|
|
83
|
-
[key: string]: string;
|
|
84
|
-
}): void;
|
|
86
|
+
setOptions(options: TypstNamedParams): void;
|
|
85
87
|
eq(other: TypstNode): boolean;
|
|
86
88
|
}
|
|
87
89
|
export interface Tex2TypstOptions {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tex2typst",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "JavaScript library for converting TeX code to Typst",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"prebuild": "rimraf dist/",
|
|
18
|
-
"build:node": "
|
|
19
|
-
"build:browser": "
|
|
18
|
+
"build:node": "esbuild src/index.ts --bundle --platform=node --outfile=dist/index.js --format=esm",
|
|
19
|
+
"build:browser": "esbuild src/tex2typst.ts --bundle --platform=browser --outfile=dist/tex2typst.min.js --minify",
|
|
20
20
|
"build:types": "tsc --project ./tsconfig.json",
|
|
21
21
|
"build": "npm run build:node && npm run build:browser && npm run build:types",
|
|
22
22
|
"test": "vitest run",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"js-yaml": "^4.1.0",
|
|
28
28
|
"rimraf": "^3.0.2",
|
|
29
29
|
"toml": "^3.0.0",
|
|
30
|
-
"ts-node": "^10.9.2",
|
|
31
30
|
"typescript": "^5.5.3",
|
|
32
|
-
"vitest": "^2.0.2"
|
|
31
|
+
"vitest": "^2.0.2",
|
|
32
|
+
"esbuild": "^0.25.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {}
|
|
35
35
|
}
|