katex.js 406 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788
  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.katex = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. "use strict";
  3. var _ParseError = require("./src/ParseError");
  4. var _ParseError2 = _interopRequireDefault(_ParseError);
  5. var _Settings = require("./src/Settings");
  6. var _Settings2 = _interopRequireDefault(_Settings);
  7. var _buildTree = require("./src/buildTree");
  8. var _buildTree2 = _interopRequireDefault(_buildTree);
  9. var _parseTree = require("./src/parseTree");
  10. var _parseTree2 = _interopRequireDefault(_parseTree);
  11. var _utils = require("./src/utils");
  12. var _utils2 = _interopRequireDefault(_utils);
  13. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14. /**
  15. * Parse and build an expression, and place that expression in the DOM node
  16. * given.
  17. */
  18. var render = function render(expression, baseNode, options) {
  19. _utils2.default.clearNode(baseNode);
  20. var settings = new _Settings2.default(options);
  21. var tree = (0, _parseTree2.default)(expression, settings);
  22. var node = (0, _buildTree2.default)(tree, expression, settings).toNode();
  23. baseNode.appendChild(node);
  24. };
  25. // KaTeX's styles don't work properly in quirks mode. Print out an error, and
  26. // disable rendering.
  27. /* eslint no-console:0 */
  28. /**
  29. * This is the main entry point for KaTeX. Here, we expose functions for
  30. * rendering expressions either to DOM nodes or to markup strings.
  31. *
  32. * We also expose the ParseError class to check if errors thrown from KaTeX are
  33. * errors in the expression, or errors in javascript handling.
  34. */
  35. if (typeof document !== "undefined") {
  36. if (document.compatMode !== "CSS1Compat") {
  37. typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype.");
  38. render = function render() {
  39. throw new _ParseError2.default("KaTeX doesn't work in quirks mode.");
  40. };
  41. }
  42. }
  43. /**
  44. * Parse and build an expression, and return the markup for that.
  45. */
  46. var renderToString = function renderToString(expression, options) {
  47. var settings = new _Settings2.default(options);
  48. var tree = (0, _parseTree2.default)(expression, settings);
  49. return (0, _buildTree2.default)(tree, expression, settings).toMarkup();
  50. };
  51. /**
  52. * Parse an expression and return the parse tree.
  53. */
  54. var generateParseTree = function generateParseTree(expression, options) {
  55. var settings = new _Settings2.default(options);
  56. return (0, _parseTree2.default)(expression, settings);
  57. };
  58. module.exports = {
  59. render: render,
  60. renderToString: renderToString,
  61. /**
  62. * NOTE: This method is not currently recommended for public use.
  63. * The internal tree representation is unstable and is very likely
  64. * to change. Use at your own risk.
  65. */
  66. __parse: generateParseTree,
  67. ParseError: _ParseError2.default
  68. };
  69. },{"./src/ParseError":29,"./src/Settings":32,"./src/buildTree":37,"./src/parseTree":46,"./src/utils":51}],2:[function(require,module,exports){
  70. module.exports = { "default": require("core-js/library/fn/json/stringify"), __esModule: true };
  71. },{"core-js/library/fn/json/stringify":6}],3:[function(require,module,exports){
  72. module.exports = { "default": require("core-js/library/fn/object/define-property"), __esModule: true };
  73. },{"core-js/library/fn/object/define-property":7}],4:[function(require,module,exports){
  74. "use strict";
  75. exports.__esModule = true;
  76. exports.default = function (instance, Constructor) {
  77. if (!(instance instanceof Constructor)) {
  78. throw new TypeError("Cannot call a class as a function");
  79. }
  80. };
  81. },{}],5:[function(require,module,exports){
  82. "use strict";
  83. exports.__esModule = true;
  84. var _defineProperty = require("../core-js/object/define-property");
  85. var _defineProperty2 = _interopRequireDefault(_defineProperty);
  86. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  87. exports.default = function () {
  88. function defineProperties(target, props) {
  89. for (var i = 0; i < props.length; i++) {
  90. var descriptor = props[i];
  91. descriptor.enumerable = descriptor.enumerable || false;
  92. descriptor.configurable = true;
  93. if ("value" in descriptor) descriptor.writable = true;
  94. (0, _defineProperty2.default)(target, descriptor.key, descriptor);
  95. }
  96. }
  97. return function (Constructor, protoProps, staticProps) {
  98. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  99. if (staticProps) defineProperties(Constructor, staticProps);
  100. return Constructor;
  101. };
  102. }();
  103. },{"../core-js/object/define-property":3}],6:[function(require,module,exports){
  104. var core = require('../../modules/_core')
  105. , $JSON = core.JSON || (core.JSON = {stringify: JSON.stringify});
  106. module.exports = function stringify(it){ // eslint-disable-line no-unused-vars
  107. return $JSON.stringify.apply($JSON, arguments);
  108. };
  109. },{"../../modules/_core":10}],7:[function(require,module,exports){
  110. require('../../modules/es6.object.define-property');
  111. var $Object = require('../../modules/_core').Object;
  112. module.exports = function defineProperty(it, key, desc){
  113. return $Object.defineProperty(it, key, desc);
  114. };
  115. },{"../../modules/_core":10,"../../modules/es6.object.define-property":23}],8:[function(require,module,exports){
  116. module.exports = function(it){
  117. if(typeof it != 'function')throw TypeError(it + ' is not a function!');
  118. return it;
  119. };
  120. },{}],9:[function(require,module,exports){
  121. var isObject = require('./_is-object');
  122. module.exports = function(it){
  123. if(!isObject(it))throw TypeError(it + ' is not an object!');
  124. return it;
  125. };
  126. },{"./_is-object":19}],10:[function(require,module,exports){
  127. var core = module.exports = {version: '2.4.0'};
  128. if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
  129. },{}],11:[function(require,module,exports){
  130. // optional / simple context binding
  131. var aFunction = require('./_a-function');
  132. module.exports = function(fn, that, length){
  133. aFunction(fn);
  134. if(that === undefined)return fn;
  135. switch(length){
  136. case 1: return function(a){
  137. return fn.call(that, a);
  138. };
  139. case 2: return function(a, b){
  140. return fn.call(that, a, b);
  141. };
  142. case 3: return function(a, b, c){
  143. return fn.call(that, a, b, c);
  144. };
  145. }
  146. return function(/* ...args */){
  147. return fn.apply(that, arguments);
  148. };
  149. };
  150. },{"./_a-function":8}],12:[function(require,module,exports){
  151. // Thank's IE8 for his funny defineProperty
  152. module.exports = !require('./_fails')(function(){
  153. return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
  154. });
  155. },{"./_fails":15}],13:[function(require,module,exports){
  156. var isObject = require('./_is-object')
  157. , document = require('./_global').document
  158. // in old IE typeof document.createElement is 'object'
  159. , is = isObject(document) && isObject(document.createElement);
  160. module.exports = function(it){
  161. return is ? document.createElement(it) : {};
  162. };
  163. },{"./_global":16,"./_is-object":19}],14:[function(require,module,exports){
  164. var global = require('./_global')
  165. , core = require('./_core')
  166. , ctx = require('./_ctx')
  167. , hide = require('./_hide')
  168. , PROTOTYPE = 'prototype';
  169. var $export = function(type, name, source){
  170. var IS_FORCED = type & $export.F
  171. , IS_GLOBAL = type & $export.G
  172. , IS_STATIC = type & $export.S
  173. , IS_PROTO = type & $export.P
  174. , IS_BIND = type & $export.B
  175. , IS_WRAP = type & $export.W
  176. , exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
  177. , expProto = exports[PROTOTYPE]
  178. , target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]
  179. , key, own, out;
  180. if(IS_GLOBAL)source = name;
  181. for(key in source){
  182. // contains in native
  183. own = !IS_FORCED && target && target[key] !== undefined;
  184. if(own && key in exports)continue;
  185. // export native or passed
  186. out = own ? target[key] : source[key];
  187. // prevent global pollution for namespaces
  188. exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
  189. // bind timers to global for call from export context
  190. : IS_BIND && own ? ctx(out, global)
  191. // wrap global constructors for prevent change them in library
  192. : IS_WRAP && target[key] == out ? (function(C){
  193. var F = function(a, b, c){
  194. if(this instanceof C){
  195. switch(arguments.length){
  196. case 0: return new C;
  197. case 1: return new C(a);
  198. case 2: return new C(a, b);
  199. } return new C(a, b, c);
  200. } return C.apply(this, arguments);
  201. };
  202. F[PROTOTYPE] = C[PROTOTYPE];
  203. return F;
  204. // make static versions for prototype methods
  205. })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  206. // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
  207. if(IS_PROTO){
  208. (exports.virtual || (exports.virtual = {}))[key] = out;
  209. // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
  210. if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out);
  211. }
  212. }
  213. };
  214. // type bitmap
  215. $export.F = 1; // forced
  216. $export.G = 2; // global
  217. $export.S = 4; // static
  218. $export.P = 8; // proto
  219. $export.B = 16; // bind
  220. $export.W = 32; // wrap
  221. $export.U = 64; // safe
  222. $export.R = 128; // real proto method for `library`
  223. module.exports = $export;
  224. },{"./_core":10,"./_ctx":11,"./_global":16,"./_hide":17}],15:[function(require,module,exports){
  225. module.exports = function(exec){
  226. try {
  227. return !!exec();
  228. } catch(e){
  229. return true;
  230. }
  231. };
  232. },{}],16:[function(require,module,exports){
  233. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  234. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  235. ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
  236. if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
  237. },{}],17:[function(require,module,exports){
  238. var dP = require('./_object-dp')
  239. , createDesc = require('./_property-desc');
  240. module.exports = require('./_descriptors') ? function(object, key, value){
  241. return dP.f(object, key, createDesc(1, value));
  242. } : function(object, key, value){
  243. object[key] = value;
  244. return object;
  245. };
  246. },{"./_descriptors":12,"./_object-dp":20,"./_property-desc":21}],18:[function(require,module,exports){
  247. module.exports = !require('./_descriptors') && !require('./_fails')(function(){
  248. return Object.defineProperty(require('./_dom-create')('div'), 'a', {get: function(){ return 7; }}).a != 7;
  249. });
  250. },{"./_descriptors":12,"./_dom-create":13,"./_fails":15}],19:[function(require,module,exports){
  251. module.exports = function(it){
  252. return typeof it === 'object' ? it !== null : typeof it === 'function';
  253. };
  254. },{}],20:[function(require,module,exports){
  255. var anObject = require('./_an-object')
  256. , IE8_DOM_DEFINE = require('./_ie8-dom-define')
  257. , toPrimitive = require('./_to-primitive')
  258. , dP = Object.defineProperty;
  259. exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes){
  260. anObject(O);
  261. P = toPrimitive(P, true);
  262. anObject(Attributes);
  263. if(IE8_DOM_DEFINE)try {
  264. return dP(O, P, Attributes);
  265. } catch(e){ /* empty */ }
  266. if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
  267. if('value' in Attributes)O[P] = Attributes.value;
  268. return O;
  269. };
  270. },{"./_an-object":9,"./_descriptors":12,"./_ie8-dom-define":18,"./_to-primitive":22}],21:[function(require,module,exports){
  271. module.exports = function(bitmap, value){
  272. return {
  273. enumerable : !(bitmap & 1),
  274. configurable: !(bitmap & 2),
  275. writable : !(bitmap & 4),
  276. value : value
  277. };
  278. };
  279. },{}],22:[function(require,module,exports){
  280. // 7.1.1 ToPrimitive(input [, PreferredType])
  281. var isObject = require('./_is-object');
  282. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  283. // and the second argument - flag - preferred type is a string
  284. module.exports = function(it, S){
  285. if(!isObject(it))return it;
  286. var fn, val;
  287. if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
  288. if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
  289. if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
  290. throw TypeError("Can't convert object to primitive value");
  291. };
  292. },{"./_is-object":19}],23:[function(require,module,exports){
  293. var $export = require('./_export');
  294. // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
  295. $export($export.S + $export.F * !require('./_descriptors'), 'Object', {defineProperty: require('./_object-dp').f});
  296. },{"./_descriptors":12,"./_export":14,"./_object-dp":20}],24:[function(require,module,exports){
  297. /** @flow */
  298. "use strict";
  299. function getRelocatable(re) {
  300. // In the future, this could use a WeakMap instead of an expando.
  301. if (!re.__matchAtRelocatable) {
  302. // Disjunctions are the lowest-precedence operator, so we can make any
  303. // pattern match the empty string by appending `|()` to it:
  304. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-patterns
  305. var source = re.source + "|()";
  306. // We always make the new regex global.
  307. var flags = "g" + (re.ignoreCase ? "i" : "") + (re.multiline ? "m" : "") + (re.unicode ? "u" : "")
  308. // sticky (/.../y) doesn't make sense in conjunction with our relocation
  309. // logic, so we ignore it here.
  310. ;
  311. re.__matchAtRelocatable = new RegExp(source, flags);
  312. }
  313. return re.__matchAtRelocatable;
  314. }
  315. function matchAt(re, str, pos) {
  316. if (re.global || re.sticky) {
  317. throw new Error("matchAt(...): Only non-global regexes are supported");
  318. }
  319. var reloc = getRelocatable(re);
  320. reloc.lastIndex = pos;
  321. var match = reloc.exec(str);
  322. // Last capturing group is our sentinel that indicates whether the regex
  323. // matched at the given location.
  324. if (match[match.length - 1] == null) {
  325. // Original regex matched.
  326. match.length = match.length - 1;
  327. return match;
  328. } else {
  329. return null;
  330. }
  331. }
  332. module.exports = matchAt;
  333. },{}],25:[function(require,module,exports){
  334. 'use strict';
  335. /* eslint-disable no-unused-vars */
  336. var hasOwnProperty = Object.prototype.hasOwnProperty;
  337. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  338. function toObject(val) {
  339. if (val === null || val === undefined) {
  340. throw new TypeError('Object.assign cannot be called with null or undefined');
  341. }
  342. return Object(val);
  343. }
  344. function shouldUseNative() {
  345. try {
  346. if (!Object.assign) {
  347. return false;
  348. }
  349. // Detect buggy property enumeration order in older V8 versions.
  350. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  351. var test1 = new String('abc'); // eslint-disable-line
  352. test1[5] = 'de';
  353. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  354. return false;
  355. }
  356. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  357. var test2 = {};
  358. for (var i = 0; i < 10; i++) {
  359. test2['_' + String.fromCharCode(i)] = i;
  360. }
  361. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  362. return test2[n];
  363. });
  364. if (order2.join('') !== '0123456789') {
  365. return false;
  366. }
  367. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  368. var test3 = {};
  369. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  370. test3[letter] = letter;
  371. });
  372. if (Object.keys(Object.assign({}, test3)).join('') !==
  373. 'abcdefghijklmnopqrst') {
  374. return false;
  375. }
  376. return true;
  377. } catch (e) {
  378. // We don't expect any of the above to throw, but better to be safe.
  379. return false;
  380. }
  381. }
  382. module.exports = shouldUseNative() ? Object.assign : function (target, source) {
  383. var from;
  384. var to = toObject(target);
  385. var symbols;
  386. for (var s = 1; s < arguments.length; s++) {
  387. from = Object(arguments[s]);
  388. for (var key in from) {
  389. if (hasOwnProperty.call(from, key)) {
  390. to[key] = from[key];
  391. }
  392. }
  393. if (Object.getOwnPropertySymbols) {
  394. symbols = Object.getOwnPropertySymbols(from);
  395. for (var i = 0; i < symbols.length; i++) {
  396. if (propIsEnumerable.call(from, symbols[i])) {
  397. to[symbols[i]] = from[symbols[i]];
  398. }
  399. }
  400. }
  401. }
  402. return to;
  403. };
  404. },{}],26:[function(require,module,exports){
  405. "use strict";
  406. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  407. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  408. var _createClass2 = require("babel-runtime/helpers/createClass");
  409. var _createClass3 = _interopRequireDefault(_createClass2);
  410. var _matchAt = require("match-at");
  411. var _matchAt2 = _interopRequireDefault(_matchAt);
  412. var _ParseError = require("./ParseError");
  413. var _ParseError2 = _interopRequireDefault(_ParseError);
  414. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  415. /**
  416. * The resulting token returned from `lex`.
  417. *
  418. * It consists of the token text plus some position information.
  419. * The position information is essentially a range in an input string,
  420. * but instead of referencing the bare input string, we refer to the lexer.
  421. * That way it is possible to attach extra metadata to the input string,
  422. * like for example a file name or similar.
  423. *
  424. * The position information (all three parameters) is optional,
  425. * so it is OK to construct synthetic tokens if appropriate.
  426. * Not providing available position information may lead to
  427. * degraded error reporting, though.
  428. *
  429. * @param {string} text the text of this token
  430. * @param {number=} start the start offset, zero-based inclusive
  431. * @param {number=} end the end offset, zero-based exclusive
  432. * @param {Lexer=} lexer the lexer which in turn holds the input string
  433. */
  434. /**
  435. * The Lexer class handles tokenizing the input in various ways. Since our
  436. * parser expects us to be able to backtrack, the lexer allows lexing from any
  437. * given starting point.
  438. *
  439. * Its main exposed function is the `lex` function, which takes a position to
  440. * lex from and a type of token to lex. It defers to the appropriate `_innerLex`
  441. * function.
  442. *
  443. * The various `_innerLex` functions perform the actual lexing of different
  444. * kinds.
  445. */
  446. var Token = function () {
  447. function Token(text, start, end, lexer) {
  448. (0, _classCallCheck3.default)(this, Token);
  449. this.text = text;
  450. this.start = start;
  451. this.end = end;
  452. this.lexer = lexer;
  453. }
  454. /**
  455. * Given a pair of tokens (this and endToken), compute a “Token” encompassing
  456. * the whole input range enclosed by these two.
  457. *
  458. * @param {Token} endToken last token of the range, inclusive
  459. * @param {string} text the text of the newly constructed token
  460. */
  461. (0, _createClass3.default)(Token, [{
  462. key: "range",
  463. value: function range(endToken, text) {
  464. if (endToken.lexer !== this.lexer) {
  465. return new Token(text); // sorry, no position information available
  466. }
  467. return new Token(text, this.start, endToken.end, this.lexer);
  468. }
  469. }]);
  470. return Token;
  471. }();
  472. /* The following tokenRegex
  473. * - matches typical whitespace (but not NBSP etc.) using its first group
  474. * - does not match any control character \x00-\x1f except whitespace
  475. * - does not match a bare backslash
  476. * - matches any ASCII character except those just mentioned
  477. * - does not match the BMP private use area \uE000-\uF8FF
  478. * - does not match bare surrogate code units
  479. * - matches any BMP character except for those just described
  480. * - matches any valid Unicode surrogate pair
  481. * - matches a backslash followed by one or more letters
  482. * - matches a backslash followed by any BMP character, including newline
  483. * Just because the Lexer matches something doesn't mean it's valid input:
  484. * If there is no matching function or symbol definition, the Parser will
  485. * still reject the input.
  486. */
  487. var tokenRegex = new RegExp("([ \r\n\t]+)|" + // whitespace
  488. "([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + // single codepoint
  489. "|[\uD800-\uDBFF][\uDC00-\uDFFF]" + // surrogate pair
  490. "|\\\\(?:[a-zA-Z]+|[^\uD800-\uDFFF])" + // function name
  491. ")");
  492. /*
  493. * Main Lexer class
  494. */
  495. var Lexer = function () {
  496. function Lexer(input) {
  497. (0, _classCallCheck3.default)(this, Lexer);
  498. this.input = input;
  499. this.pos = 0;
  500. }
  501. /**
  502. * This function lexes a single token.
  503. */
  504. (0, _createClass3.default)(Lexer, [{
  505. key: "lex",
  506. value: function lex() {
  507. var input = this.input;
  508. var pos = this.pos;
  509. if (pos === input.length) {
  510. return new Token("EOF", pos, pos, this);
  511. }
  512. var match = (0, _matchAt2.default)(tokenRegex, input, pos);
  513. if (match === null) {
  514. throw new _ParseError2.default("Unexpected character: '" + input[pos] + "'", new Token(input[pos], pos, pos + 1, this));
  515. }
  516. var text = match[2] || " ";
  517. var start = this.pos;
  518. this.pos += match[0].length;
  519. var end = this.pos;
  520. return new Token(text, start, end, this);
  521. }
  522. }]);
  523. return Lexer;
  524. }();
  525. module.exports = Lexer;
  526. },{"./ParseError":29,"babel-runtime/helpers/classCallCheck":4,"babel-runtime/helpers/createClass":5,"match-at":24}],27:[function(require,module,exports){
  527. "use strict";
  528. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  529. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  530. var _createClass2 = require("babel-runtime/helpers/createClass");
  531. var _createClass3 = _interopRequireDefault(_createClass2);
  532. var _Lexer = require("./Lexer");
  533. var _Lexer2 = _interopRequireDefault(_Lexer);
  534. var _macros = require("./macros");
  535. var _macros2 = _interopRequireDefault(_macros);
  536. var _ParseError = require("./ParseError");
  537. var _ParseError2 = _interopRequireDefault(_ParseError);
  538. var _objectAssign = require("object-assign");
  539. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  540. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  541. /**
  542. * This file contains the “gullet” where macros are expanded
  543. * until only non-macro tokens remain.
  544. */
  545. var MacroExpander = function () {
  546. function MacroExpander(input, macros) {
  547. (0, _classCallCheck3.default)(this, MacroExpander);
  548. this.lexer = new _Lexer2.default(input);
  549. this.macros = (0, _objectAssign2.default)({}, _macros2.default, macros);
  550. this.stack = []; // contains tokens in REVERSE order
  551. this.discardedWhiteSpace = [];
  552. }
  553. /**
  554. * Recursively expand first token, then return first non-expandable token.
  555. *
  556. * At the moment, macro expansion doesn't handle delimited macros,
  557. * i.e. things like those defined by \def\foo#1\end{…}.
  558. * See the TeX book page 202ff. for details on how those should behave.
  559. */
  560. (0, _createClass3.default)(MacroExpander, [{
  561. key: "nextToken",
  562. value: function nextToken() {
  563. for (;;) {
  564. if (this.stack.length === 0) {
  565. this.stack.push(this.lexer.lex());
  566. }
  567. var topToken = this.stack.pop();
  568. var name = topToken.text;
  569. if (!(name.charAt(0) === "\\" && this.macros.hasOwnProperty(name))) {
  570. return topToken;
  571. }
  572. var tok = void 0;
  573. var expansion = this.macros[name];
  574. if (typeof expansion === "string") {
  575. var numArgs = 0;
  576. if (expansion.indexOf("#") !== -1) {
  577. var stripped = expansion.replace(/##/g, "");
  578. while (stripped.indexOf("#" + (numArgs + 1)) !== -1) {
  579. ++numArgs;
  580. }
  581. }
  582. var bodyLexer = new _Lexer2.default(expansion);
  583. expansion = [];
  584. tok = bodyLexer.lex();
  585. while (tok.text !== "EOF") {
  586. expansion.push(tok);
  587. tok = bodyLexer.lex();
  588. }
  589. expansion.reverse(); // to fit in with stack using push and pop
  590. expansion.numArgs = numArgs;
  591. this.macros[name] = expansion;
  592. }
  593. if (expansion.numArgs) {
  594. var args = [];
  595. var i = void 0;
  596. // obtain arguments, either single token or balanced {…} group
  597. for (i = 0; i < expansion.numArgs; ++i) {
  598. var startOfArg = this.get(true);
  599. if (startOfArg.text === "{") {
  600. var arg = [];
  601. var depth = 1;
  602. while (depth !== 0) {
  603. tok = this.get(false);
  604. arg.push(tok);
  605. if (tok.text === "{") {
  606. ++depth;
  607. } else if (tok.text === "}") {
  608. --depth;
  609. } else if (tok.text === "EOF") {
  610. throw new _ParseError2.default("End of input in macro argument", startOfArg);
  611. }
  612. }
  613. arg.pop(); // remove last }
  614. arg.reverse(); // like above, to fit in with stack order
  615. args[i] = arg;
  616. } else if (startOfArg.text === "EOF") {
  617. throw new _ParseError2.default("End of input expecting macro argument", topToken);
  618. } else {
  619. args[i] = [startOfArg];
  620. }
  621. }
  622. // paste arguments in place of the placeholders
  623. expansion = expansion.slice(); // make a shallow copy
  624. for (i = expansion.length - 1; i >= 0; --i) {
  625. tok = expansion[i];
  626. if (tok.text === "#") {
  627. if (i === 0) {
  628. throw new _ParseError2.default("Incomplete placeholder at end of macro body", tok);
  629. }
  630. tok = expansion[--i]; // next token on stack
  631. if (tok.text === "#") {
  632. // ## → #
  633. expansion.splice(i + 1, 1); // drop first #
  634. } else if (/^[1-9]$/.test(tok.text)) {
  635. // expansion.splice(i, 2, arg[0], arg[1], …)
  636. // to replace placeholder with the indicated argument.
  637. // TODO: use spread once we move to ES2015
  638. expansion.splice.apply(expansion, [i, 2].concat(args[tok.text - 1]));
  639. } else {
  640. throw new _ParseError2.default("Not a valid argument number", tok);
  641. }
  642. }
  643. }
  644. }
  645. this.stack = this.stack.concat(expansion);
  646. }
  647. }
  648. }, {
  649. key: "get",
  650. value: function get(ignoreSpace) {
  651. this.discardedWhiteSpace = [];
  652. var token = this.nextToken();
  653. if (ignoreSpace) {
  654. while (token.text === " ") {
  655. this.discardedWhiteSpace.push(token);
  656. token = this.nextToken();
  657. }
  658. }
  659. return token;
  660. }
  661. /**
  662. * Undo the effect of the preceding call to the get method.
  663. * A call to this method MUST be immediately preceded and immediately followed
  664. * by a call to get. Only used during mode switching, i.e. after one token
  665. * was got in the old mode but should get got again in a new mode
  666. * with possibly different whitespace handling.
  667. */
  668. }, {
  669. key: "unget",
  670. value: function unget(token) {
  671. this.stack.push(token);
  672. while (this.discardedWhiteSpace.length !== 0) {
  673. this.stack.push(this.discardedWhiteSpace.pop());
  674. }
  675. }
  676. }]);
  677. return MacroExpander;
  678. }();
  679. module.exports = MacroExpander;
  680. },{"./Lexer":26,"./ParseError":29,"./macros":44,"babel-runtime/helpers/classCallCheck":4,"babel-runtime/helpers/createClass":5,"object-assign":25}],28:[function(require,module,exports){
  681. "use strict";
  682. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  683. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  684. var _createClass2 = require("babel-runtime/helpers/createClass");
  685. var _createClass3 = _interopRequireDefault(_createClass2);
  686. var _fontMetrics2 = require("./fontMetrics");
  687. var _fontMetrics3 = _interopRequireDefault(_fontMetrics2);
  688. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  689. var BASESIZE = 6; /**
  690. * This file contains information about the options that the Parser carries
  691. * around with it while parsing. Data is held in an `Options` object, and when
  692. * recursing, a new `Options` object can be created with the `.with*` and
  693. * `.reset` functions.
  694. */
  695. var sizeStyleMap = [
  696. // Each element contains [textsize, scriptsize, scriptscriptsize].
  697. // The size mappings are taken from TeX with \normalsize=10pt.
  698. [1, 1, 1], // size1: [5, 5, 5] \tiny
  699. [2, 1, 1], // size2: [6, 5, 5]
  700. [3, 1, 1], // size3: [7, 5, 5] \scriptsize
  701. [4, 2, 1], // size4: [8, 6, 5] \footnotesize
  702. [5, 2, 1], // size5: [9, 6, 5] \small
  703. [6, 3, 1], // size6: [10, 7, 5] \normalsize
  704. [7, 4, 2], // size7: [12, 8, 6] \large
  705. [8, 6, 3], // size8: [14.4, 10, 7] \Large
  706. [9, 7, 6], // size9: [17.28, 12, 10] \LARGE
  707. [10, 8, 7], // size10: [20.74, 14.4, 12] \huge
  708. [11, 10, 9]];
  709. var sizeMultipliers = [
  710. // fontMetrics.js:getFontMetrics also uses size indexes, so if
  711. // you change size indexes, change that function.
  712. 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
  713. var sizeAtStyle = function sizeAtStyle(size, style) {
  714. return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
  715. };
  716. /**
  717. * This is the main options class. It contains the current style, size, color,
  718. * and font.
  719. *
  720. * Options objects should not be modified. To create a new Options with
  721. * different properties, call a `.having*` method.
  722. */
  723. var Options = function () {
  724. function Options(data) {
  725. (0, _classCallCheck3.default)(this, Options);
  726. this.style = data.style;
  727. this.color = data.color;
  728. this.size = data.size || BASESIZE;
  729. this.textSize = data.textSize || this.size;
  730. this.phantom = data.phantom;
  731. this.font = data.font;
  732. this.sizeMultiplier = sizeMultipliers[this.size - 1];
  733. this._fontMetrics = null;
  734. }
  735. /**
  736. * Returns a new options object with the same properties as "this". Properties
  737. * from "extension" will be copied to the new options object.
  738. */
  739. (0, _createClass3.default)(Options, [{
  740. key: "extend",
  741. value: function extend(extension) {
  742. var data = {
  743. style: this.style,
  744. size: this.size,
  745. textSize: this.textSize,
  746. color: this.color,
  747. phantom: this.phantom,
  748. font: this.font
  749. };
  750. for (var key in extension) {
  751. if (extension.hasOwnProperty(key)) {
  752. data[key] = extension[key];
  753. }
  754. }
  755. return new Options(data);
  756. }
  757. /**
  758. * Return an options object with the given style. If `this.style === style`,
  759. * returns `this`.
  760. */
  761. }, {
  762. key: "havingStyle",
  763. value: function havingStyle(style) {
  764. if (this.style === style) {
  765. return this;
  766. } else {
  767. return this.extend({
  768. style: style,
  769. size: sizeAtStyle(this.textSize, style)
  770. });
  771. }
  772. }
  773. /**
  774. * Return an options object with a cramped version of the current style. If
  775. * the current style is cramped, returns `this`.
  776. */
  777. }, {
  778. key: "havingCrampedStyle",
  779. value: function havingCrampedStyle() {
  780. return this.havingStyle(this.style.cramp());
  781. }
  782. /**
  783. * Return an options object with the given size and in at least `\textstyle`.
  784. * Returns `this` if appropriate.
  785. */
  786. }, {
  787. key: "havingSize",
  788. value: function havingSize(size) {
  789. if (this.size === size && this.textSize === size) {
  790. return this;
  791. } else {
  792. return this.extend({
  793. style: this.style.text(),
  794. size: size,
  795. textSize: size
  796. });
  797. }
  798. }
  799. /**
  800. * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
  801. * changes to at least `\textstyle`.
  802. */
  803. }, {
  804. key: "havingBaseStyle",
  805. value: function havingBaseStyle(style) {
  806. style = style || this.style.text();
  807. var wantSize = sizeAtStyle(BASESIZE, style);
  808. if (this.size === wantSize && this.textSize === BASESIZE && this.style === style) {
  809. return this;
  810. } else {
  811. return this.extend({
  812. style: style,
  813. size: wantSize,
  814. baseSize: BASESIZE
  815. });
  816. }
  817. }
  818. /**
  819. * Create a new options object with the given color.
  820. */
  821. }, {
  822. key: "withColor",
  823. value: function withColor(color) {
  824. return this.extend({
  825. color: color
  826. });
  827. }
  828. /**
  829. * Create a new options object with "phantom" set to true.
  830. */
  831. }, {
  832. key: "withPhantom",
  833. value: function withPhantom() {
  834. return this.extend({
  835. phantom: true
  836. });
  837. }
  838. /**
  839. * Create a new options objects with the give font.
  840. */
  841. }, {
  842. key: "withFont",
  843. value: function withFont(font) {
  844. return this.extend({
  845. font: font || this.font
  846. });
  847. }
  848. /**
  849. * Return the CSS sizing classes required to switch from enclosing options
  850. * `oldOptions` to `this`. Returns an array of classes.
  851. */
  852. }, {
  853. key: "sizingClasses",
  854. value: function sizingClasses(oldOptions) {
  855. if (oldOptions.size !== this.size) {
  856. return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
  857. } else {
  858. return [];
  859. }
  860. }
  861. /**
  862. * Return the CSS sizing classes required to switch to the base size. Like
  863. * `this.havingSize(BASESIZE).sizingClasses(this)`.
  864. */
  865. }, {
  866. key: "baseSizingClasses",
  867. value: function baseSizingClasses() {
  868. if (this.size !== BASESIZE) {
  869. return ["sizing", "reset-size" + this.size, "size" + BASESIZE];
  870. } else {
  871. return [];
  872. }
  873. }
  874. /**
  875. * Return the font metrics for this size.
  876. */
  877. }, {
  878. key: "fontMetrics",
  879. value: function fontMetrics() {
  880. if (!this._fontMetrics) {
  881. this._fontMetrics = _fontMetrics3.default.getFontMetrics(this.size);
  882. }
  883. return this._fontMetrics;
  884. }
  885. /**
  886. * A map of color names to CSS colors.
  887. * TODO(emily): Remove this when we have real macros
  888. */
  889. }, {
  890. key: "getColor",
  891. /**
  892. * Gets the CSS color of the current options object, accounting for the
  893. * `colorMap`.
  894. */
  895. value: function getColor() {
  896. if (this.phantom) {
  897. return "transparent";
  898. } else {
  899. return Options.colorMap[this.color] || this.color;
  900. }
  901. }
  902. }]);
  903. return Options;
  904. }();
  905. /**
  906. * The base size index.
  907. */
  908. Options.colorMap = {
  909. "katex-blue": "#6495ed",
  910. "katex-orange": "#ffa500",
  911. "katex-pink": "#ff00af",
  912. "katex-red": "#df0030",
  913. "katex-green": "#28ae7b",
  914. "katex-gray": "gray",
  915. "katex-purple": "#9d38bd",
  916. "katex-blueA": "#ccfaff",
  917. "katex-blueB": "#80f6ff",
  918. "katex-blueC": "#63d9ea",
  919. "katex-blueD": "#11accd",
  920. "katex-blueE": "#0c7f99",
  921. "katex-tealA": "#94fff5",
  922. "katex-tealB": "#26edd5",
  923. "katex-tealC": "#01d1c1",
  924. "katex-tealD": "#01a995",
  925. "katex-tealE": "#208170",
  926. "katex-greenA": "#b6ffb0",
  927. "katex-greenB": "#8af281",
  928. "katex-greenC": "#74cf70",
  929. "katex-greenD": "#1fab54",
  930. "katex-greenE": "#0d923f",
  931. "katex-goldA": "#ffd0a9",
  932. "katex-goldB": "#ffbb71",
  933. "katex-goldC": "#ff9c39",
  934. "katex-goldD": "#e07d10",
  935. "katex-goldE": "#a75a05",
  936. "katex-redA": "#fca9a9",
  937. "katex-redB": "#ff8482",
  938. "katex-redC": "#f9685d",
  939. "katex-redD": "#e84d39",
  940. "katex-redE": "#bc2612",
  941. "katex-maroonA": "#ffbde0",
  942. "katex-maroonB": "#ff92c6",
  943. "katex-maroonC": "#ed5fa6",
  944. "katex-maroonD": "#ca337c",
  945. "katex-maroonE": "#9e034e",
  946. "katex-purpleA": "#ddd7ff",
  947. "katex-purpleB": "#c6b9fc",
  948. "katex-purpleC": "#aa87ff",
  949. "katex-purpleD": "#7854ab",
  950. "katex-purpleE": "#543b78",
  951. "katex-mintA": "#f5f9e8",
  952. "katex-mintB": "#edf2df",
  953. "katex-mintC": "#e0e5cc",
  954. "katex-grayA": "#f6f7f7",
  955. "katex-grayB": "#f0f1f2",
  956. "katex-grayC": "#e3e5e6",
  957. "katex-grayD": "#d6d8da",
  958. "katex-grayE": "#babec2",
  959. "katex-grayF": "#888d93",
  960. "katex-grayG": "#626569",
  961. "katex-grayH": "#3b3e40",
  962. "katex-grayI": "#21242c",
  963. "katex-kaBlue": "#314453",
  964. "katex-kaGreen": "#71B307"
  965. };
  966. Options.BASESIZE = BASESIZE;
  967. module.exports = Options;
  968. },{"./fontMetrics":41,"babel-runtime/helpers/classCallCheck":4,"babel-runtime/helpers/createClass":5}],29:[function(require,module,exports){
  969. "use strict";
  970. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  971. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  972. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  973. /**
  974. * This is the ParseError class, which is the main error thrown by KaTeX
  975. * functions when something has gone wrong. This is used to distinguish internal
  976. * errors from errors in the expression that the user provided.
  977. *
  978. * If possible, a caller should provide a Token or ParseNode with information
  979. * about where in the source string the problem occurred.
  980. *
  981. * @param {string} message The error message
  982. * @param {(Token|ParseNode)=} token An object providing position information
  983. */
  984. var ParseError = function ParseError(message, token) {
  985. (0, _classCallCheck3.default)(this, ParseError);
  986. var error = "KaTeX parse error: " + message;
  987. var start = void 0;
  988. var end = void 0;
  989. if (token && token.lexer && token.start <= token.end) {
  990. // If we have the input and a position, make the error a bit fancier
  991. // Get the input
  992. var input = token.lexer.input;
  993. // Prepend some information
  994. start = token.start;
  995. end = token.end;
  996. if (start === input.length) {
  997. error += " at end of input: ";
  998. } else {
  999. error += " at position " + (start + 1) + ": ";
  1000. }
  1001. // Underline token in question using combining underscores
  1002. var underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332");
  1003. // Extract some context from the input and add it to the error
  1004. var left = void 0;
  1005. if (start > 15) {
  1006. left = "…" + input.slice(start - 15, start);
  1007. } else {
  1008. left = input.slice(0, start);
  1009. }
  1010. var right = void 0;
  1011. if (end + 15 < input.length) {
  1012. right = input.slice(end, end + 15) + "…";
  1013. } else {
  1014. right = input.slice(end);
  1015. }
  1016. error += left + underlined + right;
  1017. }
  1018. // Some hackery to make ParseError a prototype of Error
  1019. // See http://stackoverflow.com/a/8460753
  1020. var self = new Error(error);
  1021. self.name = "ParseError";
  1022. self.__proto__ = ParseError.prototype;
  1023. self.position = start;
  1024. return self;
  1025. };
  1026. // More hackery
  1027. ParseError.prototype.__proto__ = Error.prototype;
  1028. module.exports = ParseError;
  1029. },{"babel-runtime/helpers/classCallCheck":4}],30:[function(require,module,exports){
  1030. "use strict";
  1031. Object.defineProperty(exports, "__esModule", {
  1032. value: true
  1033. });
  1034. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  1035. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  1036. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1037. /**
  1038. * The resulting parse tree nodes of the parse tree.
  1039. *
  1040. * It is possible to provide position information, so that a ParseNode can
  1041. * fulfil a role similar to a Token in error reporting.
  1042. * For details on the corresponding properties see Token constructor.
  1043. * Providing such information can lead to better error reporting.
  1044. *
  1045. * @param {string} type type of node, like e.g. "ordgroup"
  1046. * @param {?object} value type-specific representation of the node
  1047. * @param {string} mode parse mode in action for this node,
  1048. * "math" or "text"
  1049. * @param {Token=} firstToken first token of the input for this node,
  1050. * will omit position information if unset
  1051. * @param {Token=} lastToken last token of the input for this node,
  1052. * will default to firstToken if unset
  1053. */
  1054. var ParseNode = function ParseNode(type, value, mode, firstToken, lastToken) {
  1055. (0, _classCallCheck3.default)(this, ParseNode);
  1056. this.type = type;
  1057. this.value = value;
  1058. this.mode = mode;
  1059. if (firstToken && (!lastToken || lastToken.lexer === firstToken.lexer)) {
  1060. this.lexer = firstToken.lexer;
  1061. this.start = firstToken.start;
  1062. this.end = (lastToken || firstToken).end;
  1063. }
  1064. };
  1065. exports.default = ParseNode;
  1066. },{"babel-runtime/helpers/classCallCheck":4}],31:[function(require,module,exports){
  1067. "use strict";
  1068. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  1069. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  1070. var _createClass2 = require("babel-runtime/helpers/createClass");
  1071. var _createClass3 = _interopRequireDefault(_createClass2);
  1072. var _functions = require("./functions");
  1073. var _functions2 = _interopRequireDefault(_functions);
  1074. var _environments = require("./environments");
  1075. var _environments2 = _interopRequireDefault(_environments);
  1076. var _MacroExpander = require("./MacroExpander");
  1077. var _MacroExpander2 = _interopRequireDefault(_MacroExpander);
  1078. var _symbols = require("./symbols");
  1079. var _symbols2 = _interopRequireDefault(_symbols);
  1080. var _utils = require("./utils");
  1081. var _utils2 = _interopRequireDefault(_utils);
  1082. var _units = require("./units");
  1083. var _units2 = _interopRequireDefault(_units);
  1084. var _unicodeRegexes = require("./unicodeRegexes");
  1085. var _ParseNode = require("./ParseNode");
  1086. var _ParseNode2 = _interopRequireDefault(_ParseNode);
  1087. var _ParseError = require("./ParseError");
  1088. var _ParseError2 = _interopRequireDefault(_ParseError);
  1089. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1090. /**
  1091. * This file contains the parser used to parse out a TeX expression from the
  1092. * input. Since TeX isn't context-free, standard parsers don't work particularly
  1093. * well.
  1094. *
  1095. * The strategy of this parser is as such:
  1096. *
  1097. * The main functions (the `.parse...` ones) take a position in the current
  1098. * parse string to parse tokens from. The lexer (found in Lexer.js, stored at
  1099. * this.lexer) also supports pulling out tokens at arbitrary places. When
  1100. * individual tokens are needed at a position, the lexer is called to pull out a
  1101. * token, which is then used.
  1102. *
  1103. * The parser has a property called "mode" indicating the mode that
  1104. * the parser is currently in. Currently it has to be one of "math" or
  1105. * "text", which denotes whether the current environment is a math-y
  1106. * one or a text-y one (e.g. inside \text). Currently, this serves to
  1107. * limit the functions which can be used in text mode.
  1108. *
  1109. * The main functions then return an object which contains the useful data that
  1110. * was parsed at its given point, and a new position at the end of the parsed
  1111. * data. The main functions can call each other and continue the parsing by
  1112. * using the returned position as a new starting point.
  1113. *
  1114. * There are also extra `.handle...` functions, which pull out some reused
  1115. * functionality into self-contained functions.
  1116. *
  1117. * The earlier functions return ParseNodes.
  1118. * The later functions (which are called deeper in the parse) sometimes return
  1119. * ParseFuncOrArgument, which contain a ParseNode as well as some data about
  1120. * whether the parsed object is a function which is missing some arguments, or a
  1121. * standalone object which can be used as an argument to another function.
  1122. */
  1123. /**
  1124. * An initial function (without its arguments), or an argument to a function.
  1125. * The `result` argument should be a ParseNode.
  1126. */
  1127. function ParseFuncOrArgument(result, isFunction, token) {
  1128. this.result = result;
  1129. // Is this a function (i.e. is it something defined in functions.js)?
  1130. this.isFunction = isFunction;
  1131. this.token = token;
  1132. } /* eslint no-constant-condition:0 */
  1133. var Parser = function () {
  1134. function Parser(input, settings) {
  1135. (0, _classCallCheck3.default)(this, Parser);
  1136. // Create a new macro expander (gullet) and (indirectly via that) also a
  1137. // new lexer (mouth) for this parser (stomach, in the language of TeX)
  1138. this.gullet = new _MacroExpander2.default(input, settings.macros);
  1139. // Use old \color behavior (same as LaTeX's \textcolor) if requested.
  1140. // We do this after the macros object has been copied by MacroExpander.
  1141. if (settings.colorIsTextColor) {
  1142. this.gullet.macros["\\color"] = "\\textcolor";
  1143. }
  1144. // Store the settings for use in parsing
  1145. this.settings = settings;
  1146. // Count leftright depth (for \middle errors)
  1147. this.leftrightDepth = 0;
  1148. }
  1149. /**
  1150. * Checks a result to make sure it has the right type, and throws an
  1151. * appropriate error otherwise.
  1152. *
  1153. * @param {boolean=} consume whether to consume the expected token,
  1154. * defaults to true
  1155. */
  1156. (0, _createClass3.default)(Parser, [{
  1157. key: "expect",
  1158. value: function expect(text, consume) {
  1159. if (this.nextToken.text !== text) {
  1160. throw new _ParseError2.default("Expected '" + text + "', got '" + this.nextToken.text + "'", this.nextToken);
  1161. }
  1162. if (consume !== false) {
  1163. this.consume();
  1164. }
  1165. }
  1166. /**
  1167. * Considers the current look ahead token as consumed,
  1168. * and fetches the one after that as the new look ahead.
  1169. */
  1170. }, {
  1171. key: "consume",
  1172. value: function consume() {
  1173. this.nextToken = this.gullet.get(this.mode === "math");
  1174. }
  1175. }, {
  1176. key: "switchMode",
  1177. value: function switchMode(newMode) {
  1178. this.gullet.unget(this.nextToken);
  1179. this.mode = newMode;
  1180. this.consume();
  1181. }
  1182. /**
  1183. * Main parsing function, which parses an entire input.
  1184. *
  1185. * @return {?Array.<ParseNode>}
  1186. */
  1187. }, {
  1188. key: "parse",
  1189. value: function parse() {
  1190. // Try to parse the input
  1191. this.mode = "math";
  1192. this.consume();
  1193. var parse = this.parseInput();
  1194. return parse;
  1195. }
  1196. /**
  1197. * Parses an entire input tree.
  1198. */
  1199. }, {
  1200. key: "parseInput",
  1201. value: function parseInput() {
  1202. // Parse an expression
  1203. var expression = this.parseExpression(false);
  1204. // If we succeeded, make sure there's an EOF at the end
  1205. this.expect("EOF", false);
  1206. return expression;
  1207. }
  1208. }, {
  1209. key: "parseExpression",
  1210. /**
  1211. * Parses an "expression", which is a list of atoms.
  1212. *
  1213. * @param {boolean} breakOnInfix Should the parsing stop when we hit infix
  1214. * nodes? This happens when functions have higher precendence
  1215. * than infix nodes in implicit parses.
  1216. *
  1217. * @param {?string} breakOnTokenText The text of the token that the expression
  1218. * should end with, or `null` if something else should end the
  1219. * expression.
  1220. *
  1221. * @return {ParseNode}
  1222. */
  1223. value: function parseExpression(breakOnInfix, breakOnTokenText) {
  1224. var body = [];
  1225. // Keep adding atoms to the body until we can't parse any more atoms (either
  1226. // we reached the end, a }, or a \right)
  1227. while (true) {
  1228. var lex = this.nextToken;
  1229. if (Parser.endOfExpression.indexOf(lex.text) !== -1) {
  1230. break;
  1231. }
  1232. if (breakOnTokenText && lex.text === breakOnTokenText) {
  1233. break;
  1234. }
  1235. if (breakOnInfix && _functions2.default[lex.text] && _functions2.default[lex.text].infix) {
  1236. break;
  1237. }
  1238. var atom = this.parseAtom();
  1239. if (!atom) {
  1240. if (!this.settings.throwOnError && lex.text[0] === "\\") {
  1241. var errorNode = this.handleUnsupportedCmd();
  1242. body.push(errorNode);
  1243. continue;
  1244. }
  1245. break;
  1246. }
  1247. body.push(atom);
  1248. }
  1249. return this.handleInfixNodes(body);
  1250. }
  1251. /**
  1252. * Rewrites infix operators such as \over with corresponding commands such
  1253. * as \frac.
  1254. *
  1255. * There can only be one infix operator per group. If there's more than one
  1256. * then the expression is ambiguous. This can be resolved by adding {}.
  1257. *
  1258. * @returns {Array}
  1259. */
  1260. }, {
  1261. key: "handleInfixNodes",
  1262. value: function handleInfixNodes(body) {
  1263. var overIndex = -1;
  1264. var funcName = void 0;
  1265. for (var i = 0; i < body.length; i++) {
  1266. var node = body[i];
  1267. if (node.type === "infix") {
  1268. if (overIndex !== -1) {
  1269. throw new _ParseError2.default("only one infix operator per group", node.value.token);
  1270. }
  1271. overIndex = i;
  1272. funcName = node.value.replaceWith;
  1273. }
  1274. }
  1275. if (overIndex !== -1) {
  1276. var numerNode = void 0;
  1277. var denomNode = void 0;
  1278. var numerBody = body.slice(0, overIndex);
  1279. var denomBody = body.slice(overIndex + 1);
  1280. if (numerBody.length === 1 && numerBody[0].type === "ordgroup") {
  1281. numerNode = numerBody[0];
  1282. } else {
  1283. numerNode = new _ParseNode2.default("ordgroup", numerBody, this.mode);
  1284. }
  1285. if (denomBody.length === 1 && denomBody[0].type === "ordgroup") {
  1286. denomNode = denomBody[0];
  1287. } else {
  1288. denomNode = new _ParseNode2.default("ordgroup", denomBody, this.mode);
  1289. }
  1290. var value = this.callFunction(funcName, [numerNode, denomNode], null);
  1291. return [new _ParseNode2.default(value.type, value, this.mode)];
  1292. } else {
  1293. return body;
  1294. }
  1295. }
  1296. // The greediness of a superscript or subscript
  1297. }, {
  1298. key: "handleSupSubscript",
  1299. /**
  1300. * Handle a subscript or superscript with nice errors.
  1301. */
  1302. value: function handleSupSubscript(name) {
  1303. var symbolToken = this.nextToken;
  1304. var symbol = symbolToken.text;
  1305. this.consume();
  1306. var group = this.parseGroup();
  1307. if (!group) {
  1308. if (!this.settings.throwOnError && this.nextToken.text[0] === "\\") {
  1309. return this.handleUnsupportedCmd();
  1310. } else {
  1311. throw new _ParseError2.default("Expected group after '" + symbol + "'", symbolToken);
  1312. }
  1313. } else if (group.isFunction) {
  1314. // ^ and _ have a greediness, so handle interactions with functions'
  1315. // greediness
  1316. var funcGreediness = _functions2.default[group.result].greediness;
  1317. if (funcGreediness > Parser.SUPSUB_GREEDINESS) {
  1318. return this.parseFunction(group);
  1319. } else {
  1320. throw new _ParseError2.default("Got function '" + group.result + "' with no arguments " + "as " + name, symbolToken);
  1321. }
  1322. } else {
  1323. return group.result;
  1324. }
  1325. }
  1326. /**
  1327. * Converts the textual input of an unsupported command into a text node
  1328. * contained within a color node whose color is determined by errorColor
  1329. */
  1330. }, {
  1331. key: "handleUnsupportedCmd",
  1332. value: function handleUnsupportedCmd() {
  1333. var text = this.nextToken.text;
  1334. var textordArray = [];
  1335. for (var i = 0; i < text.length; i++) {
  1336. textordArray.push(new _ParseNode2.default("textord", text[i], "text"));
  1337. }
  1338. var textNode = new _ParseNode2.default("text", {
  1339. body: textordArray,
  1340. type: "text"
  1341. }, this.mode);
  1342. var colorNode = new _ParseNode2.default("color", {
  1343. color: this.settings.errorColor,
  1344. value: [textNode],
  1345. type: "color"
  1346. }, this.mode);
  1347. this.consume();
  1348. return colorNode;
  1349. }
  1350. /**
  1351. * Parses a group with optional super/subscripts.
  1352. *
  1353. * @return {?ParseNode}
  1354. */
  1355. }, {
  1356. key: "parseAtom",
  1357. value: function parseAtom() {
  1358. // The body of an atom is an implicit group, so that things like
  1359. // \left(x\right)^2 work correctly.
  1360. var base = this.parseImplicitGroup();
  1361. // In text mode, we don't have superscripts or subscripts
  1362. if (this.mode === "text") {
  1363. return base;
  1364. }
  1365. // Note that base may be empty (i.e. null) at this point.
  1366. var superscript = void 0;
  1367. var subscript = void 0;
  1368. while (true) {
  1369. // Lex the first token
  1370. var lex = this.nextToken;
  1371. if (lex.text === "\\limits" || lex.text === "\\nolimits") {
  1372. // We got a limit control
  1373. if (!base || base.type !== "op") {
  1374. throw new _ParseError2.default("Limit controls must follow a math operator", lex);
  1375. } else {
  1376. var limits = lex.text === "\\limits";
  1377. base.value.limits = limits;
  1378. base.value.alwaysHandleSupSub = true;
  1379. }
  1380. this.consume();
  1381. } else if (lex.text === "^") {
  1382. // We got a superscript start
  1383. if (superscript) {
  1384. throw new _ParseError2.default("Double superscript", lex);
  1385. }
  1386. superscript = this.handleSupSubscript("superscript");
  1387. } else if (lex.text === "_") {
  1388. // We got a subscript start
  1389. if (subscript) {
  1390. throw new _ParseError2.default("Double subscript", lex);
  1391. }
  1392. subscript = this.handleSupSubscript("subscript");
  1393. } else if (lex.text === "'") {
  1394. // We got a prime
  1395. if (superscript) {
  1396. throw new _ParseError2.default("Double superscript", lex);
  1397. }
  1398. var prime = new _ParseNode2.default("textord", "\\prime", this.mode);
  1399. // Many primes can be grouped together, so we handle this here
  1400. var primes = [prime];
  1401. this.consume();
  1402. // Keep lexing tokens until we get something that's not a prime
  1403. while (this.nextToken.text === "'") {
  1404. // For each one, add another prime to the list
  1405. primes.push(prime);
  1406. this.consume();
  1407. }
  1408. // If there's a superscript following the primes, combine that
  1409. // superscript in with the primes.
  1410. if (this.nextToken.text === "^") {
  1411. primes.push(this.handleSupSubscript("superscript"));
  1412. }
  1413. // Put everything into an ordgroup as the superscript
  1414. superscript = new _ParseNode2.default("ordgroup", primes, this.mode);
  1415. } else {
  1416. // If it wasn't ^, _, or ', stop parsing super/subscripts
  1417. break;
  1418. }
  1419. }
  1420. if (superscript || subscript) {
  1421. // If we got either a superscript or subscript, create a supsub
  1422. return new _ParseNode2.default("supsub", {
  1423. base: base,
  1424. sup: superscript,
  1425. sub: subscript
  1426. }, this.mode);
  1427. } else {
  1428. // Otherwise return the original body
  1429. return base;
  1430. }
  1431. }
  1432. // A list of the size-changing functions, for use in parseImplicitGroup
  1433. // A list of the style-changing functions, for use in parseImplicitGroup
  1434. // Old font functions
  1435. }, {
  1436. key: "parseImplicitGroup",
  1437. /**
  1438. * Parses an implicit group, which is a group that starts at the end of a
  1439. * specified, and ends right before a higher explicit group ends, or at EOL. It
  1440. * is used for functions that appear to affect the current style, like \Large or
  1441. * \textrm, where instead of keeping a style we just pretend that there is an
  1442. * implicit grouping after it until the end of the group. E.g.
  1443. * small text {\Large large text} small text again
  1444. * It is also used for \left and \right to get the correct grouping.
  1445. *
  1446. * @return {?ParseNode}
  1447. */
  1448. value: function parseImplicitGroup() {
  1449. var start = this.parseSymbol();
  1450. if (start == null) {
  1451. // If we didn't get anything we handle, fall back to parseFunction
  1452. return this.parseFunction();
  1453. }
  1454. var func = start.result;
  1455. if (func === "\\left") {
  1456. // If we see a left:
  1457. // Parse the entire left function (including the delimiter)
  1458. var left = this.parseFunction(start);
  1459. // Parse out the implicit body
  1460. ++this.leftrightDepth;
  1461. var body = this.parseExpression(false);
  1462. --this.leftrightDepth;
  1463. // Check the next token
  1464. this.expect("\\right", false);
  1465. var right = this.parseFunction();
  1466. return new _ParseNode2.default("leftright", {
  1467. body: body,
  1468. left: left.value.value,
  1469. right: right.value.value
  1470. }, this.mode);
  1471. } else if (func === "\\begin") {
  1472. // begin...end is similar to left...right
  1473. var begin = this.parseFunction(start);
  1474. var envName = begin.value.name;
  1475. if (!_environments2.default.hasOwnProperty(envName)) {
  1476. throw new _ParseError2.default("No such environment: " + envName, begin.value.nameGroup);
  1477. }
  1478. // Build the environment object. Arguments and other information will
  1479. // be made available to the begin and end methods using properties.
  1480. var env = _environments2.default[envName];
  1481. var args = this.parseArguments("\\begin{" + envName + "}", env);
  1482. var context = {
  1483. mode: this.mode,
  1484. envName: envName,
  1485. parser: this,
  1486. positions: args.pop()
  1487. };
  1488. var result = env.handler(context, args);
  1489. this.expect("\\end", false);
  1490. var endNameToken = this.nextToken;
  1491. var end = this.parseFunction();
  1492. if (end.value.name !== envName) {
  1493. throw new _ParseError2.default("Mismatch: \\begin{" + envName + "} matched " + "by \\end{" + end.value.name + "}", endNameToken);
  1494. }
  1495. result.position = end.position;
  1496. return result;
  1497. } else if (_utils2.default.contains(Parser.sizeFuncs, func)) {
  1498. // If we see a sizing function, parse out the implicit body
  1499. this.consumeSpaces();
  1500. var _body = this.parseExpression(false);
  1501. return new _ParseNode2.default("sizing", {
  1502. // Figure out what size to use based on the list of functions above
  1503. size: _utils2.default.indexOf(Parser.sizeFuncs, func) + 1,
  1504. value: _body
  1505. }, this.mode);
  1506. } else if (_utils2.default.contains(Parser.styleFuncs, func)) {
  1507. // If we see a styling function, parse out the implicit body
  1508. this.consumeSpaces();
  1509. var _body2 = this.parseExpression(true);
  1510. return new _ParseNode2.default("styling", {
  1511. // Figure out what style to use by pulling out the style from
  1512. // the function name
  1513. style: func.slice(1, func.length - 5),
  1514. value: _body2
  1515. }, this.mode);
  1516. } else if (func in Parser.oldFontFuncs) {
  1517. var style = Parser.oldFontFuncs[func];
  1518. // If we see an old font function, parse out the implicit body
  1519. this.consumeSpaces();
  1520. var _body3 = this.parseExpression(true);
  1521. if (style.slice(0, 4) === 'text') {
  1522. return new _ParseNode2.default("text", {
  1523. style: style,
  1524. body: new _ParseNode2.default("ordgroup", _body3, this.mode)
  1525. }, this.mode);
  1526. } else {
  1527. return new _ParseNode2.default("font", {
  1528. font: style,
  1529. body: new _ParseNode2.default("ordgroup", _body3, this.mode)
  1530. }, this.mode);
  1531. }
  1532. } else if (func === "\\color") {
  1533. // If we see a styling function, parse out the implicit body
  1534. var color = this.parseColorGroup(false);
  1535. if (!color) {
  1536. throw new _ParseError2.default("\\color not followed by color");
  1537. }
  1538. var _body4 = this.parseExpression(true);
  1539. return new _ParseNode2.default("color", {
  1540. type: "color",
  1541. color: color.result.value,
  1542. value: _body4
  1543. }, this.mode);
  1544. } else if (func === "$") {
  1545. if (this.mode === "math") {
  1546. throw new _ParseError2.default("$ within math mode");
  1547. }
  1548. this.consume();
  1549. var outerMode = this.mode;
  1550. this.switchMode("math");
  1551. var _body5 = this.parseExpression(false, "$");
  1552. this.expect("$", true);
  1553. this.switchMode(outerMode);
  1554. return new _ParseNode2.default("styling", {
  1555. style: "text",
  1556. value: _body5
  1557. }, "math");
  1558. } else {
  1559. // Defer to parseFunction if it's not a function we handle
  1560. return this.parseFunction(start);
  1561. }
  1562. }
  1563. /**
  1564. * Parses an entire function, including its base and all of its arguments.
  1565. * The base might either have been parsed already, in which case
  1566. * it is provided as an argument, or it's the next group in the input.
  1567. *
  1568. * @param {ParseFuncOrArgument=} baseGroup optional as described above
  1569. * @return {?ParseNode}
  1570. */
  1571. }, {
  1572. key: "parseFunction",
  1573. value: function parseFunction(baseGroup) {
  1574. if (!baseGroup) {
  1575. baseGroup = this.parseGroup();
  1576. }
  1577. if (baseGroup) {
  1578. if (baseGroup.isFunction) {
  1579. var func = baseGroup.result;
  1580. var funcData = _functions2.default[func];
  1581. if (this.mode === "text" && !funcData.allowedInText) {
  1582. throw new _ParseError2.default("Can't use function '" + func + "' in text mode", baseGroup.token);
  1583. } else if (this.mode === "math" && funcData.allowedInMath === false) {
  1584. throw new _ParseError2.default("Can't use function '" + func + "' in math mode", baseGroup.token);
  1585. }
  1586. var args = this.parseArguments(func, funcData);
  1587. var token = baseGroup.token;
  1588. var result = this.callFunction(func, args, args.pop(), token);
  1589. return new _ParseNode2.default(result.type, result, this.mode);
  1590. } else {
  1591. return baseGroup.result;
  1592. }
  1593. } else {
  1594. return null;
  1595. }
  1596. }
  1597. /**
  1598. * Call a function handler with a suitable context and arguments.
  1599. */
  1600. }, {
  1601. key: "callFunction",
  1602. value: function callFunction(name, args, positions, token) {
  1603. var context = {
  1604. funcName: name,
  1605. parser: this,
  1606. positions: positions,
  1607. token: token
  1608. };
  1609. return _functions2.default[name].handler(context, args);
  1610. }
  1611. /**
  1612. * Parses the arguments of a function or environment
  1613. *
  1614. * @param {string} func "\name" or "\begin{name}"
  1615. * @param {{numArgs:number,numOptionalArgs:number|undefined}} funcData
  1616. * @return the array of arguments, with the list of positions as last element
  1617. */
  1618. }, {
  1619. key: "parseArguments",
  1620. value: function parseArguments(func, funcData) {
  1621. var totalArgs = funcData.numArgs + funcData.numOptionalArgs;
  1622. if (totalArgs === 0) {
  1623. return [[this.pos]];
  1624. }
  1625. var baseGreediness = funcData.greediness;
  1626. var positions = [this.pos];
  1627. var args = [];
  1628. for (var i = 0; i < totalArgs; i++) {
  1629. var nextToken = this.nextToken;
  1630. var argType = funcData.argTypes && funcData.argTypes[i];
  1631. var arg = void 0;
  1632. if (i < funcData.numOptionalArgs) {
  1633. if (argType) {
  1634. arg = this.parseGroupOfType(argType, true);
  1635. } else {
  1636. arg = this.parseGroup(true);
  1637. }
  1638. if (!arg) {
  1639. args.push(null);
  1640. positions.push(this.pos);
  1641. continue;
  1642. }
  1643. } else {
  1644. if (argType) {
  1645. arg = this.parseGroupOfType(argType);
  1646. } else {
  1647. arg = this.parseGroup();
  1648. }
  1649. if (!arg) {
  1650. if (!this.settings.throwOnError && this.nextToken.text[0] === "\\") {
  1651. arg = new ParseFuncOrArgument(this.handleUnsupportedCmd(this.nextToken.text), false);
  1652. } else {
  1653. throw new _ParseError2.default("Expected group after '" + func + "'", nextToken);
  1654. }
  1655. }
  1656. }
  1657. var argNode = void 0;
  1658. if (arg.isFunction) {
  1659. var argGreediness = _functions2.default[arg.result].greediness;
  1660. if (argGreediness > baseGreediness) {
  1661. argNode = this.parseFunction(arg);
  1662. } else {
  1663. throw new _ParseError2.default("Got function '" + arg.result + "' as " + "argument to '" + func + "'", nextToken);
  1664. }
  1665. } else {
  1666. argNode = arg.result;
  1667. }
  1668. args.push(argNode);
  1669. positions.push(this.pos);
  1670. }
  1671. args.push(positions);
  1672. return args;
  1673. }
  1674. /**
  1675. * Parses a group when the mode is changing.
  1676. *
  1677. * @return {?ParseFuncOrArgument}
  1678. */
  1679. }, {
  1680. key: "parseGroupOfType",
  1681. value: function parseGroupOfType(innerMode, optional) {
  1682. var outerMode = this.mode;
  1683. // Handle `original` argTypes
  1684. if (innerMode === "original") {
  1685. innerMode = outerMode;
  1686. }
  1687. if (innerMode === "color") {
  1688. return this.parseColorGroup(optional);
  1689. }
  1690. if (innerMode === "size") {
  1691. return this.parseSizeGroup(optional);
  1692. }
  1693. this.switchMode(innerMode);
  1694. if (innerMode === "text") {
  1695. // text mode is special because it should ignore the whitespace before
  1696. // it
  1697. this.consumeSpaces();
  1698. }
  1699. // By the time we get here, innerMode is one of "text" or "math".
  1700. // We switch the mode of the parser, recurse, then restore the old mode.
  1701. var res = this.parseGroup(optional);
  1702. this.switchMode(outerMode);
  1703. return res;
  1704. }
  1705. }, {
  1706. key: "consumeSpaces",
  1707. value: function consumeSpaces() {
  1708. while (this.nextToken.text === " ") {
  1709. this.consume();
  1710. }
  1711. }
  1712. /**
  1713. * Parses a group, essentially returning the string formed by the
  1714. * brace-enclosed tokens plus some position information.
  1715. *
  1716. * @param {string} modeName Used to describe the mode in error messages
  1717. * @param {boolean=} optional Whether the group is optional or required
  1718. */
  1719. }, {
  1720. key: "parseStringGroup",
  1721. value: function parseStringGroup(modeName, optional) {
  1722. if (optional && this.nextToken.text !== "[") {
  1723. return null;
  1724. }
  1725. var outerMode = this.mode;
  1726. this.mode = "text";
  1727. this.expect(optional ? "[" : "{");
  1728. var str = "";
  1729. var firstToken = this.nextToken;
  1730. var lastToken = firstToken;
  1731. while (this.nextToken.text !== (optional ? "]" : "}")) {
  1732. if (this.nextToken.text === "EOF") {
  1733. throw new _ParseError2.default("Unexpected end of input in " + modeName, firstToken.range(this.nextToken, str));
  1734. }
  1735. lastToken = this.nextToken;
  1736. str += lastToken.text;
  1737. this.consume();
  1738. }
  1739. this.mode = outerMode;
  1740. this.expect(optional ? "]" : "}");
  1741. return firstToken.range(lastToken, str);
  1742. }
  1743. /**
  1744. * Parses a regex-delimited group: the largest sequence of tokens
  1745. * whose concatenated strings match `regex`. Returns the string
  1746. * formed by the tokens plus some position information.
  1747. *
  1748. * @param {RegExp} regex
  1749. * @param {string} modeName Used to describe the mode in error messages
  1750. */
  1751. }, {
  1752. key: "parseRegexGroup",
  1753. value: function parseRegexGroup(regex, modeName) {
  1754. var outerMode = this.mode;
  1755. this.mode = "text";
  1756. var firstToken = this.nextToken;
  1757. var lastToken = firstToken;
  1758. var str = "";
  1759. while (this.nextToken.text !== "EOF" && regex.test(str + this.nextToken.text)) {
  1760. lastToken = this.nextToken;
  1761. str += lastToken.text;
  1762. this.consume();
  1763. }
  1764. if (str === "") {
  1765. throw new _ParseError2.default("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken);
  1766. }
  1767. this.mode = outerMode;
  1768. return firstToken.range(lastToken, str);
  1769. }
  1770. /**
  1771. * Parses a color description.
  1772. */
  1773. }, {
  1774. key: "parseColorGroup",
  1775. value: function parseColorGroup(optional) {
  1776. var res = this.parseStringGroup("color", optional);
  1777. if (!res) {
  1778. return null;
  1779. }
  1780. var match = /^(#[a-z0-9]+|[a-z]+)$/i.exec(res.text);
  1781. if (!match) {
  1782. throw new _ParseError2.default("Invalid color: '" + res.text + "'", res);
  1783. }
  1784. return new ParseFuncOrArgument(new _ParseNode2.default("color", match[0], this.mode), false);
  1785. }
  1786. /**
  1787. * Parses a size specification, consisting of magnitude and unit.
  1788. */
  1789. }, {
  1790. key: "parseSizeGroup",
  1791. value: function parseSizeGroup(optional) {
  1792. var res = void 0;
  1793. if (!optional && this.nextToken.text !== "{") {
  1794. res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size");
  1795. } else {
  1796. res = this.parseStringGroup("size", optional);
  1797. }
  1798. if (!res) {
  1799. return null;
  1800. }
  1801. var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text);
  1802. if (!match) {
  1803. throw new _ParseError2.default("Invalid size: '" + res.text + "'", res);
  1804. }
  1805. var data = {
  1806. number: +(match[1] + match[2]), // sign + magnitude, cast to number
  1807. unit: match[3]
  1808. };
  1809. if (!_units2.default.validUnit(data)) {
  1810. throw new _ParseError2.default("Invalid unit: '" + data.unit + "'", res);
  1811. }
  1812. return new ParseFuncOrArgument(new _ParseNode2.default("size", data, this.mode), false);
  1813. }
  1814. /**
  1815. * If the argument is false or absent, this parses an ordinary group,
  1816. * which is either a single nucleus (like "x") or an expression
  1817. * in braces (like "{x+y}").
  1818. * If the argument is true, it parses either a bracket-delimited expression
  1819. * (like "[x+y]") or returns null to indicate the absence of a
  1820. * bracket-enclosed group.
  1821. *
  1822. * @param {boolean=} optional Whether the group is optional or required
  1823. * @return {?ParseFuncOrArgument}
  1824. */
  1825. }, {
  1826. key: "parseGroup",
  1827. value: function parseGroup(optional) {
  1828. var firstToken = this.nextToken;
  1829. // Try to parse an open brace
  1830. if (this.nextToken.text === (optional ? "[" : "{")) {
  1831. // If we get a brace, parse an expression
  1832. this.consume();
  1833. var expression = this.parseExpression(false, optional ? "]" : null);
  1834. var lastToken = this.nextToken;
  1835. // Make sure we get a close brace
  1836. this.expect(optional ? "]" : "}");
  1837. if (this.mode === "text") {
  1838. this.formLigatures(expression);
  1839. }
  1840. return new ParseFuncOrArgument(new _ParseNode2.default("ordgroup", expression, this.mode, firstToken, lastToken), false);
  1841. } else {
  1842. // Otherwise, just return a nucleus, or nothing for an optional group
  1843. return optional ? null : this.parseSymbol();
  1844. }
  1845. }
  1846. /**
  1847. * Form ligature-like combinations of characters for text mode.
  1848. * This includes inputs like "--", "---", "``" and "''".
  1849. * The result will simply replace multiple textord nodes with a single
  1850. * character in each value by a single textord node having multiple
  1851. * characters in its value. The representation is still ASCII source.
  1852. *
  1853. * @param {Array.<ParseNode>} group the nodes of this group,
  1854. * list will be moified in place
  1855. */
  1856. }, {
  1857. key: "formLigatures",
  1858. value: function formLigatures(group) {
  1859. var n = group.length - 1;
  1860. for (var i = 0; i < n; ++i) {
  1861. var a = group[i];
  1862. var v = a.value;
  1863. if (v === "-" && group[i + 1].value === "-") {
  1864. if (i + 1 < n && group[i + 2].value === "-") {
  1865. group.splice(i, 3, new _ParseNode2.default("textord", "---", "text", a, group[i + 2]));
  1866. n -= 2;
  1867. } else {
  1868. group.splice(i, 2, new _ParseNode2.default("textord", "--", "text", a, group[i + 1]));
  1869. n -= 1;
  1870. }
  1871. }
  1872. if ((v === "'" || v === "`") && group[i + 1].value === v) {
  1873. group.splice(i, 2, new _ParseNode2.default("textord", v + v, "text", a, group[i + 1]));
  1874. n -= 1;
  1875. }
  1876. }
  1877. }
  1878. /**
  1879. * Parse a single symbol out of the string. Here, we handle both the functions
  1880. * we have defined, as well as the single character symbols
  1881. *
  1882. * @return {?ParseFuncOrArgument}
  1883. */
  1884. }, {
  1885. key: "parseSymbol",
  1886. value: function parseSymbol() {
  1887. var nucleus = this.nextToken;
  1888. if (_functions2.default[nucleus.text]) {
  1889. this.consume();
  1890. // If there exists a function with this name, we return the function and
  1891. // say that it is a function.
  1892. return new ParseFuncOrArgument(nucleus.text, true, nucleus);
  1893. } else if (_symbols2.default[this.mode][nucleus.text]) {
  1894. this.consume();
  1895. // Otherwise if this is a no-argument function, find the type it
  1896. // corresponds to in the symbols map
  1897. return new ParseFuncOrArgument(new _ParseNode2.default(_symbols2.default[this.mode][nucleus.text].group, nucleus.text, this.mode, nucleus), false, nucleus);
  1898. } else if (this.mode === "text" && _unicodeRegexes.cjkRegex.test(nucleus.text)) {
  1899. this.consume();
  1900. return new ParseFuncOrArgument(new _ParseNode2.default("textord", nucleus.text, this.mode, nucleus), false, nucleus);
  1901. } else if (nucleus.text === "$") {
  1902. return new ParseFuncOrArgument(nucleus.text, false, nucleus);
  1903. } else {
  1904. return null;
  1905. }
  1906. }
  1907. }]);
  1908. return Parser;
  1909. }();
  1910. Parser.endOfExpression = ["}", "\\end", "\\right", "&", "\\\\", "\\cr"];
  1911. Parser.SUPSUB_GREEDINESS = 1;
  1912. Parser.sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"];
  1913. Parser.styleFuncs = ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"];
  1914. Parser.oldFontFuncs = {
  1915. "\\rm": "mathrm",
  1916. "\\sf": "mathsf",
  1917. "\\tt": "mathtt",
  1918. "\\bf": "mathbf",
  1919. "\\it": "mathit"
  1920. };
  1921. Parser.prototype.ParseNode = _ParseNode2.default;
  1922. module.exports = Parser;
  1923. },{"./MacroExpander":27,"./ParseError":29,"./ParseNode":30,"./environments":40,"./functions":43,"./symbols":48,"./unicodeRegexes":49,"./units":50,"./utils":51,"babel-runtime/helpers/classCallCheck":4,"babel-runtime/helpers/createClass":5}],32:[function(require,module,exports){
  1924. "use strict";
  1925. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  1926. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  1927. var _utils = require("./utils");
  1928. var _utils2 = _interopRequireDefault(_utils);
  1929. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1930. /**
  1931. * The main Settings object
  1932. *
  1933. * The current options stored are:
  1934. * - displayMode: Whether the expression should be typeset as inline math
  1935. * (false, the default), meaning that the math starts in
  1936. * \textstyle and is placed in an inline-block); or as display
  1937. * math (true), meaning that the math starts in \displaystyle
  1938. * and is placed in a block with vertical margin.
  1939. */
  1940. var Settings = function Settings(options) {
  1941. (0, _classCallCheck3.default)(this, Settings);
  1942. // allow null options
  1943. options = options || {};
  1944. this.displayMode = _utils2.default.deflt(options.displayMode, false);
  1945. this.throwOnError = _utils2.default.deflt(options.throwOnError, true);
  1946. this.errorColor = _utils2.default.deflt(options.errorColor, "#cc0000");
  1947. this.macros = options.macros || {};
  1948. this.colorIsTextColor = _utils2.default.deflt(options.colorIsTextColor, false);
  1949. }; /**
  1950. * This is a module for storing settings passed into KaTeX. It correctly handles
  1951. * default settings.
  1952. */
  1953. module.exports = Settings;
  1954. },{"./utils":51,"babel-runtime/helpers/classCallCheck":4}],33:[function(require,module,exports){
  1955. "use strict";
  1956. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  1957. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  1958. var _createClass2 = require("babel-runtime/helpers/createClass");
  1959. var _createClass3 = _interopRequireDefault(_createClass2);
  1960. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1961. /**
  1962. * This file contains information and classes for the various kinds of styles
  1963. * used in TeX. It provides a generic `Style` class, which holds information
  1964. * about a specific style. It then provides instances of all the different kinds
  1965. * of styles possible, and provides functions to move between them and get
  1966. * information about them.
  1967. */
  1968. /**
  1969. * The main style class. Contains a unique id for the style, a size (which is
  1970. * the same for cramped and uncramped version of a style), and a cramped flag.
  1971. */
  1972. var Style = function () {
  1973. function Style(id, size, cramped) {
  1974. (0, _classCallCheck3.default)(this, Style);
  1975. this.id = id;
  1976. this.size = size;
  1977. this.cramped = cramped;
  1978. }
  1979. /**
  1980. * Get the style of a superscript given a base in the current style.
  1981. */
  1982. (0, _createClass3.default)(Style, [{
  1983. key: "sup",
  1984. value: function sup() {
  1985. return styles[_sup[this.id]];
  1986. }
  1987. /**
  1988. * Get the style of a subscript given a base in the current style.
  1989. */
  1990. }, {
  1991. key: "sub",
  1992. value: function sub() {
  1993. return styles[_sub[this.id]];
  1994. }
  1995. /**
  1996. * Get the style of a fraction numerator given the fraction in the current
  1997. * style.
  1998. */
  1999. }, {
  2000. key: "fracNum",
  2001. value: function fracNum() {
  2002. return styles[_fracNum[this.id]];
  2003. }
  2004. /**
  2005. * Get the style of a fraction denominator given the fraction in the current
  2006. * style.
  2007. */
  2008. }, {
  2009. key: "fracDen",
  2010. value: function fracDen() {
  2011. return styles[_fracDen[this.id]];
  2012. }
  2013. /**
  2014. * Get the cramped version of a style (in particular, cramping a cramped style
  2015. * doesn't change the style).
  2016. */
  2017. }, {
  2018. key: "cramp",
  2019. value: function cramp() {
  2020. return styles[_cramp[this.id]];
  2021. }
  2022. /**
  2023. * Get a text or display version of this style.
  2024. */
  2025. }, {
  2026. key: "text",
  2027. value: function text() {
  2028. return styles[_text[this.id]];
  2029. }
  2030. /**
  2031. * Return if this style is tightly spaced (scriptstyle/scriptscriptstyle)
  2032. */
  2033. }, {
  2034. key: "isTight",
  2035. value: function isTight() {
  2036. return this.size >= 2;
  2037. }
  2038. }]);
  2039. return Style;
  2040. }();
  2041. // IDs of the different styles
  2042. var D = 0;
  2043. var Dc = 1;
  2044. var T = 2;
  2045. var Tc = 3;
  2046. var S = 4;
  2047. var Sc = 5;
  2048. var SS = 6;
  2049. var SSc = 7;
  2050. // Instances of the different styles
  2051. var styles = [new Style(D, 0, false), new Style(Dc, 0, true), new Style(T, 1, false), new Style(Tc, 1, true), new Style(S, 2, false), new Style(Sc, 2, true), new Style(SS, 3, false), new Style(SSc, 3, true)];
  2052. // Lookup tables for switching from one style to another
  2053. var _sup = [S, Sc, S, Sc, SS, SSc, SS, SSc];
  2054. var _sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc];
  2055. var _fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc];
  2056. var _fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc];
  2057. var _cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc];
  2058. var _text = [D, Dc, T, Tc, T, Tc, T, Tc];
  2059. // We only export some of the styles. Also, we don't export the `Style` class so
  2060. // no more styles can be generated.
  2061. module.exports = {
  2062. DISPLAY: styles[D],
  2063. TEXT: styles[T],
  2064. SCRIPT: styles[S],
  2065. SCRIPTSCRIPT: styles[SS]
  2066. };
  2067. },{"babel-runtime/helpers/classCallCheck":4,"babel-runtime/helpers/createClass":5}],34:[function(require,module,exports){
  2068. "use strict";
  2069. var _domTree = require("./domTree");
  2070. var _domTree2 = _interopRequireDefault(_domTree);
  2071. var _fontMetrics = require("./fontMetrics");
  2072. var _fontMetrics2 = _interopRequireDefault(_fontMetrics);
  2073. var _symbols = require("./symbols");
  2074. var _symbols2 = _interopRequireDefault(_symbols);
  2075. var _utils = require("./utils");
  2076. var _utils2 = _interopRequireDefault(_utils);
  2077. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2078. // The following have to be loaded from Main-Italic font, using class mainit
  2079. /* eslint no-console:0 */
  2080. /**
  2081. * This module contains general functions that can be used for building
  2082. * different kinds of domTree nodes in a consistent manner.
  2083. */
  2084. var mainitLetters = ["\\imath", // dotless i
  2085. "\\jmath", // dotless j
  2086. "\\pounds"];
  2087. /**
  2088. * Looks up the given symbol in fontMetrics, after applying any symbol
  2089. * replacements defined in symbol.js
  2090. */
  2091. var lookupSymbol = function lookupSymbol(value, fontFamily, mode) {
  2092. // Replace the value with its replaced value from symbol.js
  2093. if (_symbols2.default[mode][value] && _symbols2.default[mode][value].replace) {
  2094. value = _symbols2.default[mode][value].replace;
  2095. }
  2096. return {
  2097. value: value,
  2098. metrics: _fontMetrics2.default.getCharacterMetrics(value, fontFamily)
  2099. };
  2100. };
  2101. /**
  2102. * Makes a symbolNode after translation via the list of symbols in symbols.js.
  2103. * Correctly pulls out metrics for the character, and optionally takes a list of
  2104. * classes to be attached to the node.
  2105. *
  2106. * TODO: make argument order closer to makeSpan
  2107. * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
  2108. * should if present come first in `classes`.
  2109. */
  2110. var makeSymbol = function makeSymbol(value, fontFamily, mode, options, classes) {
  2111. var lookup = lookupSymbol(value, fontFamily, mode);
  2112. var metrics = lookup.metrics;
  2113. value = lookup.value;
  2114. var symbolNode = void 0;
  2115. if (metrics) {
  2116. var italic = metrics.italic;
  2117. if (mode === "text") {
  2118. italic = 0;
  2119. }
  2120. symbolNode = new _domTree2.default.symbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, classes);
  2121. } else {
  2122. // TODO(emily): Figure out a good way to only print this in development
  2123. typeof console !== "undefined" && console.warn("No character metrics for '" + value + "' in style '" + fontFamily + "'");
  2124. symbolNode = new _domTree2.default.symbolNode(value, 0, 0, 0, 0, classes);
  2125. }
  2126. if (options) {
  2127. symbolNode.maxFontSize = options.sizeMultiplier;
  2128. if (options.style.isTight()) {
  2129. symbolNode.classes.push("mtight");
  2130. }
  2131. if (options.getColor()) {
  2132. symbolNode.style.color = options.getColor();
  2133. }
  2134. }
  2135. return symbolNode;
  2136. };
  2137. /**
  2138. * Makes a symbol in Main-Regular or AMS-Regular.
  2139. * Used for rel, bin, open, close, inner, and punct.
  2140. */
  2141. var mathsym = function mathsym(value, mode, options, classes) {
  2142. // Decide what font to render the symbol in by its entry in the symbols
  2143. // table.
  2144. // Have a special case for when the value = \ because the \ is used as a
  2145. // textord in unsupported command errors but cannot be parsed as a regular
  2146. // text ordinal and is therefore not present as a symbol in the symbols
  2147. // table for text
  2148. if (value === "\\" || _symbols2.default[mode][value].font === "main") {
  2149. return makeSymbol(value, "Main-Regular", mode, options, classes);
  2150. } else {
  2151. return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"]));
  2152. }
  2153. };
  2154. /**
  2155. * Makes a symbol in the default font for mathords and textords.
  2156. */
  2157. var mathDefault = function mathDefault(value, mode, options, classes, type) {
  2158. if (type === "mathord") {
  2159. var fontLookup = mathit(value, mode, options, classes);
  2160. return makeSymbol(value, fontLookup.fontName, mode, options, classes.concat([fontLookup.fontClass]));
  2161. } else if (type === "textord") {
  2162. var font = _symbols2.default[mode][value] && _symbols2.default[mode][value].font;
  2163. if (font === "ams") {
  2164. return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"]));
  2165. } else {
  2166. // if (font === "main") {
  2167. return makeSymbol(value, "Main-Regular", mode, options, classes.concat(["mathrm"]));
  2168. }
  2169. } else {
  2170. throw new Error("unexpected type: " + type + " in mathDefault");
  2171. }
  2172. };
  2173. /**
  2174. * Determines which of the two font names (Main-Italic and Math-Italic) and
  2175. * corresponding style tags (mainit or mathit) to use for font "mathit",
  2176. * depending on the symbol. Use this function instead of fontMap for font
  2177. * "mathit".
  2178. */
  2179. var mathit = function mathit(value, mode, options, classes) {
  2180. if (/[0-9]/.test(value.charAt(0)) ||
  2181. // glyphs for \imath and \jmath do not exist in Math-Italic so we
  2182. // need to use Main-Italic instead
  2183. _utils2.default.contains(mainitLetters, value)) {
  2184. return {
  2185. fontName: "Main-Italic",
  2186. fontClass: "mainit"
  2187. };
  2188. } else {
  2189. return {
  2190. fontName: "Math-Italic",
  2191. fontClass: "mathit"
  2192. };
  2193. }
  2194. };
  2195. /**
  2196. * Makes either a mathord or textord in the correct font and color.
  2197. */
  2198. var makeOrd = function makeOrd(group, options, type) {
  2199. var mode = group.mode;
  2200. var value = group.value;
  2201. var classes = ["mord"];
  2202. var font = options.font;
  2203. if (font) {
  2204. var fontLookup = void 0;
  2205. if (font === "mathit" || _utils2.default.contains(mainitLetters, value)) {
  2206. fontLookup = mathit(value, mode, options, classes);
  2207. } else {
  2208. fontLookup = fontMap[font];
  2209. }
  2210. if (lookupSymbol(value, fontLookup.fontName, mode).metrics) {
  2211. return makeSymbol(value, fontLookup.fontName, mode, options, classes.concat([fontLookup.fontClass || font]));
  2212. } else {
  2213. return mathDefault(value, mode, options, classes, type);
  2214. }
  2215. } else {
  2216. return mathDefault(value, mode, options, classes, type);
  2217. }
  2218. };
  2219. /**
  2220. * Calculate the height, depth, and maxFontSize of an element based on its
  2221. * children.
  2222. */
  2223. var sizeElementFromChildren = function sizeElementFromChildren(elem) {
  2224. var height = 0;
  2225. var depth = 0;
  2226. var maxFontSize = 0;
  2227. if (elem.children) {
  2228. for (var i = 0; i < elem.children.length; i++) {
  2229. if (elem.children[i].height > height) {
  2230. height = elem.children[i].height;
  2231. }
  2232. if (elem.children[i].depth > depth) {
  2233. depth = elem.children[i].depth;
  2234. }
  2235. if (elem.children[i].maxFontSize > maxFontSize) {
  2236. maxFontSize = elem.children[i].maxFontSize;
  2237. }
  2238. }
  2239. }
  2240. elem.height = height;
  2241. elem.depth = depth;
  2242. elem.maxFontSize = maxFontSize;
  2243. };
  2244. /**
  2245. * Makes a span with the given list of classes, list of children, and options.
  2246. *
  2247. * TODO: Ensure that `options` is always provided (currently some call sites
  2248. * don't pass it).
  2249. * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
  2250. * should if present come first in `classes`.
  2251. */
  2252. var makeSpan = function makeSpan(classes, children, options) {
  2253. var span = new _domTree2.default.span(classes, children, options);
  2254. sizeElementFromChildren(span);
  2255. return span;
  2256. };
  2257. /**
  2258. * Prepends the given children to the given span, updating height, depth, and
  2259. * maxFontSize.
  2260. */
  2261. var prependChildren = function prependChildren(span, children) {
  2262. span.children = children.concat(span.children);
  2263. sizeElementFromChildren(span);
  2264. };
  2265. /**
  2266. * Makes a document fragment with the given list of children.
  2267. */
  2268. var makeFragment = function makeFragment(children) {
  2269. var fragment = new _domTree2.default.documentFragment(children);
  2270. sizeElementFromChildren(fragment);
  2271. return fragment;
  2272. };
  2273. /**
  2274. * Makes a vertical list by stacking elements and kerns on top of each other.
  2275. * Allows for many different ways of specifying the positioning method.
  2276. *
  2277. * Arguments:
  2278. * - children: A list of child or kern nodes to be stacked on top of each other
  2279. * (i.e. the first element will be at the bottom, and the last at
  2280. * the top). Element nodes are specified as
  2281. * {type: "elem", elem: node}
  2282. * while kern nodes are specified as
  2283. * {type: "kern", size: size}
  2284. * - positionType: The method by which the vlist should be positioned. Valid
  2285. * values are:
  2286. * - "individualShift": The children list only contains elem
  2287. * nodes, and each node contains an extra
  2288. * "shift" value of how much it should be
  2289. * shifted (note that shifting is always
  2290. * moving downwards). positionData is
  2291. * ignored.
  2292. * - "top": The positionData specifies the topmost point of
  2293. * the vlist (note this is expected to be a height,
  2294. * so positive values move up)
  2295. * - "bottom": The positionData specifies the bottommost point
  2296. * of the vlist (note this is expected to be a
  2297. * depth, so positive values move down
  2298. * - "shift": The vlist will be positioned such that its
  2299. * baseline is positionData away from the baseline
  2300. * of the first child. Positive values move
  2301. * downwards.
  2302. * - "firstBaseline": The vlist will be positioned such that
  2303. * its baseline is aligned with the
  2304. * baseline of the first child.
  2305. * positionData is ignored. (this is
  2306. * equivalent to "shift" with
  2307. * positionData=0)
  2308. * - positionData: Data used in different ways depending on positionType
  2309. * - options: An Options object
  2310. *
  2311. */
  2312. var makeVList = function makeVList(children, positionType, positionData, options) {
  2313. var depth = void 0;
  2314. var currPos = void 0;
  2315. var i = void 0;
  2316. if (positionType === "individualShift") {
  2317. var oldChildren = children;
  2318. children = [oldChildren[0]];
  2319. // Add in kerns to the list of children to get each element to be
  2320. // shifted to the correct specified shift
  2321. depth = -oldChildren[0].shift - oldChildren[0].elem.depth;
  2322. currPos = depth;
  2323. for (i = 1; i < oldChildren.length; i++) {
  2324. var diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth;
  2325. var size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth);
  2326. currPos = currPos + diff;
  2327. children.push({ type: "kern", size: size });
  2328. children.push(oldChildren[i]);
  2329. }
  2330. } else if (positionType === "top") {
  2331. // We always start at the bottom, so calculate the bottom by adding up
  2332. // all the sizes
  2333. var bottom = positionData;
  2334. for (i = 0; i < children.length; i++) {
  2335. if (children[i].type === "kern") {
  2336. bottom -= children[i].size;
  2337. } else {
  2338. bottom -= children[i].elem.height + children[i].elem.depth;
  2339. }
  2340. }
  2341. depth = bottom;
  2342. } else if (positionType === "bottom") {
  2343. depth = -positionData;
  2344. } else if (positionType === "shift") {
  2345. depth = -children[0].elem.depth - positionData;
  2346. } else if (positionType === "firstBaseline") {
  2347. depth = -children[0].elem.depth;
  2348. } else {
  2349. depth = 0;
  2350. }
  2351. // Create a strut that is taller than any list item. The strut is added to
  2352. // each item, where it will determine the item's baseline. Since it has
  2353. // `overflow:hidden`, the strut's top edge will sit on the item's line box's
  2354. // top edge and the strut's bottom edge will sit on the item's baseline,
  2355. // with no additional line-height spacing. This allows the item baseline to
  2356. // be positioned precisely without worrying about font ascent and
  2357. // line-height.
  2358. var pstrutSize = 0;
  2359. for (i = 0; i < children.length; i++) {
  2360. if (children[i].type === "elem") {
  2361. var child = children[i].elem;
  2362. pstrutSize = Math.max(pstrutSize, child.maxFontSize, child.height);
  2363. }
  2364. }
  2365. pstrutSize += 2;
  2366. var pstrut = makeSpan(["pstrut"], []);
  2367. pstrut.style.height = pstrutSize + "em";
  2368. // Create a new list of actual children at the correct offsets
  2369. var realChildren = [];
  2370. var minPos = depth;
  2371. var maxPos = depth;
  2372. currPos = depth;
  2373. for (i = 0; i < children.length; i++) {
  2374. if (children[i].type === "kern") {
  2375. currPos += children[i].size;
  2376. } else {
  2377. var _child = children[i].elem;
  2378. var childWrap = makeSpan([], [pstrut, _child]);
  2379. childWrap.style.top = -pstrutSize - currPos - _child.depth + "em";
  2380. if (children[i].marginLeft) {
  2381. childWrap.style.marginLeft = children[i].marginLeft;
  2382. }
  2383. if (children[i].marginRight) {
  2384. childWrap.style.marginRight = children[i].marginRight;
  2385. }
  2386. realChildren.push(childWrap);
  2387. currPos += _child.height + _child.depth;
  2388. }
  2389. minPos = Math.min(minPos, currPos);
  2390. maxPos = Math.max(maxPos, currPos);
  2391. }
  2392. // The vlist contents go in a table-cell with `vertical-align:bottom`.
  2393. // This cell's bottom edge will determine the containing table's baseline
  2394. // without overly expanding the containing line-box.
  2395. var vlist = makeSpan(["vlist"], realChildren);
  2396. vlist.style.height = maxPos + "em";
  2397. // A second row is used if necessary to represent the vlist's depth.
  2398. var rows = void 0;
  2399. if (minPos < 0) {
  2400. var depthStrut = makeSpan(["vlist"], []);
  2401. depthStrut.style.height = -minPos + "em";
  2402. // Safari wants the first row to have inline content; otherwise it
  2403. // puts the bottom of the *second* row on the baseline.
  2404. var topStrut = makeSpan(["vlist-s"], [new _domTree2.default.symbolNode("\u200B")]);
  2405. rows = [makeSpan(["vlist-r"], [vlist, topStrut]), makeSpan(["vlist-r"], [depthStrut])];
  2406. } else {
  2407. rows = [makeSpan(["vlist-r"], [vlist])];
  2408. }
  2409. var vtable = makeSpan(["vlist-t"], rows);
  2410. if (rows.length === 2) {
  2411. vtable.classes.push("vlist-t2");
  2412. }
  2413. vtable.height = maxPos;
  2414. vtable.depth = -minPos;
  2415. return vtable;
  2416. };
  2417. // A map of spacing functions to their attributes, like size and corresponding
  2418. // CSS class
  2419. var spacingFunctions = {
  2420. "\\qquad": {
  2421. size: "2em",
  2422. className: "qquad"
  2423. },
  2424. "\\quad": {
  2425. size: "1em",
  2426. className: "quad"
  2427. },
  2428. "\\enspace": {
  2429. size: "0.5em",
  2430. className: "enspace"
  2431. },
  2432. "\\;": {
  2433. size: "0.277778em",
  2434. className: "thickspace"
  2435. },
  2436. "\\:": {
  2437. size: "0.22222em",
  2438. className: "mediumspace"
  2439. },
  2440. "\\,": {
  2441. size: "0.16667em",
  2442. className: "thinspace"
  2443. },
  2444. "\\!": {
  2445. size: "-0.16667em",
  2446. className: "negativethinspace"
  2447. }
  2448. };
  2449. /**
  2450. * Maps TeX font commands to objects containing:
  2451. * - variant: string used for "mathvariant" attribute in buildMathML.js
  2452. * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics
  2453. */
  2454. // A map between tex font commands an MathML mathvariant attribute values
  2455. var fontMap = {
  2456. // styles
  2457. "mathbf": {
  2458. variant: "bold",
  2459. fontName: "Main-Bold"
  2460. },
  2461. "mathrm": {
  2462. variant: "normal",
  2463. fontName: "Main-Regular"
  2464. },
  2465. "textit": {
  2466. variant: "italic",
  2467. fontName: "Main-Italic"
  2468. },
  2469. // "mathit" is missing because it requires the use of two fonts: Main-Italic
  2470. // and Math-Italic. This is handled by a special case in makeOrd which ends
  2471. // up calling mathit.
  2472. // families
  2473. "mathbb": {
  2474. variant: "double-struck",
  2475. fontName: "AMS-Regular"
  2476. },
  2477. "mathcal": {
  2478. variant: "script",
  2479. fontName: "Caligraphic-Regular"
  2480. },
  2481. "mathfrak": {
  2482. variant: "fraktur",
  2483. fontName: "Fraktur-Regular"
  2484. },
  2485. "mathscr": {
  2486. variant: "script",
  2487. fontName: "Script-Regular"
  2488. },
  2489. "mathsf": {
  2490. variant: "sans-serif",
  2491. fontName: "SansSerif-Regular"
  2492. },
  2493. "mathtt": {
  2494. variant: "monospace",
  2495. fontName: "Typewriter-Regular"
  2496. }
  2497. };
  2498. module.exports = {
  2499. fontMap: fontMap,
  2500. makeSymbol: makeSymbol,
  2501. mathsym: mathsym,
  2502. makeSpan: makeSpan,
  2503. makeFragment: makeFragment,
  2504. makeVList: makeVList,
  2505. makeOrd: makeOrd,
  2506. prependChildren: prependChildren,
  2507. spacingFunctions: spacingFunctions
  2508. };
  2509. },{"./domTree":39,"./fontMetrics":41,"./symbols":48,"./utils":51}],35:[function(require,module,exports){
  2510. "use strict";
  2511. var _stringify = require("babel-runtime/core-js/json/stringify");
  2512. var _stringify2 = _interopRequireDefault(_stringify);
  2513. var _ParseError = require("./ParseError");
  2514. var _ParseError2 = _interopRequireDefault(_ParseError);
  2515. var _Style = require("./Style");
  2516. var _Style2 = _interopRequireDefault(_Style);
  2517. var _buildCommon = require("./buildCommon");
  2518. var _buildCommon2 = _interopRequireDefault(_buildCommon);
  2519. var _delimiter = require("./delimiter");
  2520. var _delimiter2 = _interopRequireDefault(_delimiter);
  2521. var _domTree = require("./domTree");
  2522. var _domTree2 = _interopRequireDefault(_domTree);
  2523. var _units = require("./units");
  2524. var _units2 = _interopRequireDefault(_units);
  2525. var _utils = require("./utils");
  2526. var _utils2 = _interopRequireDefault(_utils);
  2527. var _stretchy = require("./stretchy");
  2528. var _stretchy2 = _interopRequireDefault(_stretchy);
  2529. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2530. /* eslint no-console:0 */
  2531. /**
  2532. * This file does the main work of building a domTree structure from a parse
  2533. * tree. The entry point is the `buildHTML` function, which takes a parse tree.
  2534. * Then, the buildExpression, buildGroup, and various groupTypes functions are
  2535. * called, to produce a final HTML tree.
  2536. */
  2537. var isSpace = function isSpace(node) {
  2538. return node instanceof _domTree2.default.span && node.classes[0] === "mspace";
  2539. };
  2540. // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`)
  2541. // depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6,
  2542. // and the text before Rule 19.
  2543. var isBin = function isBin(node) {
  2544. return node && node.classes[0] === "mbin";
  2545. };
  2546. var isBinLeftCanceller = function isBinLeftCanceller(node, isRealGroup) {
  2547. // TODO: This code assumes that a node's math class is the first element
  2548. // of its `classes` array. A later cleanup should ensure this, for
  2549. // instance by changing the signature of `makeSpan`.
  2550. if (node) {
  2551. return _utils2.default.contains(["mbin", "mopen", "mrel", "mop", "mpunct"], node.classes[0]);
  2552. } else {
  2553. return isRealGroup;
  2554. }
  2555. };
  2556. var isBinRightCanceller = function isBinRightCanceller(node, isRealGroup) {
  2557. if (node) {
  2558. return _utils2.default.contains(["mrel", "mclose", "mpunct"], node.classes[0]);
  2559. } else {
  2560. return isRealGroup;
  2561. }
  2562. };
  2563. /**
  2564. * Splice out any spaces from `children` starting at position `i`, and return
  2565. * the spliced-out array. Returns null if `children[i]` does not exist or is not
  2566. * a space.
  2567. */
  2568. var spliceSpaces = function spliceSpaces(children, i) {
  2569. var j = i;
  2570. while (j < children.length && isSpace(children[j])) {
  2571. j++;
  2572. }
  2573. if (j === i) {
  2574. return null;
  2575. } else {
  2576. return children.splice(i, j - i);
  2577. }
  2578. };
  2579. /**
  2580. * Take a list of nodes, build them in order, and return a list of the built
  2581. * nodes. documentFragments are flattened into their contents, so the
  2582. * returned list contains no fragments. `isRealGroup` is true if `expression`
  2583. * is a real group (no atoms will be added on either side), as opposed to
  2584. * a partial group (e.g. one created by \color).
  2585. */
  2586. var buildExpression = function buildExpression(expression, options, isRealGroup) {
  2587. // Parse expressions into `groups`.
  2588. var groups = [];
  2589. for (var i = 0; i < expression.length; i++) {
  2590. var group = expression[i];
  2591. var output = buildGroup(group, options);
  2592. if (output instanceof _domTree2.default.documentFragment) {
  2593. Array.prototype.push.apply(groups, output.children);
  2594. } else {
  2595. groups.push(output);
  2596. }
  2597. }
  2598. // At this point `groups` consists entirely of `symbolNode`s and `span`s.
  2599. // Explicit spaces (e.g., \;, \,) should be ignored with respect to atom
  2600. // spacing (e.g., "add thick space between mord and mrel"). Since CSS
  2601. // adjacency rules implement atom spacing, spaces should be invisible to
  2602. // CSS. So we splice them out of `groups` and into the atoms themselves.
  2603. for (var _i = 0; _i < groups.length; _i++) {
  2604. var spaces = spliceSpaces(groups, _i);
  2605. if (spaces) {
  2606. // Splicing of spaces may have removed all remaining groups.
  2607. if (_i < groups.length) {
  2608. // If there is a following group, move space within it.
  2609. if (groups[_i] instanceof _domTree2.default.symbolNode) {
  2610. groups[_i] = (0, _buildCommon.makeSpan)([].concat(groups[_i].classes), [groups[_i]]);
  2611. }
  2612. _buildCommon2.default.prependChildren(groups[_i], spaces);
  2613. } else {
  2614. // Otherwise, put any spaces back at the end of the groups.
  2615. Array.prototype.push.apply(groups, spaces);
  2616. break;
  2617. }
  2618. }
  2619. }
  2620. // Binary operators change to ordinary symbols in some contexts.
  2621. for (var _i2 = 0; _i2 < groups.length; _i2++) {
  2622. if (isBin(groups[_i2]) && (isBinLeftCanceller(groups[_i2 - 1], isRealGroup) || isBinRightCanceller(groups[_i2 + 1], isRealGroup))) {
  2623. groups[_i2].classes[0] = "mord";
  2624. }
  2625. }
  2626. // Process \\not commands within the group.
  2627. // TODO(kevinb): Handle multiple \\not commands in a row.
  2628. // TODO(kevinb): Handle \\not{abc} correctly. The \\not should appear over
  2629. // the 'a' instead of the 'c'.
  2630. for (var _i3 = 0; _i3 < groups.length; _i3++) {
  2631. if (groups[_i3].value === "\u0338" && _i3 + 1 < groups.length) {
  2632. var children = groups.slice(_i3, _i3 + 2);
  2633. children[0].classes = ["mainrm"];
  2634. // \u0338 is a combining glyph so we could reorder the children so
  2635. // that it comes after the other glyph. This works correctly on
  2636. // most browsers except for Safari. Instead we absolutely position
  2637. // the glyph and set its right side to match that of the other
  2638. // glyph which is visually equivalent.
  2639. children[0].style.position = "absolute";
  2640. children[0].style.right = "0";
  2641. // Copy the classes from the second glyph to the new container.
  2642. // This is so it behaves the same as though there was no \\not.
  2643. var classes = groups[_i3 + 1].classes;
  2644. var container = (0, _buildCommon.makeSpan)(classes, children);
  2645. // LaTeX adds a space between ords separated by a \\not.
  2646. if (classes.indexOf("mord") !== -1) {
  2647. // \glue(\thickmuskip) 2.77771 plus 2.77771
  2648. container.style.paddingLeft = "0.277771em";
  2649. }
  2650. // Ensure that the \u0338 is positioned relative to the container.
  2651. container.style.position = "relative";
  2652. groups.splice(_i3, 2, container);
  2653. }
  2654. }
  2655. return groups;
  2656. };
  2657. // Return math atom class (mclass) of a domTree.
  2658. var getTypeOfDomTree = function getTypeOfDomTree(node) {
  2659. if (node instanceof _domTree2.default.documentFragment) {
  2660. if (node.children.length) {
  2661. return getTypeOfDomTree(node.children[node.children.length - 1]);
  2662. }
  2663. } else {
  2664. if (_utils2.default.contains(["mord", "mop", "mbin", "mrel", "mopen", "mclose", "mpunct", "minner"], node.classes[0])) {
  2665. return node.classes[0];
  2666. }
  2667. }
  2668. return null;
  2669. };
  2670. /**
  2671. * Sometimes, groups perform special rules when they have superscripts or
  2672. * subscripts attached to them. This function lets the `supsub` group know that
  2673. * its inner element should handle the superscripts and subscripts instead of
  2674. * handling them itself.
  2675. */
  2676. var shouldHandleSupSub = function shouldHandleSupSub(group, options) {
  2677. if (!group.value.base) {
  2678. return false;
  2679. } else {
  2680. var base = group.value.base;
  2681. if (base.type === "op") {
  2682. // Operators handle supsubs differently when they have limits
  2683. // (e.g. `\displaystyle\sum_2^3`)
  2684. return base.value.limits && (options.style.size === _Style2.default.DISPLAY.size || base.value.alwaysHandleSupSub);
  2685. } else if (base.type === "accent") {
  2686. return isCharacterBox(base.value.base);
  2687. } else if (base.type === "horizBrace") {
  2688. var isSup = group.value.sub ? false : true;
  2689. return isSup === base.value.isOver;
  2690. } else {
  2691. return null;
  2692. }
  2693. }
  2694. };
  2695. /**
  2696. * Sometimes we want to pull out the innermost element of a group. In most
  2697. * cases, this will just be the group itself, but when ordgroups and colors have
  2698. * a single element, we want to pull that out.
  2699. */
  2700. var getBaseElem = function getBaseElem(group) {
  2701. if (!group) {
  2702. return false;
  2703. } else if (group.type === "ordgroup") {
  2704. if (group.value.length === 1) {
  2705. return getBaseElem(group.value[0]);
  2706. } else {
  2707. return group;
  2708. }
  2709. } else if (group.type === "color") {
  2710. if (group.value.value.length === 1) {
  2711. return getBaseElem(group.value.value[0]);
  2712. } else {
  2713. return group;
  2714. }
  2715. } else if (group.type === "font") {
  2716. return getBaseElem(group.value.body);
  2717. } else {
  2718. return group;
  2719. }
  2720. };
  2721. /**
  2722. * TeXbook algorithms often reference "character boxes", which are simply groups
  2723. * with a single character in them. To decide if something is a character box,
  2724. * we find its innermost group, and see if it is a single character.
  2725. */
  2726. var isCharacterBox = function isCharacterBox(group) {
  2727. var baseElem = getBaseElem(group);
  2728. // These are all they types of groups which hold single characters
  2729. return baseElem.type === "mathord" || baseElem.type === "textord" || baseElem.type === "bin" || baseElem.type === "rel" || baseElem.type === "inner" || baseElem.type === "open" || baseElem.type === "close" || baseElem.type === "punct";
  2730. };
  2731. var makeNullDelimiter = function makeNullDelimiter(options, classes) {
  2732. var moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses());
  2733. return (0, _buildCommon.makeSpan)(classes.concat(moreClasses));
  2734. };
  2735. /**
  2736. * This is a map of group types to the function used to handle that type.
  2737. * Simpler types come at the beginning, while complicated types come afterwards.
  2738. */
  2739. var groupTypes = {};
  2740. groupTypes.mathord = function (group, options) {
  2741. return _buildCommon2.default.makeOrd(group, options, "mathord");
  2742. };
  2743. groupTypes.textord = function (group, options) {
  2744. return _buildCommon2.default.makeOrd(group, options, "textord");
  2745. };
  2746. groupTypes.bin = function (group, options) {
  2747. return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mbin"]);
  2748. };
  2749. groupTypes.rel = function (group, options) {
  2750. return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mrel"]);
  2751. };
  2752. groupTypes.open = function (group, options) {
  2753. return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mopen"]);
  2754. };
  2755. groupTypes.close = function (group, options) {
  2756. return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mclose"]);
  2757. };
  2758. groupTypes.inner = function (group, options) {
  2759. return _buildCommon2.default.mathsym(group.value, group.mode, options, ["minner"]);
  2760. };
  2761. groupTypes.punct = function (group, options) {
  2762. return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mpunct"]);
  2763. };
  2764. groupTypes.ordgroup = function (group, options) {
  2765. return (0, _buildCommon.makeSpan)(["mord"], buildExpression(group.value, options, true), options);
  2766. };
  2767. groupTypes.text = function (group, options) {
  2768. var newOptions = options.withFont(group.value.style);
  2769. var inner = buildExpression(group.value.body, newOptions, true);
  2770. for (var i = 0; i < inner.length - 1; i++) {
  2771. if (inner[i].tryCombine(inner[i + 1])) {
  2772. inner.splice(i + 1, 1);
  2773. i--;
  2774. }
  2775. }
  2776. return (0, _buildCommon.makeSpan)(["mord", "text"], inner, newOptions);
  2777. };
  2778. groupTypes.color = function (group, options) {
  2779. var elements = buildExpression(group.value.value, options.withColor(group.value.color), false);
  2780. // \color isn't supposed to affect the type of the elements it contains.
  2781. // To accomplish this, we wrap the results in a fragment, so the inner
  2782. // elements will be able to directly interact with their neighbors. For
  2783. // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3`
  2784. return new _buildCommon2.default.makeFragment(elements);
  2785. };
  2786. groupTypes.supsub = function (group, options) {
  2787. // Superscript and subscripts are handled in the TeXbook on page
  2788. // 445-446, rules 18(a-f).
  2789. // Here is where we defer to the inner group if it should handle
  2790. // superscripts and subscripts itself.
  2791. if (shouldHandleSupSub(group, options)) {
  2792. return groupTypes[group.value.base.type](group, options);
  2793. }
  2794. var base = buildGroup(group.value.base, options);
  2795. var supm = void 0;
  2796. var subm = void 0;
  2797. var metrics = options.fontMetrics();
  2798. var newOptions = void 0;
  2799. // Rule 18a
  2800. var supShift = 0;
  2801. var subShift = 0;
  2802. if (group.value.sup) {
  2803. newOptions = options.havingStyle(options.style.sup());
  2804. supm = buildGroup(group.value.sup, newOptions, options);
  2805. if (!isCharacterBox(group.value.base)) {
  2806. supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier;
  2807. }
  2808. }
  2809. if (group.value.sub) {
  2810. newOptions = options.havingStyle(options.style.sub());
  2811. subm = buildGroup(group.value.sub, newOptions, options);
  2812. if (!isCharacterBox(group.value.base)) {
  2813. subShift = base.depth + newOptions.fontMetrics().subDrop * newOptions.sizeMultiplier / options.sizeMultiplier;
  2814. }
  2815. }
  2816. // Rule 18c
  2817. var minSupShift = void 0;
  2818. if (options.style === _Style2.default.DISPLAY) {
  2819. minSupShift = metrics.sup1;
  2820. } else if (options.style.cramped) {
  2821. minSupShift = metrics.sup3;
  2822. } else {
  2823. minSupShift = metrics.sup2;
  2824. }
  2825. // scriptspace is a font-size-independent size, so scale it
  2826. // appropriately
  2827. var multiplier = options.sizeMultiplier;
  2828. var scriptspace = 0.5 / metrics.ptPerEm / multiplier + "em";
  2829. var supsub = void 0;
  2830. if (!group.value.sup) {
  2831. // Rule 18b
  2832. subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight);
  2833. var vlistElem = [{ type: "elem", elem: subm, marginRight: scriptspace }];
  2834. // Subscripts shouldn't be shifted by the base's italic correction.
  2835. // Account for that by shifting the subscript back the appropriate
  2836. // amount. Note we only do this when the base is a single symbol.
  2837. if (base instanceof _domTree2.default.symbolNode) {
  2838. vlistElem[0].marginLeft = -base.italic + "em";
  2839. }
  2840. supsub = _buildCommon2.default.makeVList(vlistElem, "shift", subShift, options);
  2841. } else if (!group.value.sub) {
  2842. // Rule 18c, d
  2843. supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight);
  2844. supsub = _buildCommon2.default.makeVList([{ type: "elem", elem: supm, marginRight: scriptspace }], "shift", -supShift, options);
  2845. } else {
  2846. supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight);
  2847. subShift = Math.max(subShift, metrics.sub2);
  2848. var ruleWidth = metrics.defaultRuleThickness;
  2849. // Rule 18e
  2850. if (supShift - supm.depth - (subm.height - subShift) < 4 * ruleWidth) {
  2851. subShift = 4 * ruleWidth - (supShift - supm.depth) + subm.height;
  2852. var psi = 0.8 * metrics.xHeight - (supShift - supm.depth);
  2853. if (psi > 0) {
  2854. supShift += psi;
  2855. subShift -= psi;
  2856. }
  2857. }
  2858. var _vlistElem = [{ type: "elem", elem: subm, shift: subShift, marginRight: scriptspace }, { type: "elem", elem: supm, shift: -supShift, marginRight: scriptspace }];
  2859. // See comment above about subscripts not being shifted
  2860. if (base instanceof _domTree2.default.symbolNode) {
  2861. _vlistElem[0].marginLeft = -base.italic + "em";
  2862. }
  2863. supsub = _buildCommon2.default.makeVList(_vlistElem, "individualShift", null, options);
  2864. }
  2865. // We ensure to wrap the supsub vlist in a span.msupsub to reset text-align
  2866. var mclass = getTypeOfDomTree(base) || "mord";
  2867. return (0, _buildCommon.makeSpan)([mclass], [base, (0, _buildCommon.makeSpan)(["msupsub"], [supsub])], options);
  2868. };
  2869. groupTypes.genfrac = function (group, options) {
  2870. // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e).
  2871. // Figure out what style this fraction should be in based on the
  2872. // function used
  2873. var style = options.style;
  2874. if (group.value.size === "display") {
  2875. style = _Style2.default.DISPLAY;
  2876. } else if (group.value.size === "text") {
  2877. style = _Style2.default.TEXT;
  2878. }
  2879. var nstyle = style.fracNum();
  2880. var dstyle = style.fracDen();
  2881. var newOptions = void 0;
  2882. newOptions = options.havingStyle(nstyle);
  2883. var numerm = buildGroup(group.value.numer, newOptions, options);
  2884. newOptions = options.havingStyle(dstyle);
  2885. var denomm = buildGroup(group.value.denom, newOptions, options);
  2886. var rule = void 0;
  2887. var ruleWidth = void 0;
  2888. var ruleSpacing = void 0;
  2889. if (group.value.hasBarLine) {
  2890. rule = makeLineSpan("frac-line", options);
  2891. ruleWidth = rule.height;
  2892. ruleSpacing = rule.height;
  2893. } else {
  2894. rule = null;
  2895. ruleWidth = 0;
  2896. ruleSpacing = options.fontMetrics().defaultRuleThickness;
  2897. }
  2898. // Rule 15b
  2899. var numShift = void 0;
  2900. var clearance = void 0;
  2901. var denomShift = void 0;
  2902. if (style.size === _Style2.default.DISPLAY.size) {
  2903. numShift = options.fontMetrics().num1;
  2904. if (ruleWidth > 0) {
  2905. clearance = 3 * ruleSpacing;
  2906. } else {
  2907. clearance = 7 * ruleSpacing;
  2908. }
  2909. denomShift = options.fontMetrics().denom1;
  2910. } else {
  2911. if (ruleWidth > 0) {
  2912. numShift = options.fontMetrics().num2;
  2913. clearance = ruleSpacing;
  2914. } else {
  2915. numShift = options.fontMetrics().num3;
  2916. clearance = 3 * ruleSpacing;
  2917. }
  2918. denomShift = options.fontMetrics().denom2;
  2919. }
  2920. var frac = void 0;
  2921. if (ruleWidth === 0) {
  2922. // Rule 15c
  2923. var candidateClearance = numShift - numerm.depth - (denomm.height - denomShift);
  2924. if (candidateClearance < clearance) {
  2925. numShift += 0.5 * (clearance - candidateClearance);
  2926. denomShift += 0.5 * (clearance - candidateClearance);
  2927. }
  2928. frac = _buildCommon2.default.makeVList([{ type: "elem", elem: denomm, shift: denomShift }, { type: "elem", elem: numerm, shift: -numShift }], "individualShift", null, options);
  2929. } else {
  2930. // Rule 15d
  2931. var axisHeight = options.fontMetrics().axisHeight;
  2932. if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) {
  2933. numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth));
  2934. }
  2935. if (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift) < clearance) {
  2936. denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift));
  2937. }
  2938. var midShift = -(axisHeight - 0.5 * ruleWidth);
  2939. frac = _buildCommon2.default.makeVList([{ type: "elem", elem: denomm, shift: denomShift }, { type: "elem", elem: rule, shift: midShift }, { type: "elem", elem: numerm, shift: -numShift }], "individualShift", null, options);
  2940. }
  2941. // Since we manually change the style sometimes (with \dfrac or \tfrac),
  2942. // account for the possible size change here.
  2943. newOptions = options.havingStyle(style);
  2944. frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier;
  2945. frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier;
  2946. // Rule 15e
  2947. var delimSize = void 0;
  2948. if (style.size === _Style2.default.DISPLAY.size) {
  2949. delimSize = options.fontMetrics().delim1;
  2950. } else {
  2951. delimSize = options.fontMetrics().delim2;
  2952. }
  2953. var leftDelim = void 0;
  2954. var rightDelim = void 0;
  2955. if (group.value.leftDelim == null) {
  2956. leftDelim = makeNullDelimiter(options, ["mopen"]);
  2957. } else {
  2958. leftDelim = _delimiter2.default.customSizedDelim(group.value.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]);
  2959. }
  2960. if (group.value.rightDelim == null) {
  2961. rightDelim = makeNullDelimiter(options, ["mclose"]);
  2962. } else {
  2963. rightDelim = _delimiter2.default.customSizedDelim(group.value.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]);
  2964. }
  2965. return (0, _buildCommon.makeSpan)(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, (0, _buildCommon.makeSpan)(["mfrac"], [frac]), rightDelim], options);
  2966. };
  2967. groupTypes.array = function (group, options) {
  2968. var r = void 0;
  2969. var c = void 0;
  2970. var nr = group.value.body.length;
  2971. var nc = 0;
  2972. var body = new Array(nr);
  2973. // Horizontal spacing
  2974. var pt = 1 / options.fontMetrics().ptPerEm;
  2975. var arraycolsep = 5 * pt; // \arraycolsep in article.cls
  2976. // Vertical spacing
  2977. var baselineskip = 12 * pt; // see size10.clo
  2978. // Default \jot from ltmath.dtx
  2979. // TODO(edemaine): allow overriding \jot via \setlength (#687)
  2980. var jot = 3 * pt;
  2981. // Default \arraystretch from lttab.dtx
  2982. // TODO(gagern): may get redefined once we have user-defined macros
  2983. var arraystretch = _utils2.default.deflt(group.value.arraystretch, 1);
  2984. var arrayskip = arraystretch * baselineskip;
  2985. var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and
  2986. var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx
  2987. var totalHeight = 0;
  2988. for (r = 0; r < group.value.body.length; ++r) {
  2989. var inrow = group.value.body[r];
  2990. var height = arstrutHeight; // \@array adds an \@arstrut
  2991. var depth = arstrutDepth; // to each tow (via the template)
  2992. if (nc < inrow.length) {
  2993. nc = inrow.length;
  2994. }
  2995. var outrow = new Array(inrow.length);
  2996. for (c = 0; c < inrow.length; ++c) {
  2997. var elt = buildGroup(inrow[c], options);
  2998. if (depth < elt.depth) {
  2999. depth = elt.depth;
  3000. }
  3001. if (height < elt.height) {
  3002. height = elt.height;
  3003. }
  3004. outrow[c] = elt;
  3005. }
  3006. var gap = 0;
  3007. if (group.value.rowGaps[r]) {
  3008. gap = _units2.default.calculateSize(group.value.rowGaps[r].value, options);
  3009. if (gap > 0) {
  3010. // \@argarraycr
  3011. gap += arstrutDepth;
  3012. if (depth < gap) {
  3013. depth = gap; // \@xargarraycr
  3014. }
  3015. gap = 0;
  3016. }
  3017. }
  3018. // In AMS multiline environments such as aligned and gathered, rows
  3019. // correspond to lines that have additional \jot added to the
  3020. // \baselineskip via \openup.
  3021. if (group.value.addJot) {
  3022. depth += jot;
  3023. }
  3024. outrow.height = height;
  3025. outrow.depth = depth;
  3026. totalHeight += height;
  3027. outrow.pos = totalHeight;
  3028. totalHeight += depth + gap; // \@yargarraycr
  3029. body[r] = outrow;
  3030. }
  3031. var offset = totalHeight / 2 + options.fontMetrics().axisHeight;
  3032. var colDescriptions = group.value.cols || [];
  3033. var cols = [];
  3034. var colSep = void 0;
  3035. var colDescrNum = void 0;
  3036. for (c = 0, colDescrNum = 0;
  3037. // Continue while either there are more columns or more column
  3038. // descriptions, so trailing separators don't get lost.
  3039. c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) {
  3040. var colDescr = colDescriptions[colDescrNum] || {};
  3041. var firstSeparator = true;
  3042. while (colDescr.type === "separator") {
  3043. // If there is more than one separator in a row, add a space
  3044. // between them.
  3045. if (!firstSeparator) {
  3046. colSep = (0, _buildCommon.makeSpan)(["arraycolsep"], []);
  3047. colSep.style.width = options.fontMetrics().doubleRuleSep + "em";
  3048. cols.push(colSep);
  3049. }
  3050. if (colDescr.separator === "|") {
  3051. var separator = (0, _buildCommon.makeSpan)(["vertical-separator"], []);
  3052. separator.style.height = totalHeight + "em";
  3053. separator.style.verticalAlign = -(totalHeight - offset) + "em";
  3054. cols.push(separator);
  3055. } else {
  3056. throw new _ParseError2.default("Invalid separator type: " + colDescr.separator);
  3057. }
  3058. colDescrNum++;
  3059. colDescr = colDescriptions[colDescrNum] || {};
  3060. firstSeparator = false;
  3061. }
  3062. if (c >= nc) {
  3063. continue;
  3064. }
  3065. var sepwidth = void 0;
  3066. if (c > 0 || group.value.hskipBeforeAndAfter) {
  3067. sepwidth = _utils2.default.deflt(colDescr.pregap, arraycolsep);
  3068. if (sepwidth !== 0) {
  3069. colSep = (0, _buildCommon.makeSpan)(["arraycolsep"], []);
  3070. colSep.style.width = sepwidth + "em";
  3071. cols.push(colSep);
  3072. }
  3073. }
  3074. var col = [];
  3075. for (r = 0; r < nr; ++r) {
  3076. var row = body[r];
  3077. var elem = row[c];
  3078. if (!elem) {
  3079. continue;
  3080. }
  3081. var shift = row.pos - offset;
  3082. elem.depth = row.depth;
  3083. elem.height = row.height;
  3084. col.push({ type: "elem", elem: elem, shift: shift });
  3085. }
  3086. col = _buildCommon2.default.makeVList(col, "individualShift", null, options);
  3087. col = (0, _buildCommon.makeSpan)(["col-align-" + (colDescr.align || "c")], [col]);
  3088. cols.push(col);
  3089. if (c < nc - 1 || group.value.hskipBeforeAndAfter) {
  3090. sepwidth = _utils2.default.deflt(colDescr.postgap, arraycolsep);
  3091. if (sepwidth !== 0) {
  3092. colSep = (0, _buildCommon.makeSpan)(["arraycolsep"], []);
  3093. colSep.style.width = sepwidth + "em";
  3094. cols.push(colSep);
  3095. }
  3096. }
  3097. }
  3098. body = (0, _buildCommon.makeSpan)(["mtable"], cols);
  3099. return (0, _buildCommon.makeSpan)(["mord"], [body], options);
  3100. };
  3101. groupTypes.spacing = function (group, options) {
  3102. if (group.value === "\\ " || group.value === "\\space" || group.value === " " || group.value === "~") {
  3103. // Spaces are generated by adding an actual space. Each of these
  3104. // things has an entry in the symbols table, so these will be turned
  3105. // into appropriate outputs.
  3106. if (group.mode === "text") {
  3107. return _buildCommon2.default.makeOrd(group, options, "textord");
  3108. } else {
  3109. return (0, _buildCommon.makeSpan)(["mspace"], [_buildCommon2.default.mathsym(group.value, group.mode, options)], options);
  3110. }
  3111. } else {
  3112. // Other kinds of spaces are of arbitrary width. We use CSS to
  3113. // generate these.
  3114. return (0, _buildCommon.makeSpan)(["mspace", _buildCommon2.default.spacingFunctions[group.value].className], [], options);
  3115. }
  3116. };
  3117. groupTypes.llap = function (group, options) {
  3118. var inner = (0, _buildCommon.makeSpan)(["inner"], [buildGroup(group.value.body, options)]);
  3119. var fix = (0, _buildCommon.makeSpan)(["fix"], []);
  3120. return (0, _buildCommon.makeSpan)(["mord", "llap"], [inner, fix], options);
  3121. };
  3122. groupTypes.rlap = function (group, options) {
  3123. var inner = (0, _buildCommon.makeSpan)(["inner"], [buildGroup(group.value.body, options)]);
  3124. var fix = (0, _buildCommon.makeSpan)(["fix"], []);
  3125. return (0, _buildCommon.makeSpan)(["mord", "rlap"], [inner, fix], options);
  3126. };
  3127. groupTypes.op = function (group, options) {
  3128. // Operators are handled in the TeXbook pg. 443-444, rule 13(a).
  3129. var supGroup = void 0;
  3130. var subGroup = void 0;
  3131. var hasLimits = false;
  3132. if (group.type === "supsub") {
  3133. // If we have limits, supsub will pass us its group to handle. Pull
  3134. // out the superscript and subscript and set the group to the op in
  3135. // its base.
  3136. supGroup = group.value.sup;
  3137. subGroup = group.value.sub;
  3138. group = group.value.base;
  3139. hasLimits = true;
  3140. }
  3141. var style = options.style;
  3142. // Most operators have a large successor symbol, but these don't.
  3143. var noSuccessor = ["\\smallint"];
  3144. var large = false;
  3145. if (style.size === _Style2.default.DISPLAY.size && group.value.symbol && !_utils2.default.contains(noSuccessor, group.value.body)) {
  3146. // Most symbol operators get larger in displaystyle (rule 13)
  3147. large = true;
  3148. }
  3149. var base = void 0;
  3150. if (group.value.symbol) {
  3151. // If this is a symbol, create the symbol.
  3152. var fontName = large ? "Size2-Regular" : "Size1-Regular";
  3153. base = _buildCommon2.default.makeSymbol(group.value.body, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]);
  3154. } else if (group.value.value) {
  3155. // If this is a list, compose that list.
  3156. var inner = buildExpression(group.value.value, options, true);
  3157. if (inner.length === 1 && inner[0] instanceof _domTree2.default.symbolNode) {
  3158. base = inner[0];
  3159. base.classes[0] = "mop"; // replace old mclass
  3160. } else {
  3161. base = (0, _buildCommon.makeSpan)(["mop"], inner, options);
  3162. }
  3163. } else {
  3164. // Otherwise, this is a text operator. Build the text from the
  3165. // operator's name.
  3166. // TODO(emily): Add a space in the middle of some of these
  3167. // operators, like \limsup
  3168. var output = [];
  3169. for (var i = 1; i < group.value.body.length; i++) {
  3170. output.push(_buildCommon2.default.mathsym(group.value.body[i], group.mode));
  3171. }
  3172. base = (0, _buildCommon.makeSpan)(["mop"], output, options);
  3173. }
  3174. // If content of op is a single symbol, shift it vertically.
  3175. var baseShift = 0;
  3176. var slant = 0;
  3177. if (base instanceof _domTree2.default.symbolNode) {
  3178. // Shift the symbol so its center lies on the axis (rule 13). It
  3179. // appears that our fonts have the centers of the symbols already
  3180. // almost on the axis, so these numbers are very small. Note we
  3181. // don't actually apply this here, but instead it is used either in
  3182. // the vlist creation or separately when there are no limits.
  3183. baseShift = (base.height - base.depth) / 2 - options.fontMetrics().axisHeight;
  3184. // The slant of the symbol is just its italic correction.
  3185. slant = base.italic;
  3186. }
  3187. if (hasLimits) {
  3188. // IE 8 clips \int if it is in a display: inline-block. We wrap it
  3189. // in a new span so it is an inline, and works.
  3190. base = (0, _buildCommon.makeSpan)([], [base]);
  3191. var supm = void 0;
  3192. var supKern = void 0;
  3193. var subm = void 0;
  3194. var subKern = void 0;
  3195. var newOptions = void 0;
  3196. // We manually have to handle the superscripts and subscripts. This,
  3197. // aside from the kern calculations, is copied from supsub.
  3198. if (supGroup) {
  3199. newOptions = options.havingStyle(style.sup());
  3200. supm = buildGroup(supGroup, newOptions, options);
  3201. supKern = Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - supm.depth);
  3202. }
  3203. if (subGroup) {
  3204. newOptions = options.havingStyle(style.sub());
  3205. subm = buildGroup(subGroup, newOptions, options);
  3206. subKern = Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - subm.height);
  3207. }
  3208. // Build the final group as a vlist of the possible subscript, base,
  3209. // and possible superscript.
  3210. var finalGroup = void 0;
  3211. var top = void 0;
  3212. var bottom = void 0;
  3213. if (!supGroup) {
  3214. top = base.height - baseShift;
  3215. // Shift the limits by the slant of the symbol. Note
  3216. // that we are supposed to shift the limits by 1/2 of the slant,
  3217. // but since we are centering the limits adding a full slant of
  3218. // margin will shift by 1/2 that.
  3219. finalGroup = _buildCommon2.default.makeVList([{ type: "kern", size: options.fontMetrics().bigOpSpacing5 }, { type: "elem", elem: subm, marginLeft: -slant + "em" }, { type: "kern", size: subKern }, { type: "elem", elem: base }], "top", top, options);
  3220. } else if (!subGroup) {
  3221. bottom = base.depth + baseShift;
  3222. finalGroup = _buildCommon2.default.makeVList([{ type: "elem", elem: base }, { type: "kern", size: supKern }, { type: "elem", elem: supm, marginLeft: slant + "em" }, { type: "kern", size: options.fontMetrics().bigOpSpacing5 }], "bottom", bottom, options);
  3223. } else if (!supGroup && !subGroup) {
  3224. // This case probably shouldn't occur (this would mean the
  3225. // supsub was sending us a group with no superscript or
  3226. // subscript) but be safe.
  3227. return base;
  3228. } else {
  3229. bottom = options.fontMetrics().bigOpSpacing5 + subm.height + subm.depth + subKern + base.depth + baseShift;
  3230. finalGroup = _buildCommon2.default.makeVList([{ type: "kern", size: options.fontMetrics().bigOpSpacing5 }, { type: "elem", elem: subm, marginLeft: -slant + "em" }, { type: "kern", size: subKern }, { type: "elem", elem: base }, { type: "kern", size: supKern }, { type: "elem", elem: supm, marginLeft: slant + "em" }, { type: "kern", size: options.fontMetrics().bigOpSpacing5 }], "bottom", bottom, options);
  3231. }
  3232. return (0, _buildCommon.makeSpan)(["mop", "op-limits"], [finalGroup], options);
  3233. } else {
  3234. if (baseShift) {
  3235. base.style.position = "relative";
  3236. base.style.top = baseShift + "em";
  3237. }
  3238. return base;
  3239. }
  3240. };
  3241. groupTypes.mod = function (group, options) {
  3242. var inner = [];
  3243. if (group.value.modType === "bmod") {
  3244. // “\nonscript\mskip-\medmuskip\mkern5mu”
  3245. if (!options.style.isTight()) {
  3246. inner.push((0, _buildCommon.makeSpan)(["mspace", "negativemediumspace"], [], options));
  3247. }
  3248. inner.push((0, _buildCommon.makeSpan)(["mspace", "thickspace"], [], options));
  3249. } else if (options.style.size === _Style2.default.DISPLAY.size) {
  3250. inner.push((0, _buildCommon.makeSpan)(["mspace", "quad"], [], options));
  3251. } else if (group.value.modType === "mod") {
  3252. inner.push((0, _buildCommon.makeSpan)(["mspace", "twelvemuspace"], [], options));
  3253. } else {
  3254. inner.push((0, _buildCommon.makeSpan)(["mspace", "eightmuspace"], [], options));
  3255. }
  3256. if (group.value.modType === "pod" || group.value.modType === "pmod") {
  3257. inner.push(_buildCommon2.default.mathsym("(", group.mode));
  3258. }
  3259. if (group.value.modType !== "pod") {
  3260. var modInner = [_buildCommon2.default.mathsym("m", group.mode), _buildCommon2.default.mathsym("o", group.mode), _buildCommon2.default.mathsym("d", group.mode)];
  3261. if (group.value.modType === "bmod") {
  3262. inner.push((0, _buildCommon.makeSpan)(["mbin"], modInner, options));
  3263. // “\mkern5mu\nonscript\mskip-\medmuskip”
  3264. inner.push((0, _buildCommon.makeSpan)(["mspace", "thickspace"], [], options));
  3265. if (!options.style.isTight()) {
  3266. inner.push((0, _buildCommon.makeSpan)(["mspace", "negativemediumspace"], [], options));
  3267. }
  3268. } else {
  3269. Array.prototype.push.apply(inner, modInner);
  3270. inner.push((0, _buildCommon.makeSpan)(["mspace", "sixmuspace"], [], options));
  3271. }
  3272. }
  3273. if (group.value.value) {
  3274. Array.prototype.push.apply(inner, buildExpression(group.value.value, options, false));
  3275. }
  3276. if (group.value.modType === "pod" || group.value.modType === "pmod") {
  3277. inner.push(_buildCommon2.default.mathsym(")", group.mode));
  3278. }
  3279. return _buildCommon2.default.makeFragment(inner);
  3280. };
  3281. groupTypes.katex = function (group, options) {
  3282. // The KaTeX logo. The offsets for the K and a were chosen to look
  3283. // good, but the offsets for the T, E, and X were taken from the
  3284. // definition of \TeX in TeX (see TeXbook pg. 356)
  3285. var k = (0, _buildCommon.makeSpan)(["k"], [_buildCommon2.default.mathsym("K", group.mode)], options);
  3286. var a = (0, _buildCommon.makeSpan)(["a"], [_buildCommon2.default.mathsym("A", group.mode)], options);
  3287. a.height = (a.height + 0.2) * 0.75;
  3288. a.depth = (a.height - 0.2) * 0.75;
  3289. var t = (0, _buildCommon.makeSpan)(["t"], [_buildCommon2.default.mathsym("T", group.mode)], options);
  3290. var e = (0, _buildCommon.makeSpan)(["e"], [_buildCommon2.default.mathsym("E", group.mode)], options);
  3291. e.height = e.height - 0.2155;
  3292. e.depth = e.depth + 0.2155;
  3293. var x = (0, _buildCommon.makeSpan)(["x"], [_buildCommon2.default.mathsym("X", group.mode)], options);
  3294. return (0, _buildCommon.makeSpan)(["mord", "katex-logo"], [k, a, t, e, x], options);
  3295. };
  3296. var makeLineSpan = function makeLineSpan(className, options, thickness) {
  3297. var line = (0, _buildCommon.makeSpan)([className], [], options);
  3298. line.height = thickness || options.fontMetrics().defaultRuleThickness;
  3299. line.style.borderBottomWidth = line.height + "em";
  3300. line.maxFontSize = 1.0;
  3301. return line;
  3302. };
  3303. groupTypes.overline = function (group, options) {
  3304. // Overlines are handled in the TeXbook pg 443, Rule 9.
  3305. // Build the inner group in the cramped style.
  3306. var innerGroup = buildGroup(group.value.body, options.havingCrampedStyle());
  3307. // Create the line above the body
  3308. var line = makeLineSpan("overline-line", options);
  3309. // Generate the vlist, with the appropriate kerns
  3310. var vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: innerGroup }, { type: "kern", size: 3 * line.height }, { type: "elem", elem: line }, { type: "kern", size: line.height }], "firstBaseline", null, options);
  3311. return (0, _buildCommon.makeSpan)(["mord", "overline"], [vlist], options);
  3312. };
  3313. groupTypes.underline = function (group, options) {
  3314. // Underlines are handled in the TeXbook pg 443, Rule 10.
  3315. // Build the inner group.
  3316. var innerGroup = buildGroup(group.value.body, options);
  3317. // Create the line above the body
  3318. var line = makeLineSpan("underline-line", options);
  3319. // Generate the vlist, with the appropriate kerns
  3320. var vlist = _buildCommon2.default.makeVList([{ type: "kern", size: line.height }, { type: "elem", elem: line }, { type: "kern", size: 3 * line.height }, { type: "elem", elem: innerGroup }], "top", innerGroup.height, options);
  3321. return (0, _buildCommon.makeSpan)(["mord", "underline"], [vlist], options);
  3322. };
  3323. groupTypes.sqrt = function (group, options) {
  3324. // Square roots are handled in the TeXbook pg. 443, Rule 11.
  3325. // First, we do the same steps as in overline to build the inner group
  3326. // and line
  3327. var inner = buildGroup(group.value.body, options.havingCrampedStyle());
  3328. // Some groups can return document fragments. Handle those by wrapping
  3329. // them in a span.
  3330. if (inner instanceof _domTree2.default.documentFragment) {
  3331. inner = (0, _buildCommon.makeSpan)([], [inner], options);
  3332. }
  3333. // Calculate the minimum size for the \surd delimiter
  3334. var metrics = options.fontMetrics();
  3335. var theta = metrics.defaultRuleThickness;
  3336. var phi = theta;
  3337. if (options.style.id < _Style2.default.TEXT.id) {
  3338. phi = options.fontMetrics().xHeight;
  3339. }
  3340. // Calculate the clearance between the body and line
  3341. var lineClearance = theta + phi / 4;
  3342. var minDelimiterHeight = (inner.height + inner.depth + lineClearance + theta) * options.sizeMultiplier;
  3343. // Create a sqrt SVG of the required minimum size
  3344. var img = _delimiter2.default.customSizedDelim("\\surd", minDelimiterHeight, false, options, group.mode);
  3345. // Calculate the actual line width.
  3346. // This actually should depend on the chosen font -- e.g. \boldmath
  3347. // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and
  3348. // have thicker rules.
  3349. var ruleWidth = options.fontMetrics().sqrtRuleThickness * img.sizeMultiplier;
  3350. var delimDepth = img.height - ruleWidth;
  3351. // Adjust the clearance based on the delimiter size
  3352. if (delimDepth > inner.height + inner.depth + lineClearance) {
  3353. lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2;
  3354. }
  3355. // Shift the sqrt image
  3356. var imgShift = img.height - inner.height - lineClearance - ruleWidth;
  3357. // We add a special case here, because even when `inner` is empty, we
  3358. // still get a line. So, we use a simple heuristic to decide if we
  3359. // should omit the body entirely. (note this doesn't work for something
  3360. // like `\sqrt{\rlap{x}}`, but if someone is doing that they deserve for
  3361. // it not to work.
  3362. var body = void 0;
  3363. if (inner.height === 0 && inner.depth === 0) {
  3364. body = (0, _buildCommon.makeSpan)();
  3365. } else {
  3366. inner.style.paddingLeft = img.surdWidth + "em";
  3367. // Overlay the image and the argument.
  3368. body = _buildCommon2.default.makeVList([{ type: "elem", elem: inner }, { type: "kern", size: -(inner.height + imgShift) }, { type: "elem", elem: img }, { type: "kern", size: ruleWidth }], "firstBaseline", null, options);
  3369. body.children[0].children[0].classes.push("svg-align");
  3370. }
  3371. if (!group.value.index) {
  3372. return (0, _buildCommon.makeSpan)(["mord", "sqrt"], [body], options);
  3373. } else {
  3374. // Handle the optional root index
  3375. // The index is always in scriptscript style
  3376. var newOptions = options.havingStyle(_Style2.default.SCRIPTSCRIPT);
  3377. var rootm = buildGroup(group.value.index, newOptions, options);
  3378. // The amount the index is shifted by. This is taken from the TeX
  3379. // source, in the definition of `\r@@t`.
  3380. var toShift = 0.6 * (body.height - body.depth);
  3381. // Build a VList with the superscript shifted up correctly
  3382. var rootVList = _buildCommon2.default.makeVList([{ type: "elem", elem: rootm }], "shift", -toShift, options);
  3383. // Add a class surrounding it so we can add on the appropriate
  3384. // kerning
  3385. var rootVListWrap = (0, _buildCommon.makeSpan)(["root"], [rootVList]);
  3386. return (0, _buildCommon.makeSpan)(["mord", "sqrt"], [rootVListWrap, body], options);
  3387. }
  3388. };
  3389. function sizingGroup(value, options, baseOptions) {
  3390. var inner = buildExpression(value, options, false);
  3391. var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier;
  3392. // Add size-resetting classes to the inner list and set maxFontSize
  3393. // manually. Handle nested size changes.
  3394. for (var i = 0; i < inner.length; i++) {
  3395. var pos = _utils2.default.indexOf(inner[i].classes, "sizing");
  3396. if (pos < 0) {
  3397. Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions));
  3398. } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) {
  3399. // This is a nested size change: e.g., inner[i] is the "b" in
  3400. // `\Huge a \small b`. Override the old size (the `reset-` class)
  3401. // but not the new size.
  3402. inner[i].classes[pos + 1] = "reset-size" + baseOptions.size;
  3403. }
  3404. inner[i].height *= multiplier;
  3405. inner[i].depth *= multiplier;
  3406. }
  3407. return _buildCommon2.default.makeFragment(inner);
  3408. }
  3409. groupTypes.sizing = function (group, options) {
  3410. // Handle sizing operators like \Huge. Real TeX doesn't actually allow
  3411. // these functions inside of math expressions, so we do some special
  3412. // handling.
  3413. var newOptions = options.havingSize(group.value.size);
  3414. return sizingGroup(group.value.value, newOptions, options);
  3415. };
  3416. groupTypes.styling = function (group, options) {
  3417. // Style changes are handled in the TeXbook on pg. 442, Rule 3.
  3418. // Figure out what style we're changing to.
  3419. var styleMap = {
  3420. "display": _Style2.default.DISPLAY,
  3421. "text": _Style2.default.TEXT,
  3422. "script": _Style2.default.SCRIPT,
  3423. "scriptscript": _Style2.default.SCRIPTSCRIPT
  3424. };
  3425. var newStyle = styleMap[group.value.style];
  3426. var newOptions = options.havingStyle(newStyle);
  3427. return sizingGroup(group.value.value, newOptions, options);
  3428. };
  3429. groupTypes.font = function (group, options) {
  3430. var font = group.value.font;
  3431. return buildGroup(group.value.body, options.withFont(font));
  3432. };
  3433. groupTypes.delimsizing = function (group, options) {
  3434. var delim = group.value.value;
  3435. if (delim === ".") {
  3436. // Empty delimiters still count as elements, even though they don't
  3437. // show anything.
  3438. return (0, _buildCommon.makeSpan)([group.value.mclass]);
  3439. }
  3440. // Use delimiter.sizedDelim to generate the delimiter.
  3441. return _delimiter2.default.sizedDelim(delim, group.value.size, options, group.mode, [group.value.mclass]);
  3442. };
  3443. groupTypes.leftright = function (group, options) {
  3444. // Build the inner expression
  3445. var inner = buildExpression(group.value.body, options, true);
  3446. var innerHeight = 0;
  3447. var innerDepth = 0;
  3448. var hadMiddle = false;
  3449. // Calculate its height and depth
  3450. for (var i = 0; i < inner.length; i++) {
  3451. if (inner[i].isMiddle) {
  3452. hadMiddle = true;
  3453. } else {
  3454. innerHeight = Math.max(inner[i].height, innerHeight);
  3455. innerDepth = Math.max(inner[i].depth, innerDepth);
  3456. }
  3457. }
  3458. // The size of delimiters is the same, regardless of what style we are
  3459. // in. Thus, to correctly calculate the size of delimiter we need around
  3460. // a group, we scale down the inner size based on the size.
  3461. innerHeight *= options.sizeMultiplier;
  3462. innerDepth *= options.sizeMultiplier;
  3463. var leftDelim = void 0;
  3464. if (group.value.left === ".") {
  3465. // Empty delimiters in \left and \right make null delimiter spaces.
  3466. leftDelim = makeNullDelimiter(options, ["mopen"]);
  3467. } else {
  3468. // Otherwise, use leftRightDelim to generate the correct sized
  3469. // delimiter.
  3470. leftDelim = _delimiter2.default.leftRightDelim(group.value.left, innerHeight, innerDepth, options, group.mode, ["mopen"]);
  3471. }
  3472. // Add it to the beginning of the expression
  3473. inner.unshift(leftDelim);
  3474. // Handle middle delimiters
  3475. if (hadMiddle) {
  3476. for (var _i4 = 1; _i4 < inner.length; _i4++) {
  3477. var middleDelim = inner[_i4];
  3478. if (middleDelim.isMiddle) {
  3479. // Apply the options that were active when \middle was called
  3480. inner[_i4] = _delimiter2.default.leftRightDelim(middleDelim.isMiddle.value, innerHeight, innerDepth, middleDelim.isMiddle.options, group.mode, []);
  3481. // Add back spaces shifted into the delimiter
  3482. var spaces = spliceSpaces(middleDelim.children, 0);
  3483. if (spaces) {
  3484. _buildCommon2.default.prependChildren(inner[_i4], spaces);
  3485. }
  3486. }
  3487. }
  3488. }
  3489. var rightDelim = void 0;
  3490. // Same for the right delimiter
  3491. if (group.value.right === ".") {
  3492. rightDelim = makeNullDelimiter(options, ["mclose"]);
  3493. } else {
  3494. rightDelim = _delimiter2.default.leftRightDelim(group.value.right, innerHeight, innerDepth, options, group.mode, ["mclose"]);
  3495. }
  3496. // Add it to the end of the expression.
  3497. inner.push(rightDelim);
  3498. return (0, _buildCommon.makeSpan)(["minner"], inner, options);
  3499. };
  3500. groupTypes.middle = function (group, options) {
  3501. var middleDelim = void 0;
  3502. if (group.value.value === ".") {
  3503. middleDelim = makeNullDelimiter(options, []);
  3504. } else {
  3505. middleDelim = _delimiter2.default.sizedDelim(group.value.value, 1, options, group.mode, []);
  3506. middleDelim.isMiddle = { value: group.value.value, options: options };
  3507. }
  3508. return middleDelim;
  3509. };
  3510. groupTypes.rule = function (group, options) {
  3511. // Make an empty span for the rule
  3512. var rule = (0, _buildCommon.makeSpan)(["mord", "rule"], [], options);
  3513. // Calculate the shift, width, and height of the rule, and account for units
  3514. var shift = 0;
  3515. if (group.value.shift) {
  3516. shift = _units2.default.calculateSize(group.value.shift, options);
  3517. }
  3518. var width = _units2.default.calculateSize(group.value.width, options);
  3519. var height = _units2.default.calculateSize(group.value.height, options);
  3520. // Style the rule to the right size
  3521. rule.style.borderRightWidth = width + "em";
  3522. rule.style.borderTopWidth = height + "em";
  3523. rule.style.bottom = shift + "em";
  3524. // Record the height and width
  3525. rule.width = width;
  3526. rule.height = height + shift;
  3527. rule.depth = -shift;
  3528. // Font size is the number large enough that the browser will
  3529. // reserve at least `absHeight` space above the baseline.
  3530. // The 1.125 factor was empirically determined
  3531. rule.maxFontSize = height * 1.125 * options.sizeMultiplier;
  3532. return rule;
  3533. };
  3534. groupTypes.kern = function (group, options) {
  3535. // Make an empty span for the rule
  3536. var rule = (0, _buildCommon.makeSpan)(["mord", "rule"], [], options);
  3537. if (group.value.dimension) {
  3538. var dimension = _units2.default.calculateSize(group.value.dimension, options);
  3539. rule.style.marginLeft = dimension + "em";
  3540. }
  3541. return rule;
  3542. };
  3543. groupTypes.accent = function (group, options) {
  3544. // Accents are handled in the TeXbook pg. 443, rule 12.
  3545. var base = group.value.base;
  3546. var supsubGroup = void 0;
  3547. if (group.type === "supsub") {
  3548. // If our base is a character box, and we have superscripts and
  3549. // subscripts, the supsub will defer to us. In particular, we want
  3550. // to attach the superscripts and subscripts to the inner body (so
  3551. // that the position of the superscripts and subscripts won't be
  3552. // affected by the height of the accent). We accomplish this by
  3553. // sticking the base of the accent into the base of the supsub, and
  3554. // rendering that, while keeping track of where the accent is.
  3555. // The supsub group is the group that was passed in
  3556. var supsub = group;
  3557. // The real accent group is the base of the supsub group
  3558. group = supsub.value.base;
  3559. // The character box is the base of the accent group
  3560. base = group.value.base;
  3561. // Stick the character box into the base of the supsub group
  3562. supsub.value.base = base;
  3563. // Rerender the supsub group with its new base, and store that
  3564. // result.
  3565. supsubGroup = buildGroup(supsub, options);
  3566. }
  3567. // Build the base group
  3568. var body = buildGroup(base, options.havingCrampedStyle());
  3569. // Does the accent need to shift for the skew of a character?
  3570. var mustShift = group.value.isShifty && isCharacterBox(base);
  3571. // Calculate the skew of the accent. This is based on the line "If the
  3572. // nucleus is not a single character, let s = 0; otherwise set s to the
  3573. // kern amount for the nucleus followed by the \skewchar of its font."
  3574. // Note that our skew metrics are just the kern between each character
  3575. // and the skewchar.
  3576. var skew = 0;
  3577. if (mustShift) {
  3578. // If the base is a character box, then we want the skew of the
  3579. // innermost character. To do that, we find the innermost character:
  3580. var baseChar = getBaseElem(base);
  3581. // Then, we render its group to get the symbol inside it
  3582. var baseGroup = buildGroup(baseChar, options.havingCrampedStyle());
  3583. // Finally, we pull the skew off of the symbol.
  3584. skew = baseGroup.skew;
  3585. // Note that we now throw away baseGroup, because the layers we
  3586. // removed with getBaseElem might contain things like \color which
  3587. // we can't get rid of.
  3588. // TODO(emily): Find a better way to get the skew
  3589. }
  3590. // calculate the amount of space between the body and the accent
  3591. var clearance = Math.min(body.height, options.fontMetrics().xHeight);
  3592. // Build the accent
  3593. var accentBody = void 0;
  3594. if (!group.value.isStretchy) {
  3595. var accent = _buildCommon2.default.makeSymbol(group.value.label, "Main-Regular", group.mode, options);
  3596. // Remove the italic correction of the accent, because it only serves to
  3597. // shift the accent over to a place we don't want.
  3598. accent.italic = 0;
  3599. // The \vec character that the fonts use is a combining character, and
  3600. // thus shows up much too far to the left. To account for this, we add a
  3601. // specific class which shifts the accent over to where we want it.
  3602. // TODO(emily): Fix this in a better way, like by changing the font
  3603. // Similarly, text accent \H is a combining character and
  3604. // requires a different adjustment.
  3605. var accentClass = null;
  3606. if (group.value.label === "\\vec") {
  3607. accentClass = "accent-vec";
  3608. } else if (group.value.label === '\\H') {
  3609. accentClass = "accent-hungarian";
  3610. }
  3611. accentBody = (0, _buildCommon.makeSpan)([], [accent]);
  3612. accentBody = (0, _buildCommon.makeSpan)(["accent-body", accentClass], [accentBody]);
  3613. // Shift the accent over by the skew. Note we shift by twice the skew
  3614. // because we are centering the accent, so by adding 2*skew to the left,
  3615. // we shift it to the right by 1*skew.
  3616. accentBody.style.marginLeft = 2 * skew + "em";
  3617. accentBody = _buildCommon2.default.makeVList([{ type: "elem", elem: body }, { type: "kern", size: -clearance }, { type: "elem", elem: accentBody }], "firstBaseline", null, options);
  3618. } else {
  3619. accentBody = _stretchy2.default.svgSpan(group, options);
  3620. accentBody = _buildCommon2.default.makeVList([{ type: "elem", elem: body }, { type: "elem", elem: accentBody }], "firstBaseline", null, options);
  3621. var styleSpan = accentBody.children[0].children[0].children[1];
  3622. styleSpan.classes.push("svg-align"); // text-align: left;
  3623. if (skew > 0) {
  3624. // Shorten the accent and nudge it to the right.
  3625. styleSpan.style.width = "calc(100% - " + 2 * skew + "em)";
  3626. styleSpan.style.marginLeft = 2 * skew + "em";
  3627. }
  3628. }
  3629. var accentWrap = (0, _buildCommon.makeSpan)(["mord", "accent"], [accentBody], options);
  3630. if (supsubGroup) {
  3631. // Here, we replace the "base" child of the supsub with our newly
  3632. // generated accent.
  3633. supsubGroup.children[0] = accentWrap;
  3634. // Since we don't rerun the height calculation after replacing the
  3635. // accent, we manually recalculate height.
  3636. supsubGroup.height = Math.max(accentWrap.height, supsubGroup.height);
  3637. // Accents should always be ords, even when their innards are not.
  3638. supsubGroup.classes[0] = "mord";
  3639. return supsubGroup;
  3640. } else {
  3641. return accentWrap;
  3642. }
  3643. };
  3644. groupTypes.horizBrace = function (group, options) {
  3645. var style = options.style;
  3646. var hasSupSub = group.type === "supsub";
  3647. var supSubGroup = void 0;
  3648. var newOptions = void 0;
  3649. if (hasSupSub) {
  3650. // Ref: LaTeX source2e: }}}}\limits}
  3651. // i.e. LaTeX treats the brace similar to an op and passes it
  3652. // with \limits, so we need to assign supsub style.
  3653. if (group.value.sup) {
  3654. newOptions = options.havingStyle(style.sup());
  3655. supSubGroup = buildGroup(group.value.sup, newOptions, options);
  3656. } else {
  3657. newOptions = options.havingStyle(style.sub());
  3658. supSubGroup = buildGroup(group.value.sub, newOptions, options);
  3659. }
  3660. group = group.value.base;
  3661. }
  3662. // Build the base group
  3663. var body = buildGroup(group.value.base, options.havingBaseStyle(_Style2.default.DISPLAY));
  3664. // Create the stretchy element
  3665. var braceBody = _stretchy2.default.svgSpan(group, options);
  3666. // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓
  3667. // This first vlist contains the subject matter and the brace: equation
  3668. var vlist = void 0;
  3669. if (group.value.isOver) {
  3670. vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: body }, { type: "kern", size: 0.1 }, { type: "elem", elem: braceBody }], "firstBaseline", null, options);
  3671. vlist.children[0].children[0].children[1].classes.push("svg-align");
  3672. } else {
  3673. vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: braceBody }, { type: "kern", size: 0.1 }, { type: "elem", elem: body }], "bottom", body.depth + 0.1 + braceBody.height, options);
  3674. vlist.children[0].children[0].children[0].classes.push("svg-align");
  3675. }
  3676. if (hasSupSub) {
  3677. // In order to write the supsub, wrap the first vlist in another vlist:
  3678. // They can't all go in the same vlist, because the note might be wider
  3679. // than the equation. We want the equation to control the brace width.
  3680. // note long note long note
  3681. // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓
  3682. // equation eqn eqn
  3683. var vSpan = (0, _buildCommon.makeSpan)(["mord", group.value.isOver ? "mover" : "munder"], [vlist], options);
  3684. if (group.value.isOver) {
  3685. vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: vSpan }, { type: "kern", size: 0.2 }, { type: "elem", elem: supSubGroup }], "firstBaseline", null, options);
  3686. } else {
  3687. vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: supSubGroup }, { type: "kern", size: 0.2 }, { type: "elem", elem: vSpan }], "bottom", vSpan.depth + 0.2 + supSubGroup.height, options);
  3688. }
  3689. }
  3690. return (0, _buildCommon.makeSpan)(["mord", group.value.isOver ? "mover" : "munder"], [vlist], options);
  3691. };
  3692. groupTypes.accentUnder = function (group, options) {
  3693. // Treat under accents much like underlines.
  3694. var innerGroup = buildGroup(group.value.body, options);
  3695. var accentBody = _stretchy2.default.svgSpan(group, options);
  3696. var kern = /tilde/.test(group.value.label) ? 0.12 : 0;
  3697. // Generate the vlist, with the appropriate kerns
  3698. var vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: accentBody }, { type: "kern", size: kern }, { type: "elem", elem: innerGroup }], "bottom", accentBody.height + kern, options);
  3699. vlist.children[0].children[0].children[0].classes.push("svg-align");
  3700. return (0, _buildCommon.makeSpan)(["mord", "accentunder"], [vlist], options);
  3701. };
  3702. groupTypes.enclose = function (group, options) {
  3703. // \cancel, \bcancel, \xcancel, \sout, \fbox
  3704. var inner = buildGroup(group.value.body, options);
  3705. var label = group.value.label.substr(1);
  3706. var scale = options.sizeMultiplier;
  3707. var img = void 0;
  3708. var pad = 0;
  3709. var imgShift = 0;
  3710. if (label === "sout") {
  3711. img = (0, _buildCommon.makeSpan)(["stretchy", "sout"]);
  3712. img.height = options.fontMetrics().defaultRuleThickness / scale;
  3713. imgShift = -0.5 * options.fontMetrics().xHeight;
  3714. } else {
  3715. // Add horizontal padding
  3716. inner.classes.push(label === "fbox" ? "boxpad" : "cancel-pad");
  3717. // Add vertical padding
  3718. var isCharBox = isCharacterBox(group.value.body);
  3719. // ref: LaTeX source2e: \fboxsep = 3pt; \fboxrule = .4pt
  3720. // ref: cancel package: \advance\totalheight2\p@ % "+2"
  3721. pad = label === "fbox" ? 0.34 : isCharBox ? 0.2 : 0;
  3722. imgShift = inner.depth + pad;
  3723. img = _stretchy2.default.encloseSpan(inner, label, pad, options);
  3724. }
  3725. var vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: inner, shift: 0 }, { type: "elem", elem: img, shift: imgShift }], "individualShift", null, options);
  3726. if (label !== "fbox") {
  3727. vlist.children[0].children[0].children[1].classes.push("svg-align");
  3728. }
  3729. if (/cancel/.test(label)) {
  3730. // cancel does not create horiz space for its line extension.
  3731. // That is, not when adjacent to a mord.
  3732. return (0, _buildCommon.makeSpan)(["mord", "cancel-lap"], [vlist], options);
  3733. } else {
  3734. return (0, _buildCommon.makeSpan)(["mord"], [vlist], options);
  3735. }
  3736. };
  3737. groupTypes.xArrow = function (group, options) {
  3738. var style = options.style;
  3739. // Build the argument groups in the appropriate style.
  3740. // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}%
  3741. var newOptions = options.havingStyle(style.sup());
  3742. var upperGroup = buildGroup(group.value.body, newOptions, options);
  3743. upperGroup.classes.push("x-arrow-pad");
  3744. var lowerGroup = void 0;
  3745. if (group.value.below) {
  3746. // Build the lower group
  3747. newOptions = options.havingStyle(style.sub());
  3748. lowerGroup = buildGroup(group.value.below, newOptions, options);
  3749. lowerGroup.classes.push("x-arrow-pad");
  3750. }
  3751. var arrowBody = _stretchy2.default.svgSpan(group, options);
  3752. var arrowShift = -options.fontMetrics().axisHeight + arrowBody.depth;
  3753. var upperShift = -options.fontMetrics().axisHeight - arrowBody.height - 0.111; // 2 mu. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi
  3754. // Generate the vlist
  3755. var vlist = void 0;
  3756. if (group.value.below) {
  3757. var lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + arrowBody.height + 0.111;
  3758. vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: upperGroup, shift: upperShift }, { type: "elem", elem: arrowBody, shift: arrowShift }, { type: "elem", elem: lowerGroup, shift: lowerShift }], "individualShift", null, options);
  3759. } else {
  3760. vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: upperGroup, shift: upperShift }, { type: "elem", elem: arrowBody, shift: arrowShift }], "individualShift", null, options);
  3761. }
  3762. vlist.children[0].children[0].children[1].classes.push("svg-align");
  3763. return (0, _buildCommon.makeSpan)(["mrel", "x-arrow"], [vlist], options);
  3764. };
  3765. groupTypes.phantom = function (group, options) {
  3766. var elements = buildExpression(group.value.value, options.withPhantom(), false);
  3767. // \phantom isn't supposed to affect the elements it contains.
  3768. // See "color" for more details.
  3769. return new _buildCommon2.default.makeFragment(elements);
  3770. };
  3771. groupTypes.mclass = function (group, options) {
  3772. var elements = buildExpression(group.value.value, options, true);
  3773. return (0, _buildCommon.makeSpan)([group.value.mclass], elements, options);
  3774. };
  3775. /**
  3776. * buildGroup is the function that takes a group and calls the correct groupType
  3777. * function for it. It also handles the interaction of size and style changes
  3778. * between parents and children.
  3779. */
  3780. var buildGroup = function buildGroup(group, options, baseOptions) {
  3781. if (!group) {
  3782. return (0, _buildCommon.makeSpan)();
  3783. }
  3784. if (groupTypes[group.type]) {
  3785. // Call the groupTypes function
  3786. var groupNode = groupTypes[group.type](group, options);
  3787. // If the size changed between the parent and the current group, account
  3788. // for that size difference.
  3789. if (baseOptions && options.size !== baseOptions.size) {
  3790. groupNode = (0, _buildCommon.makeSpan)(options.sizingClasses(baseOptions), [groupNode], options);
  3791. var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier;
  3792. groupNode.height *= multiplier;
  3793. groupNode.depth *= multiplier;
  3794. }
  3795. return groupNode;
  3796. } else {
  3797. throw new _ParseError2.default("Got group of unknown type: '" + group.type + "'");
  3798. }
  3799. };
  3800. /**
  3801. * Take an entire parse tree, and build it into an appropriate set of HTML
  3802. * nodes.
  3803. */
  3804. var buildHTML = function buildHTML(tree, options) {
  3805. // buildExpression is destructive, so we need to make a clone
  3806. // of the incoming tree so that it isn't accidentally changed
  3807. tree = JSON.parse((0, _stringify2.default)(tree));
  3808. // Build the expression contained in the tree
  3809. var expression = buildExpression(tree, options, true);
  3810. var body = (0, _buildCommon.makeSpan)(["base"], expression, options);
  3811. // Add struts, which ensure that the top of the HTML element falls at the
  3812. // height of the expression, and the bottom of the HTML element falls at the
  3813. // depth of the expression.
  3814. var topStrut = (0, _buildCommon.makeSpan)(["strut"]);
  3815. var bottomStrut = (0, _buildCommon.makeSpan)(["strut", "bottom"]);
  3816. topStrut.style.height = body.height + "em";
  3817. bottomStrut.style.height = body.height + body.depth + "em";
  3818. // We'd like to use `vertical-align: top` but in IE 9 this lowers the
  3819. // baseline of the box to the bottom of this strut (instead staying in the
  3820. // normal place) so we use an absolute value for vertical-align instead
  3821. bottomStrut.style.verticalAlign = -body.depth + "em";
  3822. // Wrap the struts and body together
  3823. var htmlNode = (0, _buildCommon.makeSpan)(["katex-html"], [topStrut, bottomStrut, body]);
  3824. htmlNode.setAttribute("aria-hidden", "true");
  3825. return htmlNode;
  3826. };
  3827. module.exports = buildHTML;
  3828. },{"./ParseError":29,"./Style":33,"./buildCommon":34,"./delimiter":38,"./domTree":39,"./stretchy":47,"./units":50,"./utils":51,"babel-runtime/core-js/json/stringify":2}],36:[function(require,module,exports){
  3829. "use strict";
  3830. var _buildCommon = require("./buildCommon");
  3831. var _buildCommon2 = _interopRequireDefault(_buildCommon);
  3832. var _fontMetrics = require("./fontMetrics");
  3833. var _fontMetrics2 = _interopRequireDefault(_fontMetrics);
  3834. var _mathMLTree = require("./mathMLTree");
  3835. var _mathMLTree2 = _interopRequireDefault(_mathMLTree);
  3836. var _ParseError = require("./ParseError");
  3837. var _ParseError2 = _interopRequireDefault(_ParseError);
  3838. var _Style = require("./Style");
  3839. var _Style2 = _interopRequireDefault(_Style);
  3840. var _symbols = require("./symbols");
  3841. var _symbols2 = _interopRequireDefault(_symbols);
  3842. var _utils = require("./utils");
  3843. var _utils2 = _interopRequireDefault(_utils);
  3844. var _stretchy = require("./stretchy");
  3845. var _stretchy2 = _interopRequireDefault(_stretchy);
  3846. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3847. /**
  3848. * Takes a symbol and converts it into a MathML text node after performing
  3849. * optional replacement from symbols.js.
  3850. */
  3851. /**
  3852. * This file converts a parse tree into a cooresponding MathML tree. The main
  3853. * entry point is the `buildMathML` function, which takes a parse tree from the
  3854. * parser.
  3855. */
  3856. var makeText = function makeText(text, mode) {
  3857. if (_symbols2.default[mode][text] && _symbols2.default[mode][text].replace) {
  3858. text = _symbols2.default[mode][text].replace;
  3859. }
  3860. return new _mathMLTree2.default.TextNode(text);
  3861. };
  3862. /**
  3863. * Returns the math variant as a string or null if none is required.
  3864. */
  3865. var getVariant = function getVariant(group, options) {
  3866. var font = options.font;
  3867. if (!font) {
  3868. return null;
  3869. }
  3870. var mode = group.mode;
  3871. if (font === "mathit") {
  3872. return "italic";
  3873. }
  3874. var value = group.value;
  3875. if (_utils2.default.contains(["\\imath", "\\jmath"], value)) {
  3876. return null;
  3877. }
  3878. if (_symbols2.default[mode][value] && _symbols2.default[mode][value].replace) {
  3879. value = _symbols2.default[mode][value].replace;
  3880. }
  3881. var fontName = _buildCommon.fontMap[font].fontName;
  3882. if (_fontMetrics2.default.getCharacterMetrics(value, fontName)) {
  3883. return _buildCommon.fontMap[options.font].variant;
  3884. }
  3885. return null;
  3886. };
  3887. /**
  3888. * Functions for handling the different types of groups found in the parse
  3889. * tree. Each function should take a parse group and return a MathML node.
  3890. */
  3891. var groupTypes = {};
  3892. var defaultVariant = {
  3893. "mi": "italic",
  3894. "mn": "normal",
  3895. "mtext": "normal"
  3896. };
  3897. groupTypes.mathord = function (group, options) {
  3898. var node = new _mathMLTree2.default.MathNode("mi", [makeText(group.value, group.mode)]);
  3899. var variant = getVariant(group, options) || "italic";
  3900. if (variant !== defaultVariant[node.type]) {
  3901. node.setAttribute("mathvariant", variant);
  3902. }
  3903. return node;
  3904. };
  3905. groupTypes.textord = function (group, options) {
  3906. var text = makeText(group.value, group.mode);
  3907. var variant = getVariant(group, options) || "normal";
  3908. var node = void 0;
  3909. if (group.mode === 'text') {
  3910. node = new _mathMLTree2.default.MathNode("mtext", [text]);
  3911. } else if (/[0-9]/.test(group.value)) {
  3912. // TODO(kevinb) merge adjacent <mn> nodes
  3913. // do it as a post processing step
  3914. node = new _mathMLTree2.default.MathNode("mn", [text]);
  3915. } else if (group.value === "\\prime") {
  3916. node = new _mathMLTree2.default.MathNode("mo", [text]);
  3917. } else {
  3918. node = new _mathMLTree2.default.MathNode("mi", [text]);
  3919. }
  3920. if (variant !== defaultVariant[node.type]) {
  3921. node.setAttribute("mathvariant", variant);
  3922. }
  3923. return node;
  3924. };
  3925. groupTypes.bin = function (group) {
  3926. var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]);
  3927. return node;
  3928. };
  3929. groupTypes.rel = function (group) {
  3930. var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]);
  3931. return node;
  3932. };
  3933. groupTypes.open = function (group) {
  3934. var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]);
  3935. return node;
  3936. };
  3937. groupTypes.close = function (group) {
  3938. var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]);
  3939. return node;
  3940. };
  3941. groupTypes.inner = function (group) {
  3942. var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]);
  3943. return node;
  3944. };
  3945. groupTypes.punct = function (group) {
  3946. var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]);
  3947. node.setAttribute("separator", "true");
  3948. return node;
  3949. };
  3950. groupTypes.ordgroup = function (group, options) {
  3951. var inner = buildExpression(group.value, options);
  3952. var node = new _mathMLTree2.default.MathNode("mrow", inner);
  3953. return node;
  3954. };
  3955. groupTypes.text = function (group, options) {
  3956. var body = group.value.body;
  3957. // Convert each element of the body into MathML, and combine consecutive
  3958. // <mtext> outputs into a single <mtext> tag. In this way, we don't
  3959. // nest non-text items (e.g., $nested-math$) within an <mtext>.
  3960. var inner = [];
  3961. var currentText = null;
  3962. for (var i = 0; i < body.length; i++) {
  3963. var _group = buildGroup(body[i], options);
  3964. if (_group.type === 'mtext' && currentText != null) {
  3965. Array.prototype.push.apply(currentText.children, _group.children);
  3966. } else {
  3967. inner.push(_group);
  3968. if (_group.type === 'mtext') {
  3969. currentText = _group;
  3970. }
  3971. }
  3972. }
  3973. // If there is a single tag in the end (presumably <mtext>),
  3974. // just return it. Otherwise, wrap them in an <mrow>.
  3975. if (inner.length === 1) {
  3976. return inner[0];
  3977. } else {
  3978. return new _mathMLTree2.default.MathNode("mrow", inner);
  3979. }
  3980. };
  3981. groupTypes.color = function (group, options) {
  3982. var inner = buildExpression(group.value.value, options);
  3983. var node = new _mathMLTree2.default.MathNode("mstyle", inner);
  3984. node.setAttribute("mathcolor", group.value.color);
  3985. return node;
  3986. };
  3987. groupTypes.supsub = function (group, options) {
  3988. // Is the inner group a relevant horizonal brace?
  3989. var isBrace = false;
  3990. var isOver = void 0;
  3991. var isSup = void 0;
  3992. if (group.value.base) {
  3993. if (group.value.base.value.type === "horizBrace") {
  3994. isSup = group.value.sup ? true : false;
  3995. if (isSup === group.value.base.value.isOver) {
  3996. isBrace = true;
  3997. isOver = group.value.base.value.isOver;
  3998. }
  3999. }
  4000. }
  4001. var removeUnnecessaryRow = true;
  4002. var children = [buildGroup(group.value.base, options, removeUnnecessaryRow)];
  4003. if (group.value.sub) {
  4004. children.push(buildGroup(group.value.sub, options, removeUnnecessaryRow));
  4005. }
  4006. if (group.value.sup) {
  4007. children.push(buildGroup(group.value.sup, options, removeUnnecessaryRow));
  4008. }
  4009. var nodeType = void 0;
  4010. if (isBrace) {
  4011. nodeType = isOver ? "mover" : "munder";
  4012. } else if (!group.value.sub) {
  4013. nodeType = "msup";
  4014. } else if (!group.value.sup) {
  4015. nodeType = "msub";
  4016. } else {
  4017. var base = group.value.base;
  4018. if (base && base.value.limits && options.style === _Style2.default.DISPLAY) {
  4019. nodeType = "munderover";
  4020. } else {
  4021. nodeType = "msubsup";
  4022. }
  4023. }
  4024. var node = new _mathMLTree2.default.MathNode(nodeType, children);
  4025. return node;
  4026. };
  4027. groupTypes.genfrac = function (group, options) {
  4028. var node = new _mathMLTree2.default.MathNode("mfrac", [buildGroup(group.value.numer, options), buildGroup(group.value.denom, options)]);
  4029. if (!group.value.hasBarLine) {
  4030. node.setAttribute("linethickness", "0px");
  4031. }
  4032. if (group.value.leftDelim != null || group.value.rightDelim != null) {
  4033. var withDelims = [];
  4034. if (group.value.leftDelim != null) {
  4035. var leftOp = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode(group.value.leftDelim)]);
  4036. leftOp.setAttribute("fence", "true");
  4037. withDelims.push(leftOp);
  4038. }
  4039. withDelims.push(node);
  4040. if (group.value.rightDelim != null) {
  4041. var rightOp = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode(group.value.rightDelim)]);
  4042. rightOp.setAttribute("fence", "true");
  4043. withDelims.push(rightOp);
  4044. }
  4045. var outerNode = new _mathMLTree2.default.MathNode("mrow", withDelims);
  4046. return outerNode;
  4047. }
  4048. return node;
  4049. };
  4050. groupTypes.array = function (group, options) {
  4051. return new _mathMLTree2.default.MathNode("mtable", group.value.body.map(function (row) {
  4052. return new _mathMLTree2.default.MathNode("mtr", row.map(function (cell) {
  4053. return new _mathMLTree2.default.MathNode("mtd", [buildGroup(cell, options)]);
  4054. }));
  4055. }));
  4056. };
  4057. groupTypes.sqrt = function (group, options) {
  4058. var node = void 0;
  4059. if (group.value.index) {
  4060. node = new _mathMLTree2.default.MathNode("mroot", [buildGroup(group.value.body, options), buildGroup(group.value.index, options)]);
  4061. } else {
  4062. node = new _mathMLTree2.default.MathNode("msqrt", [buildGroup(group.value.body, options)]);
  4063. }
  4064. return node;
  4065. };
  4066. groupTypes.leftright = function (group, options) {
  4067. var inner = buildExpression(group.value.body, options);
  4068. if (group.value.left !== ".") {
  4069. var leftNode = new _mathMLTree2.default.MathNode("mo", [makeText(group.value.left, group.mode)]);
  4070. leftNode.setAttribute("fence", "true");
  4071. inner.unshift(leftNode);
  4072. }
  4073. if (group.value.right !== ".") {
  4074. var rightNode = new _mathMLTree2.default.MathNode("mo", [makeText(group.value.right, group.mode)]);
  4075. rightNode.setAttribute("fence", "true");
  4076. inner.push(rightNode);
  4077. }
  4078. var outerNode = new _mathMLTree2.default.MathNode("mrow", inner);
  4079. return outerNode;
  4080. };
  4081. groupTypes.middle = function (group, options) {
  4082. var middleNode = new _mathMLTree2.default.MathNode("mo", [makeText(group.value.middle, group.mode)]);
  4083. middleNode.setAttribute("fence", "true");
  4084. return middleNode;
  4085. };
  4086. groupTypes.accent = function (group, options) {
  4087. var accentNode = void 0;
  4088. if (group.value.isStretchy) {
  4089. accentNode = _stretchy2.default.mathMLnode(group.value.label);
  4090. } else {
  4091. accentNode = new _mathMLTree2.default.MathNode("mo", [makeText(group.value.label, group.mode)]);
  4092. }
  4093. var node = new _mathMLTree2.default.MathNode("mover", [buildGroup(group.value.base, options), accentNode]);
  4094. node.setAttribute("accent", "true");
  4095. return node;
  4096. };
  4097. groupTypes.spacing = function (group) {
  4098. var node = void 0;
  4099. if (group.value === "\\ " || group.value === "\\space" || group.value === " " || group.value === "~") {
  4100. node = new _mathMLTree2.default.MathNode("mtext", [new _mathMLTree2.default.TextNode("\xA0")]);
  4101. } else {
  4102. node = new _mathMLTree2.default.MathNode("mspace");
  4103. node.setAttribute("width", _buildCommon2.default.spacingFunctions[group.value].size);
  4104. }
  4105. return node;
  4106. };
  4107. groupTypes.op = function (group, options) {
  4108. var node = void 0;
  4109. // TODO(emily): handle big operators using the `largeop` attribute
  4110. if (group.value.symbol) {
  4111. // This is a symbol. Just add the symbol.
  4112. node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value.body, group.mode)]);
  4113. } else if (group.value.value) {
  4114. // This is an operator with children. Add them.
  4115. node = new _mathMLTree2.default.MathNode("mo", buildExpression(group.value.value, options));
  4116. } else {
  4117. // This is a text operator. Add all of the characters from the
  4118. // operator's name.
  4119. // TODO(emily): Add a space in the middle of some of these
  4120. // operators, like \limsup.
  4121. node = new _mathMLTree2.default.MathNode("mi", [new _mathMLTree2.default.TextNode(group.value.body.slice(1))]);
  4122. }
  4123. return node;
  4124. };
  4125. groupTypes.mod = function (group, options) {
  4126. var inner = [];
  4127. if (group.value.modType === "pod" || group.value.modType === "pmod") {
  4128. inner.push(new _mathMLTree2.default.MathNode("mo", [makeText("(", group.mode)]));
  4129. }
  4130. if (group.value.modType !== "pod") {
  4131. inner.push(new _mathMLTree2.default.MathNode("mo", [makeText("mod", group.mode)]));
  4132. }
  4133. if (group.value.value) {
  4134. var space = new _mathMLTree2.default.MathNode("mspace");
  4135. space.setAttribute("width", "0.333333em");
  4136. inner.push(space);
  4137. inner = inner.concat(buildExpression(group.value.value, options));
  4138. }
  4139. if (group.value.modType === "pod" || group.value.modType === "pmod") {
  4140. inner.push(new _mathMLTree2.default.MathNode("mo", [makeText(")", group.mode)]));
  4141. }
  4142. return new _mathMLTree2.default.MathNode("mo", inner);
  4143. };
  4144. groupTypes.katex = function (group) {
  4145. var node = new _mathMLTree2.default.MathNode("mtext", [new _mathMLTree2.default.TextNode("KaTeX")]);
  4146. return node;
  4147. };
  4148. groupTypes.font = function (group, options) {
  4149. var font = group.value.font;
  4150. return buildGroup(group.value.body, options.withFont(font));
  4151. };
  4152. groupTypes.delimsizing = function (group) {
  4153. var children = [];
  4154. if (group.value.value !== ".") {
  4155. children.push(makeText(group.value.value, group.mode));
  4156. }
  4157. var node = new _mathMLTree2.default.MathNode("mo", children);
  4158. if (group.value.mclass === "mopen" || group.value.mclass === "mclose") {
  4159. // Only some of the delimsizing functions act as fences, and they
  4160. // return "mopen" or "mclose" mclass.
  4161. node.setAttribute("fence", "true");
  4162. } else {
  4163. // Explicitly disable fencing if it's not a fence, to override the
  4164. // defaults.
  4165. node.setAttribute("fence", "false");
  4166. }
  4167. return node;
  4168. };
  4169. groupTypes.styling = function (group, options) {
  4170. // Figure out what style we're changing to.
  4171. // TODO(kevinb): dedupe this with buildHTML.js
  4172. // This will be easier of handling of styling nodes is in the same file.
  4173. var styleMap = {
  4174. "display": _Style2.default.DISPLAY,
  4175. "text": _Style2.default.TEXT,
  4176. "script": _Style2.default.SCRIPT,
  4177. "scriptscript": _Style2.default.SCRIPTSCRIPT
  4178. };
  4179. var newStyle = styleMap[group.value.style];
  4180. var newOptions = options.havingStyle(newStyle);
  4181. var inner = buildExpression(group.value.value, newOptions);
  4182. var node = new _mathMLTree2.default.MathNode("mstyle", inner);
  4183. var styleAttributes = {
  4184. "display": ["0", "true"],
  4185. "text": ["0", "false"],
  4186. "script": ["1", "false"],
  4187. "scriptscript": ["2", "false"]
  4188. };
  4189. var attr = styleAttributes[group.value.style];
  4190. node.setAttribute("scriptlevel", attr[0]);
  4191. node.setAttribute("displaystyle", attr[1]);
  4192. return node;
  4193. };
  4194. groupTypes.sizing = function (group, options) {
  4195. var newOptions = options.havingSize(group.value.size);
  4196. var inner = buildExpression(group.value.value, newOptions);
  4197. var node = new _mathMLTree2.default.MathNode("mstyle", inner);
  4198. // TODO(emily): This doesn't produce the correct size for nested size
  4199. // changes, because we don't keep state of what style we're currently
  4200. // in, so we can't reset the size to normal before changing it. Now
  4201. // that we're passing an options parameter we should be able to fix
  4202. // this.
  4203. node.setAttribute("mathsize", newOptions.sizeMultiplier + "em");
  4204. return node;
  4205. };
  4206. groupTypes.overline = function (group, options) {
  4207. var operator = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode("\u203E")]);
  4208. operator.setAttribute("stretchy", "true");
  4209. var node = new _mathMLTree2.default.MathNode("mover", [buildGroup(group.value.body, options), operator]);
  4210. node.setAttribute("accent", "true");
  4211. return node;
  4212. };
  4213. groupTypes.underline = function (group, options) {
  4214. var operator = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode("\u203E")]);
  4215. operator.setAttribute("stretchy", "true");
  4216. var node = new _mathMLTree2.default.MathNode("munder", [buildGroup(group.value.body, options), operator]);
  4217. node.setAttribute("accentunder", "true");
  4218. return node;
  4219. };
  4220. groupTypes.accentUnder = function (group, options) {
  4221. var accentNode = _stretchy2.default.mathMLnode(group.value.label);
  4222. var node = new _mathMLTree2.default.MathNode("munder", [buildGroup(group.value.body, options), accentNode]);
  4223. node.setAttribute("accentunder", "true");
  4224. return node;
  4225. };
  4226. groupTypes.enclose = function (group, options) {
  4227. var node = new _mathMLTree2.default.MathNode("menclose", [buildGroup(group.value.body, options)]);
  4228. var notation = "";
  4229. switch (group.value.label) {
  4230. case "\\bcancel":
  4231. notation = "downdiagonalstrike";
  4232. break;
  4233. case "\\sout":
  4234. notation = "horizontalstrike";
  4235. break;
  4236. case "\\fbox":
  4237. notation = "box";
  4238. break;
  4239. default:
  4240. notation = "updiagonalstrike";
  4241. }
  4242. node.setAttribute("notation", notation);
  4243. return node;
  4244. };
  4245. groupTypes.horizBrace = function (group, options) {
  4246. var accentNode = _stretchy2.default.mathMLnode(group.value.label);
  4247. return new _mathMLTree2.default.MathNode(group.value.isOver ? "mover" : "munder", [buildGroup(group.value.base, options), accentNode]);
  4248. };
  4249. groupTypes.xArrow = function (group, options) {
  4250. var arrowNode = _stretchy2.default.mathMLnode(group.value.label);
  4251. var node = void 0;
  4252. var lowerNode = void 0;
  4253. if (group.value.body) {
  4254. var upperNode = buildGroup(group.value.body, options);
  4255. if (group.value.below) {
  4256. lowerNode = buildGroup(group.value.below, options);
  4257. node = new _mathMLTree2.default.MathNode("munderover", [arrowNode, lowerNode, upperNode]);
  4258. } else {
  4259. node = new _mathMLTree2.default.MathNode("mover", [arrowNode, upperNode]);
  4260. }
  4261. } else if (group.value.below) {
  4262. lowerNode = buildGroup(group.value.below, options);
  4263. node = new _mathMLTree2.default.MathNode("munder", [arrowNode, lowerNode]);
  4264. } else {
  4265. node = new _mathMLTree2.default.MathNode("mover", [arrowNode]);
  4266. }
  4267. return node;
  4268. };
  4269. groupTypes.rule = function (group) {
  4270. // TODO(emily): Figure out if there's an actual way to draw black boxes
  4271. // in MathML.
  4272. var node = new _mathMLTree2.default.MathNode("mrow");
  4273. return node;
  4274. };
  4275. groupTypes.kern = function (group) {
  4276. // TODO(kevin): Figure out if there's a way to add space in MathML
  4277. var node = new _mathMLTree2.default.MathNode("mrow");
  4278. return node;
  4279. };
  4280. groupTypes.llap = function (group, options) {
  4281. var node = new _mathMLTree2.default.MathNode("mpadded", [buildGroup(group.value.body, options)]);
  4282. node.setAttribute("lspace", "-1width");
  4283. node.setAttribute("width", "0px");
  4284. return node;
  4285. };
  4286. groupTypes.rlap = function (group, options) {
  4287. var node = new _mathMLTree2.default.MathNode("mpadded", [buildGroup(group.value.body, options)]);
  4288. node.setAttribute("width", "0px");
  4289. return node;
  4290. };
  4291. groupTypes.phantom = function (group, options) {
  4292. var inner = buildExpression(group.value.value, options);
  4293. return new _mathMLTree2.default.MathNode("mphantom", inner);
  4294. };
  4295. groupTypes.mclass = function (group, options) {
  4296. var inner = buildExpression(group.value.value, options);
  4297. return new _mathMLTree2.default.MathNode("mstyle", inner);
  4298. };
  4299. /**
  4300. * Takes a list of nodes, builds them, and returns a list of the generated
  4301. * MathML nodes. A little simpler than the HTML version because we don't do any
  4302. * previous-node handling.
  4303. */
  4304. var buildExpression = function buildExpression(expression, options) {
  4305. var groups = [];
  4306. for (var i = 0; i < expression.length; i++) {
  4307. var group = expression[i];
  4308. groups.push(buildGroup(group, options));
  4309. }
  4310. // TODO(kevinb): combine \\not with mrels and mords
  4311. return groups;
  4312. };
  4313. /**
  4314. * Takes a group from the parser and calls the appropriate groupTypes function
  4315. * on it to produce a MathML node.
  4316. */
  4317. // TODO(kevinb): determine if removeUnnecessaryRow should always be true
  4318. var buildGroup = function buildGroup(group, options) {
  4319. var removeUnnecessaryRow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4320. if (!group) {
  4321. return new _mathMLTree2.default.MathNode("mrow");
  4322. }
  4323. if (groupTypes[group.type]) {
  4324. // Call the groupTypes function
  4325. var result = groupTypes[group.type](group, options);
  4326. if (removeUnnecessaryRow) {
  4327. if (result.type === "mrow" && result.children.length === 1) {
  4328. return result.children[0];
  4329. }
  4330. }
  4331. return result;
  4332. } else {
  4333. throw new _ParseError2.default("Got group of unknown type: '" + group.type + "'");
  4334. }
  4335. };
  4336. /**
  4337. * Takes a full parse tree and settings and builds a MathML representation of
  4338. * it. In particular, we put the elements from building the parse tree into a
  4339. * <semantics> tag so we can also include that TeX source as an annotation.
  4340. *
  4341. * Note that we actually return a domTree element with a `<math>` inside it so
  4342. * we can do appropriate styling.
  4343. */
  4344. var buildMathML = function buildMathML(tree, texExpression, options) {
  4345. var expression = buildExpression(tree, options);
  4346. // Wrap up the expression in an mrow so it is presented in the semantics
  4347. // tag correctly.
  4348. var wrapper = new _mathMLTree2.default.MathNode("mrow", expression);
  4349. // Build a TeX annotation of the source
  4350. var annotation = new _mathMLTree2.default.MathNode("annotation", [new _mathMLTree2.default.TextNode(texExpression)]);
  4351. annotation.setAttribute("encoding", "application/x-tex");
  4352. var semantics = new _mathMLTree2.default.MathNode("semantics", [wrapper, annotation]);
  4353. var math = new _mathMLTree2.default.MathNode("math", [semantics]);
  4354. // You can't style <math> nodes, so we wrap the node in a span.
  4355. return (0, _buildCommon.makeSpan)(["katex-mathml"], [math]);
  4356. };
  4357. module.exports = buildMathML;
  4358. },{"./ParseError":29,"./Style":33,"./buildCommon":34,"./fontMetrics":41,"./mathMLTree":45,"./stretchy":47,"./symbols":48,"./utils":51}],37:[function(require,module,exports){
  4359. "use strict";
  4360. var _buildHTML = require("./buildHTML");
  4361. var _buildHTML2 = _interopRequireDefault(_buildHTML);
  4362. var _buildMathML = require("./buildMathML");
  4363. var _buildMathML2 = _interopRequireDefault(_buildMathML);
  4364. var _buildCommon = require("./buildCommon");
  4365. var _Options = require("./Options");
  4366. var _Options2 = _interopRequireDefault(_Options);
  4367. var _Settings = require("./Settings");
  4368. var _Settings2 = _interopRequireDefault(_Settings);
  4369. var _Style = require("./Style");
  4370. var _Style2 = _interopRequireDefault(_Style);
  4371. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4372. var buildTree = function buildTree(tree, expression, settings) {
  4373. settings = settings || new _Settings2.default({});
  4374. var startStyle = _Style2.default.TEXT;
  4375. if (settings.displayMode) {
  4376. startStyle = _Style2.default.DISPLAY;
  4377. }
  4378. // Setup the default options
  4379. var options = new _Options2.default({
  4380. style: startStyle
  4381. });
  4382. // `buildHTML` sometimes messes with the parse tree (like turning bins ->
  4383. // ords), so we build the MathML version first.
  4384. var mathMLNode = (0, _buildMathML2.default)(tree, expression, options);
  4385. var htmlNode = (0, _buildHTML2.default)(tree, options);
  4386. var katexNode = (0, _buildCommon.makeSpan)(["katex"], [mathMLNode, htmlNode]);
  4387. if (settings.displayMode) {
  4388. return (0, _buildCommon.makeSpan)(["katex-display"], [katexNode]);
  4389. } else {
  4390. return katexNode;
  4391. }
  4392. };
  4393. module.exports = buildTree;
  4394. },{"./Options":28,"./Settings":32,"./Style":33,"./buildCommon":34,"./buildHTML":35,"./buildMathML":36}],38:[function(require,module,exports){
  4395. "use strict";
  4396. var _ParseError = require("./ParseError");
  4397. var _ParseError2 = _interopRequireDefault(_ParseError);
  4398. var _Style = require("./Style");
  4399. var _Style2 = _interopRequireDefault(_Style);
  4400. var _buildCommon = require("./buildCommon");
  4401. var _buildCommon2 = _interopRequireDefault(_buildCommon);
  4402. var _fontMetrics = require("./fontMetrics");
  4403. var _fontMetrics2 = _interopRequireDefault(_fontMetrics);
  4404. var _symbols = require("./symbols");
  4405. var _symbols2 = _interopRequireDefault(_symbols);
  4406. var _utils = require("./utils");
  4407. var _utils2 = _interopRequireDefault(_utils);
  4408. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4409. /**
  4410. * Get the metrics for a given symbol and font, after transformation (i.e.
  4411. * after following replacement from symbols.js)
  4412. */
  4413. /**
  4414. * This file deals with creating delimiters of various sizes. The TeXbook
  4415. * discusses these routines on page 441-442, in the "Another subroutine sets box
  4416. * x to a specified variable delimiter" paragraph.
  4417. *
  4418. * There are three main routines here. `makeSmallDelim` makes a delimiter in the
  4419. * normal font, but in either text, script, or scriptscript style.
  4420. * `makeLargeDelim` makes a delimiter in textstyle, but in one of the Size1,
  4421. * Size2, Size3, or Size4 fonts. `makeStackedDelim` makes a delimiter out of
  4422. * smaller pieces that are stacked on top of one another.
  4423. *
  4424. * The functions take a parameter `center`, which determines if the delimiter
  4425. * should be centered around the axis.
  4426. *
  4427. * Then, there are three exposed functions. `sizedDelim` makes a delimiter in
  4428. * one of the given sizes. This is used for things like `\bigl`.
  4429. * `customSizedDelim` makes a delimiter with a given total height+depth. It is
  4430. * called in places like `\sqrt`. `leftRightDelim` makes an appropriate
  4431. * delimiter which surrounds an expression of a given height an depth. It is
  4432. * used in `\left` and `\right`.
  4433. */
  4434. var getMetrics = function getMetrics(symbol, font) {
  4435. if (_symbols2.default.math[symbol] && _symbols2.default.math[symbol].replace) {
  4436. return _fontMetrics2.default.getCharacterMetrics(_symbols2.default.math[symbol].replace, font);
  4437. } else {
  4438. return _fontMetrics2.default.getCharacterMetrics(symbol, font);
  4439. }
  4440. };
  4441. /**
  4442. * Puts a delimiter span in a given style, and adds appropriate height, depth,
  4443. * and maxFontSizes.
  4444. */
  4445. var styleWrap = function styleWrap(delim, toStyle, options, classes) {
  4446. var newOptions = options.havingBaseStyle(toStyle);
  4447. var span = (0, _buildCommon.makeSpan)((classes || []).concat(newOptions.sizingClasses(options)), [delim], options);
  4448. span.delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier;
  4449. span.height *= span.delimSizeMultiplier;
  4450. span.depth *= span.delimSizeMultiplier;
  4451. span.maxFontSize = newOptions.sizeMultiplier;
  4452. return span;
  4453. };
  4454. var centerSpan = function centerSpan(span, options, style) {
  4455. var newOptions = options.havingBaseStyle(style);
  4456. var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight;
  4457. span.classes.push("delimcenter");
  4458. span.style.top = shift + "em";
  4459. span.height -= shift;
  4460. span.depth += shift;
  4461. };
  4462. /**
  4463. * Makes a small delimiter. This is a delimiter that comes in the Main-Regular
  4464. * font, but is restyled to either be in textstyle, scriptstyle, or
  4465. * scriptscriptstyle.
  4466. */
  4467. var makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) {
  4468. var text = _buildCommon2.default.makeSymbol(delim, "Main-Regular", mode, options);
  4469. var span = styleWrap(text, style, options, classes);
  4470. if (center) {
  4471. centerSpan(span, options, style);
  4472. }
  4473. return span;
  4474. };
  4475. /**
  4476. * Builds a symbol in the given font size (note size is an integer)
  4477. */
  4478. var mathrmSize = function mathrmSize(value, size, mode, options) {
  4479. return _buildCommon2.default.makeSymbol(value, "Size" + size + "-Regular", mode, options);
  4480. };
  4481. /**
  4482. * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2,
  4483. * Size3, or Size4 fonts. It is always rendered in textstyle.
  4484. */
  4485. var makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) {
  4486. var inner = mathrmSize(delim, size, mode, options);
  4487. var span = styleWrap((0, _buildCommon.makeSpan)(["delimsizing", "size" + size], [inner], options), _Style2.default.TEXT, options, classes);
  4488. if (center) {
  4489. centerSpan(span, options, _Style2.default.TEXT);
  4490. }
  4491. return span;
  4492. };
  4493. /**
  4494. * Make an inner span with the given offset and in the given font. This is used
  4495. * in `makeStackedDelim` to make the stacking pieces for the delimiter.
  4496. */
  4497. var makeInner = function makeInner(symbol, font, mode) {
  4498. var sizeClass = void 0;
  4499. // Apply the correct CSS class to choose the right font.
  4500. if (font === "Size1-Regular") {
  4501. sizeClass = "delim-size1";
  4502. } else if (font === "Size4-Regular") {
  4503. sizeClass = "delim-size4";
  4504. }
  4505. var inner = (0, _buildCommon.makeSpan)(["delimsizinginner", sizeClass], [(0, _buildCommon.makeSpan)([], [_buildCommon2.default.makeSymbol(symbol, font, mode)])]);
  4506. // Since this will be passed into `makeVList` in the end, wrap the element
  4507. // in the appropriate tag that VList uses.
  4508. return { type: "elem", elem: inner };
  4509. };
  4510. /**
  4511. * Make a stacked delimiter out of a given delimiter, with the total height at
  4512. * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook.
  4513. */
  4514. var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) {
  4515. // There are four parts, the top, an optional middle, a repeated part, and a
  4516. // bottom.
  4517. var top = void 0;
  4518. var middle = void 0;
  4519. var repeat = void 0;
  4520. var bottom = void 0;
  4521. top = repeat = bottom = delim;
  4522. middle = null;
  4523. // Also keep track of what font the delimiters are in
  4524. var font = "Size1-Regular";
  4525. // We set the parts and font based on the symbol. Note that we use
  4526. // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the
  4527. // repeats of the arrows
  4528. if (delim === "\\uparrow") {
  4529. repeat = bottom = "\u23D0";
  4530. } else if (delim === "\\Uparrow") {
  4531. repeat = bottom = "\u2016";
  4532. } else if (delim === "\\downarrow") {
  4533. top = repeat = "\u23D0";
  4534. } else if (delim === "\\Downarrow") {
  4535. top = repeat = "\u2016";
  4536. } else if (delim === "\\updownarrow") {
  4537. top = "\\uparrow";
  4538. repeat = "\u23D0";
  4539. bottom = "\\downarrow";
  4540. } else if (delim === "\\Updownarrow") {
  4541. top = "\\Uparrow";
  4542. repeat = "\u2016";
  4543. bottom = "\\Downarrow";
  4544. } else if (delim === "[" || delim === "\\lbrack") {
  4545. top = "\u23A1";
  4546. repeat = "\u23A2";
  4547. bottom = "\u23A3";
  4548. font = "Size4-Regular";
  4549. } else if (delim === "]" || delim === "\\rbrack") {
  4550. top = "\u23A4";
  4551. repeat = "\u23A5";
  4552. bottom = "\u23A6";
  4553. font = "Size4-Regular";
  4554. } else if (delim === "\\lfloor") {
  4555. repeat = top = "\u23A2";
  4556. bottom = "\u23A3";
  4557. font = "Size4-Regular";
  4558. } else if (delim === "\\lceil") {
  4559. top = "\u23A1";
  4560. repeat = bottom = "\u23A2";
  4561. font = "Size4-Regular";
  4562. } else if (delim === "\\rfloor") {
  4563. repeat = top = "\u23A5";
  4564. bottom = "\u23A6";
  4565. font = "Size4-Regular";
  4566. } else if (delim === "\\rceil") {
  4567. top = "\u23A4";
  4568. repeat = bottom = "\u23A5";
  4569. font = "Size4-Regular";
  4570. } else if (delim === "(") {
  4571. top = "\u239B";
  4572. repeat = "\u239C";
  4573. bottom = "\u239D";
  4574. font = "Size4-Regular";
  4575. } else if (delim === ")") {
  4576. top = "\u239E";
  4577. repeat = "\u239F";
  4578. bottom = "\u23A0";
  4579. font = "Size4-Regular";
  4580. } else if (delim === "\\{" || delim === "\\lbrace") {
  4581. top = "\u23A7";
  4582. middle = "\u23A8";
  4583. bottom = "\u23A9";
  4584. repeat = "\u23AA";
  4585. font = "Size4-Regular";
  4586. } else if (delim === "\\}" || delim === "\\rbrace") {
  4587. top = "\u23AB";
  4588. middle = "\u23AC";
  4589. bottom = "\u23AD";
  4590. repeat = "\u23AA";
  4591. font = "Size4-Regular";
  4592. } else if (delim === "\\lgroup") {
  4593. top = "\u23A7";
  4594. bottom = "\u23A9";
  4595. repeat = "\u23AA";
  4596. font = "Size4-Regular";
  4597. } else if (delim === "\\rgroup") {
  4598. top = "\u23AB";
  4599. bottom = "\u23AD";
  4600. repeat = "\u23AA";
  4601. font = "Size4-Regular";
  4602. } else if (delim === "\\lmoustache") {
  4603. top = "\u23A7";
  4604. bottom = "\u23AD";
  4605. repeat = "\u23AA";
  4606. font = "Size4-Regular";
  4607. } else if (delim === "\\rmoustache") {
  4608. top = "\u23AB";
  4609. bottom = "\u23A9";
  4610. repeat = "\u23AA";
  4611. font = "Size4-Regular";
  4612. }
  4613. // Get the metrics of the four sections
  4614. var topMetrics = getMetrics(top, font);
  4615. var topHeightTotal = topMetrics.height + topMetrics.depth;
  4616. var repeatMetrics = getMetrics(repeat, font);
  4617. var repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth;
  4618. var bottomMetrics = getMetrics(bottom, font);
  4619. var bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth;
  4620. var middleHeightTotal = 0;
  4621. var middleFactor = 1;
  4622. if (middle !== null) {
  4623. var middleMetrics = getMetrics(middle, font);
  4624. middleHeightTotal = middleMetrics.height + middleMetrics.depth;
  4625. middleFactor = 2; // repeat symmetrically above and below middle
  4626. }
  4627. // Calcuate the minimal height that the delimiter can have.
  4628. // It is at least the size of the top, bottom, and optional middle combined.
  4629. var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal;
  4630. // Compute the number of copies of the repeat symbol we will need
  4631. var repeatCount = Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal));
  4632. // Compute the total height of the delimiter including all the symbols
  4633. var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal;
  4634. // The center of the delimiter is placed at the center of the axis. Note
  4635. // that in this context, "center" means that the delimiter should be
  4636. // centered around the axis in the current style, while normally it is
  4637. // centered around the axis in textstyle.
  4638. var axisHeight = options.fontMetrics().axisHeight;
  4639. if (center) {
  4640. axisHeight *= options.sizeMultiplier;
  4641. }
  4642. // Calculate the depth
  4643. var depth = realHeightTotal / 2 - axisHeight;
  4644. // Now, we start building the pieces that will go into the vlist
  4645. // Keep a list of the inner pieces
  4646. var inners = [];
  4647. // Add the bottom symbol
  4648. inners.push(makeInner(bottom, font, mode));
  4649. if (middle === null) {
  4650. // Add that many symbols
  4651. for (var i = 0; i < repeatCount; i++) {
  4652. inners.push(makeInner(repeat, font, mode));
  4653. }
  4654. } else {
  4655. // When there is a middle bit, we need the middle part and two repeated
  4656. // sections
  4657. for (var _i = 0; _i < repeatCount; _i++) {
  4658. inners.push(makeInner(repeat, font, mode));
  4659. }
  4660. inners.push(makeInner(middle, font, mode));
  4661. for (var _i2 = 0; _i2 < repeatCount; _i2++) {
  4662. inners.push(makeInner(repeat, font, mode));
  4663. }
  4664. }
  4665. // Add the top symbol
  4666. inners.push(makeInner(top, font, mode));
  4667. // Finally, build the vlist
  4668. var newOptions = options.havingBaseStyle(_Style2.default.TEXT);
  4669. var inner = _buildCommon2.default.makeVList(inners, "bottom", depth, newOptions);
  4670. return styleWrap((0, _buildCommon.makeSpan)(["delimsizing", "mult"], [inner], newOptions), _Style2.default.TEXT, options, classes);
  4671. };
  4672. var sqrtInnerSVG = {
  4673. // The main path geometry is from glyph U221A in the font KaTeX Main
  4674. main: "<svg viewBox='0 0 400000 1000' preserveAspectRatio='xMinYMin\nslice'><path d='M95 622c-2.667 0-7.167-2.667-13.5\n-8S72 604 72 600c0-2 .333-3.333 1-4 1.333-2.667 23.833-20.667 67.5-54s\n65.833-50.333 66.5-51c1.333-1.333 3-2 5-2 4.667 0 8.667 3.333 12 10l173\n378c.667 0 35.333-71 104-213s137.5-285 206.5-429S812 17.333 812 14c5.333\n-9.333 12-14 20-14h399166v40H845.272L620 507 385 993c-2.667 4.667-9 7-19\n7-6 0-10-1-12-3L160 575l-65 47zM834 0h399166v40H845z'/></svg>",
  4675. // size1 is from glyph U221A in the font KaTeX_Size1-Regular
  4676. 1: "<svg viewBox='0 0 400000 1200' preserveAspectRatio='xMinYMin\nslice'><path d='M263 601c.667 0 18 39.667 52 119s68.167\n 158.667 102.5 238 51.833 119.333 52.5 120C810 373.333 980.667 17.667 982 11\nc4.667-7.333 11-11 19-11h398999v40H1012.333L741 607c-38.667 80.667-84 175-136\n 283s-89.167 185.333-111.5 232-33.833 70.333-34.5 71c-4.667 4.667-12.333 7-23\n 7l-12-1-109-253c-72.667-168-109.333-252-110-252-10.667 8-22 16.667-34 26-22\n 17.333-33.333 26-34 26l-26-26 76-59 76-60zM1001 0h398999v40H1012z'/></svg>",
  4677. // size2 is from glyph U221A in the font KaTeX_Size2-Regular
  4678. 2: "<svg viewBox='0 0 400000 1800' preserveAspectRatio='xMinYMin\nslice'><path d='M1001 0h398999v40H1013.084S929.667 308 749\n 880s-277 876.333-289 913c-4.667 4.667-12.667 7-24 7h-12c-1.333-3.333-3.667\n-11.667-7-25-35.333-125.333-106.667-373.333-214-744-10 12-21 25-33 39l-32 39\nc-6-5.333-15-14-27-26l25-30c26.667-32.667 52-63 76-91l52-60 208 722c56-175.333\n 126.333-397.333 211-666s153.833-488.167 207.5-658.5C944.167 129.167 975 32.667\n 983 10c4-6.667 10-10 18-10zm0 0h398999v40H1013z'/></svg>",
  4679. // size3 is from glyph U221A in the font KaTeX_Size3-Regular
  4680. 3: "<svg viewBox='0 0 400000 2400' preserveAspectRatio='xMinYMin\nslice'><path d='M424 2398c-1.333-.667-38.5-172-111.5-514\nS202.667 1370.667 202 1370c0-2-10.667 14.333-32 49-4.667 7.333-9.833 15.667\n-15.5 25s-9.833 16-12.5 20l-5 7c-4-3.333-8.333-7.667-13-13l-13-13 76-122 77-121\n 209 968c0-2 84.667-361.667 254-1079C896.333 373.667 981.667 13.333 983 10\nc4-6.667 10-10 18-10h398999v40H1014.622S927.332 418.667 742 1206c-185.333\n 787.333-279.333 1182.333-282 1185-2 6-10 9-24 9-8 0-12-.667-12-2z\nM1001 0h398999v40H1014z'/></svg>",
  4681. // size4 is from glyph U221A in the font KaTeX_Size4-Regular
  4682. 4: "<svg viewBox='0 0 400000 3000' preserveAspectRatio='xMinYMin\nslice'><path d='M473 2713C812.333 913.667 982.333 13 983 11\nc3.333-7.333 9.333-11 18-11h399110v40H1017.698S927.168 518 741.5 1506C555.833\n 2494 462 2989 460 2991c-2 6-10 9-24 9-8 0-12-.667-12-2s-5.333-32-16-92c-50.667\n-293.333-119.667-693.333-207-1200 0-1.333-5.333 8.667-16 30l-32 64-16 33-26-26\n 76-153 77-151c.667.667 35.667 202 105 604 67.333 400.667 102 602.667 104 606z\nM1001 0h398999v40H1017z'/></svg>",
  4683. // tall is from glyph U23B7 in the font KaTeX_Size4-Regular
  4684. tall: "l-4 4-4 4c-.667.667-2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1h\n-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170c-4-3.333-8.333\n-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667 219 661 l218 661z\nM702 0H400000v40H742z'/></svg>"
  4685. };
  4686. var sqrtSpan = function sqrtSpan(height, delim, options) {
  4687. // Create a span containing an SVG image of a sqrt symbol.
  4688. var span = _buildCommon2.default.makeSpan([], [], options);
  4689. var sizeMultiplier = options.sizeMultiplier; // default
  4690. if (delim.type === "small") {
  4691. // Get an SVG that is derived from glyph U+221A in font KaTeX-Main.
  4692. var newOptions = options.havingBaseStyle(delim.style);
  4693. sizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier;
  4694. span.height = 1 * sizeMultiplier;
  4695. span.style.height = span.height + "em";
  4696. span.surdWidth = 0.833 * sizeMultiplier; // from the font.
  4697. //In the font, the glyph is 1000 units tall. The font scale is 1:1000.
  4698. span.innerHTML = "<svg width='100%' height='" + span.height + "em'>\n " + sqrtInnerSVG['main'] + "</svg>";
  4699. } else if (delim.type === "large") {
  4700. // These SVGs come from fonts: KaTeX_Size1, _Size2, etc.
  4701. // Get sqrt height from font data
  4702. span.height = sizeToMaxHeight[delim.size] / sizeMultiplier;
  4703. span.style.height = span.height + "em";
  4704. span.surdWidth = 1.0 / sizeMultiplier; // from the font
  4705. span.innerHTML = "<svg width=\"100%\" height=\"" + span.height + "em\">\n " + sqrtInnerSVG[delim.size] + "</svg>";
  4706. } else {
  4707. // Tall sqrt. In TeX, this would be stacked using multiple glyphs.
  4708. // We'll use a single SVG to accomplish the same thing.
  4709. span.height = height / sizeMultiplier;
  4710. span.style.height = span.height + "em";
  4711. span.surdWidth = 1.056 / sizeMultiplier;
  4712. var viewBoxHeight = Math.floor(span.height * 1000); // scale = 1:1000
  4713. var vertSegment = viewBoxHeight - 54;
  4714. // This \sqrt is customized in both height and width. We set the
  4715. // height now. Then CSS will stretch the image to the correct width.
  4716. // This SVG path comes from glyph U+23B7, font KaTeX_Size4-Regular.
  4717. span.innerHTML = "<svg width='100%' height='" + span.height + "em'>\n <svg viewBox='0 0 400000 " + viewBoxHeight + "'\n preserveAspectRatio='xMinYMax slice'>\n <path d='M702 0H400000v40H742v" + vertSegment + "\n " + sqrtInnerSVG['tall'] + "</svg>";
  4718. }
  4719. span.sizeMultiplier = sizeMultiplier;
  4720. return span;
  4721. };
  4722. // There are three kinds of delimiters, delimiters that stack when they become
  4723. // too large
  4724. var stackLargeDelimiters = ["(", ")", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\\lceil", "\\rceil", "\\surd"];
  4725. // delimiters that always stack
  4726. var stackAlwaysDelimiters = ["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache"];
  4727. // and delimiters that never stack
  4728. var stackNeverDelimiters = ["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"];
  4729. // Metrics of the different sizes. Found by looking at TeX's output of
  4730. // $\bigl| // \Bigl| \biggl| \Biggl| \showlists$
  4731. // Used to create stacked delimiters of appropriate sizes in makeSizedDelim.
  4732. var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0];
  4733. /**
  4734. * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4.
  4735. */
  4736. var makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) {
  4737. // < and > turn into \langle and \rangle in delimiters
  4738. if (delim === "<" || delim === "\\lt") {
  4739. delim = "\\langle";
  4740. } else if (delim === ">" || delim === "\\gt") {
  4741. delim = "\\rangle";
  4742. }
  4743. // Sized delimiters are never centered.
  4744. if (_utils2.default.contains(stackLargeDelimiters, delim) || _utils2.default.contains(stackNeverDelimiters, delim)) {
  4745. return makeLargeDelim(delim, size, false, options, mode, classes);
  4746. } else if (_utils2.default.contains(stackAlwaysDelimiters, delim)) {
  4747. return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes);
  4748. } else {
  4749. throw new _ParseError2.default("Illegal delimiter: '" + delim + "'");
  4750. }
  4751. };
  4752. /**
  4753. * There are three different sequences of delimiter sizes that the delimiters
  4754. * follow depending on the kind of delimiter. This is used when creating custom
  4755. * sized delimiters to decide whether to create a small, large, or stacked
  4756. * delimiter.
  4757. *
  4758. * In real TeX, these sequences aren't explicitly defined, but are instead
  4759. * defined inside the font metrics. Since there are only three sequences that
  4760. * are possible for the delimiters that TeX defines, it is easier to just encode
  4761. * them explicitly here.
  4762. */
  4763. // Delimiters that never stack try small delimiters and large delimiters only
  4764. var stackNeverDelimiterSequence = [{ type: "small", style: _Style2.default.SCRIPTSCRIPT }, { type: "small", style: _Style2.default.SCRIPT }, { type: "small", style: _Style2.default.TEXT }, { type: "large", size: 1 }, { type: "large", size: 2 }, { type: "large", size: 3 }, { type: "large", size: 4 }];
  4765. // Delimiters that always stack try the small delimiters first, then stack
  4766. var stackAlwaysDelimiterSequence = [{ type: "small", style: _Style2.default.SCRIPTSCRIPT }, { type: "small", style: _Style2.default.SCRIPT }, { type: "small", style: _Style2.default.TEXT }, { type: "stack" }];
  4767. // Delimiters that stack when large try the small and then large delimiters, and
  4768. // stack afterwards
  4769. var stackLargeDelimiterSequence = [{ type: "small", style: _Style2.default.SCRIPTSCRIPT }, { type: "small", style: _Style2.default.SCRIPT }, { type: "small", style: _Style2.default.TEXT }, { type: "large", size: 1 }, { type: "large", size: 2 }, { type: "large", size: 3 }, { type: "large", size: 4 }, { type: "stack" }];
  4770. /**
  4771. * Get the font used in a delimiter based on what kind of delimiter it is.
  4772. */
  4773. var delimTypeToFont = function delimTypeToFont(type) {
  4774. if (type.type === "small") {
  4775. return "Main-Regular";
  4776. } else if (type.type === "large") {
  4777. return "Size" + type.size + "-Regular";
  4778. } else if (type.type === "stack") {
  4779. return "Size4-Regular";
  4780. }
  4781. };
  4782. /**
  4783. * Traverse a sequence of types of delimiters to decide what kind of delimiter
  4784. * should be used to create a delimiter of the given height+depth.
  4785. */
  4786. var traverseSequence = function traverseSequence(delim, height, sequence, options) {
  4787. // Here, we choose the index we should start at in the sequences. In smaller
  4788. // sizes (which correspond to larger numbers in style.size) we start earlier
  4789. // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts
  4790. // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2
  4791. var start = Math.min(2, 3 - options.style.size);
  4792. for (var i = start; i < sequence.length; i++) {
  4793. if (sequence[i].type === "stack") {
  4794. // This is always the last delimiter, so we just break the loop now.
  4795. break;
  4796. }
  4797. var metrics = getMetrics(delim, delimTypeToFont(sequence[i]));
  4798. var heightDepth = metrics.height + metrics.depth;
  4799. // Small delimiters are scaled down versions of the same font, so we
  4800. // account for the style change size.
  4801. if (sequence[i].type === "small") {
  4802. var newOptions = options.havingBaseStyle(sequence[i].style);
  4803. heightDepth *= newOptions.sizeMultiplier;
  4804. }
  4805. // Check if the delimiter at this size works for the given height.
  4806. if (heightDepth > height) {
  4807. return sequence[i];
  4808. }
  4809. }
  4810. // If we reached the end of the sequence, return the last sequence element.
  4811. return sequence[sequence.length - 1];
  4812. };
  4813. /**
  4814. * Make a delimiter of a given height+depth, with optional centering. Here, we
  4815. * traverse the sequences, and create a delimiter that the sequence tells us to.
  4816. */
  4817. var makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) {
  4818. if (delim === "<" || delim === "\\lt") {
  4819. delim = "\\langle";
  4820. } else if (delim === ">" || delim === "\\gt") {
  4821. delim = "\\rangle";
  4822. }
  4823. // Decide what sequence to use
  4824. var sequence = void 0;
  4825. if (_utils2.default.contains(stackNeverDelimiters, delim)) {
  4826. sequence = stackNeverDelimiterSequence;
  4827. } else if (_utils2.default.contains(stackLargeDelimiters, delim)) {
  4828. sequence = stackLargeDelimiterSequence;
  4829. } else {
  4830. sequence = stackAlwaysDelimiterSequence;
  4831. }
  4832. // Look through the sequence
  4833. var delimType = traverseSequence(delim, height, sequence, options);
  4834. if (delim === "\\surd") {
  4835. // Get an SVG image for
  4836. return sqrtSpan(height, delimType, options);
  4837. } else {
  4838. // Get the delimiter from font glyphs.
  4839. // Depending on the sequence element we decided on, call the
  4840. // appropriate function.
  4841. if (delimType.type === "small") {
  4842. return makeSmallDelim(delim, delimType.style, center, options, mode, classes);
  4843. } else if (delimType.type === "large") {
  4844. return makeLargeDelim(delim, delimType.size, center, options, mode, classes);
  4845. } else if (delimType.type === "stack") {
  4846. return makeStackedDelim(delim, height, center, options, mode, classes);
  4847. }
  4848. }
  4849. };
  4850. /**
  4851. * Make a delimiter for use with `\left` and `\right`, given a height and depth
  4852. * of an expression that the delimiters surround.
  4853. */
  4854. var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) {
  4855. // We always center \left/\right delimiters, so the axis is always shifted
  4856. var axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier;
  4857. // Taken from TeX source, tex.web, function make_left_right
  4858. var delimiterFactor = 901;
  4859. var delimiterExtend = 5.0 / options.fontMetrics().ptPerEm;
  4860. var maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight);
  4861. var totalHeight = Math.max(
  4862. // In real TeX, calculations are done using integral values which are
  4863. // 65536 per pt, or 655360 per em. So, the division here truncates in
  4864. // TeX but doesn't here, producing different results. If we wanted to
  4865. // exactly match TeX's calculation, we could do
  4866. // Math.floor(655360 * maxDistFromAxis / 500) *
  4867. // delimiterFactor / 655360
  4868. // (To see the difference, compare
  4869. // x^{x^{\left(\rule{0.1em}{0.68em}\right)}}
  4870. // in TeX and KaTeX)
  4871. maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend);
  4872. // Finally, we defer to `makeCustomSizedDelim` with our calculated total
  4873. // height
  4874. return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes);
  4875. };
  4876. module.exports = {
  4877. sizedDelim: makeSizedDelim,
  4878. customSizedDelim: makeCustomSizedDelim,
  4879. leftRightDelim: makeLeftRightDelim
  4880. };
  4881. },{"./ParseError":29,"./Style":33,"./buildCommon":34,"./fontMetrics":41,"./symbols":48,"./utils":51}],39:[function(require,module,exports){
  4882. "use strict";
  4883. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  4884. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  4885. var _createClass2 = require("babel-runtime/helpers/createClass");
  4886. var _createClass3 = _interopRequireDefault(_createClass2);
  4887. var _unicodeRegexes = require("./unicodeRegexes");
  4888. var _unicodeRegexes2 = _interopRequireDefault(_unicodeRegexes);
  4889. var _utils = require("./utils");
  4890. var _utils2 = _interopRequireDefault(_utils);
  4891. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4892. /**
  4893. * Create an HTML className based on a list of classes. In addition to joining
  4894. * with spaces, we also remove null or empty classes.
  4895. */
  4896. /**
  4897. * These objects store the data about the DOM nodes we create, as well as some
  4898. * extra data. They can then be transformed into real DOM nodes with the
  4899. * `toNode` function or HTML markup using `toMarkup`. They are useful for both
  4900. * storing extra properties on the nodes, as well as providing a way to easily
  4901. * work with the DOM.
  4902. *
  4903. * Similar functions for working with MathML nodes exist in mathMLTree.js.
  4904. */
  4905. var createClass = function createClass(classes) {
  4906. classes = classes.slice();
  4907. for (var i = classes.length - 1; i >= 0; i--) {
  4908. if (!classes[i]) {
  4909. classes.splice(i, 1);
  4910. }
  4911. }
  4912. return classes.join(" ");
  4913. };
  4914. /**
  4915. * This node represents a span node, with a className, a list of children, and
  4916. * an inline style. It also contains information about its height, depth, and
  4917. * maxFontSize.
  4918. */
  4919. var span = function () {
  4920. function span(classes, children, options) {
  4921. (0, _classCallCheck3.default)(this, span);
  4922. this.classes = classes || [];
  4923. this.children = children || [];
  4924. this.height = 0;
  4925. this.depth = 0;
  4926. this.maxFontSize = 0;
  4927. this.style = {};
  4928. this.attributes = {};
  4929. this.innerHTML; // used for inline SVG code.
  4930. if (options) {
  4931. if (options.style.isTight()) {
  4932. this.classes.push("mtight");
  4933. }
  4934. if (options.getColor()) {
  4935. this.style.color = options.getColor();
  4936. }
  4937. }
  4938. }
  4939. /**
  4940. * Sets an arbitrary attribute on the span. Warning: use this wisely. Not all
  4941. * browsers support attributes the same, and having too many custom attributes
  4942. * is probably bad.
  4943. */
  4944. (0, _createClass3.default)(span, [{
  4945. key: "setAttribute",
  4946. value: function setAttribute(attribute, value) {
  4947. this.attributes[attribute] = value;
  4948. }
  4949. }, {
  4950. key: "tryCombine",
  4951. value: function tryCombine(sibling) {
  4952. return false;
  4953. }
  4954. /**
  4955. * Convert the span into an HTML node
  4956. */
  4957. }, {
  4958. key: "toNode",
  4959. value: function toNode() {
  4960. var span = document.createElement("span");
  4961. // Apply the class
  4962. span.className = createClass(this.classes);
  4963. // Apply inline styles
  4964. for (var style in this.style) {
  4965. if (Object.prototype.hasOwnProperty.call(this.style, style)) {
  4966. span.style[style] = this.style[style];
  4967. }
  4968. }
  4969. // Apply attributes
  4970. for (var attr in this.attributes) {
  4971. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  4972. span.setAttribute(attr, this.attributes[attr]);
  4973. }
  4974. }
  4975. if (this.innerHTML) {
  4976. span.innerHTML = this.innerHTML;
  4977. }
  4978. // Append the children, also as HTML nodes
  4979. for (var i = 0; i < this.children.length; i++) {
  4980. span.appendChild(this.children[i].toNode());
  4981. }
  4982. return span;
  4983. }
  4984. /**
  4985. * Convert the span into an HTML markup string
  4986. */
  4987. }, {
  4988. key: "toMarkup",
  4989. value: function toMarkup() {
  4990. var markup = "<span";
  4991. // Add the class
  4992. if (this.classes.length) {
  4993. markup += " class=\"";
  4994. markup += _utils2.default.escape(createClass(this.classes));
  4995. markup += "\"";
  4996. }
  4997. var styles = "";
  4998. // Add the styles, after hyphenation
  4999. for (var style in this.style) {
  5000. if (this.style.hasOwnProperty(style)) {
  5001. styles += _utils2.default.hyphenate(style) + ":" + this.style[style] + ";";
  5002. }
  5003. }
  5004. if (styles) {
  5005. markup += " style=\"" + _utils2.default.escape(styles) + "\"";
  5006. }
  5007. // Add the attributes
  5008. for (var attr in this.attributes) {
  5009. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  5010. markup += " " + attr + "=\"";
  5011. markup += _utils2.default.escape(this.attributes[attr]);
  5012. markup += "\"";
  5013. }
  5014. }
  5015. markup += ">";
  5016. if (this.innerHTML) {
  5017. markup += this.innerHTML;
  5018. }
  5019. // Add the markup of the children, also as markup
  5020. for (var i = 0; i < this.children.length; i++) {
  5021. markup += this.children[i].toMarkup();
  5022. }
  5023. markup += "</span>";
  5024. return markup;
  5025. }
  5026. }]);
  5027. return span;
  5028. }();
  5029. /**
  5030. * This node represents a document fragment, which contains elements, but when
  5031. * placed into the DOM doesn't have any representation itself. Thus, it only
  5032. * contains children and doesn't have any HTML properties. It also keeps track
  5033. * of a height, depth, and maxFontSize.
  5034. */
  5035. var documentFragment = function () {
  5036. function documentFragment(children) {
  5037. (0, _classCallCheck3.default)(this, documentFragment);
  5038. this.children = children || [];
  5039. this.height = 0;
  5040. this.depth = 0;
  5041. this.maxFontSize = 0;
  5042. }
  5043. /**
  5044. * Convert the fragment into a node
  5045. */
  5046. (0, _createClass3.default)(documentFragment, [{
  5047. key: "toNode",
  5048. value: function toNode() {
  5049. // Create a fragment
  5050. var frag = document.createDocumentFragment();
  5051. // Append the children
  5052. for (var i = 0; i < this.children.length; i++) {
  5053. frag.appendChild(this.children[i].toNode());
  5054. }
  5055. return frag;
  5056. }
  5057. /**
  5058. * Convert the fragment into HTML markup
  5059. */
  5060. }, {
  5061. key: "toMarkup",
  5062. value: function toMarkup() {
  5063. var markup = "";
  5064. // Simply concatenate the markup for the children together
  5065. for (var i = 0; i < this.children.length; i++) {
  5066. markup += this.children[i].toMarkup();
  5067. }
  5068. return markup;
  5069. }
  5070. }]);
  5071. return documentFragment;
  5072. }();
  5073. var iCombinations = {
  5074. 'î': "\u0131\u0302",
  5075. 'ï': "\u0131\u0308",
  5076. 'í': "\u0131\u0301",
  5077. // 'ī': '\u0131\u0304', // enable when we add Extended Latin
  5078. 'ì': "\u0131\u0300"
  5079. };
  5080. /**
  5081. * A symbol node contains information about a single symbol. It either renders
  5082. * to a single text node, or a span with a single text node in it, depending on
  5083. * whether it has CSS classes, styles, or needs italic correction.
  5084. */
  5085. var symbolNode = function () {
  5086. function symbolNode(value, height, depth, italic, skew, classes, style) {
  5087. (0, _classCallCheck3.default)(this, symbolNode);
  5088. this.value = value || "";
  5089. this.height = height || 0;
  5090. this.depth = depth || 0;
  5091. this.italic = italic || 0;
  5092. this.skew = skew || 0;
  5093. this.classes = classes || [];
  5094. this.style = style || {};
  5095. this.maxFontSize = 0;
  5096. // Mark CJK characters with specific classes so that we can specify which
  5097. // fonts to use. This allows us to render these characters with a serif
  5098. // font in situations where the browser would either default to a sans serif
  5099. // or render a placeholder character.
  5100. if (_unicodeRegexes2.default.cjkRegex.test(value)) {
  5101. // I couldn't find any fonts that contained Hangul as well as all of
  5102. // the other characters we wanted to test there for it gets its own
  5103. // CSS class.
  5104. if (_unicodeRegexes2.default.hangulRegex.test(value)) {
  5105. this.classes.push('hangul_fallback');
  5106. } else {
  5107. this.classes.push('cjk_fallback');
  5108. }
  5109. }
  5110. if (/[îïíì]/.test(this.value)) {
  5111. // add ī when we add Extended Latin
  5112. this.value = iCombinations[this.value];
  5113. }
  5114. }
  5115. (0, _createClass3.default)(symbolNode, [{
  5116. key: "tryCombine",
  5117. value: function tryCombine(sibling) {
  5118. if (!sibling || !(sibling instanceof symbolNode) || this.italic > 0 || createClass(this.classes) !== createClass(sibling.classes) || this.skew !== sibling.skew || this.maxFontSize !== sibling.maxFontSize) {
  5119. return false;
  5120. }
  5121. for (var style in this.style) {
  5122. if (this.style.hasOwnProperty(style) && this.style[style] !== sibling.style[style]) {
  5123. return false;
  5124. }
  5125. }
  5126. for (var _style in sibling.style) {
  5127. if (sibling.style.hasOwnProperty(_style) && this.style[_style] !== sibling.style[_style]) {
  5128. return false;
  5129. }
  5130. }
  5131. this.value += sibling.value;
  5132. this.height = Math.max(this.height, sibling.height);
  5133. this.depth = Math.max(this.depth, sibling.depth);
  5134. this.italic = sibling.italic;
  5135. return true;
  5136. }
  5137. /**
  5138. * Creates a text node or span from a symbol node. Note that a span is only
  5139. * created if it is needed.
  5140. */
  5141. }, {
  5142. key: "toNode",
  5143. value: function toNode() {
  5144. var node = document.createTextNode(this.value);
  5145. var span = null;
  5146. if (this.italic > 0) {
  5147. span = document.createElement("span");
  5148. span.style.marginRight = this.italic + "em";
  5149. }
  5150. if (this.classes.length > 0) {
  5151. span = span || document.createElement("span");
  5152. span.className = createClass(this.classes);
  5153. }
  5154. for (var style in this.style) {
  5155. if (this.style.hasOwnProperty(style)) {
  5156. span = span || document.createElement("span");
  5157. span.style[style] = this.style[style];
  5158. }
  5159. }
  5160. if (span) {
  5161. span.appendChild(node);
  5162. return span;
  5163. } else {
  5164. return node;
  5165. }
  5166. }
  5167. /**
  5168. * Creates markup for a symbol node.
  5169. */
  5170. }, {
  5171. key: "toMarkup",
  5172. value: function toMarkup() {
  5173. // TODO(alpert): More duplication than I'd like from
  5174. // span.prototype.toMarkup and symbolNode.prototype.toNode...
  5175. var needsSpan = false;
  5176. var markup = "<span";
  5177. if (this.classes.length) {
  5178. needsSpan = true;
  5179. markup += " class=\"";
  5180. markup += _utils2.default.escape(createClass(this.classes));
  5181. markup += "\"";
  5182. }
  5183. var styles = "";
  5184. if (this.italic > 0) {
  5185. styles += "margin-right:" + this.italic + "em;";
  5186. }
  5187. for (var style in this.style) {
  5188. if (this.style.hasOwnProperty(style)) {
  5189. styles += _utils2.default.hyphenate(style) + ":" + this.style[style] + ";";
  5190. }
  5191. }
  5192. if (styles) {
  5193. needsSpan = true;
  5194. markup += " style=\"" + _utils2.default.escape(styles) + "\"";
  5195. }
  5196. var escaped = _utils2.default.escape(this.value);
  5197. if (needsSpan) {
  5198. markup += ">";
  5199. markup += escaped;
  5200. markup += "</span>";
  5201. return markup;
  5202. } else {
  5203. return escaped;
  5204. }
  5205. }
  5206. }]);
  5207. return symbolNode;
  5208. }();
  5209. module.exports = {
  5210. span: span,
  5211. documentFragment: documentFragment,
  5212. symbolNode: symbolNode
  5213. };
  5214. },{"./unicodeRegexes":49,"./utils":51,"babel-runtime/helpers/classCallCheck":4,"babel-runtime/helpers/createClass":5}],40:[function(require,module,exports){
  5215. "use strict";
  5216. var _ParseNode = require("./ParseNode");
  5217. var _ParseNode2 = _interopRequireDefault(_ParseNode);
  5218. var _ParseError = require("./ParseError");
  5219. var _ParseError2 = _interopRequireDefault(_ParseError);
  5220. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5221. /**
  5222. * Parse the body of the environment, with rows delimited by \\ and
  5223. * columns delimited by &, and create a nested list in row-major order
  5224. * with one group per cell. If given an optional argument style
  5225. * ("text", "display", etc.), then each cell is cast into that style.
  5226. */
  5227. /* eslint no-constant-condition:0 */
  5228. function parseArray(parser, result, style) {
  5229. var row = [];
  5230. var body = [row];
  5231. var rowGaps = [];
  5232. while (true) {
  5233. var cell = parser.parseExpression(false, null);
  5234. cell = new _ParseNode2.default("ordgroup", cell, parser.mode);
  5235. if (style) {
  5236. cell = new _ParseNode2.default("styling", {
  5237. style: style,
  5238. value: [cell]
  5239. }, parser.mode);
  5240. }
  5241. row.push(cell);
  5242. var next = parser.nextToken.text;
  5243. if (next === "&") {
  5244. parser.consume();
  5245. } else if (next === "\\end") {
  5246. break;
  5247. } else if (next === "\\\\" || next === "\\cr") {
  5248. var cr = parser.parseFunction();
  5249. rowGaps.push(cr.value.size);
  5250. row = [];
  5251. body.push(row);
  5252. } else {
  5253. throw new _ParseError2.default("Expected & or \\\\ or \\end", parser.nextToken);
  5254. }
  5255. }
  5256. result.body = body;
  5257. result.rowGaps = rowGaps;
  5258. return new _ParseNode2.default(result.type, result, parser.mode);
  5259. }
  5260. /*
  5261. * An environment definition is very similar to a function definition:
  5262. * it is declared with a name or a list of names, a set of properties
  5263. * and a handler containing the actual implementation.
  5264. *
  5265. * The properties include:
  5266. * - numArgs: The number of arguments after the \begin{name} function.
  5267. * - argTypes: (optional) Just like for a function
  5268. * - allowedInText: (optional) Whether or not the environment is allowed inside
  5269. * text mode (default false) (not enforced yet)
  5270. * - numOptionalArgs: (optional) Just like for a function
  5271. * A bare number instead of that object indicates the numArgs value.
  5272. *
  5273. * The handler function will receive two arguments
  5274. * - context: information and references provided by the parser
  5275. * - args: an array of arguments passed to \begin{name}
  5276. * The context contains the following properties:
  5277. * - envName: the name of the environment, one of the listed names.
  5278. * - parser: the parser object
  5279. * - lexer: the lexer object
  5280. * - positions: the positions associated with these arguments from args.
  5281. * The handler must return a ParseResult.
  5282. */
  5283. function defineEnvironment(names, props, handler) {
  5284. if (typeof names === "string") {
  5285. names = [names];
  5286. }
  5287. if (typeof props === "number") {
  5288. props = { numArgs: props };
  5289. }
  5290. // Set default values of environments
  5291. var data = {
  5292. numArgs: props.numArgs || 0,
  5293. argTypes: props.argTypes,
  5294. greediness: 1,
  5295. allowedInText: !!props.allowedInText,
  5296. numOptionalArgs: props.numOptionalArgs || 0,
  5297. handler: handler
  5298. };
  5299. for (var i = 0; i < names.length; ++i) {
  5300. module.exports[names[i]] = data;
  5301. }
  5302. }
  5303. // Decides on a style for cells in an array according to whether the given
  5304. // environment name starts with the letter 'd'.
  5305. function dCellStyle(envName) {
  5306. if (envName.substr(0, 1) === "d") {
  5307. return "display";
  5308. } else {
  5309. return "text";
  5310. }
  5311. }
  5312. // Arrays are part of LaTeX, defined in lttab.dtx so its documentation
  5313. // is part of the source2e.pdf file of LaTeX2e source documentation.
  5314. // {darray} is an {array} environment where cells are set in \displaystyle,
  5315. // as defined in nccmath.sty.
  5316. defineEnvironment(["array", "darray"], {
  5317. numArgs: 1
  5318. }, function (context, args) {
  5319. var colalign = args[0];
  5320. colalign = colalign.value.map ? colalign.value : [colalign];
  5321. var cols = colalign.map(function (node) {
  5322. var ca = node.value;
  5323. if ("lcr".indexOf(ca) !== -1) {
  5324. return {
  5325. type: "align",
  5326. align: ca
  5327. };
  5328. } else if (ca === "|") {
  5329. return {
  5330. type: "separator",
  5331. separator: "|"
  5332. };
  5333. }
  5334. throw new _ParseError2.default("Unknown column alignment: " + node.value, node);
  5335. });
  5336. var res = {
  5337. type: "array",
  5338. cols: cols,
  5339. hskipBeforeAndAfter: true };
  5340. res = parseArray(context.parser, res, dCellStyle(context.envName));
  5341. return res;
  5342. });
  5343. // The matrix environments of amsmath builds on the array environment
  5344. // of LaTeX, which is discussed above.
  5345. defineEnvironment(["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix"], {}, function (context) {
  5346. var delimiters = {
  5347. "matrix": null,
  5348. "pmatrix": ["(", ")"],
  5349. "bmatrix": ["[", "]"],
  5350. "Bmatrix": ["\\{", "\\}"],
  5351. "vmatrix": ["|", "|"],
  5352. "Vmatrix": ["\\Vert", "\\Vert"]
  5353. }[context.envName];
  5354. var res = {
  5355. type: "array",
  5356. hskipBeforeAndAfter: false };
  5357. res = parseArray(context.parser, res, dCellStyle(context.envName));
  5358. if (delimiters) {
  5359. res = new _ParseNode2.default("leftright", {
  5360. body: [res],
  5361. left: delimiters[0],
  5362. right: delimiters[1]
  5363. }, context.mode);
  5364. }
  5365. return res;
  5366. });
  5367. // A cases environment (in amsmath.sty) is almost equivalent to
  5368. // \def\arraystretch{1.2}%
  5369. // \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right.
  5370. // {dcases} is a {cases} environment where cells are set in \displaystyle,
  5371. // as defined in mathtools.sty.
  5372. defineEnvironment(["cases", "dcases"], {}, function (context) {
  5373. var res = {
  5374. type: "array",
  5375. arraystretch: 1.2,
  5376. cols: [{
  5377. type: "align",
  5378. align: "l",
  5379. pregap: 0,
  5380. // TODO(kevinb) get the current style.
  5381. // For now we use the metrics for TEXT style which is what we were
  5382. // doing before. Before attempting to get the current style we
  5383. // should look at TeX's behavior especially for \over and matrices.
  5384. postgap: 1.0 }, {
  5385. type: "align",
  5386. align: "l",
  5387. pregap: 0,
  5388. postgap: 0
  5389. }]
  5390. };
  5391. res = parseArray(context.parser, res, dCellStyle(context.envName));
  5392. res = new _ParseNode2.default("leftright", {
  5393. body: [res],
  5394. left: "\\{",
  5395. right: "."
  5396. }, context.mode);
  5397. return res;
  5398. });
  5399. // An aligned environment is like the align* environment
  5400. // except it operates within math mode.
  5401. // Note that we assume \nomallineskiplimit to be zero,
  5402. // so that \strut@ is the same as \strut.
  5403. defineEnvironment("aligned", {}, function (context) {
  5404. var res = {
  5405. type: "array",
  5406. cols: [],
  5407. addJot: true
  5408. };
  5409. res = parseArray(context.parser, res, "display");
  5410. // Count number of columns = maximum number of cells in each row.
  5411. // At the same time, prepend empty group {} at beginning of every second
  5412. // cell in each row (starting with second cell) so that operators become
  5413. // binary. This behavior is implemented in amsmath's \start@aligned.
  5414. var emptyGroup = new _ParseNode2.default("ordgroup", [], context.mode);
  5415. var numCols = 0;
  5416. res.value.body.forEach(function (row) {
  5417. for (var i = 1; i < row.length; i += 2) {
  5418. // Modify ordgroup node within styling node
  5419. var ordgroup = row[i].value.value[0];
  5420. ordgroup.value.unshift(emptyGroup);
  5421. }
  5422. if (numCols < row.length) {
  5423. numCols = row.length;
  5424. }
  5425. });
  5426. for (var i = 0; i < numCols; ++i) {
  5427. var align = "r";
  5428. var pregap = 0;
  5429. if (i % 2 === 1) {
  5430. align = "l";
  5431. } else if (i > 0) {
  5432. pregap = 2; // one \qquad between columns
  5433. }
  5434. res.value.cols[i] = {
  5435. type: "align",
  5436. align: align,
  5437. pregap: pregap,
  5438. postgap: 0
  5439. };
  5440. }
  5441. return res;
  5442. });
  5443. // A gathered environment is like an array environment with one centered
  5444. // column, but where rows are considered lines so get \jot line spacing
  5445. // and contents are set in \displaystyle.
  5446. defineEnvironment("gathered", {}, function (context) {
  5447. var res = {
  5448. type: "array",
  5449. cols: [{
  5450. type: "align",
  5451. align: "c"
  5452. }],
  5453. addJot: true
  5454. };
  5455. res = parseArray(context.parser, res, "display");
  5456. return res;
  5457. });
  5458. },{"./ParseError":29,"./ParseNode":30}],41:[function(require,module,exports){
  5459. "use strict";
  5460. var _unicodeRegexes = require("./unicodeRegexes");
  5461. var _fontMetricsData = require("./fontMetricsData");
  5462. var _fontMetricsData2 = _interopRequireDefault(_fontMetricsData);
  5463. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5464. /**
  5465. * This file contains metrics regarding fonts and individual symbols. The sigma
  5466. * and xi variables, as well as the metricMap map contain data extracted from
  5467. * TeX, TeX font metrics, and the TTF files. These data are then exposed via the
  5468. * `metrics` variable and the getCharacterMetrics function.
  5469. */
  5470. // In TeX, there are actually three sets of dimensions, one for each of
  5471. // textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
  5472. // 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
  5473. // provided in the the arrays below, in that order.
  5474. //
  5475. // The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
  5476. // This was determined by running the following script:
  5477. //
  5478. // latex -interaction=nonstopmode \
  5479. // '\documentclass{article}\usepackage{amsmath}\begin{document}' \
  5480. // '$a$ \expandafter\show\the\textfont2' \
  5481. // '\expandafter\show\the\scriptfont2' \
  5482. // '\expandafter\show\the\scriptscriptfont2' \
  5483. // '\stop'
  5484. //
  5485. // The metrics themselves were retreived using the following commands:
  5486. //
  5487. // tftopl cmsy10
  5488. // tftopl cmsy7
  5489. // tftopl cmsy5
  5490. //
  5491. // The output of each of these commands is quite lengthy. The only part we
  5492. // care about is the FONTDIMEN section. Each value is measured in EMs.
  5493. var sigmasAndXis = {
  5494. slant: [0.250, 0.250, 0.250], // sigma1
  5495. space: [0.000, 0.000, 0.000], // sigma2
  5496. stretch: [0.000, 0.000, 0.000], // sigma3
  5497. shrink: [0.000, 0.000, 0.000], // sigma4
  5498. xHeight: [0.431, 0.431, 0.431], // sigma5
  5499. quad: [1.000, 1.171, 1.472], // sigma6
  5500. extraSpace: [0.000, 0.000, 0.000], // sigma7
  5501. num1: [0.677, 0.732, 0.925], // sigma8
  5502. num2: [0.394, 0.384, 0.387], // sigma9
  5503. num3: [0.444, 0.471, 0.504], // sigma10
  5504. denom1: [0.686, 0.752, 1.025], // sigma11
  5505. denom2: [0.345, 0.344, 0.532], // sigma12
  5506. sup1: [0.413, 0.503, 0.504], // sigma13
  5507. sup2: [0.363, 0.431, 0.404], // sigma14
  5508. sup3: [0.289, 0.286, 0.294], // sigma15
  5509. sub1: [0.150, 0.143, 0.200], // sigma16
  5510. sub2: [0.247, 0.286, 0.400], // sigma17
  5511. supDrop: [0.386, 0.353, 0.494], // sigma18
  5512. subDrop: [0.050, 0.071, 0.100], // sigma19
  5513. delim1: [2.390, 1.700, 1.980], // sigma20
  5514. delim2: [1.010, 1.157, 1.420], // sigma21
  5515. axisHeight: [0.250, 0.250, 0.250], // sigma22
  5516. // These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
  5517. // they correspond to the font parameters of the extension fonts (family 3).
  5518. // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
  5519. // match cmex7, we'd use cmex7.tfm values for script and scriptscript
  5520. // values.
  5521. defaultRuleThickness: [0.04, 0.049, 0.049], // xi8; cmex7: 0.049
  5522. bigOpSpacing1: [0.111, 0.111, 0.111], // xi9
  5523. bigOpSpacing2: [0.166, 0.166, 0.166], // xi10
  5524. bigOpSpacing3: [0.2, 0.2, 0.2], // xi11
  5525. bigOpSpacing4: [0.6, 0.611, 0.611], // xi12; cmex7: 0.611
  5526. bigOpSpacing5: [0.1, 0.143, 0.143], // xi13; cmex7: 0.143
  5527. // The \sqrt rule width is taken from the height of the surd character.
  5528. // Since we use the same font at all sizes, this thickness doesn't scale.
  5529. sqrtRuleThickness: [0.04, 0.04, 0.04],
  5530. // This value determines how large a pt is, for metrics which are defined
  5531. // in terms of pts.
  5532. // This value is also used in katex.less; if you change it make sure the
  5533. // values match.
  5534. ptPerEm: [10.0, 10.0, 10.0],
  5535. // The space between adjacent `|` columns in an array definition. From
  5536. // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
  5537. doubleRuleSep: [0.2, 0.2, 0.2]
  5538. };
  5539. // This map contains a mapping from font name and character code to character
  5540. // metrics, including height, depth, italic correction, and skew (kern from the
  5541. // character to the corresponding \skewchar)
  5542. // This map is generated via `make metrics`. It should not be changed manually.
  5543. // These are very rough approximations. We default to Times New Roman which
  5544. // should have Latin-1 and Cyrillic characters, but may not depending on the
  5545. // operating system. The metrics do not account for extra height from the
  5546. // accents. In the case of Cyrillic characters which have both ascenders and
  5547. // descenders we prefer approximations with ascenders, primarily to prevent
  5548. // the fraction bar or root line from intersecting the glyph.
  5549. // TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
  5550. var extraCharacterMap = {
  5551. // Latin-1
  5552. 'À': 'A',
  5553. 'Á': 'A',
  5554. 'Â': 'A',
  5555. 'Ã': 'A',
  5556. 'Ä': 'A',
  5557. 'Å': 'A',
  5558. 'Æ': 'A',
  5559. 'Ç': 'C',
  5560. 'È': 'E',
  5561. 'É': 'E',
  5562. 'Ê': 'E',
  5563. 'Ë': 'E',
  5564. 'Ì': 'I',
  5565. 'Í': 'I',
  5566. 'Î': 'I',
  5567. 'Ï': 'I',
  5568. 'Ð': 'D',
  5569. 'Ñ': 'N',
  5570. 'Ò': 'O',
  5571. 'Ó': 'O',
  5572. 'Ô': 'O',
  5573. 'Õ': 'O',
  5574. 'Ö': 'O',
  5575. 'Ø': 'O',
  5576. 'Ù': 'U',
  5577. 'Ú': 'U',
  5578. 'Û': 'U',
  5579. 'Ü': 'U',
  5580. 'Ý': 'Y',
  5581. 'Þ': 'o',
  5582. 'ß': 'B',
  5583. 'à': 'a',
  5584. 'á': 'a',
  5585. 'â': 'a',
  5586. 'ã': 'a',
  5587. 'ä': 'a',
  5588. 'å': 'a',
  5589. 'æ': 'a',
  5590. 'ç': 'c',
  5591. 'è': 'e',
  5592. 'é': 'e',
  5593. 'ê': 'e',
  5594. 'ë': 'e',
  5595. 'ì': 'i',
  5596. 'í': 'i',
  5597. 'î': 'i',
  5598. 'ï': 'i',
  5599. 'ð': 'd',
  5600. 'ñ': 'n',
  5601. 'ò': 'o',
  5602. 'ó': 'o',
  5603. 'ô': 'o',
  5604. 'õ': 'o',
  5605. 'ö': 'o',
  5606. 'ø': 'o',
  5607. 'ù': 'u',
  5608. 'ú': 'u',
  5609. 'û': 'u',
  5610. 'ü': 'u',
  5611. 'ý': 'y',
  5612. 'þ': 'o',
  5613. 'ÿ': 'y',
  5614. // Cyrillic
  5615. 'А': 'A',
  5616. 'Б': 'B',
  5617. 'В': 'B',
  5618. 'Г': 'F',
  5619. 'Д': 'A',
  5620. 'Е': 'E',
  5621. 'Ж': 'K',
  5622. 'З': '3',
  5623. 'И': 'N',
  5624. 'Й': 'N',
  5625. 'К': 'K',
  5626. 'Л': 'N',
  5627. 'М': 'M',
  5628. 'Н': 'H',
  5629. 'О': 'O',
  5630. 'П': 'N',
  5631. 'Р': 'P',
  5632. 'С': 'C',
  5633. 'Т': 'T',
  5634. 'У': 'y',
  5635. 'Ф': 'O',
  5636. 'Х': 'X',
  5637. 'Ц': 'U',
  5638. 'Ч': 'h',
  5639. 'Ш': 'W',
  5640. 'Щ': 'W',
  5641. 'Ъ': 'B',
  5642. 'Ы': 'X',
  5643. 'Ь': 'B',
  5644. 'Э': '3',
  5645. 'Ю': 'X',
  5646. 'Я': 'R',
  5647. 'а': 'a',
  5648. 'б': 'b',
  5649. 'в': 'a',
  5650. 'г': 'r',
  5651. 'д': 'y',
  5652. 'е': 'e',
  5653. 'ж': 'm',
  5654. 'з': 'e',
  5655. 'и': 'n',
  5656. 'й': 'n',
  5657. 'к': 'n',
  5658. 'л': 'n',
  5659. 'м': 'm',
  5660. 'н': 'n',
  5661. 'о': 'o',
  5662. 'п': 'n',
  5663. 'р': 'p',
  5664. 'с': 'c',
  5665. 'т': 'o',
  5666. 'у': 'y',
  5667. 'ф': 'b',
  5668. 'х': 'x',
  5669. 'ц': 'n',
  5670. 'ч': 'n',
  5671. 'ш': 'w',
  5672. 'щ': 'w',
  5673. 'ъ': 'a',
  5674. 'ы': 'm',
  5675. 'ь': 'a',
  5676. 'э': 'e',
  5677. 'ю': 'm',
  5678. 'я': 'r'
  5679. };
  5680. /**
  5681. * This function is a convenience function for looking up information in the
  5682. * metricMap table. It takes a character as a string, and a style.
  5683. *
  5684. * Note: the `width` property may be undefined if fontMetricsData.js wasn't
  5685. * built using `Make extended_metrics`.
  5686. */
  5687. var getCharacterMetrics = function getCharacterMetrics(character, style) {
  5688. var ch = character.charCodeAt(0);
  5689. if (character[0] in extraCharacterMap) {
  5690. ch = extraCharacterMap[character[0]].charCodeAt(0);
  5691. } else if (_unicodeRegexes.cjkRegex.test(character[0])) {
  5692. ch = 'M'.charCodeAt(0);
  5693. }
  5694. var metrics = _fontMetricsData2.default[style][ch];
  5695. if (metrics) {
  5696. return {
  5697. depth: metrics[0],
  5698. height: metrics[1],
  5699. italic: metrics[2],
  5700. skew: metrics[3],
  5701. width: metrics[4]
  5702. };
  5703. }
  5704. };
  5705. var fontMetricsBySizeIndex = {};
  5706. /**
  5707. * Get the font metrics for a given size.
  5708. */
  5709. var getFontMetrics = function getFontMetrics(size) {
  5710. var sizeIndex = void 0;
  5711. if (size >= 5) {
  5712. sizeIndex = 0;
  5713. } else if (size >= 3) {
  5714. sizeIndex = 1;
  5715. } else {
  5716. sizeIndex = 2;
  5717. }
  5718. if (!fontMetricsBySizeIndex[sizeIndex]) {
  5719. var metrics = fontMetricsBySizeIndex[sizeIndex] = {};
  5720. for (var key in sigmasAndXis) {
  5721. if (sigmasAndXis.hasOwnProperty(key)) {
  5722. metrics[key] = sigmasAndXis[key][sizeIndex];
  5723. }
  5724. }
  5725. metrics.cssEmPerMu = metrics.quad / 18;
  5726. }
  5727. return fontMetricsBySizeIndex[sizeIndex];
  5728. };
  5729. module.exports = {
  5730. getFontMetrics: getFontMetrics,
  5731. getCharacterMetrics: getCharacterMetrics
  5732. };
  5733. },{"./fontMetricsData":42,"./unicodeRegexes":49}],42:[function(require,module,exports){
  5734. "use strict";
  5735. module.exports = {
  5736. "AMS-Regular": {
  5737. "65": [0, 0.68889, 0, 0],
  5738. "66": [0, 0.68889, 0, 0],
  5739. "67": [0, 0.68889, 0, 0],
  5740. "68": [0, 0.68889, 0, 0],
  5741. "69": [0, 0.68889, 0, 0],
  5742. "70": [0, 0.68889, 0, 0],
  5743. "71": [0, 0.68889, 0, 0],
  5744. "72": [0, 0.68889, 0, 0],
  5745. "73": [0, 0.68889, 0, 0],
  5746. "74": [0.16667, 0.68889, 0, 0],
  5747. "75": [0, 0.68889, 0, 0],
  5748. "76": [0, 0.68889, 0, 0],
  5749. "77": [0, 0.68889, 0, 0],
  5750. "78": [0, 0.68889, 0, 0],
  5751. "79": [0.16667, 0.68889, 0, 0],
  5752. "80": [0, 0.68889, 0, 0],
  5753. "81": [0.16667, 0.68889, 0, 0],
  5754. "82": [0, 0.68889, 0, 0],
  5755. "83": [0, 0.68889, 0, 0],
  5756. "84": [0, 0.68889, 0, 0],
  5757. "85": [0, 0.68889, 0, 0],
  5758. "86": [0, 0.68889, 0, 0],
  5759. "87": [0, 0.68889, 0, 0],
  5760. "88": [0, 0.68889, 0, 0],
  5761. "89": [0, 0.68889, 0, 0],
  5762. "90": [0, 0.68889, 0, 0],
  5763. "107": [0, 0.68889, 0, 0],
  5764. "165": [0, 0.675, 0.025, 0],
  5765. "174": [0.15559, 0.69224, 0, 0],
  5766. "240": [0, 0.68889, 0, 0],
  5767. "295": [0, 0.68889, 0, 0],
  5768. "710": [0, 0.825, 0, 0],
  5769. "732": [0, 0.9, 0, 0],
  5770. "770": [0, 0.825, 0, 0],
  5771. "771": [0, 0.9, 0, 0],
  5772. "989": [0.08167, 0.58167, 0, 0],
  5773. "1008": [0, 0.43056, 0.04028, 0],
  5774. "8245": [0, 0.54986, 0, 0],
  5775. "8463": [0, 0.68889, 0, 0],
  5776. "8487": [0, 0.68889, 0, 0],
  5777. "8498": [0, 0.68889, 0, 0],
  5778. "8502": [0, 0.68889, 0, 0],
  5779. "8503": [0, 0.68889, 0, 0],
  5780. "8504": [0, 0.68889, 0, 0],
  5781. "8513": [0, 0.68889, 0, 0],
  5782. "8592": [-0.03598, 0.46402, 0, 0],
  5783. "8594": [-0.03598, 0.46402, 0, 0],
  5784. "8602": [-0.13313, 0.36687, 0, 0],
  5785. "8603": [-0.13313, 0.36687, 0, 0],
  5786. "8606": [0.01354, 0.52239, 0, 0],
  5787. "8608": [0.01354, 0.52239, 0, 0],
  5788. "8610": [0.01354, 0.52239, 0, 0],
  5789. "8611": [0.01354, 0.52239, 0, 0],
  5790. "8619": [0, 0.54986, 0, 0],
  5791. "8620": [0, 0.54986, 0, 0],
  5792. "8621": [-0.13313, 0.37788, 0, 0],
  5793. "8622": [-0.13313, 0.36687, 0, 0],
  5794. "8624": [0, 0.69224, 0, 0],
  5795. "8625": [0, 0.69224, 0, 0],
  5796. "8630": [0, 0.43056, 0, 0],
  5797. "8631": [0, 0.43056, 0, 0],
  5798. "8634": [0.08198, 0.58198, 0, 0],
  5799. "8635": [0.08198, 0.58198, 0, 0],
  5800. "8638": [0.19444, 0.69224, 0, 0],
  5801. "8639": [0.19444, 0.69224, 0, 0],
  5802. "8642": [0.19444, 0.69224, 0, 0],
  5803. "8643": [0.19444, 0.69224, 0, 0],
  5804. "8644": [0.1808, 0.675, 0, 0],
  5805. "8646": [0.1808, 0.675, 0, 0],
  5806. "8647": [0.1808, 0.675, 0, 0],
  5807. "8648": [0.19444, 0.69224, 0, 0],
  5808. "8649": [0.1808, 0.675, 0, 0],
  5809. "8650": [0.19444, 0.69224, 0, 0],
  5810. "8651": [0.01354, 0.52239, 0, 0],
  5811. "8652": [0.01354, 0.52239, 0, 0],
  5812. "8653": [-0.13313, 0.36687, 0, 0],
  5813. "8654": [-0.13313, 0.36687, 0, 0],
  5814. "8655": [-0.13313, 0.36687, 0, 0],
  5815. "8666": [0.13667, 0.63667, 0, 0],
  5816. "8667": [0.13667, 0.63667, 0, 0],
  5817. "8669": [-0.13313, 0.37788, 0, 0],
  5818. "8672": [-0.064, 0.437, 0, 0],
  5819. "8674": [-0.064, 0.437, 0, 0],
  5820. "8705": [0, 0.825, 0, 0],
  5821. "8708": [0, 0.68889, 0, 0],
  5822. "8709": [0.08167, 0.58167, 0, 0],
  5823. "8717": [0, 0.43056, 0, 0],
  5824. "8722": [-0.03598, 0.46402, 0, 0],
  5825. "8724": [0.08198, 0.69224, 0, 0],
  5826. "8726": [0.08167, 0.58167, 0, 0],
  5827. "8733": [0, 0.69224, 0, 0],
  5828. "8736": [0, 0.69224, 0, 0],
  5829. "8737": [0, 0.69224, 0, 0],
  5830. "8738": [0.03517, 0.52239, 0, 0],
  5831. "8739": [0.08167, 0.58167, 0, 0],
  5832. "8740": [0.25142, 0.74111, 0, 0],
  5833. "8741": [0.08167, 0.58167, 0, 0],
  5834. "8742": [0.25142, 0.74111, 0, 0],
  5835. "8756": [0, 0.69224, 0, 0],
  5836. "8757": [0, 0.69224, 0, 0],
  5837. "8764": [-0.13313, 0.36687, 0, 0],
  5838. "8765": [-0.13313, 0.37788, 0, 0],
  5839. "8769": [-0.13313, 0.36687, 0, 0],
  5840. "8770": [-0.03625, 0.46375, 0, 0],
  5841. "8774": [0.30274, 0.79383, 0, 0],
  5842. "8776": [-0.01688, 0.48312, 0, 0],
  5843. "8778": [0.08167, 0.58167, 0, 0],
  5844. "8782": [0.06062, 0.54986, 0, 0],
  5845. "8783": [0.06062, 0.54986, 0, 0],
  5846. "8785": [0.08198, 0.58198, 0, 0],
  5847. "8786": [0.08198, 0.58198, 0, 0],
  5848. "8787": [0.08198, 0.58198, 0, 0],
  5849. "8790": [0, 0.69224, 0, 0],
  5850. "8791": [0.22958, 0.72958, 0, 0],
  5851. "8796": [0.08198, 0.91667, 0, 0],
  5852. "8806": [0.25583, 0.75583, 0, 0],
  5853. "8807": [0.25583, 0.75583, 0, 0],
  5854. "8808": [0.25142, 0.75726, 0, 0],
  5855. "8809": [0.25142, 0.75726, 0, 0],
  5856. "8812": [0.25583, 0.75583, 0, 0],
  5857. "8814": [0.20576, 0.70576, 0, 0],
  5858. "8815": [0.20576, 0.70576, 0, 0],
  5859. "8816": [0.30274, 0.79383, 0, 0],
  5860. "8817": [0.30274, 0.79383, 0, 0],
  5861. "8818": [0.22958, 0.72958, 0, 0],
  5862. "8819": [0.22958, 0.72958, 0, 0],
  5863. "8822": [0.1808, 0.675, 0, 0],
  5864. "8823": [0.1808, 0.675, 0, 0],
  5865. "8828": [0.13667, 0.63667, 0, 0],
  5866. "8829": [0.13667, 0.63667, 0, 0],
  5867. "8830": [0.22958, 0.72958, 0, 0],
  5868. "8831": [0.22958, 0.72958, 0, 0],
  5869. "8832": [0.20576, 0.70576, 0, 0],
  5870. "8833": [0.20576, 0.70576, 0, 0],
  5871. "8840": [0.30274, 0.79383, 0, 0],
  5872. "8841": [0.30274, 0.79383, 0, 0],
  5873. "8842": [0.13597, 0.63597, 0, 0],
  5874. "8843": [0.13597, 0.63597, 0, 0],
  5875. "8847": [0.03517, 0.54986, 0, 0],
  5876. "8848": [0.03517, 0.54986, 0, 0],
  5877. "8858": [0.08198, 0.58198, 0, 0],
  5878. "8859": [0.08198, 0.58198, 0, 0],
  5879. "8861": [0.08198, 0.58198, 0, 0],
  5880. "8862": [0, 0.675, 0, 0],
  5881. "8863": [0, 0.675, 0, 0],
  5882. "8864": [0, 0.675, 0, 0],
  5883. "8865": [0, 0.675, 0, 0],
  5884. "8872": [0, 0.69224, 0, 0],
  5885. "8873": [0, 0.69224, 0, 0],
  5886. "8874": [0, 0.69224, 0, 0],
  5887. "8876": [0, 0.68889, 0, 0],
  5888. "8877": [0, 0.68889, 0, 0],
  5889. "8878": [0, 0.68889, 0, 0],
  5890. "8879": [0, 0.68889, 0, 0],
  5891. "8882": [0.03517, 0.54986, 0, 0],
  5892. "8883": [0.03517, 0.54986, 0, 0],
  5893. "8884": [0.13667, 0.63667, 0, 0],
  5894. "8885": [0.13667, 0.63667, 0, 0],
  5895. "8888": [0, 0.54986, 0, 0],
  5896. "8890": [0.19444, 0.43056, 0, 0],
  5897. "8891": [0.19444, 0.69224, 0, 0],
  5898. "8892": [0.19444, 0.69224, 0, 0],
  5899. "8901": [0, 0.54986, 0, 0],
  5900. "8903": [0.08167, 0.58167, 0, 0],
  5901. "8905": [0.08167, 0.58167, 0, 0],
  5902. "8906": [0.08167, 0.58167, 0, 0],
  5903. "8907": [0, 0.69224, 0, 0],
  5904. "8908": [0, 0.69224, 0, 0],
  5905. "8909": [-0.03598, 0.46402, 0, 0],
  5906. "8910": [0, 0.54986, 0, 0],
  5907. "8911": [0, 0.54986, 0, 0],
  5908. "8912": [0.03517, 0.54986, 0, 0],
  5909. "8913": [0.03517, 0.54986, 0, 0],
  5910. "8914": [0, 0.54986, 0, 0],
  5911. "8915": [0, 0.54986, 0, 0],
  5912. "8916": [0, 0.69224, 0, 0],
  5913. "8918": [0.0391, 0.5391, 0, 0],
  5914. "8919": [0.0391, 0.5391, 0, 0],
  5915. "8920": [0.03517, 0.54986, 0, 0],
  5916. "8921": [0.03517, 0.54986, 0, 0],
  5917. "8922": [0.38569, 0.88569, 0, 0],
  5918. "8923": [0.38569, 0.88569, 0, 0],
  5919. "8926": [0.13667, 0.63667, 0, 0],
  5920. "8927": [0.13667, 0.63667, 0, 0],
  5921. "8928": [0.30274, 0.79383, 0, 0],
  5922. "8929": [0.30274, 0.79383, 0, 0],
  5923. "8934": [0.23222, 0.74111, 0, 0],
  5924. "8935": [0.23222, 0.74111, 0, 0],
  5925. "8936": [0.23222, 0.74111, 0, 0],
  5926. "8937": [0.23222, 0.74111, 0, 0],
  5927. "8938": [0.20576, 0.70576, 0, 0],
  5928. "8939": [0.20576, 0.70576, 0, 0],
  5929. "8940": [0.30274, 0.79383, 0, 0],
  5930. "8941": [0.30274, 0.79383, 0, 0],
  5931. "8994": [0.19444, 0.69224, 0, 0],
  5932. "8995": [0.19444, 0.69224, 0, 0],
  5933. "9416": [0.15559, 0.69224, 0, 0],
  5934. "9484": [0, 0.69224, 0, 0],
  5935. "9488": [0, 0.69224, 0, 0],
  5936. "9492": [0, 0.37788, 0, 0],
  5937. "9496": [0, 0.37788, 0, 0],
  5938. "9585": [0.19444, 0.68889, 0, 0],
  5939. "9586": [0.19444, 0.74111, 0, 0],
  5940. "9632": [0, 0.675, 0, 0],
  5941. "9633": [0, 0.675, 0, 0],
  5942. "9650": [0, 0.54986, 0, 0],
  5943. "9651": [0, 0.54986, 0, 0],
  5944. "9654": [0.03517, 0.54986, 0, 0],
  5945. "9660": [0, 0.54986, 0, 0],
  5946. "9661": [0, 0.54986, 0, 0],
  5947. "9664": [0.03517, 0.54986, 0, 0],
  5948. "9674": [0.11111, 0.69224, 0, 0],
  5949. "9733": [0.19444, 0.69224, 0, 0],
  5950. "10003": [0, 0.69224, 0, 0],
  5951. "10016": [0, 0.69224, 0, 0],
  5952. "10731": [0.11111, 0.69224, 0, 0],
  5953. "10846": [0.19444, 0.75583, 0, 0],
  5954. "10877": [0.13667, 0.63667, 0, 0],
  5955. "10878": [0.13667, 0.63667, 0, 0],
  5956. "10885": [0.25583, 0.75583, 0, 0],
  5957. "10886": [0.25583, 0.75583, 0, 0],
  5958. "10887": [0.13597, 0.63597, 0, 0],
  5959. "10888": [0.13597, 0.63597, 0, 0],
  5960. "10889": [0.26167, 0.75726, 0, 0],
  5961. "10890": [0.26167, 0.75726, 0, 0],
  5962. "10891": [0.48256, 0.98256, 0, 0],
  5963. "10892": [0.48256, 0.98256, 0, 0],
  5964. "10901": [0.13667, 0.63667, 0, 0],
  5965. "10902": [0.13667, 0.63667, 0, 0],
  5966. "10933": [0.25142, 0.75726, 0, 0],
  5967. "10934": [0.25142, 0.75726, 0, 0],
  5968. "10935": [0.26167, 0.75726, 0, 0],
  5969. "10936": [0.26167, 0.75726, 0, 0],
  5970. "10937": [0.26167, 0.75726, 0, 0],
  5971. "10938": [0.26167, 0.75726, 0, 0],
  5972. "10949": [0.25583, 0.75583, 0, 0],
  5973. "10950": [0.25583, 0.75583, 0, 0],
  5974. "10955": [0.28481, 0.79383, 0, 0],
  5975. "10956": [0.28481, 0.79383, 0, 0],
  5976. "57350": [0.08167, 0.58167, 0, 0],
  5977. "57351": [0.08167, 0.58167, 0, 0],
  5978. "57352": [0.08167, 0.58167, 0, 0],
  5979. "57353": [0, 0.43056, 0.04028, 0],
  5980. "57356": [0.25142, 0.75726, 0, 0],
  5981. "57357": [0.25142, 0.75726, 0, 0],
  5982. "57358": [0.41951, 0.91951, 0, 0],
  5983. "57359": [0.30274, 0.79383, 0, 0],
  5984. "57360": [0.30274, 0.79383, 0, 0],
  5985. "57361": [0.41951, 0.91951, 0, 0],
  5986. "57366": [0.25142, 0.75726, 0, 0],
  5987. "57367": [0.25142, 0.75726, 0, 0],
  5988. "57368": [0.25142, 0.75726, 0, 0],
  5989. "57369": [0.25142, 0.75726, 0, 0],
  5990. "57370": [0.13597, 0.63597, 0, 0],
  5991. "57371": [0.13597, 0.63597, 0, 0]
  5992. },
  5993. "Caligraphic-Regular": {
  5994. "48": [0, 0.43056, 0, 0],
  5995. "49": [0, 0.43056, 0, 0],
  5996. "50": [0, 0.43056, 0, 0],
  5997. "51": [0.19444, 0.43056, 0, 0],
  5998. "52": [0.19444, 0.43056, 0, 0],
  5999. "53": [0.19444, 0.43056, 0, 0],
  6000. "54": [0, 0.64444, 0, 0],
  6001. "55": [0.19444, 0.43056, 0, 0],
  6002. "56": [0, 0.64444, 0, 0],
  6003. "57": [0.19444, 0.43056, 0, 0],
  6004. "65": [0, 0.68333, 0, 0.19445],
  6005. "66": [0, 0.68333, 0.03041, 0.13889],
  6006. "67": [0, 0.68333, 0.05834, 0.13889],
  6007. "68": [0, 0.68333, 0.02778, 0.08334],
  6008. "69": [0, 0.68333, 0.08944, 0.11111],
  6009. "70": [0, 0.68333, 0.09931, 0.11111],
  6010. "71": [0.09722, 0.68333, 0.0593, 0.11111],
  6011. "72": [0, 0.68333, 0.00965, 0.11111],
  6012. "73": [0, 0.68333, 0.07382, 0],
  6013. "74": [0.09722, 0.68333, 0.18472, 0.16667],
  6014. "75": [0, 0.68333, 0.01445, 0.05556],
  6015. "76": [0, 0.68333, 0, 0.13889],
  6016. "77": [0, 0.68333, 0, 0.13889],
  6017. "78": [0, 0.68333, 0.14736, 0.08334],
  6018. "79": [0, 0.68333, 0.02778, 0.11111],
  6019. "80": [0, 0.68333, 0.08222, 0.08334],
  6020. "81": [0.09722, 0.68333, 0, 0.11111],
  6021. "82": [0, 0.68333, 0, 0.08334],
  6022. "83": [0, 0.68333, 0.075, 0.13889],
  6023. "84": [0, 0.68333, 0.25417, 0],
  6024. "85": [0, 0.68333, 0.09931, 0.08334],
  6025. "86": [0, 0.68333, 0.08222, 0],
  6026. "87": [0, 0.68333, 0.08222, 0.08334],
  6027. "88": [0, 0.68333, 0.14643, 0.13889],
  6028. "89": [0.09722, 0.68333, 0.08222, 0.08334],
  6029. "90": [0, 0.68333, 0.07944, 0.13889]
  6030. },
  6031. "Fraktur-Regular": {
  6032. "33": [0, 0.69141, 0, 0],
  6033. "34": [0, 0.69141, 0, 0],
  6034. "38": [0, 0.69141, 0, 0],
  6035. "39": [0, 0.69141, 0, 0],
  6036. "40": [0.24982, 0.74947, 0, 0],
  6037. "41": [0.24982, 0.74947, 0, 0],
  6038. "42": [0, 0.62119, 0, 0],
  6039. "43": [0.08319, 0.58283, 0, 0],
  6040. "44": [0, 0.10803, 0, 0],
  6041. "45": [0.08319, 0.58283, 0, 0],
  6042. "46": [0, 0.10803, 0, 0],
  6043. "47": [0.24982, 0.74947, 0, 0],
  6044. "48": [0, 0.47534, 0, 0],
  6045. "49": [0, 0.47534, 0, 0],
  6046. "50": [0, 0.47534, 0, 0],
  6047. "51": [0.18906, 0.47534, 0, 0],
  6048. "52": [0.18906, 0.47534, 0, 0],
  6049. "53": [0.18906, 0.47534, 0, 0],
  6050. "54": [0, 0.69141, 0, 0],
  6051. "55": [0.18906, 0.47534, 0, 0],
  6052. "56": [0, 0.69141, 0, 0],
  6053. "57": [0.18906, 0.47534, 0, 0],
  6054. "58": [0, 0.47534, 0, 0],
  6055. "59": [0.12604, 0.47534, 0, 0],
  6056. "61": [-0.13099, 0.36866, 0, 0],
  6057. "63": [0, 0.69141, 0, 0],
  6058. "65": [0, 0.69141, 0, 0],
  6059. "66": [0, 0.69141, 0, 0],
  6060. "67": [0, 0.69141, 0, 0],
  6061. "68": [0, 0.69141, 0, 0],
  6062. "69": [0, 0.69141, 0, 0],
  6063. "70": [0.12604, 0.69141, 0, 0],
  6064. "71": [0, 0.69141, 0, 0],
  6065. "72": [0.06302, 0.69141, 0, 0],
  6066. "73": [0, 0.69141, 0, 0],
  6067. "74": [0.12604, 0.69141, 0, 0],
  6068. "75": [0, 0.69141, 0, 0],
  6069. "76": [0, 0.69141, 0, 0],
  6070. "77": [0, 0.69141, 0, 0],
  6071. "78": [0, 0.69141, 0, 0],
  6072. "79": [0, 0.69141, 0, 0],
  6073. "80": [0.18906, 0.69141, 0, 0],
  6074. "81": [0.03781, 0.69141, 0, 0],
  6075. "82": [0, 0.69141, 0, 0],
  6076. "83": [0, 0.69141, 0, 0],
  6077. "84": [0, 0.69141, 0, 0],
  6078. "85": [0, 0.69141, 0, 0],
  6079. "86": [0, 0.69141, 0, 0],
  6080. "87": [0, 0.69141, 0, 0],
  6081. "88": [0, 0.69141, 0, 0],
  6082. "89": [0.18906, 0.69141, 0, 0],
  6083. "90": [0.12604, 0.69141, 0, 0],
  6084. "91": [0.24982, 0.74947, 0, 0],
  6085. "93": [0.24982, 0.74947, 0, 0],
  6086. "94": [0, 0.69141, 0, 0],
  6087. "97": [0, 0.47534, 0, 0],
  6088. "98": [0, 0.69141, 0, 0],
  6089. "99": [0, 0.47534, 0, 0],
  6090. "100": [0, 0.62119, 0, 0],
  6091. "101": [0, 0.47534, 0, 0],
  6092. "102": [0.18906, 0.69141, 0, 0],
  6093. "103": [0.18906, 0.47534, 0, 0],
  6094. "104": [0.18906, 0.69141, 0, 0],
  6095. "105": [0, 0.69141, 0, 0],
  6096. "106": [0, 0.69141, 0, 0],
  6097. "107": [0, 0.69141, 0, 0],
  6098. "108": [0, 0.69141, 0, 0],
  6099. "109": [0, 0.47534, 0, 0],
  6100. "110": [0, 0.47534, 0, 0],
  6101. "111": [0, 0.47534, 0, 0],
  6102. "112": [0.18906, 0.52396, 0, 0],
  6103. "113": [0.18906, 0.47534, 0, 0],
  6104. "114": [0, 0.47534, 0, 0],
  6105. "115": [0, 0.47534, 0, 0],
  6106. "116": [0, 0.62119, 0, 0],
  6107. "117": [0, 0.47534, 0, 0],
  6108. "118": [0, 0.52396, 0, 0],
  6109. "119": [0, 0.52396, 0, 0],
  6110. "120": [0.18906, 0.47534, 0, 0],
  6111. "121": [0.18906, 0.47534, 0, 0],
  6112. "122": [0.18906, 0.47534, 0, 0],
  6113. "8216": [0, 0.69141, 0, 0],
  6114. "8217": [0, 0.69141, 0, 0],
  6115. "58112": [0, 0.62119, 0, 0],
  6116. "58113": [0, 0.62119, 0, 0],
  6117. "58114": [0.18906, 0.69141, 0, 0],
  6118. "58115": [0.18906, 0.69141, 0, 0],
  6119. "58116": [0.18906, 0.47534, 0, 0],
  6120. "58117": [0, 0.69141, 0, 0],
  6121. "58118": [0, 0.62119, 0, 0],
  6122. "58119": [0, 0.47534, 0, 0]
  6123. },
  6124. "Main-Bold": {
  6125. "33": [0, 0.69444, 0, 0],
  6126. "34": [0, 0.69444, 0, 0],
  6127. "35": [0.19444, 0.69444, 0, 0],
  6128. "36": [0.05556, 0.75, 0, 0],
  6129. "37": [0.05556, 0.75, 0, 0],
  6130. "38": [0, 0.69444, 0, 0],
  6131. "39": [0, 0.69444, 0, 0],
  6132. "40": [0.25, 0.75, 0, 0],
  6133. "41": [0.25, 0.75, 0, 0],
  6134. "42": [0, 0.75, 0, 0],
  6135. "43": [0.13333, 0.63333, 0, 0],
  6136. "44": [0.19444, 0.15556, 0, 0],
  6137. "45": [0, 0.44444, 0, 0],
  6138. "46": [0, 0.15556, 0, 0],
  6139. "47": [0.25, 0.75, 0, 0],
  6140. "48": [0, 0.64444, 0, 0],
  6141. "49": [0, 0.64444, 0, 0],
  6142. "50": [0, 0.64444, 0, 0],
  6143. "51": [0, 0.64444, 0, 0],
  6144. "52": [0, 0.64444, 0, 0],
  6145. "53": [0, 0.64444, 0, 0],
  6146. "54": [0, 0.64444, 0, 0],
  6147. "55": [0, 0.64444, 0, 0],
  6148. "56": [0, 0.64444, 0, 0],
  6149. "57": [0, 0.64444, 0, 0],
  6150. "58": [0, 0.44444, 0, 0],
  6151. "59": [0.19444, 0.44444, 0, 0],
  6152. "60": [0.08556, 0.58556, 0, 0],
  6153. "61": [-0.10889, 0.39111, 0, 0],
  6154. "62": [0.08556, 0.58556, 0, 0],
  6155. "63": [0, 0.69444, 0, 0],
  6156. "64": [0, 0.69444, 0, 0],
  6157. "65": [0, 0.68611, 0, 0],
  6158. "66": [0, 0.68611, 0, 0],
  6159. "67": [0, 0.68611, 0, 0],
  6160. "68": [0, 0.68611, 0, 0],
  6161. "69": [0, 0.68611, 0, 0],
  6162. "70": [0, 0.68611, 0, 0],
  6163. "71": [0, 0.68611, 0, 0],
  6164. "72": [0, 0.68611, 0, 0],
  6165. "73": [0, 0.68611, 0, 0],
  6166. "74": [0, 0.68611, 0, 0],
  6167. "75": [0, 0.68611, 0, 0],
  6168. "76": [0, 0.68611, 0, 0],
  6169. "77": [0, 0.68611, 0, 0],
  6170. "78": [0, 0.68611, 0, 0],
  6171. "79": [0, 0.68611, 0, 0],
  6172. "80": [0, 0.68611, 0, 0],
  6173. "81": [0.19444, 0.68611, 0, 0],
  6174. "82": [0, 0.68611, 0, 0],
  6175. "83": [0, 0.68611, 0, 0],
  6176. "84": [0, 0.68611, 0, 0],
  6177. "85": [0, 0.68611, 0, 0],
  6178. "86": [0, 0.68611, 0.01597, 0],
  6179. "87": [0, 0.68611, 0.01597, 0],
  6180. "88": [0, 0.68611, 0, 0],
  6181. "89": [0, 0.68611, 0.02875, 0],
  6182. "90": [0, 0.68611, 0, 0],
  6183. "91": [0.25, 0.75, 0, 0],
  6184. "92": [0.25, 0.75, 0, 0],
  6185. "93": [0.25, 0.75, 0, 0],
  6186. "94": [0, 0.69444, 0, 0],
  6187. "95": [0.31, 0.13444, 0.03194, 0],
  6188. "96": [0, 0.69444, 0, 0],
  6189. "97": [0, 0.44444, 0, 0],
  6190. "98": [0, 0.69444, 0, 0],
  6191. "99": [0, 0.44444, 0, 0],
  6192. "100": [0, 0.69444, 0, 0],
  6193. "101": [0, 0.44444, 0, 0],
  6194. "102": [0, 0.69444, 0.10903, 0],
  6195. "103": [0.19444, 0.44444, 0.01597, 0],
  6196. "104": [0, 0.69444, 0, 0],
  6197. "105": [0, 0.69444, 0, 0],
  6198. "106": [0.19444, 0.69444, 0, 0],
  6199. "107": [0, 0.69444, 0, 0],
  6200. "108": [0, 0.69444, 0, 0],
  6201. "109": [0, 0.44444, 0, 0],
  6202. "110": [0, 0.44444, 0, 0],
  6203. "111": [0, 0.44444, 0, 0],
  6204. "112": [0.19444, 0.44444, 0, 0],
  6205. "113": [0.19444, 0.44444, 0, 0],
  6206. "114": [0, 0.44444, 0, 0],
  6207. "115": [0, 0.44444, 0, 0],
  6208. "116": [0, 0.63492, 0, 0],
  6209. "117": [0, 0.44444, 0, 0],
  6210. "118": [0, 0.44444, 0.01597, 0],
  6211. "119": [0, 0.44444, 0.01597, 0],
  6212. "120": [0, 0.44444, 0, 0],
  6213. "121": [0.19444, 0.44444, 0.01597, 0],
  6214. "122": [0, 0.44444, 0, 0],
  6215. "123": [0.25, 0.75, 0, 0],
  6216. "124": [0.25, 0.75, 0, 0],
  6217. "125": [0.25, 0.75, 0, 0],
  6218. "126": [0.35, 0.34444, 0, 0],
  6219. "168": [0, 0.69444, 0, 0],
  6220. "172": [0, 0.44444, 0, 0],
  6221. "175": [0, 0.59611, 0, 0],
  6222. "176": [0, 0.69444, 0, 0],
  6223. "177": [0.13333, 0.63333, 0, 0],
  6224. "180": [0, 0.69444, 0, 0],
  6225. "215": [0.13333, 0.63333, 0, 0],
  6226. "247": [0.13333, 0.63333, 0, 0],
  6227. "305": [0, 0.44444, 0, 0],
  6228. "567": [0.19444, 0.44444, 0, 0],
  6229. "710": [0, 0.69444, 0, 0],
  6230. "711": [0, 0.63194, 0, 0],
  6231. "713": [0, 0.59611, 0, 0],
  6232. "714": [0, 0.69444, 0, 0],
  6233. "715": [0, 0.69444, 0, 0],
  6234. "728": [0, 0.69444, 0, 0],
  6235. "729": [0, 0.69444, 0, 0],
  6236. "730": [0, 0.69444, 0, 0],
  6237. "732": [0, 0.69444, 0, 0],
  6238. "768": [0, 0.69444, 0, 0],
  6239. "769": [0, 0.69444, 0, 0],
  6240. "770": [0, 0.69444, 0, 0],
  6241. "771": [0, 0.69444, 0, 0],
  6242. "772": [0, 0.59611, 0, 0],
  6243. "774": [0, 0.69444, 0, 0],
  6244. "775": [0, 0.69444, 0, 0],
  6245. "776": [0, 0.69444, 0, 0],
  6246. "778": [0, 0.69444, 0, 0],
  6247. "779": [0, 0.69444, 0, 0],
  6248. "780": [0, 0.63194, 0, 0],
  6249. "824": [0.19444, 0.69444, 0, 0],
  6250. "915": [0, 0.68611, 0, 0],
  6251. "916": [0, 0.68611, 0, 0],
  6252. "920": [0, 0.68611, 0, 0],
  6253. "923": [0, 0.68611, 0, 0],
  6254. "926": [0, 0.68611, 0, 0],
  6255. "928": [0, 0.68611, 0, 0],
  6256. "931": [0, 0.68611, 0, 0],
  6257. "933": [0, 0.68611, 0, 0],
  6258. "934": [0, 0.68611, 0, 0],
  6259. "936": [0, 0.68611, 0, 0],
  6260. "937": [0, 0.68611, 0, 0],
  6261. "8211": [0, 0.44444, 0.03194, 0],
  6262. "8212": [0, 0.44444, 0.03194, 0],
  6263. "8216": [0, 0.69444, 0, 0],
  6264. "8217": [0, 0.69444, 0, 0],
  6265. "8220": [0, 0.69444, 0, 0],
  6266. "8221": [0, 0.69444, 0, 0],
  6267. "8224": [0.19444, 0.69444, 0, 0],
  6268. "8225": [0.19444, 0.69444, 0, 0],
  6269. "8242": [0, 0.55556, 0, 0],
  6270. "8407": [0, 0.72444, 0.15486, 0],
  6271. "8463": [0, 0.69444, 0, 0],
  6272. "8465": [0, 0.69444, 0, 0],
  6273. "8467": [0, 0.69444, 0, 0],
  6274. "8472": [0.19444, 0.44444, 0, 0],
  6275. "8476": [0, 0.69444, 0, 0],
  6276. "8501": [0, 0.69444, 0, 0],
  6277. "8592": [-0.10889, 0.39111, 0, 0],
  6278. "8593": [0.19444, 0.69444, 0, 0],
  6279. "8594": [-0.10889, 0.39111, 0, 0],
  6280. "8595": [0.19444, 0.69444, 0, 0],
  6281. "8596": [-0.10889, 0.39111, 0, 0],
  6282. "8597": [0.25, 0.75, 0, 0],
  6283. "8598": [0.19444, 0.69444, 0, 0],
  6284. "8599": [0.19444, 0.69444, 0, 0],
  6285. "8600": [0.19444, 0.69444, 0, 0],
  6286. "8601": [0.19444, 0.69444, 0, 0],
  6287. "8636": [-0.10889, 0.39111, 0, 0],
  6288. "8637": [-0.10889, 0.39111, 0, 0],
  6289. "8640": [-0.10889, 0.39111, 0, 0],
  6290. "8641": [-0.10889, 0.39111, 0, 0],
  6291. "8656": [-0.10889, 0.39111, 0, 0],
  6292. "8657": [0.19444, 0.69444, 0, 0],
  6293. "8658": [-0.10889, 0.39111, 0, 0],
  6294. "8659": [0.19444, 0.69444, 0, 0],
  6295. "8660": [-0.10889, 0.39111, 0, 0],
  6296. "8661": [0.25, 0.75, 0, 0],
  6297. "8704": [0, 0.69444, 0, 0],
  6298. "8706": [0, 0.69444, 0.06389, 0],
  6299. "8707": [0, 0.69444, 0, 0],
  6300. "8709": [0.05556, 0.75, 0, 0],
  6301. "8711": [0, 0.68611, 0, 0],
  6302. "8712": [0.08556, 0.58556, 0, 0],
  6303. "8715": [0.08556, 0.58556, 0, 0],
  6304. "8722": [0.13333, 0.63333, 0, 0],
  6305. "8723": [0.13333, 0.63333, 0, 0],
  6306. "8725": [0.25, 0.75, 0, 0],
  6307. "8726": [0.25, 0.75, 0, 0],
  6308. "8727": [-0.02778, 0.47222, 0, 0],
  6309. "8728": [-0.02639, 0.47361, 0, 0],
  6310. "8729": [-0.02639, 0.47361, 0, 0],
  6311. "8730": [0.18, 0.82, 0, 0],
  6312. "8733": [0, 0.44444, 0, 0],
  6313. "8734": [0, 0.44444, 0, 0],
  6314. "8736": [0, 0.69224, 0, 0],
  6315. "8739": [0.25, 0.75, 0, 0],
  6316. "8741": [0.25, 0.75, 0, 0],
  6317. "8743": [0, 0.55556, 0, 0],
  6318. "8744": [0, 0.55556, 0, 0],
  6319. "8745": [0, 0.55556, 0, 0],
  6320. "8746": [0, 0.55556, 0, 0],
  6321. "8747": [0.19444, 0.69444, 0.12778, 0],
  6322. "8764": [-0.10889, 0.39111, 0, 0],
  6323. "8768": [0.19444, 0.69444, 0, 0],
  6324. "8771": [0.00222, 0.50222, 0, 0],
  6325. "8776": [0.02444, 0.52444, 0, 0],
  6326. "8781": [0.00222, 0.50222, 0, 0],
  6327. "8801": [0.00222, 0.50222, 0, 0],
  6328. "8804": [0.19667, 0.69667, 0, 0],
  6329. "8805": [0.19667, 0.69667, 0, 0],
  6330. "8810": [0.08556, 0.58556, 0, 0],
  6331. "8811": [0.08556, 0.58556, 0, 0],
  6332. "8826": [0.08556, 0.58556, 0, 0],
  6333. "8827": [0.08556, 0.58556, 0, 0],
  6334. "8834": [0.08556, 0.58556, 0, 0],
  6335. "8835": [0.08556, 0.58556, 0, 0],
  6336. "8838": [0.19667, 0.69667, 0, 0],
  6337. "8839": [0.19667, 0.69667, 0, 0],
  6338. "8846": [0, 0.55556, 0, 0],
  6339. "8849": [0.19667, 0.69667, 0, 0],
  6340. "8850": [0.19667, 0.69667, 0, 0],
  6341. "8851": [0, 0.55556, 0, 0],
  6342. "8852": [0, 0.55556, 0, 0],
  6343. "8853": [0.13333, 0.63333, 0, 0],
  6344. "8854": [0.13333, 0.63333, 0, 0],
  6345. "8855": [0.13333, 0.63333, 0, 0],
  6346. "8856": [0.13333, 0.63333, 0, 0],
  6347. "8857": [0.13333, 0.63333, 0, 0],
  6348. "8866": [0, 0.69444, 0, 0],
  6349. "8867": [0, 0.69444, 0, 0],
  6350. "8868": [0, 0.69444, 0, 0],
  6351. "8869": [0, 0.69444, 0, 0],
  6352. "8900": [-0.02639, 0.47361, 0, 0],
  6353. "8901": [-0.02639, 0.47361, 0, 0],
  6354. "8902": [-0.02778, 0.47222, 0, 0],
  6355. "8968": [0.25, 0.75, 0, 0],
  6356. "8969": [0.25, 0.75, 0, 0],
  6357. "8970": [0.25, 0.75, 0, 0],
  6358. "8971": [0.25, 0.75, 0, 0],
  6359. "8994": [-0.13889, 0.36111, 0, 0],
  6360. "8995": [-0.13889, 0.36111, 0, 0],
  6361. "9651": [0.19444, 0.69444, 0, 0],
  6362. "9657": [-0.02778, 0.47222, 0, 0],
  6363. "9661": [0.19444, 0.69444, 0, 0],
  6364. "9667": [-0.02778, 0.47222, 0, 0],
  6365. "9711": [0.19444, 0.69444, 0, 0],
  6366. "9824": [0.12963, 0.69444, 0, 0],
  6367. "9825": [0.12963, 0.69444, 0, 0],
  6368. "9826": [0.12963, 0.69444, 0, 0],
  6369. "9827": [0.12963, 0.69444, 0, 0],
  6370. "9837": [0, 0.75, 0, 0],
  6371. "9838": [0.19444, 0.69444, 0, 0],
  6372. "9839": [0.19444, 0.69444, 0, 0],
  6373. "10216": [0.25, 0.75, 0, 0],
  6374. "10217": [0.25, 0.75, 0, 0],
  6375. "10815": [0, 0.68611, 0, 0],
  6376. "10927": [0.19667, 0.69667, 0, 0],
  6377. "10928": [0.19667, 0.69667, 0, 0]
  6378. },
  6379. "Main-Italic": {
  6380. "33": [0, 0.69444, 0.12417, 0],
  6381. "34": [0, 0.69444, 0.06961, 0],
  6382. "35": [0.19444, 0.69444, 0.06616, 0],
  6383. "37": [0.05556, 0.75, 0.13639, 0],
  6384. "38": [0, 0.69444, 0.09694, 0],
  6385. "39": [0, 0.69444, 0.12417, 0],
  6386. "40": [0.25, 0.75, 0.16194, 0],
  6387. "41": [0.25, 0.75, 0.03694, 0],
  6388. "42": [0, 0.75, 0.14917, 0],
  6389. "43": [0.05667, 0.56167, 0.03694, 0],
  6390. "44": [0.19444, 0.10556, 0, 0],
  6391. "45": [0, 0.43056, 0.02826, 0],
  6392. "46": [0, 0.10556, 0, 0],
  6393. "47": [0.25, 0.75, 0.16194, 0],
  6394. "48": [0, 0.64444, 0.13556, 0],
  6395. "49": [0, 0.64444, 0.13556, 0],
  6396. "50": [0, 0.64444, 0.13556, 0],
  6397. "51": [0, 0.64444, 0.13556, 0],
  6398. "52": [0.19444, 0.64444, 0.13556, 0],
  6399. "53": [0, 0.64444, 0.13556, 0],
  6400. "54": [0, 0.64444, 0.13556, 0],
  6401. "55": [0.19444, 0.64444, 0.13556, 0],
  6402. "56": [0, 0.64444, 0.13556, 0],
  6403. "57": [0, 0.64444, 0.13556, 0],
  6404. "58": [0, 0.43056, 0.0582, 0],
  6405. "59": [0.19444, 0.43056, 0.0582, 0],
  6406. "61": [-0.13313, 0.36687, 0.06616, 0],
  6407. "63": [0, 0.69444, 0.1225, 0],
  6408. "64": [0, 0.69444, 0.09597, 0],
  6409. "65": [0, 0.68333, 0, 0],
  6410. "66": [0, 0.68333, 0.10257, 0],
  6411. "67": [0, 0.68333, 0.14528, 0],
  6412. "68": [0, 0.68333, 0.09403, 0],
  6413. "69": [0, 0.68333, 0.12028, 0],
  6414. "70": [0, 0.68333, 0.13305, 0],
  6415. "71": [0, 0.68333, 0.08722, 0],
  6416. "72": [0, 0.68333, 0.16389, 0],
  6417. "73": [0, 0.68333, 0.15806, 0],
  6418. "74": [0, 0.68333, 0.14028, 0],
  6419. "75": [0, 0.68333, 0.14528, 0],
  6420. "76": [0, 0.68333, 0, 0],
  6421. "77": [0, 0.68333, 0.16389, 0],
  6422. "78": [0, 0.68333, 0.16389, 0],
  6423. "79": [0, 0.68333, 0.09403, 0],
  6424. "80": [0, 0.68333, 0.10257, 0],
  6425. "81": [0.19444, 0.68333, 0.09403, 0],
  6426. "82": [0, 0.68333, 0.03868, 0],
  6427. "83": [0, 0.68333, 0.11972, 0],
  6428. "84": [0, 0.68333, 0.13305, 0],
  6429. "85": [0, 0.68333, 0.16389, 0],
  6430. "86": [0, 0.68333, 0.18361, 0],
  6431. "87": [0, 0.68333, 0.18361, 0],
  6432. "88": [0, 0.68333, 0.15806, 0],
  6433. "89": [0, 0.68333, 0.19383, 0],
  6434. "90": [0, 0.68333, 0.14528, 0],
  6435. "91": [0.25, 0.75, 0.1875, 0],
  6436. "93": [0.25, 0.75, 0.10528, 0],
  6437. "94": [0, 0.69444, 0.06646, 0],
  6438. "95": [0.31, 0.12056, 0.09208, 0],
  6439. "97": [0, 0.43056, 0.07671, 0],
  6440. "98": [0, 0.69444, 0.06312, 0],
  6441. "99": [0, 0.43056, 0.05653, 0],
  6442. "100": [0, 0.69444, 0.10333, 0],
  6443. "101": [0, 0.43056, 0.07514, 0],
  6444. "102": [0.19444, 0.69444, 0.21194, 0],
  6445. "103": [0.19444, 0.43056, 0.08847, 0],
  6446. "104": [0, 0.69444, 0.07671, 0],
  6447. "105": [0, 0.65536, 0.1019, 0],
  6448. "106": [0.19444, 0.65536, 0.14467, 0],
  6449. "107": [0, 0.69444, 0.10764, 0],
  6450. "108": [0, 0.69444, 0.10333, 0],
  6451. "109": [0, 0.43056, 0.07671, 0],
  6452. "110": [0, 0.43056, 0.07671, 0],
  6453. "111": [0, 0.43056, 0.06312, 0],
  6454. "112": [0.19444, 0.43056, 0.06312, 0],
  6455. "113": [0.19444, 0.43056, 0.08847, 0],
  6456. "114": [0, 0.43056, 0.10764, 0],
  6457. "115": [0, 0.43056, 0.08208, 0],
  6458. "116": [0, 0.61508, 0.09486, 0],
  6459. "117": [0, 0.43056, 0.07671, 0],
  6460. "118": [0, 0.43056, 0.10764, 0],
  6461. "119": [0, 0.43056, 0.10764, 0],
  6462. "120": [0, 0.43056, 0.12042, 0],
  6463. "121": [0.19444, 0.43056, 0.08847, 0],
  6464. "122": [0, 0.43056, 0.12292, 0],
  6465. "126": [0.35, 0.31786, 0.11585, 0],
  6466. "163": [0, 0.69444, 0, 0],
  6467. "305": [0, 0.43056, 0, 0.02778],
  6468. "567": [0.19444, 0.43056, 0, 0.08334],
  6469. "768": [0, 0.69444, 0, 0],
  6470. "769": [0, 0.69444, 0.09694, 0],
  6471. "770": [0, 0.69444, 0.06646, 0],
  6472. "771": [0, 0.66786, 0.11585, 0],
  6473. "772": [0, 0.56167, 0.10333, 0],
  6474. "774": [0, 0.69444, 0.10806, 0],
  6475. "775": [0, 0.66786, 0.11752, 0],
  6476. "776": [0, 0.66786, 0.10474, 0],
  6477. "778": [0, 0.69444, 0, 0],
  6478. "779": [0, 0.69444, 0.1225, 0],
  6479. "780": [0, 0.62847, 0.08295, 0],
  6480. "915": [0, 0.68333, 0.13305, 0],
  6481. "916": [0, 0.68333, 0, 0],
  6482. "920": [0, 0.68333, 0.09403, 0],
  6483. "923": [0, 0.68333, 0, 0],
  6484. "926": [0, 0.68333, 0.15294, 0],
  6485. "928": [0, 0.68333, 0.16389, 0],
  6486. "931": [0, 0.68333, 0.12028, 0],
  6487. "933": [0, 0.68333, 0.11111, 0],
  6488. "934": [0, 0.68333, 0.05986, 0],
  6489. "936": [0, 0.68333, 0.11111, 0],
  6490. "937": [0, 0.68333, 0.10257, 0],
  6491. "8211": [0, 0.43056, 0.09208, 0],
  6492. "8212": [0, 0.43056, 0.09208, 0],
  6493. "8216": [0, 0.69444, 0.12417, 0],
  6494. "8217": [0, 0.69444, 0.12417, 0],
  6495. "8220": [0, 0.69444, 0.1685, 0],
  6496. "8221": [0, 0.69444, 0.06961, 0],
  6497. "8463": [0, 0.68889, 0, 0]
  6498. },
  6499. "Main-Regular": {
  6500. "32": [0, 0, 0, 0],
  6501. "33": [0, 0.69444, 0, 0],
  6502. "34": [0, 0.69444, 0, 0],
  6503. "35": [0.19444, 0.69444, 0, 0],
  6504. "36": [0.05556, 0.75, 0, 0],
  6505. "37": [0.05556, 0.75, 0, 0],
  6506. "38": [0, 0.69444, 0, 0],
  6507. "39": [0, 0.69444, 0, 0],
  6508. "40": [0.25, 0.75, 0, 0],
  6509. "41": [0.25, 0.75, 0, 0],
  6510. "42": [0, 0.75, 0, 0],
  6511. "43": [0.08333, 0.58333, 0, 0],
  6512. "44": [0.19444, 0.10556, 0, 0],
  6513. "45": [0, 0.43056, 0, 0],
  6514. "46": [0, 0.10556, 0, 0],
  6515. "47": [0.25, 0.75, 0, 0],
  6516. "48": [0, 0.64444, 0, 0],
  6517. "49": [0, 0.64444, 0, 0],
  6518. "50": [0, 0.64444, 0, 0],
  6519. "51": [0, 0.64444, 0, 0],
  6520. "52": [0, 0.64444, 0, 0],
  6521. "53": [0, 0.64444, 0, 0],
  6522. "54": [0, 0.64444, 0, 0],
  6523. "55": [0, 0.64444, 0, 0],
  6524. "56": [0, 0.64444, 0, 0],
  6525. "57": [0, 0.64444, 0, 0],
  6526. "58": [0, 0.43056, 0, 0],
  6527. "59": [0.19444, 0.43056, 0, 0],
  6528. "60": [0.0391, 0.5391, 0, 0],
  6529. "61": [-0.13313, 0.36687, 0, 0],
  6530. "62": [0.0391, 0.5391, 0, 0],
  6531. "63": [0, 0.69444, 0, 0],
  6532. "64": [0, 0.69444, 0, 0],
  6533. "65": [0, 0.68333, 0, 0],
  6534. "66": [0, 0.68333, 0, 0],
  6535. "67": [0, 0.68333, 0, 0],
  6536. "68": [0, 0.68333, 0, 0],
  6537. "69": [0, 0.68333, 0, 0],
  6538. "70": [0, 0.68333, 0, 0],
  6539. "71": [0, 0.68333, 0, 0],
  6540. "72": [0, 0.68333, 0, 0],
  6541. "73": [0, 0.68333, 0, 0],
  6542. "74": [0, 0.68333, 0, 0],
  6543. "75": [0, 0.68333, 0, 0],
  6544. "76": [0, 0.68333, 0, 0],
  6545. "77": [0, 0.68333, 0, 0],
  6546. "78": [0, 0.68333, 0, 0],
  6547. "79": [0, 0.68333, 0, 0],
  6548. "80": [0, 0.68333, 0, 0],
  6549. "81": [0.19444, 0.68333, 0, 0],
  6550. "82": [0, 0.68333, 0, 0],
  6551. "83": [0, 0.68333, 0, 0],
  6552. "84": [0, 0.68333, 0, 0],
  6553. "85": [0, 0.68333, 0, 0],
  6554. "86": [0, 0.68333, 0.01389, 0],
  6555. "87": [0, 0.68333, 0.01389, 0],
  6556. "88": [0, 0.68333, 0, 0],
  6557. "89": [0, 0.68333, 0.025, 0],
  6558. "90": [0, 0.68333, 0, 0],
  6559. "91": [0.25, 0.75, 0, 0],
  6560. "92": [0.25, 0.75, 0, 0],
  6561. "93": [0.25, 0.75, 0, 0],
  6562. "94": [0, 0.69444, 0, 0],
  6563. "95": [0.31, 0.12056, 0.02778, 0],
  6564. "96": [0, 0.69444, 0, 0],
  6565. "97": [0, 0.43056, 0, 0],
  6566. "98": [0, 0.69444, 0, 0],
  6567. "99": [0, 0.43056, 0, 0],
  6568. "100": [0, 0.69444, 0, 0],
  6569. "101": [0, 0.43056, 0, 0],
  6570. "102": [0, 0.69444, 0.07778, 0],
  6571. "103": [0.19444, 0.43056, 0.01389, 0],
  6572. "104": [0, 0.69444, 0, 0],
  6573. "105": [0, 0.66786, 0, 0],
  6574. "106": [0.19444, 0.66786, 0, 0],
  6575. "107": [0, 0.69444, 0, 0],
  6576. "108": [0, 0.69444, 0, 0],
  6577. "109": [0, 0.43056, 0, 0],
  6578. "110": [0, 0.43056, 0, 0],
  6579. "111": [0, 0.43056, 0, 0],
  6580. "112": [0.19444, 0.43056, 0, 0],
  6581. "113": [0.19444, 0.43056, 0, 0],
  6582. "114": [0, 0.43056, 0, 0],
  6583. "115": [0, 0.43056, 0, 0],
  6584. "116": [0, 0.61508, 0, 0],
  6585. "117": [0, 0.43056, 0, 0],
  6586. "118": [0, 0.43056, 0.01389, 0],
  6587. "119": [0, 0.43056, 0.01389, 0],
  6588. "120": [0, 0.43056, 0, 0],
  6589. "121": [0.19444, 0.43056, 0.01389, 0],
  6590. "122": [0, 0.43056, 0, 0],
  6591. "123": [0.25, 0.75, 0, 0],
  6592. "124": [0.25, 0.75, 0, 0],
  6593. "125": [0.25, 0.75, 0, 0],
  6594. "126": [0.35, 0.31786, 0, 0],
  6595. "160": [0, 0, 0, 0],
  6596. "168": [0, 0.66786, 0, 0],
  6597. "172": [0, 0.43056, 0, 0],
  6598. "175": [0, 0.56778, 0, 0],
  6599. "176": [0, 0.69444, 0, 0],
  6600. "177": [0.08333, 0.58333, 0, 0],
  6601. "180": [0, 0.69444, 0, 0],
  6602. "215": [0.08333, 0.58333, 0, 0],
  6603. "247": [0.08333, 0.58333, 0, 0],
  6604. "305": [0, 0.43056, 0, 0],
  6605. "567": [0.19444, 0.43056, 0, 0],
  6606. "710": [0, 0.69444, 0, 0],
  6607. "711": [0, 0.62847, 0, 0],
  6608. "713": [0, 0.56778, 0, 0],
  6609. "714": [0, 0.69444, 0, 0],
  6610. "715": [0, 0.69444, 0, 0],
  6611. "728": [0, 0.69444, 0, 0],
  6612. "729": [0, 0.66786, 0, 0],
  6613. "730": [0, 0.69444, 0, 0],
  6614. "732": [0, 0.66786, 0, 0],
  6615. "768": [0, 0.69444, 0, 0],
  6616. "769": [0, 0.69444, 0, 0],
  6617. "770": [0, 0.69444, 0, 0],
  6618. "771": [0, 0.66786, 0, 0],
  6619. "772": [0, 0.56778, 0, 0],
  6620. "774": [0, 0.69444, 0, 0],
  6621. "775": [0, 0.66786, 0, 0],
  6622. "776": [0, 0.66786, 0, 0],
  6623. "778": [0, 0.69444, 0, 0],
  6624. "779": [0, 0.69444, 0, 0],
  6625. "780": [0, 0.62847, 0, 0],
  6626. "824": [0.19444, 0.69444, 0, 0],
  6627. "915": [0, 0.68333, 0, 0],
  6628. "916": [0, 0.68333, 0, 0],
  6629. "920": [0, 0.68333, 0, 0],
  6630. "923": [0, 0.68333, 0, 0],
  6631. "926": [0, 0.68333, 0, 0],
  6632. "928": [0, 0.68333, 0, 0],
  6633. "931": [0, 0.68333, 0, 0],
  6634. "933": [0, 0.68333, 0, 0],
  6635. "934": [0, 0.68333, 0, 0],
  6636. "936": [0, 0.68333, 0, 0],
  6637. "937": [0, 0.68333, 0, 0],
  6638. "8211": [0, 0.43056, 0.02778, 0],
  6639. "8212": [0, 0.43056, 0.02778, 0],
  6640. "8216": [0, 0.69444, 0, 0],
  6641. "8217": [0, 0.69444, 0, 0],
  6642. "8220": [0, 0.69444, 0, 0],
  6643. "8221": [0, 0.69444, 0, 0],
  6644. "8224": [0.19444, 0.69444, 0, 0],
  6645. "8225": [0.19444, 0.69444, 0, 0],
  6646. "8230": [0, 0.12, 0, 0],
  6647. "8242": [0, 0.55556, 0, 0],
  6648. "8407": [0, 0.71444, 0.15382, 0],
  6649. "8463": [0, 0.68889, 0, 0],
  6650. "8465": [0, 0.69444, 0, 0],
  6651. "8467": [0, 0.69444, 0, 0.11111],
  6652. "8472": [0.19444, 0.43056, 0, 0.11111],
  6653. "8476": [0, 0.69444, 0, 0],
  6654. "8501": [0, 0.69444, 0, 0],
  6655. "8592": [-0.13313, 0.36687, 0, 0],
  6656. "8593": [0.19444, 0.69444, 0, 0],
  6657. "8594": [-0.13313, 0.36687, 0, 0],
  6658. "8595": [0.19444, 0.69444, 0, 0],
  6659. "8596": [-0.13313, 0.36687, 0, 0],
  6660. "8597": [0.25, 0.75, 0, 0],
  6661. "8598": [0.19444, 0.69444, 0, 0],
  6662. "8599": [0.19444, 0.69444, 0, 0],
  6663. "8600": [0.19444, 0.69444, 0, 0],
  6664. "8601": [0.19444, 0.69444, 0, 0],
  6665. "8614": [0.011, 0.511, 0, 0],
  6666. "8617": [0.011, 0.511, 0, 0],
  6667. "8618": [0.011, 0.511, 0, 0],
  6668. "8636": [-0.13313, 0.36687, 0, 0],
  6669. "8637": [-0.13313, 0.36687, 0, 0],
  6670. "8640": [-0.13313, 0.36687, 0, 0],
  6671. "8641": [-0.13313, 0.36687, 0, 0],
  6672. "8652": [0.011, 0.671, 0, 0],
  6673. "8656": [-0.13313, 0.36687, 0, 0],
  6674. "8657": [0.19444, 0.69444, 0, 0],
  6675. "8658": [-0.13313, 0.36687, 0, 0],
  6676. "8659": [0.19444, 0.69444, 0, 0],
  6677. "8660": [-0.13313, 0.36687, 0, 0],
  6678. "8661": [0.25, 0.75, 0, 0],
  6679. "8704": [0, 0.69444, 0, 0],
  6680. "8706": [0, 0.69444, 0.05556, 0.08334],
  6681. "8707": [0, 0.69444, 0, 0],
  6682. "8709": [0.05556, 0.75, 0, 0],
  6683. "8711": [0, 0.68333, 0, 0],
  6684. "8712": [0.0391, 0.5391, 0, 0],
  6685. "8715": [0.0391, 0.5391, 0, 0],
  6686. "8722": [0.08333, 0.58333, 0, 0],
  6687. "8723": [0.08333, 0.58333, 0, 0],
  6688. "8725": [0.25, 0.75, 0, 0],
  6689. "8726": [0.25, 0.75, 0, 0],
  6690. "8727": [-0.03472, 0.46528, 0, 0],
  6691. "8728": [-0.05555, 0.44445, 0, 0],
  6692. "8729": [-0.05555, 0.44445, 0, 0],
  6693. "8730": [0.2, 0.8, 0, 0],
  6694. "8733": [0, 0.43056, 0, 0],
  6695. "8734": [0, 0.43056, 0, 0],
  6696. "8736": [0, 0.69224, 0, 0],
  6697. "8739": [0.25, 0.75, 0, 0],
  6698. "8741": [0.25, 0.75, 0, 0],
  6699. "8743": [0, 0.55556, 0, 0],
  6700. "8744": [0, 0.55556, 0, 0],
  6701. "8745": [0, 0.55556, 0, 0],
  6702. "8746": [0, 0.55556, 0, 0],
  6703. "8747": [0.19444, 0.69444, 0.11111, 0],
  6704. "8764": [-0.13313, 0.36687, 0, 0],
  6705. "8768": [0.19444, 0.69444, 0, 0],
  6706. "8771": [-0.03625, 0.46375, 0, 0],
  6707. "8773": [-0.022, 0.589, 0, 0],
  6708. "8776": [-0.01688, 0.48312, 0, 0],
  6709. "8781": [-0.03625, 0.46375, 0, 0],
  6710. "8784": [-0.133, 0.67, 0, 0],
  6711. "8800": [0.215, 0.716, 0, 0],
  6712. "8801": [-0.03625, 0.46375, 0, 0],
  6713. "8804": [0.13597, 0.63597, 0, 0],
  6714. "8805": [0.13597, 0.63597, 0, 0],
  6715. "8810": [0.0391, 0.5391, 0, 0],
  6716. "8811": [0.0391, 0.5391, 0, 0],
  6717. "8826": [0.0391, 0.5391, 0, 0],
  6718. "8827": [0.0391, 0.5391, 0, 0],
  6719. "8834": [0.0391, 0.5391, 0, 0],
  6720. "8835": [0.0391, 0.5391, 0, 0],
  6721. "8838": [0.13597, 0.63597, 0, 0],
  6722. "8839": [0.13597, 0.63597, 0, 0],
  6723. "8846": [0, 0.55556, 0, 0],
  6724. "8849": [0.13597, 0.63597, 0, 0],
  6725. "8850": [0.13597, 0.63597, 0, 0],
  6726. "8851": [0, 0.55556, 0, 0],
  6727. "8852": [0, 0.55556, 0, 0],
  6728. "8853": [0.08333, 0.58333, 0, 0],
  6729. "8854": [0.08333, 0.58333, 0, 0],
  6730. "8855": [0.08333, 0.58333, 0, 0],
  6731. "8856": [0.08333, 0.58333, 0, 0],
  6732. "8857": [0.08333, 0.58333, 0, 0],
  6733. "8866": [0, 0.69444, 0, 0],
  6734. "8867": [0, 0.69444, 0, 0],
  6735. "8868": [0, 0.69444, 0, 0],
  6736. "8869": [0, 0.69444, 0, 0],
  6737. "8872": [0.249, 0.75, 0, 0],
  6738. "8900": [-0.05555, 0.44445, 0, 0],
  6739. "8901": [-0.05555, 0.44445, 0, 0],
  6740. "8902": [-0.03472, 0.46528, 0, 0],
  6741. "8904": [0.005, 0.505, 0, 0],
  6742. "8942": [0.03, 0.9, 0, 0],
  6743. "8943": [-0.19, 0.31, 0, 0],
  6744. "8945": [-0.1, 0.82, 0, 0],
  6745. "8968": [0.25, 0.75, 0, 0],
  6746. "8969": [0.25, 0.75, 0, 0],
  6747. "8970": [0.25, 0.75, 0, 0],
  6748. "8971": [0.25, 0.75, 0, 0],
  6749. "8994": [-0.14236, 0.35764, 0, 0],
  6750. "8995": [-0.14236, 0.35764, 0, 0],
  6751. "9136": [0.244, 0.744, 0, 0],
  6752. "9137": [0.244, 0.744, 0, 0],
  6753. "9651": [0.19444, 0.69444, 0, 0],
  6754. "9657": [-0.03472, 0.46528, 0, 0],
  6755. "9661": [0.19444, 0.69444, 0, 0],
  6756. "9667": [-0.03472, 0.46528, 0, 0],
  6757. "9711": [0.19444, 0.69444, 0, 0],
  6758. "9824": [0.12963, 0.69444, 0, 0],
  6759. "9825": [0.12963, 0.69444, 0, 0],
  6760. "9826": [0.12963, 0.69444, 0, 0],
  6761. "9827": [0.12963, 0.69444, 0, 0],
  6762. "9837": [0, 0.75, 0, 0],
  6763. "9838": [0.19444, 0.69444, 0, 0],
  6764. "9839": [0.19444, 0.69444, 0, 0],
  6765. "10216": [0.25, 0.75, 0, 0],
  6766. "10217": [0.25, 0.75, 0, 0],
  6767. "10222": [0.244, 0.744, 0, 0],
  6768. "10223": [0.244, 0.744, 0, 0],
  6769. "10229": [0.011, 0.511, 0, 0],
  6770. "10230": [0.011, 0.511, 0, 0],
  6771. "10231": [0.011, 0.511, 0, 0],
  6772. "10232": [0.024, 0.525, 0, 0],
  6773. "10233": [0.024, 0.525, 0, 0],
  6774. "10234": [0.024, 0.525, 0, 0],
  6775. "10236": [0.011, 0.511, 0, 0],
  6776. "10815": [0, 0.68333, 0, 0],
  6777. "10927": [0.13597, 0.63597, 0, 0],
  6778. "10928": [0.13597, 0.63597, 0, 0]
  6779. },
  6780. "Math-BoldItalic": {
  6781. "47": [0.19444, 0.69444, 0, 0],
  6782. "65": [0, 0.68611, 0, 0],
  6783. "66": [0, 0.68611, 0.04835, 0],
  6784. "67": [0, 0.68611, 0.06979, 0],
  6785. "68": [0, 0.68611, 0.03194, 0],
  6786. "69": [0, 0.68611, 0.05451, 0],
  6787. "70": [0, 0.68611, 0.15972, 0],
  6788. "71": [0, 0.68611, 0, 0],
  6789. "72": [0, 0.68611, 0.08229, 0],
  6790. "73": [0, 0.68611, 0.07778, 0],
  6791. "74": [0, 0.68611, 0.10069, 0],
  6792. "75": [0, 0.68611, 0.06979, 0],
  6793. "76": [0, 0.68611, 0, 0],
  6794. "77": [0, 0.68611, 0.11424, 0],
  6795. "78": [0, 0.68611, 0.11424, 0],
  6796. "79": [0, 0.68611, 0.03194, 0],
  6797. "80": [0, 0.68611, 0.15972, 0],
  6798. "81": [0.19444, 0.68611, 0, 0],
  6799. "82": [0, 0.68611, 0.00421, 0],
  6800. "83": [0, 0.68611, 0.05382, 0],
  6801. "84": [0, 0.68611, 0.15972, 0],
  6802. "85": [0, 0.68611, 0.11424, 0],
  6803. "86": [0, 0.68611, 0.25555, 0],
  6804. "87": [0, 0.68611, 0.15972, 0],
  6805. "88": [0, 0.68611, 0.07778, 0],
  6806. "89": [0, 0.68611, 0.25555, 0],
  6807. "90": [0, 0.68611, 0.06979, 0],
  6808. "97": [0, 0.44444, 0, 0],
  6809. "98": [0, 0.69444, 0, 0],
  6810. "99": [0, 0.44444, 0, 0],
  6811. "100": [0, 0.69444, 0, 0],
  6812. "101": [0, 0.44444, 0, 0],
  6813. "102": [0.19444, 0.69444, 0.11042, 0],
  6814. "103": [0.19444, 0.44444, 0.03704, 0],
  6815. "104": [0, 0.69444, 0, 0],
  6816. "105": [0, 0.69326, 0, 0],
  6817. "106": [0.19444, 0.69326, 0.0622, 0],
  6818. "107": [0, 0.69444, 0.01852, 0],
  6819. "108": [0, 0.69444, 0.0088, 0],
  6820. "109": [0, 0.44444, 0, 0],
  6821. "110": [0, 0.44444, 0, 0],
  6822. "111": [0, 0.44444, 0, 0],
  6823. "112": [0.19444, 0.44444, 0, 0],
  6824. "113": [0.19444, 0.44444, 0.03704, 0],
  6825. "114": [0, 0.44444, 0.03194, 0],
  6826. "115": [0, 0.44444, 0, 0],
  6827. "116": [0, 0.63492, 0, 0],
  6828. "117": [0, 0.44444, 0, 0],
  6829. "118": [0, 0.44444, 0.03704, 0],
  6830. "119": [0, 0.44444, 0.02778, 0],
  6831. "120": [0, 0.44444, 0, 0],
  6832. "121": [0.19444, 0.44444, 0.03704, 0],
  6833. "122": [0, 0.44444, 0.04213, 0],
  6834. "915": [0, 0.68611, 0.15972, 0],
  6835. "916": [0, 0.68611, 0, 0],
  6836. "920": [0, 0.68611, 0.03194, 0],
  6837. "923": [0, 0.68611, 0, 0],
  6838. "926": [0, 0.68611, 0.07458, 0],
  6839. "928": [0, 0.68611, 0.08229, 0],
  6840. "931": [0, 0.68611, 0.05451, 0],
  6841. "933": [0, 0.68611, 0.15972, 0],
  6842. "934": [0, 0.68611, 0, 0],
  6843. "936": [0, 0.68611, 0.11653, 0],
  6844. "937": [0, 0.68611, 0.04835, 0],
  6845. "945": [0, 0.44444, 0, 0],
  6846. "946": [0.19444, 0.69444, 0.03403, 0],
  6847. "947": [0.19444, 0.44444, 0.06389, 0],
  6848. "948": [0, 0.69444, 0.03819, 0],
  6849. "949": [0, 0.44444, 0, 0],
  6850. "950": [0.19444, 0.69444, 0.06215, 0],
  6851. "951": [0.19444, 0.44444, 0.03704, 0],
  6852. "952": [0, 0.69444, 0.03194, 0],
  6853. "953": [0, 0.44444, 0, 0],
  6854. "954": [0, 0.44444, 0, 0],
  6855. "955": [0, 0.69444, 0, 0],
  6856. "956": [0.19444, 0.44444, 0, 0],
  6857. "957": [0, 0.44444, 0.06898, 0],
  6858. "958": [0.19444, 0.69444, 0.03021, 0],
  6859. "959": [0, 0.44444, 0, 0],
  6860. "960": [0, 0.44444, 0.03704, 0],
  6861. "961": [0.19444, 0.44444, 0, 0],
  6862. "962": [0.09722, 0.44444, 0.07917, 0],
  6863. "963": [0, 0.44444, 0.03704, 0],
  6864. "964": [0, 0.44444, 0.13472, 0],
  6865. "965": [0, 0.44444, 0.03704, 0],
  6866. "966": [0.19444, 0.44444, 0, 0],
  6867. "967": [0.19444, 0.44444, 0, 0],
  6868. "968": [0.19444, 0.69444, 0.03704, 0],
  6869. "969": [0, 0.44444, 0.03704, 0],
  6870. "977": [0, 0.69444, 0, 0],
  6871. "981": [0.19444, 0.69444, 0, 0],
  6872. "982": [0, 0.44444, 0.03194, 0],
  6873. "1009": [0.19444, 0.44444, 0, 0],
  6874. "1013": [0, 0.44444, 0, 0]
  6875. },
  6876. "Math-Italic": {
  6877. "47": [0.19444, 0.69444, 0, 0],
  6878. "65": [0, 0.68333, 0, 0.13889],
  6879. "66": [0, 0.68333, 0.05017, 0.08334],
  6880. "67": [0, 0.68333, 0.07153, 0.08334],
  6881. "68": [0, 0.68333, 0.02778, 0.05556],
  6882. "69": [0, 0.68333, 0.05764, 0.08334],
  6883. "70": [0, 0.68333, 0.13889, 0.08334],
  6884. "71": [0, 0.68333, 0, 0.08334],
  6885. "72": [0, 0.68333, 0.08125, 0.05556],
  6886. "73": [0, 0.68333, 0.07847, 0.11111],
  6887. "74": [0, 0.68333, 0.09618, 0.16667],
  6888. "75": [0, 0.68333, 0.07153, 0.05556],
  6889. "76": [0, 0.68333, 0, 0.02778],
  6890. "77": [0, 0.68333, 0.10903, 0.08334],
  6891. "78": [0, 0.68333, 0.10903, 0.08334],
  6892. "79": [0, 0.68333, 0.02778, 0.08334],
  6893. "80": [0, 0.68333, 0.13889, 0.08334],
  6894. "81": [0.19444, 0.68333, 0, 0.08334],
  6895. "82": [0, 0.68333, 0.00773, 0.08334],
  6896. "83": [0, 0.68333, 0.05764, 0.08334],
  6897. "84": [0, 0.68333, 0.13889, 0.08334],
  6898. "85": [0, 0.68333, 0.10903, 0.02778],
  6899. "86": [0, 0.68333, 0.22222, 0],
  6900. "87": [0, 0.68333, 0.13889, 0],
  6901. "88": [0, 0.68333, 0.07847, 0.08334],
  6902. "89": [0, 0.68333, 0.22222, 0],
  6903. "90": [0, 0.68333, 0.07153, 0.08334],
  6904. "97": [0, 0.43056, 0, 0],
  6905. "98": [0, 0.69444, 0, 0],
  6906. "99": [0, 0.43056, 0, 0.05556],
  6907. "100": [0, 0.69444, 0, 0.16667],
  6908. "101": [0, 0.43056, 0, 0.05556],
  6909. "102": [0.19444, 0.69444, 0.10764, 0.16667],
  6910. "103": [0.19444, 0.43056, 0.03588, 0.02778],
  6911. "104": [0, 0.69444, 0, 0],
  6912. "105": [0, 0.65952, 0, 0],
  6913. "106": [0.19444, 0.65952, 0.05724, 0],
  6914. "107": [0, 0.69444, 0.03148, 0],
  6915. "108": [0, 0.69444, 0.01968, 0.08334],
  6916. "109": [0, 0.43056, 0, 0],
  6917. "110": [0, 0.43056, 0, 0],
  6918. "111": [0, 0.43056, 0, 0.05556],
  6919. "112": [0.19444, 0.43056, 0, 0.08334],
  6920. "113": [0.19444, 0.43056, 0.03588, 0.08334],
  6921. "114": [0, 0.43056, 0.02778, 0.05556],
  6922. "115": [0, 0.43056, 0, 0.05556],
  6923. "116": [0, 0.61508, 0, 0.08334],
  6924. "117": [0, 0.43056, 0, 0.02778],
  6925. "118": [0, 0.43056, 0.03588, 0.02778],
  6926. "119": [0, 0.43056, 0.02691, 0.08334],
  6927. "120": [0, 0.43056, 0, 0.02778],
  6928. "121": [0.19444, 0.43056, 0.03588, 0.05556],
  6929. "122": [0, 0.43056, 0.04398, 0.05556],
  6930. "915": [0, 0.68333, 0.13889, 0.08334],
  6931. "916": [0, 0.68333, 0, 0.16667],
  6932. "920": [0, 0.68333, 0.02778, 0.08334],
  6933. "923": [0, 0.68333, 0, 0.16667],
  6934. "926": [0, 0.68333, 0.07569, 0.08334],
  6935. "928": [0, 0.68333, 0.08125, 0.05556],
  6936. "931": [0, 0.68333, 0.05764, 0.08334],
  6937. "933": [0, 0.68333, 0.13889, 0.05556],
  6938. "934": [0, 0.68333, 0, 0.08334],
  6939. "936": [0, 0.68333, 0.11, 0.05556],
  6940. "937": [0, 0.68333, 0.05017, 0.08334],
  6941. "945": [0, 0.43056, 0.0037, 0.02778],
  6942. "946": [0.19444, 0.69444, 0.05278, 0.08334],
  6943. "947": [0.19444, 0.43056, 0.05556, 0],
  6944. "948": [0, 0.69444, 0.03785, 0.05556],
  6945. "949": [0, 0.43056, 0, 0.08334],
  6946. "950": [0.19444, 0.69444, 0.07378, 0.08334],
  6947. "951": [0.19444, 0.43056, 0.03588, 0.05556],
  6948. "952": [0, 0.69444, 0.02778, 0.08334],
  6949. "953": [0, 0.43056, 0, 0.05556],
  6950. "954": [0, 0.43056, 0, 0],
  6951. "955": [0, 0.69444, 0, 0],
  6952. "956": [0.19444, 0.43056, 0, 0.02778],
  6953. "957": [0, 0.43056, 0.06366, 0.02778],
  6954. "958": [0.19444, 0.69444, 0.04601, 0.11111],
  6955. "959": [0, 0.43056, 0, 0.05556],
  6956. "960": [0, 0.43056, 0.03588, 0],
  6957. "961": [0.19444, 0.43056, 0, 0.08334],
  6958. "962": [0.09722, 0.43056, 0.07986, 0.08334],
  6959. "963": [0, 0.43056, 0.03588, 0],
  6960. "964": [0, 0.43056, 0.1132, 0.02778],
  6961. "965": [0, 0.43056, 0.03588, 0.02778],
  6962. "966": [0.19444, 0.43056, 0, 0.08334],
  6963. "967": [0.19444, 0.43056, 0, 0.05556],
  6964. "968": [0.19444, 0.69444, 0.03588, 0.11111],
  6965. "969": [0, 0.43056, 0.03588, 0],
  6966. "977": [0, 0.69444, 0, 0.08334],
  6967. "981": [0.19444, 0.69444, 0, 0.08334],
  6968. "982": [0, 0.43056, 0.02778, 0],
  6969. "1009": [0.19444, 0.43056, 0, 0.08334],
  6970. "1013": [0, 0.43056, 0, 0.05556]
  6971. },
  6972. "Math-Regular": {
  6973. "65": [0, 0.68333, 0, 0.13889],
  6974. "66": [0, 0.68333, 0.05017, 0.08334],
  6975. "67": [0, 0.68333, 0.07153, 0.08334],
  6976. "68": [0, 0.68333, 0.02778, 0.05556],
  6977. "69": [0, 0.68333, 0.05764, 0.08334],
  6978. "70": [0, 0.68333, 0.13889, 0.08334],
  6979. "71": [0, 0.68333, 0, 0.08334],
  6980. "72": [0, 0.68333, 0.08125, 0.05556],
  6981. "73": [0, 0.68333, 0.07847, 0.11111],
  6982. "74": [0, 0.68333, 0.09618, 0.16667],
  6983. "75": [0, 0.68333, 0.07153, 0.05556],
  6984. "76": [0, 0.68333, 0, 0.02778],
  6985. "77": [0, 0.68333, 0.10903, 0.08334],
  6986. "78": [0, 0.68333, 0.10903, 0.08334],
  6987. "79": [0, 0.68333, 0.02778, 0.08334],
  6988. "80": [0, 0.68333, 0.13889, 0.08334],
  6989. "81": [0.19444, 0.68333, 0, 0.08334],
  6990. "82": [0, 0.68333, 0.00773, 0.08334],
  6991. "83": [0, 0.68333, 0.05764, 0.08334],
  6992. "84": [0, 0.68333, 0.13889, 0.08334],
  6993. "85": [0, 0.68333, 0.10903, 0.02778],
  6994. "86": [0, 0.68333, 0.22222, 0],
  6995. "87": [0, 0.68333, 0.13889, 0],
  6996. "88": [0, 0.68333, 0.07847, 0.08334],
  6997. "89": [0, 0.68333, 0.22222, 0],
  6998. "90": [0, 0.68333, 0.07153, 0.08334],
  6999. "97": [0, 0.43056, 0, 0],
  7000. "98": [0, 0.69444, 0, 0],
  7001. "99": [0, 0.43056, 0, 0.05556],
  7002. "100": [0, 0.69444, 0, 0.16667],
  7003. "101": [0, 0.43056, 0, 0.05556],
  7004. "102": [0.19444, 0.69444, 0.10764, 0.16667],
  7005. "103": [0.19444, 0.43056, 0.03588, 0.02778],
  7006. "104": [0, 0.69444, 0, 0],
  7007. "105": [0, 0.65952, 0, 0],
  7008. "106": [0.19444, 0.65952, 0.05724, 0],
  7009. "107": [0, 0.69444, 0.03148, 0],
  7010. "108": [0, 0.69444, 0.01968, 0.08334],
  7011. "109": [0, 0.43056, 0, 0],
  7012. "110": [0, 0.43056, 0, 0],
  7013. "111": [0, 0.43056, 0, 0.05556],
  7014. "112": [0.19444, 0.43056, 0, 0.08334],
  7015. "113": [0.19444, 0.43056, 0.03588, 0.08334],
  7016. "114": [0, 0.43056, 0.02778, 0.05556],
  7017. "115": [0, 0.43056, 0, 0.05556],
  7018. "116": [0, 0.61508, 0, 0.08334],
  7019. "117": [0, 0.43056, 0, 0.02778],
  7020. "118": [0, 0.43056, 0.03588, 0.02778],
  7021. "119": [0, 0.43056, 0.02691, 0.08334],
  7022. "120": [0, 0.43056, 0, 0.02778],
  7023. "121": [0.19444, 0.43056, 0.03588, 0.05556],
  7024. "122": [0, 0.43056, 0.04398, 0.05556],
  7025. "915": [0, 0.68333, 0.13889, 0.08334],
  7026. "916": [0, 0.68333, 0, 0.16667],
  7027. "920": [0, 0.68333, 0.02778, 0.08334],
  7028. "923": [0, 0.68333, 0, 0.16667],
  7029. "926": [0, 0.68333, 0.07569, 0.08334],
  7030. "928": [0, 0.68333, 0.08125, 0.05556],
  7031. "931": [0, 0.68333, 0.05764, 0.08334],
  7032. "933": [0, 0.68333, 0.13889, 0.05556],
  7033. "934": [0, 0.68333, 0, 0.08334],
  7034. "936": [0, 0.68333, 0.11, 0.05556],
  7035. "937": [0, 0.68333, 0.05017, 0.08334],
  7036. "945": [0, 0.43056, 0.0037, 0.02778],
  7037. "946": [0.19444, 0.69444, 0.05278, 0.08334],
  7038. "947": [0.19444, 0.43056, 0.05556, 0],
  7039. "948": [0, 0.69444, 0.03785, 0.05556],
  7040. "949": [0, 0.43056, 0, 0.08334],
  7041. "950": [0.19444, 0.69444, 0.07378, 0.08334],
  7042. "951": [0.19444, 0.43056, 0.03588, 0.05556],
  7043. "952": [0, 0.69444, 0.02778, 0.08334],
  7044. "953": [0, 0.43056, 0, 0.05556],
  7045. "954": [0, 0.43056, 0, 0],
  7046. "955": [0, 0.69444, 0, 0],
  7047. "956": [0.19444, 0.43056, 0, 0.02778],
  7048. "957": [0, 0.43056, 0.06366, 0.02778],
  7049. "958": [0.19444, 0.69444, 0.04601, 0.11111],
  7050. "959": [0, 0.43056, 0, 0.05556],
  7051. "960": [0, 0.43056, 0.03588, 0],
  7052. "961": [0.19444, 0.43056, 0, 0.08334],
  7053. "962": [0.09722, 0.43056, 0.07986, 0.08334],
  7054. "963": [0, 0.43056, 0.03588, 0],
  7055. "964": [0, 0.43056, 0.1132, 0.02778],
  7056. "965": [0, 0.43056, 0.03588, 0.02778],
  7057. "966": [0.19444, 0.43056, 0, 0.08334],
  7058. "967": [0.19444, 0.43056, 0, 0.05556],
  7059. "968": [0.19444, 0.69444, 0.03588, 0.11111],
  7060. "969": [0, 0.43056, 0.03588, 0],
  7061. "977": [0, 0.69444, 0, 0.08334],
  7062. "981": [0.19444, 0.69444, 0, 0.08334],
  7063. "982": [0, 0.43056, 0.02778, 0],
  7064. "1009": [0.19444, 0.43056, 0, 0.08334],
  7065. "1013": [0, 0.43056, 0, 0.05556]
  7066. },
  7067. "SansSerif-Regular": {
  7068. "33": [0, 0.69444, 0, 0],
  7069. "34": [0, 0.69444, 0, 0],
  7070. "35": [0.19444, 0.69444, 0, 0],
  7071. "36": [0.05556, 0.75, 0, 0],
  7072. "37": [0.05556, 0.75, 0, 0],
  7073. "38": [0, 0.69444, 0, 0],
  7074. "39": [0, 0.69444, 0, 0],
  7075. "40": [0.25, 0.75, 0, 0],
  7076. "41": [0.25, 0.75, 0, 0],
  7077. "42": [0, 0.75, 0, 0],
  7078. "43": [0.08333, 0.58333, 0, 0],
  7079. "44": [0.125, 0.08333, 0, 0],
  7080. "45": [0, 0.44444, 0, 0],
  7081. "46": [0, 0.08333, 0, 0],
  7082. "47": [0.25, 0.75, 0, 0],
  7083. "48": [0, 0.65556, 0, 0],
  7084. "49": [0, 0.65556, 0, 0],
  7085. "50": [0, 0.65556, 0, 0],
  7086. "51": [0, 0.65556, 0, 0],
  7087. "52": [0, 0.65556, 0, 0],
  7088. "53": [0, 0.65556, 0, 0],
  7089. "54": [0, 0.65556, 0, 0],
  7090. "55": [0, 0.65556, 0, 0],
  7091. "56": [0, 0.65556, 0, 0],
  7092. "57": [0, 0.65556, 0, 0],
  7093. "58": [0, 0.44444, 0, 0],
  7094. "59": [0.125, 0.44444, 0, 0],
  7095. "61": [-0.13, 0.37, 0, 0],
  7096. "63": [0, 0.69444, 0, 0],
  7097. "64": [0, 0.69444, 0, 0],
  7098. "65": [0, 0.69444, 0, 0],
  7099. "66": [0, 0.69444, 0, 0],
  7100. "67": [0, 0.69444, 0, 0],
  7101. "68": [0, 0.69444, 0, 0],
  7102. "69": [0, 0.69444, 0, 0],
  7103. "70": [0, 0.69444, 0, 0],
  7104. "71": [0, 0.69444, 0, 0],
  7105. "72": [0, 0.69444, 0, 0],
  7106. "73": [0, 0.69444, 0, 0],
  7107. "74": [0, 0.69444, 0, 0],
  7108. "75": [0, 0.69444, 0, 0],
  7109. "76": [0, 0.69444, 0, 0],
  7110. "77": [0, 0.69444, 0, 0],
  7111. "78": [0, 0.69444, 0, 0],
  7112. "79": [0, 0.69444, 0, 0],
  7113. "80": [0, 0.69444, 0, 0],
  7114. "81": [0.125, 0.69444, 0, 0],
  7115. "82": [0, 0.69444, 0, 0],
  7116. "83": [0, 0.69444, 0, 0],
  7117. "84": [0, 0.69444, 0, 0],
  7118. "85": [0, 0.69444, 0, 0],
  7119. "86": [0, 0.69444, 0.01389, 0],
  7120. "87": [0, 0.69444, 0.01389, 0],
  7121. "88": [0, 0.69444, 0, 0],
  7122. "89": [0, 0.69444, 0.025, 0],
  7123. "90": [0, 0.69444, 0, 0],
  7124. "91": [0.25, 0.75, 0, 0],
  7125. "93": [0.25, 0.75, 0, 0],
  7126. "94": [0, 0.69444, 0, 0],
  7127. "95": [0.35, 0.09444, 0.02778, 0],
  7128. "97": [0, 0.44444, 0, 0],
  7129. "98": [0, 0.69444, 0, 0],
  7130. "99": [0, 0.44444, 0, 0],
  7131. "100": [0, 0.69444, 0, 0],
  7132. "101": [0, 0.44444, 0, 0],
  7133. "102": [0, 0.69444, 0.06944, 0],
  7134. "103": [0.19444, 0.44444, 0.01389, 0],
  7135. "104": [0, 0.69444, 0, 0],
  7136. "105": [0, 0.67937, 0, 0],
  7137. "106": [0.19444, 0.67937, 0, 0],
  7138. "107": [0, 0.69444, 0, 0],
  7139. "108": [0, 0.69444, 0, 0],
  7140. "109": [0, 0.44444, 0, 0],
  7141. "110": [0, 0.44444, 0, 0],
  7142. "111": [0, 0.44444, 0, 0],
  7143. "112": [0.19444, 0.44444, 0, 0],
  7144. "113": [0.19444, 0.44444, 0, 0],
  7145. "114": [0, 0.44444, 0.01389, 0],
  7146. "115": [0, 0.44444, 0, 0],
  7147. "116": [0, 0.57143, 0, 0],
  7148. "117": [0, 0.44444, 0, 0],
  7149. "118": [0, 0.44444, 0.01389, 0],
  7150. "119": [0, 0.44444, 0.01389, 0],
  7151. "120": [0, 0.44444, 0, 0],
  7152. "121": [0.19444, 0.44444, 0.01389, 0],
  7153. "122": [0, 0.44444, 0, 0],
  7154. "126": [0.35, 0.32659, 0, 0],
  7155. "305": [0, 0.44444, 0, 0],
  7156. "567": [0.19444, 0.44444, 0, 0],
  7157. "768": [0, 0.69444, 0, 0],
  7158. "769": [0, 0.69444, 0, 0],
  7159. "770": [0, 0.69444, 0, 0],
  7160. "771": [0, 0.67659, 0, 0],
  7161. "772": [0, 0.60889, 0, 0],
  7162. "774": [0, 0.69444, 0, 0],
  7163. "775": [0, 0.67937, 0, 0],
  7164. "776": [0, 0.67937, 0, 0],
  7165. "778": [0, 0.69444, 0, 0],
  7166. "779": [0, 0.69444, 0, 0],
  7167. "780": [0, 0.63194, 0, 0],
  7168. "915": [0, 0.69444, 0, 0],
  7169. "916": [0, 0.69444, 0, 0],
  7170. "920": [0, 0.69444, 0, 0],
  7171. "923": [0, 0.69444, 0, 0],
  7172. "926": [0, 0.69444, 0, 0],
  7173. "928": [0, 0.69444, 0, 0],
  7174. "931": [0, 0.69444, 0, 0],
  7175. "933": [0, 0.69444, 0, 0],
  7176. "934": [0, 0.69444, 0, 0],
  7177. "936": [0, 0.69444, 0, 0],
  7178. "937": [0, 0.69444, 0, 0],
  7179. "8211": [0, 0.44444, 0.02778, 0],
  7180. "8212": [0, 0.44444, 0.02778, 0],
  7181. "8216": [0, 0.69444, 0, 0],
  7182. "8217": [0, 0.69444, 0, 0],
  7183. "8220": [0, 0.69444, 0, 0],
  7184. "8221": [0, 0.69444, 0, 0]
  7185. },
  7186. "Script-Regular": {
  7187. "65": [0, 0.7, 0.22925, 0],
  7188. "66": [0, 0.7, 0.04087, 0],
  7189. "67": [0, 0.7, 0.1689, 0],
  7190. "68": [0, 0.7, 0.09371, 0],
  7191. "69": [0, 0.7, 0.18583, 0],
  7192. "70": [0, 0.7, 0.13634, 0],
  7193. "71": [0, 0.7, 0.17322, 0],
  7194. "72": [0, 0.7, 0.29694, 0],
  7195. "73": [0, 0.7, 0.19189, 0],
  7196. "74": [0.27778, 0.7, 0.19189, 0],
  7197. "75": [0, 0.7, 0.31259, 0],
  7198. "76": [0, 0.7, 0.19189, 0],
  7199. "77": [0, 0.7, 0.15981, 0],
  7200. "78": [0, 0.7, 0.3525, 0],
  7201. "79": [0, 0.7, 0.08078, 0],
  7202. "80": [0, 0.7, 0.08078, 0],
  7203. "81": [0, 0.7, 0.03305, 0],
  7204. "82": [0, 0.7, 0.06259, 0],
  7205. "83": [0, 0.7, 0.19189, 0],
  7206. "84": [0, 0.7, 0.29087, 0],
  7207. "85": [0, 0.7, 0.25815, 0],
  7208. "86": [0, 0.7, 0.27523, 0],
  7209. "87": [0, 0.7, 0.27523, 0],
  7210. "88": [0, 0.7, 0.26006, 0],
  7211. "89": [0, 0.7, 0.2939, 0],
  7212. "90": [0, 0.7, 0.24037, 0]
  7213. },
  7214. "Size1-Regular": {
  7215. "40": [0.35001, 0.85, 0, 0],
  7216. "41": [0.35001, 0.85, 0, 0],
  7217. "47": [0.35001, 0.85, 0, 0],
  7218. "91": [0.35001, 0.85, 0, 0],
  7219. "92": [0.35001, 0.85, 0, 0],
  7220. "93": [0.35001, 0.85, 0, 0],
  7221. "123": [0.35001, 0.85, 0, 0],
  7222. "125": [0.35001, 0.85, 0, 0],
  7223. "710": [0, 0.72222, 0, 0],
  7224. "732": [0, 0.72222, 0, 0],
  7225. "770": [0, 0.72222, 0, 0],
  7226. "771": [0, 0.72222, 0, 0],
  7227. "8214": [-0.00099, 0.601, 0, 0],
  7228. "8593": [1e-05, 0.6, 0, 0],
  7229. "8595": [1e-05, 0.6, 0, 0],
  7230. "8657": [1e-05, 0.6, 0, 0],
  7231. "8659": [1e-05, 0.6, 0, 0],
  7232. "8719": [0.25001, 0.75, 0, 0],
  7233. "8720": [0.25001, 0.75, 0, 0],
  7234. "8721": [0.25001, 0.75, 0, 0],
  7235. "8730": [0.35001, 0.85, 0, 0],
  7236. "8739": [-0.00599, 0.606, 0, 0],
  7237. "8741": [-0.00599, 0.606, 0, 0],
  7238. "8747": [0.30612, 0.805, 0.19445, 0],
  7239. "8748": [0.306, 0.805, 0.19445, 0],
  7240. "8749": [0.306, 0.805, 0.19445, 0],
  7241. "8750": [0.30612, 0.805, 0.19445, 0],
  7242. "8896": [0.25001, 0.75, 0, 0],
  7243. "8897": [0.25001, 0.75, 0, 0],
  7244. "8898": [0.25001, 0.75, 0, 0],
  7245. "8899": [0.25001, 0.75, 0, 0],
  7246. "8968": [0.35001, 0.85, 0, 0],
  7247. "8969": [0.35001, 0.85, 0, 0],
  7248. "8970": [0.35001, 0.85, 0, 0],
  7249. "8971": [0.35001, 0.85, 0, 0],
  7250. "9168": [-0.00099, 0.601, 0, 0],
  7251. "10216": [0.35001, 0.85, 0, 0],
  7252. "10217": [0.35001, 0.85, 0, 0],
  7253. "10752": [0.25001, 0.75, 0, 0],
  7254. "10753": [0.25001, 0.75, 0, 0],
  7255. "10754": [0.25001, 0.75, 0, 0],
  7256. "10756": [0.25001, 0.75, 0, 0],
  7257. "10758": [0.25001, 0.75, 0, 0]
  7258. },
  7259. "Size2-Regular": {
  7260. "40": [0.65002, 1.15, 0, 0],
  7261. "41": [0.65002, 1.15, 0, 0],
  7262. "47": [0.65002, 1.15, 0, 0],
  7263. "91": [0.65002, 1.15, 0, 0],
  7264. "92": [0.65002, 1.15, 0, 0],
  7265. "93": [0.65002, 1.15, 0, 0],
  7266. "123": [0.65002, 1.15, 0, 0],
  7267. "125": [0.65002, 1.15, 0, 0],
  7268. "710": [0, 0.75, 0, 0],
  7269. "732": [0, 0.75, 0, 0],
  7270. "770": [0, 0.75, 0, 0],
  7271. "771": [0, 0.75, 0, 0],
  7272. "8719": [0.55001, 1.05, 0, 0],
  7273. "8720": [0.55001, 1.05, 0, 0],
  7274. "8721": [0.55001, 1.05, 0, 0],
  7275. "8730": [0.65002, 1.15, 0, 0],
  7276. "8747": [0.86225, 1.36, 0.44445, 0],
  7277. "8748": [0.862, 1.36, 0.44445, 0],
  7278. "8749": [0.862, 1.36, 0.44445, 0],
  7279. "8750": [0.86225, 1.36, 0.44445, 0],
  7280. "8896": [0.55001, 1.05, 0, 0],
  7281. "8897": [0.55001, 1.05, 0, 0],
  7282. "8898": [0.55001, 1.05, 0, 0],
  7283. "8899": [0.55001, 1.05, 0, 0],
  7284. "8968": [0.65002, 1.15, 0, 0],
  7285. "8969": [0.65002, 1.15, 0, 0],
  7286. "8970": [0.65002, 1.15, 0, 0],
  7287. "8971": [0.65002, 1.15, 0, 0],
  7288. "10216": [0.65002, 1.15, 0, 0],
  7289. "10217": [0.65002, 1.15, 0, 0],
  7290. "10752": [0.55001, 1.05, 0, 0],
  7291. "10753": [0.55001, 1.05, 0, 0],
  7292. "10754": [0.55001, 1.05, 0, 0],
  7293. "10756": [0.55001, 1.05, 0, 0],
  7294. "10758": [0.55001, 1.05, 0, 0]
  7295. },
  7296. "Size3-Regular": {
  7297. "40": [0.95003, 1.45, 0, 0],
  7298. "41": [0.95003, 1.45, 0, 0],
  7299. "47": [0.95003, 1.45, 0, 0],
  7300. "91": [0.95003, 1.45, 0, 0],
  7301. "92": [0.95003, 1.45, 0, 0],
  7302. "93": [0.95003, 1.45, 0, 0],
  7303. "123": [0.95003, 1.45, 0, 0],
  7304. "125": [0.95003, 1.45, 0, 0],
  7305. "710": [0, 0.75, 0, 0],
  7306. "732": [0, 0.75, 0, 0],
  7307. "770": [0, 0.75, 0, 0],
  7308. "771": [0, 0.75, 0, 0],
  7309. "8730": [0.95003, 1.45, 0, 0],
  7310. "8968": [0.95003, 1.45, 0, 0],
  7311. "8969": [0.95003, 1.45, 0, 0],
  7312. "8970": [0.95003, 1.45, 0, 0],
  7313. "8971": [0.95003, 1.45, 0, 0],
  7314. "10216": [0.95003, 1.45, 0, 0],
  7315. "10217": [0.95003, 1.45, 0, 0]
  7316. },
  7317. "Size4-Regular": {
  7318. "40": [1.25003, 1.75, 0, 0],
  7319. "41": [1.25003, 1.75, 0, 0],
  7320. "47": [1.25003, 1.75, 0, 0],
  7321. "91": [1.25003, 1.75, 0, 0],
  7322. "92": [1.25003, 1.75, 0, 0],
  7323. "93": [1.25003, 1.75, 0, 0],
  7324. "123": [1.25003, 1.75, 0, 0],
  7325. "125": [1.25003, 1.75, 0, 0],
  7326. "710": [0, 0.825, 0, 0],
  7327. "732": [0, 0.825, 0, 0],
  7328. "770": [0, 0.825, 0, 0],
  7329. "771": [0, 0.825, 0, 0],
  7330. "8730": [1.25003, 1.75, 0, 0],
  7331. "8968": [1.25003, 1.75, 0, 0],
  7332. "8969": [1.25003, 1.75, 0, 0],
  7333. "8970": [1.25003, 1.75, 0, 0],
  7334. "8971": [1.25003, 1.75, 0, 0],
  7335. "9115": [0.64502, 1.155, 0, 0],
  7336. "9116": [1e-05, 0.6, 0, 0],
  7337. "9117": [0.64502, 1.155, 0, 0],
  7338. "9118": [0.64502, 1.155, 0, 0],
  7339. "9119": [1e-05, 0.6, 0, 0],
  7340. "9120": [0.64502, 1.155, 0, 0],
  7341. "9121": [0.64502, 1.155, 0, 0],
  7342. "9122": [-0.00099, 0.601, 0, 0],
  7343. "9123": [0.64502, 1.155, 0, 0],
  7344. "9124": [0.64502, 1.155, 0, 0],
  7345. "9125": [-0.00099, 0.601, 0, 0],
  7346. "9126": [0.64502, 1.155, 0, 0],
  7347. "9127": [1e-05, 0.9, 0, 0],
  7348. "9128": [0.65002, 1.15, 0, 0],
  7349. "9129": [0.90001, 0, 0, 0],
  7350. "9130": [0, 0.3, 0, 0],
  7351. "9131": [1e-05, 0.9, 0, 0],
  7352. "9132": [0.65002, 1.15, 0, 0],
  7353. "9133": [0.90001, 0, 0, 0],
  7354. "9143": [0.88502, 0.915, 0, 0],
  7355. "10216": [1.25003, 1.75, 0, 0],
  7356. "10217": [1.25003, 1.75, 0, 0],
  7357. "57344": [-0.00499, 0.605, 0, 0],
  7358. "57345": [-0.00499, 0.605, 0, 0],
  7359. "57680": [0, 0.12, 0, 0],
  7360. "57681": [0, 0.12, 0, 0],
  7361. "57682": [0, 0.12, 0, 0],
  7362. "57683": [0, 0.12, 0, 0]
  7363. },
  7364. "Typewriter-Regular": {
  7365. "33": [0, 0.61111, 0, 0],
  7366. "34": [0, 0.61111, 0, 0],
  7367. "35": [0, 0.61111, 0, 0],
  7368. "36": [0.08333, 0.69444, 0, 0],
  7369. "37": [0.08333, 0.69444, 0, 0],
  7370. "38": [0, 0.61111, 0, 0],
  7371. "39": [0, 0.61111, 0, 0],
  7372. "40": [0.08333, 0.69444, 0, 0],
  7373. "41": [0.08333, 0.69444, 0, 0],
  7374. "42": [0, 0.52083, 0, 0],
  7375. "43": [-0.08056, 0.53055, 0, 0],
  7376. "44": [0.13889, 0.125, 0, 0],
  7377. "45": [-0.08056, 0.53055, 0, 0],
  7378. "46": [0, 0.125, 0, 0],
  7379. "47": [0.08333, 0.69444, 0, 0],
  7380. "48": [0, 0.61111, 0, 0],
  7381. "49": [0, 0.61111, 0, 0],
  7382. "50": [0, 0.61111, 0, 0],
  7383. "51": [0, 0.61111, 0, 0],
  7384. "52": [0, 0.61111, 0, 0],
  7385. "53": [0, 0.61111, 0, 0],
  7386. "54": [0, 0.61111, 0, 0],
  7387. "55": [0, 0.61111, 0, 0],
  7388. "56": [0, 0.61111, 0, 0],
  7389. "57": [0, 0.61111, 0, 0],
  7390. "58": [0, 0.43056, 0, 0],
  7391. "59": [0.13889, 0.43056, 0, 0],
  7392. "60": [-0.05556, 0.55556, 0, 0],
  7393. "61": [-0.19549, 0.41562, 0, 0],
  7394. "62": [-0.05556, 0.55556, 0, 0],
  7395. "63": [0, 0.61111, 0, 0],
  7396. "64": [0, 0.61111, 0, 0],
  7397. "65": [0, 0.61111, 0, 0],
  7398. "66": [0, 0.61111, 0, 0],
  7399. "67": [0, 0.61111, 0, 0],
  7400. "68": [0, 0.61111, 0, 0],
  7401. "69": [0, 0.61111, 0, 0],
  7402. "70": [0, 0.61111, 0, 0],
  7403. "71": [0, 0.61111, 0, 0],
  7404. "72": [0, 0.61111, 0, 0],
  7405. "73": [0, 0.61111, 0, 0],
  7406. "74": [0, 0.61111, 0, 0],
  7407. "75": [0, 0.61111, 0, 0],
  7408. "76": [0, 0.61111, 0, 0],
  7409. "77": [0, 0.61111, 0, 0],
  7410. "78": [0, 0.61111, 0, 0],
  7411. "79": [0, 0.61111, 0, 0],
  7412. "80": [0, 0.61111, 0, 0],
  7413. "81": [0.13889, 0.61111, 0, 0],
  7414. "82": [0, 0.61111, 0, 0],
  7415. "83": [0, 0.61111, 0, 0],
  7416. "84": [0, 0.61111, 0, 0],
  7417. "85": [0, 0.61111, 0, 0],
  7418. "86": [0, 0.61111, 0, 0],
  7419. "87": [0, 0.61111, 0, 0],
  7420. "88": [0, 0.61111, 0, 0],
  7421. "89": [0, 0.61111, 0, 0],
  7422. "90": [0, 0.61111, 0, 0],
  7423. "91": [0.08333, 0.69444, 0, 0],
  7424. "92": [0.08333, 0.69444, 0, 0],
  7425. "93": [0.08333, 0.69444, 0, 0],
  7426. "94": [0, 0.61111, 0, 0],
  7427. "95": [0.09514, 0, 0, 0],
  7428. "96": [0, 0.61111, 0, 0],
  7429. "97": [0, 0.43056, 0, 0],
  7430. "98": [0, 0.61111, 0, 0],
  7431. "99": [0, 0.43056, 0, 0],
  7432. "100": [0, 0.61111, 0, 0],
  7433. "101": [0, 0.43056, 0, 0],
  7434. "102": [0, 0.61111, 0, 0],
  7435. "103": [0.22222, 0.43056, 0, 0],
  7436. "104": [0, 0.61111, 0, 0],
  7437. "105": [0, 0.61111, 0, 0],
  7438. "106": [0.22222, 0.61111, 0, 0],
  7439. "107": [0, 0.61111, 0, 0],
  7440. "108": [0, 0.61111, 0, 0],
  7441. "109": [0, 0.43056, 0, 0],
  7442. "110": [0, 0.43056, 0, 0],
  7443. "111": [0, 0.43056, 0, 0],
  7444. "112": [0.22222, 0.43056, 0, 0],
  7445. "113": [0.22222, 0.43056, 0, 0],
  7446. "114": [0, 0.43056, 0, 0],
  7447. "115": [0, 0.43056, 0, 0],
  7448. "116": [0, 0.55358, 0, 0],
  7449. "117": [0, 0.43056, 0, 0],
  7450. "118": [0, 0.43056, 0, 0],
  7451. "119": [0, 0.43056, 0, 0],
  7452. "120": [0, 0.43056, 0, 0],
  7453. "121": [0.22222, 0.43056, 0, 0],
  7454. "122": [0, 0.43056, 0, 0],
  7455. "123": [0.08333, 0.69444, 0, 0],
  7456. "124": [0.08333, 0.69444, 0, 0],
  7457. "125": [0.08333, 0.69444, 0, 0],
  7458. "126": [0, 0.61111, 0, 0],
  7459. "127": [0, 0.61111, 0, 0],
  7460. "305": [0, 0.43056, 0, 0],
  7461. "567": [0.22222, 0.43056, 0, 0],
  7462. "768": [0, 0.61111, 0, 0],
  7463. "769": [0, 0.61111, 0, 0],
  7464. "770": [0, 0.61111, 0, 0],
  7465. "771": [0, 0.61111, 0, 0],
  7466. "772": [0, 0.56555, 0, 0],
  7467. "774": [0, 0.61111, 0, 0],
  7468. "776": [0, 0.61111, 0, 0],
  7469. "778": [0, 0.61111, 0, 0],
  7470. "780": [0, 0.56597, 0, 0],
  7471. "915": [0, 0.61111, 0, 0],
  7472. "916": [0, 0.61111, 0, 0],
  7473. "920": [0, 0.61111, 0, 0],
  7474. "923": [0, 0.61111, 0, 0],
  7475. "926": [0, 0.61111, 0, 0],
  7476. "928": [0, 0.61111, 0, 0],
  7477. "931": [0, 0.61111, 0, 0],
  7478. "933": [0, 0.61111, 0, 0],
  7479. "934": [0, 0.61111, 0, 0],
  7480. "936": [0, 0.61111, 0, 0],
  7481. "937": [0, 0.61111, 0, 0],
  7482. "2018": [0, 0.61111, 0, 0],
  7483. "2019": [0, 0.61111, 0, 0],
  7484. "8242": [0, 0.61111, 0, 0]
  7485. }
  7486. };
  7487. },{}],43:[function(require,module,exports){
  7488. "use strict";
  7489. var _utils = require("./utils");
  7490. var _utils2 = _interopRequireDefault(_utils);
  7491. var _ParseError = require("./ParseError");
  7492. var _ParseError2 = _interopRequireDefault(_ParseError);
  7493. var _ParseNode = require("./ParseNode");
  7494. var _ParseNode2 = _interopRequireDefault(_ParseNode);
  7495. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7496. /* This file contains a list of functions that we parse, identified by
  7497. * the calls to defineFunction.
  7498. *
  7499. * The first argument to defineFunction is a single name or a list of names.
  7500. * All functions named in such a list will share a single implementation.
  7501. *
  7502. * Each declared function can have associated properties, which
  7503. * include the following:
  7504. *
  7505. * - numArgs: The number of arguments the function takes.
  7506. * If this is the only property, it can be passed as a number
  7507. * instead of an element of a properties object.
  7508. * - argTypes: (optional) An array corresponding to each argument of the
  7509. * function, giving the type of argument that should be parsed. Its
  7510. * length should be equal to `numArgs + numOptionalArgs`. Valid
  7511. * types:
  7512. * - "size": A size-like thing, such as "1em" or "5ex"
  7513. * - "color": An html color, like "#abc" or "blue"
  7514. * - "original": The same type as the environment that the
  7515. * function being parsed is in (e.g. used for the
  7516. * bodies of functions like \textcolor where the
  7517. * first argument is special and the second
  7518. * argument is parsed normally)
  7519. * Other possible types (probably shouldn't be used)
  7520. * - "text": Text-like (e.g. \text)
  7521. * - "math": Normal math
  7522. * If undefined, this will be treated as an appropriate length
  7523. * array of "original" strings
  7524. * - greediness: (optional) The greediness of the function to use ungrouped
  7525. * arguments.
  7526. *
  7527. * E.g. if you have an expression
  7528. * \sqrt \frac 1 2
  7529. * since \frac has greediness=2 vs \sqrt's greediness=1, \frac
  7530. * will use the two arguments '1' and '2' as its two arguments,
  7531. * then that whole function will be used as the argument to
  7532. * \sqrt. On the other hand, the expressions
  7533. * \frac \frac 1 2 3
  7534. * and
  7535. * \frac \sqrt 1 2
  7536. * will fail because \frac and \frac have equal greediness
  7537. * and \sqrt has a lower greediness than \frac respectively. To
  7538. * make these parse, we would have to change them to:
  7539. * \frac {\frac 1 2} 3
  7540. * and
  7541. * \frac {\sqrt 1} 2
  7542. *
  7543. * The default value is `1`
  7544. * - allowedInText: (optional) Whether or not the function is allowed inside
  7545. * text mode (default false)
  7546. * - numOptionalArgs: (optional) The number of optional arguments the function
  7547. * should parse. If the optional arguments aren't found,
  7548. * `null` will be passed to the handler in their place.
  7549. * (default 0)
  7550. * - infix: (optional) Must be true if the function is an infix operator.
  7551. *
  7552. * The last argument is that implementation, the handler for the function(s).
  7553. * It is called to handle these functions and their arguments.
  7554. * It receives two arguments:
  7555. * - context contains information and references provided by the parser
  7556. * - args is an array of arguments obtained from TeX input
  7557. * The context contains the following properties:
  7558. * - funcName: the text (i.e. name) of the function, including \
  7559. * - parser: the parser object
  7560. * - lexer: the lexer object
  7561. * - positions: the positions in the overall string of the function
  7562. * and the arguments.
  7563. * The latter three should only be used to produce error messages.
  7564. *
  7565. * The function should return an object with the following keys:
  7566. * - type: The type of element that this is. This is then used in
  7567. * buildHTML/buildMathML to determine which function
  7568. * should be called to build this node into a DOM node
  7569. * Any other data can be added to the object, which will be passed
  7570. * in to the function in buildHTML/buildMathML as `group.value`.
  7571. */
  7572. function defineFunction(names, props, handler) {
  7573. if (typeof names === "string") {
  7574. names = [names];
  7575. }
  7576. if (typeof props === "number") {
  7577. props = { numArgs: props };
  7578. }
  7579. // Set default values of functions
  7580. var data = {
  7581. numArgs: props.numArgs,
  7582. argTypes: props.argTypes,
  7583. greediness: props.greediness === undefined ? 1 : props.greediness,
  7584. allowedInText: !!props.allowedInText,
  7585. allowedInMath: props.allowedInMath,
  7586. numOptionalArgs: props.numOptionalArgs || 0,
  7587. infix: !!props.infix,
  7588. handler: handler
  7589. };
  7590. for (var i = 0; i < names.length; ++i) {
  7591. module.exports[names[i]] = data;
  7592. }
  7593. }
  7594. // Since the corresponding buildHTML/buildMathML function expects a
  7595. // list of elements, we normalize for different kinds of arguments
  7596. var ordargument = function ordargument(arg) {
  7597. if (arg.type === "ordgroup") {
  7598. return arg.value;
  7599. } else {
  7600. return [arg];
  7601. }
  7602. };
  7603. // A normal square root
  7604. defineFunction("\\sqrt", {
  7605. numArgs: 1,
  7606. numOptionalArgs: 1
  7607. }, function (context, args) {
  7608. var index = args[0];
  7609. var body = args[1];
  7610. return {
  7611. type: "sqrt",
  7612. body: body,
  7613. index: index
  7614. };
  7615. });
  7616. // Non-mathy text, possibly in a font
  7617. var textFunctionStyles = {
  7618. "\\text": undefined, "\\textrm": "mathrm", "\\textsf": "mathsf",
  7619. "\\texttt": "mathtt", "\\textnormal": "mathrm", "\\textbf": "mathbf",
  7620. "\\textit": "textit"
  7621. };
  7622. defineFunction(["\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", "\\textbf", "\\textit"], {
  7623. numArgs: 1,
  7624. argTypes: ["text"],
  7625. greediness: 2,
  7626. allowedInText: true
  7627. }, function (context, args) {
  7628. var body = args[0];
  7629. return {
  7630. type: "text",
  7631. body: ordargument(body),
  7632. style: textFunctionStyles[context.funcName]
  7633. };
  7634. });
  7635. // A two-argument custom color
  7636. defineFunction("\\textcolor", {
  7637. numArgs: 2,
  7638. allowedInText: true,
  7639. greediness: 3,
  7640. argTypes: ["color", "original"]
  7641. }, function (context, args) {
  7642. var color = args[0];
  7643. var body = args[1];
  7644. return {
  7645. type: "color",
  7646. color: color.value,
  7647. value: ordargument(body)
  7648. };
  7649. });
  7650. // \color is handled in Parser.js's parseImplicitGroup
  7651. defineFunction("\\color", {
  7652. numArgs: 1,
  7653. allowedInText: true,
  7654. greediness: 3,
  7655. argTypes: ["color"]
  7656. }, null);
  7657. // An overline
  7658. defineFunction("\\overline", {
  7659. numArgs: 1
  7660. }, function (context, args) {
  7661. var body = args[0];
  7662. return {
  7663. type: "overline",
  7664. body: body
  7665. };
  7666. });
  7667. // An underline
  7668. defineFunction("\\underline", {
  7669. numArgs: 1
  7670. }, function (context, args) {
  7671. var body = args[0];
  7672. return {
  7673. type: "underline",
  7674. body: body
  7675. };
  7676. });
  7677. // A box of the width and height
  7678. defineFunction("\\rule", {
  7679. numArgs: 2,
  7680. numOptionalArgs: 1,
  7681. argTypes: ["size", "size", "size"]
  7682. }, function (context, args) {
  7683. var shift = args[0];
  7684. var width = args[1];
  7685. var height = args[2];
  7686. return {
  7687. type: "rule",
  7688. shift: shift && shift.value,
  7689. width: width.value,
  7690. height: height.value
  7691. };
  7692. });
  7693. // TODO: In TeX, \mkern only accepts mu-units, and \kern does not accept
  7694. // mu-units. In current KaTeX we relax this; both commands accept any unit.
  7695. defineFunction(["\\kern", "\\mkern"], {
  7696. numArgs: 1,
  7697. argTypes: ["size"]
  7698. }, function (context, args) {
  7699. return {
  7700. type: "kern",
  7701. dimension: args[0].value
  7702. };
  7703. });
  7704. // A KaTeX logo
  7705. defineFunction("\\KaTeX", {
  7706. numArgs: 0
  7707. }, function (context) {
  7708. return {
  7709. type: "katex"
  7710. };
  7711. });
  7712. defineFunction("\\phantom", {
  7713. numArgs: 1
  7714. }, function (context, args) {
  7715. var body = args[0];
  7716. return {
  7717. type: "phantom",
  7718. value: ordargument(body)
  7719. };
  7720. });
  7721. // Math class commands except \mathop
  7722. defineFunction(["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], {
  7723. numArgs: 1
  7724. }, function (context, args) {
  7725. var body = args[0];
  7726. return {
  7727. type: "mclass",
  7728. mclass: "m" + context.funcName.substr(5),
  7729. value: ordargument(body)
  7730. };
  7731. });
  7732. // Build a relation by placing one symbol on top of another
  7733. defineFunction("\\stackrel", {
  7734. numArgs: 2
  7735. }, function (context, args) {
  7736. var top = args[0];
  7737. var bottom = args[1];
  7738. var bottomop = new _ParseNode2.default("op", {
  7739. type: "op",
  7740. limits: true,
  7741. alwaysHandleSupSub: true,
  7742. symbol: false,
  7743. value: ordargument(bottom)
  7744. }, bottom.mode);
  7745. var supsub = new _ParseNode2.default("supsub", {
  7746. base: bottomop,
  7747. sup: top,
  7748. sub: null
  7749. }, top.mode);
  7750. return {
  7751. type: "mclass",
  7752. mclass: "mrel",
  7753. value: [supsub]
  7754. };
  7755. });
  7756. // \mod-type functions
  7757. defineFunction("\\bmod", {
  7758. numArgs: 0
  7759. }, function (context, args) {
  7760. return {
  7761. type: "mod",
  7762. modType: "bmod",
  7763. value: null
  7764. };
  7765. });
  7766. defineFunction(["\\pod", "\\pmod", "\\mod"], {
  7767. numArgs: 1
  7768. }, function (context, args) {
  7769. var body = args[0];
  7770. return {
  7771. type: "mod",
  7772. modType: context.funcName.substr(1),
  7773. value: ordargument(body)
  7774. };
  7775. });
  7776. // Extra data needed for the delimiter handler down below
  7777. var delimiterSizes = {
  7778. "\\bigl": { mclass: "mopen", size: 1 },
  7779. "\\Bigl": { mclass: "mopen", size: 2 },
  7780. "\\biggl": { mclass: "mopen", size: 3 },
  7781. "\\Biggl": { mclass: "mopen", size: 4 },
  7782. "\\bigr": { mclass: "mclose", size: 1 },
  7783. "\\Bigr": { mclass: "mclose", size: 2 },
  7784. "\\biggr": { mclass: "mclose", size: 3 },
  7785. "\\Biggr": { mclass: "mclose", size: 4 },
  7786. "\\bigm": { mclass: "mrel", size: 1 },
  7787. "\\Bigm": { mclass: "mrel", size: 2 },
  7788. "\\biggm": { mclass: "mrel", size: 3 },
  7789. "\\Biggm": { mclass: "mrel", size: 4 },
  7790. "\\big": { mclass: "mord", size: 1 },
  7791. "\\Big": { mclass: "mord", size: 2 },
  7792. "\\bigg": { mclass: "mord", size: 3 },
  7793. "\\Bigg": { mclass: "mord", size: 4 }
  7794. };
  7795. var delimiters = ["(", ")", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\\lceil", "\\rceil", "<", ">", "\\langle", "\\rangle", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."];
  7796. var fontAliases = {
  7797. "\\Bbb": "\\mathbb",
  7798. "\\bold": "\\mathbf",
  7799. "\\frak": "\\mathfrak"
  7800. };
  7801. // Single-argument color functions
  7802. defineFunction(["\\blue", "\\orange", "\\pink", "\\red", "\\green", "\\gray", "\\purple", "\\blueA", "\\blueB", "\\blueC", "\\blueD", "\\blueE", "\\tealA", "\\tealB", "\\tealC", "\\tealD", "\\tealE", "\\greenA", "\\greenB", "\\greenC", "\\greenD", "\\greenE", "\\goldA", "\\goldB", "\\goldC", "\\goldD", "\\goldE", "\\redA", "\\redB", "\\redC", "\\redD", "\\redE", "\\maroonA", "\\maroonB", "\\maroonC", "\\maroonD", "\\maroonE", "\\purpleA", "\\purpleB", "\\purpleC", "\\purpleD", "\\purpleE", "\\mintA", "\\mintB", "\\mintC", "\\grayA", "\\grayB", "\\grayC", "\\grayD", "\\grayE", "\\grayF", "\\grayG", "\\grayH", "\\grayI", "\\kaBlue", "\\kaGreen"], {
  7803. numArgs: 1,
  7804. allowedInText: true,
  7805. greediness: 3
  7806. }, function (context, args) {
  7807. var body = args[0];
  7808. return {
  7809. type: "color",
  7810. color: "katex-" + context.funcName.slice(1),
  7811. value: ordargument(body)
  7812. };
  7813. });
  7814. // There are 2 flags for operators; whether they produce limits in
  7815. // displaystyle, and whether they are symbols and should grow in
  7816. // displaystyle. These four groups cover the four possible choices.
  7817. // No limits, not symbols
  7818. defineFunction(["\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg", "\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg", "\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp", "\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th"], {
  7819. numArgs: 0
  7820. }, function (context) {
  7821. return {
  7822. type: "op",
  7823. limits: false,
  7824. symbol: false,
  7825. body: context.funcName
  7826. };
  7827. });
  7828. // Limits, not symbols
  7829. defineFunction(["\\det", "\\gcd", "\\inf", "\\lim", "\\liminf", "\\limsup", "\\max", "\\min", "\\Pr", "\\sup"], {
  7830. numArgs: 0
  7831. }, function (context) {
  7832. return {
  7833. type: "op",
  7834. limits: true,
  7835. symbol: false,
  7836. body: context.funcName
  7837. };
  7838. });
  7839. // No limits, symbols
  7840. defineFunction(["\\int", "\\iint", "\\iiint", "\\oint"], {
  7841. numArgs: 0
  7842. }, function (context) {
  7843. return {
  7844. type: "op",
  7845. limits: false,
  7846. symbol: true,
  7847. body: context.funcName
  7848. };
  7849. });
  7850. // Limits, symbols
  7851. defineFunction(["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint"], {
  7852. numArgs: 0
  7853. }, function (context) {
  7854. return {
  7855. type: "op",
  7856. limits: true,
  7857. symbol: true,
  7858. body: context.funcName
  7859. };
  7860. });
  7861. // \mathop class command
  7862. defineFunction("\\mathop", {
  7863. numArgs: 1
  7864. }, function (context, args) {
  7865. var body = args[0];
  7866. return {
  7867. type: "op",
  7868. limits: false,
  7869. symbol: false,
  7870. value: ordargument(body)
  7871. };
  7872. });
  7873. // Fractions
  7874. defineFunction(["\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac"], {
  7875. numArgs: 2,
  7876. greediness: 2
  7877. }, function (context, args) {
  7878. var numer = args[0];
  7879. var denom = args[1];
  7880. var hasBarLine = void 0;
  7881. var leftDelim = null;
  7882. var rightDelim = null;
  7883. var size = "auto";
  7884. switch (context.funcName) {
  7885. case "\\dfrac":
  7886. case "\\frac":
  7887. case "\\tfrac":
  7888. hasBarLine = true;
  7889. break;
  7890. case "\\\\atopfrac":
  7891. hasBarLine = false;
  7892. break;
  7893. case "\\dbinom":
  7894. case "\\binom":
  7895. case "\\tbinom":
  7896. hasBarLine = false;
  7897. leftDelim = "(";
  7898. rightDelim = ")";
  7899. break;
  7900. default:
  7901. throw new Error("Unrecognized genfrac command");
  7902. }
  7903. switch (context.funcName) {
  7904. case "\\dfrac":
  7905. case "\\dbinom":
  7906. size = "display";
  7907. break;
  7908. case "\\tfrac":
  7909. case "\\tbinom":
  7910. size = "text";
  7911. break;
  7912. }
  7913. return {
  7914. type: "genfrac",
  7915. numer: numer,
  7916. denom: denom,
  7917. hasBarLine: hasBarLine,
  7918. leftDelim: leftDelim,
  7919. rightDelim: rightDelim,
  7920. size: size
  7921. };
  7922. });
  7923. // Left and right overlap functions
  7924. defineFunction(["\\llap", "\\rlap"], {
  7925. numArgs: 1,
  7926. allowedInText: true
  7927. }, function (context, args) {
  7928. var body = args[0];
  7929. return {
  7930. type: context.funcName.slice(1),
  7931. body: body
  7932. };
  7933. });
  7934. // Delimiter functions
  7935. var checkDelimiter = function checkDelimiter(delim, context) {
  7936. if (_utils2.default.contains(delimiters, delim.value)) {
  7937. return delim;
  7938. } else {
  7939. throw new _ParseError2.default("Invalid delimiter: '" + delim.value + "' after '" + context.funcName + "'", delim);
  7940. }
  7941. };
  7942. defineFunction(["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"], {
  7943. numArgs: 1
  7944. }, function (context, args) {
  7945. var delim = checkDelimiter(args[0], context);
  7946. return {
  7947. type: "delimsizing",
  7948. size: delimiterSizes[context.funcName].size,
  7949. mclass: delimiterSizes[context.funcName].mclass,
  7950. value: delim.value
  7951. };
  7952. });
  7953. defineFunction(["\\left", "\\right"], {
  7954. numArgs: 1
  7955. }, function (context, args) {
  7956. var delim = checkDelimiter(args[0], context);
  7957. // \left and \right are caught somewhere in Parser.js, which is
  7958. // why this data doesn't match what is in buildHTML.
  7959. return {
  7960. type: "leftright",
  7961. value: delim.value
  7962. };
  7963. });
  7964. defineFunction("\\middle", {
  7965. numArgs: 1
  7966. }, function (context, args) {
  7967. var delim = checkDelimiter(args[0], context);
  7968. if (!context.parser.leftrightDepth) {
  7969. throw new _ParseError2.default("\\middle without preceding \\left", delim);
  7970. }
  7971. return {
  7972. type: "middle",
  7973. value: delim.value
  7974. };
  7975. });
  7976. // Sizing functions (handled in Parser.js explicitly, hence no handler)
  7977. defineFunction(["\\tiny", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"], 0, null);
  7978. // Style changing functions (handled in Parser.js explicitly, hence no
  7979. // handler)
  7980. defineFunction(["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"], 0, null);
  7981. // Old font changing functions
  7982. defineFunction(["\\rm", "\\sf", "\\tt", "\\bf", "\\it"], 0, null);
  7983. defineFunction([
  7984. // styles
  7985. "\\mathrm", "\\mathit", "\\mathbf",
  7986. // families
  7987. "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt",
  7988. // aliases
  7989. "\\Bbb", "\\bold", "\\frak"], {
  7990. numArgs: 1,
  7991. greediness: 2
  7992. }, function (context, args) {
  7993. var body = args[0];
  7994. var func = context.funcName;
  7995. if (func in fontAliases) {
  7996. func = fontAliases[func];
  7997. }
  7998. return {
  7999. type: "font",
  8000. font: func.slice(1),
  8001. body: body
  8002. };
  8003. });
  8004. // Accents
  8005. defineFunction(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], {
  8006. numArgs: 1
  8007. }, function (context, args) {
  8008. var base = args[0];
  8009. var isStretchy = !_utils2.default.contains(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot"], context.funcName);
  8010. var isShifty = !isStretchy || _utils2.default.contains(["\\widehat", "\\widetilde"], context.funcName);
  8011. return {
  8012. type: "accent",
  8013. label: context.funcName,
  8014. isStretchy: isStretchy,
  8015. isShifty: isShifty,
  8016. value: ordargument(base),
  8017. base: base
  8018. };
  8019. });
  8020. // Text-mode accents
  8021. defineFunction(["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\r", "\\H", "\\v"], {
  8022. numArgs: 1,
  8023. allowedInText: true,
  8024. allowedInMath: false
  8025. }, function (context, args) {
  8026. var base = args[0];
  8027. return {
  8028. type: "accent",
  8029. label: context.funcName,
  8030. isStretchy: false,
  8031. isShifty: true,
  8032. value: ordargument(base),
  8033. base: base
  8034. };
  8035. });
  8036. // Horizontal stretchy braces
  8037. defineFunction(["\\overbrace", "\\underbrace"], {
  8038. numArgs: 1
  8039. }, function (context, args) {
  8040. var base = args[0];
  8041. return {
  8042. type: "horizBrace",
  8043. label: context.funcName,
  8044. isOver: /^\\over/.test(context.funcName),
  8045. base: base
  8046. };
  8047. });
  8048. // Stretchy accents under the body
  8049. defineFunction(["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\undertilde"], {
  8050. numArgs: 1
  8051. }, function (context, args) {
  8052. var body = args[0];
  8053. return {
  8054. type: "accentUnder",
  8055. label: context.funcName,
  8056. value: ordargument(body),
  8057. body: body
  8058. };
  8059. });
  8060. // Stretchy arrows with an optional argument
  8061. defineFunction(["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xLongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xLongequal", "\\xtofrom"], {
  8062. numArgs: 1,
  8063. numOptionalArgs: 1
  8064. }, function (context, args) {
  8065. var below = args[0];
  8066. var body = args[1];
  8067. return {
  8068. type: "xArrow", // x for extensible
  8069. label: context.funcName,
  8070. body: body,
  8071. below: below
  8072. };
  8073. });
  8074. // enclose
  8075. defineFunction(["\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\fbox"], {
  8076. numArgs: 1
  8077. }, function (context, args) {
  8078. var body = args[0];
  8079. return {
  8080. type: "enclose",
  8081. label: context.funcName,
  8082. body: body
  8083. };
  8084. });
  8085. // Infix generalized fractions
  8086. defineFunction(["\\over", "\\choose", "\\atop"], {
  8087. numArgs: 0,
  8088. infix: true
  8089. }, function (context) {
  8090. var replaceWith = void 0;
  8091. switch (context.funcName) {
  8092. case "\\over":
  8093. replaceWith = "\\frac";
  8094. break;
  8095. case "\\choose":
  8096. replaceWith = "\\binom";
  8097. break;
  8098. case "\\atop":
  8099. replaceWith = "\\\\atopfrac";
  8100. break;
  8101. default:
  8102. throw new Error("Unrecognized infix genfrac command");
  8103. }
  8104. return {
  8105. type: "infix",
  8106. replaceWith: replaceWith,
  8107. token: context.token
  8108. };
  8109. });
  8110. // Row breaks for aligned data
  8111. defineFunction(["\\\\", "\\cr"], {
  8112. numArgs: 0,
  8113. numOptionalArgs: 1,
  8114. argTypes: ["size"]
  8115. }, function (context, args) {
  8116. var size = args[0];
  8117. return {
  8118. type: "cr",
  8119. size: size
  8120. };
  8121. });
  8122. // Environment delimiters
  8123. defineFunction(["\\begin", "\\end"], {
  8124. numArgs: 1,
  8125. argTypes: ["text"]
  8126. }, function (context, args) {
  8127. var nameGroup = args[0];
  8128. if (nameGroup.type !== "ordgroup") {
  8129. throw new _ParseError2.default("Invalid environment name", nameGroup);
  8130. }
  8131. var name = "";
  8132. for (var i = 0; i < nameGroup.value.length; ++i) {
  8133. name += nameGroup.value[i].value;
  8134. }
  8135. return {
  8136. type: "environment",
  8137. name: name,
  8138. nameGroup: nameGroup
  8139. };
  8140. });
  8141. },{"./ParseError":29,"./ParseNode":30,"./utils":51}],44:[function(require,module,exports){
  8142. "use strict";
  8143. /**
  8144. * Predefined macros for KaTeX.
  8145. * This can be used to define some commands in terms of others.
  8146. */
  8147. // This function might one day accept additional argument and do more things.
  8148. function defineMacro(name, body) {
  8149. module.exports[name] = body;
  8150. }
  8151. //////////////////////////////////////////////////////////////////////
  8152. // basics
  8153. defineMacro("\\bgroup", "{");
  8154. defineMacro("\\egroup", "}");
  8155. defineMacro("\\begingroup", "{");
  8156. defineMacro("\\endgroup", "}");
  8157. // We don't distinguish between math and nonmath kerns.
  8158. // (In TeX, the mu unit works only with \mkern.)
  8159. defineMacro("\\mkern", "\\kern");
  8160. //////////////////////////////////////////////////////////////////////
  8161. // amsmath.sty
  8162. // \def\overset#1#2{\binrel@{#2}\binrel@@{\mathop{\kern\z@#2}\limits^{#1}}}
  8163. defineMacro("\\overset", "\\mathop{#2}\\limits^{#1}");
  8164. defineMacro("\\underset", "\\mathop{#2}\\limits_{#1}");
  8165. // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
  8166. defineMacro("\\boxed", "\\fbox{\\displaystyle{#1}}");
  8167. //TODO: When implementing \dots, should ideally add the \DOTSB indicator
  8168. // into the macro, to indicate these are binary operators.
  8169. // \def\iff{\DOTSB\;\Longleftrightarrow\;}
  8170. // \def\implies{\DOTSB\;\Longrightarrow\;}
  8171. // \def\impliedby{\DOTSB\;\Longleftarrow\;}
  8172. defineMacro("\\iff", "\\;\\Longleftrightarrow\\;");
  8173. defineMacro("\\implies", "\\;\\Longrightarrow\\;");
  8174. defineMacro("\\impliedby", "\\;\\Longleftarrow\\;");
  8175. //////////////////////////////////////////////////////////////////////
  8176. // mathtools.sty
  8177. //\providecommand\ordinarycolon{:}
  8178. defineMacro("\\ordinarycolon", ":");
  8179. //\def\vcentcolon{\mathrel{\mathop\ordinarycolon}}
  8180. //TODO(edemaine): Not yet centered. Fix via \raisebox or #726
  8181. defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}");
  8182. // \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon}
  8183. defineMacro("\\dblcolon", "\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon");
  8184. // \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=}
  8185. defineMacro("\\coloneqq", "\\vcentcolon\\mathrel{\\mkern-1.2mu}=");
  8186. // \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=}
  8187. defineMacro("\\Coloneqq", "\\dblcolon\\mathrel{\\mkern-1.2mu}=");
  8188. // \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
  8189. defineMacro("\\coloneq", "\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}");
  8190. // \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
  8191. defineMacro("\\Coloneq", "\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}");
  8192. // \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon}
  8193. defineMacro("\\eqqcolon", "=\\mathrel{\\mkern-1.2mu}\\vcentcolon");
  8194. // \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon}
  8195. defineMacro("\\Eqqcolon", "=\\mathrel{\\mkern-1.2mu}\\dblcolon");
  8196. // \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon}
  8197. defineMacro("\\eqcolon", "\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon");
  8198. // \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon}
  8199. defineMacro("\\Eqcolon", "\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon");
  8200. // \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx}
  8201. defineMacro("\\colonapprox", "\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx");
  8202. // \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx}
  8203. defineMacro("\\Colonapprox", "\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx");
  8204. // \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim}
  8205. defineMacro("\\colonsim", "\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim");
  8206. // \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim}
  8207. defineMacro("\\Colonsim", "\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim");
  8208. //////////////////////////////////////////////////////////////////////
  8209. // colonequals.sty
  8210. // Alternate names for mathtools's macros:
  8211. defineMacro("\\ratio", "\\vcentcolon");
  8212. defineMacro("\\coloncolon", "\\dblcolon");
  8213. defineMacro("\\colonequals", "\\coloneqq");
  8214. defineMacro("\\coloncolonequals", "\\Coloneqq");
  8215. defineMacro("\\equalscolon", "\\eqqcolon");
  8216. defineMacro("\\equalscoloncolon", "\\Eqqcolon");
  8217. defineMacro("\\colonminus", "\\coloneq");
  8218. defineMacro("\\coloncolonminus", "\\Coloneq");
  8219. defineMacro("\\minuscolon", "\\eqcolon");
  8220. defineMacro("\\minuscoloncolon", "\\Eqcolon");
  8221. // \colonapprox name is same in mathtools and colonequals.
  8222. defineMacro("\\coloncolonapprox", "\\Colonapprox");
  8223. // \colonsim name is same in mathtools and colonequals.
  8224. defineMacro("\\coloncolonsim", "\\Colonsim");
  8225. // Additional macros, implemented by analogy with mathtools definitions:
  8226. defineMacro("\\simcolon", "\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon");
  8227. defineMacro("\\simcoloncolon", "\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon");
  8228. defineMacro("\\approxcolon", "\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon");
  8229. defineMacro("\\approxcoloncolon", "\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon");
  8230. },{}],45:[function(require,module,exports){
  8231. "use strict";
  8232. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  8233. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  8234. var _createClass2 = require("babel-runtime/helpers/createClass");
  8235. var _createClass3 = _interopRequireDefault(_createClass2);
  8236. var _utils = require("./utils");
  8237. var _utils2 = _interopRequireDefault(_utils);
  8238. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8239. /**
  8240. * This node represents a general purpose MathML node of any type. The
  8241. * constructor requires the type of node to create (for example, `"mo"` or
  8242. * `"mspace"`, corresponding to `<mo>` and `<mspace>` tags).
  8243. */
  8244. var MathNode = function () {
  8245. function MathNode(type, children) {
  8246. (0, _classCallCheck3.default)(this, MathNode);
  8247. this.type = type;
  8248. this.attributes = {};
  8249. this.children = children || [];
  8250. }
  8251. /**
  8252. * Sets an attribute on a MathML node. MathML depends on attributes to convey a
  8253. * semantic content, so this is used heavily.
  8254. */
  8255. (0, _createClass3.default)(MathNode, [{
  8256. key: "setAttribute",
  8257. value: function setAttribute(name, value) {
  8258. this.attributes[name] = value;
  8259. }
  8260. /**
  8261. * Converts the math node into a MathML-namespaced DOM element.
  8262. */
  8263. }, {
  8264. key: "toNode",
  8265. value: function toNode() {
  8266. var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type);
  8267. for (var attr in this.attributes) {
  8268. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  8269. node.setAttribute(attr, this.attributes[attr]);
  8270. }
  8271. }
  8272. for (var i = 0; i < this.children.length; i++) {
  8273. node.appendChild(this.children[i].toNode());
  8274. }
  8275. return node;
  8276. }
  8277. /**
  8278. * Converts the math node into an HTML markup string.
  8279. */
  8280. }, {
  8281. key: "toMarkup",
  8282. value: function toMarkup() {
  8283. var markup = "<" + this.type;
  8284. // Add the attributes
  8285. for (var attr in this.attributes) {
  8286. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  8287. markup += " " + attr + "=\"";
  8288. markup += _utils2.default.escape(this.attributes[attr]);
  8289. markup += "\"";
  8290. }
  8291. }
  8292. markup += ">";
  8293. for (var i = 0; i < this.children.length; i++) {
  8294. markup += this.children[i].toMarkup();
  8295. }
  8296. markup += "</" + this.type + ">";
  8297. return markup;
  8298. }
  8299. }]);
  8300. return MathNode;
  8301. }();
  8302. /**
  8303. * This node represents a piece of text.
  8304. */
  8305. /**
  8306. * These objects store data about MathML nodes. This is the MathML equivalent
  8307. * of the types in domTree.js. Since MathML handles its own rendering, and
  8308. * since we're mainly using MathML to improve accessibility, we don't manage
  8309. * any of the styling state that the plain DOM nodes do.
  8310. *
  8311. * The `toNode` and `toMarkup` functions work simlarly to how they do in
  8312. * domTree.js, creating namespaced DOM nodes and HTML text markup respectively.
  8313. */
  8314. var TextNode = function () {
  8315. function TextNode(text) {
  8316. (0, _classCallCheck3.default)(this, TextNode);
  8317. this.text = text;
  8318. }
  8319. /**
  8320. * Converts the text node into a DOM text node.
  8321. */
  8322. (0, _createClass3.default)(TextNode, [{
  8323. key: "toNode",
  8324. value: function toNode() {
  8325. return document.createTextNode(this.text);
  8326. }
  8327. /**
  8328. * Converts the text node into HTML markup (which is just the text itself).
  8329. */
  8330. }, {
  8331. key: "toMarkup",
  8332. value: function toMarkup() {
  8333. return _utils2.default.escape(this.text);
  8334. }
  8335. }]);
  8336. return TextNode;
  8337. }();
  8338. module.exports = {
  8339. MathNode: MathNode,
  8340. TextNode: TextNode
  8341. };
  8342. },{"./utils":51,"babel-runtime/helpers/classCallCheck":4,"babel-runtime/helpers/createClass":5}],46:[function(require,module,exports){
  8343. 'use strict';
  8344. var _Parser = require('./Parser');
  8345. var _Parser2 = _interopRequireDefault(_Parser);
  8346. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8347. /**
  8348. * Parses an expression using a Parser, then returns the parsed result.
  8349. */
  8350. var parseTree = function parseTree(toParse, settings) {
  8351. if (!(typeof toParse === 'string' || toParse instanceof String)) {
  8352. throw new TypeError('KaTeX can only parse string typed expression');
  8353. }
  8354. var parser = new _Parser2.default(toParse, settings);
  8355. return parser.parse();
  8356. }; /**
  8357. * Provides a single function for parsing an expression using a Parser
  8358. * TODO(emily): Remove this
  8359. */
  8360. module.exports = parseTree;
  8361. },{"./Parser":31}],47:[function(require,module,exports){
  8362. "use strict";
  8363. /**
  8364. * This file provides support to buildMathML.js and buildHTML.js
  8365. * for stretchy wide elements rendered from SVG files
  8366. * and other CSS trickery.
  8367. */
  8368. var buildCommon = require("./buildCommon");
  8369. var mathMLTree = require("./mathMLTree");
  8370. var utils = require("./utils");
  8371. var stretchyCodePoint = {
  8372. widehat: "^",
  8373. widetilde: "~",
  8374. undertilde: "~",
  8375. overleftarrow: "\u2190",
  8376. underleftarrow: "\u2190",
  8377. xleftarrow: "\u2190",
  8378. overrightarrow: "\u2192",
  8379. underrightarrow: "\u2192",
  8380. xrightarrow: "\u2192",
  8381. underbrace: "\u23B5",
  8382. overbrace: "\u23DE",
  8383. overleftrightarrow: "\u2194",
  8384. underleftrightarrow: "\u2194",
  8385. xleftrightarrow: "\u2194",
  8386. Overrightarrow: "\u21D2",
  8387. xRightarrow: "\u21D2",
  8388. overleftharpoon: "\u21BC",
  8389. xleftharpoonup: "\u21BC",
  8390. overrightharpoon: "\u21C0",
  8391. xrightharpoonup: "\u21C0",
  8392. xLeftarrow: "\u21D0",
  8393. xLeftrightarrow: "\u21D4",
  8394. xhookleftarrow: "\u21A9",
  8395. xhookrightarrow: "\u21AA",
  8396. xmapsto: "\u21A6",
  8397. xrightharpoondown: "\u21C1",
  8398. xleftharpoondown: "\u21BD",
  8399. xrightleftharpoons: "\u21CC",
  8400. xleftrightharpoons: "\u21CB",
  8401. xtwoheadleftarrow: "\u219E",
  8402. xtwoheadrightarrow: "\u21A0",
  8403. xLongequal: "=",
  8404. xtofrom: "\u21C4"
  8405. };
  8406. var mathMLnode = function mathMLnode(label) {
  8407. var node = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(stretchyCodePoint[label.substr(1)])]);
  8408. node.setAttribute("stretchy", "true");
  8409. return node;
  8410. };
  8411. // In the katexImagesData object just below, the dimensions all
  8412. // correspond to path geometry inside the relevant SVG.
  8413. // For example, \rightarrow uses the same arrowhead as glyph U+2192
  8414. // from the KaTeX Main font. The scaling factor is 1000.
  8415. // That is, inside the font, that arrowhead is 522 units tall, which
  8416. // corresponds to 0.522 em inside the document.
  8417. // And for extensible arrows, we split that distance around the math axis.
  8418. var katexImagesData = {
  8419. // height, depth, imageName, minWidth
  8420. overleftarrow: [0.522, 0, "leftarrow", 0.5],
  8421. underleftarrow: [0.522, 0, "leftarrow", 0.5],
  8422. xleftarrow: [0.261, 0.261, "leftarrow", 0.783],
  8423. overrightarrow: [0.522, 0, "rightarrow", 0.5],
  8424. underrightarrow: [0.522, 0, "rightarrow", 0.5],
  8425. xrightarrow: [0.261, 0.261, "rightarrow", 0.783],
  8426. overbrace: [0.548, 0, "overbrace", 1.6],
  8427. underbrace: [0.548, 0, "underbrace", 1.6],
  8428. overleftrightarrow: [0.522, 0, "leftrightarrow", 0.5],
  8429. underleftrightarrow: [0.522, 0, "leftrightarrow", 0.5],
  8430. xleftrightarrow: [0.261, 0.261, "leftrightarrow", 0.783],
  8431. Overrightarrow: [0.56, 0, "doublerightarrow", 0.5],
  8432. xLeftarrow: [0.28, 0.28, "doubleleftarrow", 0.783],
  8433. xRightarrow: [0.28, 0.28, "doublerightarrow", 0.783],
  8434. xLeftrightarrow: [0.28, 0.28, "doubleleftrightarrow", 0.955],
  8435. overleftharpoon: [0.522, 0, "leftharpoon", 0.5],
  8436. overrightharpoon: [0.522, 0, "rightharpoon", 0.5],
  8437. xleftharpoonup: [0.261, 0.261, "leftharpoon", 0.783],
  8438. xrightharpoonup: [0.261, 0.261, "rightharpoon", 0.783],
  8439. xhookleftarrow: [0.261, 0.261, "hookleftarrow", 0.87],
  8440. xhookrightarrow: [0.261, 0.261, "hookrightarrow", 0.87],
  8441. overlinesegment: [0.414, 0, "linesegment", 0.5],
  8442. underlinesegment: [0.414, 0, "linesegment", 0.5],
  8443. xmapsto: [0.261, 0.261, "mapsto", 0.783],
  8444. xrightharpoondown: [0.261, 0.261, "rightharpoondown", 0.783],
  8445. xleftharpoondown: [0.261, 0.261, "leftharpoondown", 0.783],
  8446. xrightleftharpoons: [0.358, 0.358, "rightleftharpoons", 0.716],
  8447. xleftrightharpoons: [0.358, 0.358, "leftrightharpoons", 0.716],
  8448. overgroup: [0.342, 0, "overgroup", 0.87],
  8449. undergroup: [0.342, 0, "undergroup", 0.87],
  8450. xtwoheadleftarrow: [0.167, 0.167, "twoheadleftarrow", 0.86],
  8451. xtwoheadrightarrow: [0.167, 0.167, "twoheadrightarrow", 0.86],
  8452. xLongequal: [0.167, 0.167, "longequal", 0.5],
  8453. xtofrom: [0.264, 0.264, "tofrom", 0.86]
  8454. };
  8455. // Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts.
  8456. // Copyright (c) 2009-2010, Design Science, Inc. (<www.mathjax.org>)
  8457. // Copyright (c) 2014-2017 Khan Academy (<www.khanacademy.org>)
  8458. // Licensed under the SIL Open Font License, Version 1.1.
  8459. // See \nhttp://scripts.sil.org/OFL
  8460. // Nested SVGs
  8461. // Many of the KaTeX SVG images contain a nested SVG. This is done to
  8462. // achieve a stretchy image while avoiding distortion of arrowheads or
  8463. // brace corners.
  8464. // The inner SVG typically contains a very long (400 em) arrow.
  8465. // The outer SVG acts like a window that exposes only part of the inner SVG.
  8466. // The outer SVG will grow or shrink to match the dimensions set by CSS.
  8467. // The inner SVG always has a longer, thinner aspect ratio than the outer
  8468. // SVG. After the inner SVG fills 100% of the height of the outer SVG,
  8469. // there is a long arrow shaft left over. That left-over shaft is not shown.
  8470. // Instead, it is sliced off because the inner SVG is set to
  8471. // "preserveAspectRatio='... slice'".
  8472. // Thus, the reader sees an arrow that matches the subject matter width
  8473. // without distortion.
  8474. // Some functions, such as \cancel, need to vary their aspect ratio. These
  8475. // functions do not get the nested SVG treatment.
  8476. // Second Brush Stroke
  8477. // Low resolution monitors struggle to display images in fine detail.
  8478. // So browsers apply anti-aliasing. A long straight arrow shaft therefore
  8479. // will sometimes appear as if it has a blurred edge.
  8480. // To mitigate this, these SVG files contain a second "brush-stroke" on the
  8481. // arrow shafts. That is, a second long thin rectangular SVG path has been
  8482. // written directly on top of each arrow shaft. This reinforcement causes
  8483. // some of the screen pixels to display as black instead of the anti-aliased
  8484. // gray pixel that a single path would generate. So we get arrow shafts
  8485. // whose edges appear to be sharper.
  8486. var svgPath = {
  8487. doubleleftarrow: "<path d='M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z'/>",
  8488. doublerightarrow: "<path d='M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/>",
  8489. leftarrow: "<path d='M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z'/>",
  8490. rightarrow: "<path d='M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z'/>"
  8491. };
  8492. var innerSVG = {
  8493. // Since bcancel's SVG is inline and it omits the viewBox attribute,
  8494. // it's stroke-width will not vary with span area.
  8495. bcancel: "<line x1='0' y1='0' x2='100%' y2='100%' stroke-width='0.046em'/>",
  8496. cancel: "<line x1='0' y1='100%' x2='100%' y2='0' stroke-width='0.046em'/>",
  8497. // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main
  8498. doubleleftarrow: "><svg viewBox='0 0 400000 549'\npreserveAspectRatio='xMinYMin slice'>" + svgPath["doubleleftarrow"] + "</svg>",
  8499. // doubleleftrightarrow is from glyph U+21D4 in font KaTeX Main
  8500. doubleleftrightarrow: "><svg width='50.1%' viewBox='0 0 400000 549'\npreserveAspectRatio='xMinYMin slice'>" + svgPath["doubleleftarrow"] + "</svg>\n<svg x='50%' width='50%' viewBox='0 0 400000 549' preserveAspectRatio='xMaxYMin\n slice'>" + svgPath["doublerightarrow"] + "</svg>",
  8501. // doublerightarrow is from glyph U+21D2 in font KaTeX Main
  8502. doublerightarrow: "><svg viewBox='0 0 400000 549'\npreserveAspectRatio='xMaxYMin slice'>" + svgPath["doublerightarrow"] + "</svg>",
  8503. // hookleftarrow is from glyph U+21A9 in font KaTeX Main
  8504. hookleftarrow: "><svg width='50.1%' viewBox='0 0 400000 522'\npreserveAspectRatio='xMinYMin slice'>" + svgPath["leftarrow"] + "</svg>\n<svg x='50%' width='50%' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin\n slice'><path d='M399859 241c-764 0 0 0 0 0 40-3.3 68.7\n -15.7 86-37 10-12 15-25.3 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5\n -23-17.3-1.3-26-8-26-20 0-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21\n 16.7 14 11.2 21 33.5 21 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z\n M0 281v-40h399859v40z'/></svg>",
  8505. // hookrightarrow is from glyph U+21AA in font KaTeX Main
  8506. hookrightarrow: "><svg width='50.1%' viewBox='0 0 400000 522'\npreserveAspectRatio='xMinYMin slice'><path d='M400000 281\nH103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5-83.5C70.8 58.2 104 47 142 47\nc16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3-68.7 15.7-86 37-10 12-15 25.3\n-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21 71.5 23h399859zM103 281v-40\nh399897v40z'/></svg><svg x='50%' width='50%' viewBox='0 0 400000 522'\npreserveAspectRatio='xMaxYMin slice'>" + svgPath["rightarrow"] + "</svg>",
  8507. // leftarrow is from glyph U+2190 in font KaTeX Main
  8508. leftarrow: "><svg viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin\n slice'>" + svgPath["leftarrow"] + "</svg>",
  8509. // leftharpoon is from glyph U+21BD in font KaTeX Main
  8510. leftharpoon: "><svg viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin\n slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z'/></svg>",
  8511. // leftharpoondown is from glyph U+21BD in font KaTeX Main
  8512. leftharpoondown: "><svg viewBox='0 0 400000 522'\npreserveAspectRatio='xMinYMin slice'><path d=\"M7 241c-4 4-6.333 8.667-7 14\n 0 5.333.667 9 2 11s5.333 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667\n 6.333 16.333 9 17 2 .667 5 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21\n -32-87.333-82.667-157.667-152-211l-3-3h399907v-40z\nM93 281 H400000 v-40L7 241z\"/></svg>",
  8513. // leftrightarrow is from glyph U+2194 in font KaTeX Main
  8514. leftrightarrow: "><svg width='50.1%' viewBox='0 0 400000 522'\npreserveAspectRatio='xMinYMin slice'>" + svgPath["leftarrow"] + "</svg>\n<svg x='50%' width='50%' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin\n slice'>" + svgPath["rightarrow"] + "</svg>",
  8515. // leftrightharpoons is from glyphs U+21BC/21B1 in font KaTeX Main
  8516. leftrightharpoons: "><svg width='50.1%' viewBox='0 0 400000 716'\npreserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3\n 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52\n 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8\n 16c-42 98.7-107.3 174.7-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26\nv40h399900v-40zM0 435v40h400000v-40zm0 0v40h400000v-40z'/></svg>\n<svg x='50%' width='50%' viewBox='0 0 400000 716' preserveAspectRatio='xMaxYMin\n slice'><path d='M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z'/></svg>",
  8517. linesegment: "><svg width='50.1%' viewBox='0 0 400000 414'\npreserveAspectRatio='xMinYMin slice'><path d='M40 187V40H0\nv334h40V227h399960v-40zm0 0V40H0v334h40V227h399960v-40z'/></svg><svg x='50%'\nwidth='50%' viewBox='0 0 400000 414' preserveAspectRatio='xMaxYMin slice'>\n<path d='M0 187v40h399960v147h40V40h-40v147zm0\n 0v40h399960v147h40V40h-40v147z'/></svg>",
  8518. longequal: " viewBox='0 0 100 334' preserveAspectRatio='none'>\n<path d='M0 50h100v40H0zm0 194h100v40H0z'/>",
  8519. // mapsto is from glyph U+21A6 in font KaTeX Main
  8520. mapsto: "><svg width='50.1%' viewBox='0 0 400000 522'\npreserveAspectRatio='xMinYMin slice'><path d='M40 241c740\n 0 0 0 0 0v-75c0-40.7-.2-64.3-.5-71-.3-6.7-2.2-11.7-5.5-15-4-4-8.7-6-14-6-5.3 0\n-10 2-14 6C2.7 83.3.8 91.3.5 104 .2 116.7 0 169 0 261c0 114 .7 172.3 2 175 4 8\n 10 12 18 12 5.3 0 10-2 14-6 3.3-3.3 5.2-8.3 5.5-15 .3-6.7.5-30.3.5-71v-75\nh399960zm0 0v40h399960v-40z'/></svg><svg x='50%' width='50%' viewBox='0 0\n 400000 522' preserveAspectRatio='xMaxYMin slice'>" + svgPath["rightarrow"] + "</svg>",
  8521. // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular
  8522. overbrace: "><svg width='25.5%' viewBox='0 0 400000 548'\npreserveAspectRatio='xMinYMin slice'><path d='M6 548l-6-6\nv-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117-45 179-50h399577v120H403\nc-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7 5-6 9-10 13-.7 1-7.3 1-20 1\nH6z'/></svg><svg x='25%' width='50%' viewBox='0 0 400000 548'\npreserveAspectRatio='xMidYMin slice'><path d='M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z'/></svg>\n<svg x='74.9%' width='24.1%' viewBox='0 0 400000 548'\npreserveAspectRatio='xMaxYMin slice'><path d='M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z'/></svg>",
  8523. // overgroup is from the MnSymbol package (public domain)
  8524. overgroup: "><svg width='50.1%' viewBox='0 0 400000 342'\npreserveAspectRatio='xMinYMin slice'><path d='M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z'/></svg><svg x='50%' width='50%' viewBox='0 0 400000 342'\npreserveAspectRatio='xMaxYMin slice'><path d='M0 80h399565\nc371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0 3-1 3-3v-38\nc-76-158-257-219-435-219H0z'/></svg>",
  8525. // rightarrow is from glyph U+2192 in font KaTeX Main
  8526. rightarrow: "><svg viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin\n slice'>" + svgPath["rightarrow"] + "</svg>",
  8527. // rightharpoon is from glyph U+21C0 in font KaTeX Main
  8528. rightharpoon: "><svg viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin\n slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z'/></svg>",
  8529. // rightharpoondown is from glyph U+21C1 in font KaTeX Main
  8530. rightharpoondown: "><svg viewBox='0 0 400000 522'\npreserveAspectRatio='xMaxYMin slice'><path d='M399747 511\nc0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217\n 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3\n -10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3\n 8.7-5 14-5 16zM0 241v40h399900v-40z'/></svg>",
  8531. // rightleftharpoons is from glyph U+21CC in font KaTeX Main
  8532. rightleftharpoons: "><svg width='50%' viewBox='0 0 400000 716'\npreserveAspectRatio='xMinYMin slice'><path d='M7 435c-4 4\n-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12 10c90.7 54 156 130 196 228 3.3 10.7 6.3\n 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7\n-157.7-152-211l-3-3h399907v-40H7zm93 0v40h399900v-40zM0 241v40h399900v-40z\nm0 0v40h399900v-40z'/></svg><svg x='50%' width='50%' viewBox='0 0 400000 716'\npreserveAspectRatio='xMaxYMin slice'><path d='M0 241v40\nh399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3\n-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42\n 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5zm0 0v40h399900v-40z\n m100 194v40h399900v-40zm0 0v40h399900v-40z'/></svg>",
  8533. // tilde1 is a modified version of a glyph from the MnSymbol package
  8534. tilde1: " viewBox='0 0 600 260' preserveAspectRatio='none'>\n<path d='M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z'/>",
  8535. // Ditto tilde2, tilde3, and tilde 4
  8536. tilde2: " viewBox='0 0 1033 286' preserveAspectRatio='none'>\n<path d='M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z'/>",
  8537. tilde3: " viewBox='0 0 2339 306' preserveAspectRatio='none'>\n<path d='M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z'/>",
  8538. tilde4: " viewBox='0 0 2340 312' preserveAspectRatio='none'>\n<path d='M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z'/>",
  8539. // tofrom is from glyph U+21C4 in font KaTeX AMS Regular
  8540. tofrom: "><svg width='50.1%' viewBox='0 0 400000 528'\npreserveAspectRatio='xMinYMin slice'><path d='M0 147h400000\nv40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37\n-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8c28.7-32 52-65.7 70-101 10.7-23.3\n 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3 68 321 0 361zm0-174v-40h399900\nv40zm100 154v40h399900v-40z'/></svg><svg x='50%' width='50%' viewBox='0 0\n 400000 528' preserveAspectRatio='xMaxYMin slice'><path\nd='M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7\n 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32-52 65.7-70 101-10.7\n 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142-167z\n M100 147v40h399900v-40zM0 341v40h399900v-40z'/></svg>",
  8541. // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular
  8542. twoheadleftarrow: "><svg viewBox='0 0 400000 334'\npreserveAspectRatio='xMinYMin slice'><path d='M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z'/>\n</svg>",
  8543. // twoheadrightarrow is from glyph U+21A0 in font KaTeX AMS Regular
  8544. twoheadrightarrow: "><svg viewBox='0 0 400000 334'\npreserveAspectRatio='xMaxYMin slice'><path d='M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z'/>\n</svg>",
  8545. // underbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular
  8546. underbrace: "><svg width='25.1%' viewBox='0 0 400000 548'\npreserveAspectRatio='xMinYMin slice'><path d='M0 6l6-6h17\nc12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13 35.313 51.3 80.813 93.8 136.5 127.5\n 55.688 33.7 117.188 55.8 184.5 66.5.688 0 2 .3 4 1 18.688 2.7 76 4.3 172 5\nh399450v120H429l-6-1c-124.688-8-235-61.7-331-161C60.687 138.7 32.312 99.3 7 54\nL0 41V6z'/></svg><svg x='25%' width='50%' viewBox='0 0 400000 548'\npreserveAspectRatio='xMidYMin slice'><path d='M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z'/></svg>\n<svg x='74.9%' width='25.1%' viewBox='0 0 400000 548'\npreserveAspectRatio='xMaxYMin slice'><path d='M399994 0l6 6\nv35l-6 11c-56 104-135.3 181.3-238 232-57.3 28.7-117 45-179 50H-300V214h399897\nc43.3-7 81-15 113-26 100.7-33 179.7-91 237-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1\nh17z'/></svg>",
  8547. // undergroup is from the MnSymbol package (public domain)
  8548. undergroup: "><svg width='50.1%' viewBox='0 0 400000 342'\npreserveAspectRatio='xMinYMin slice'><path d='M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z'/></svg><svg x='50%' width='50%' viewBox='0 0 400000 342'\npreserveAspectRatio='xMaxYMin slice'><path d='M0 262h399565\nc371 0 266.7-149.4 414-180 5.9-1.2 18 0 18 0 2 0 3 1 3 3v38c-76 158-257\n 219-435 219H0z'/></svg>",
  8549. // widehat1 is a modified version of a glyph from the MnSymbol package
  8550. widehat1: " viewBox='0 0 1062 239' preserveAspectRatio='none'>\n<path d='M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z'/>",
  8551. // Ditto widehat2, widehat3, and widehat4
  8552. widehat2: " viewBox='0 0 2364 300' preserveAspectRatio='none'>\n<path d='M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z'/>",
  8553. widehat3: " viewBox='0 0 2364 360' preserveAspectRatio='none'>\n<path d='M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z'/>",
  8554. widehat4: " viewBox='0 0 2364 420' preserveAspectRatio='none'>\n<path d='M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z'/>",
  8555. xcancel: "<line x1='0' y1='0' x2='100%' y2='100%' stroke-width='0.046em'/>\n<line x1='0' y1='100%' x2='100%' y2='0' stroke-width='0.046em'/>"
  8556. };
  8557. var svgSpan = function svgSpan(group, options) {
  8558. // Create a span with inline SVG for the element.
  8559. var label = group.value.label.substr(1);
  8560. var height = 0;
  8561. var depth = 0;
  8562. var imageName = "";
  8563. var minWidth = 0;
  8564. if (utils.contains(["widehat", "widetilde", "undertilde"], label)) {
  8565. // There are four SVG images available for each function.
  8566. // Choose a taller image when there are more characters.
  8567. var numChars = group.value.value.length;
  8568. if (numChars > 5) {
  8569. height = 0.312;
  8570. imageName = (label === "widehat" ? "widehat" : "tilde") + "4";
  8571. } else {
  8572. var imgIndex = [1, 1, 2, 2, 3, 3][numChars];
  8573. if (label === "widehat") {
  8574. height = [0, 0.24, 0.30, 0.30, 0.36, 0.36][numChars];
  8575. imageName = "widehat" + imgIndex;
  8576. } else {
  8577. height = [0, 0.26, 0.30, 0.30, 0.34, 0.34][numChars];
  8578. imageName = "tilde" + imgIndex;
  8579. }
  8580. }
  8581. } else {
  8582. var imgData = katexImagesData[label];
  8583. height = imgData[0];
  8584. depth = imgData[1];
  8585. imageName = imgData[2];
  8586. minWidth = imgData[3];
  8587. }
  8588. var span = buildCommon.makeSpan([], [], options);
  8589. span.height = height;
  8590. span.depth = depth;
  8591. var totalHeight = height + depth;
  8592. span.style.height = totalHeight + "em";
  8593. if (minWidth > 0) {
  8594. span.style.minWidth = minWidth + "em";
  8595. }
  8596. span.innerHTML = "<svg width='100%' height='" + totalHeight + "em'" + innerSVG[imageName] + "</svg>";
  8597. return span;
  8598. };
  8599. var encloseSpan = function encloseSpan(inner, label, pad, options) {
  8600. // Return an image span for \cancel, \bcancel, \xcancel, or \fbox
  8601. var img = void 0;
  8602. var totalHeight = inner.height + inner.depth + 2 * pad;
  8603. if (label === "fbox") {
  8604. img = buildCommon.makeSpan(["stretchy", label], [], options);
  8605. if (options.color) {
  8606. img.style.borderColor = options.getColor();
  8607. }
  8608. } else {
  8609. img = buildCommon.makeSpan([], [], options);
  8610. img.innerHTML = "<svg width='100%' height='" + totalHeight + "em'>" + innerSVG[label] + "</svg>";
  8611. }
  8612. img.height = totalHeight;
  8613. img.style.height = totalHeight + "em";
  8614. return img;
  8615. };
  8616. module.exports = {
  8617. encloseSpan: encloseSpan,
  8618. mathMLnode: mathMLnode,
  8619. svgSpan: svgSpan
  8620. };
  8621. },{"./buildCommon":34,"./mathMLTree":45,"./utils":51}],48:[function(require,module,exports){
  8622. "use strict";
  8623. /**
  8624. * This file holds a list of all no-argument functions and single-character
  8625. * symbols (like 'a' or ';').
  8626. *
  8627. * For each of the symbols, there are three properties they can have:
  8628. * - font (required): the font to be used for this symbol. Either "main" (the
  8629. normal font), or "ams" (the ams fonts).
  8630. * - group (required): the ParseNode group type the symbol should have (i.e.
  8631. "textord", "mathord", etc).
  8632. See https://github.com/Khan/KaTeX/wiki/Examining-TeX#group-types
  8633. * - replace: the character that this symbol or function should be
  8634. * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi
  8635. * character in the main font).
  8636. *
  8637. * The outermost map in the table indicates what mode the symbols should be
  8638. * accepted in (e.g. "math" or "text").
  8639. */
  8640. module.exports = {
  8641. math: {},
  8642. text: {}
  8643. };
  8644. function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) {
  8645. module.exports[mode][name] = {
  8646. font: font,
  8647. group: group,
  8648. replace: replace
  8649. };
  8650. if (acceptUnicodeChar) {
  8651. module.exports[mode][replace] = module.exports[mode][name];
  8652. }
  8653. }
  8654. // Some abbreviations for commonly used strings.
  8655. // This helps minify the code, and also spotting typos using jshint.
  8656. // modes:
  8657. var math = "math";
  8658. var text = "text";
  8659. // fonts:
  8660. var main = "main";
  8661. var ams = "ams";
  8662. // groups:
  8663. var accent = "accent";
  8664. var bin = "bin";
  8665. var close = "close";
  8666. var inner = "inner";
  8667. var mathord = "mathord";
  8668. var op = "op";
  8669. var open = "open";
  8670. var punct = "punct";
  8671. var rel = "rel";
  8672. var spacing = "spacing";
  8673. var textord = "textord";
  8674. // Now comes the symbol table
  8675. // Relation Symbols
  8676. defineSymbol(math, main, rel, "\u2261", "\\equiv");
  8677. defineSymbol(math, main, rel, "\u227A", "\\prec");
  8678. defineSymbol(math, main, rel, "\u227B", "\\succ");
  8679. defineSymbol(math, main, rel, "\u223C", "\\sim");
  8680. defineSymbol(math, main, rel, "\u22A5", "\\perp");
  8681. defineSymbol(math, main, rel, "\u2AAF", "\\preceq");
  8682. defineSymbol(math, main, rel, "\u2AB0", "\\succeq");
  8683. defineSymbol(math, main, rel, "\u2243", "\\simeq");
  8684. defineSymbol(math, main, rel, "\u2223", "\\mid");
  8685. defineSymbol(math, main, rel, "\u226A", "\\ll");
  8686. defineSymbol(math, main, rel, "\u226B", "\\gg");
  8687. defineSymbol(math, main, rel, "\u224D", "\\asymp");
  8688. defineSymbol(math, main, rel, "\u2225", "\\parallel");
  8689. defineSymbol(math, main, rel, "\u22C8", "\\bowtie");
  8690. defineSymbol(math, main, rel, "\u2323", "\\smile");
  8691. defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq");
  8692. defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq");
  8693. defineSymbol(math, main, rel, "\u2250", "\\doteq");
  8694. defineSymbol(math, main, rel, "\u2322", "\\frown");
  8695. defineSymbol(math, main, rel, "\u220B", "\\ni");
  8696. defineSymbol(math, main, rel, "\u221D", "\\propto");
  8697. defineSymbol(math, main, rel, "\u22A2", "\\vdash");
  8698. defineSymbol(math, main, rel, "\u22A3", "\\dashv");
  8699. defineSymbol(math, main, rel, "\u220B", "\\owns");
  8700. // Punctuation
  8701. defineSymbol(math, main, punct, ".", "\\ldotp");
  8702. defineSymbol(math, main, punct, "\u22C5", "\\cdotp");
  8703. // Misc Symbols
  8704. defineSymbol(math, main, textord, "#", "\\#");
  8705. defineSymbol(text, main, textord, "#", "\\#");
  8706. defineSymbol(math, main, textord, "&", "\\&");
  8707. defineSymbol(text, main, textord, "&", "\\&");
  8708. defineSymbol(math, main, textord, "\u2135", "\\aleph");
  8709. defineSymbol(math, main, textord, "\u2200", "\\forall");
  8710. defineSymbol(math, main, textord, "\u210F", "\\hbar");
  8711. defineSymbol(math, main, textord, "\u2203", "\\exists");
  8712. defineSymbol(math, main, textord, "\u2207", "\\nabla");
  8713. defineSymbol(math, main, textord, "\u266D", "\\flat");
  8714. defineSymbol(math, main, textord, "\u2113", "\\ell");
  8715. defineSymbol(math, main, textord, "\u266E", "\\natural");
  8716. defineSymbol(math, main, textord, "\u2663", "\\clubsuit");
  8717. defineSymbol(math, main, textord, "\u2118", "\\wp");
  8718. defineSymbol(math, main, textord, "\u266F", "\\sharp");
  8719. defineSymbol(math, main, textord, "\u2662", "\\diamondsuit");
  8720. defineSymbol(math, main, textord, "\u211C", "\\Re");
  8721. defineSymbol(math, main, textord, "\u2661", "\\heartsuit");
  8722. defineSymbol(math, main, textord, "\u2111", "\\Im");
  8723. defineSymbol(math, main, textord, "\u2660", "\\spadesuit");
  8724. // Math and Text
  8725. defineSymbol(math, main, textord, "\u2020", "\\dag");
  8726. defineSymbol(text, main, textord, "\u2020", "\\dag");
  8727. defineSymbol(text, main, textord, "\u2020", "\\textdagger");
  8728. defineSymbol(math, main, textord, "\u2021", "\\ddag");
  8729. defineSymbol(text, main, textord, "\u2021", "\\ddag");
  8730. defineSymbol(text, main, textord, "\u2020", "\\textdaggerdbl");
  8731. // Large Delimiters
  8732. defineSymbol(math, main, close, "\u23B1", "\\rmoustache");
  8733. defineSymbol(math, main, open, "\u23B0", "\\lmoustache");
  8734. defineSymbol(math, main, close, "\u27EF", "\\rgroup");
  8735. defineSymbol(math, main, open, "\u27EE", "\\lgroup");
  8736. // Binary Operators
  8737. defineSymbol(math, main, bin, "\u2213", "\\mp");
  8738. defineSymbol(math, main, bin, "\u2296", "\\ominus");
  8739. defineSymbol(math, main, bin, "\u228E", "\\uplus");
  8740. defineSymbol(math, main, bin, "\u2293", "\\sqcap");
  8741. defineSymbol(math, main, bin, "\u2217", "\\ast");
  8742. defineSymbol(math, main, bin, "\u2294", "\\sqcup");
  8743. defineSymbol(math, main, bin, "\u25EF", "\\bigcirc");
  8744. defineSymbol(math, main, bin, "\u2219", "\\bullet");
  8745. defineSymbol(math, main, bin, "\u2021", "\\ddagger");
  8746. defineSymbol(math, main, bin, "\u2240", "\\wr");
  8747. defineSymbol(math, main, bin, "\u2A3F", "\\amalg");
  8748. // Arrow Symbols
  8749. defineSymbol(math, main, rel, "\u27F5", "\\longleftarrow");
  8750. defineSymbol(math, main, rel, "\u21D0", "\\Leftarrow");
  8751. defineSymbol(math, main, rel, "\u27F8", "\\Longleftarrow");
  8752. defineSymbol(math, main, rel, "\u27F6", "\\longrightarrow");
  8753. defineSymbol(math, main, rel, "\u21D2", "\\Rightarrow");
  8754. defineSymbol(math, main, rel, "\u27F9", "\\Longrightarrow");
  8755. defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow");
  8756. defineSymbol(math, main, rel, "\u27F7", "\\longleftrightarrow");
  8757. defineSymbol(math, main, rel, "\u21D4", "\\Leftrightarrow");
  8758. defineSymbol(math, main, rel, "\u27FA", "\\Longleftrightarrow");
  8759. defineSymbol(math, main, rel, "\u21A6", "\\mapsto");
  8760. defineSymbol(math, main, rel, "\u27FC", "\\longmapsto");
  8761. defineSymbol(math, main, rel, "\u2197", "\\nearrow");
  8762. defineSymbol(math, main, rel, "\u21A9", "\\hookleftarrow");
  8763. defineSymbol(math, main, rel, "\u21AA", "\\hookrightarrow");
  8764. defineSymbol(math, main, rel, "\u2198", "\\searrow");
  8765. defineSymbol(math, main, rel, "\u21BC", "\\leftharpoonup");
  8766. defineSymbol(math, main, rel, "\u21C0", "\\rightharpoonup");
  8767. defineSymbol(math, main, rel, "\u2199", "\\swarrow");
  8768. defineSymbol(math, main, rel, "\u21BD", "\\leftharpoondown");
  8769. defineSymbol(math, main, rel, "\u21C1", "\\rightharpoondown");
  8770. defineSymbol(math, main, rel, "\u2196", "\\nwarrow");
  8771. defineSymbol(math, main, rel, "\u21CC", "\\rightleftharpoons");
  8772. // AMS Negated Binary Relations
  8773. defineSymbol(math, ams, rel, "\u226E", "\\nless");
  8774. defineSymbol(math, ams, rel, "\uE010", "\\nleqslant");
  8775. defineSymbol(math, ams, rel, "\uE011", "\\nleqq");
  8776. defineSymbol(math, ams, rel, "\u2A87", "\\lneq");
  8777. defineSymbol(math, ams, rel, "\u2268", "\\lneqq");
  8778. defineSymbol(math, ams, rel, "\uE00C", "\\lvertneqq");
  8779. defineSymbol(math, ams, rel, "\u22E6", "\\lnsim");
  8780. defineSymbol(math, ams, rel, "\u2A89", "\\lnapprox");
  8781. defineSymbol(math, ams, rel, "\u2280", "\\nprec");
  8782. defineSymbol(math, ams, rel, "\u22E0", "\\npreceq");
  8783. defineSymbol(math, ams, rel, "\u22E8", "\\precnsim");
  8784. defineSymbol(math, ams, rel, "\u2AB9", "\\precnapprox");
  8785. defineSymbol(math, ams, rel, "\u2241", "\\nsim");
  8786. defineSymbol(math, ams, rel, "\uE006", "\\nshortmid");
  8787. defineSymbol(math, ams, rel, "\u2224", "\\nmid");
  8788. defineSymbol(math, ams, rel, "\u22AC", "\\nvdash");
  8789. defineSymbol(math, ams, rel, "\u22AD", "\\nvDash");
  8790. defineSymbol(math, ams, rel, "\u22EA", "\\ntriangleleft");
  8791. defineSymbol(math, ams, rel, "\u22EC", "\\ntrianglelefteq");
  8792. defineSymbol(math, ams, rel, "\u228A", "\\subsetneq");
  8793. defineSymbol(math, ams, rel, "\uE01A", "\\varsubsetneq");
  8794. defineSymbol(math, ams, rel, "\u2ACB", "\\subsetneqq");
  8795. defineSymbol(math, ams, rel, "\uE017", "\\varsubsetneqq");
  8796. defineSymbol(math, ams, rel, "\u226F", "\\ngtr");
  8797. defineSymbol(math, ams, rel, "\uE00F", "\\ngeqslant");
  8798. defineSymbol(math, ams, rel, "\uE00E", "\\ngeqq");
  8799. defineSymbol(math, ams, rel, "\u2A88", "\\gneq");
  8800. defineSymbol(math, ams, rel, "\u2269", "\\gneqq");
  8801. defineSymbol(math, ams, rel, "\uE00D", "\\gvertneqq");
  8802. defineSymbol(math, ams, rel, "\u22E7", "\\gnsim");
  8803. defineSymbol(math, ams, rel, "\u2A8A", "\\gnapprox");
  8804. defineSymbol(math, ams, rel, "\u2281", "\\nsucc");
  8805. defineSymbol(math, ams, rel, "\u22E1", "\\nsucceq");
  8806. defineSymbol(math, ams, rel, "\u22E9", "\\succnsim");
  8807. defineSymbol(math, ams, rel, "\u2ABA", "\\succnapprox");
  8808. defineSymbol(math, ams, rel, "\u2246", "\\ncong");
  8809. defineSymbol(math, ams, rel, "\uE007", "\\nshortparallel");
  8810. defineSymbol(math, ams, rel, "\u2226", "\\nparallel");
  8811. defineSymbol(math, ams, rel, "\u22AF", "\\nVDash");
  8812. defineSymbol(math, ams, rel, "\u22EB", "\\ntriangleright");
  8813. defineSymbol(math, ams, rel, "\u22ED", "\\ntrianglerighteq");
  8814. defineSymbol(math, ams, rel, "\uE018", "\\nsupseteqq");
  8815. defineSymbol(math, ams, rel, "\u228B", "\\supsetneq");
  8816. defineSymbol(math, ams, rel, "\uE01B", "\\varsupsetneq");
  8817. defineSymbol(math, ams, rel, "\u2ACC", "\\supsetneqq");
  8818. defineSymbol(math, ams, rel, "\uE019", "\\varsupsetneqq");
  8819. defineSymbol(math, ams, rel, "\u22AE", "\\nVdash");
  8820. defineSymbol(math, ams, rel, "\u2AB5", "\\precneqq");
  8821. defineSymbol(math, ams, rel, "\u2AB6", "\\succneqq");
  8822. defineSymbol(math, ams, rel, "\uE016", "\\nsubseteqq");
  8823. defineSymbol(math, ams, bin, "\u22B4", "\\unlhd");
  8824. defineSymbol(math, ams, bin, "\u22B5", "\\unrhd");
  8825. // AMS Negated Arrows
  8826. defineSymbol(math, ams, rel, "\u219A", "\\nleftarrow");
  8827. defineSymbol(math, ams, rel, "\u219B", "\\nrightarrow");
  8828. defineSymbol(math, ams, rel, "\u21CD", "\\nLeftarrow");
  8829. defineSymbol(math, ams, rel, "\u21CF", "\\nRightarrow");
  8830. defineSymbol(math, ams, rel, "\u21AE", "\\nleftrightarrow");
  8831. defineSymbol(math, ams, rel, "\u21CE", "\\nLeftrightarrow");
  8832. // AMS Misc
  8833. defineSymbol(math, ams, rel, "\u25B3", "\\vartriangle");
  8834. defineSymbol(math, ams, textord, "\u210F", "\\hslash");
  8835. defineSymbol(math, ams, textord, "\u25BD", "\\triangledown");
  8836. defineSymbol(math, ams, textord, "\u25CA", "\\lozenge");
  8837. defineSymbol(math, ams, textord, "\u24C8", "\\circledS");
  8838. defineSymbol(math, ams, textord, "\xAE", "\\circledR");
  8839. defineSymbol(text, ams, textord, "\xAE", "\\circledR");
  8840. defineSymbol(math, ams, textord, "\u2221", "\\measuredangle");
  8841. defineSymbol(math, ams, textord, "\u2204", "\\nexists");
  8842. defineSymbol(math, ams, textord, "\u2127", "\\mho");
  8843. defineSymbol(math, ams, textord, "\u2132", "\\Finv");
  8844. defineSymbol(math, ams, textord, "\u2141", "\\Game");
  8845. defineSymbol(math, ams, textord, "k", "\\Bbbk");
  8846. defineSymbol(math, ams, textord, "\u2035", "\\backprime");
  8847. defineSymbol(math, ams, textord, "\u25B2", "\\blacktriangle");
  8848. defineSymbol(math, ams, textord, "\u25BC", "\\blacktriangledown");
  8849. defineSymbol(math, ams, textord, "\u25A0", "\\blacksquare");
  8850. defineSymbol(math, ams, textord, "\u29EB", "\\blacklozenge");
  8851. defineSymbol(math, ams, textord, "\u2605", "\\bigstar");
  8852. defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle");
  8853. defineSymbol(math, ams, textord, "\u2201", "\\complement");
  8854. defineSymbol(math, ams, textord, "\xF0", "\\eth");
  8855. defineSymbol(math, ams, textord, "\u2571", "\\diagup");
  8856. defineSymbol(math, ams, textord, "\u2572", "\\diagdown");
  8857. defineSymbol(math, ams, textord, "\u25A1", "\\square");
  8858. defineSymbol(math, ams, textord, "\u25A1", "\\Box");
  8859. defineSymbol(math, ams, textord, "\u25CA", "\\Diamond");
  8860. defineSymbol(math, ams, textord, "\xA5", "\\yen");
  8861. defineSymbol(math, ams, textord, "\u2713", "\\checkmark");
  8862. defineSymbol(text, ams, textord, "\u2713", "\\checkmark");
  8863. // AMS Hebrew
  8864. defineSymbol(math, ams, textord, "\u2136", "\\beth");
  8865. defineSymbol(math, ams, textord, "\u2138", "\\daleth");
  8866. defineSymbol(math, ams, textord, "\u2137", "\\gimel");
  8867. // AMS Greek
  8868. defineSymbol(math, ams, textord, "\u03DD", "\\digamma");
  8869. defineSymbol(math, ams, textord, "\u03F0", "\\varkappa");
  8870. // AMS Delimiters
  8871. defineSymbol(math, ams, open, "\u250C", "\\ulcorner");
  8872. defineSymbol(math, ams, close, "\u2510", "\\urcorner");
  8873. defineSymbol(math, ams, open, "\u2514", "\\llcorner");
  8874. defineSymbol(math, ams, close, "\u2518", "\\lrcorner");
  8875. // AMS Binary Relations
  8876. defineSymbol(math, ams, rel, "\u2266", "\\leqq");
  8877. defineSymbol(math, ams, rel, "\u2A7D", "\\leqslant");
  8878. defineSymbol(math, ams, rel, "\u2A95", "\\eqslantless");
  8879. defineSymbol(math, ams, rel, "\u2272", "\\lesssim");
  8880. defineSymbol(math, ams, rel, "\u2A85", "\\lessapprox");
  8881. defineSymbol(math, ams, rel, "\u224A", "\\approxeq");
  8882. defineSymbol(math, ams, bin, "\u22D6", "\\lessdot");
  8883. defineSymbol(math, ams, rel, "\u22D8", "\\lll");
  8884. defineSymbol(math, ams, rel, "\u2276", "\\lessgtr");
  8885. defineSymbol(math, ams, rel, "\u22DA", "\\lesseqgtr");
  8886. defineSymbol(math, ams, rel, "\u2A8B", "\\lesseqqgtr");
  8887. defineSymbol(math, ams, rel, "\u2251", "\\doteqdot");
  8888. defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq");
  8889. defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq");
  8890. defineSymbol(math, ams, rel, "\u223D", "\\backsim");
  8891. defineSymbol(math, ams, rel, "\u22CD", "\\backsimeq");
  8892. defineSymbol(math, ams, rel, "\u2AC5", "\\subseteqq");
  8893. defineSymbol(math, ams, rel, "\u22D0", "\\Subset");
  8894. defineSymbol(math, ams, rel, "\u228F", "\\sqsubset");
  8895. defineSymbol(math, ams, rel, "\u227C", "\\preccurlyeq");
  8896. defineSymbol(math, ams, rel, "\u22DE", "\\curlyeqprec");
  8897. defineSymbol(math, ams, rel, "\u227E", "\\precsim");
  8898. defineSymbol(math, ams, rel, "\u2AB7", "\\precapprox");
  8899. defineSymbol(math, ams, rel, "\u22B2", "\\vartriangleleft");
  8900. defineSymbol(math, ams, rel, "\u22B4", "\\trianglelefteq");
  8901. defineSymbol(math, ams, rel, "\u22A8", "\\vDash");
  8902. defineSymbol(math, ams, rel, "\u22AA", "\\Vvdash");
  8903. defineSymbol(math, ams, rel, "\u2323", "\\smallsmile");
  8904. defineSymbol(math, ams, rel, "\u2322", "\\smallfrown");
  8905. defineSymbol(math, ams, rel, "\u224F", "\\bumpeq");
  8906. defineSymbol(math, ams, rel, "\u224E", "\\Bumpeq");
  8907. defineSymbol(math, ams, rel, "\u2267", "\\geqq");
  8908. defineSymbol(math, ams, rel, "\u2A7E", "\\geqslant");
  8909. defineSymbol(math, ams, rel, "\u2A96", "\\eqslantgtr");
  8910. defineSymbol(math, ams, rel, "\u2273", "\\gtrsim");
  8911. defineSymbol(math, ams, rel, "\u2A86", "\\gtrapprox");
  8912. defineSymbol(math, ams, bin, "\u22D7", "\\gtrdot");
  8913. defineSymbol(math, ams, rel, "\u22D9", "\\ggg");
  8914. defineSymbol(math, ams, rel, "\u2277", "\\gtrless");
  8915. defineSymbol(math, ams, rel, "\u22DB", "\\gtreqless");
  8916. defineSymbol(math, ams, rel, "\u2A8C", "\\gtreqqless");
  8917. defineSymbol(math, ams, rel, "\u2256", "\\eqcirc");
  8918. defineSymbol(math, ams, rel, "\u2257", "\\circeq");
  8919. defineSymbol(math, ams, rel, "\u225C", "\\triangleq");
  8920. defineSymbol(math, ams, rel, "\u223C", "\\thicksim");
  8921. defineSymbol(math, ams, rel, "\u2248", "\\thickapprox");
  8922. defineSymbol(math, ams, rel, "\u2AC6", "\\supseteqq");
  8923. defineSymbol(math, ams, rel, "\u22D1", "\\Supset");
  8924. defineSymbol(math, ams, rel, "\u2290", "\\sqsupset");
  8925. defineSymbol(math, ams, rel, "\u227D", "\\succcurlyeq");
  8926. defineSymbol(math, ams, rel, "\u22DF", "\\curlyeqsucc");
  8927. defineSymbol(math, ams, rel, "\u227F", "\\succsim");
  8928. defineSymbol(math, ams, rel, "\u2AB8", "\\succapprox");
  8929. defineSymbol(math, ams, rel, "\u22B3", "\\vartriangleright");
  8930. defineSymbol(math, ams, rel, "\u22B5", "\\trianglerighteq");
  8931. defineSymbol(math, ams, rel, "\u22A9", "\\Vdash");
  8932. defineSymbol(math, ams, rel, "\u2223", "\\shortmid");
  8933. defineSymbol(math, ams, rel, "\u2225", "\\shortparallel");
  8934. defineSymbol(math, ams, rel, "\u226C", "\\between");
  8935. defineSymbol(math, ams, rel, "\u22D4", "\\pitchfork");
  8936. defineSymbol(math, ams, rel, "\u221D", "\\varpropto");
  8937. defineSymbol(math, ams, rel, "\u25C0", "\\blacktriangleleft");
  8938. defineSymbol(math, ams, rel, "\u2234", "\\therefore");
  8939. defineSymbol(math, ams, rel, "\u220D", "\\backepsilon");
  8940. defineSymbol(math, ams, rel, "\u25B6", "\\blacktriangleright");
  8941. defineSymbol(math, ams, rel, "\u2235", "\\because");
  8942. defineSymbol(math, ams, rel, "\u22D8", "\\llless");
  8943. defineSymbol(math, ams, rel, "\u22D9", "\\gggtr");
  8944. defineSymbol(math, ams, bin, "\u22B2", "\\lhd");
  8945. defineSymbol(math, ams, bin, "\u22B3", "\\rhd");
  8946. defineSymbol(math, ams, rel, "\u2242", "\\eqsim");
  8947. defineSymbol(math, main, rel, "\u22C8", "\\Join");
  8948. defineSymbol(math, ams, rel, "\u2251", "\\Doteq");
  8949. // AMS Binary Operators
  8950. defineSymbol(math, ams, bin, "\u2214", "\\dotplus");
  8951. defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus");
  8952. defineSymbol(math, ams, bin, "\u22D2", "\\Cap");
  8953. defineSymbol(math, ams, bin, "\u22D3", "\\Cup");
  8954. defineSymbol(math, ams, bin, "\u2A5E", "\\doublebarwedge");
  8955. defineSymbol(math, ams, bin, "\u229F", "\\boxminus");
  8956. defineSymbol(math, ams, bin, "\u229E", "\\boxplus");
  8957. defineSymbol(math, ams, bin, "\u22C7", "\\divideontimes");
  8958. defineSymbol(math, ams, bin, "\u22C9", "\\ltimes");
  8959. defineSymbol(math, ams, bin, "\u22CA", "\\rtimes");
  8960. defineSymbol(math, ams, bin, "\u22CB", "\\leftthreetimes");
  8961. defineSymbol(math, ams, bin, "\u22CC", "\\rightthreetimes");
  8962. defineSymbol(math, ams, bin, "\u22CF", "\\curlywedge");
  8963. defineSymbol(math, ams, bin, "\u22CE", "\\curlyvee");
  8964. defineSymbol(math, ams, bin, "\u229D", "\\circleddash");
  8965. defineSymbol(math, ams, bin, "\u229B", "\\circledast");
  8966. defineSymbol(math, ams, bin, "\u22C5", "\\centerdot");
  8967. defineSymbol(math, ams, bin, "\u22BA", "\\intercal");
  8968. defineSymbol(math, ams, bin, "\u22D2", "\\doublecap");
  8969. defineSymbol(math, ams, bin, "\u22D3", "\\doublecup");
  8970. defineSymbol(math, ams, bin, "\u22A0", "\\boxtimes");
  8971. // AMS Arrows
  8972. defineSymbol(math, ams, rel, "\u21E2", "\\dashrightarrow");
  8973. defineSymbol(math, ams, rel, "\u21E0", "\\dashleftarrow");
  8974. defineSymbol(math, ams, rel, "\u21C7", "\\leftleftarrows");
  8975. defineSymbol(math, ams, rel, "\u21C6", "\\leftrightarrows");
  8976. defineSymbol(math, ams, rel, "\u21DA", "\\Lleftarrow");
  8977. defineSymbol(math, ams, rel, "\u219E", "\\twoheadleftarrow");
  8978. defineSymbol(math, ams, rel, "\u21A2", "\\leftarrowtail");
  8979. defineSymbol(math, ams, rel, "\u21AB", "\\looparrowleft");
  8980. defineSymbol(math, ams, rel, "\u21CB", "\\leftrightharpoons");
  8981. defineSymbol(math, ams, rel, "\u21B6", "\\curvearrowleft");
  8982. defineSymbol(math, ams, rel, "\u21BA", "\\circlearrowleft");
  8983. defineSymbol(math, ams, rel, "\u21B0", "\\Lsh");
  8984. defineSymbol(math, ams, rel, "\u21C8", "\\upuparrows");
  8985. defineSymbol(math, ams, rel, "\u21BF", "\\upharpoonleft");
  8986. defineSymbol(math, ams, rel, "\u21C3", "\\downharpoonleft");
  8987. defineSymbol(math, ams, rel, "\u22B8", "\\multimap");
  8988. defineSymbol(math, ams, rel, "\u21AD", "\\leftrightsquigarrow");
  8989. defineSymbol(math, ams, rel, "\u21C9", "\\rightrightarrows");
  8990. defineSymbol(math, ams, rel, "\u21C4", "\\rightleftarrows");
  8991. defineSymbol(math, ams, rel, "\u21A0", "\\twoheadrightarrow");
  8992. defineSymbol(math, ams, rel, "\u21A3", "\\rightarrowtail");
  8993. defineSymbol(math, ams, rel, "\u21AC", "\\looparrowright");
  8994. defineSymbol(math, ams, rel, "\u21B7", "\\curvearrowright");
  8995. defineSymbol(math, ams, rel, "\u21BB", "\\circlearrowright");
  8996. defineSymbol(math, ams, rel, "\u21B1", "\\Rsh");
  8997. defineSymbol(math, ams, rel, "\u21CA", "\\downdownarrows");
  8998. defineSymbol(math, ams, rel, "\u21BE", "\\upharpoonright");
  8999. defineSymbol(math, ams, rel, "\u21C2", "\\downharpoonright");
  9000. defineSymbol(math, ams, rel, "\u21DD", "\\rightsquigarrow");
  9001. defineSymbol(math, ams, rel, "\u21DD", "\\leadsto");
  9002. defineSymbol(math, ams, rel, "\u21DB", "\\Rrightarrow");
  9003. defineSymbol(math, ams, rel, "\u21BE", "\\restriction");
  9004. defineSymbol(math, main, textord, "\u2018", "`");
  9005. defineSymbol(math, main, textord, "$", "\\$");
  9006. defineSymbol(text, main, textord, "$", "\\$");
  9007. defineSymbol(text, main, textord, "$", "\\textdollar");
  9008. defineSymbol(math, main, textord, "%", "\\%");
  9009. defineSymbol(text, main, textord, "%", "\\%");
  9010. defineSymbol(math, main, textord, "_", "\\_");
  9011. defineSymbol(text, main, textord, "_", "\\_");
  9012. defineSymbol(text, main, textord, "_", "\\textunderscore");
  9013. defineSymbol(math, main, textord, "\u2220", "\\angle");
  9014. defineSymbol(math, main, textord, "\u221E", "\\infty");
  9015. defineSymbol(math, main, textord, "\u2032", "\\prime");
  9016. defineSymbol(math, main, textord, "\u25B3", "\\triangle");
  9017. defineSymbol(math, main, textord, "\u0393", "\\Gamma", true);
  9018. defineSymbol(math, main, textord, "\u0394", "\\Delta", true);
  9019. defineSymbol(math, main, textord, "\u0398", "\\Theta", true);
  9020. defineSymbol(math, main, textord, "\u039B", "\\Lambda", true);
  9021. defineSymbol(math, main, textord, "\u039E", "\\Xi", true);
  9022. defineSymbol(math, main, textord, "\u03A0", "\\Pi", true);
  9023. defineSymbol(math, main, textord, "\u03A3", "\\Sigma", true);
  9024. defineSymbol(math, main, textord, "\u03A5", "\\Upsilon", true);
  9025. defineSymbol(math, main, textord, "\u03A6", "\\Phi", true);
  9026. defineSymbol(math, main, textord, "\u03A8", "\\Psi", true);
  9027. defineSymbol(math, main, textord, "\u03A9", "\\Omega", true);
  9028. defineSymbol(math, main, textord, "\xAC", "\\neg");
  9029. defineSymbol(math, main, textord, "\xAC", "\\lnot");
  9030. defineSymbol(math, main, textord, "\u22A4", "\\top");
  9031. defineSymbol(math, main, textord, "\u22A5", "\\bot");
  9032. defineSymbol(math, main, textord, "\u2205", "\\emptyset");
  9033. defineSymbol(math, ams, textord, "\u2205", "\\varnothing");
  9034. defineSymbol(math, main, mathord, "\u03B1", "\\alpha", true);
  9035. defineSymbol(math, main, mathord, "\u03B2", "\\beta", true);
  9036. defineSymbol(math, main, mathord, "\u03B3", "\\gamma", true);
  9037. defineSymbol(math, main, mathord, "\u03B4", "\\delta", true);
  9038. defineSymbol(math, main, mathord, "\u03F5", "\\epsilon", true);
  9039. defineSymbol(math, main, mathord, "\u03B6", "\\zeta", true);
  9040. defineSymbol(math, main, mathord, "\u03B7", "\\eta", true);
  9041. defineSymbol(math, main, mathord, "\u03B8", "\\theta", true);
  9042. defineSymbol(math, main, mathord, "\u03B9", "\\iota", true);
  9043. defineSymbol(math, main, mathord, "\u03BA", "\\kappa", true);
  9044. defineSymbol(math, main, mathord, "\u03BB", "\\lambda", true);
  9045. defineSymbol(math, main, mathord, "\u03BC", "\\mu", true);
  9046. defineSymbol(math, main, mathord, "\u03BD", "\\nu", true);
  9047. defineSymbol(math, main, mathord, "\u03BE", "\\xi", true);
  9048. defineSymbol(math, main, mathord, "\u03BF", "\\omicron", true);
  9049. defineSymbol(math, main, mathord, "\u03C0", "\\pi", true);
  9050. defineSymbol(math, main, mathord, "\u03C1", "\\rho", true);
  9051. defineSymbol(math, main, mathord, "\u03C3", "\\sigma", true);
  9052. defineSymbol(math, main, mathord, "\u03C4", "\\tau", true);
  9053. defineSymbol(math, main, mathord, "\u03C5", "\\upsilon", true);
  9054. defineSymbol(math, main, mathord, "\u03D5", "\\phi", true);
  9055. defineSymbol(math, main, mathord, "\u03C7", "\\chi", true);
  9056. defineSymbol(math, main, mathord, "\u03C8", "\\psi", true);
  9057. defineSymbol(math, main, mathord, "\u03C9", "\\omega", true);
  9058. defineSymbol(math, main, mathord, "\u03B5", "\\varepsilon", true);
  9059. defineSymbol(math, main, mathord, "\u03D1", "\\vartheta", true);
  9060. defineSymbol(math, main, mathord, "\u03D6", "\\varpi", true);
  9061. defineSymbol(math, main, mathord, "\u03F1", "\\varrho", true);
  9062. defineSymbol(math, main, mathord, "\u03C2", "\\varsigma", true);
  9063. defineSymbol(math, main, mathord, "\u03C6", "\\varphi", true);
  9064. defineSymbol(math, main, bin, "\u2217", "*");
  9065. defineSymbol(math, main, bin, "+", "+");
  9066. defineSymbol(math, main, bin, "\u2212", "-");
  9067. defineSymbol(math, main, bin, "\u22C5", "\\cdot");
  9068. defineSymbol(math, main, bin, "\u2218", "\\circ");
  9069. defineSymbol(math, main, bin, "\xF7", "\\div");
  9070. defineSymbol(math, main, bin, "\xB1", "\\pm");
  9071. defineSymbol(math, main, bin, "\xD7", "\\times");
  9072. defineSymbol(math, main, bin, "\u2229", "\\cap");
  9073. defineSymbol(math, main, bin, "\u222A", "\\cup");
  9074. defineSymbol(math, main, bin, "\u2216", "\\setminus");
  9075. defineSymbol(math, main, bin, "\u2227", "\\land");
  9076. defineSymbol(math, main, bin, "\u2228", "\\lor");
  9077. defineSymbol(math, main, bin, "\u2227", "\\wedge");
  9078. defineSymbol(math, main, bin, "\u2228", "\\vee");
  9079. defineSymbol(math, main, textord, "\u221A", "\\surd");
  9080. defineSymbol(math, main, open, "(", "(");
  9081. defineSymbol(math, main, open, "[", "[");
  9082. defineSymbol(math, main, open, "\u27E8", "\\langle");
  9083. defineSymbol(math, main, open, "\u2223", "\\lvert");
  9084. defineSymbol(math, main, open, "\u2225", "\\lVert");
  9085. defineSymbol(math, main, close, ")", ")");
  9086. defineSymbol(math, main, close, "]", "]");
  9087. defineSymbol(math, main, close, "?", "?");
  9088. defineSymbol(math, main, close, "!", "!");
  9089. defineSymbol(math, main, close, "\u27E9", "\\rangle");
  9090. defineSymbol(math, main, close, "\u2223", "\\rvert");
  9091. defineSymbol(math, main, close, "\u2225", "\\rVert");
  9092. defineSymbol(math, main, rel, "=", "=");
  9093. defineSymbol(math, main, rel, "<", "<");
  9094. defineSymbol(math, main, rel, ">", ">");
  9095. defineSymbol(math, main, rel, ":", ":");
  9096. defineSymbol(math, main, rel, "\u2248", "\\approx");
  9097. defineSymbol(math, main, rel, "\u2245", "\\cong");
  9098. defineSymbol(math, main, rel, "\u2265", "\\ge");
  9099. defineSymbol(math, main, rel, "\u2265", "\\geq");
  9100. defineSymbol(math, main, rel, "\u2190", "\\gets");
  9101. defineSymbol(math, main, rel, ">", "\\gt");
  9102. defineSymbol(math, main, rel, "\u2208", "\\in");
  9103. defineSymbol(math, main, rel, "\u2209", "\\notin");
  9104. defineSymbol(math, main, rel, "\u0338", "\\not");
  9105. defineSymbol(math, main, rel, "\u2282", "\\subset");
  9106. defineSymbol(math, main, rel, "\u2283", "\\supset");
  9107. defineSymbol(math, main, rel, "\u2286", "\\subseteq");
  9108. defineSymbol(math, main, rel, "\u2287", "\\supseteq");
  9109. defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq");
  9110. defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq");
  9111. defineSymbol(math, main, rel, "\u22A8", "\\models");
  9112. defineSymbol(math, main, rel, "\u2190", "\\leftarrow");
  9113. defineSymbol(math, main, rel, "\u2264", "\\le");
  9114. defineSymbol(math, main, rel, "\u2264", "\\leq");
  9115. defineSymbol(math, main, rel, "<", "\\lt");
  9116. defineSymbol(math, main, rel, "\u2260", "\\ne");
  9117. defineSymbol(math, main, rel, "\u2260", "\\neq");
  9118. defineSymbol(math, main, rel, "\u2192", "\\rightarrow");
  9119. defineSymbol(math, main, rel, "\u2192", "\\to");
  9120. defineSymbol(math, ams, rel, "\u2271", "\\ngeq");
  9121. defineSymbol(math, ams, rel, "\u2270", "\\nleq");
  9122. defineSymbol(math, main, spacing, null, "\\!");
  9123. defineSymbol(math, main, spacing, "\xA0", "\\ ");
  9124. defineSymbol(math, main, spacing, "\xA0", "~");
  9125. defineSymbol(math, main, spacing, null, "\\,");
  9126. defineSymbol(math, main, spacing, null, "\\:");
  9127. defineSymbol(math, main, spacing, null, "\\;");
  9128. defineSymbol(math, main, spacing, null, "\\enspace");
  9129. defineSymbol(math, main, spacing, null, "\\qquad");
  9130. defineSymbol(math, main, spacing, null, "\\quad");
  9131. defineSymbol(math, main, spacing, "\xA0", "\\space");
  9132. defineSymbol(math, main, punct, ",", ",");
  9133. defineSymbol(math, main, punct, ";", ";");
  9134. defineSymbol(math, main, punct, ":", "\\colon");
  9135. defineSymbol(math, ams, bin, "\u22BC", "\\barwedge");
  9136. defineSymbol(math, ams, bin, "\u22BB", "\\veebar");
  9137. defineSymbol(math, main, bin, "\u2299", "\\odot");
  9138. defineSymbol(math, main, bin, "\u2295", "\\oplus");
  9139. defineSymbol(math, main, bin, "\u2297", "\\otimes");
  9140. defineSymbol(math, main, textord, "\u2202", "\\partial");
  9141. defineSymbol(math, main, bin, "\u2298", "\\oslash");
  9142. defineSymbol(math, ams, bin, "\u229A", "\\circledcirc");
  9143. defineSymbol(math, ams, bin, "\u22A1", "\\boxdot");
  9144. defineSymbol(math, main, bin, "\u25B3", "\\bigtriangleup");
  9145. defineSymbol(math, main, bin, "\u25BD", "\\bigtriangledown");
  9146. defineSymbol(math, main, bin, "\u2020", "\\dagger");
  9147. defineSymbol(math, main, bin, "\u22C4", "\\diamond");
  9148. defineSymbol(math, main, bin, "\u22C6", "\\star");
  9149. defineSymbol(math, main, bin, "\u25C3", "\\triangleleft");
  9150. defineSymbol(math, main, bin, "\u25B9", "\\triangleright");
  9151. defineSymbol(math, main, open, "{", "\\{");
  9152. defineSymbol(text, main, textord, "{", "\\{");
  9153. defineSymbol(text, main, textord, "{", "\\textbraceleft");
  9154. defineSymbol(math, main, close, "}", "\\}");
  9155. defineSymbol(text, main, textord, "}", "\\}");
  9156. defineSymbol(text, main, textord, "}", "\\textbraceright");
  9157. defineSymbol(math, main, open, "{", "\\lbrace");
  9158. defineSymbol(math, main, close, "}", "\\rbrace");
  9159. defineSymbol(math, main, open, "[", "\\lbrack");
  9160. defineSymbol(math, main, close, "]", "\\rbrack");
  9161. defineSymbol(text, main, textord, "<", "\\textless"); // in T1 fontenc
  9162. defineSymbol(text, main, textord, ">", "\\textgreater"); // in T1 fontenc
  9163. defineSymbol(math, main, open, "\u230A", "\\lfloor");
  9164. defineSymbol(math, main, close, "\u230B", "\\rfloor");
  9165. defineSymbol(math, main, open, "\u2308", "\\lceil");
  9166. defineSymbol(math, main, close, "\u2309", "\\rceil");
  9167. defineSymbol(math, main, textord, "\\", "\\backslash");
  9168. defineSymbol(math, main, textord, "\u2223", "|");
  9169. defineSymbol(math, main, textord, "\u2223", "\\vert");
  9170. defineSymbol(text, main, textord, "|", "\\textbar"); // in T1 fontenc
  9171. defineSymbol(math, main, textord, "\u2225", "\\|");
  9172. defineSymbol(math, main, textord, "\u2225", "\\Vert");
  9173. defineSymbol(text, main, textord, "\u2225", "\\textbardbl");
  9174. defineSymbol(math, main, rel, "\u2191", "\\uparrow");
  9175. defineSymbol(math, main, rel, "\u21D1", "\\Uparrow");
  9176. defineSymbol(math, main, rel, "\u2193", "\\downarrow");
  9177. defineSymbol(math, main, rel, "\u21D3", "\\Downarrow");
  9178. defineSymbol(math, main, rel, "\u2195", "\\updownarrow");
  9179. defineSymbol(math, main, rel, "\u21D5", "\\Updownarrow");
  9180. defineSymbol(math, main, op, "\u2210", "\\coprod");
  9181. defineSymbol(math, main, op, "\u22C1", "\\bigvee");
  9182. defineSymbol(math, main, op, "\u22C0", "\\bigwedge");
  9183. defineSymbol(math, main, op, "\u2A04", "\\biguplus");
  9184. defineSymbol(math, main, op, "\u22C2", "\\bigcap");
  9185. defineSymbol(math, main, op, "\u22C3", "\\bigcup");
  9186. defineSymbol(math, main, op, "\u222B", "\\int");
  9187. defineSymbol(math, main, op, "\u222B", "\\intop");
  9188. defineSymbol(math, main, op, "\u222C", "\\iint");
  9189. defineSymbol(math, main, op, "\u222D", "\\iiint");
  9190. defineSymbol(math, main, op, "\u220F", "\\prod");
  9191. defineSymbol(math, main, op, "\u2211", "\\sum");
  9192. defineSymbol(math, main, op, "\u2A02", "\\bigotimes");
  9193. defineSymbol(math, main, op, "\u2A01", "\\bigoplus");
  9194. defineSymbol(math, main, op, "\u2A00", "\\bigodot");
  9195. defineSymbol(math, main, op, "\u222E", "\\oint");
  9196. defineSymbol(math, main, op, "\u2A06", "\\bigsqcup");
  9197. defineSymbol(math, main, op, "\u222B", "\\smallint");
  9198. defineSymbol(text, main, inner, "\u2026", "\\textellipsis");
  9199. defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
  9200. defineSymbol(text, main, inner, "\u2026", "\\ldots", true);
  9201. defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
  9202. defineSymbol(math, main, inner, "\u22EF", "\\cdots", true);
  9203. defineSymbol(math, main, inner, "\u22F1", "\\ddots", true);
  9204. defineSymbol(math, main, textord, "\u22EE", "\\vdots", true);
  9205. defineSymbol(math, main, accent, "\xB4", "\\acute");
  9206. defineSymbol(math, main, accent, "`", "\\grave");
  9207. defineSymbol(math, main, accent, "\xA8", "\\ddot");
  9208. defineSymbol(math, main, accent, "~", "\\tilde");
  9209. defineSymbol(math, main, accent, "\xAF", "\\bar");
  9210. defineSymbol(math, main, accent, "\u02D8", "\\breve");
  9211. defineSymbol(math, main, accent, "\u02C7", "\\check");
  9212. defineSymbol(math, main, accent, "^", "\\hat");
  9213. defineSymbol(math, main, accent, "\u20D7", "\\vec");
  9214. defineSymbol(math, main, accent, "\u02D9", "\\dot");
  9215. defineSymbol(math, main, mathord, "\u0131", "\\imath");
  9216. defineSymbol(math, main, mathord, "\u0237", "\\jmath");
  9217. defineSymbol(text, main, accent, "\u02CA", "\\'"); // acute
  9218. defineSymbol(text, main, accent, "\u02CB", "\\`"); // grave
  9219. defineSymbol(text, main, accent, "\u02C6", "\\^"); // circumflex
  9220. defineSymbol(text, main, accent, "\u02DC", "\\~"); // tilde
  9221. defineSymbol(text, main, accent, "\u02C9", "\\="); // macron
  9222. defineSymbol(text, main, accent, "\u02D8", "\\u"); // breve
  9223. defineSymbol(text, main, accent, "\u02D9", "\\."); // dot above
  9224. defineSymbol(text, main, accent, "\u02DA", "\\r"); // ring above
  9225. defineSymbol(text, main, accent, "\u02C7", "\\v"); // caron
  9226. defineSymbol(text, main, accent, "\xA8", '\\"'); // diaresis
  9227. defineSymbol(text, main, accent, "\u030B", "\\H"); // double acute
  9228. defineSymbol(text, main, textord, "\u2013", "--");
  9229. defineSymbol(text, main, textord, "\u2013", "\\textendash");
  9230. defineSymbol(text, main, textord, "\u2014", "---");
  9231. defineSymbol(text, main, textord, "\u2014", "\\textemdash");
  9232. defineSymbol(text, main, textord, "\u2018", "`");
  9233. defineSymbol(text, main, textord, "\u2018", "\\textquoteleft");
  9234. defineSymbol(text, main, textord, "\u2019", "'");
  9235. defineSymbol(text, main, textord, "\u2019", "\\textquoteright");
  9236. defineSymbol(text, main, textord, "\u201C", "``");
  9237. defineSymbol(text, main, textord, "\u201C", "\\textquotedblleft");
  9238. defineSymbol(text, main, textord, "\u201D", "''");
  9239. defineSymbol(text, main, textord, "\u201D", "\\textquotedblright");
  9240. defineSymbol(math, main, textord, "\xB0", "\\degree");
  9241. defineSymbol(text, main, textord, "\xB0", "\\degree");
  9242. // TODO: In LaTeX, \pounds can generate a different character in text and math
  9243. // mode, but among our fonts, only Main-Italic defines this character "163".
  9244. defineSymbol(math, main, mathord, "\xA3", "\\pounds");
  9245. defineSymbol(math, main, mathord, "\xA3", "\\mathsterling");
  9246. defineSymbol(text, main, mathord, "\xA3", "\\pounds");
  9247. defineSymbol(text, main, mathord, "\xA3", "\\textsterling");
  9248. defineSymbol(math, ams, textord, "\u2720", "\\maltese");
  9249. defineSymbol(text, ams, textord, "\u2720", "\\maltese");
  9250. defineSymbol(text, main, spacing, "\xA0", "\\ ");
  9251. defineSymbol(text, main, spacing, "\xA0", " ");
  9252. defineSymbol(text, main, spacing, "\xA0", "~");
  9253. // There are lots of symbols which are the same, so we add them in afterwards.
  9254. // All of these are textords in math mode
  9255. var mathTextSymbols = "0123456789/@.\"";
  9256. for (var i = 0; i < mathTextSymbols.length; i++) {
  9257. var ch = mathTextSymbols.charAt(i);
  9258. defineSymbol(math, main, textord, ch, ch);
  9259. }
  9260. // All of these are textords in text mode
  9261. var textSymbols = "0123456789!@*()-=+[]<>|\";:?/.,";
  9262. for (var _i = 0; _i < textSymbols.length; _i++) {
  9263. var _ch = textSymbols.charAt(_i);
  9264. defineSymbol(text, main, textord, _ch, _ch);
  9265. }
  9266. // All of these are textords in text mode, and mathords in math mode
  9267. var letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  9268. for (var _i2 = 0; _i2 < letters.length; _i2++) {
  9269. var _ch2 = letters.charAt(_i2);
  9270. defineSymbol(math, main, mathord, _ch2, _ch2);
  9271. defineSymbol(text, main, textord, _ch2, _ch2);
  9272. }
  9273. // Latin-1 letters
  9274. for (var _i3 = 0x00C0; _i3 <= 0x00D6; _i3++) {
  9275. var _ch3 = String.fromCharCode(_i3);
  9276. defineSymbol(math, main, mathord, _ch3, _ch3);
  9277. defineSymbol(text, main, textord, _ch3, _ch3);
  9278. }
  9279. for (var _i4 = 0x00D8; _i4 <= 0x00F6; _i4++) {
  9280. var _ch4 = String.fromCharCode(_i4);
  9281. defineSymbol(math, main, mathord, _ch4, _ch4);
  9282. defineSymbol(text, main, textord, _ch4, _ch4);
  9283. }
  9284. for (var _i5 = 0x00F8; _i5 <= 0x00FF; _i5++) {
  9285. var _ch5 = String.fromCharCode(_i5);
  9286. defineSymbol(math, main, mathord, _ch5, _ch5);
  9287. defineSymbol(text, main, textord, _ch5, _ch5);
  9288. }
  9289. // Cyrillic
  9290. for (var _i6 = 0x0410; _i6 <= 0x044F; _i6++) {
  9291. var _ch6 = String.fromCharCode(_i6);
  9292. defineSymbol(text, main, textord, _ch6, _ch6);
  9293. }
  9294. // Unicode versions of existing characters
  9295. defineSymbol(text, main, textord, "\u2013", "–");
  9296. defineSymbol(text, main, textord, "\u2014", "—");
  9297. defineSymbol(text, main, textord, "\u2018", "‘");
  9298. defineSymbol(text, main, textord, "\u2019", "’");
  9299. defineSymbol(text, main, textord, "\u201C", "“");
  9300. defineSymbol(text, main, textord, "\u201D", "”");
  9301. },{}],49:[function(require,module,exports){
  9302. "use strict";
  9303. var hangulRegex = /[\uAC00-\uD7AF]/;
  9304. // This regex combines
  9305. // - CJK symbols and punctuation: [\u3000-\u303F]
  9306. // - Hiragana: [\u3040-\u309F]
  9307. // - Katakana: [\u30A0-\u30FF]
  9308. // - CJK ideograms: [\u4E00-\u9FAF]
  9309. // - Hangul syllables: [\uAC00-\uD7AF]
  9310. // - Fullwidth punctuation: [\uFF00-\uFF60]
  9311. // Notably missing are halfwidth Katakana and Romanji glyphs.
  9312. var cjkRegex = /[\u3000-\u30FF\u4E00-\u9FAF\uAC00-\uD7AF\uFF00-\uFF60]/;
  9313. module.exports = {
  9314. cjkRegex: cjkRegex,
  9315. hangulRegex: hangulRegex
  9316. };
  9317. },{}],50:[function(require,module,exports){
  9318. "use strict";
  9319. var _ParseError = require("./ParseError");
  9320. var _ParseError2 = _interopRequireDefault(_ParseError);
  9321. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9322. // This table gives the number of TeX pts in one of each *absolute* TeX unit.
  9323. // Thus, multiplying a length by this number converts the length from units
  9324. // into pts. Dividing the result by ptPerEm gives the number of ems
  9325. // *assuming* a font size of ptPerEm (normal size, normal style).
  9326. var ptPerUnit = {
  9327. // https://en.wikibooks.org/wiki/LaTeX/Lengths and
  9328. // https://tex.stackexchange.com/a/8263
  9329. "pt": 1, // TeX point
  9330. "mm": 7227 / 2540, // millimeter
  9331. "cm": 7227 / 254, // centimeter
  9332. "in": 72.27, // inch
  9333. "bp": 803 / 800, // big (PostScript) points
  9334. "pc": 12, // pica
  9335. "dd": 1238 / 1157, // didot
  9336. "cc": 14856 / 1157, // cicero (12 didot)
  9337. "nd": 685 / 642, // new didot
  9338. "nc": 1370 / 107, // new cicero (12 new didot)
  9339. "sp": 1 / 65536, // scaled point (TeX's internal smallest unit)
  9340. // https://tex.stackexchange.com/a/41371
  9341. "px": 803 / 800 };
  9342. // Dictionary of relative units, for fast validity testing.
  9343. /* eslint no-console:0 */
  9344. /**
  9345. * This file does conversion between units. In particular, it provides
  9346. * calculateSize to convert other units into ems.
  9347. */
  9348. var relativeUnit = {
  9349. "ex": true,
  9350. "em": true,
  9351. "mu": true
  9352. };
  9353. /**
  9354. * Determine whether the specified unit (either a string defining the unit
  9355. * or a "size" parse node containing a unit field) is valid.
  9356. */
  9357. var validUnit = function validUnit(unit) {
  9358. if (unit.unit) {
  9359. unit = unit.unit;
  9360. }
  9361. return unit in ptPerUnit || unit in relativeUnit || unit === "ex";
  9362. };
  9363. /*
  9364. * Convert a "size" parse node (with numeric "number" and string "unit" fields,
  9365. * as parsed by functions.js argType "size") into a CSS em value for the
  9366. * current style/scale. `options` gives the current options.
  9367. */
  9368. var calculateSize = function calculateSize(sizeValue, options) {
  9369. var scale = void 0;
  9370. if (sizeValue.unit in ptPerUnit) {
  9371. // Absolute units
  9372. scale = ptPerUnit[sizeValue.unit] // Convert unit to pt
  9373. / options.fontMetrics().ptPerEm // Convert pt to CSS em
  9374. / options.sizeMultiplier; // Unscale to make absolute units
  9375. } else if (sizeValue.unit === "mu") {
  9376. // `mu` units scale with scriptstyle/scriptscriptstyle.
  9377. scale = options.fontMetrics().cssEmPerMu;
  9378. } else {
  9379. // Other relative units always refer to the *textstyle* font
  9380. // in the current size.
  9381. var unitOptions = void 0;
  9382. if (options.style.isTight()) {
  9383. // isTight() means current style is script/scriptscript.
  9384. unitOptions = options.havingStyle(options.style.text());
  9385. } else {
  9386. unitOptions = options;
  9387. }
  9388. // TODO: In TeX these units are relative to the quad of the current
  9389. // *text* font, e.g. cmr10. KaTeX instead uses values from the
  9390. // comparably-sized *Computer Modern symbol* font. At 10pt, these
  9391. // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
  9392. // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
  9393. // TeX \showlists shows a kern of 1.13889 * fontsize;
  9394. // KaTeX shows a kern of 1.171 * fontsize.
  9395. if (sizeValue.unit === "ex") {
  9396. scale = unitOptions.fontMetrics().xHeight;
  9397. } else if (sizeValue.unit === "em") {
  9398. scale = unitOptions.fontMetrics().quad;
  9399. } else {
  9400. throw new _ParseError2.default("Invalid unit: '" + sizeValue.unit + "'");
  9401. }
  9402. if (unitOptions !== options) {
  9403. scale *= unitOptions.sizeMultiplier / options.sizeMultiplier;
  9404. }
  9405. }
  9406. return sizeValue.number * scale;
  9407. };
  9408. module.exports = {
  9409. validUnit: validUnit,
  9410. calculateSize: calculateSize
  9411. };
  9412. },{"./ParseError":29}],51:[function(require,module,exports){
  9413. "use strict";
  9414. /**
  9415. * This file contains a list of utility functions which are useful in other
  9416. * files.
  9417. */
  9418. /**
  9419. * Provide an `indexOf` function which works in IE8, but defers to native if
  9420. * possible.
  9421. */
  9422. var nativeIndexOf = Array.prototype.indexOf;
  9423. var indexOf = function indexOf(list, elem) {
  9424. if (list == null) {
  9425. return -1;
  9426. }
  9427. if (nativeIndexOf && list.indexOf === nativeIndexOf) {
  9428. return list.indexOf(elem);
  9429. }
  9430. var l = list.length;
  9431. for (var i = 0; i < l; i++) {
  9432. if (list[i] === elem) {
  9433. return i;
  9434. }
  9435. }
  9436. return -1;
  9437. };
  9438. /**
  9439. * Return whether an element is contained in a list
  9440. */
  9441. var contains = function contains(list, elem) {
  9442. return indexOf(list, elem) !== -1;
  9443. };
  9444. /**
  9445. * Provide a default value if a setting is undefined
  9446. */
  9447. var deflt = function deflt(setting, defaultIfUndefined) {
  9448. return setting === undefined ? defaultIfUndefined : setting;
  9449. };
  9450. // hyphenate and escape adapted from Facebook's React under Apache 2 license
  9451. var uppercase = /([A-Z])/g;
  9452. var hyphenate = function hyphenate(str) {
  9453. return str.replace(uppercase, "-$1").toLowerCase();
  9454. };
  9455. var ESCAPE_LOOKUP = {
  9456. "&": "&amp;",
  9457. ">": "&gt;",
  9458. "<": "&lt;",
  9459. "\"": "&quot;",
  9460. "'": "&#x27;"
  9461. };
  9462. var ESCAPE_REGEX = /[&><"']/g;
  9463. function escaper(match) {
  9464. return ESCAPE_LOOKUP[match];
  9465. }
  9466. /**
  9467. * Escapes text to prevent scripting attacks.
  9468. *
  9469. * @param {*} text Text value to escape.
  9470. * @return {string} An escaped string.
  9471. */
  9472. function escape(text) {
  9473. return ("" + text).replace(ESCAPE_REGEX, escaper);
  9474. }
  9475. /**
  9476. * A function to set the text content of a DOM element in all supported
  9477. * browsers. Note that we don't define this if there is no document.
  9478. */
  9479. var setTextContent = void 0;
  9480. if (typeof document !== "undefined") {
  9481. var testNode = document.createElement("span");
  9482. if ("textContent" in testNode) {
  9483. setTextContent = function setTextContent(node, text) {
  9484. node.textContent = text;
  9485. };
  9486. } else {
  9487. setTextContent = function setTextContent(node, text) {
  9488. node.innerText = text;
  9489. };
  9490. }
  9491. }
  9492. /**
  9493. * A function to clear a node.
  9494. */
  9495. function clearNode(node) {
  9496. setTextContent(node, "");
  9497. }
  9498. module.exports = {
  9499. contains: contains,
  9500. deflt: deflt,
  9501. escape: escape,
  9502. hyphenate: hyphenate,
  9503. indexOf: indexOf,
  9504. setTextContent: setTextContent,
  9505. clearNode: clearNode
  9506. };
  9507. },{}]},{},[1])(1)
  9508. });