katex.js 614 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["katex"] = factory();
  8. else
  9. root["katex"] = factory();
  10. })((typeof self !== 'undefined' ? self : this), function() {
  11. return /******/ (function() { // webpackBootstrap
  12. /******/ "use strict";
  13. /******/ // The require scope
  14. /******/ var __webpack_require__ = {};
  15. /******/
  16. /************************************************************************/
  17. /******/ /* webpack/runtime/define property getters */
  18. /******/ !function() {
  19. /******/ // define getter functions for harmony exports
  20. /******/ __webpack_require__.d = function(exports, definition) {
  21. /******/ for(var key in definition) {
  22. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  23. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  24. /******/ }
  25. /******/ }
  26. /******/ };
  27. /******/ }();
  28. /******/
  29. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  30. /******/ !function() {
  31. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  32. /******/ }();
  33. /******/
  34. /************************************************************************/
  35. var __webpack_exports__ = {};
  36. // EXPORTS
  37. __webpack_require__.d(__webpack_exports__, {
  38. "default": function() { return /* binding */ katex_webpack; }
  39. });
  40. ;// CONCATENATED MODULE: ./src/ParseError.js
  41. /**
  42. * This is the ParseError class, which is the main error thrown by KaTeX
  43. * functions when something has gone wrong. This is used to distinguish internal
  44. * errors from errors in the expression that the user provided.
  45. *
  46. * If possible, a caller should provide a Token or ParseNode with information
  47. * about where in the source string the problem occurred.
  48. */
  49. var ParseError = // Error position based on passed-in Token or ParseNode.
  50. function ParseError(message, // The error message
  51. token // An object providing position information
  52. ) {
  53. this.position = void 0;
  54. var error = "KaTeX parse error: " + message;
  55. var start;
  56. var loc = token && token.loc;
  57. if (loc && loc.start <= loc.end) {
  58. // If we have the input and a position, make the error a bit fancier
  59. // Get the input
  60. var input = loc.lexer.input; // Prepend some information
  61. start = loc.start;
  62. var end = loc.end;
  63. if (start === input.length) {
  64. error += " at end of input: ";
  65. } else {
  66. error += " at position " + (start + 1) + ": ";
  67. } // Underline token in question using combining underscores
  68. var underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332"); // Extract some context from the input and add it to the error
  69. var left;
  70. if (start > 15) {
  71. left = "…" + input.slice(start - 15, start);
  72. } else {
  73. left = input.slice(0, start);
  74. }
  75. var right;
  76. if (end + 15 < input.length) {
  77. right = input.slice(end, end + 15) + "…";
  78. } else {
  79. right = input.slice(end);
  80. }
  81. error += left + underlined + right;
  82. } // Some hackery to make ParseError a prototype of Error
  83. // See http://stackoverflow.com/a/8460753
  84. var self = new Error(error);
  85. self.name = "ParseError"; // $FlowFixMe
  86. self.__proto__ = ParseError.prototype; // $FlowFixMe
  87. self.position = start;
  88. return self;
  89. }; // $FlowFixMe More hackery
  90. ParseError.prototype.__proto__ = Error.prototype;
  91. /* harmony default export */ var src_ParseError = (ParseError);
  92. ;// CONCATENATED MODULE: ./src/utils.js
  93. /**
  94. * This file contains a list of utility functions which are useful in other
  95. * files.
  96. */
  97. /**
  98. * Return whether an element is contained in a list
  99. */
  100. var contains = function contains(list, elem) {
  101. return list.indexOf(elem) !== -1;
  102. };
  103. /**
  104. * Provide a default value if a setting is undefined
  105. * NOTE: Couldn't use `T` as the output type due to facebook/flow#5022.
  106. */
  107. var deflt = function deflt(setting, defaultIfUndefined) {
  108. return setting === undefined ? defaultIfUndefined : setting;
  109. }; // hyphenate and escape adapted from Facebook's React under Apache 2 license
  110. var uppercase = /([A-Z])/g;
  111. var hyphenate = function hyphenate(str) {
  112. return str.replace(uppercase, "-$1").toLowerCase();
  113. };
  114. var ESCAPE_LOOKUP = {
  115. "&": "&amp;",
  116. ">": "&gt;",
  117. "<": "&lt;",
  118. "\"": "&quot;",
  119. "'": "&#x27;"
  120. };
  121. var ESCAPE_REGEX = /[&><"']/g;
  122. /**
  123. * Escapes text to prevent scripting attacks.
  124. */
  125. function utils_escape(text) {
  126. return String(text).replace(ESCAPE_REGEX, function (match) {
  127. return ESCAPE_LOOKUP[match];
  128. });
  129. }
  130. /**
  131. * Sometimes we want to pull out the innermost element of a group. In most
  132. * cases, this will just be the group itself, but when ordgroups and colors have
  133. * a single element, we want to pull that out.
  134. */
  135. var getBaseElem = function getBaseElem(group) {
  136. if (group.type === "ordgroup") {
  137. if (group.body.length === 1) {
  138. return getBaseElem(group.body[0]);
  139. } else {
  140. return group;
  141. }
  142. } else if (group.type === "color") {
  143. if (group.body.length === 1) {
  144. return getBaseElem(group.body[0]);
  145. } else {
  146. return group;
  147. }
  148. } else if (group.type === "font") {
  149. return getBaseElem(group.body);
  150. } else {
  151. return group;
  152. }
  153. };
  154. /**
  155. * TeXbook algorithms often reference "character boxes", which are simply groups
  156. * with a single character in them. To decide if something is a character box,
  157. * we find its innermost group, and see if it is a single character.
  158. */
  159. var isCharacterBox = function isCharacterBox(group) {
  160. var baseElem = getBaseElem(group); // These are all they types of groups which hold single characters
  161. return baseElem.type === "mathord" || baseElem.type === "textord" || baseElem.type === "atom";
  162. };
  163. var assert = function assert(value) {
  164. if (!value) {
  165. throw new Error('Expected non-null, but got ' + String(value));
  166. }
  167. return value;
  168. };
  169. /**
  170. * Return the protocol of a URL, or "_relative" if the URL does not specify a
  171. * protocol (and thus is relative).
  172. */
  173. var protocolFromUrl = function protocolFromUrl(url) {
  174. var protocol = /^\s*([^\\/#]*?)(?::|&#0*58|&#x0*3a)/i.exec(url);
  175. return protocol != null ? protocol[1] : "_relative";
  176. };
  177. /* harmony default export */ var utils = ({
  178. contains: contains,
  179. deflt: deflt,
  180. escape: utils_escape,
  181. hyphenate: hyphenate,
  182. getBaseElem: getBaseElem,
  183. isCharacterBox: isCharacterBox,
  184. protocolFromUrl: protocolFromUrl
  185. });
  186. ;// CONCATENATED MODULE: ./src/Settings.js
  187. /* eslint no-console:0 */
  188. /**
  189. * This is a module for storing settings passed into KaTeX. It correctly handles
  190. * default settings.
  191. */
  192. // TODO: automatically generate documentation
  193. // TODO: check all properties on Settings exist
  194. // TODO: check the type of a property on Settings matches
  195. var SETTINGS_SCHEMA = {
  196. displayMode: {
  197. type: "boolean",
  198. description: "Render math in display mode, which puts the math in " + "display style (so \\int and \\sum are large, for example), and " + "centers the math on the page on its own line.",
  199. cli: "-d, --display-mode"
  200. },
  201. output: {
  202. type: {
  203. enum: ["htmlAndMathml", "html", "mathml"]
  204. },
  205. description: "Determines the markup language of the output.",
  206. cli: "-F, --format <type>"
  207. },
  208. leqno: {
  209. type: "boolean",
  210. description: "Render display math in leqno style (left-justified tags)."
  211. },
  212. fleqn: {
  213. type: "boolean",
  214. description: "Render display math flush left."
  215. },
  216. throwOnError: {
  217. type: "boolean",
  218. default: true,
  219. cli: "-t, --no-throw-on-error",
  220. cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error."
  221. },
  222. errorColor: {
  223. type: "string",
  224. default: "#cc0000",
  225. cli: "-c, --error-color <color>",
  226. cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.",
  227. cliProcessor: function cliProcessor(color) {
  228. return "#" + color;
  229. }
  230. },
  231. macros: {
  232. type: "object",
  233. cli: "-m, --macro <def>",
  234. cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).",
  235. cliDefault: [],
  236. cliProcessor: function cliProcessor(def, defs) {
  237. defs.push(def);
  238. return defs;
  239. }
  240. },
  241. minRuleThickness: {
  242. type: "number",
  243. description: "Specifies a minimum thickness, in ems, for fraction lines," + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.",
  244. processor: function processor(t) {
  245. return Math.max(0, t);
  246. },
  247. cli: "--min-rule-thickness <size>",
  248. cliProcessor: parseFloat
  249. },
  250. colorIsTextColor: {
  251. type: "boolean",
  252. description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.",
  253. cli: "-b, --color-is-text-color"
  254. },
  255. strict: {
  256. type: [{
  257. enum: ["warn", "ignore", "error"]
  258. }, "boolean", "function"],
  259. description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.",
  260. cli: "-S, --strict",
  261. cliDefault: false
  262. },
  263. trust: {
  264. type: ["boolean", "function"],
  265. description: "Trust the input, enabling all HTML features such as \\url.",
  266. cli: "-T, --trust"
  267. },
  268. maxSize: {
  269. type: "number",
  270. default: Infinity,
  271. description: "If non-zero, all user-specified sizes, e.g. in " + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + "elements and spaces can be arbitrarily large",
  272. processor: function processor(s) {
  273. return Math.max(0, s);
  274. },
  275. cli: "-s, --max-size <n>",
  276. cliProcessor: parseInt
  277. },
  278. maxExpand: {
  279. type: "number",
  280. default: 1000,
  281. description: "Limit the number of macro expansions to the specified " + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + "the macro expander will try to fully expand as in LaTeX.",
  282. processor: function processor(n) {
  283. return Math.max(0, n);
  284. },
  285. cli: "-e, --max-expand <n>",
  286. cliProcessor: function cliProcessor(n) {
  287. return n === "Infinity" ? Infinity : parseInt(n);
  288. }
  289. },
  290. globalGroup: {
  291. type: "boolean",
  292. cli: false
  293. }
  294. };
  295. function getDefaultValue(schema) {
  296. if (schema.default) {
  297. return schema.default;
  298. }
  299. var type = schema.type;
  300. var defaultType = Array.isArray(type) ? type[0] : type;
  301. if (typeof defaultType !== 'string') {
  302. return defaultType.enum[0];
  303. }
  304. switch (defaultType) {
  305. case 'boolean':
  306. return false;
  307. case 'string':
  308. return '';
  309. case 'number':
  310. return 0;
  311. case 'object':
  312. return {};
  313. }
  314. }
  315. /**
  316. * The main Settings object
  317. *
  318. * The current options stored are:
  319. * - displayMode: Whether the expression should be typeset as inline math
  320. * (false, the default), meaning that the math starts in
  321. * \textstyle and is placed in an inline-block); or as display
  322. * math (true), meaning that the math starts in \displaystyle
  323. * and is placed in a block with vertical margin.
  324. */
  325. var Settings = /*#__PURE__*/function () {
  326. function Settings(options) {
  327. this.displayMode = void 0;
  328. this.output = void 0;
  329. this.leqno = void 0;
  330. this.fleqn = void 0;
  331. this.throwOnError = void 0;
  332. this.errorColor = void 0;
  333. this.macros = void 0;
  334. this.minRuleThickness = void 0;
  335. this.colorIsTextColor = void 0;
  336. this.strict = void 0;
  337. this.trust = void 0;
  338. this.maxSize = void 0;
  339. this.maxExpand = void 0;
  340. this.globalGroup = void 0;
  341. // allow null options
  342. options = options || {};
  343. for (var prop in SETTINGS_SCHEMA) {
  344. if (SETTINGS_SCHEMA.hasOwnProperty(prop)) {
  345. // $FlowFixMe
  346. var schema = SETTINGS_SCHEMA[prop]; // TODO: validate options
  347. // $FlowFixMe
  348. this[prop] = options[prop] !== undefined ? schema.processor ? schema.processor(options[prop]) : options[prop] : getDefaultValue(schema);
  349. }
  350. }
  351. }
  352. /**
  353. * Report nonstrict (non-LaTeX-compatible) input.
  354. * Can safely not be called if `this.strict` is false in JavaScript.
  355. */
  356. var _proto = Settings.prototype;
  357. _proto.reportNonstrict = function reportNonstrict(errorCode, errorMsg, token) {
  358. var strict = this.strict;
  359. if (typeof strict === "function") {
  360. // Allow return value of strict function to be boolean or string
  361. // (or null/undefined, meaning no further processing).
  362. strict = strict(errorCode, errorMsg, token);
  363. }
  364. if (!strict || strict === "ignore") {
  365. return;
  366. } else if (strict === true || strict === "error") {
  367. throw new src_ParseError("LaTeX-incompatible input and strict mode is set to 'error': " + (errorMsg + " [" + errorCode + "]"), token);
  368. } else if (strict === "warn") {
  369. typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]"));
  370. } else {
  371. // won't happen in type-safe code
  372. typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]"));
  373. }
  374. }
  375. /**
  376. * Check whether to apply strict (LaTeX-adhering) behavior for unusual
  377. * input (like `\\`). Unlike `nonstrict`, will not throw an error;
  378. * instead, "error" translates to a return value of `true`, while "ignore"
  379. * translates to a return value of `false`. May still print a warning:
  380. * "warn" prints a warning and returns `false`.
  381. * This is for the second category of `errorCode`s listed in the README.
  382. */
  383. ;
  384. _proto.useStrictBehavior = function useStrictBehavior(errorCode, errorMsg, token) {
  385. var strict = this.strict;
  386. if (typeof strict === "function") {
  387. // Allow return value of strict function to be boolean or string
  388. // (or null/undefined, meaning no further processing).
  389. // But catch any exceptions thrown by function, treating them
  390. // like "error".
  391. try {
  392. strict = strict(errorCode, errorMsg, token);
  393. } catch (error) {
  394. strict = "error";
  395. }
  396. }
  397. if (!strict || strict === "ignore") {
  398. return false;
  399. } else if (strict === true || strict === "error") {
  400. return true;
  401. } else if (strict === "warn") {
  402. typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]"));
  403. return false;
  404. } else {
  405. // won't happen in type-safe code
  406. typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]"));
  407. return false;
  408. }
  409. }
  410. /**
  411. * Check whether to test potentially dangerous input, and return
  412. * `true` (trusted) or `false` (untrusted). The sole argument `context`
  413. * should be an object with `command` field specifying the relevant LaTeX
  414. * command (as a string starting with `\`), and any other arguments, etc.
  415. * If `context` has a `url` field, a `protocol` field will automatically
  416. * get added by this function (changing the specified object).
  417. */
  418. ;
  419. _proto.isTrusted = function isTrusted(context) {
  420. if (context.url && !context.protocol) {
  421. context.protocol = utils.protocolFromUrl(context.url);
  422. }
  423. var trust = typeof this.trust === "function" ? this.trust(context) : this.trust;
  424. return Boolean(trust);
  425. };
  426. return Settings;
  427. }();
  428. ;// CONCATENATED MODULE: ./src/Style.js
  429. /**
  430. * This file contains information and classes for the various kinds of styles
  431. * used in TeX. It provides a generic `Style` class, which holds information
  432. * about a specific style. It then provides instances of all the different kinds
  433. * of styles possible, and provides functions to move between them and get
  434. * information about them.
  435. */
  436. /**
  437. * The main style class. Contains a unique id for the style, a size (which is
  438. * the same for cramped and uncramped version of a style), and a cramped flag.
  439. */
  440. var Style = /*#__PURE__*/function () {
  441. function Style(id, size, cramped) {
  442. this.id = void 0;
  443. this.size = void 0;
  444. this.cramped = void 0;
  445. this.id = id;
  446. this.size = size;
  447. this.cramped = cramped;
  448. }
  449. /**
  450. * Get the style of a superscript given a base in the current style.
  451. */
  452. var _proto = Style.prototype;
  453. _proto.sup = function sup() {
  454. return styles[_sup[this.id]];
  455. }
  456. /**
  457. * Get the style of a subscript given a base in the current style.
  458. */
  459. ;
  460. _proto.sub = function sub() {
  461. return styles[_sub[this.id]];
  462. }
  463. /**
  464. * Get the style of a fraction numerator given the fraction in the current
  465. * style.
  466. */
  467. ;
  468. _proto.fracNum = function fracNum() {
  469. return styles[_fracNum[this.id]];
  470. }
  471. /**
  472. * Get the style of a fraction denominator given the fraction in the current
  473. * style.
  474. */
  475. ;
  476. _proto.fracDen = function fracDen() {
  477. return styles[_fracDen[this.id]];
  478. }
  479. /**
  480. * Get the cramped version of a style (in particular, cramping a cramped style
  481. * doesn't change the style).
  482. */
  483. ;
  484. _proto.cramp = function cramp() {
  485. return styles[_cramp[this.id]];
  486. }
  487. /**
  488. * Get a text or display version of this style.
  489. */
  490. ;
  491. _proto.text = function text() {
  492. return styles[_text[this.id]];
  493. }
  494. /**
  495. * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle)
  496. */
  497. ;
  498. _proto.isTight = function isTight() {
  499. return this.size >= 2;
  500. };
  501. return Style;
  502. }(); // Export an interface for type checking, but don't expose the implementation.
  503. // This way, no more styles can be generated.
  504. // IDs of the different styles
  505. var D = 0;
  506. var Dc = 1;
  507. var T = 2;
  508. var Tc = 3;
  509. var S = 4;
  510. var Sc = 5;
  511. var SS = 6;
  512. var SSc = 7; // Instances of the different styles
  513. 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)]; // Lookup tables for switching from one style to another
  514. var _sup = [S, Sc, S, Sc, SS, SSc, SS, SSc];
  515. var _sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc];
  516. var _fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc];
  517. var _fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc];
  518. var _cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc];
  519. var _text = [D, Dc, T, Tc, T, Tc, T, Tc]; // We only export some of the styles.
  520. /* harmony default export */ var src_Style = ({
  521. DISPLAY: styles[D],
  522. TEXT: styles[T],
  523. SCRIPT: styles[S],
  524. SCRIPTSCRIPT: styles[SS]
  525. });
  526. ;// CONCATENATED MODULE: ./src/unicodeScripts.js
  527. /*
  528. * This file defines the Unicode scripts and script families that we
  529. * support. To add new scripts or families, just add a new entry to the
  530. * scriptData array below. Adding scripts to the scriptData array allows
  531. * characters from that script to appear in \text{} environments.
  532. */
  533. /**
  534. * Each script or script family has a name and an array of blocks.
  535. * Each block is an array of two numbers which specify the start and
  536. * end points (inclusive) of a block of Unicode codepoints.
  537. */
  538. /**
  539. * Unicode block data for the families of scripts we support in \text{}.
  540. * Scripts only need to appear here if they do not have font metrics.
  541. */
  542. var scriptData = [{
  543. // Latin characters beyond the Latin-1 characters we have metrics for.
  544. // Needed for Czech, Hungarian and Turkish text, for example.
  545. name: 'latin',
  546. blocks: [[0x0100, 0x024f], // Latin Extended-A and Latin Extended-B
  547. [0x0300, 0x036f] // Combining Diacritical marks
  548. ]
  549. }, {
  550. // The Cyrillic script used by Russian and related languages.
  551. // A Cyrillic subset used to be supported as explicitly defined
  552. // symbols in symbols.js
  553. name: 'cyrillic',
  554. blocks: [[0x0400, 0x04ff]]
  555. }, {
  556. // Armenian
  557. name: 'armenian',
  558. blocks: [[0x0530, 0x058F]]
  559. }, {
  560. // The Brahmic scripts of South and Southeast Asia
  561. // Devanagari (0900–097F)
  562. // Bengali (0980–09FF)
  563. // Gurmukhi (0A00–0A7F)
  564. // Gujarati (0A80–0AFF)
  565. // Oriya (0B00–0B7F)
  566. // Tamil (0B80–0BFF)
  567. // Telugu (0C00–0C7F)
  568. // Kannada (0C80–0CFF)
  569. // Malayalam (0D00–0D7F)
  570. // Sinhala (0D80–0DFF)
  571. // Thai (0E00–0E7F)
  572. // Lao (0E80–0EFF)
  573. // Tibetan (0F00–0FFF)
  574. // Myanmar (1000–109F)
  575. name: 'brahmic',
  576. blocks: [[0x0900, 0x109F]]
  577. }, {
  578. name: 'georgian',
  579. blocks: [[0x10A0, 0x10ff]]
  580. }, {
  581. // Chinese and Japanese.
  582. // The "k" in cjk is for Korean, but we've separated Korean out
  583. name: "cjk",
  584. blocks: [[0x3000, 0x30FF], // CJK symbols and punctuation, Hiragana, Katakana
  585. [0x4E00, 0x9FAF], // CJK ideograms
  586. [0xFF00, 0xFF60] // Fullwidth punctuation
  587. // TODO: add halfwidth Katakana and Romanji glyphs
  588. ]
  589. }, {
  590. // Korean
  591. name: 'hangul',
  592. blocks: [[0xAC00, 0xD7AF]]
  593. }];
  594. /**
  595. * Given a codepoint, return the name of the script or script family
  596. * it is from, or null if it is not part of a known block
  597. */
  598. function scriptFromCodepoint(codepoint) {
  599. for (var i = 0; i < scriptData.length; i++) {
  600. var script = scriptData[i];
  601. for (var _i = 0; _i < script.blocks.length; _i++) {
  602. var block = script.blocks[_i];
  603. if (codepoint >= block[0] && codepoint <= block[1]) {
  604. return script.name;
  605. }
  606. }
  607. }
  608. return null;
  609. }
  610. /**
  611. * A flattened version of all the supported blocks in a single array.
  612. * This is an optimization to make supportedCodepoint() fast.
  613. */
  614. var allBlocks = [];
  615. scriptData.forEach(function (s) {
  616. return s.blocks.forEach(function (b) {
  617. return allBlocks.push.apply(allBlocks, b);
  618. });
  619. });
  620. /**
  621. * Given a codepoint, return true if it falls within one of the
  622. * scripts or script families defined above and false otherwise.
  623. *
  624. * Micro benchmarks shows that this is faster than
  625. * /[\u3000-\u30FF\u4E00-\u9FAF\uFF00-\uFF60\uAC00-\uD7AF\u0900-\u109F]/.test()
  626. * in Firefox, Chrome and Node.
  627. */
  628. function supportedCodepoint(codepoint) {
  629. for (var i = 0; i < allBlocks.length; i += 2) {
  630. if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) {
  631. return true;
  632. }
  633. }
  634. return false;
  635. }
  636. ;// CONCATENATED MODULE: ./src/svgGeometry.js
  637. /**
  638. * This file provides support to domTree.js and delimiter.js.
  639. * It's a storehouse of path geometry for SVG images.
  640. */
  641. // In all paths below, the viewBox-to-em scale is 1000:1.
  642. var hLinePad = 80; // padding above a sqrt viniculum. Prevents image cropping.
  643. // The viniculum of a \sqrt can be made thicker by a KaTeX rendering option.
  644. // Think of variable extraViniculum as two detours in the SVG path.
  645. // The detour begins at the lower left of the area labeled extraViniculum below.
  646. // The detour proceeds one extraViniculum distance up and slightly to the right,
  647. // displacing the radiused corner between surd and viniculum. The radius is
  648. // traversed as usual, then the detour resumes. It goes right, to the end of
  649. // the very long viniculumn, then down one extraViniculum distance,
  650. // after which it resumes regular path geometry for the radical.
  651. /* viniculum
  652. /
  653. /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraViniculum
  654. / █████████████████████←0.04em (40 unit) std viniculum thickness
  655. / /
  656. / /
  657. / /\
  658. / / surd
  659. */
  660. var sqrtMain = function sqrtMain(extraViniculum, hLinePad) {
  661. // sqrtMain path geometry is from glyph U221A in the font KaTeX Main
  662. return "M95," + (622 + extraViniculum + hLinePad) + "\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl" + extraViniculum / 2.075 + " -" + extraViniculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraViniculum) + "H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM" + (834 + extraViniculum) + " " + hLinePad + "h400000v" + (40 + extraViniculum) + "h-400000z";
  663. };
  664. var sqrtSize1 = function sqrtSize1(extraViniculum, hLinePad) {
  665. // size1 is from glyph U221A in the font KaTeX_Size1-Regular
  666. return "M263," + (601 + extraViniculum + hLinePad) + "c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl" + extraViniculum / 2.084 + " -" + extraViniculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraViniculum) + "H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM" + (1001 + extraViniculum) + " " + hLinePad + "h400000v" + (40 + extraViniculum) + "h-400000z";
  667. };
  668. var sqrtSize2 = function sqrtSize2(extraViniculum, hLinePad) {
  669. // size2 is from glyph U221A in the font KaTeX_Size2-Regular
  670. return "M983 " + (10 + extraViniculum + hLinePad) + "\nl" + extraViniculum / 3.13 + " -" + extraViniculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraViniculum) + "\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM" + (1001 + extraViniculum) + " " + hLinePad + "h400000v" + (40 + extraViniculum) + "h-400000z";
  671. };
  672. var sqrtSize3 = function sqrtSize3(extraViniculum, hLinePad) {
  673. // size3 is from glyph U221A in the font KaTeX_Size3-Regular
  674. return "M424," + (2398 + extraViniculum + hLinePad) + "\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl" + extraViniculum / 4.223 + " -" + extraViniculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraViniculum) + "H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M" + (1001 + extraViniculum) + " " + hLinePad + "\nh400000v" + (40 + extraViniculum) + "h-400000z";
  675. };
  676. var sqrtSize4 = function sqrtSize4(extraViniculum, hLinePad) {
  677. // size4 is from glyph U221A in the font KaTeX_Size4-Regular
  678. return "M473," + (2713 + extraViniculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraViniculum / 5.298 + " -" + extraViniculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraViniculum) + "H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM" + (1001 + extraViniculum) + " " + hLinePad + "h400000v" + (40 + extraViniculum) + "H1017.7z";
  679. };
  680. var phasePath = function phasePath(y) {
  681. var x = y / 2; // x coordinate at top of angle
  682. return "M400000 " + y + " H0 L" + x + " 0 l65 45 L145 " + (y - 80) + " H400000z";
  683. };
  684. var sqrtTall = function sqrtTall(extraViniculum, hLinePad, viewBoxHeight) {
  685. // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular
  686. // One path edge has a variable length. It runs vertically from the viniculumn
  687. // to a point near (14 units) the bottom of the surd. The viniculum
  688. // is normally 40 units thick. So the length of the line in question is:
  689. var vertSegment = viewBoxHeight - 54 - hLinePad - extraViniculum;
  690. return "M702 " + (extraViniculum + hLinePad) + "H400000" + (40 + extraViniculum) + "\nH742v" + vertSegment + "l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 " + hLinePad + "H400000v" + (40 + extraViniculum) + "H742z";
  691. };
  692. var sqrtPath = function sqrtPath(size, extraViniculum, viewBoxHeight) {
  693. extraViniculum = 1000 * extraViniculum; // Convert from document ems to viewBox.
  694. var path = "";
  695. switch (size) {
  696. case "sqrtMain":
  697. path = sqrtMain(extraViniculum, hLinePad);
  698. break;
  699. case "sqrtSize1":
  700. path = sqrtSize1(extraViniculum, hLinePad);
  701. break;
  702. case "sqrtSize2":
  703. path = sqrtSize2(extraViniculum, hLinePad);
  704. break;
  705. case "sqrtSize3":
  706. path = sqrtSize3(extraViniculum, hLinePad);
  707. break;
  708. case "sqrtSize4":
  709. path = sqrtSize4(extraViniculum, hLinePad);
  710. break;
  711. case "sqrtTall":
  712. path = sqrtTall(extraViniculum, hLinePad, viewBoxHeight);
  713. }
  714. return path;
  715. };
  716. var innerPath = function innerPath(name, height) {
  717. // The inner part of stretchy tall delimiters
  718. switch (name) {
  719. case "\u239C":
  720. return "M291 0 H417 V" + height + " H291z M291 0 H417 V" + height + " H291z";
  721. case "\u2223":
  722. return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z";
  723. case "\u2225":
  724. return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z" + ("M367 0 H410 V" + height + " H367z M367 0 H410 V" + height + " H367z");
  725. case "\u239F":
  726. return "M457 0 H583 V" + height + " H457z M457 0 H583 V" + height + " H457z";
  727. case "\u23A2":
  728. return "M319 0 H403 V" + height + " H319z M319 0 H403 V" + height + " H319z";
  729. case "\u23A5":
  730. return "M263 0 H347 V" + height + " H263z M263 0 H347 V" + height + " H263z";
  731. case "\u23AA":
  732. return "M384 0 H504 V" + height + " H384z M384 0 H504 V" + height + " H384z";
  733. case "\u23D0":
  734. return "M312 0 H355 V" + height + " H312z M312 0 H355 V" + height + " H312z";
  735. case "\u2016":
  736. return "M257 0 H300 V" + height + " H257z M257 0 H300 V" + height + " H257z" + ("M478 0 H521 V" + height + " H478z M478 0 H521 V" + height + " H478z");
  737. default:
  738. return "";
  739. }
  740. };
  741. var path = {
  742. // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main
  743. doubleleftarrow: "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",
  744. // doublerightarrow is from glyph U+21D2 in font KaTeX Main
  745. doublerightarrow: "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",
  746. // leftarrow is from glyph U+2190 in font KaTeX Main
  747. leftarrow: "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",
  748. // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular
  749. leftbrace: "M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z",
  750. leftbraceunder: "M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z",
  751. // overgroup is from the MnSymbol package (public domain)
  752. leftgroup: "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",
  753. leftgroupunder: "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",
  754. // Harpoons are from glyph U+21BD in font KaTeX Main
  755. leftharpoon: "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",
  756. leftharpoonplus: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-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-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z",
  757. leftharpoondown: "M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z",
  758. leftharpoondownplus: "M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z",
  759. // hook is from glyph U+21A9 in font KaTeX Main
  760. lefthook: "M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 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\n 71.5 23h399859zM103 281v-40h399897v40z",
  761. leftlinesegment: "M40 281 V428 H0 V94 H40 V241 H400000 v40z\nM40 281 V428 H0 V94 H40 V241 H400000 v40z",
  762. leftmapsto: "M40 281 V448H0V74H40V241H400000v40z\nM40 281 V448H0V74H40V241H400000v40z",
  763. // tofrom is from glyph U+21C4 in font KaTeX AMS Regular
  764. leftToFrom: "M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z",
  765. longequal: "M0 50 h400000 v40H0z m0 194h40000v40H0z\nM0 50 h400000 v40H0z m0 194h40000v40H0z",
  766. midbrace: "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",
  767. midbraceunder: "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",
  768. oiintSize1: "M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z",
  769. oiintSize2: "M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z",
  770. oiiintSize1: "M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z",
  771. oiiintSize2: "M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z",
  772. rightarrow: "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",
  773. rightbrace: "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",
  774. rightbraceunder: "M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z",
  775. rightgroup: "M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z",
  776. rightgroupunder: "M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z",
  777. rightharpoon: "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",
  778. rightharpoonplus: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-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-10.7 0-16.7\n 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 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z",
  779. rightharpoondown: "M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z",
  780. rightharpoondownplus: "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",
  781. righthook: "M399859 241c-764 0 0 0 0 0 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-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z",
  782. rightlinesegment: "M399960 241 V94 h40 V428 h-40 V281 H0 v-40z\nM399960 241 V94 h40 V428 h-40 V281 H0 v-40z",
  783. rightToFrom: "M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z",
  784. // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular
  785. twoheadleftarrow: "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",
  786. twoheadrightarrow: "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",
  787. // tilde1 is a modified version of a glyph from the MnSymbol package
  788. tilde1: "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",
  789. // ditto tilde2, tilde3, & tilde4
  790. tilde2: "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",
  791. tilde3: "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",
  792. tilde4: "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",
  793. // vec is from glyph U+20D7 in font KaTeX Main
  794. vec: "M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z",
  795. // widehat1 is a modified version of a glyph from the MnSymbol package
  796. widehat1: "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",
  797. // ditto widehat2, widehat3, & widehat4
  798. widehat2: "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",
  799. widehat3: "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",
  800. widehat4: "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",
  801. // widecheck paths are all inverted versions of widehat
  802. widecheck1: "M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z",
  803. widecheck2: "M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",
  804. widecheck3: "M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",
  805. widecheck4: "M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",
  806. // The next ten paths support reaction arrows from the mhchem package.
  807. // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX
  808. // baraboveleftarrow is mostly from from glyph U+2190 in font KaTeX Main
  809. baraboveleftarrow: "M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z",
  810. // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main
  811. rightarrowabovebar: "M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-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 11 8 0\n13.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 39\n-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-40.5\n-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\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z",
  812. // The short left harpoon has 0.5em (i.e. 500 units) kern on the left end.
  813. // Ref from mhchem.sty: \rlap{\raisebox{-.22ex}{$\kern0.5em
  814. baraboveshortleftharpoon: "M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z",
  815. rightharpoonaboveshortbar: "M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z",
  816. shortbaraboveleftharpoon: "M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z",
  817. shortrightharpoonabovebar: "M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z"
  818. };
  819. var tallDelim = function tallDelim(label, midHeight) {
  820. switch (label) {
  821. case "lbrack":
  822. return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 h84z";
  823. case "rbrack":
  824. return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z";
  825. case "vert":
  826. return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z";
  827. case "doublevert":
  828. return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z\nM367 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v" + midHeight + " v585 h43z";
  829. case "lfloor":
  830. return "M319 602 V0 H403 V602 v" + midHeight + " v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z";
  831. case "rfloor":
  832. return "M319 602 V0 H403 V602 v" + midHeight + " v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z";
  833. case "lceil":
  834. return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v602 h84z\nM403 1759 V0 H319 V1759 v" + midHeight + " v602 h84z";
  835. case "rceil":
  836. return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v602 h84z\nM347 1759 V0 h-84 V1759 v" + midHeight + " v602 h84z";
  837. case "lparen":
  838. return "M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0," + (midHeight + 84) + "c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-" + (midHeight + 92) + "c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z";
  839. case "rparen":
  840. return "M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0," + (midHeight + 9) + "\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-" + (midHeight + 144) + "c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z";
  841. default:
  842. // We should not ever get here.
  843. throw new Error("Unknown stretchy delimiter.");
  844. }
  845. };
  846. ;// CONCATENATED MODULE: ./src/tree.js
  847. /**
  848. * This node represents a document fragment, which contains elements, but when
  849. * placed into the DOM doesn't have any representation itself. It only contains
  850. * children and doesn't have any DOM node properties.
  851. */
  852. var DocumentFragment = /*#__PURE__*/function () {
  853. // HtmlDomNode
  854. // Never used; needed for satisfying interface.
  855. function DocumentFragment(children) {
  856. this.children = void 0;
  857. this.classes = void 0;
  858. this.height = void 0;
  859. this.depth = void 0;
  860. this.maxFontSize = void 0;
  861. this.style = void 0;
  862. this.children = children;
  863. this.classes = [];
  864. this.height = 0;
  865. this.depth = 0;
  866. this.maxFontSize = 0;
  867. this.style = {};
  868. }
  869. var _proto = DocumentFragment.prototype;
  870. _proto.hasClass = function hasClass(className) {
  871. return utils.contains(this.classes, className);
  872. }
  873. /** Convert the fragment into a node. */
  874. ;
  875. _proto.toNode = function toNode() {
  876. var frag = document.createDocumentFragment();
  877. for (var i = 0; i < this.children.length; i++) {
  878. frag.appendChild(this.children[i].toNode());
  879. }
  880. return frag;
  881. }
  882. /** Convert the fragment into HTML markup. */
  883. ;
  884. _proto.toMarkup = function toMarkup() {
  885. var markup = ""; // Simply concatenate the markup for the children together.
  886. for (var i = 0; i < this.children.length; i++) {
  887. markup += this.children[i].toMarkup();
  888. }
  889. return markup;
  890. }
  891. /**
  892. * Converts the math node into a string, similar to innerText. Applies to
  893. * MathDomNode's only.
  894. */
  895. ;
  896. _proto.toText = function toText() {
  897. // To avoid this, we would subclass documentFragment separately for
  898. // MathML, but polyfills for subclassing is expensive per PR 1469.
  899. // $FlowFixMe: Only works for ChildType = MathDomNode.
  900. var toText = function toText(child) {
  901. return child.toText();
  902. };
  903. return this.children.map(toText).join("");
  904. };
  905. return DocumentFragment;
  906. }();
  907. ;// CONCATENATED MODULE: ./src/fontMetricsData.js
  908. // This file is GENERATED by buildMetrics.sh. DO NOT MODIFY.
  909. /* harmony default export */ var fontMetricsData = ({
  910. "AMS-Regular": {
  911. "32": [0, 0, 0, 0, 0.25],
  912. "65": [0, 0.68889, 0, 0, 0.72222],
  913. "66": [0, 0.68889, 0, 0, 0.66667],
  914. "67": [0, 0.68889, 0, 0, 0.72222],
  915. "68": [0, 0.68889, 0, 0, 0.72222],
  916. "69": [0, 0.68889, 0, 0, 0.66667],
  917. "70": [0, 0.68889, 0, 0, 0.61111],
  918. "71": [0, 0.68889, 0, 0, 0.77778],
  919. "72": [0, 0.68889, 0, 0, 0.77778],
  920. "73": [0, 0.68889, 0, 0, 0.38889],
  921. "74": [0.16667, 0.68889, 0, 0, 0.5],
  922. "75": [0, 0.68889, 0, 0, 0.77778],
  923. "76": [0, 0.68889, 0, 0, 0.66667],
  924. "77": [0, 0.68889, 0, 0, 0.94445],
  925. "78": [0, 0.68889, 0, 0, 0.72222],
  926. "79": [0.16667, 0.68889, 0, 0, 0.77778],
  927. "80": [0, 0.68889, 0, 0, 0.61111],
  928. "81": [0.16667, 0.68889, 0, 0, 0.77778],
  929. "82": [0, 0.68889, 0, 0, 0.72222],
  930. "83": [0, 0.68889, 0, 0, 0.55556],
  931. "84": [0, 0.68889, 0, 0, 0.66667],
  932. "85": [0, 0.68889, 0, 0, 0.72222],
  933. "86": [0, 0.68889, 0, 0, 0.72222],
  934. "87": [0, 0.68889, 0, 0, 1.0],
  935. "88": [0, 0.68889, 0, 0, 0.72222],
  936. "89": [0, 0.68889, 0, 0, 0.72222],
  937. "90": [0, 0.68889, 0, 0, 0.66667],
  938. "107": [0, 0.68889, 0, 0, 0.55556],
  939. "160": [0, 0, 0, 0, 0.25],
  940. "165": [0, 0.675, 0.025, 0, 0.75],
  941. "174": [0.15559, 0.69224, 0, 0, 0.94666],
  942. "240": [0, 0.68889, 0, 0, 0.55556],
  943. "295": [0, 0.68889, 0, 0, 0.54028],
  944. "710": [0, 0.825, 0, 0, 2.33334],
  945. "732": [0, 0.9, 0, 0, 2.33334],
  946. "770": [0, 0.825, 0, 0, 2.33334],
  947. "771": [0, 0.9, 0, 0, 2.33334],
  948. "989": [0.08167, 0.58167, 0, 0, 0.77778],
  949. "1008": [0, 0.43056, 0.04028, 0, 0.66667],
  950. "8245": [0, 0.54986, 0, 0, 0.275],
  951. "8463": [0, 0.68889, 0, 0, 0.54028],
  952. "8487": [0, 0.68889, 0, 0, 0.72222],
  953. "8498": [0, 0.68889, 0, 0, 0.55556],
  954. "8502": [0, 0.68889, 0, 0, 0.66667],
  955. "8503": [0, 0.68889, 0, 0, 0.44445],
  956. "8504": [0, 0.68889, 0, 0, 0.66667],
  957. "8513": [0, 0.68889, 0, 0, 0.63889],
  958. "8592": [-0.03598, 0.46402, 0, 0, 0.5],
  959. "8594": [-0.03598, 0.46402, 0, 0, 0.5],
  960. "8602": [-0.13313, 0.36687, 0, 0, 1.0],
  961. "8603": [-0.13313, 0.36687, 0, 0, 1.0],
  962. "8606": [0.01354, 0.52239, 0, 0, 1.0],
  963. "8608": [0.01354, 0.52239, 0, 0, 1.0],
  964. "8610": [0.01354, 0.52239, 0, 0, 1.11111],
  965. "8611": [0.01354, 0.52239, 0, 0, 1.11111],
  966. "8619": [0, 0.54986, 0, 0, 1.0],
  967. "8620": [0, 0.54986, 0, 0, 1.0],
  968. "8621": [-0.13313, 0.37788, 0, 0, 1.38889],
  969. "8622": [-0.13313, 0.36687, 0, 0, 1.0],
  970. "8624": [0, 0.69224, 0, 0, 0.5],
  971. "8625": [0, 0.69224, 0, 0, 0.5],
  972. "8630": [0, 0.43056, 0, 0, 1.0],
  973. "8631": [0, 0.43056, 0, 0, 1.0],
  974. "8634": [0.08198, 0.58198, 0, 0, 0.77778],
  975. "8635": [0.08198, 0.58198, 0, 0, 0.77778],
  976. "8638": [0.19444, 0.69224, 0, 0, 0.41667],
  977. "8639": [0.19444, 0.69224, 0, 0, 0.41667],
  978. "8642": [0.19444, 0.69224, 0, 0, 0.41667],
  979. "8643": [0.19444, 0.69224, 0, 0, 0.41667],
  980. "8644": [0.1808, 0.675, 0, 0, 1.0],
  981. "8646": [0.1808, 0.675, 0, 0, 1.0],
  982. "8647": [0.1808, 0.675, 0, 0, 1.0],
  983. "8648": [0.19444, 0.69224, 0, 0, 0.83334],
  984. "8649": [0.1808, 0.675, 0, 0, 1.0],
  985. "8650": [0.19444, 0.69224, 0, 0, 0.83334],
  986. "8651": [0.01354, 0.52239, 0, 0, 1.0],
  987. "8652": [0.01354, 0.52239, 0, 0, 1.0],
  988. "8653": [-0.13313, 0.36687, 0, 0, 1.0],
  989. "8654": [-0.13313, 0.36687, 0, 0, 1.0],
  990. "8655": [-0.13313, 0.36687, 0, 0, 1.0],
  991. "8666": [0.13667, 0.63667, 0, 0, 1.0],
  992. "8667": [0.13667, 0.63667, 0, 0, 1.0],
  993. "8669": [-0.13313, 0.37788, 0, 0, 1.0],
  994. "8672": [-0.064, 0.437, 0, 0, 1.334],
  995. "8674": [-0.064, 0.437, 0, 0, 1.334],
  996. "8705": [0, 0.825, 0, 0, 0.5],
  997. "8708": [0, 0.68889, 0, 0, 0.55556],
  998. "8709": [0.08167, 0.58167, 0, 0, 0.77778],
  999. "8717": [0, 0.43056, 0, 0, 0.42917],
  1000. "8722": [-0.03598, 0.46402, 0, 0, 0.5],
  1001. "8724": [0.08198, 0.69224, 0, 0, 0.77778],
  1002. "8726": [0.08167, 0.58167, 0, 0, 0.77778],
  1003. "8733": [0, 0.69224, 0, 0, 0.77778],
  1004. "8736": [0, 0.69224, 0, 0, 0.72222],
  1005. "8737": [0, 0.69224, 0, 0, 0.72222],
  1006. "8738": [0.03517, 0.52239, 0, 0, 0.72222],
  1007. "8739": [0.08167, 0.58167, 0, 0, 0.22222],
  1008. "8740": [0.25142, 0.74111, 0, 0, 0.27778],
  1009. "8741": [0.08167, 0.58167, 0, 0, 0.38889],
  1010. "8742": [0.25142, 0.74111, 0, 0, 0.5],
  1011. "8756": [0, 0.69224, 0, 0, 0.66667],
  1012. "8757": [0, 0.69224, 0, 0, 0.66667],
  1013. "8764": [-0.13313, 0.36687, 0, 0, 0.77778],
  1014. "8765": [-0.13313, 0.37788, 0, 0, 0.77778],
  1015. "8769": [-0.13313, 0.36687, 0, 0, 0.77778],
  1016. "8770": [-0.03625, 0.46375, 0, 0, 0.77778],
  1017. "8774": [0.30274, 0.79383, 0, 0, 0.77778],
  1018. "8776": [-0.01688, 0.48312, 0, 0, 0.77778],
  1019. "8778": [0.08167, 0.58167, 0, 0, 0.77778],
  1020. "8782": [0.06062, 0.54986, 0, 0, 0.77778],
  1021. "8783": [0.06062, 0.54986, 0, 0, 0.77778],
  1022. "8785": [0.08198, 0.58198, 0, 0, 0.77778],
  1023. "8786": [0.08198, 0.58198, 0, 0, 0.77778],
  1024. "8787": [0.08198, 0.58198, 0, 0, 0.77778],
  1025. "8790": [0, 0.69224, 0, 0, 0.77778],
  1026. "8791": [0.22958, 0.72958, 0, 0, 0.77778],
  1027. "8796": [0.08198, 0.91667, 0, 0, 0.77778],
  1028. "8806": [0.25583, 0.75583, 0, 0, 0.77778],
  1029. "8807": [0.25583, 0.75583, 0, 0, 0.77778],
  1030. "8808": [0.25142, 0.75726, 0, 0, 0.77778],
  1031. "8809": [0.25142, 0.75726, 0, 0, 0.77778],
  1032. "8812": [0.25583, 0.75583, 0, 0, 0.5],
  1033. "8814": [0.20576, 0.70576, 0, 0, 0.77778],
  1034. "8815": [0.20576, 0.70576, 0, 0, 0.77778],
  1035. "8816": [0.30274, 0.79383, 0, 0, 0.77778],
  1036. "8817": [0.30274, 0.79383, 0, 0, 0.77778],
  1037. "8818": [0.22958, 0.72958, 0, 0, 0.77778],
  1038. "8819": [0.22958, 0.72958, 0, 0, 0.77778],
  1039. "8822": [0.1808, 0.675, 0, 0, 0.77778],
  1040. "8823": [0.1808, 0.675, 0, 0, 0.77778],
  1041. "8828": [0.13667, 0.63667, 0, 0, 0.77778],
  1042. "8829": [0.13667, 0.63667, 0, 0, 0.77778],
  1043. "8830": [0.22958, 0.72958, 0, 0, 0.77778],
  1044. "8831": [0.22958, 0.72958, 0, 0, 0.77778],
  1045. "8832": [0.20576, 0.70576, 0, 0, 0.77778],
  1046. "8833": [0.20576, 0.70576, 0, 0, 0.77778],
  1047. "8840": [0.30274, 0.79383, 0, 0, 0.77778],
  1048. "8841": [0.30274, 0.79383, 0, 0, 0.77778],
  1049. "8842": [0.13597, 0.63597, 0, 0, 0.77778],
  1050. "8843": [0.13597, 0.63597, 0, 0, 0.77778],
  1051. "8847": [0.03517, 0.54986, 0, 0, 0.77778],
  1052. "8848": [0.03517, 0.54986, 0, 0, 0.77778],
  1053. "8858": [0.08198, 0.58198, 0, 0, 0.77778],
  1054. "8859": [0.08198, 0.58198, 0, 0, 0.77778],
  1055. "8861": [0.08198, 0.58198, 0, 0, 0.77778],
  1056. "8862": [0, 0.675, 0, 0, 0.77778],
  1057. "8863": [0, 0.675, 0, 0, 0.77778],
  1058. "8864": [0, 0.675, 0, 0, 0.77778],
  1059. "8865": [0, 0.675, 0, 0, 0.77778],
  1060. "8872": [0, 0.69224, 0, 0, 0.61111],
  1061. "8873": [0, 0.69224, 0, 0, 0.72222],
  1062. "8874": [0, 0.69224, 0, 0, 0.88889],
  1063. "8876": [0, 0.68889, 0, 0, 0.61111],
  1064. "8877": [0, 0.68889, 0, 0, 0.61111],
  1065. "8878": [0, 0.68889, 0, 0, 0.72222],
  1066. "8879": [0, 0.68889, 0, 0, 0.72222],
  1067. "8882": [0.03517, 0.54986, 0, 0, 0.77778],
  1068. "8883": [0.03517, 0.54986, 0, 0, 0.77778],
  1069. "8884": [0.13667, 0.63667, 0, 0, 0.77778],
  1070. "8885": [0.13667, 0.63667, 0, 0, 0.77778],
  1071. "8888": [0, 0.54986, 0, 0, 1.11111],
  1072. "8890": [0.19444, 0.43056, 0, 0, 0.55556],
  1073. "8891": [0.19444, 0.69224, 0, 0, 0.61111],
  1074. "8892": [0.19444, 0.69224, 0, 0, 0.61111],
  1075. "8901": [0, 0.54986, 0, 0, 0.27778],
  1076. "8903": [0.08167, 0.58167, 0, 0, 0.77778],
  1077. "8905": [0.08167, 0.58167, 0, 0, 0.77778],
  1078. "8906": [0.08167, 0.58167, 0, 0, 0.77778],
  1079. "8907": [0, 0.69224, 0, 0, 0.77778],
  1080. "8908": [0, 0.69224, 0, 0, 0.77778],
  1081. "8909": [-0.03598, 0.46402, 0, 0, 0.77778],
  1082. "8910": [0, 0.54986, 0, 0, 0.76042],
  1083. "8911": [0, 0.54986, 0, 0, 0.76042],
  1084. "8912": [0.03517, 0.54986, 0, 0, 0.77778],
  1085. "8913": [0.03517, 0.54986, 0, 0, 0.77778],
  1086. "8914": [0, 0.54986, 0, 0, 0.66667],
  1087. "8915": [0, 0.54986, 0, 0, 0.66667],
  1088. "8916": [0, 0.69224, 0, 0, 0.66667],
  1089. "8918": [0.0391, 0.5391, 0, 0, 0.77778],
  1090. "8919": [0.0391, 0.5391, 0, 0, 0.77778],
  1091. "8920": [0.03517, 0.54986, 0, 0, 1.33334],
  1092. "8921": [0.03517, 0.54986, 0, 0, 1.33334],
  1093. "8922": [0.38569, 0.88569, 0, 0, 0.77778],
  1094. "8923": [0.38569, 0.88569, 0, 0, 0.77778],
  1095. "8926": [0.13667, 0.63667, 0, 0, 0.77778],
  1096. "8927": [0.13667, 0.63667, 0, 0, 0.77778],
  1097. "8928": [0.30274, 0.79383, 0, 0, 0.77778],
  1098. "8929": [0.30274, 0.79383, 0, 0, 0.77778],
  1099. "8934": [0.23222, 0.74111, 0, 0, 0.77778],
  1100. "8935": [0.23222, 0.74111, 0, 0, 0.77778],
  1101. "8936": [0.23222, 0.74111, 0, 0, 0.77778],
  1102. "8937": [0.23222, 0.74111, 0, 0, 0.77778],
  1103. "8938": [0.20576, 0.70576, 0, 0, 0.77778],
  1104. "8939": [0.20576, 0.70576, 0, 0, 0.77778],
  1105. "8940": [0.30274, 0.79383, 0, 0, 0.77778],
  1106. "8941": [0.30274, 0.79383, 0, 0, 0.77778],
  1107. "8994": [0.19444, 0.69224, 0, 0, 0.77778],
  1108. "8995": [0.19444, 0.69224, 0, 0, 0.77778],
  1109. "9416": [0.15559, 0.69224, 0, 0, 0.90222],
  1110. "9484": [0, 0.69224, 0, 0, 0.5],
  1111. "9488": [0, 0.69224, 0, 0, 0.5],
  1112. "9492": [0, 0.37788, 0, 0, 0.5],
  1113. "9496": [0, 0.37788, 0, 0, 0.5],
  1114. "9585": [0.19444, 0.68889, 0, 0, 0.88889],
  1115. "9586": [0.19444, 0.74111, 0, 0, 0.88889],
  1116. "9632": [0, 0.675, 0, 0, 0.77778],
  1117. "9633": [0, 0.675, 0, 0, 0.77778],
  1118. "9650": [0, 0.54986, 0, 0, 0.72222],
  1119. "9651": [0, 0.54986, 0, 0, 0.72222],
  1120. "9654": [0.03517, 0.54986, 0, 0, 0.77778],
  1121. "9660": [0, 0.54986, 0, 0, 0.72222],
  1122. "9661": [0, 0.54986, 0, 0, 0.72222],
  1123. "9664": [0.03517, 0.54986, 0, 0, 0.77778],
  1124. "9674": [0.11111, 0.69224, 0, 0, 0.66667],
  1125. "9733": [0.19444, 0.69224, 0, 0, 0.94445],
  1126. "10003": [0, 0.69224, 0, 0, 0.83334],
  1127. "10016": [0, 0.69224, 0, 0, 0.83334],
  1128. "10731": [0.11111, 0.69224, 0, 0, 0.66667],
  1129. "10846": [0.19444, 0.75583, 0, 0, 0.61111],
  1130. "10877": [0.13667, 0.63667, 0, 0, 0.77778],
  1131. "10878": [0.13667, 0.63667, 0, 0, 0.77778],
  1132. "10885": [0.25583, 0.75583, 0, 0, 0.77778],
  1133. "10886": [0.25583, 0.75583, 0, 0, 0.77778],
  1134. "10887": [0.13597, 0.63597, 0, 0, 0.77778],
  1135. "10888": [0.13597, 0.63597, 0, 0, 0.77778],
  1136. "10889": [0.26167, 0.75726, 0, 0, 0.77778],
  1137. "10890": [0.26167, 0.75726, 0, 0, 0.77778],
  1138. "10891": [0.48256, 0.98256, 0, 0, 0.77778],
  1139. "10892": [0.48256, 0.98256, 0, 0, 0.77778],
  1140. "10901": [0.13667, 0.63667, 0, 0, 0.77778],
  1141. "10902": [0.13667, 0.63667, 0, 0, 0.77778],
  1142. "10933": [0.25142, 0.75726, 0, 0, 0.77778],
  1143. "10934": [0.25142, 0.75726, 0, 0, 0.77778],
  1144. "10935": [0.26167, 0.75726, 0, 0, 0.77778],
  1145. "10936": [0.26167, 0.75726, 0, 0, 0.77778],
  1146. "10937": [0.26167, 0.75726, 0, 0, 0.77778],
  1147. "10938": [0.26167, 0.75726, 0, 0, 0.77778],
  1148. "10949": [0.25583, 0.75583, 0, 0, 0.77778],
  1149. "10950": [0.25583, 0.75583, 0, 0, 0.77778],
  1150. "10955": [0.28481, 0.79383, 0, 0, 0.77778],
  1151. "10956": [0.28481, 0.79383, 0, 0, 0.77778],
  1152. "57350": [0.08167, 0.58167, 0, 0, 0.22222],
  1153. "57351": [0.08167, 0.58167, 0, 0, 0.38889],
  1154. "57352": [0.08167, 0.58167, 0, 0, 0.77778],
  1155. "57353": [0, 0.43056, 0.04028, 0, 0.66667],
  1156. "57356": [0.25142, 0.75726, 0, 0, 0.77778],
  1157. "57357": [0.25142, 0.75726, 0, 0, 0.77778],
  1158. "57358": [0.41951, 0.91951, 0, 0, 0.77778],
  1159. "57359": [0.30274, 0.79383, 0, 0, 0.77778],
  1160. "57360": [0.30274, 0.79383, 0, 0, 0.77778],
  1161. "57361": [0.41951, 0.91951, 0, 0, 0.77778],
  1162. "57366": [0.25142, 0.75726, 0, 0, 0.77778],
  1163. "57367": [0.25142, 0.75726, 0, 0, 0.77778],
  1164. "57368": [0.25142, 0.75726, 0, 0, 0.77778],
  1165. "57369": [0.25142, 0.75726, 0, 0, 0.77778],
  1166. "57370": [0.13597, 0.63597, 0, 0, 0.77778],
  1167. "57371": [0.13597, 0.63597, 0, 0, 0.77778]
  1168. },
  1169. "Caligraphic-Regular": {
  1170. "32": [0, 0, 0, 0, 0.25],
  1171. "65": [0, 0.68333, 0, 0.19445, 0.79847],
  1172. "66": [0, 0.68333, 0.03041, 0.13889, 0.65681],
  1173. "67": [0, 0.68333, 0.05834, 0.13889, 0.52653],
  1174. "68": [0, 0.68333, 0.02778, 0.08334, 0.77139],
  1175. "69": [0, 0.68333, 0.08944, 0.11111, 0.52778],
  1176. "70": [0, 0.68333, 0.09931, 0.11111, 0.71875],
  1177. "71": [0.09722, 0.68333, 0.0593, 0.11111, 0.59487],
  1178. "72": [0, 0.68333, 0.00965, 0.11111, 0.84452],
  1179. "73": [0, 0.68333, 0.07382, 0, 0.54452],
  1180. "74": [0.09722, 0.68333, 0.18472, 0.16667, 0.67778],
  1181. "75": [0, 0.68333, 0.01445, 0.05556, 0.76195],
  1182. "76": [0, 0.68333, 0, 0.13889, 0.68972],
  1183. "77": [0, 0.68333, 0, 0.13889, 1.2009],
  1184. "78": [0, 0.68333, 0.14736, 0.08334, 0.82049],
  1185. "79": [0, 0.68333, 0.02778, 0.11111, 0.79611],
  1186. "80": [0, 0.68333, 0.08222, 0.08334, 0.69556],
  1187. "81": [0.09722, 0.68333, 0, 0.11111, 0.81667],
  1188. "82": [0, 0.68333, 0, 0.08334, 0.8475],
  1189. "83": [0, 0.68333, 0.075, 0.13889, 0.60556],
  1190. "84": [0, 0.68333, 0.25417, 0, 0.54464],
  1191. "85": [0, 0.68333, 0.09931, 0.08334, 0.62583],
  1192. "86": [0, 0.68333, 0.08222, 0, 0.61278],
  1193. "87": [0, 0.68333, 0.08222, 0.08334, 0.98778],
  1194. "88": [0, 0.68333, 0.14643, 0.13889, 0.7133],
  1195. "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834],
  1196. "90": [0, 0.68333, 0.07944, 0.13889, 0.72473],
  1197. "160": [0, 0, 0, 0, 0.25]
  1198. },
  1199. "Fraktur-Regular": {
  1200. "32": [0, 0, 0, 0, 0.25],
  1201. "33": [0, 0.69141, 0, 0, 0.29574],
  1202. "34": [0, 0.69141, 0, 0, 0.21471],
  1203. "38": [0, 0.69141, 0, 0, 0.73786],
  1204. "39": [0, 0.69141, 0, 0, 0.21201],
  1205. "40": [0.24982, 0.74947, 0, 0, 0.38865],
  1206. "41": [0.24982, 0.74947, 0, 0, 0.38865],
  1207. "42": [0, 0.62119, 0, 0, 0.27764],
  1208. "43": [0.08319, 0.58283, 0, 0, 0.75623],
  1209. "44": [0, 0.10803, 0, 0, 0.27764],
  1210. "45": [0.08319, 0.58283, 0, 0, 0.75623],
  1211. "46": [0, 0.10803, 0, 0, 0.27764],
  1212. "47": [0.24982, 0.74947, 0, 0, 0.50181],
  1213. "48": [0, 0.47534, 0, 0, 0.50181],
  1214. "49": [0, 0.47534, 0, 0, 0.50181],
  1215. "50": [0, 0.47534, 0, 0, 0.50181],
  1216. "51": [0.18906, 0.47534, 0, 0, 0.50181],
  1217. "52": [0.18906, 0.47534, 0, 0, 0.50181],
  1218. "53": [0.18906, 0.47534, 0, 0, 0.50181],
  1219. "54": [0, 0.69141, 0, 0, 0.50181],
  1220. "55": [0.18906, 0.47534, 0, 0, 0.50181],
  1221. "56": [0, 0.69141, 0, 0, 0.50181],
  1222. "57": [0.18906, 0.47534, 0, 0, 0.50181],
  1223. "58": [0, 0.47534, 0, 0, 0.21606],
  1224. "59": [0.12604, 0.47534, 0, 0, 0.21606],
  1225. "61": [-0.13099, 0.36866, 0, 0, 0.75623],
  1226. "63": [0, 0.69141, 0, 0, 0.36245],
  1227. "65": [0, 0.69141, 0, 0, 0.7176],
  1228. "66": [0, 0.69141, 0, 0, 0.88397],
  1229. "67": [0, 0.69141, 0, 0, 0.61254],
  1230. "68": [0, 0.69141, 0, 0, 0.83158],
  1231. "69": [0, 0.69141, 0, 0, 0.66278],
  1232. "70": [0.12604, 0.69141, 0, 0, 0.61119],
  1233. "71": [0, 0.69141, 0, 0, 0.78539],
  1234. "72": [0.06302, 0.69141, 0, 0, 0.7203],
  1235. "73": [0, 0.69141, 0, 0, 0.55448],
  1236. "74": [0.12604, 0.69141, 0, 0, 0.55231],
  1237. "75": [0, 0.69141, 0, 0, 0.66845],
  1238. "76": [0, 0.69141, 0, 0, 0.66602],
  1239. "77": [0, 0.69141, 0, 0, 1.04953],
  1240. "78": [0, 0.69141, 0, 0, 0.83212],
  1241. "79": [0, 0.69141, 0, 0, 0.82699],
  1242. "80": [0.18906, 0.69141, 0, 0, 0.82753],
  1243. "81": [0.03781, 0.69141, 0, 0, 0.82699],
  1244. "82": [0, 0.69141, 0, 0, 0.82807],
  1245. "83": [0, 0.69141, 0, 0, 0.82861],
  1246. "84": [0, 0.69141, 0, 0, 0.66899],
  1247. "85": [0, 0.69141, 0, 0, 0.64576],
  1248. "86": [0, 0.69141, 0, 0, 0.83131],
  1249. "87": [0, 0.69141, 0, 0, 1.04602],
  1250. "88": [0, 0.69141, 0, 0, 0.71922],
  1251. "89": [0.18906, 0.69141, 0, 0, 0.83293],
  1252. "90": [0.12604, 0.69141, 0, 0, 0.60201],
  1253. "91": [0.24982, 0.74947, 0, 0, 0.27764],
  1254. "93": [0.24982, 0.74947, 0, 0, 0.27764],
  1255. "94": [0, 0.69141, 0, 0, 0.49965],
  1256. "97": [0, 0.47534, 0, 0, 0.50046],
  1257. "98": [0, 0.69141, 0, 0, 0.51315],
  1258. "99": [0, 0.47534, 0, 0, 0.38946],
  1259. "100": [0, 0.62119, 0, 0, 0.49857],
  1260. "101": [0, 0.47534, 0, 0, 0.40053],
  1261. "102": [0.18906, 0.69141, 0, 0, 0.32626],
  1262. "103": [0.18906, 0.47534, 0, 0, 0.5037],
  1263. "104": [0.18906, 0.69141, 0, 0, 0.52126],
  1264. "105": [0, 0.69141, 0, 0, 0.27899],
  1265. "106": [0, 0.69141, 0, 0, 0.28088],
  1266. "107": [0, 0.69141, 0, 0, 0.38946],
  1267. "108": [0, 0.69141, 0, 0, 0.27953],
  1268. "109": [0, 0.47534, 0, 0, 0.76676],
  1269. "110": [0, 0.47534, 0, 0, 0.52666],
  1270. "111": [0, 0.47534, 0, 0, 0.48885],
  1271. "112": [0.18906, 0.52396, 0, 0, 0.50046],
  1272. "113": [0.18906, 0.47534, 0, 0, 0.48912],
  1273. "114": [0, 0.47534, 0, 0, 0.38919],
  1274. "115": [0, 0.47534, 0, 0, 0.44266],
  1275. "116": [0, 0.62119, 0, 0, 0.33301],
  1276. "117": [0, 0.47534, 0, 0, 0.5172],
  1277. "118": [0, 0.52396, 0, 0, 0.5118],
  1278. "119": [0, 0.52396, 0, 0, 0.77351],
  1279. "120": [0.18906, 0.47534, 0, 0, 0.38865],
  1280. "121": [0.18906, 0.47534, 0, 0, 0.49884],
  1281. "122": [0.18906, 0.47534, 0, 0, 0.39054],
  1282. "160": [0, 0, 0, 0, 0.25],
  1283. "8216": [0, 0.69141, 0, 0, 0.21471],
  1284. "8217": [0, 0.69141, 0, 0, 0.21471],
  1285. "58112": [0, 0.62119, 0, 0, 0.49749],
  1286. "58113": [0, 0.62119, 0, 0, 0.4983],
  1287. "58114": [0.18906, 0.69141, 0, 0, 0.33328],
  1288. "58115": [0.18906, 0.69141, 0, 0, 0.32923],
  1289. "58116": [0.18906, 0.47534, 0, 0, 0.50343],
  1290. "58117": [0, 0.69141, 0, 0, 0.33301],
  1291. "58118": [0, 0.62119, 0, 0, 0.33409],
  1292. "58119": [0, 0.47534, 0, 0, 0.50073]
  1293. },
  1294. "Main-Bold": {
  1295. "32": [0, 0, 0, 0, 0.25],
  1296. "33": [0, 0.69444, 0, 0, 0.35],
  1297. "34": [0, 0.69444, 0, 0, 0.60278],
  1298. "35": [0.19444, 0.69444, 0, 0, 0.95833],
  1299. "36": [0.05556, 0.75, 0, 0, 0.575],
  1300. "37": [0.05556, 0.75, 0, 0, 0.95833],
  1301. "38": [0, 0.69444, 0, 0, 0.89444],
  1302. "39": [0, 0.69444, 0, 0, 0.31944],
  1303. "40": [0.25, 0.75, 0, 0, 0.44722],
  1304. "41": [0.25, 0.75, 0, 0, 0.44722],
  1305. "42": [0, 0.75, 0, 0, 0.575],
  1306. "43": [0.13333, 0.63333, 0, 0, 0.89444],
  1307. "44": [0.19444, 0.15556, 0, 0, 0.31944],
  1308. "45": [0, 0.44444, 0, 0, 0.38333],
  1309. "46": [0, 0.15556, 0, 0, 0.31944],
  1310. "47": [0.25, 0.75, 0, 0, 0.575],
  1311. "48": [0, 0.64444, 0, 0, 0.575],
  1312. "49": [0, 0.64444, 0, 0, 0.575],
  1313. "50": [0, 0.64444, 0, 0, 0.575],
  1314. "51": [0, 0.64444, 0, 0, 0.575],
  1315. "52": [0, 0.64444, 0, 0, 0.575],
  1316. "53": [0, 0.64444, 0, 0, 0.575],
  1317. "54": [0, 0.64444, 0, 0, 0.575],
  1318. "55": [0, 0.64444, 0, 0, 0.575],
  1319. "56": [0, 0.64444, 0, 0, 0.575],
  1320. "57": [0, 0.64444, 0, 0, 0.575],
  1321. "58": [0, 0.44444, 0, 0, 0.31944],
  1322. "59": [0.19444, 0.44444, 0, 0, 0.31944],
  1323. "60": [0.08556, 0.58556, 0, 0, 0.89444],
  1324. "61": [-0.10889, 0.39111, 0, 0, 0.89444],
  1325. "62": [0.08556, 0.58556, 0, 0, 0.89444],
  1326. "63": [0, 0.69444, 0, 0, 0.54305],
  1327. "64": [0, 0.69444, 0, 0, 0.89444],
  1328. "65": [0, 0.68611, 0, 0, 0.86944],
  1329. "66": [0, 0.68611, 0, 0, 0.81805],
  1330. "67": [0, 0.68611, 0, 0, 0.83055],
  1331. "68": [0, 0.68611, 0, 0, 0.88194],
  1332. "69": [0, 0.68611, 0, 0, 0.75555],
  1333. "70": [0, 0.68611, 0, 0, 0.72361],
  1334. "71": [0, 0.68611, 0, 0, 0.90416],
  1335. "72": [0, 0.68611, 0, 0, 0.9],
  1336. "73": [0, 0.68611, 0, 0, 0.43611],
  1337. "74": [0, 0.68611, 0, 0, 0.59444],
  1338. "75": [0, 0.68611, 0, 0, 0.90138],
  1339. "76": [0, 0.68611, 0, 0, 0.69166],
  1340. "77": [0, 0.68611, 0, 0, 1.09166],
  1341. "78": [0, 0.68611, 0, 0, 0.9],
  1342. "79": [0, 0.68611, 0, 0, 0.86388],
  1343. "80": [0, 0.68611, 0, 0, 0.78611],
  1344. "81": [0.19444, 0.68611, 0, 0, 0.86388],
  1345. "82": [0, 0.68611, 0, 0, 0.8625],
  1346. "83": [0, 0.68611, 0, 0, 0.63889],
  1347. "84": [0, 0.68611, 0, 0, 0.8],
  1348. "85": [0, 0.68611, 0, 0, 0.88472],
  1349. "86": [0, 0.68611, 0.01597, 0, 0.86944],
  1350. "87": [0, 0.68611, 0.01597, 0, 1.18888],
  1351. "88": [0, 0.68611, 0, 0, 0.86944],
  1352. "89": [0, 0.68611, 0.02875, 0, 0.86944],
  1353. "90": [0, 0.68611, 0, 0, 0.70277],
  1354. "91": [0.25, 0.75, 0, 0, 0.31944],
  1355. "92": [0.25, 0.75, 0, 0, 0.575],
  1356. "93": [0.25, 0.75, 0, 0, 0.31944],
  1357. "94": [0, 0.69444, 0, 0, 0.575],
  1358. "95": [0.31, 0.13444, 0.03194, 0, 0.575],
  1359. "97": [0, 0.44444, 0, 0, 0.55902],
  1360. "98": [0, 0.69444, 0, 0, 0.63889],
  1361. "99": [0, 0.44444, 0, 0, 0.51111],
  1362. "100": [0, 0.69444, 0, 0, 0.63889],
  1363. "101": [0, 0.44444, 0, 0, 0.52708],
  1364. "102": [0, 0.69444, 0.10903, 0, 0.35139],
  1365. "103": [0.19444, 0.44444, 0.01597, 0, 0.575],
  1366. "104": [0, 0.69444, 0, 0, 0.63889],
  1367. "105": [0, 0.69444, 0, 0, 0.31944],
  1368. "106": [0.19444, 0.69444, 0, 0, 0.35139],
  1369. "107": [0, 0.69444, 0, 0, 0.60694],
  1370. "108": [0, 0.69444, 0, 0, 0.31944],
  1371. "109": [0, 0.44444, 0, 0, 0.95833],
  1372. "110": [0, 0.44444, 0, 0, 0.63889],
  1373. "111": [0, 0.44444, 0, 0, 0.575],
  1374. "112": [0.19444, 0.44444, 0, 0, 0.63889],
  1375. "113": [0.19444, 0.44444, 0, 0, 0.60694],
  1376. "114": [0, 0.44444, 0, 0, 0.47361],
  1377. "115": [0, 0.44444, 0, 0, 0.45361],
  1378. "116": [0, 0.63492, 0, 0, 0.44722],
  1379. "117": [0, 0.44444, 0, 0, 0.63889],
  1380. "118": [0, 0.44444, 0.01597, 0, 0.60694],
  1381. "119": [0, 0.44444, 0.01597, 0, 0.83055],
  1382. "120": [0, 0.44444, 0, 0, 0.60694],
  1383. "121": [0.19444, 0.44444, 0.01597, 0, 0.60694],
  1384. "122": [0, 0.44444, 0, 0, 0.51111],
  1385. "123": [0.25, 0.75, 0, 0, 0.575],
  1386. "124": [0.25, 0.75, 0, 0, 0.31944],
  1387. "125": [0.25, 0.75, 0, 0, 0.575],
  1388. "126": [0.35, 0.34444, 0, 0, 0.575],
  1389. "160": [0, 0, 0, 0, 0.25],
  1390. "163": [0, 0.69444, 0, 0, 0.86853],
  1391. "168": [0, 0.69444, 0, 0, 0.575],
  1392. "172": [0, 0.44444, 0, 0, 0.76666],
  1393. "176": [0, 0.69444, 0, 0, 0.86944],
  1394. "177": [0.13333, 0.63333, 0, 0, 0.89444],
  1395. "184": [0.17014, 0, 0, 0, 0.51111],
  1396. "198": [0, 0.68611, 0, 0, 1.04166],
  1397. "215": [0.13333, 0.63333, 0, 0, 0.89444],
  1398. "216": [0.04861, 0.73472, 0, 0, 0.89444],
  1399. "223": [0, 0.69444, 0, 0, 0.59722],
  1400. "230": [0, 0.44444, 0, 0, 0.83055],
  1401. "247": [0.13333, 0.63333, 0, 0, 0.89444],
  1402. "248": [0.09722, 0.54167, 0, 0, 0.575],
  1403. "305": [0, 0.44444, 0, 0, 0.31944],
  1404. "338": [0, 0.68611, 0, 0, 1.16944],
  1405. "339": [0, 0.44444, 0, 0, 0.89444],
  1406. "567": [0.19444, 0.44444, 0, 0, 0.35139],
  1407. "710": [0, 0.69444, 0, 0, 0.575],
  1408. "711": [0, 0.63194, 0, 0, 0.575],
  1409. "713": [0, 0.59611, 0, 0, 0.575],
  1410. "714": [0, 0.69444, 0, 0, 0.575],
  1411. "715": [0, 0.69444, 0, 0, 0.575],
  1412. "728": [0, 0.69444, 0, 0, 0.575],
  1413. "729": [0, 0.69444, 0, 0, 0.31944],
  1414. "730": [0, 0.69444, 0, 0, 0.86944],
  1415. "732": [0, 0.69444, 0, 0, 0.575],
  1416. "733": [0, 0.69444, 0, 0, 0.575],
  1417. "915": [0, 0.68611, 0, 0, 0.69166],
  1418. "916": [0, 0.68611, 0, 0, 0.95833],
  1419. "920": [0, 0.68611, 0, 0, 0.89444],
  1420. "923": [0, 0.68611, 0, 0, 0.80555],
  1421. "926": [0, 0.68611, 0, 0, 0.76666],
  1422. "928": [0, 0.68611, 0, 0, 0.9],
  1423. "931": [0, 0.68611, 0, 0, 0.83055],
  1424. "933": [0, 0.68611, 0, 0, 0.89444],
  1425. "934": [0, 0.68611, 0, 0, 0.83055],
  1426. "936": [0, 0.68611, 0, 0, 0.89444],
  1427. "937": [0, 0.68611, 0, 0, 0.83055],
  1428. "8211": [0, 0.44444, 0.03194, 0, 0.575],
  1429. "8212": [0, 0.44444, 0.03194, 0, 1.14999],
  1430. "8216": [0, 0.69444, 0, 0, 0.31944],
  1431. "8217": [0, 0.69444, 0, 0, 0.31944],
  1432. "8220": [0, 0.69444, 0, 0, 0.60278],
  1433. "8221": [0, 0.69444, 0, 0, 0.60278],
  1434. "8224": [0.19444, 0.69444, 0, 0, 0.51111],
  1435. "8225": [0.19444, 0.69444, 0, 0, 0.51111],
  1436. "8242": [0, 0.55556, 0, 0, 0.34444],
  1437. "8407": [0, 0.72444, 0.15486, 0, 0.575],
  1438. "8463": [0, 0.69444, 0, 0, 0.66759],
  1439. "8465": [0, 0.69444, 0, 0, 0.83055],
  1440. "8467": [0, 0.69444, 0, 0, 0.47361],
  1441. "8472": [0.19444, 0.44444, 0, 0, 0.74027],
  1442. "8476": [0, 0.69444, 0, 0, 0.83055],
  1443. "8501": [0, 0.69444, 0, 0, 0.70277],
  1444. "8592": [-0.10889, 0.39111, 0, 0, 1.14999],
  1445. "8593": [0.19444, 0.69444, 0, 0, 0.575],
  1446. "8594": [-0.10889, 0.39111, 0, 0, 1.14999],
  1447. "8595": [0.19444, 0.69444, 0, 0, 0.575],
  1448. "8596": [-0.10889, 0.39111, 0, 0, 1.14999],
  1449. "8597": [0.25, 0.75, 0, 0, 0.575],
  1450. "8598": [0.19444, 0.69444, 0, 0, 1.14999],
  1451. "8599": [0.19444, 0.69444, 0, 0, 1.14999],
  1452. "8600": [0.19444, 0.69444, 0, 0, 1.14999],
  1453. "8601": [0.19444, 0.69444, 0, 0, 1.14999],
  1454. "8636": [-0.10889, 0.39111, 0, 0, 1.14999],
  1455. "8637": [-0.10889, 0.39111, 0, 0, 1.14999],
  1456. "8640": [-0.10889, 0.39111, 0, 0, 1.14999],
  1457. "8641": [-0.10889, 0.39111, 0, 0, 1.14999],
  1458. "8656": [-0.10889, 0.39111, 0, 0, 1.14999],
  1459. "8657": [0.19444, 0.69444, 0, 0, 0.70277],
  1460. "8658": [-0.10889, 0.39111, 0, 0, 1.14999],
  1461. "8659": [0.19444, 0.69444, 0, 0, 0.70277],
  1462. "8660": [-0.10889, 0.39111, 0, 0, 1.14999],
  1463. "8661": [0.25, 0.75, 0, 0, 0.70277],
  1464. "8704": [0, 0.69444, 0, 0, 0.63889],
  1465. "8706": [0, 0.69444, 0.06389, 0, 0.62847],
  1466. "8707": [0, 0.69444, 0, 0, 0.63889],
  1467. "8709": [0.05556, 0.75, 0, 0, 0.575],
  1468. "8711": [0, 0.68611, 0, 0, 0.95833],
  1469. "8712": [0.08556, 0.58556, 0, 0, 0.76666],
  1470. "8715": [0.08556, 0.58556, 0, 0, 0.76666],
  1471. "8722": [0.13333, 0.63333, 0, 0, 0.89444],
  1472. "8723": [0.13333, 0.63333, 0, 0, 0.89444],
  1473. "8725": [0.25, 0.75, 0, 0, 0.575],
  1474. "8726": [0.25, 0.75, 0, 0, 0.575],
  1475. "8727": [-0.02778, 0.47222, 0, 0, 0.575],
  1476. "8728": [-0.02639, 0.47361, 0, 0, 0.575],
  1477. "8729": [-0.02639, 0.47361, 0, 0, 0.575],
  1478. "8730": [0.18, 0.82, 0, 0, 0.95833],
  1479. "8733": [0, 0.44444, 0, 0, 0.89444],
  1480. "8734": [0, 0.44444, 0, 0, 1.14999],
  1481. "8736": [0, 0.69224, 0, 0, 0.72222],
  1482. "8739": [0.25, 0.75, 0, 0, 0.31944],
  1483. "8741": [0.25, 0.75, 0, 0, 0.575],
  1484. "8743": [0, 0.55556, 0, 0, 0.76666],
  1485. "8744": [0, 0.55556, 0, 0, 0.76666],
  1486. "8745": [0, 0.55556, 0, 0, 0.76666],
  1487. "8746": [0, 0.55556, 0, 0, 0.76666],
  1488. "8747": [0.19444, 0.69444, 0.12778, 0, 0.56875],
  1489. "8764": [-0.10889, 0.39111, 0, 0, 0.89444],
  1490. "8768": [0.19444, 0.69444, 0, 0, 0.31944],
  1491. "8771": [0.00222, 0.50222, 0, 0, 0.89444],
  1492. "8773": [0.027, 0.638, 0, 0, 0.894],
  1493. "8776": [0.02444, 0.52444, 0, 0, 0.89444],
  1494. "8781": [0.00222, 0.50222, 0, 0, 0.89444],
  1495. "8801": [0.00222, 0.50222, 0, 0, 0.89444],
  1496. "8804": [0.19667, 0.69667, 0, 0, 0.89444],
  1497. "8805": [0.19667, 0.69667, 0, 0, 0.89444],
  1498. "8810": [0.08556, 0.58556, 0, 0, 1.14999],
  1499. "8811": [0.08556, 0.58556, 0, 0, 1.14999],
  1500. "8826": [0.08556, 0.58556, 0, 0, 0.89444],
  1501. "8827": [0.08556, 0.58556, 0, 0, 0.89444],
  1502. "8834": [0.08556, 0.58556, 0, 0, 0.89444],
  1503. "8835": [0.08556, 0.58556, 0, 0, 0.89444],
  1504. "8838": [0.19667, 0.69667, 0, 0, 0.89444],
  1505. "8839": [0.19667, 0.69667, 0, 0, 0.89444],
  1506. "8846": [0, 0.55556, 0, 0, 0.76666],
  1507. "8849": [0.19667, 0.69667, 0, 0, 0.89444],
  1508. "8850": [0.19667, 0.69667, 0, 0, 0.89444],
  1509. "8851": [0, 0.55556, 0, 0, 0.76666],
  1510. "8852": [0, 0.55556, 0, 0, 0.76666],
  1511. "8853": [0.13333, 0.63333, 0, 0, 0.89444],
  1512. "8854": [0.13333, 0.63333, 0, 0, 0.89444],
  1513. "8855": [0.13333, 0.63333, 0, 0, 0.89444],
  1514. "8856": [0.13333, 0.63333, 0, 0, 0.89444],
  1515. "8857": [0.13333, 0.63333, 0, 0, 0.89444],
  1516. "8866": [0, 0.69444, 0, 0, 0.70277],
  1517. "8867": [0, 0.69444, 0, 0, 0.70277],
  1518. "8868": [0, 0.69444, 0, 0, 0.89444],
  1519. "8869": [0, 0.69444, 0, 0, 0.89444],
  1520. "8900": [-0.02639, 0.47361, 0, 0, 0.575],
  1521. "8901": [-0.02639, 0.47361, 0, 0, 0.31944],
  1522. "8902": [-0.02778, 0.47222, 0, 0, 0.575],
  1523. "8968": [0.25, 0.75, 0, 0, 0.51111],
  1524. "8969": [0.25, 0.75, 0, 0, 0.51111],
  1525. "8970": [0.25, 0.75, 0, 0, 0.51111],
  1526. "8971": [0.25, 0.75, 0, 0, 0.51111],
  1527. "8994": [-0.13889, 0.36111, 0, 0, 1.14999],
  1528. "8995": [-0.13889, 0.36111, 0, 0, 1.14999],
  1529. "9651": [0.19444, 0.69444, 0, 0, 1.02222],
  1530. "9657": [-0.02778, 0.47222, 0, 0, 0.575],
  1531. "9661": [0.19444, 0.69444, 0, 0, 1.02222],
  1532. "9667": [-0.02778, 0.47222, 0, 0, 0.575],
  1533. "9711": [0.19444, 0.69444, 0, 0, 1.14999],
  1534. "9824": [0.12963, 0.69444, 0, 0, 0.89444],
  1535. "9825": [0.12963, 0.69444, 0, 0, 0.89444],
  1536. "9826": [0.12963, 0.69444, 0, 0, 0.89444],
  1537. "9827": [0.12963, 0.69444, 0, 0, 0.89444],
  1538. "9837": [0, 0.75, 0, 0, 0.44722],
  1539. "9838": [0.19444, 0.69444, 0, 0, 0.44722],
  1540. "9839": [0.19444, 0.69444, 0, 0, 0.44722],
  1541. "10216": [0.25, 0.75, 0, 0, 0.44722],
  1542. "10217": [0.25, 0.75, 0, 0, 0.44722],
  1543. "10815": [0, 0.68611, 0, 0, 0.9],
  1544. "10927": [0.19667, 0.69667, 0, 0, 0.89444],
  1545. "10928": [0.19667, 0.69667, 0, 0, 0.89444],
  1546. "57376": [0.19444, 0.69444, 0, 0, 0]
  1547. },
  1548. "Main-BoldItalic": {
  1549. "32": [0, 0, 0, 0, 0.25],
  1550. "33": [0, 0.69444, 0.11417, 0, 0.38611],
  1551. "34": [0, 0.69444, 0.07939, 0, 0.62055],
  1552. "35": [0.19444, 0.69444, 0.06833, 0, 0.94444],
  1553. "37": [0.05556, 0.75, 0.12861, 0, 0.94444],
  1554. "38": [0, 0.69444, 0.08528, 0, 0.88555],
  1555. "39": [0, 0.69444, 0.12945, 0, 0.35555],
  1556. "40": [0.25, 0.75, 0.15806, 0, 0.47333],
  1557. "41": [0.25, 0.75, 0.03306, 0, 0.47333],
  1558. "42": [0, 0.75, 0.14333, 0, 0.59111],
  1559. "43": [0.10333, 0.60333, 0.03306, 0, 0.88555],
  1560. "44": [0.19444, 0.14722, 0, 0, 0.35555],
  1561. "45": [0, 0.44444, 0.02611, 0, 0.41444],
  1562. "46": [0, 0.14722, 0, 0, 0.35555],
  1563. "47": [0.25, 0.75, 0.15806, 0, 0.59111],
  1564. "48": [0, 0.64444, 0.13167, 0, 0.59111],
  1565. "49": [0, 0.64444, 0.13167, 0, 0.59111],
  1566. "50": [0, 0.64444, 0.13167, 0, 0.59111],
  1567. "51": [0, 0.64444, 0.13167, 0, 0.59111],
  1568. "52": [0.19444, 0.64444, 0.13167, 0, 0.59111],
  1569. "53": [0, 0.64444, 0.13167, 0, 0.59111],
  1570. "54": [0, 0.64444, 0.13167, 0, 0.59111],
  1571. "55": [0.19444, 0.64444, 0.13167, 0, 0.59111],
  1572. "56": [0, 0.64444, 0.13167, 0, 0.59111],
  1573. "57": [0, 0.64444, 0.13167, 0, 0.59111],
  1574. "58": [0, 0.44444, 0.06695, 0, 0.35555],
  1575. "59": [0.19444, 0.44444, 0.06695, 0, 0.35555],
  1576. "61": [-0.10889, 0.39111, 0.06833, 0, 0.88555],
  1577. "63": [0, 0.69444, 0.11472, 0, 0.59111],
  1578. "64": [0, 0.69444, 0.09208, 0, 0.88555],
  1579. "65": [0, 0.68611, 0, 0, 0.86555],
  1580. "66": [0, 0.68611, 0.0992, 0, 0.81666],
  1581. "67": [0, 0.68611, 0.14208, 0, 0.82666],
  1582. "68": [0, 0.68611, 0.09062, 0, 0.87555],
  1583. "69": [0, 0.68611, 0.11431, 0, 0.75666],
  1584. "70": [0, 0.68611, 0.12903, 0, 0.72722],
  1585. "71": [0, 0.68611, 0.07347, 0, 0.89527],
  1586. "72": [0, 0.68611, 0.17208, 0, 0.8961],
  1587. "73": [0, 0.68611, 0.15681, 0, 0.47166],
  1588. "74": [0, 0.68611, 0.145, 0, 0.61055],
  1589. "75": [0, 0.68611, 0.14208, 0, 0.89499],
  1590. "76": [0, 0.68611, 0, 0, 0.69777],
  1591. "77": [0, 0.68611, 0.17208, 0, 1.07277],
  1592. "78": [0, 0.68611, 0.17208, 0, 0.8961],
  1593. "79": [0, 0.68611, 0.09062, 0, 0.85499],
  1594. "80": [0, 0.68611, 0.0992, 0, 0.78721],
  1595. "81": [0.19444, 0.68611, 0.09062, 0, 0.85499],
  1596. "82": [0, 0.68611, 0.02559, 0, 0.85944],
  1597. "83": [0, 0.68611, 0.11264, 0, 0.64999],
  1598. "84": [0, 0.68611, 0.12903, 0, 0.7961],
  1599. "85": [0, 0.68611, 0.17208, 0, 0.88083],
  1600. "86": [0, 0.68611, 0.18625, 0, 0.86555],
  1601. "87": [0, 0.68611, 0.18625, 0, 1.15999],
  1602. "88": [0, 0.68611, 0.15681, 0, 0.86555],
  1603. "89": [0, 0.68611, 0.19803, 0, 0.86555],
  1604. "90": [0, 0.68611, 0.14208, 0, 0.70888],
  1605. "91": [0.25, 0.75, 0.1875, 0, 0.35611],
  1606. "93": [0.25, 0.75, 0.09972, 0, 0.35611],
  1607. "94": [0, 0.69444, 0.06709, 0, 0.59111],
  1608. "95": [0.31, 0.13444, 0.09811, 0, 0.59111],
  1609. "97": [0, 0.44444, 0.09426, 0, 0.59111],
  1610. "98": [0, 0.69444, 0.07861, 0, 0.53222],
  1611. "99": [0, 0.44444, 0.05222, 0, 0.53222],
  1612. "100": [0, 0.69444, 0.10861, 0, 0.59111],
  1613. "101": [0, 0.44444, 0.085, 0, 0.53222],
  1614. "102": [0.19444, 0.69444, 0.21778, 0, 0.4],
  1615. "103": [0.19444, 0.44444, 0.105, 0, 0.53222],
  1616. "104": [0, 0.69444, 0.09426, 0, 0.59111],
  1617. "105": [0, 0.69326, 0.11387, 0, 0.35555],
  1618. "106": [0.19444, 0.69326, 0.1672, 0, 0.35555],
  1619. "107": [0, 0.69444, 0.11111, 0, 0.53222],
  1620. "108": [0, 0.69444, 0.10861, 0, 0.29666],
  1621. "109": [0, 0.44444, 0.09426, 0, 0.94444],
  1622. "110": [0, 0.44444, 0.09426, 0, 0.64999],
  1623. "111": [0, 0.44444, 0.07861, 0, 0.59111],
  1624. "112": [0.19444, 0.44444, 0.07861, 0, 0.59111],
  1625. "113": [0.19444, 0.44444, 0.105, 0, 0.53222],
  1626. "114": [0, 0.44444, 0.11111, 0, 0.50167],
  1627. "115": [0, 0.44444, 0.08167, 0, 0.48694],
  1628. "116": [0, 0.63492, 0.09639, 0, 0.385],
  1629. "117": [0, 0.44444, 0.09426, 0, 0.62055],
  1630. "118": [0, 0.44444, 0.11111, 0, 0.53222],
  1631. "119": [0, 0.44444, 0.11111, 0, 0.76777],
  1632. "120": [0, 0.44444, 0.12583, 0, 0.56055],
  1633. "121": [0.19444, 0.44444, 0.105, 0, 0.56166],
  1634. "122": [0, 0.44444, 0.13889, 0, 0.49055],
  1635. "126": [0.35, 0.34444, 0.11472, 0, 0.59111],
  1636. "160": [0, 0, 0, 0, 0.25],
  1637. "168": [0, 0.69444, 0.11473, 0, 0.59111],
  1638. "176": [0, 0.69444, 0, 0, 0.94888],
  1639. "184": [0.17014, 0, 0, 0, 0.53222],
  1640. "198": [0, 0.68611, 0.11431, 0, 1.02277],
  1641. "216": [0.04861, 0.73472, 0.09062, 0, 0.88555],
  1642. "223": [0.19444, 0.69444, 0.09736, 0, 0.665],
  1643. "230": [0, 0.44444, 0.085, 0, 0.82666],
  1644. "248": [0.09722, 0.54167, 0.09458, 0, 0.59111],
  1645. "305": [0, 0.44444, 0.09426, 0, 0.35555],
  1646. "338": [0, 0.68611, 0.11431, 0, 1.14054],
  1647. "339": [0, 0.44444, 0.085, 0, 0.82666],
  1648. "567": [0.19444, 0.44444, 0.04611, 0, 0.385],
  1649. "710": [0, 0.69444, 0.06709, 0, 0.59111],
  1650. "711": [0, 0.63194, 0.08271, 0, 0.59111],
  1651. "713": [0, 0.59444, 0.10444, 0, 0.59111],
  1652. "714": [0, 0.69444, 0.08528, 0, 0.59111],
  1653. "715": [0, 0.69444, 0, 0, 0.59111],
  1654. "728": [0, 0.69444, 0.10333, 0, 0.59111],
  1655. "729": [0, 0.69444, 0.12945, 0, 0.35555],
  1656. "730": [0, 0.69444, 0, 0, 0.94888],
  1657. "732": [0, 0.69444, 0.11472, 0, 0.59111],
  1658. "733": [0, 0.69444, 0.11472, 0, 0.59111],
  1659. "915": [0, 0.68611, 0.12903, 0, 0.69777],
  1660. "916": [0, 0.68611, 0, 0, 0.94444],
  1661. "920": [0, 0.68611, 0.09062, 0, 0.88555],
  1662. "923": [0, 0.68611, 0, 0, 0.80666],
  1663. "926": [0, 0.68611, 0.15092, 0, 0.76777],
  1664. "928": [0, 0.68611, 0.17208, 0, 0.8961],
  1665. "931": [0, 0.68611, 0.11431, 0, 0.82666],
  1666. "933": [0, 0.68611, 0.10778, 0, 0.88555],
  1667. "934": [0, 0.68611, 0.05632, 0, 0.82666],
  1668. "936": [0, 0.68611, 0.10778, 0, 0.88555],
  1669. "937": [0, 0.68611, 0.0992, 0, 0.82666],
  1670. "8211": [0, 0.44444, 0.09811, 0, 0.59111],
  1671. "8212": [0, 0.44444, 0.09811, 0, 1.18221],
  1672. "8216": [0, 0.69444, 0.12945, 0, 0.35555],
  1673. "8217": [0, 0.69444, 0.12945, 0, 0.35555],
  1674. "8220": [0, 0.69444, 0.16772, 0, 0.62055],
  1675. "8221": [0, 0.69444, 0.07939, 0, 0.62055]
  1676. },
  1677. "Main-Italic": {
  1678. "32": [0, 0, 0, 0, 0.25],
  1679. "33": [0, 0.69444, 0.12417, 0, 0.30667],
  1680. "34": [0, 0.69444, 0.06961, 0, 0.51444],
  1681. "35": [0.19444, 0.69444, 0.06616, 0, 0.81777],
  1682. "37": [0.05556, 0.75, 0.13639, 0, 0.81777],
  1683. "38": [0, 0.69444, 0.09694, 0, 0.76666],
  1684. "39": [0, 0.69444, 0.12417, 0, 0.30667],
  1685. "40": [0.25, 0.75, 0.16194, 0, 0.40889],
  1686. "41": [0.25, 0.75, 0.03694, 0, 0.40889],
  1687. "42": [0, 0.75, 0.14917, 0, 0.51111],
  1688. "43": [0.05667, 0.56167, 0.03694, 0, 0.76666],
  1689. "44": [0.19444, 0.10556, 0, 0, 0.30667],
  1690. "45": [0, 0.43056, 0.02826, 0, 0.35778],
  1691. "46": [0, 0.10556, 0, 0, 0.30667],
  1692. "47": [0.25, 0.75, 0.16194, 0, 0.51111],
  1693. "48": [0, 0.64444, 0.13556, 0, 0.51111],
  1694. "49": [0, 0.64444, 0.13556, 0, 0.51111],
  1695. "50": [0, 0.64444, 0.13556, 0, 0.51111],
  1696. "51": [0, 0.64444, 0.13556, 0, 0.51111],
  1697. "52": [0.19444, 0.64444, 0.13556, 0, 0.51111],
  1698. "53": [0, 0.64444, 0.13556, 0, 0.51111],
  1699. "54": [0, 0.64444, 0.13556, 0, 0.51111],
  1700. "55": [0.19444, 0.64444, 0.13556, 0, 0.51111],
  1701. "56": [0, 0.64444, 0.13556, 0, 0.51111],
  1702. "57": [0, 0.64444, 0.13556, 0, 0.51111],
  1703. "58": [0, 0.43056, 0.0582, 0, 0.30667],
  1704. "59": [0.19444, 0.43056, 0.0582, 0, 0.30667],
  1705. "61": [-0.13313, 0.36687, 0.06616, 0, 0.76666],
  1706. "63": [0, 0.69444, 0.1225, 0, 0.51111],
  1707. "64": [0, 0.69444, 0.09597, 0, 0.76666],
  1708. "65": [0, 0.68333, 0, 0, 0.74333],
  1709. "66": [0, 0.68333, 0.10257, 0, 0.70389],
  1710. "67": [0, 0.68333, 0.14528, 0, 0.71555],
  1711. "68": [0, 0.68333, 0.09403, 0, 0.755],
  1712. "69": [0, 0.68333, 0.12028, 0, 0.67833],
  1713. "70": [0, 0.68333, 0.13305, 0, 0.65277],
  1714. "71": [0, 0.68333, 0.08722, 0, 0.77361],
  1715. "72": [0, 0.68333, 0.16389, 0, 0.74333],
  1716. "73": [0, 0.68333, 0.15806, 0, 0.38555],
  1717. "74": [0, 0.68333, 0.14028, 0, 0.525],
  1718. "75": [0, 0.68333, 0.14528, 0, 0.76888],
  1719. "76": [0, 0.68333, 0, 0, 0.62722],
  1720. "77": [0, 0.68333, 0.16389, 0, 0.89666],
  1721. "78": [0, 0.68333, 0.16389, 0, 0.74333],
  1722. "79": [0, 0.68333, 0.09403, 0, 0.76666],
  1723. "80": [0, 0.68333, 0.10257, 0, 0.67833],
  1724. "81": [0.19444, 0.68333, 0.09403, 0, 0.76666],
  1725. "82": [0, 0.68333, 0.03868, 0, 0.72944],
  1726. "83": [0, 0.68333, 0.11972, 0, 0.56222],
  1727. "84": [0, 0.68333, 0.13305, 0, 0.71555],
  1728. "85": [0, 0.68333, 0.16389, 0, 0.74333],
  1729. "86": [0, 0.68333, 0.18361, 0, 0.74333],
  1730. "87": [0, 0.68333, 0.18361, 0, 0.99888],
  1731. "88": [0, 0.68333, 0.15806, 0, 0.74333],
  1732. "89": [0, 0.68333, 0.19383, 0, 0.74333],
  1733. "90": [0, 0.68333, 0.14528, 0, 0.61333],
  1734. "91": [0.25, 0.75, 0.1875, 0, 0.30667],
  1735. "93": [0.25, 0.75, 0.10528, 0, 0.30667],
  1736. "94": [0, 0.69444, 0.06646, 0, 0.51111],
  1737. "95": [0.31, 0.12056, 0.09208, 0, 0.51111],
  1738. "97": [0, 0.43056, 0.07671, 0, 0.51111],
  1739. "98": [0, 0.69444, 0.06312, 0, 0.46],
  1740. "99": [0, 0.43056, 0.05653, 0, 0.46],
  1741. "100": [0, 0.69444, 0.10333, 0, 0.51111],
  1742. "101": [0, 0.43056, 0.07514, 0, 0.46],
  1743. "102": [0.19444, 0.69444, 0.21194, 0, 0.30667],
  1744. "103": [0.19444, 0.43056, 0.08847, 0, 0.46],
  1745. "104": [0, 0.69444, 0.07671, 0, 0.51111],
  1746. "105": [0, 0.65536, 0.1019, 0, 0.30667],
  1747. "106": [0.19444, 0.65536, 0.14467, 0, 0.30667],
  1748. "107": [0, 0.69444, 0.10764, 0, 0.46],
  1749. "108": [0, 0.69444, 0.10333, 0, 0.25555],
  1750. "109": [0, 0.43056, 0.07671, 0, 0.81777],
  1751. "110": [0, 0.43056, 0.07671, 0, 0.56222],
  1752. "111": [0, 0.43056, 0.06312, 0, 0.51111],
  1753. "112": [0.19444, 0.43056, 0.06312, 0, 0.51111],
  1754. "113": [0.19444, 0.43056, 0.08847, 0, 0.46],
  1755. "114": [0, 0.43056, 0.10764, 0, 0.42166],
  1756. "115": [0, 0.43056, 0.08208, 0, 0.40889],
  1757. "116": [0, 0.61508, 0.09486, 0, 0.33222],
  1758. "117": [0, 0.43056, 0.07671, 0, 0.53666],
  1759. "118": [0, 0.43056, 0.10764, 0, 0.46],
  1760. "119": [0, 0.43056, 0.10764, 0, 0.66444],
  1761. "120": [0, 0.43056, 0.12042, 0, 0.46389],
  1762. "121": [0.19444, 0.43056, 0.08847, 0, 0.48555],
  1763. "122": [0, 0.43056, 0.12292, 0, 0.40889],
  1764. "126": [0.35, 0.31786, 0.11585, 0, 0.51111],
  1765. "160": [0, 0, 0, 0, 0.25],
  1766. "168": [0, 0.66786, 0.10474, 0, 0.51111],
  1767. "176": [0, 0.69444, 0, 0, 0.83129],
  1768. "184": [0.17014, 0, 0, 0, 0.46],
  1769. "198": [0, 0.68333, 0.12028, 0, 0.88277],
  1770. "216": [0.04861, 0.73194, 0.09403, 0, 0.76666],
  1771. "223": [0.19444, 0.69444, 0.10514, 0, 0.53666],
  1772. "230": [0, 0.43056, 0.07514, 0, 0.71555],
  1773. "248": [0.09722, 0.52778, 0.09194, 0, 0.51111],
  1774. "338": [0, 0.68333, 0.12028, 0, 0.98499],
  1775. "339": [0, 0.43056, 0.07514, 0, 0.71555],
  1776. "710": [0, 0.69444, 0.06646, 0, 0.51111],
  1777. "711": [0, 0.62847, 0.08295, 0, 0.51111],
  1778. "713": [0, 0.56167, 0.10333, 0, 0.51111],
  1779. "714": [0, 0.69444, 0.09694, 0, 0.51111],
  1780. "715": [0, 0.69444, 0, 0, 0.51111],
  1781. "728": [0, 0.69444, 0.10806, 0, 0.51111],
  1782. "729": [0, 0.66786, 0.11752, 0, 0.30667],
  1783. "730": [0, 0.69444, 0, 0, 0.83129],
  1784. "732": [0, 0.66786, 0.11585, 0, 0.51111],
  1785. "733": [0, 0.69444, 0.1225, 0, 0.51111],
  1786. "915": [0, 0.68333, 0.13305, 0, 0.62722],
  1787. "916": [0, 0.68333, 0, 0, 0.81777],
  1788. "920": [0, 0.68333, 0.09403, 0, 0.76666],
  1789. "923": [0, 0.68333, 0, 0, 0.69222],
  1790. "926": [0, 0.68333, 0.15294, 0, 0.66444],
  1791. "928": [0, 0.68333, 0.16389, 0, 0.74333],
  1792. "931": [0, 0.68333, 0.12028, 0, 0.71555],
  1793. "933": [0, 0.68333, 0.11111, 0, 0.76666],
  1794. "934": [0, 0.68333, 0.05986, 0, 0.71555],
  1795. "936": [0, 0.68333, 0.11111, 0, 0.76666],
  1796. "937": [0, 0.68333, 0.10257, 0, 0.71555],
  1797. "8211": [0, 0.43056, 0.09208, 0, 0.51111],
  1798. "8212": [0, 0.43056, 0.09208, 0, 1.02222],
  1799. "8216": [0, 0.69444, 0.12417, 0, 0.30667],
  1800. "8217": [0, 0.69444, 0.12417, 0, 0.30667],
  1801. "8220": [0, 0.69444, 0.1685, 0, 0.51444],
  1802. "8221": [0, 0.69444, 0.06961, 0, 0.51444],
  1803. "8463": [0, 0.68889, 0, 0, 0.54028]
  1804. },
  1805. "Main-Regular": {
  1806. "32": [0, 0, 0, 0, 0.25],
  1807. "33": [0, 0.69444, 0, 0, 0.27778],
  1808. "34": [0, 0.69444, 0, 0, 0.5],
  1809. "35": [0.19444, 0.69444, 0, 0, 0.83334],
  1810. "36": [0.05556, 0.75, 0, 0, 0.5],
  1811. "37": [0.05556, 0.75, 0, 0, 0.83334],
  1812. "38": [0, 0.69444, 0, 0, 0.77778],
  1813. "39": [0, 0.69444, 0, 0, 0.27778],
  1814. "40": [0.25, 0.75, 0, 0, 0.38889],
  1815. "41": [0.25, 0.75, 0, 0, 0.38889],
  1816. "42": [0, 0.75, 0, 0, 0.5],
  1817. "43": [0.08333, 0.58333, 0, 0, 0.77778],
  1818. "44": [0.19444, 0.10556, 0, 0, 0.27778],
  1819. "45": [0, 0.43056, 0, 0, 0.33333],
  1820. "46": [0, 0.10556, 0, 0, 0.27778],
  1821. "47": [0.25, 0.75, 0, 0, 0.5],
  1822. "48": [0, 0.64444, 0, 0, 0.5],
  1823. "49": [0, 0.64444, 0, 0, 0.5],
  1824. "50": [0, 0.64444, 0, 0, 0.5],
  1825. "51": [0, 0.64444, 0, 0, 0.5],
  1826. "52": [0, 0.64444, 0, 0, 0.5],
  1827. "53": [0, 0.64444, 0, 0, 0.5],
  1828. "54": [0, 0.64444, 0, 0, 0.5],
  1829. "55": [0, 0.64444, 0, 0, 0.5],
  1830. "56": [0, 0.64444, 0, 0, 0.5],
  1831. "57": [0, 0.64444, 0, 0, 0.5],
  1832. "58": [0, 0.43056, 0, 0, 0.27778],
  1833. "59": [0.19444, 0.43056, 0, 0, 0.27778],
  1834. "60": [0.0391, 0.5391, 0, 0, 0.77778],
  1835. "61": [-0.13313, 0.36687, 0, 0, 0.77778],
  1836. "62": [0.0391, 0.5391, 0, 0, 0.77778],
  1837. "63": [0, 0.69444, 0, 0, 0.47222],
  1838. "64": [0, 0.69444, 0, 0, 0.77778],
  1839. "65": [0, 0.68333, 0, 0, 0.75],
  1840. "66": [0, 0.68333, 0, 0, 0.70834],
  1841. "67": [0, 0.68333, 0, 0, 0.72222],
  1842. "68": [0, 0.68333, 0, 0, 0.76389],
  1843. "69": [0, 0.68333, 0, 0, 0.68056],
  1844. "70": [0, 0.68333, 0, 0, 0.65278],
  1845. "71": [0, 0.68333, 0, 0, 0.78472],
  1846. "72": [0, 0.68333, 0, 0, 0.75],
  1847. "73": [0, 0.68333, 0, 0, 0.36111],
  1848. "74": [0, 0.68333, 0, 0, 0.51389],
  1849. "75": [0, 0.68333, 0, 0, 0.77778],
  1850. "76": [0, 0.68333, 0, 0, 0.625],
  1851. "77": [0, 0.68333, 0, 0, 0.91667],
  1852. "78": [0, 0.68333, 0, 0, 0.75],
  1853. "79": [0, 0.68333, 0, 0, 0.77778],
  1854. "80": [0, 0.68333, 0, 0, 0.68056],
  1855. "81": [0.19444, 0.68333, 0, 0, 0.77778],
  1856. "82": [0, 0.68333, 0, 0, 0.73611],
  1857. "83": [0, 0.68333, 0, 0, 0.55556],
  1858. "84": [0, 0.68333, 0, 0, 0.72222],
  1859. "85": [0, 0.68333, 0, 0, 0.75],
  1860. "86": [0, 0.68333, 0.01389, 0, 0.75],
  1861. "87": [0, 0.68333, 0.01389, 0, 1.02778],
  1862. "88": [0, 0.68333, 0, 0, 0.75],
  1863. "89": [0, 0.68333, 0.025, 0, 0.75],
  1864. "90": [0, 0.68333, 0, 0, 0.61111],
  1865. "91": [0.25, 0.75, 0, 0, 0.27778],
  1866. "92": [0.25, 0.75, 0, 0, 0.5],
  1867. "93": [0.25, 0.75, 0, 0, 0.27778],
  1868. "94": [0, 0.69444, 0, 0, 0.5],
  1869. "95": [0.31, 0.12056, 0.02778, 0, 0.5],
  1870. "97": [0, 0.43056, 0, 0, 0.5],
  1871. "98": [0, 0.69444, 0, 0, 0.55556],
  1872. "99": [0, 0.43056, 0, 0, 0.44445],
  1873. "100": [0, 0.69444, 0, 0, 0.55556],
  1874. "101": [0, 0.43056, 0, 0, 0.44445],
  1875. "102": [0, 0.69444, 0.07778, 0, 0.30556],
  1876. "103": [0.19444, 0.43056, 0.01389, 0, 0.5],
  1877. "104": [0, 0.69444, 0, 0, 0.55556],
  1878. "105": [0, 0.66786, 0, 0, 0.27778],
  1879. "106": [0.19444, 0.66786, 0, 0, 0.30556],
  1880. "107": [0, 0.69444, 0, 0, 0.52778],
  1881. "108": [0, 0.69444, 0, 0, 0.27778],
  1882. "109": [0, 0.43056, 0, 0, 0.83334],
  1883. "110": [0, 0.43056, 0, 0, 0.55556],
  1884. "111": [0, 0.43056, 0, 0, 0.5],
  1885. "112": [0.19444, 0.43056, 0, 0, 0.55556],
  1886. "113": [0.19444, 0.43056, 0, 0, 0.52778],
  1887. "114": [0, 0.43056, 0, 0, 0.39167],
  1888. "115": [0, 0.43056, 0, 0, 0.39445],
  1889. "116": [0, 0.61508, 0, 0, 0.38889],
  1890. "117": [0, 0.43056, 0, 0, 0.55556],
  1891. "118": [0, 0.43056, 0.01389, 0, 0.52778],
  1892. "119": [0, 0.43056, 0.01389, 0, 0.72222],
  1893. "120": [0, 0.43056, 0, 0, 0.52778],
  1894. "121": [0.19444, 0.43056, 0.01389, 0, 0.52778],
  1895. "122": [0, 0.43056, 0, 0, 0.44445],
  1896. "123": [0.25, 0.75, 0, 0, 0.5],
  1897. "124": [0.25, 0.75, 0, 0, 0.27778],
  1898. "125": [0.25, 0.75, 0, 0, 0.5],
  1899. "126": [0.35, 0.31786, 0, 0, 0.5],
  1900. "160": [0, 0, 0, 0, 0.25],
  1901. "163": [0, 0.69444, 0, 0, 0.76909],
  1902. "167": [0.19444, 0.69444, 0, 0, 0.44445],
  1903. "168": [0, 0.66786, 0, 0, 0.5],
  1904. "172": [0, 0.43056, 0, 0, 0.66667],
  1905. "176": [0, 0.69444, 0, 0, 0.75],
  1906. "177": [0.08333, 0.58333, 0, 0, 0.77778],
  1907. "182": [0.19444, 0.69444, 0, 0, 0.61111],
  1908. "184": [0.17014, 0, 0, 0, 0.44445],
  1909. "198": [0, 0.68333, 0, 0, 0.90278],
  1910. "215": [0.08333, 0.58333, 0, 0, 0.77778],
  1911. "216": [0.04861, 0.73194, 0, 0, 0.77778],
  1912. "223": [0, 0.69444, 0, 0, 0.5],
  1913. "230": [0, 0.43056, 0, 0, 0.72222],
  1914. "247": [0.08333, 0.58333, 0, 0, 0.77778],
  1915. "248": [0.09722, 0.52778, 0, 0, 0.5],
  1916. "305": [0, 0.43056, 0, 0, 0.27778],
  1917. "338": [0, 0.68333, 0, 0, 1.01389],
  1918. "339": [0, 0.43056, 0, 0, 0.77778],
  1919. "567": [0.19444, 0.43056, 0, 0, 0.30556],
  1920. "710": [0, 0.69444, 0, 0, 0.5],
  1921. "711": [0, 0.62847, 0, 0, 0.5],
  1922. "713": [0, 0.56778, 0, 0, 0.5],
  1923. "714": [0, 0.69444, 0, 0, 0.5],
  1924. "715": [0, 0.69444, 0, 0, 0.5],
  1925. "728": [0, 0.69444, 0, 0, 0.5],
  1926. "729": [0, 0.66786, 0, 0, 0.27778],
  1927. "730": [0, 0.69444, 0, 0, 0.75],
  1928. "732": [0, 0.66786, 0, 0, 0.5],
  1929. "733": [0, 0.69444, 0, 0, 0.5],
  1930. "915": [0, 0.68333, 0, 0, 0.625],
  1931. "916": [0, 0.68333, 0, 0, 0.83334],
  1932. "920": [0, 0.68333, 0, 0, 0.77778],
  1933. "923": [0, 0.68333, 0, 0, 0.69445],
  1934. "926": [0, 0.68333, 0, 0, 0.66667],
  1935. "928": [0, 0.68333, 0, 0, 0.75],
  1936. "931": [0, 0.68333, 0, 0, 0.72222],
  1937. "933": [0, 0.68333, 0, 0, 0.77778],
  1938. "934": [0, 0.68333, 0, 0, 0.72222],
  1939. "936": [0, 0.68333, 0, 0, 0.77778],
  1940. "937": [0, 0.68333, 0, 0, 0.72222],
  1941. "8211": [0, 0.43056, 0.02778, 0, 0.5],
  1942. "8212": [0, 0.43056, 0.02778, 0, 1.0],
  1943. "8216": [0, 0.69444, 0, 0, 0.27778],
  1944. "8217": [0, 0.69444, 0, 0, 0.27778],
  1945. "8220": [0, 0.69444, 0, 0, 0.5],
  1946. "8221": [0, 0.69444, 0, 0, 0.5],
  1947. "8224": [0.19444, 0.69444, 0, 0, 0.44445],
  1948. "8225": [0.19444, 0.69444, 0, 0, 0.44445],
  1949. "8230": [0, 0.123, 0, 0, 1.172],
  1950. "8242": [0, 0.55556, 0, 0, 0.275],
  1951. "8407": [0, 0.71444, 0.15382, 0, 0.5],
  1952. "8463": [0, 0.68889, 0, 0, 0.54028],
  1953. "8465": [0, 0.69444, 0, 0, 0.72222],
  1954. "8467": [0, 0.69444, 0, 0.11111, 0.41667],
  1955. "8472": [0.19444, 0.43056, 0, 0.11111, 0.63646],
  1956. "8476": [0, 0.69444, 0, 0, 0.72222],
  1957. "8501": [0, 0.69444, 0, 0, 0.61111],
  1958. "8592": [-0.13313, 0.36687, 0, 0, 1.0],
  1959. "8593": [0.19444, 0.69444, 0, 0, 0.5],
  1960. "8594": [-0.13313, 0.36687, 0, 0, 1.0],
  1961. "8595": [0.19444, 0.69444, 0, 0, 0.5],
  1962. "8596": [-0.13313, 0.36687, 0, 0, 1.0],
  1963. "8597": [0.25, 0.75, 0, 0, 0.5],
  1964. "8598": [0.19444, 0.69444, 0, 0, 1.0],
  1965. "8599": [0.19444, 0.69444, 0, 0, 1.0],
  1966. "8600": [0.19444, 0.69444, 0, 0, 1.0],
  1967. "8601": [0.19444, 0.69444, 0, 0, 1.0],
  1968. "8614": [0.011, 0.511, 0, 0, 1.0],
  1969. "8617": [0.011, 0.511, 0, 0, 1.126],
  1970. "8618": [0.011, 0.511, 0, 0, 1.126],
  1971. "8636": [-0.13313, 0.36687, 0, 0, 1.0],
  1972. "8637": [-0.13313, 0.36687, 0, 0, 1.0],
  1973. "8640": [-0.13313, 0.36687, 0, 0, 1.0],
  1974. "8641": [-0.13313, 0.36687, 0, 0, 1.0],
  1975. "8652": [0.011, 0.671, 0, 0, 1.0],
  1976. "8656": [-0.13313, 0.36687, 0, 0, 1.0],
  1977. "8657": [0.19444, 0.69444, 0, 0, 0.61111],
  1978. "8658": [-0.13313, 0.36687, 0, 0, 1.0],
  1979. "8659": [0.19444, 0.69444, 0, 0, 0.61111],
  1980. "8660": [-0.13313, 0.36687, 0, 0, 1.0],
  1981. "8661": [0.25, 0.75, 0, 0, 0.61111],
  1982. "8704": [0, 0.69444, 0, 0, 0.55556],
  1983. "8706": [0, 0.69444, 0.05556, 0.08334, 0.5309],
  1984. "8707": [0, 0.69444, 0, 0, 0.55556],
  1985. "8709": [0.05556, 0.75, 0, 0, 0.5],
  1986. "8711": [0, 0.68333, 0, 0, 0.83334],
  1987. "8712": [0.0391, 0.5391, 0, 0, 0.66667],
  1988. "8715": [0.0391, 0.5391, 0, 0, 0.66667],
  1989. "8722": [0.08333, 0.58333, 0, 0, 0.77778],
  1990. "8723": [0.08333, 0.58333, 0, 0, 0.77778],
  1991. "8725": [0.25, 0.75, 0, 0, 0.5],
  1992. "8726": [0.25, 0.75, 0, 0, 0.5],
  1993. "8727": [-0.03472, 0.46528, 0, 0, 0.5],
  1994. "8728": [-0.05555, 0.44445, 0, 0, 0.5],
  1995. "8729": [-0.05555, 0.44445, 0, 0, 0.5],
  1996. "8730": [0.2, 0.8, 0, 0, 0.83334],
  1997. "8733": [0, 0.43056, 0, 0, 0.77778],
  1998. "8734": [0, 0.43056, 0, 0, 1.0],
  1999. "8736": [0, 0.69224, 0, 0, 0.72222],
  2000. "8739": [0.25, 0.75, 0, 0, 0.27778],
  2001. "8741": [0.25, 0.75, 0, 0, 0.5],
  2002. "8743": [0, 0.55556, 0, 0, 0.66667],
  2003. "8744": [0, 0.55556, 0, 0, 0.66667],
  2004. "8745": [0, 0.55556, 0, 0, 0.66667],
  2005. "8746": [0, 0.55556, 0, 0, 0.66667],
  2006. "8747": [0.19444, 0.69444, 0.11111, 0, 0.41667],
  2007. "8764": [-0.13313, 0.36687, 0, 0, 0.77778],
  2008. "8768": [0.19444, 0.69444, 0, 0, 0.27778],
  2009. "8771": [-0.03625, 0.46375, 0, 0, 0.77778],
  2010. "8773": [-0.022, 0.589, 0, 0, 0.778],
  2011. "8776": [-0.01688, 0.48312, 0, 0, 0.77778],
  2012. "8781": [-0.03625, 0.46375, 0, 0, 0.77778],
  2013. "8784": [-0.133, 0.673, 0, 0, 0.778],
  2014. "8801": [-0.03625, 0.46375, 0, 0, 0.77778],
  2015. "8804": [0.13597, 0.63597, 0, 0, 0.77778],
  2016. "8805": [0.13597, 0.63597, 0, 0, 0.77778],
  2017. "8810": [0.0391, 0.5391, 0, 0, 1.0],
  2018. "8811": [0.0391, 0.5391, 0, 0, 1.0],
  2019. "8826": [0.0391, 0.5391, 0, 0, 0.77778],
  2020. "8827": [0.0391, 0.5391, 0, 0, 0.77778],
  2021. "8834": [0.0391, 0.5391, 0, 0, 0.77778],
  2022. "8835": [0.0391, 0.5391, 0, 0, 0.77778],
  2023. "8838": [0.13597, 0.63597, 0, 0, 0.77778],
  2024. "8839": [0.13597, 0.63597, 0, 0, 0.77778],
  2025. "8846": [0, 0.55556, 0, 0, 0.66667],
  2026. "8849": [0.13597, 0.63597, 0, 0, 0.77778],
  2027. "8850": [0.13597, 0.63597, 0, 0, 0.77778],
  2028. "8851": [0, 0.55556, 0, 0, 0.66667],
  2029. "8852": [0, 0.55556, 0, 0, 0.66667],
  2030. "8853": [0.08333, 0.58333, 0, 0, 0.77778],
  2031. "8854": [0.08333, 0.58333, 0, 0, 0.77778],
  2032. "8855": [0.08333, 0.58333, 0, 0, 0.77778],
  2033. "8856": [0.08333, 0.58333, 0, 0, 0.77778],
  2034. "8857": [0.08333, 0.58333, 0, 0, 0.77778],
  2035. "8866": [0, 0.69444, 0, 0, 0.61111],
  2036. "8867": [0, 0.69444, 0, 0, 0.61111],
  2037. "8868": [0, 0.69444, 0, 0, 0.77778],
  2038. "8869": [0, 0.69444, 0, 0, 0.77778],
  2039. "8872": [0.249, 0.75, 0, 0, 0.867],
  2040. "8900": [-0.05555, 0.44445, 0, 0, 0.5],
  2041. "8901": [-0.05555, 0.44445, 0, 0, 0.27778],
  2042. "8902": [-0.03472, 0.46528, 0, 0, 0.5],
  2043. "8904": [0.005, 0.505, 0, 0, 0.9],
  2044. "8942": [0.03, 0.903, 0, 0, 0.278],
  2045. "8943": [-0.19, 0.313, 0, 0, 1.172],
  2046. "8945": [-0.1, 0.823, 0, 0, 1.282],
  2047. "8968": [0.25, 0.75, 0, 0, 0.44445],
  2048. "8969": [0.25, 0.75, 0, 0, 0.44445],
  2049. "8970": [0.25, 0.75, 0, 0, 0.44445],
  2050. "8971": [0.25, 0.75, 0, 0, 0.44445],
  2051. "8994": [-0.14236, 0.35764, 0, 0, 1.0],
  2052. "8995": [-0.14236, 0.35764, 0, 0, 1.0],
  2053. "9136": [0.244, 0.744, 0, 0, 0.412],
  2054. "9137": [0.244, 0.745, 0, 0, 0.412],
  2055. "9651": [0.19444, 0.69444, 0, 0, 0.88889],
  2056. "9657": [-0.03472, 0.46528, 0, 0, 0.5],
  2057. "9661": [0.19444, 0.69444, 0, 0, 0.88889],
  2058. "9667": [-0.03472, 0.46528, 0, 0, 0.5],
  2059. "9711": [0.19444, 0.69444, 0, 0, 1.0],
  2060. "9824": [0.12963, 0.69444, 0, 0, 0.77778],
  2061. "9825": [0.12963, 0.69444, 0, 0, 0.77778],
  2062. "9826": [0.12963, 0.69444, 0, 0, 0.77778],
  2063. "9827": [0.12963, 0.69444, 0, 0, 0.77778],
  2064. "9837": [0, 0.75, 0, 0, 0.38889],
  2065. "9838": [0.19444, 0.69444, 0, 0, 0.38889],
  2066. "9839": [0.19444, 0.69444, 0, 0, 0.38889],
  2067. "10216": [0.25, 0.75, 0, 0, 0.38889],
  2068. "10217": [0.25, 0.75, 0, 0, 0.38889],
  2069. "10222": [0.244, 0.744, 0, 0, 0.412],
  2070. "10223": [0.244, 0.745, 0, 0, 0.412],
  2071. "10229": [0.011, 0.511, 0, 0, 1.609],
  2072. "10230": [0.011, 0.511, 0, 0, 1.638],
  2073. "10231": [0.011, 0.511, 0, 0, 1.859],
  2074. "10232": [0.024, 0.525, 0, 0, 1.609],
  2075. "10233": [0.024, 0.525, 0, 0, 1.638],
  2076. "10234": [0.024, 0.525, 0, 0, 1.858],
  2077. "10236": [0.011, 0.511, 0, 0, 1.638],
  2078. "10815": [0, 0.68333, 0, 0, 0.75],
  2079. "10927": [0.13597, 0.63597, 0, 0, 0.77778],
  2080. "10928": [0.13597, 0.63597, 0, 0, 0.77778],
  2081. "57376": [0.19444, 0.69444, 0, 0, 0]
  2082. },
  2083. "Math-BoldItalic": {
  2084. "32": [0, 0, 0, 0, 0.25],
  2085. "48": [0, 0.44444, 0, 0, 0.575],
  2086. "49": [0, 0.44444, 0, 0, 0.575],
  2087. "50": [0, 0.44444, 0, 0, 0.575],
  2088. "51": [0.19444, 0.44444, 0, 0, 0.575],
  2089. "52": [0.19444, 0.44444, 0, 0, 0.575],
  2090. "53": [0.19444, 0.44444, 0, 0, 0.575],
  2091. "54": [0, 0.64444, 0, 0, 0.575],
  2092. "55": [0.19444, 0.44444, 0, 0, 0.575],
  2093. "56": [0, 0.64444, 0, 0, 0.575],
  2094. "57": [0.19444, 0.44444, 0, 0, 0.575],
  2095. "65": [0, 0.68611, 0, 0, 0.86944],
  2096. "66": [0, 0.68611, 0.04835, 0, 0.8664],
  2097. "67": [0, 0.68611, 0.06979, 0, 0.81694],
  2098. "68": [0, 0.68611, 0.03194, 0, 0.93812],
  2099. "69": [0, 0.68611, 0.05451, 0, 0.81007],
  2100. "70": [0, 0.68611, 0.15972, 0, 0.68889],
  2101. "71": [0, 0.68611, 0, 0, 0.88673],
  2102. "72": [0, 0.68611, 0.08229, 0, 0.98229],
  2103. "73": [0, 0.68611, 0.07778, 0, 0.51111],
  2104. "74": [0, 0.68611, 0.10069, 0, 0.63125],
  2105. "75": [0, 0.68611, 0.06979, 0, 0.97118],
  2106. "76": [0, 0.68611, 0, 0, 0.75555],
  2107. "77": [0, 0.68611, 0.11424, 0, 1.14201],
  2108. "78": [0, 0.68611, 0.11424, 0, 0.95034],
  2109. "79": [0, 0.68611, 0.03194, 0, 0.83666],
  2110. "80": [0, 0.68611, 0.15972, 0, 0.72309],
  2111. "81": [0.19444, 0.68611, 0, 0, 0.86861],
  2112. "82": [0, 0.68611, 0.00421, 0, 0.87235],
  2113. "83": [0, 0.68611, 0.05382, 0, 0.69271],
  2114. "84": [0, 0.68611, 0.15972, 0, 0.63663],
  2115. "85": [0, 0.68611, 0.11424, 0, 0.80027],
  2116. "86": [0, 0.68611, 0.25555, 0, 0.67778],
  2117. "87": [0, 0.68611, 0.15972, 0, 1.09305],
  2118. "88": [0, 0.68611, 0.07778, 0, 0.94722],
  2119. "89": [0, 0.68611, 0.25555, 0, 0.67458],
  2120. "90": [0, 0.68611, 0.06979, 0, 0.77257],
  2121. "97": [0, 0.44444, 0, 0, 0.63287],
  2122. "98": [0, 0.69444, 0, 0, 0.52083],
  2123. "99": [0, 0.44444, 0, 0, 0.51342],
  2124. "100": [0, 0.69444, 0, 0, 0.60972],
  2125. "101": [0, 0.44444, 0, 0, 0.55361],
  2126. "102": [0.19444, 0.69444, 0.11042, 0, 0.56806],
  2127. "103": [0.19444, 0.44444, 0.03704, 0, 0.5449],
  2128. "104": [0, 0.69444, 0, 0, 0.66759],
  2129. "105": [0, 0.69326, 0, 0, 0.4048],
  2130. "106": [0.19444, 0.69326, 0.0622, 0, 0.47083],
  2131. "107": [0, 0.69444, 0.01852, 0, 0.6037],
  2132. "108": [0, 0.69444, 0.0088, 0, 0.34815],
  2133. "109": [0, 0.44444, 0, 0, 1.0324],
  2134. "110": [0, 0.44444, 0, 0, 0.71296],
  2135. "111": [0, 0.44444, 0, 0, 0.58472],
  2136. "112": [0.19444, 0.44444, 0, 0, 0.60092],
  2137. "113": [0.19444, 0.44444, 0.03704, 0, 0.54213],
  2138. "114": [0, 0.44444, 0.03194, 0, 0.5287],
  2139. "115": [0, 0.44444, 0, 0, 0.53125],
  2140. "116": [0, 0.63492, 0, 0, 0.41528],
  2141. "117": [0, 0.44444, 0, 0, 0.68102],
  2142. "118": [0, 0.44444, 0.03704, 0, 0.56666],
  2143. "119": [0, 0.44444, 0.02778, 0, 0.83148],
  2144. "120": [0, 0.44444, 0, 0, 0.65903],
  2145. "121": [0.19444, 0.44444, 0.03704, 0, 0.59028],
  2146. "122": [0, 0.44444, 0.04213, 0, 0.55509],
  2147. "160": [0, 0, 0, 0, 0.25],
  2148. "915": [0, 0.68611, 0.15972, 0, 0.65694],
  2149. "916": [0, 0.68611, 0, 0, 0.95833],
  2150. "920": [0, 0.68611, 0.03194, 0, 0.86722],
  2151. "923": [0, 0.68611, 0, 0, 0.80555],
  2152. "926": [0, 0.68611, 0.07458, 0, 0.84125],
  2153. "928": [0, 0.68611, 0.08229, 0, 0.98229],
  2154. "931": [0, 0.68611, 0.05451, 0, 0.88507],
  2155. "933": [0, 0.68611, 0.15972, 0, 0.67083],
  2156. "934": [0, 0.68611, 0, 0, 0.76666],
  2157. "936": [0, 0.68611, 0.11653, 0, 0.71402],
  2158. "937": [0, 0.68611, 0.04835, 0, 0.8789],
  2159. "945": [0, 0.44444, 0, 0, 0.76064],
  2160. "946": [0.19444, 0.69444, 0.03403, 0, 0.65972],
  2161. "947": [0.19444, 0.44444, 0.06389, 0, 0.59003],
  2162. "948": [0, 0.69444, 0.03819, 0, 0.52222],
  2163. "949": [0, 0.44444, 0, 0, 0.52882],
  2164. "950": [0.19444, 0.69444, 0.06215, 0, 0.50833],
  2165. "951": [0.19444, 0.44444, 0.03704, 0, 0.6],
  2166. "952": [0, 0.69444, 0.03194, 0, 0.5618],
  2167. "953": [0, 0.44444, 0, 0, 0.41204],
  2168. "954": [0, 0.44444, 0, 0, 0.66759],
  2169. "955": [0, 0.69444, 0, 0, 0.67083],
  2170. "956": [0.19444, 0.44444, 0, 0, 0.70787],
  2171. "957": [0, 0.44444, 0.06898, 0, 0.57685],
  2172. "958": [0.19444, 0.69444, 0.03021, 0, 0.50833],
  2173. "959": [0, 0.44444, 0, 0, 0.58472],
  2174. "960": [0, 0.44444, 0.03704, 0, 0.68241],
  2175. "961": [0.19444, 0.44444, 0, 0, 0.6118],
  2176. "962": [0.09722, 0.44444, 0.07917, 0, 0.42361],
  2177. "963": [0, 0.44444, 0.03704, 0, 0.68588],
  2178. "964": [0, 0.44444, 0.13472, 0, 0.52083],
  2179. "965": [0, 0.44444, 0.03704, 0, 0.63055],
  2180. "966": [0.19444, 0.44444, 0, 0, 0.74722],
  2181. "967": [0.19444, 0.44444, 0, 0, 0.71805],
  2182. "968": [0.19444, 0.69444, 0.03704, 0, 0.75833],
  2183. "969": [0, 0.44444, 0.03704, 0, 0.71782],
  2184. "977": [0, 0.69444, 0, 0, 0.69155],
  2185. "981": [0.19444, 0.69444, 0, 0, 0.7125],
  2186. "982": [0, 0.44444, 0.03194, 0, 0.975],
  2187. "1009": [0.19444, 0.44444, 0, 0, 0.6118],
  2188. "1013": [0, 0.44444, 0, 0, 0.48333],
  2189. "57649": [0, 0.44444, 0, 0, 0.39352],
  2190. "57911": [0.19444, 0.44444, 0, 0, 0.43889]
  2191. },
  2192. "Math-Italic": {
  2193. "32": [0, 0, 0, 0, 0.25],
  2194. "48": [0, 0.43056, 0, 0, 0.5],
  2195. "49": [0, 0.43056, 0, 0, 0.5],
  2196. "50": [0, 0.43056, 0, 0, 0.5],
  2197. "51": [0.19444, 0.43056, 0, 0, 0.5],
  2198. "52": [0.19444, 0.43056, 0, 0, 0.5],
  2199. "53": [0.19444, 0.43056, 0, 0, 0.5],
  2200. "54": [0, 0.64444, 0, 0, 0.5],
  2201. "55": [0.19444, 0.43056, 0, 0, 0.5],
  2202. "56": [0, 0.64444, 0, 0, 0.5],
  2203. "57": [0.19444, 0.43056, 0, 0, 0.5],
  2204. "65": [0, 0.68333, 0, 0.13889, 0.75],
  2205. "66": [0, 0.68333, 0.05017, 0.08334, 0.75851],
  2206. "67": [0, 0.68333, 0.07153, 0.08334, 0.71472],
  2207. "68": [0, 0.68333, 0.02778, 0.05556, 0.82792],
  2208. "69": [0, 0.68333, 0.05764, 0.08334, 0.7382],
  2209. "70": [0, 0.68333, 0.13889, 0.08334, 0.64306],
  2210. "71": [0, 0.68333, 0, 0.08334, 0.78625],
  2211. "72": [0, 0.68333, 0.08125, 0.05556, 0.83125],
  2212. "73": [0, 0.68333, 0.07847, 0.11111, 0.43958],
  2213. "74": [0, 0.68333, 0.09618, 0.16667, 0.55451],
  2214. "75": [0, 0.68333, 0.07153, 0.05556, 0.84931],
  2215. "76": [0, 0.68333, 0, 0.02778, 0.68056],
  2216. "77": [0, 0.68333, 0.10903, 0.08334, 0.97014],
  2217. "78": [0, 0.68333, 0.10903, 0.08334, 0.80347],
  2218. "79": [0, 0.68333, 0.02778, 0.08334, 0.76278],
  2219. "80": [0, 0.68333, 0.13889, 0.08334, 0.64201],
  2220. "81": [0.19444, 0.68333, 0, 0.08334, 0.79056],
  2221. "82": [0, 0.68333, 0.00773, 0.08334, 0.75929],
  2222. "83": [0, 0.68333, 0.05764, 0.08334, 0.6132],
  2223. "84": [0, 0.68333, 0.13889, 0.08334, 0.58438],
  2224. "85": [0, 0.68333, 0.10903, 0.02778, 0.68278],
  2225. "86": [0, 0.68333, 0.22222, 0, 0.58333],
  2226. "87": [0, 0.68333, 0.13889, 0, 0.94445],
  2227. "88": [0, 0.68333, 0.07847, 0.08334, 0.82847],
  2228. "89": [0, 0.68333, 0.22222, 0, 0.58056],
  2229. "90": [0, 0.68333, 0.07153, 0.08334, 0.68264],
  2230. "97": [0, 0.43056, 0, 0, 0.52859],
  2231. "98": [0, 0.69444, 0, 0, 0.42917],
  2232. "99": [0, 0.43056, 0, 0.05556, 0.43276],
  2233. "100": [0, 0.69444, 0, 0.16667, 0.52049],
  2234. "101": [0, 0.43056, 0, 0.05556, 0.46563],
  2235. "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959],
  2236. "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697],
  2237. "104": [0, 0.69444, 0, 0, 0.57616],
  2238. "105": [0, 0.65952, 0, 0, 0.34451],
  2239. "106": [0.19444, 0.65952, 0.05724, 0, 0.41181],
  2240. "107": [0, 0.69444, 0.03148, 0, 0.5206],
  2241. "108": [0, 0.69444, 0.01968, 0.08334, 0.29838],
  2242. "109": [0, 0.43056, 0, 0, 0.87801],
  2243. "110": [0, 0.43056, 0, 0, 0.60023],
  2244. "111": [0, 0.43056, 0, 0.05556, 0.48472],
  2245. "112": [0.19444, 0.43056, 0, 0.08334, 0.50313],
  2246. "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641],
  2247. "114": [0, 0.43056, 0.02778, 0.05556, 0.45116],
  2248. "115": [0, 0.43056, 0, 0.05556, 0.46875],
  2249. "116": [0, 0.61508, 0, 0.08334, 0.36111],
  2250. "117": [0, 0.43056, 0, 0.02778, 0.57246],
  2251. "118": [0, 0.43056, 0.03588, 0.02778, 0.48472],
  2252. "119": [0, 0.43056, 0.02691, 0.08334, 0.71592],
  2253. "120": [0, 0.43056, 0, 0.02778, 0.57153],
  2254. "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028],
  2255. "122": [0, 0.43056, 0.04398, 0.05556, 0.46505],
  2256. "160": [0, 0, 0, 0, 0.25],
  2257. "915": [0, 0.68333, 0.13889, 0.08334, 0.61528],
  2258. "916": [0, 0.68333, 0, 0.16667, 0.83334],
  2259. "920": [0, 0.68333, 0.02778, 0.08334, 0.76278],
  2260. "923": [0, 0.68333, 0, 0.16667, 0.69445],
  2261. "926": [0, 0.68333, 0.07569, 0.08334, 0.74236],
  2262. "928": [0, 0.68333, 0.08125, 0.05556, 0.83125],
  2263. "931": [0, 0.68333, 0.05764, 0.08334, 0.77986],
  2264. "933": [0, 0.68333, 0.13889, 0.05556, 0.58333],
  2265. "934": [0, 0.68333, 0, 0.08334, 0.66667],
  2266. "936": [0, 0.68333, 0.11, 0.05556, 0.61222],
  2267. "937": [0, 0.68333, 0.05017, 0.08334, 0.7724],
  2268. "945": [0, 0.43056, 0.0037, 0.02778, 0.6397],
  2269. "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563],
  2270. "947": [0.19444, 0.43056, 0.05556, 0, 0.51773],
  2271. "948": [0, 0.69444, 0.03785, 0.05556, 0.44444],
  2272. "949": [0, 0.43056, 0, 0.08334, 0.46632],
  2273. "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375],
  2274. "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653],
  2275. "952": [0, 0.69444, 0.02778, 0.08334, 0.46944],
  2276. "953": [0, 0.43056, 0, 0.05556, 0.35394],
  2277. "954": [0, 0.43056, 0, 0, 0.57616],
  2278. "955": [0, 0.69444, 0, 0, 0.58334],
  2279. "956": [0.19444, 0.43056, 0, 0.02778, 0.60255],
  2280. "957": [0, 0.43056, 0.06366, 0.02778, 0.49398],
  2281. "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375],
  2282. "959": [0, 0.43056, 0, 0.05556, 0.48472],
  2283. "960": [0, 0.43056, 0.03588, 0, 0.57003],
  2284. "961": [0.19444, 0.43056, 0, 0.08334, 0.51702],
  2285. "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285],
  2286. "963": [0, 0.43056, 0.03588, 0, 0.57141],
  2287. "964": [0, 0.43056, 0.1132, 0.02778, 0.43715],
  2288. "965": [0, 0.43056, 0.03588, 0.02778, 0.54028],
  2289. "966": [0.19444, 0.43056, 0, 0.08334, 0.65417],
  2290. "967": [0.19444, 0.43056, 0, 0.05556, 0.62569],
  2291. "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139],
  2292. "969": [0, 0.43056, 0.03588, 0, 0.62245],
  2293. "977": [0, 0.69444, 0, 0.08334, 0.59144],
  2294. "981": [0.19444, 0.69444, 0, 0.08334, 0.59583],
  2295. "982": [0, 0.43056, 0.02778, 0, 0.82813],
  2296. "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702],
  2297. "1013": [0, 0.43056, 0, 0.05556, 0.4059],
  2298. "57649": [0, 0.43056, 0, 0.02778, 0.32246],
  2299. "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403]
  2300. },
  2301. "SansSerif-Bold": {
  2302. "32": [0, 0, 0, 0, 0.25],
  2303. "33": [0, 0.69444, 0, 0, 0.36667],
  2304. "34": [0, 0.69444, 0, 0, 0.55834],
  2305. "35": [0.19444, 0.69444, 0, 0, 0.91667],
  2306. "36": [0.05556, 0.75, 0, 0, 0.55],
  2307. "37": [0.05556, 0.75, 0, 0, 1.02912],
  2308. "38": [0, 0.69444, 0, 0, 0.83056],
  2309. "39": [0, 0.69444, 0, 0, 0.30556],
  2310. "40": [0.25, 0.75, 0, 0, 0.42778],
  2311. "41": [0.25, 0.75, 0, 0, 0.42778],
  2312. "42": [0, 0.75, 0, 0, 0.55],
  2313. "43": [0.11667, 0.61667, 0, 0, 0.85556],
  2314. "44": [0.10556, 0.13056, 0, 0, 0.30556],
  2315. "45": [0, 0.45833, 0, 0, 0.36667],
  2316. "46": [0, 0.13056, 0, 0, 0.30556],
  2317. "47": [0.25, 0.75, 0, 0, 0.55],
  2318. "48": [0, 0.69444, 0, 0, 0.55],
  2319. "49": [0, 0.69444, 0, 0, 0.55],
  2320. "50": [0, 0.69444, 0, 0, 0.55],
  2321. "51": [0, 0.69444, 0, 0, 0.55],
  2322. "52": [0, 0.69444, 0, 0, 0.55],
  2323. "53": [0, 0.69444, 0, 0, 0.55],
  2324. "54": [0, 0.69444, 0, 0, 0.55],
  2325. "55": [0, 0.69444, 0, 0, 0.55],
  2326. "56": [0, 0.69444, 0, 0, 0.55],
  2327. "57": [0, 0.69444, 0, 0, 0.55],
  2328. "58": [0, 0.45833, 0, 0, 0.30556],
  2329. "59": [0.10556, 0.45833, 0, 0, 0.30556],
  2330. "61": [-0.09375, 0.40625, 0, 0, 0.85556],
  2331. "63": [0, 0.69444, 0, 0, 0.51945],
  2332. "64": [0, 0.69444, 0, 0, 0.73334],
  2333. "65": [0, 0.69444, 0, 0, 0.73334],
  2334. "66": [0, 0.69444, 0, 0, 0.73334],
  2335. "67": [0, 0.69444, 0, 0, 0.70278],
  2336. "68": [0, 0.69444, 0, 0, 0.79445],
  2337. "69": [0, 0.69444, 0, 0, 0.64167],
  2338. "70": [0, 0.69444, 0, 0, 0.61111],
  2339. "71": [0, 0.69444, 0, 0, 0.73334],
  2340. "72": [0, 0.69444, 0, 0, 0.79445],
  2341. "73": [0, 0.69444, 0, 0, 0.33056],
  2342. "74": [0, 0.69444, 0, 0, 0.51945],
  2343. "75": [0, 0.69444, 0, 0, 0.76389],
  2344. "76": [0, 0.69444, 0, 0, 0.58056],
  2345. "77": [0, 0.69444, 0, 0, 0.97778],
  2346. "78": [0, 0.69444, 0, 0, 0.79445],
  2347. "79": [0, 0.69444, 0, 0, 0.79445],
  2348. "80": [0, 0.69444, 0, 0, 0.70278],
  2349. "81": [0.10556, 0.69444, 0, 0, 0.79445],
  2350. "82": [0, 0.69444, 0, 0, 0.70278],
  2351. "83": [0, 0.69444, 0, 0, 0.61111],
  2352. "84": [0, 0.69444, 0, 0, 0.73334],
  2353. "85": [0, 0.69444, 0, 0, 0.76389],
  2354. "86": [0, 0.69444, 0.01528, 0, 0.73334],
  2355. "87": [0, 0.69444, 0.01528, 0, 1.03889],
  2356. "88": [0, 0.69444, 0, 0, 0.73334],
  2357. "89": [0, 0.69444, 0.0275, 0, 0.73334],
  2358. "90": [0, 0.69444, 0, 0, 0.67223],
  2359. "91": [0.25, 0.75, 0, 0, 0.34306],
  2360. "93": [0.25, 0.75, 0, 0, 0.34306],
  2361. "94": [0, 0.69444, 0, 0, 0.55],
  2362. "95": [0.35, 0.10833, 0.03056, 0, 0.55],
  2363. "97": [0, 0.45833, 0, 0, 0.525],
  2364. "98": [0, 0.69444, 0, 0, 0.56111],
  2365. "99": [0, 0.45833, 0, 0, 0.48889],
  2366. "100": [0, 0.69444, 0, 0, 0.56111],
  2367. "101": [0, 0.45833, 0, 0, 0.51111],
  2368. "102": [0, 0.69444, 0.07639, 0, 0.33611],
  2369. "103": [0.19444, 0.45833, 0.01528, 0, 0.55],
  2370. "104": [0, 0.69444, 0, 0, 0.56111],
  2371. "105": [0, 0.69444, 0, 0, 0.25556],
  2372. "106": [0.19444, 0.69444, 0, 0, 0.28611],
  2373. "107": [0, 0.69444, 0, 0, 0.53056],
  2374. "108": [0, 0.69444, 0, 0, 0.25556],
  2375. "109": [0, 0.45833, 0, 0, 0.86667],
  2376. "110": [0, 0.45833, 0, 0, 0.56111],
  2377. "111": [0, 0.45833, 0, 0, 0.55],
  2378. "112": [0.19444, 0.45833, 0, 0, 0.56111],
  2379. "113": [0.19444, 0.45833, 0, 0, 0.56111],
  2380. "114": [0, 0.45833, 0.01528, 0, 0.37222],
  2381. "115": [0, 0.45833, 0, 0, 0.42167],
  2382. "116": [0, 0.58929, 0, 0, 0.40417],
  2383. "117": [0, 0.45833, 0, 0, 0.56111],
  2384. "118": [0, 0.45833, 0.01528, 0, 0.5],
  2385. "119": [0, 0.45833, 0.01528, 0, 0.74445],
  2386. "120": [0, 0.45833, 0, 0, 0.5],
  2387. "121": [0.19444, 0.45833, 0.01528, 0, 0.5],
  2388. "122": [0, 0.45833, 0, 0, 0.47639],
  2389. "126": [0.35, 0.34444, 0, 0, 0.55],
  2390. "160": [0, 0, 0, 0, 0.25],
  2391. "168": [0, 0.69444, 0, 0, 0.55],
  2392. "176": [0, 0.69444, 0, 0, 0.73334],
  2393. "180": [0, 0.69444, 0, 0, 0.55],
  2394. "184": [0.17014, 0, 0, 0, 0.48889],
  2395. "305": [0, 0.45833, 0, 0, 0.25556],
  2396. "567": [0.19444, 0.45833, 0, 0, 0.28611],
  2397. "710": [0, 0.69444, 0, 0, 0.55],
  2398. "711": [0, 0.63542, 0, 0, 0.55],
  2399. "713": [0, 0.63778, 0, 0, 0.55],
  2400. "728": [0, 0.69444, 0, 0, 0.55],
  2401. "729": [0, 0.69444, 0, 0, 0.30556],
  2402. "730": [0, 0.69444, 0, 0, 0.73334],
  2403. "732": [0, 0.69444, 0, 0, 0.55],
  2404. "733": [0, 0.69444, 0, 0, 0.55],
  2405. "915": [0, 0.69444, 0, 0, 0.58056],
  2406. "916": [0, 0.69444, 0, 0, 0.91667],
  2407. "920": [0, 0.69444, 0, 0, 0.85556],
  2408. "923": [0, 0.69444, 0, 0, 0.67223],
  2409. "926": [0, 0.69444, 0, 0, 0.73334],
  2410. "928": [0, 0.69444, 0, 0, 0.79445],
  2411. "931": [0, 0.69444, 0, 0, 0.79445],
  2412. "933": [0, 0.69444, 0, 0, 0.85556],
  2413. "934": [0, 0.69444, 0, 0, 0.79445],
  2414. "936": [0, 0.69444, 0, 0, 0.85556],
  2415. "937": [0, 0.69444, 0, 0, 0.79445],
  2416. "8211": [0, 0.45833, 0.03056, 0, 0.55],
  2417. "8212": [0, 0.45833, 0.03056, 0, 1.10001],
  2418. "8216": [0, 0.69444, 0, 0, 0.30556],
  2419. "8217": [0, 0.69444, 0, 0, 0.30556],
  2420. "8220": [0, 0.69444, 0, 0, 0.55834],
  2421. "8221": [0, 0.69444, 0, 0, 0.55834]
  2422. },
  2423. "SansSerif-Italic": {
  2424. "32": [0, 0, 0, 0, 0.25],
  2425. "33": [0, 0.69444, 0.05733, 0, 0.31945],
  2426. "34": [0, 0.69444, 0.00316, 0, 0.5],
  2427. "35": [0.19444, 0.69444, 0.05087, 0, 0.83334],
  2428. "36": [0.05556, 0.75, 0.11156, 0, 0.5],
  2429. "37": [0.05556, 0.75, 0.03126, 0, 0.83334],
  2430. "38": [0, 0.69444, 0.03058, 0, 0.75834],
  2431. "39": [0, 0.69444, 0.07816, 0, 0.27778],
  2432. "40": [0.25, 0.75, 0.13164, 0, 0.38889],
  2433. "41": [0.25, 0.75, 0.02536, 0, 0.38889],
  2434. "42": [0, 0.75, 0.11775, 0, 0.5],
  2435. "43": [0.08333, 0.58333, 0.02536, 0, 0.77778],
  2436. "44": [0.125, 0.08333, 0, 0, 0.27778],
  2437. "45": [0, 0.44444, 0.01946, 0, 0.33333],
  2438. "46": [0, 0.08333, 0, 0, 0.27778],
  2439. "47": [0.25, 0.75, 0.13164, 0, 0.5],
  2440. "48": [0, 0.65556, 0.11156, 0, 0.5],
  2441. "49": [0, 0.65556, 0.11156, 0, 0.5],
  2442. "50": [0, 0.65556, 0.11156, 0, 0.5],
  2443. "51": [0, 0.65556, 0.11156, 0, 0.5],
  2444. "52": [0, 0.65556, 0.11156, 0, 0.5],
  2445. "53": [0, 0.65556, 0.11156, 0, 0.5],
  2446. "54": [0, 0.65556, 0.11156, 0, 0.5],
  2447. "55": [0, 0.65556, 0.11156, 0, 0.5],
  2448. "56": [0, 0.65556, 0.11156, 0, 0.5],
  2449. "57": [0, 0.65556, 0.11156, 0, 0.5],
  2450. "58": [0, 0.44444, 0.02502, 0, 0.27778],
  2451. "59": [0.125, 0.44444, 0.02502, 0, 0.27778],
  2452. "61": [-0.13, 0.37, 0.05087, 0, 0.77778],
  2453. "63": [0, 0.69444, 0.11809, 0, 0.47222],
  2454. "64": [0, 0.69444, 0.07555, 0, 0.66667],
  2455. "65": [0, 0.69444, 0, 0, 0.66667],
  2456. "66": [0, 0.69444, 0.08293, 0, 0.66667],
  2457. "67": [0, 0.69444, 0.11983, 0, 0.63889],
  2458. "68": [0, 0.69444, 0.07555, 0, 0.72223],
  2459. "69": [0, 0.69444, 0.11983, 0, 0.59722],
  2460. "70": [0, 0.69444, 0.13372, 0, 0.56945],
  2461. "71": [0, 0.69444, 0.11983, 0, 0.66667],
  2462. "72": [0, 0.69444, 0.08094, 0, 0.70834],
  2463. "73": [0, 0.69444, 0.13372, 0, 0.27778],
  2464. "74": [0, 0.69444, 0.08094, 0, 0.47222],
  2465. "75": [0, 0.69444, 0.11983, 0, 0.69445],
  2466. "76": [0, 0.69444, 0, 0, 0.54167],
  2467. "77": [0, 0.69444, 0.08094, 0, 0.875],
  2468. "78": [0, 0.69444, 0.08094, 0, 0.70834],
  2469. "79": [0, 0.69444, 0.07555, 0, 0.73611],
  2470. "80": [0, 0.69444, 0.08293, 0, 0.63889],
  2471. "81": [0.125, 0.69444, 0.07555, 0, 0.73611],
  2472. "82": [0, 0.69444, 0.08293, 0, 0.64584],
  2473. "83": [0, 0.69444, 0.09205, 0, 0.55556],
  2474. "84": [0, 0.69444, 0.13372, 0, 0.68056],
  2475. "85": [0, 0.69444, 0.08094, 0, 0.6875],
  2476. "86": [0, 0.69444, 0.1615, 0, 0.66667],
  2477. "87": [0, 0.69444, 0.1615, 0, 0.94445],
  2478. "88": [0, 0.69444, 0.13372, 0, 0.66667],
  2479. "89": [0, 0.69444, 0.17261, 0, 0.66667],
  2480. "90": [0, 0.69444, 0.11983, 0, 0.61111],
  2481. "91": [0.25, 0.75, 0.15942, 0, 0.28889],
  2482. "93": [0.25, 0.75, 0.08719, 0, 0.28889],
  2483. "94": [0, 0.69444, 0.0799, 0, 0.5],
  2484. "95": [0.35, 0.09444, 0.08616, 0, 0.5],
  2485. "97": [0, 0.44444, 0.00981, 0, 0.48056],
  2486. "98": [0, 0.69444, 0.03057, 0, 0.51667],
  2487. "99": [0, 0.44444, 0.08336, 0, 0.44445],
  2488. "100": [0, 0.69444, 0.09483, 0, 0.51667],
  2489. "101": [0, 0.44444, 0.06778, 0, 0.44445],
  2490. "102": [0, 0.69444, 0.21705, 0, 0.30556],
  2491. "103": [0.19444, 0.44444, 0.10836, 0, 0.5],
  2492. "104": [0, 0.69444, 0.01778, 0, 0.51667],
  2493. "105": [0, 0.67937, 0.09718, 0, 0.23889],
  2494. "106": [0.19444, 0.67937, 0.09162, 0, 0.26667],
  2495. "107": [0, 0.69444, 0.08336, 0, 0.48889],
  2496. "108": [0, 0.69444, 0.09483, 0, 0.23889],
  2497. "109": [0, 0.44444, 0.01778, 0, 0.79445],
  2498. "110": [0, 0.44444, 0.01778, 0, 0.51667],
  2499. "111": [0, 0.44444, 0.06613, 0, 0.5],
  2500. "112": [0.19444, 0.44444, 0.0389, 0, 0.51667],
  2501. "113": [0.19444, 0.44444, 0.04169, 0, 0.51667],
  2502. "114": [0, 0.44444, 0.10836, 0, 0.34167],
  2503. "115": [0, 0.44444, 0.0778, 0, 0.38333],
  2504. "116": [0, 0.57143, 0.07225, 0, 0.36111],
  2505. "117": [0, 0.44444, 0.04169, 0, 0.51667],
  2506. "118": [0, 0.44444, 0.10836, 0, 0.46111],
  2507. "119": [0, 0.44444, 0.10836, 0, 0.68334],
  2508. "120": [0, 0.44444, 0.09169, 0, 0.46111],
  2509. "121": [0.19444, 0.44444, 0.10836, 0, 0.46111],
  2510. "122": [0, 0.44444, 0.08752, 0, 0.43472],
  2511. "126": [0.35, 0.32659, 0.08826, 0, 0.5],
  2512. "160": [0, 0, 0, 0, 0.25],
  2513. "168": [0, 0.67937, 0.06385, 0, 0.5],
  2514. "176": [0, 0.69444, 0, 0, 0.73752],
  2515. "184": [0.17014, 0, 0, 0, 0.44445],
  2516. "305": [0, 0.44444, 0.04169, 0, 0.23889],
  2517. "567": [0.19444, 0.44444, 0.04169, 0, 0.26667],
  2518. "710": [0, 0.69444, 0.0799, 0, 0.5],
  2519. "711": [0, 0.63194, 0.08432, 0, 0.5],
  2520. "713": [0, 0.60889, 0.08776, 0, 0.5],
  2521. "714": [0, 0.69444, 0.09205, 0, 0.5],
  2522. "715": [0, 0.69444, 0, 0, 0.5],
  2523. "728": [0, 0.69444, 0.09483, 0, 0.5],
  2524. "729": [0, 0.67937, 0.07774, 0, 0.27778],
  2525. "730": [0, 0.69444, 0, 0, 0.73752],
  2526. "732": [0, 0.67659, 0.08826, 0, 0.5],
  2527. "733": [0, 0.69444, 0.09205, 0, 0.5],
  2528. "915": [0, 0.69444, 0.13372, 0, 0.54167],
  2529. "916": [0, 0.69444, 0, 0, 0.83334],
  2530. "920": [0, 0.69444, 0.07555, 0, 0.77778],
  2531. "923": [0, 0.69444, 0, 0, 0.61111],
  2532. "926": [0, 0.69444, 0.12816, 0, 0.66667],
  2533. "928": [0, 0.69444, 0.08094, 0, 0.70834],
  2534. "931": [0, 0.69444, 0.11983, 0, 0.72222],
  2535. "933": [0, 0.69444, 0.09031, 0, 0.77778],
  2536. "934": [0, 0.69444, 0.04603, 0, 0.72222],
  2537. "936": [0, 0.69444, 0.09031, 0, 0.77778],
  2538. "937": [0, 0.69444, 0.08293, 0, 0.72222],
  2539. "8211": [0, 0.44444, 0.08616, 0, 0.5],
  2540. "8212": [0, 0.44444, 0.08616, 0, 1.0],
  2541. "8216": [0, 0.69444, 0.07816, 0, 0.27778],
  2542. "8217": [0, 0.69444, 0.07816, 0, 0.27778],
  2543. "8220": [0, 0.69444, 0.14205, 0, 0.5],
  2544. "8221": [0, 0.69444, 0.00316, 0, 0.5]
  2545. },
  2546. "SansSerif-Regular": {
  2547. "32": [0, 0, 0, 0, 0.25],
  2548. "33": [0, 0.69444, 0, 0, 0.31945],
  2549. "34": [0, 0.69444, 0, 0, 0.5],
  2550. "35": [0.19444, 0.69444, 0, 0, 0.83334],
  2551. "36": [0.05556, 0.75, 0, 0, 0.5],
  2552. "37": [0.05556, 0.75, 0, 0, 0.83334],
  2553. "38": [0, 0.69444, 0, 0, 0.75834],
  2554. "39": [0, 0.69444, 0, 0, 0.27778],
  2555. "40": [0.25, 0.75, 0, 0, 0.38889],
  2556. "41": [0.25, 0.75, 0, 0, 0.38889],
  2557. "42": [0, 0.75, 0, 0, 0.5],
  2558. "43": [0.08333, 0.58333, 0, 0, 0.77778],
  2559. "44": [0.125, 0.08333, 0, 0, 0.27778],
  2560. "45": [0, 0.44444, 0, 0, 0.33333],
  2561. "46": [0, 0.08333, 0, 0, 0.27778],
  2562. "47": [0.25, 0.75, 0, 0, 0.5],
  2563. "48": [0, 0.65556, 0, 0, 0.5],
  2564. "49": [0, 0.65556, 0, 0, 0.5],
  2565. "50": [0, 0.65556, 0, 0, 0.5],
  2566. "51": [0, 0.65556, 0, 0, 0.5],
  2567. "52": [0, 0.65556, 0, 0, 0.5],
  2568. "53": [0, 0.65556, 0, 0, 0.5],
  2569. "54": [0, 0.65556, 0, 0, 0.5],
  2570. "55": [0, 0.65556, 0, 0, 0.5],
  2571. "56": [0, 0.65556, 0, 0, 0.5],
  2572. "57": [0, 0.65556, 0, 0, 0.5],
  2573. "58": [0, 0.44444, 0, 0, 0.27778],
  2574. "59": [0.125, 0.44444, 0, 0, 0.27778],
  2575. "61": [-0.13, 0.37, 0, 0, 0.77778],
  2576. "63": [0, 0.69444, 0, 0, 0.47222],
  2577. "64": [0, 0.69444, 0, 0, 0.66667],
  2578. "65": [0, 0.69444, 0, 0, 0.66667],
  2579. "66": [0, 0.69444, 0, 0, 0.66667],
  2580. "67": [0, 0.69444, 0, 0, 0.63889],
  2581. "68": [0, 0.69444, 0, 0, 0.72223],
  2582. "69": [0, 0.69444, 0, 0, 0.59722],
  2583. "70": [0, 0.69444, 0, 0, 0.56945],
  2584. "71": [0, 0.69444, 0, 0, 0.66667],
  2585. "72": [0, 0.69444, 0, 0, 0.70834],
  2586. "73": [0, 0.69444, 0, 0, 0.27778],
  2587. "74": [0, 0.69444, 0, 0, 0.47222],
  2588. "75": [0, 0.69444, 0, 0, 0.69445],
  2589. "76": [0, 0.69444, 0, 0, 0.54167],
  2590. "77": [0, 0.69444, 0, 0, 0.875],
  2591. "78": [0, 0.69444, 0, 0, 0.70834],
  2592. "79": [0, 0.69444, 0, 0, 0.73611],
  2593. "80": [0, 0.69444, 0, 0, 0.63889],
  2594. "81": [0.125, 0.69444, 0, 0, 0.73611],
  2595. "82": [0, 0.69444, 0, 0, 0.64584],
  2596. "83": [0, 0.69444, 0, 0, 0.55556],
  2597. "84": [0, 0.69444, 0, 0, 0.68056],
  2598. "85": [0, 0.69444, 0, 0, 0.6875],
  2599. "86": [0, 0.69444, 0.01389, 0, 0.66667],
  2600. "87": [0, 0.69444, 0.01389, 0, 0.94445],
  2601. "88": [0, 0.69444, 0, 0, 0.66667],
  2602. "89": [0, 0.69444, 0.025, 0, 0.66667],
  2603. "90": [0, 0.69444, 0, 0, 0.61111],
  2604. "91": [0.25, 0.75, 0, 0, 0.28889],
  2605. "93": [0.25, 0.75, 0, 0, 0.28889],
  2606. "94": [0, 0.69444, 0, 0, 0.5],
  2607. "95": [0.35, 0.09444, 0.02778, 0, 0.5],
  2608. "97": [0, 0.44444, 0, 0, 0.48056],
  2609. "98": [0, 0.69444, 0, 0, 0.51667],
  2610. "99": [0, 0.44444, 0, 0, 0.44445],
  2611. "100": [0, 0.69444, 0, 0, 0.51667],
  2612. "101": [0, 0.44444, 0, 0, 0.44445],
  2613. "102": [0, 0.69444, 0.06944, 0, 0.30556],
  2614. "103": [0.19444, 0.44444, 0.01389, 0, 0.5],
  2615. "104": [0, 0.69444, 0, 0, 0.51667],
  2616. "105": [0, 0.67937, 0, 0, 0.23889],
  2617. "106": [0.19444, 0.67937, 0, 0, 0.26667],
  2618. "107": [0, 0.69444, 0, 0, 0.48889],
  2619. "108": [0, 0.69444, 0, 0, 0.23889],
  2620. "109": [0, 0.44444, 0, 0, 0.79445],
  2621. "110": [0, 0.44444, 0, 0, 0.51667],
  2622. "111": [0, 0.44444, 0, 0, 0.5],
  2623. "112": [0.19444, 0.44444, 0, 0, 0.51667],
  2624. "113": [0.19444, 0.44444, 0, 0, 0.51667],
  2625. "114": [0, 0.44444, 0.01389, 0, 0.34167],
  2626. "115": [0, 0.44444, 0, 0, 0.38333],
  2627. "116": [0, 0.57143, 0, 0, 0.36111],
  2628. "117": [0, 0.44444, 0, 0, 0.51667],
  2629. "118": [0, 0.44444, 0.01389, 0, 0.46111],
  2630. "119": [0, 0.44444, 0.01389, 0, 0.68334],
  2631. "120": [0, 0.44444, 0, 0, 0.46111],
  2632. "121": [0.19444, 0.44444, 0.01389, 0, 0.46111],
  2633. "122": [0, 0.44444, 0, 0, 0.43472],
  2634. "126": [0.35, 0.32659, 0, 0, 0.5],
  2635. "160": [0, 0, 0, 0, 0.25],
  2636. "168": [0, 0.67937, 0, 0, 0.5],
  2637. "176": [0, 0.69444, 0, 0, 0.66667],
  2638. "184": [0.17014, 0, 0, 0, 0.44445],
  2639. "305": [0, 0.44444, 0, 0, 0.23889],
  2640. "567": [0.19444, 0.44444, 0, 0, 0.26667],
  2641. "710": [0, 0.69444, 0, 0, 0.5],
  2642. "711": [0, 0.63194, 0, 0, 0.5],
  2643. "713": [0, 0.60889, 0, 0, 0.5],
  2644. "714": [0, 0.69444, 0, 0, 0.5],
  2645. "715": [0, 0.69444, 0, 0, 0.5],
  2646. "728": [0, 0.69444, 0, 0, 0.5],
  2647. "729": [0, 0.67937, 0, 0, 0.27778],
  2648. "730": [0, 0.69444, 0, 0, 0.66667],
  2649. "732": [0, 0.67659, 0, 0, 0.5],
  2650. "733": [0, 0.69444, 0, 0, 0.5],
  2651. "915": [0, 0.69444, 0, 0, 0.54167],
  2652. "916": [0, 0.69444, 0, 0, 0.83334],
  2653. "920": [0, 0.69444, 0, 0, 0.77778],
  2654. "923": [0, 0.69444, 0, 0, 0.61111],
  2655. "926": [0, 0.69444, 0, 0, 0.66667],
  2656. "928": [0, 0.69444, 0, 0, 0.70834],
  2657. "931": [0, 0.69444, 0, 0, 0.72222],
  2658. "933": [0, 0.69444, 0, 0, 0.77778],
  2659. "934": [0, 0.69444, 0, 0, 0.72222],
  2660. "936": [0, 0.69444, 0, 0, 0.77778],
  2661. "937": [0, 0.69444, 0, 0, 0.72222],
  2662. "8211": [0, 0.44444, 0.02778, 0, 0.5],
  2663. "8212": [0, 0.44444, 0.02778, 0, 1.0],
  2664. "8216": [0, 0.69444, 0, 0, 0.27778],
  2665. "8217": [0, 0.69444, 0, 0, 0.27778],
  2666. "8220": [0, 0.69444, 0, 0, 0.5],
  2667. "8221": [0, 0.69444, 0, 0, 0.5]
  2668. },
  2669. "Script-Regular": {
  2670. "32": [0, 0, 0, 0, 0.25],
  2671. "65": [0, 0.7, 0.22925, 0, 0.80253],
  2672. "66": [0, 0.7, 0.04087, 0, 0.90757],
  2673. "67": [0, 0.7, 0.1689, 0, 0.66619],
  2674. "68": [0, 0.7, 0.09371, 0, 0.77443],
  2675. "69": [0, 0.7, 0.18583, 0, 0.56162],
  2676. "70": [0, 0.7, 0.13634, 0, 0.89544],
  2677. "71": [0, 0.7, 0.17322, 0, 0.60961],
  2678. "72": [0, 0.7, 0.29694, 0, 0.96919],
  2679. "73": [0, 0.7, 0.19189, 0, 0.80907],
  2680. "74": [0.27778, 0.7, 0.19189, 0, 1.05159],
  2681. "75": [0, 0.7, 0.31259, 0, 0.91364],
  2682. "76": [0, 0.7, 0.19189, 0, 0.87373],
  2683. "77": [0, 0.7, 0.15981, 0, 1.08031],
  2684. "78": [0, 0.7, 0.3525, 0, 0.9015],
  2685. "79": [0, 0.7, 0.08078, 0, 0.73787],
  2686. "80": [0, 0.7, 0.08078, 0, 1.01262],
  2687. "81": [0, 0.7, 0.03305, 0, 0.88282],
  2688. "82": [0, 0.7, 0.06259, 0, 0.85],
  2689. "83": [0, 0.7, 0.19189, 0, 0.86767],
  2690. "84": [0, 0.7, 0.29087, 0, 0.74697],
  2691. "85": [0, 0.7, 0.25815, 0, 0.79996],
  2692. "86": [0, 0.7, 0.27523, 0, 0.62204],
  2693. "87": [0, 0.7, 0.27523, 0, 0.80532],
  2694. "88": [0, 0.7, 0.26006, 0, 0.94445],
  2695. "89": [0, 0.7, 0.2939, 0, 0.70961],
  2696. "90": [0, 0.7, 0.24037, 0, 0.8212],
  2697. "160": [0, 0, 0, 0, 0.25]
  2698. },
  2699. "Size1-Regular": {
  2700. "32": [0, 0, 0, 0, 0.25],
  2701. "40": [0.35001, 0.85, 0, 0, 0.45834],
  2702. "41": [0.35001, 0.85, 0, 0, 0.45834],
  2703. "47": [0.35001, 0.85, 0, 0, 0.57778],
  2704. "91": [0.35001, 0.85, 0, 0, 0.41667],
  2705. "92": [0.35001, 0.85, 0, 0, 0.57778],
  2706. "93": [0.35001, 0.85, 0, 0, 0.41667],
  2707. "123": [0.35001, 0.85, 0, 0, 0.58334],
  2708. "125": [0.35001, 0.85, 0, 0, 0.58334],
  2709. "160": [0, 0, 0, 0, 0.25],
  2710. "710": [0, 0.72222, 0, 0, 0.55556],
  2711. "732": [0, 0.72222, 0, 0, 0.55556],
  2712. "770": [0, 0.72222, 0, 0, 0.55556],
  2713. "771": [0, 0.72222, 0, 0, 0.55556],
  2714. "8214": [-0.00099, 0.601, 0, 0, 0.77778],
  2715. "8593": [1e-05, 0.6, 0, 0, 0.66667],
  2716. "8595": [1e-05, 0.6, 0, 0, 0.66667],
  2717. "8657": [1e-05, 0.6, 0, 0, 0.77778],
  2718. "8659": [1e-05, 0.6, 0, 0, 0.77778],
  2719. "8719": [0.25001, 0.75, 0, 0, 0.94445],
  2720. "8720": [0.25001, 0.75, 0, 0, 0.94445],
  2721. "8721": [0.25001, 0.75, 0, 0, 1.05556],
  2722. "8730": [0.35001, 0.85, 0, 0, 1.0],
  2723. "8739": [-0.00599, 0.606, 0, 0, 0.33333],
  2724. "8741": [-0.00599, 0.606, 0, 0, 0.55556],
  2725. "8747": [0.30612, 0.805, 0.19445, 0, 0.47222],
  2726. "8748": [0.306, 0.805, 0.19445, 0, 0.47222],
  2727. "8749": [0.306, 0.805, 0.19445, 0, 0.47222],
  2728. "8750": [0.30612, 0.805, 0.19445, 0, 0.47222],
  2729. "8896": [0.25001, 0.75, 0, 0, 0.83334],
  2730. "8897": [0.25001, 0.75, 0, 0, 0.83334],
  2731. "8898": [0.25001, 0.75, 0, 0, 0.83334],
  2732. "8899": [0.25001, 0.75, 0, 0, 0.83334],
  2733. "8968": [0.35001, 0.85, 0, 0, 0.47222],
  2734. "8969": [0.35001, 0.85, 0, 0, 0.47222],
  2735. "8970": [0.35001, 0.85, 0, 0, 0.47222],
  2736. "8971": [0.35001, 0.85, 0, 0, 0.47222],
  2737. "9168": [-0.00099, 0.601, 0, 0, 0.66667],
  2738. "10216": [0.35001, 0.85, 0, 0, 0.47222],
  2739. "10217": [0.35001, 0.85, 0, 0, 0.47222],
  2740. "10752": [0.25001, 0.75, 0, 0, 1.11111],
  2741. "10753": [0.25001, 0.75, 0, 0, 1.11111],
  2742. "10754": [0.25001, 0.75, 0, 0, 1.11111],
  2743. "10756": [0.25001, 0.75, 0, 0, 0.83334],
  2744. "10758": [0.25001, 0.75, 0, 0, 0.83334]
  2745. },
  2746. "Size2-Regular": {
  2747. "32": [0, 0, 0, 0, 0.25],
  2748. "40": [0.65002, 1.15, 0, 0, 0.59722],
  2749. "41": [0.65002, 1.15, 0, 0, 0.59722],
  2750. "47": [0.65002, 1.15, 0, 0, 0.81111],
  2751. "91": [0.65002, 1.15, 0, 0, 0.47222],
  2752. "92": [0.65002, 1.15, 0, 0, 0.81111],
  2753. "93": [0.65002, 1.15, 0, 0, 0.47222],
  2754. "123": [0.65002, 1.15, 0, 0, 0.66667],
  2755. "125": [0.65002, 1.15, 0, 0, 0.66667],
  2756. "160": [0, 0, 0, 0, 0.25],
  2757. "710": [0, 0.75, 0, 0, 1.0],
  2758. "732": [0, 0.75, 0, 0, 1.0],
  2759. "770": [0, 0.75, 0, 0, 1.0],
  2760. "771": [0, 0.75, 0, 0, 1.0],
  2761. "8719": [0.55001, 1.05, 0, 0, 1.27778],
  2762. "8720": [0.55001, 1.05, 0, 0, 1.27778],
  2763. "8721": [0.55001, 1.05, 0, 0, 1.44445],
  2764. "8730": [0.65002, 1.15, 0, 0, 1.0],
  2765. "8747": [0.86225, 1.36, 0.44445, 0, 0.55556],
  2766. "8748": [0.862, 1.36, 0.44445, 0, 0.55556],
  2767. "8749": [0.862, 1.36, 0.44445, 0, 0.55556],
  2768. "8750": [0.86225, 1.36, 0.44445, 0, 0.55556],
  2769. "8896": [0.55001, 1.05, 0, 0, 1.11111],
  2770. "8897": [0.55001, 1.05, 0, 0, 1.11111],
  2771. "8898": [0.55001, 1.05, 0, 0, 1.11111],
  2772. "8899": [0.55001, 1.05, 0, 0, 1.11111],
  2773. "8968": [0.65002, 1.15, 0, 0, 0.52778],
  2774. "8969": [0.65002, 1.15, 0, 0, 0.52778],
  2775. "8970": [0.65002, 1.15, 0, 0, 0.52778],
  2776. "8971": [0.65002, 1.15, 0, 0, 0.52778],
  2777. "10216": [0.65002, 1.15, 0, 0, 0.61111],
  2778. "10217": [0.65002, 1.15, 0, 0, 0.61111],
  2779. "10752": [0.55001, 1.05, 0, 0, 1.51112],
  2780. "10753": [0.55001, 1.05, 0, 0, 1.51112],
  2781. "10754": [0.55001, 1.05, 0, 0, 1.51112],
  2782. "10756": [0.55001, 1.05, 0, 0, 1.11111],
  2783. "10758": [0.55001, 1.05, 0, 0, 1.11111]
  2784. },
  2785. "Size3-Regular": {
  2786. "32": [0, 0, 0, 0, 0.25],
  2787. "40": [0.95003, 1.45, 0, 0, 0.73611],
  2788. "41": [0.95003, 1.45, 0, 0, 0.73611],
  2789. "47": [0.95003, 1.45, 0, 0, 1.04445],
  2790. "91": [0.95003, 1.45, 0, 0, 0.52778],
  2791. "92": [0.95003, 1.45, 0, 0, 1.04445],
  2792. "93": [0.95003, 1.45, 0, 0, 0.52778],
  2793. "123": [0.95003, 1.45, 0, 0, 0.75],
  2794. "125": [0.95003, 1.45, 0, 0, 0.75],
  2795. "160": [0, 0, 0, 0, 0.25],
  2796. "710": [0, 0.75, 0, 0, 1.44445],
  2797. "732": [0, 0.75, 0, 0, 1.44445],
  2798. "770": [0, 0.75, 0, 0, 1.44445],
  2799. "771": [0, 0.75, 0, 0, 1.44445],
  2800. "8730": [0.95003, 1.45, 0, 0, 1.0],
  2801. "8968": [0.95003, 1.45, 0, 0, 0.58334],
  2802. "8969": [0.95003, 1.45, 0, 0, 0.58334],
  2803. "8970": [0.95003, 1.45, 0, 0, 0.58334],
  2804. "8971": [0.95003, 1.45, 0, 0, 0.58334],
  2805. "10216": [0.95003, 1.45, 0, 0, 0.75],
  2806. "10217": [0.95003, 1.45, 0, 0, 0.75]
  2807. },
  2808. "Size4-Regular": {
  2809. "32": [0, 0, 0, 0, 0.25],
  2810. "40": [1.25003, 1.75, 0, 0, 0.79167],
  2811. "41": [1.25003, 1.75, 0, 0, 0.79167],
  2812. "47": [1.25003, 1.75, 0, 0, 1.27778],
  2813. "91": [1.25003, 1.75, 0, 0, 0.58334],
  2814. "92": [1.25003, 1.75, 0, 0, 1.27778],
  2815. "93": [1.25003, 1.75, 0, 0, 0.58334],
  2816. "123": [1.25003, 1.75, 0, 0, 0.80556],
  2817. "125": [1.25003, 1.75, 0, 0, 0.80556],
  2818. "160": [0, 0, 0, 0, 0.25],
  2819. "710": [0, 0.825, 0, 0, 1.8889],
  2820. "732": [0, 0.825, 0, 0, 1.8889],
  2821. "770": [0, 0.825, 0, 0, 1.8889],
  2822. "771": [0, 0.825, 0, 0, 1.8889],
  2823. "8730": [1.25003, 1.75, 0, 0, 1.0],
  2824. "8968": [1.25003, 1.75, 0, 0, 0.63889],
  2825. "8969": [1.25003, 1.75, 0, 0, 0.63889],
  2826. "8970": [1.25003, 1.75, 0, 0, 0.63889],
  2827. "8971": [1.25003, 1.75, 0, 0, 0.63889],
  2828. "9115": [0.64502, 1.155, 0, 0, 0.875],
  2829. "9116": [1e-05, 0.6, 0, 0, 0.875],
  2830. "9117": [0.64502, 1.155, 0, 0, 0.875],
  2831. "9118": [0.64502, 1.155, 0, 0, 0.875],
  2832. "9119": [1e-05, 0.6, 0, 0, 0.875],
  2833. "9120": [0.64502, 1.155, 0, 0, 0.875],
  2834. "9121": [0.64502, 1.155, 0, 0, 0.66667],
  2835. "9122": [-0.00099, 0.601, 0, 0, 0.66667],
  2836. "9123": [0.64502, 1.155, 0, 0, 0.66667],
  2837. "9124": [0.64502, 1.155, 0, 0, 0.66667],
  2838. "9125": [-0.00099, 0.601, 0, 0, 0.66667],
  2839. "9126": [0.64502, 1.155, 0, 0, 0.66667],
  2840. "9127": [1e-05, 0.9, 0, 0, 0.88889],
  2841. "9128": [0.65002, 1.15, 0, 0, 0.88889],
  2842. "9129": [0.90001, 0, 0, 0, 0.88889],
  2843. "9130": [0, 0.3, 0, 0, 0.88889],
  2844. "9131": [1e-05, 0.9, 0, 0, 0.88889],
  2845. "9132": [0.65002, 1.15, 0, 0, 0.88889],
  2846. "9133": [0.90001, 0, 0, 0, 0.88889],
  2847. "9143": [0.88502, 0.915, 0, 0, 1.05556],
  2848. "10216": [1.25003, 1.75, 0, 0, 0.80556],
  2849. "10217": [1.25003, 1.75, 0, 0, 0.80556],
  2850. "57344": [-0.00499, 0.605, 0, 0, 1.05556],
  2851. "57345": [-0.00499, 0.605, 0, 0, 1.05556],
  2852. "57680": [0, 0.12, 0, 0, 0.45],
  2853. "57681": [0, 0.12, 0, 0, 0.45],
  2854. "57682": [0, 0.12, 0, 0, 0.45],
  2855. "57683": [0, 0.12, 0, 0, 0.45]
  2856. },
  2857. "Typewriter-Regular": {
  2858. "32": [0, 0, 0, 0, 0.525],
  2859. "33": [0, 0.61111, 0, 0, 0.525],
  2860. "34": [0, 0.61111, 0, 0, 0.525],
  2861. "35": [0, 0.61111, 0, 0, 0.525],
  2862. "36": [0.08333, 0.69444, 0, 0, 0.525],
  2863. "37": [0.08333, 0.69444, 0, 0, 0.525],
  2864. "38": [0, 0.61111, 0, 0, 0.525],
  2865. "39": [0, 0.61111, 0, 0, 0.525],
  2866. "40": [0.08333, 0.69444, 0, 0, 0.525],
  2867. "41": [0.08333, 0.69444, 0, 0, 0.525],
  2868. "42": [0, 0.52083, 0, 0, 0.525],
  2869. "43": [-0.08056, 0.53055, 0, 0, 0.525],
  2870. "44": [0.13889, 0.125, 0, 0, 0.525],
  2871. "45": [-0.08056, 0.53055, 0, 0, 0.525],
  2872. "46": [0, 0.125, 0, 0, 0.525],
  2873. "47": [0.08333, 0.69444, 0, 0, 0.525],
  2874. "48": [0, 0.61111, 0, 0, 0.525],
  2875. "49": [0, 0.61111, 0, 0, 0.525],
  2876. "50": [0, 0.61111, 0, 0, 0.525],
  2877. "51": [0, 0.61111, 0, 0, 0.525],
  2878. "52": [0, 0.61111, 0, 0, 0.525],
  2879. "53": [0, 0.61111, 0, 0, 0.525],
  2880. "54": [0, 0.61111, 0, 0, 0.525],
  2881. "55": [0, 0.61111, 0, 0, 0.525],
  2882. "56": [0, 0.61111, 0, 0, 0.525],
  2883. "57": [0, 0.61111, 0, 0, 0.525],
  2884. "58": [0, 0.43056, 0, 0, 0.525],
  2885. "59": [0.13889, 0.43056, 0, 0, 0.525],
  2886. "60": [-0.05556, 0.55556, 0, 0, 0.525],
  2887. "61": [-0.19549, 0.41562, 0, 0, 0.525],
  2888. "62": [-0.05556, 0.55556, 0, 0, 0.525],
  2889. "63": [0, 0.61111, 0, 0, 0.525],
  2890. "64": [0, 0.61111, 0, 0, 0.525],
  2891. "65": [0, 0.61111, 0, 0, 0.525],
  2892. "66": [0, 0.61111, 0, 0, 0.525],
  2893. "67": [0, 0.61111, 0, 0, 0.525],
  2894. "68": [0, 0.61111, 0, 0, 0.525],
  2895. "69": [0, 0.61111, 0, 0, 0.525],
  2896. "70": [0, 0.61111, 0, 0, 0.525],
  2897. "71": [0, 0.61111, 0, 0, 0.525],
  2898. "72": [0, 0.61111, 0, 0, 0.525],
  2899. "73": [0, 0.61111, 0, 0, 0.525],
  2900. "74": [0, 0.61111, 0, 0, 0.525],
  2901. "75": [0, 0.61111, 0, 0, 0.525],
  2902. "76": [0, 0.61111, 0, 0, 0.525],
  2903. "77": [0, 0.61111, 0, 0, 0.525],
  2904. "78": [0, 0.61111, 0, 0, 0.525],
  2905. "79": [0, 0.61111, 0, 0, 0.525],
  2906. "80": [0, 0.61111, 0, 0, 0.525],
  2907. "81": [0.13889, 0.61111, 0, 0, 0.525],
  2908. "82": [0, 0.61111, 0, 0, 0.525],
  2909. "83": [0, 0.61111, 0, 0, 0.525],
  2910. "84": [0, 0.61111, 0, 0, 0.525],
  2911. "85": [0, 0.61111, 0, 0, 0.525],
  2912. "86": [0, 0.61111, 0, 0, 0.525],
  2913. "87": [0, 0.61111, 0, 0, 0.525],
  2914. "88": [0, 0.61111, 0, 0, 0.525],
  2915. "89": [0, 0.61111, 0, 0, 0.525],
  2916. "90": [0, 0.61111, 0, 0, 0.525],
  2917. "91": [0.08333, 0.69444, 0, 0, 0.525],
  2918. "92": [0.08333, 0.69444, 0, 0, 0.525],
  2919. "93": [0.08333, 0.69444, 0, 0, 0.525],
  2920. "94": [0, 0.61111, 0, 0, 0.525],
  2921. "95": [0.09514, 0, 0, 0, 0.525],
  2922. "96": [0, 0.61111, 0, 0, 0.525],
  2923. "97": [0, 0.43056, 0, 0, 0.525],
  2924. "98": [0, 0.61111, 0, 0, 0.525],
  2925. "99": [0, 0.43056, 0, 0, 0.525],
  2926. "100": [0, 0.61111, 0, 0, 0.525],
  2927. "101": [0, 0.43056, 0, 0, 0.525],
  2928. "102": [0, 0.61111, 0, 0, 0.525],
  2929. "103": [0.22222, 0.43056, 0, 0, 0.525],
  2930. "104": [0, 0.61111, 0, 0, 0.525],
  2931. "105": [0, 0.61111, 0, 0, 0.525],
  2932. "106": [0.22222, 0.61111, 0, 0, 0.525],
  2933. "107": [0, 0.61111, 0, 0, 0.525],
  2934. "108": [0, 0.61111, 0, 0, 0.525],
  2935. "109": [0, 0.43056, 0, 0, 0.525],
  2936. "110": [0, 0.43056, 0, 0, 0.525],
  2937. "111": [0, 0.43056, 0, 0, 0.525],
  2938. "112": [0.22222, 0.43056, 0, 0, 0.525],
  2939. "113": [0.22222, 0.43056, 0, 0, 0.525],
  2940. "114": [0, 0.43056, 0, 0, 0.525],
  2941. "115": [0, 0.43056, 0, 0, 0.525],
  2942. "116": [0, 0.55358, 0, 0, 0.525],
  2943. "117": [0, 0.43056, 0, 0, 0.525],
  2944. "118": [0, 0.43056, 0, 0, 0.525],
  2945. "119": [0, 0.43056, 0, 0, 0.525],
  2946. "120": [0, 0.43056, 0, 0, 0.525],
  2947. "121": [0.22222, 0.43056, 0, 0, 0.525],
  2948. "122": [0, 0.43056, 0, 0, 0.525],
  2949. "123": [0.08333, 0.69444, 0, 0, 0.525],
  2950. "124": [0.08333, 0.69444, 0, 0, 0.525],
  2951. "125": [0.08333, 0.69444, 0, 0, 0.525],
  2952. "126": [0, 0.61111, 0, 0, 0.525],
  2953. "127": [0, 0.61111, 0, 0, 0.525],
  2954. "160": [0, 0, 0, 0, 0.525],
  2955. "176": [0, 0.61111, 0, 0, 0.525],
  2956. "184": [0.19445, 0, 0, 0, 0.525],
  2957. "305": [0, 0.43056, 0, 0, 0.525],
  2958. "567": [0.22222, 0.43056, 0, 0, 0.525],
  2959. "711": [0, 0.56597, 0, 0, 0.525],
  2960. "713": [0, 0.56555, 0, 0, 0.525],
  2961. "714": [0, 0.61111, 0, 0, 0.525],
  2962. "715": [0, 0.61111, 0, 0, 0.525],
  2963. "728": [0, 0.61111, 0, 0, 0.525],
  2964. "730": [0, 0.61111, 0, 0, 0.525],
  2965. "770": [0, 0.61111, 0, 0, 0.525],
  2966. "771": [0, 0.61111, 0, 0, 0.525],
  2967. "776": [0, 0.61111, 0, 0, 0.525],
  2968. "915": [0, 0.61111, 0, 0, 0.525],
  2969. "916": [0, 0.61111, 0, 0, 0.525],
  2970. "920": [0, 0.61111, 0, 0, 0.525],
  2971. "923": [0, 0.61111, 0, 0, 0.525],
  2972. "926": [0, 0.61111, 0, 0, 0.525],
  2973. "928": [0, 0.61111, 0, 0, 0.525],
  2974. "931": [0, 0.61111, 0, 0, 0.525],
  2975. "933": [0, 0.61111, 0, 0, 0.525],
  2976. "934": [0, 0.61111, 0, 0, 0.525],
  2977. "936": [0, 0.61111, 0, 0, 0.525],
  2978. "937": [0, 0.61111, 0, 0, 0.525],
  2979. "8216": [0, 0.61111, 0, 0, 0.525],
  2980. "8217": [0, 0.61111, 0, 0, 0.525],
  2981. "8242": [0, 0.61111, 0, 0, 0.525],
  2982. "9251": [0.11111, 0.21944, 0, 0, 0.525]
  2983. }
  2984. });
  2985. ;// CONCATENATED MODULE: ./src/fontMetrics.js
  2986. /**
  2987. * This file contains metrics regarding fonts and individual symbols. The sigma
  2988. * and xi variables, as well as the metricMap map contain data extracted from
  2989. * TeX, TeX font metrics, and the TTF files. These data are then exposed via the
  2990. * `metrics` variable and the getCharacterMetrics function.
  2991. */
  2992. // In TeX, there are actually three sets of dimensions, one for each of
  2993. // textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
  2994. // 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
  2995. // provided in the the arrays below, in that order.
  2996. //
  2997. // The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
  2998. // This was determined by running the following script:
  2999. //
  3000. // latex -interaction=nonstopmode \
  3001. // '\documentclass{article}\usepackage{amsmath}\begin{document}' \
  3002. // '$a$ \expandafter\show\the\textfont2' \
  3003. // '\expandafter\show\the\scriptfont2' \
  3004. // '\expandafter\show\the\scriptscriptfont2' \
  3005. // '\stop'
  3006. //
  3007. // The metrics themselves were retreived using the following commands:
  3008. //
  3009. // tftopl cmsy10
  3010. // tftopl cmsy7
  3011. // tftopl cmsy5
  3012. //
  3013. // The output of each of these commands is quite lengthy. The only part we
  3014. // care about is the FONTDIMEN section. Each value is measured in EMs.
  3015. var sigmasAndXis = {
  3016. slant: [0.250, 0.250, 0.250],
  3017. // sigma1
  3018. space: [0.000, 0.000, 0.000],
  3019. // sigma2
  3020. stretch: [0.000, 0.000, 0.000],
  3021. // sigma3
  3022. shrink: [0.000, 0.000, 0.000],
  3023. // sigma4
  3024. xHeight: [0.431, 0.431, 0.431],
  3025. // sigma5
  3026. quad: [1.000, 1.171, 1.472],
  3027. // sigma6
  3028. extraSpace: [0.000, 0.000, 0.000],
  3029. // sigma7
  3030. num1: [0.677, 0.732, 0.925],
  3031. // sigma8
  3032. num2: [0.394, 0.384, 0.387],
  3033. // sigma9
  3034. num3: [0.444, 0.471, 0.504],
  3035. // sigma10
  3036. denom1: [0.686, 0.752, 1.025],
  3037. // sigma11
  3038. denom2: [0.345, 0.344, 0.532],
  3039. // sigma12
  3040. sup1: [0.413, 0.503, 0.504],
  3041. // sigma13
  3042. sup2: [0.363, 0.431, 0.404],
  3043. // sigma14
  3044. sup3: [0.289, 0.286, 0.294],
  3045. // sigma15
  3046. sub1: [0.150, 0.143, 0.200],
  3047. // sigma16
  3048. sub2: [0.247, 0.286, 0.400],
  3049. // sigma17
  3050. supDrop: [0.386, 0.353, 0.494],
  3051. // sigma18
  3052. subDrop: [0.050, 0.071, 0.100],
  3053. // sigma19
  3054. delim1: [2.390, 1.700, 1.980],
  3055. // sigma20
  3056. delim2: [1.010, 1.157, 1.420],
  3057. // sigma21
  3058. axisHeight: [0.250, 0.250, 0.250],
  3059. // sigma22
  3060. // These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
  3061. // they correspond to the font parameters of the extension fonts (family 3).
  3062. // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
  3063. // match cmex7, we'd use cmex7.tfm values for script and scriptscript
  3064. // values.
  3065. defaultRuleThickness: [0.04, 0.049, 0.049],
  3066. // xi8; cmex7: 0.049
  3067. bigOpSpacing1: [0.111, 0.111, 0.111],
  3068. // xi9
  3069. bigOpSpacing2: [0.166, 0.166, 0.166],
  3070. // xi10
  3071. bigOpSpacing3: [0.2, 0.2, 0.2],
  3072. // xi11
  3073. bigOpSpacing4: [0.6, 0.611, 0.611],
  3074. // xi12; cmex7: 0.611
  3075. bigOpSpacing5: [0.1, 0.143, 0.143],
  3076. // xi13; cmex7: 0.143
  3077. // The \sqrt rule width is taken from the height of the surd character.
  3078. // Since we use the same font at all sizes, this thickness doesn't scale.
  3079. sqrtRuleThickness: [0.04, 0.04, 0.04],
  3080. // This value determines how large a pt is, for metrics which are defined
  3081. // in terms of pts.
  3082. // This value is also used in katex.less; if you change it make sure the
  3083. // values match.
  3084. ptPerEm: [10.0, 10.0, 10.0],
  3085. // The space between adjacent `|` columns in an array definition. From
  3086. // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
  3087. doubleRuleSep: [0.2, 0.2, 0.2],
  3088. // The width of separator lines in {array} environments. From
  3089. // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
  3090. arrayRuleWidth: [0.04, 0.04, 0.04],
  3091. // Two values from LaTeX source2e:
  3092. fboxsep: [0.3, 0.3, 0.3],
  3093. // 3 pt / ptPerEm
  3094. fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm
  3095. }; // This map contains a mapping from font name and character code to character
  3096. // metrics, including height, depth, italic correction, and skew (kern from the
  3097. // character to the corresponding \skewchar)
  3098. // This map is generated via `make metrics`. It should not be changed manually.
  3099. // These are very rough approximations. We default to Times New Roman which
  3100. // should have Latin-1 and Cyrillic characters, but may not depending on the
  3101. // operating system. The metrics do not account for extra height from the
  3102. // accents. In the case of Cyrillic characters which have both ascenders and
  3103. // descenders we prefer approximations with ascenders, primarily to prevent
  3104. // the fraction bar or root line from intersecting the glyph.
  3105. // TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
  3106. var extraCharacterMap = {
  3107. // Latin-1
  3108. 'Å': 'A',
  3109. 'Ð': 'D',
  3110. 'Þ': 'o',
  3111. 'å': 'a',
  3112. 'ð': 'd',
  3113. 'þ': 'o',
  3114. // Cyrillic
  3115. 'А': 'A',
  3116. 'Б': 'B',
  3117. 'В': 'B',
  3118. 'Г': 'F',
  3119. 'Д': 'A',
  3120. 'Е': 'E',
  3121. 'Ж': 'K',
  3122. 'З': '3',
  3123. 'И': 'N',
  3124. 'Й': 'N',
  3125. 'К': 'K',
  3126. 'Л': 'N',
  3127. 'М': 'M',
  3128. 'Н': 'H',
  3129. 'О': 'O',
  3130. 'П': 'N',
  3131. 'Р': 'P',
  3132. 'С': 'C',
  3133. 'Т': 'T',
  3134. 'У': 'y',
  3135. 'Ф': 'O',
  3136. 'Х': 'X',
  3137. 'Ц': 'U',
  3138. 'Ч': 'h',
  3139. 'Ш': 'W',
  3140. 'Щ': 'W',
  3141. 'Ъ': 'B',
  3142. 'Ы': 'X',
  3143. 'Ь': 'B',
  3144. 'Э': '3',
  3145. 'Ю': 'X',
  3146. 'Я': 'R',
  3147. 'а': 'a',
  3148. 'б': 'b',
  3149. 'в': 'a',
  3150. 'г': 'r',
  3151. 'д': 'y',
  3152. 'е': 'e',
  3153. 'ж': 'm',
  3154. 'з': 'e',
  3155. 'и': 'n',
  3156. 'й': 'n',
  3157. 'к': 'n',
  3158. 'л': 'n',
  3159. 'м': 'm',
  3160. 'н': 'n',
  3161. 'о': 'o',
  3162. 'п': 'n',
  3163. 'р': 'p',
  3164. 'с': 'c',
  3165. 'т': 'o',
  3166. 'у': 'y',
  3167. 'ф': 'b',
  3168. 'х': 'x',
  3169. 'ц': 'n',
  3170. 'ч': 'n',
  3171. 'ш': 'w',
  3172. 'щ': 'w',
  3173. 'ъ': 'a',
  3174. 'ы': 'm',
  3175. 'ь': 'a',
  3176. 'э': 'e',
  3177. 'ю': 'm',
  3178. 'я': 'r'
  3179. };
  3180. /**
  3181. * This function adds new font metrics to default metricMap
  3182. * It can also override existing metrics
  3183. */
  3184. function setFontMetrics(fontName, metrics) {
  3185. fontMetricsData[fontName] = metrics;
  3186. }
  3187. /**
  3188. * This function is a convenience function for looking up information in the
  3189. * metricMap table. It takes a character as a string, and a font.
  3190. *
  3191. * Note: the `width` property may be undefined if fontMetricsData.js wasn't
  3192. * built using `Make extended_metrics`.
  3193. */
  3194. function getCharacterMetrics(character, font, mode) {
  3195. if (!fontMetricsData[font]) {
  3196. throw new Error("Font metrics not found for font: " + font + ".");
  3197. }
  3198. var ch = character.charCodeAt(0);
  3199. var metrics = fontMetricsData[font][ch];
  3200. if (!metrics && character[0] in extraCharacterMap) {
  3201. ch = extraCharacterMap[character[0]].charCodeAt(0);
  3202. metrics = fontMetricsData[font][ch];
  3203. }
  3204. if (!metrics && mode === 'text') {
  3205. // We don't typically have font metrics for Asian scripts.
  3206. // But since we support them in text mode, we need to return
  3207. // some sort of metrics.
  3208. // So if the character is in a script we support but we
  3209. // don't have metrics for it, just use the metrics for
  3210. // the Latin capital letter M. This is close enough because
  3211. // we (currently) only care about the height of the glpyh
  3212. // not its width.
  3213. if (supportedCodepoint(ch)) {
  3214. metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M'
  3215. }
  3216. }
  3217. if (metrics) {
  3218. return {
  3219. depth: metrics[0],
  3220. height: metrics[1],
  3221. italic: metrics[2],
  3222. skew: metrics[3],
  3223. width: metrics[4]
  3224. };
  3225. }
  3226. }
  3227. var fontMetricsBySizeIndex = {};
  3228. /**
  3229. * Get the font metrics for a given size.
  3230. */
  3231. function getGlobalMetrics(size) {
  3232. var sizeIndex;
  3233. if (size >= 5) {
  3234. sizeIndex = 0;
  3235. } else if (size >= 3) {
  3236. sizeIndex = 1;
  3237. } else {
  3238. sizeIndex = 2;
  3239. }
  3240. if (!fontMetricsBySizeIndex[sizeIndex]) {
  3241. var metrics = fontMetricsBySizeIndex[sizeIndex] = {
  3242. cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18
  3243. };
  3244. for (var key in sigmasAndXis) {
  3245. if (sigmasAndXis.hasOwnProperty(key)) {
  3246. metrics[key] = sigmasAndXis[key][sizeIndex];
  3247. }
  3248. }
  3249. }
  3250. return fontMetricsBySizeIndex[sizeIndex];
  3251. }
  3252. ;// CONCATENATED MODULE: ./src/Options.js
  3253. /**
  3254. * This file contains information about the options that the Parser carries
  3255. * around with it while parsing. Data is held in an `Options` object, and when
  3256. * recursing, a new `Options` object can be created with the `.with*` and
  3257. * `.reset` functions.
  3258. */
  3259. var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize].
  3260. // The size mappings are taken from TeX with \normalsize=10pt.
  3261. [1, 1, 1], // size1: [5, 5, 5] \tiny
  3262. [2, 1, 1], // size2: [6, 5, 5]
  3263. [3, 1, 1], // size3: [7, 5, 5] \scriptsize
  3264. [4, 2, 1], // size4: [8, 6, 5] \footnotesize
  3265. [5, 2, 1], // size5: [9, 6, 5] \small
  3266. [6, 3, 1], // size6: [10, 7, 5] \normalsize
  3267. [7, 4, 2], // size7: [12, 8, 6] \large
  3268. [8, 6, 3], // size8: [14.4, 10, 7] \Large
  3269. [9, 7, 6], // size9: [17.28, 12, 10] \LARGE
  3270. [10, 8, 7], // size10: [20.74, 14.4, 12] \huge
  3271. [11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE
  3272. ];
  3273. var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if
  3274. // you change size indexes, change that function.
  3275. 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
  3276. var sizeAtStyle = function sizeAtStyle(size, style) {
  3277. return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
  3278. }; // In these types, "" (empty string) means "no change".
  3279. /**
  3280. * This is the main options class. It contains the current style, size, color,
  3281. * and font.
  3282. *
  3283. * Options objects should not be modified. To create a new Options with
  3284. * different properties, call a `.having*` method.
  3285. */
  3286. var Options = /*#__PURE__*/function () {
  3287. // A font family applies to a group of fonts (i.e. SansSerif), while a font
  3288. // represents a specific font (i.e. SansSerif Bold).
  3289. // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm
  3290. /**
  3291. * The base size index.
  3292. */
  3293. function Options(data) {
  3294. this.style = void 0;
  3295. this.color = void 0;
  3296. this.size = void 0;
  3297. this.textSize = void 0;
  3298. this.phantom = void 0;
  3299. this.font = void 0;
  3300. this.fontFamily = void 0;
  3301. this.fontWeight = void 0;
  3302. this.fontShape = void 0;
  3303. this.sizeMultiplier = void 0;
  3304. this.maxSize = void 0;
  3305. this.minRuleThickness = void 0;
  3306. this._fontMetrics = void 0;
  3307. this.style = data.style;
  3308. this.color = data.color;
  3309. this.size = data.size || Options.BASESIZE;
  3310. this.textSize = data.textSize || this.size;
  3311. this.phantom = !!data.phantom;
  3312. this.font = data.font || "";
  3313. this.fontFamily = data.fontFamily || "";
  3314. this.fontWeight = data.fontWeight || '';
  3315. this.fontShape = data.fontShape || '';
  3316. this.sizeMultiplier = sizeMultipliers[this.size - 1];
  3317. this.maxSize = data.maxSize;
  3318. this.minRuleThickness = data.minRuleThickness;
  3319. this._fontMetrics = undefined;
  3320. }
  3321. /**
  3322. * Returns a new options object with the same properties as "this". Properties
  3323. * from "extension" will be copied to the new options object.
  3324. */
  3325. var _proto = Options.prototype;
  3326. _proto.extend = function extend(extension) {
  3327. var data = {
  3328. style: this.style,
  3329. size: this.size,
  3330. textSize: this.textSize,
  3331. color: this.color,
  3332. phantom: this.phantom,
  3333. font: this.font,
  3334. fontFamily: this.fontFamily,
  3335. fontWeight: this.fontWeight,
  3336. fontShape: this.fontShape,
  3337. maxSize: this.maxSize,
  3338. minRuleThickness: this.minRuleThickness
  3339. };
  3340. for (var key in extension) {
  3341. if (extension.hasOwnProperty(key)) {
  3342. data[key] = extension[key];
  3343. }
  3344. }
  3345. return new Options(data);
  3346. }
  3347. /**
  3348. * Return an options object with the given style. If `this.style === style`,
  3349. * returns `this`.
  3350. */
  3351. ;
  3352. _proto.havingStyle = function havingStyle(style) {
  3353. if (this.style === style) {
  3354. return this;
  3355. } else {
  3356. return this.extend({
  3357. style: style,
  3358. size: sizeAtStyle(this.textSize, style)
  3359. });
  3360. }
  3361. }
  3362. /**
  3363. * Return an options object with a cramped version of the current style. If
  3364. * the current style is cramped, returns `this`.
  3365. */
  3366. ;
  3367. _proto.havingCrampedStyle = function havingCrampedStyle() {
  3368. return this.havingStyle(this.style.cramp());
  3369. }
  3370. /**
  3371. * Return an options object with the given size and in at least `\textstyle`.
  3372. * Returns `this` if appropriate.
  3373. */
  3374. ;
  3375. _proto.havingSize = function havingSize(size) {
  3376. if (this.size === size && this.textSize === size) {
  3377. return this;
  3378. } else {
  3379. return this.extend({
  3380. style: this.style.text(),
  3381. size: size,
  3382. textSize: size,
  3383. sizeMultiplier: sizeMultipliers[size - 1]
  3384. });
  3385. }
  3386. }
  3387. /**
  3388. * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
  3389. * changes to at least `\textstyle`.
  3390. */
  3391. ;
  3392. _proto.havingBaseStyle = function havingBaseStyle(style) {
  3393. style = style || this.style.text();
  3394. var wantSize = sizeAtStyle(Options.BASESIZE, style);
  3395. if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) {
  3396. return this;
  3397. } else {
  3398. return this.extend({
  3399. style: style,
  3400. size: wantSize
  3401. });
  3402. }
  3403. }
  3404. /**
  3405. * Remove the effect of sizing changes such as \Huge.
  3406. * Keep the effect of the current style, such as \scriptstyle.
  3407. */
  3408. ;
  3409. _proto.havingBaseSizing = function havingBaseSizing() {
  3410. var size;
  3411. switch (this.style.id) {
  3412. case 4:
  3413. case 5:
  3414. size = 3; // normalsize in scriptstyle
  3415. break;
  3416. case 6:
  3417. case 7:
  3418. size = 1; // normalsize in scriptscriptstyle
  3419. break;
  3420. default:
  3421. size = 6;
  3422. // normalsize in textstyle or displaystyle
  3423. }
  3424. return this.extend({
  3425. style: this.style.text(),
  3426. size: size
  3427. });
  3428. }
  3429. /**
  3430. * Create a new options object with the given color.
  3431. */
  3432. ;
  3433. _proto.withColor = function withColor(color) {
  3434. return this.extend({
  3435. color: color
  3436. });
  3437. }
  3438. /**
  3439. * Create a new options object with "phantom" set to true.
  3440. */
  3441. ;
  3442. _proto.withPhantom = function withPhantom() {
  3443. return this.extend({
  3444. phantom: true
  3445. });
  3446. }
  3447. /**
  3448. * Creates a new options object with the given math font or old text font.
  3449. * @type {[type]}
  3450. */
  3451. ;
  3452. _proto.withFont = function withFont(font) {
  3453. return this.extend({
  3454. font: font
  3455. });
  3456. }
  3457. /**
  3458. * Create a new options objects with the given fontFamily.
  3459. */
  3460. ;
  3461. _proto.withTextFontFamily = function withTextFontFamily(fontFamily) {
  3462. return this.extend({
  3463. fontFamily: fontFamily,
  3464. font: ""
  3465. });
  3466. }
  3467. /**
  3468. * Creates a new options object with the given font weight
  3469. */
  3470. ;
  3471. _proto.withTextFontWeight = function withTextFontWeight(fontWeight) {
  3472. return this.extend({
  3473. fontWeight: fontWeight,
  3474. font: ""
  3475. });
  3476. }
  3477. /**
  3478. * Creates a new options object with the given font weight
  3479. */
  3480. ;
  3481. _proto.withTextFontShape = function withTextFontShape(fontShape) {
  3482. return this.extend({
  3483. fontShape: fontShape,
  3484. font: ""
  3485. });
  3486. }
  3487. /**
  3488. * Return the CSS sizing classes required to switch from enclosing options
  3489. * `oldOptions` to `this`. Returns an array of classes.
  3490. */
  3491. ;
  3492. _proto.sizingClasses = function sizingClasses(oldOptions) {
  3493. if (oldOptions.size !== this.size) {
  3494. return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
  3495. } else {
  3496. return [];
  3497. }
  3498. }
  3499. /**
  3500. * Return the CSS sizing classes required to switch to the base size. Like
  3501. * `this.havingSize(BASESIZE).sizingClasses(this)`.
  3502. */
  3503. ;
  3504. _proto.baseSizingClasses = function baseSizingClasses() {
  3505. if (this.size !== Options.BASESIZE) {
  3506. return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
  3507. } else {
  3508. return [];
  3509. }
  3510. }
  3511. /**
  3512. * Return the font metrics for this size.
  3513. */
  3514. ;
  3515. _proto.fontMetrics = function fontMetrics() {
  3516. if (!this._fontMetrics) {
  3517. this._fontMetrics = getGlobalMetrics(this.size);
  3518. }
  3519. return this._fontMetrics;
  3520. }
  3521. /**
  3522. * Gets the CSS color of the current options object
  3523. */
  3524. ;
  3525. _proto.getColor = function getColor() {
  3526. if (this.phantom) {
  3527. return "transparent";
  3528. } else {
  3529. return this.color;
  3530. }
  3531. };
  3532. return Options;
  3533. }();
  3534. Options.BASESIZE = 6;
  3535. /* harmony default export */ var src_Options = (Options);
  3536. ;// CONCATENATED MODULE: ./src/units.js
  3537. /**
  3538. * This file does conversion between units. In particular, it provides
  3539. * calculateSize to convert other units into ems.
  3540. */
  3541. // This table gives the number of TeX pts in one of each *absolute* TeX unit.
  3542. // Thus, multiplying a length by this number converts the length from units
  3543. // into pts. Dividing the result by ptPerEm gives the number of ems
  3544. // *assuming* a font size of ptPerEm (normal size, normal style).
  3545. var ptPerUnit = {
  3546. // https://en.wikibooks.org/wiki/LaTeX/Lengths and
  3547. // https://tex.stackexchange.com/a/8263
  3548. "pt": 1,
  3549. // TeX point
  3550. "mm": 7227 / 2540,
  3551. // millimeter
  3552. "cm": 7227 / 254,
  3553. // centimeter
  3554. "in": 72.27,
  3555. // inch
  3556. "bp": 803 / 800,
  3557. // big (PostScript) points
  3558. "pc": 12,
  3559. // pica
  3560. "dd": 1238 / 1157,
  3561. // didot
  3562. "cc": 14856 / 1157,
  3563. // cicero (12 didot)
  3564. "nd": 685 / 642,
  3565. // new didot
  3566. "nc": 1370 / 107,
  3567. // new cicero (12 new didot)
  3568. "sp": 1 / 65536,
  3569. // scaled point (TeX's internal smallest unit)
  3570. // https://tex.stackexchange.com/a/41371
  3571. "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX
  3572. }; // Dictionary of relative units, for fast validity testing.
  3573. var relativeUnit = {
  3574. "ex": true,
  3575. "em": true,
  3576. "mu": true
  3577. };
  3578. /**
  3579. * Determine whether the specified unit (either a string defining the unit
  3580. * or a "size" parse node containing a unit field) is valid.
  3581. */
  3582. var validUnit = function validUnit(unit) {
  3583. if (typeof unit !== "string") {
  3584. unit = unit.unit;
  3585. }
  3586. return unit in ptPerUnit || unit in relativeUnit || unit === "ex";
  3587. };
  3588. /*
  3589. * Convert a "size" parse node (with numeric "number" and string "unit" fields,
  3590. * as parsed by functions.js argType "size") into a CSS em value for the
  3591. * current style/scale. `options` gives the current options.
  3592. */
  3593. var calculateSize = function calculateSize(sizeValue, options) {
  3594. var scale;
  3595. if (sizeValue.unit in ptPerUnit) {
  3596. // Absolute units
  3597. scale = ptPerUnit[sizeValue.unit] // Convert unit to pt
  3598. / options.fontMetrics().ptPerEm // Convert pt to CSS em
  3599. / options.sizeMultiplier; // Unscale to make absolute units
  3600. } else if (sizeValue.unit === "mu") {
  3601. // `mu` units scale with scriptstyle/scriptscriptstyle.
  3602. scale = options.fontMetrics().cssEmPerMu;
  3603. } else {
  3604. // Other relative units always refer to the *textstyle* font
  3605. // in the current size.
  3606. var unitOptions;
  3607. if (options.style.isTight()) {
  3608. // isTight() means current style is script/scriptscript.
  3609. unitOptions = options.havingStyle(options.style.text());
  3610. } else {
  3611. unitOptions = options;
  3612. } // TODO: In TeX these units are relative to the quad of the current
  3613. // *text* font, e.g. cmr10. KaTeX instead uses values from the
  3614. // comparably-sized *Computer Modern symbol* font. At 10pt, these
  3615. // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
  3616. // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
  3617. // TeX \showlists shows a kern of 1.13889 * fontsize;
  3618. // KaTeX shows a kern of 1.171 * fontsize.
  3619. if (sizeValue.unit === "ex") {
  3620. scale = unitOptions.fontMetrics().xHeight;
  3621. } else if (sizeValue.unit === "em") {
  3622. scale = unitOptions.fontMetrics().quad;
  3623. } else {
  3624. throw new src_ParseError("Invalid unit: '" + sizeValue.unit + "'");
  3625. }
  3626. if (unitOptions !== options) {
  3627. scale *= unitOptions.sizeMultiplier / options.sizeMultiplier;
  3628. }
  3629. }
  3630. return Math.min(sizeValue.number * scale, options.maxSize);
  3631. };
  3632. /**
  3633. * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See
  3634. * https://github.com/KaTeX/KaTeX/pull/2460.
  3635. */
  3636. var makeEm = function makeEm(n) {
  3637. return +n.toFixed(4) + "em";
  3638. };
  3639. ;// CONCATENATED MODULE: ./src/domTree.js
  3640. /**
  3641. * These objects store the data about the DOM nodes we create, as well as some
  3642. * extra data. They can then be transformed into real DOM nodes with the
  3643. * `toNode` function or HTML markup using `toMarkup`. They are useful for both
  3644. * storing extra properties on the nodes, as well as providing a way to easily
  3645. * work with the DOM.
  3646. *
  3647. * Similar functions for working with MathML nodes exist in mathMLTree.js.
  3648. *
  3649. * TODO: refactor `span` and `anchor` into common superclass when
  3650. * target environments support class inheritance
  3651. */
  3652. /**
  3653. * Create an HTML className based on a list of classes. In addition to joining
  3654. * with spaces, we also remove empty classes.
  3655. */
  3656. var createClass = function createClass(classes) {
  3657. return classes.filter(function (cls) {
  3658. return cls;
  3659. }).join(" ");
  3660. };
  3661. var initNode = function initNode(classes, options, style) {
  3662. this.classes = classes || [];
  3663. this.attributes = {};
  3664. this.height = 0;
  3665. this.depth = 0;
  3666. this.maxFontSize = 0;
  3667. this.style = style || {};
  3668. if (options) {
  3669. if (options.style.isTight()) {
  3670. this.classes.push("mtight");
  3671. }
  3672. var color = options.getColor();
  3673. if (color) {
  3674. this.style.color = color;
  3675. }
  3676. }
  3677. };
  3678. /**
  3679. * Convert into an HTML node
  3680. */
  3681. var _toNode = function toNode(tagName) {
  3682. var node = document.createElement(tagName); // Apply the class
  3683. node.className = createClass(this.classes); // Apply inline styles
  3684. for (var style in this.style) {
  3685. if (this.style.hasOwnProperty(style)) {
  3686. // $FlowFixMe Flow doesn't seem to understand span.style's type.
  3687. node.style[style] = this.style[style];
  3688. }
  3689. } // Apply attributes
  3690. for (var attr in this.attributes) {
  3691. if (this.attributes.hasOwnProperty(attr)) {
  3692. node.setAttribute(attr, this.attributes[attr]);
  3693. }
  3694. } // Append the children, also as HTML nodes
  3695. for (var i = 0; i < this.children.length; i++) {
  3696. node.appendChild(this.children[i].toNode());
  3697. }
  3698. return node;
  3699. };
  3700. /**
  3701. * Convert into an HTML markup string
  3702. */
  3703. var _toMarkup = function toMarkup(tagName) {
  3704. var markup = "<" + tagName; // Add the class
  3705. if (this.classes.length) {
  3706. markup += " class=\"" + utils.escape(createClass(this.classes)) + "\"";
  3707. }
  3708. var styles = ""; // Add the styles, after hyphenation
  3709. for (var style in this.style) {
  3710. if (this.style.hasOwnProperty(style)) {
  3711. styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
  3712. }
  3713. }
  3714. if (styles) {
  3715. markup += " style=\"" + utils.escape(styles) + "\"";
  3716. } // Add the attributes
  3717. for (var attr in this.attributes) {
  3718. if (this.attributes.hasOwnProperty(attr)) {
  3719. markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\"";
  3720. }
  3721. }
  3722. markup += ">"; // Add the markup of the children, also as markup
  3723. for (var i = 0; i < this.children.length; i++) {
  3724. markup += this.children[i].toMarkup();
  3725. }
  3726. markup += "</" + tagName + ">";
  3727. return markup;
  3728. }; // Making the type below exact with all optional fields doesn't work due to
  3729. // - https://github.com/facebook/flow/issues/4582
  3730. // - https://github.com/facebook/flow/issues/5688
  3731. // However, since *all* fields are optional, $Shape<> works as suggested in 5688
  3732. // above.
  3733. // This type does not include all CSS properties. Additional properties should
  3734. // be added as needed.
  3735. /**
  3736. * This node represents a span node, with a className, a list of children, and
  3737. * an inline style. It also contains information about its height, depth, and
  3738. * maxFontSize.
  3739. *
  3740. * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan
  3741. * otherwise. This typesafety is important when HTML builders access a span's
  3742. * children.
  3743. */
  3744. var Span = /*#__PURE__*/function () {
  3745. function Span(classes, children, options, style) {
  3746. this.children = void 0;
  3747. this.attributes = void 0;
  3748. this.classes = void 0;
  3749. this.height = void 0;
  3750. this.depth = void 0;
  3751. this.width = void 0;
  3752. this.maxFontSize = void 0;
  3753. this.style = void 0;
  3754. initNode.call(this, classes, options, style);
  3755. this.children = children || [];
  3756. }
  3757. /**
  3758. * Sets an arbitrary attribute on the span. Warning: use this wisely. Not
  3759. * all browsers support attributes the same, and having too many custom
  3760. * attributes is probably bad.
  3761. */
  3762. var _proto = Span.prototype;
  3763. _proto.setAttribute = function setAttribute(attribute, value) {
  3764. this.attributes[attribute] = value;
  3765. };
  3766. _proto.hasClass = function hasClass(className) {
  3767. return utils.contains(this.classes, className);
  3768. };
  3769. _proto.toNode = function toNode() {
  3770. return _toNode.call(this, "span");
  3771. };
  3772. _proto.toMarkup = function toMarkup() {
  3773. return _toMarkup.call(this, "span");
  3774. };
  3775. return Span;
  3776. }();
  3777. /**
  3778. * This node represents an anchor (<a>) element with a hyperlink. See `span`
  3779. * for further details.
  3780. */
  3781. var Anchor = /*#__PURE__*/function () {
  3782. function Anchor(href, classes, children, options) {
  3783. this.children = void 0;
  3784. this.attributes = void 0;
  3785. this.classes = void 0;
  3786. this.height = void 0;
  3787. this.depth = void 0;
  3788. this.maxFontSize = void 0;
  3789. this.style = void 0;
  3790. initNode.call(this, classes, options);
  3791. this.children = children || [];
  3792. this.setAttribute('href', href);
  3793. }
  3794. var _proto2 = Anchor.prototype;
  3795. _proto2.setAttribute = function setAttribute(attribute, value) {
  3796. this.attributes[attribute] = value;
  3797. };
  3798. _proto2.hasClass = function hasClass(className) {
  3799. return utils.contains(this.classes, className);
  3800. };
  3801. _proto2.toNode = function toNode() {
  3802. return _toNode.call(this, "a");
  3803. };
  3804. _proto2.toMarkup = function toMarkup() {
  3805. return _toMarkup.call(this, "a");
  3806. };
  3807. return Anchor;
  3808. }();
  3809. /**
  3810. * This node represents an image embed (<img>) element.
  3811. */
  3812. var Img = /*#__PURE__*/function () {
  3813. function Img(src, alt, style) {
  3814. this.src = void 0;
  3815. this.alt = void 0;
  3816. this.classes = void 0;
  3817. this.height = void 0;
  3818. this.depth = void 0;
  3819. this.maxFontSize = void 0;
  3820. this.style = void 0;
  3821. this.alt = alt;
  3822. this.src = src;
  3823. this.classes = ["mord"];
  3824. this.style = style;
  3825. }
  3826. var _proto3 = Img.prototype;
  3827. _proto3.hasClass = function hasClass(className) {
  3828. return utils.contains(this.classes, className);
  3829. };
  3830. _proto3.toNode = function toNode() {
  3831. var node = document.createElement("img");
  3832. node.src = this.src;
  3833. node.alt = this.alt;
  3834. node.className = "mord"; // Apply inline styles
  3835. for (var style in this.style) {
  3836. if (this.style.hasOwnProperty(style)) {
  3837. // $FlowFixMe
  3838. node.style[style] = this.style[style];
  3839. }
  3840. }
  3841. return node;
  3842. };
  3843. _proto3.toMarkup = function toMarkup() {
  3844. var markup = "<img src='" + this.src + " 'alt='" + this.alt + "' "; // Add the styles, after hyphenation
  3845. var styles = "";
  3846. for (var style in this.style) {
  3847. if (this.style.hasOwnProperty(style)) {
  3848. styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
  3849. }
  3850. }
  3851. if (styles) {
  3852. markup += " style=\"" + utils.escape(styles) + "\"";
  3853. }
  3854. markup += "'/>";
  3855. return markup;
  3856. };
  3857. return Img;
  3858. }();
  3859. var iCombinations = {
  3860. 'î': "\u0131\u0302",
  3861. 'ï': "\u0131\u0308",
  3862. 'í': "\u0131\u0301",
  3863. // 'ī': '\u0131\u0304', // enable when we add Extended Latin
  3864. 'ì': "\u0131\u0300"
  3865. };
  3866. /**
  3867. * A symbol node contains information about a single symbol. It either renders
  3868. * to a single text node, or a span with a single text node in it, depending on
  3869. * whether it has CSS classes, styles, or needs italic correction.
  3870. */
  3871. var SymbolNode = /*#__PURE__*/function () {
  3872. function SymbolNode(text, height, depth, italic, skew, width, classes, style) {
  3873. this.text = void 0;
  3874. this.height = void 0;
  3875. this.depth = void 0;
  3876. this.italic = void 0;
  3877. this.skew = void 0;
  3878. this.width = void 0;
  3879. this.maxFontSize = void 0;
  3880. this.classes = void 0;
  3881. this.style = void 0;
  3882. this.text = text;
  3883. this.height = height || 0;
  3884. this.depth = depth || 0;
  3885. this.italic = italic || 0;
  3886. this.skew = skew || 0;
  3887. this.width = width || 0;
  3888. this.classes = classes || [];
  3889. this.style = style || {};
  3890. this.maxFontSize = 0; // Mark text from non-Latin scripts with specific classes so that we
  3891. // can specify which fonts to use. This allows us to render these
  3892. // characters with a serif font in situations where the browser would
  3893. // either default to a sans serif or render a placeholder character.
  3894. // We use CSS class names like cjk_fallback, hangul_fallback and
  3895. // brahmic_fallback. See ./unicodeScripts.js for the set of possible
  3896. // script names
  3897. var script = scriptFromCodepoint(this.text.charCodeAt(0));
  3898. if (script) {
  3899. this.classes.push(script + "_fallback");
  3900. }
  3901. if (/[îïíì]/.test(this.text)) {
  3902. // add ī when we add Extended Latin
  3903. this.text = iCombinations[this.text];
  3904. }
  3905. }
  3906. var _proto4 = SymbolNode.prototype;
  3907. _proto4.hasClass = function hasClass(className) {
  3908. return utils.contains(this.classes, className);
  3909. }
  3910. /**
  3911. * Creates a text node or span from a symbol node. Note that a span is only
  3912. * created if it is needed.
  3913. */
  3914. ;
  3915. _proto4.toNode = function toNode() {
  3916. var node = document.createTextNode(this.text);
  3917. var span = null;
  3918. if (this.italic > 0) {
  3919. span = document.createElement("span");
  3920. span.style.marginRight = makeEm(this.italic);
  3921. }
  3922. if (this.classes.length > 0) {
  3923. span = span || document.createElement("span");
  3924. span.className = createClass(this.classes);
  3925. }
  3926. for (var style in this.style) {
  3927. if (this.style.hasOwnProperty(style)) {
  3928. span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type.
  3929. span.style[style] = this.style[style];
  3930. }
  3931. }
  3932. if (span) {
  3933. span.appendChild(node);
  3934. return span;
  3935. } else {
  3936. return node;
  3937. }
  3938. }
  3939. /**
  3940. * Creates markup for a symbol node.
  3941. */
  3942. ;
  3943. _proto4.toMarkup = function toMarkup() {
  3944. // TODO(alpert): More duplication than I'd like from
  3945. // span.prototype.toMarkup and symbolNode.prototype.toNode...
  3946. var needsSpan = false;
  3947. var markup = "<span";
  3948. if (this.classes.length) {
  3949. needsSpan = true;
  3950. markup += " class=\"";
  3951. markup += utils.escape(createClass(this.classes));
  3952. markup += "\"";
  3953. }
  3954. var styles = "";
  3955. if (this.italic > 0) {
  3956. styles += "margin-right:" + this.italic + "em;";
  3957. }
  3958. for (var style in this.style) {
  3959. if (this.style.hasOwnProperty(style)) {
  3960. styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
  3961. }
  3962. }
  3963. if (styles) {
  3964. needsSpan = true;
  3965. markup += " style=\"" + utils.escape(styles) + "\"";
  3966. }
  3967. var escaped = utils.escape(this.text);
  3968. if (needsSpan) {
  3969. markup += ">";
  3970. markup += escaped;
  3971. markup += "</span>";
  3972. return markup;
  3973. } else {
  3974. return escaped;
  3975. }
  3976. };
  3977. return SymbolNode;
  3978. }();
  3979. /**
  3980. * SVG nodes are used to render stretchy wide elements.
  3981. */
  3982. var SvgNode = /*#__PURE__*/function () {
  3983. function SvgNode(children, attributes) {
  3984. this.children = void 0;
  3985. this.attributes = void 0;
  3986. this.children = children || [];
  3987. this.attributes = attributes || {};
  3988. }
  3989. var _proto5 = SvgNode.prototype;
  3990. _proto5.toNode = function toNode() {
  3991. var svgNS = "http://www.w3.org/2000/svg";
  3992. var node = document.createElementNS(svgNS, "svg"); // Apply attributes
  3993. for (var attr in this.attributes) {
  3994. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  3995. node.setAttribute(attr, this.attributes[attr]);
  3996. }
  3997. }
  3998. for (var i = 0; i < this.children.length; i++) {
  3999. node.appendChild(this.children[i].toNode());
  4000. }
  4001. return node;
  4002. };
  4003. _proto5.toMarkup = function toMarkup() {
  4004. var markup = "<svg xmlns=\"http://www.w3.org/2000/svg\""; // Apply attributes
  4005. for (var attr in this.attributes) {
  4006. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  4007. markup += " " + attr + "='" + this.attributes[attr] + "'";
  4008. }
  4009. }
  4010. markup += ">";
  4011. for (var i = 0; i < this.children.length; i++) {
  4012. markup += this.children[i].toMarkup();
  4013. }
  4014. markup += "</svg>";
  4015. return markup;
  4016. };
  4017. return SvgNode;
  4018. }();
  4019. var PathNode = /*#__PURE__*/function () {
  4020. function PathNode(pathName, alternate) {
  4021. this.pathName = void 0;
  4022. this.alternate = void 0;
  4023. this.pathName = pathName;
  4024. this.alternate = alternate; // Used only for \sqrt, \phase, & tall delims
  4025. }
  4026. var _proto6 = PathNode.prototype;
  4027. _proto6.toNode = function toNode() {
  4028. var svgNS = "http://www.w3.org/2000/svg";
  4029. var node = document.createElementNS(svgNS, "path");
  4030. if (this.alternate) {
  4031. node.setAttribute("d", this.alternate);
  4032. } else {
  4033. node.setAttribute("d", path[this.pathName]);
  4034. }
  4035. return node;
  4036. };
  4037. _proto6.toMarkup = function toMarkup() {
  4038. if (this.alternate) {
  4039. return "<path d='" + this.alternate + "'/>";
  4040. } else {
  4041. return "<path d='" + path[this.pathName] + "'/>";
  4042. }
  4043. };
  4044. return PathNode;
  4045. }();
  4046. var LineNode = /*#__PURE__*/function () {
  4047. function LineNode(attributes) {
  4048. this.attributes = void 0;
  4049. this.attributes = attributes || {};
  4050. }
  4051. var _proto7 = LineNode.prototype;
  4052. _proto7.toNode = function toNode() {
  4053. var svgNS = "http://www.w3.org/2000/svg";
  4054. var node = document.createElementNS(svgNS, "line"); // Apply attributes
  4055. for (var attr in this.attributes) {
  4056. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  4057. node.setAttribute(attr, this.attributes[attr]);
  4058. }
  4059. }
  4060. return node;
  4061. };
  4062. _proto7.toMarkup = function toMarkup() {
  4063. var markup = "<line";
  4064. for (var attr in this.attributes) {
  4065. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  4066. markup += " " + attr + "='" + this.attributes[attr] + "'";
  4067. }
  4068. }
  4069. markup += "/>";
  4070. return markup;
  4071. };
  4072. return LineNode;
  4073. }();
  4074. function assertSymbolDomNode(group) {
  4075. if (group instanceof SymbolNode) {
  4076. return group;
  4077. } else {
  4078. throw new Error("Expected symbolNode but got " + String(group) + ".");
  4079. }
  4080. }
  4081. function assertSpan(group) {
  4082. if (group instanceof Span) {
  4083. return group;
  4084. } else {
  4085. throw new Error("Expected span<HtmlDomNode> but got " + String(group) + ".");
  4086. }
  4087. }
  4088. ;// CONCATENATED MODULE: ./src/symbols.js
  4089. /**
  4090. * This file holds a list of all no-argument functions and single-character
  4091. * symbols (like 'a' or ';').
  4092. *
  4093. * For each of the symbols, there are three properties they can have:
  4094. * - font (required): the font to be used for this symbol. Either "main" (the
  4095. normal font), or "ams" (the ams fonts).
  4096. * - group (required): the ParseNode group type the symbol should have (i.e.
  4097. "textord", "mathord", etc).
  4098. See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types
  4099. * - replace: the character that this symbol or function should be
  4100. * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi
  4101. * character in the main font).
  4102. *
  4103. * The outermost map in the table indicates what mode the symbols should be
  4104. * accepted in (e.g. "math" or "text").
  4105. */
  4106. // Some of these have a "-token" suffix since these are also used as `ParseNode`
  4107. // types for raw text tokens, and we want to avoid conflicts with higher-level
  4108. // `ParseNode` types. These `ParseNode`s are constructed within `Parser` by
  4109. // looking up the `symbols` map.
  4110. var ATOMS = {
  4111. "bin": 1,
  4112. "close": 1,
  4113. "inner": 1,
  4114. "open": 1,
  4115. "punct": 1,
  4116. "rel": 1
  4117. };
  4118. var NON_ATOMS = {
  4119. "accent-token": 1,
  4120. "mathord": 1,
  4121. "op-token": 1,
  4122. "spacing": 1,
  4123. "textord": 1
  4124. };
  4125. var symbols = {
  4126. "math": {},
  4127. "text": {}
  4128. };
  4129. /* harmony default export */ var src_symbols = (symbols);
  4130. /** `acceptUnicodeChar = true` is only applicable if `replace` is set. */
  4131. function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) {
  4132. symbols[mode][name] = {
  4133. font: font,
  4134. group: group,
  4135. replace: replace
  4136. };
  4137. if (acceptUnicodeChar && replace) {
  4138. symbols[mode][replace] = symbols[mode][name];
  4139. }
  4140. } // Some abbreviations for commonly used strings.
  4141. // This helps minify the code, and also spotting typos using jshint.
  4142. // modes:
  4143. var math = "math";
  4144. var symbols_text = "text"; // fonts:
  4145. var main = "main";
  4146. var ams = "ams"; // groups:
  4147. var accent = "accent-token";
  4148. var bin = "bin";
  4149. var symbols_close = "close";
  4150. var inner = "inner";
  4151. var mathord = "mathord";
  4152. var op = "op-token";
  4153. var symbols_open = "open";
  4154. var punct = "punct";
  4155. var rel = "rel";
  4156. var spacing = "spacing";
  4157. var textord = "textord"; // Now comes the symbol table
  4158. // Relation Symbols
  4159. defineSymbol(math, main, rel, "\u2261", "\\equiv", true);
  4160. defineSymbol(math, main, rel, "\u227A", "\\prec", true);
  4161. defineSymbol(math, main, rel, "\u227B", "\\succ", true);
  4162. defineSymbol(math, main, rel, "\u223C", "\\sim", true);
  4163. defineSymbol(math, main, rel, "\u22A5", "\\perp");
  4164. defineSymbol(math, main, rel, "\u2AAF", "\\preceq", true);
  4165. defineSymbol(math, main, rel, "\u2AB0", "\\succeq", true);
  4166. defineSymbol(math, main, rel, "\u2243", "\\simeq", true);
  4167. defineSymbol(math, main, rel, "\u2223", "\\mid", true);
  4168. defineSymbol(math, main, rel, "\u226A", "\\ll", true);
  4169. defineSymbol(math, main, rel, "\u226B", "\\gg", true);
  4170. defineSymbol(math, main, rel, "\u224D", "\\asymp", true);
  4171. defineSymbol(math, main, rel, "\u2225", "\\parallel");
  4172. defineSymbol(math, main, rel, "\u22C8", "\\bowtie", true);
  4173. defineSymbol(math, main, rel, "\u2323", "\\smile", true);
  4174. defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true);
  4175. defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true);
  4176. defineSymbol(math, main, rel, "\u2250", "\\doteq", true);
  4177. defineSymbol(math, main, rel, "\u2322", "\\frown", true);
  4178. defineSymbol(math, main, rel, "\u220B", "\\ni", true);
  4179. defineSymbol(math, main, rel, "\u221D", "\\propto", true);
  4180. defineSymbol(math, main, rel, "\u22A2", "\\vdash", true);
  4181. defineSymbol(math, main, rel, "\u22A3", "\\dashv", true);
  4182. defineSymbol(math, main, rel, "\u220B", "\\owns"); // Punctuation
  4183. defineSymbol(math, main, punct, ".", "\\ldotp");
  4184. defineSymbol(math, main, punct, "\u22C5", "\\cdotp"); // Misc Symbols
  4185. defineSymbol(math, main, textord, "#", "\\#");
  4186. defineSymbol(symbols_text, main, textord, "#", "\\#");
  4187. defineSymbol(math, main, textord, "&", "\\&");
  4188. defineSymbol(symbols_text, main, textord, "&", "\\&");
  4189. defineSymbol(math, main, textord, "\u2135", "\\aleph", true);
  4190. defineSymbol(math, main, textord, "\u2200", "\\forall", true);
  4191. defineSymbol(math, main, textord, "\u210F", "\\hbar", true);
  4192. defineSymbol(math, main, textord, "\u2203", "\\exists", true);
  4193. defineSymbol(math, main, textord, "\u2207", "\\nabla", true);
  4194. defineSymbol(math, main, textord, "\u266D", "\\flat", true);
  4195. defineSymbol(math, main, textord, "\u2113", "\\ell", true);
  4196. defineSymbol(math, main, textord, "\u266E", "\\natural", true);
  4197. defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true);
  4198. defineSymbol(math, main, textord, "\u2118", "\\wp", true);
  4199. defineSymbol(math, main, textord, "\u266F", "\\sharp", true);
  4200. defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true);
  4201. defineSymbol(math, main, textord, "\u211C", "\\Re", true);
  4202. defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true);
  4203. defineSymbol(math, main, textord, "\u2111", "\\Im", true);
  4204. defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true);
  4205. defineSymbol(math, main, textord, "\xA7", "\\S", true);
  4206. defineSymbol(symbols_text, main, textord, "\xA7", "\\S");
  4207. defineSymbol(math, main, textord, "\xB6", "\\P", true);
  4208. defineSymbol(symbols_text, main, textord, "\xB6", "\\P"); // Math and Text
  4209. defineSymbol(math, main, textord, "\u2020", "\\dag");
  4210. defineSymbol(symbols_text, main, textord, "\u2020", "\\dag");
  4211. defineSymbol(symbols_text, main, textord, "\u2020", "\\textdagger");
  4212. defineSymbol(math, main, textord, "\u2021", "\\ddag");
  4213. defineSymbol(symbols_text, main, textord, "\u2021", "\\ddag");
  4214. defineSymbol(symbols_text, main, textord, "\u2021", "\\textdaggerdbl"); // Large Delimiters
  4215. defineSymbol(math, main, symbols_close, "\u23B1", "\\rmoustache", true);
  4216. defineSymbol(math, main, symbols_open, "\u23B0", "\\lmoustache", true);
  4217. defineSymbol(math, main, symbols_close, "\u27EF", "\\rgroup", true);
  4218. defineSymbol(math, main, symbols_open, "\u27EE", "\\lgroup", true); // Binary Operators
  4219. defineSymbol(math, main, bin, "\u2213", "\\mp", true);
  4220. defineSymbol(math, main, bin, "\u2296", "\\ominus", true);
  4221. defineSymbol(math, main, bin, "\u228E", "\\uplus", true);
  4222. defineSymbol(math, main, bin, "\u2293", "\\sqcap", true);
  4223. defineSymbol(math, main, bin, "\u2217", "\\ast");
  4224. defineSymbol(math, main, bin, "\u2294", "\\sqcup", true);
  4225. defineSymbol(math, main, bin, "\u25EF", "\\bigcirc", true);
  4226. defineSymbol(math, main, bin, "\u2219", "\\bullet", true);
  4227. defineSymbol(math, main, bin, "\u2021", "\\ddagger");
  4228. defineSymbol(math, main, bin, "\u2240", "\\wr", true);
  4229. defineSymbol(math, main, bin, "\u2A3F", "\\amalg");
  4230. defineSymbol(math, main, bin, "&", "\\And"); // from amsmath
  4231. // Arrow Symbols
  4232. defineSymbol(math, main, rel, "\u27F5", "\\longleftarrow", true);
  4233. defineSymbol(math, main, rel, "\u21D0", "\\Leftarrow", true);
  4234. defineSymbol(math, main, rel, "\u27F8", "\\Longleftarrow", true);
  4235. defineSymbol(math, main, rel, "\u27F6", "\\longrightarrow", true);
  4236. defineSymbol(math, main, rel, "\u21D2", "\\Rightarrow", true);
  4237. defineSymbol(math, main, rel, "\u27F9", "\\Longrightarrow", true);
  4238. defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true);
  4239. defineSymbol(math, main, rel, "\u27F7", "\\longleftrightarrow", true);
  4240. defineSymbol(math, main, rel, "\u21D4", "\\Leftrightarrow", true);
  4241. defineSymbol(math, main, rel, "\u27FA", "\\Longleftrightarrow", true);
  4242. defineSymbol(math, main, rel, "\u21A6", "\\mapsto", true);
  4243. defineSymbol(math, main, rel, "\u27FC", "\\longmapsto", true);
  4244. defineSymbol(math, main, rel, "\u2197", "\\nearrow", true);
  4245. defineSymbol(math, main, rel, "\u21A9", "\\hookleftarrow", true);
  4246. defineSymbol(math, main, rel, "\u21AA", "\\hookrightarrow", true);
  4247. defineSymbol(math, main, rel, "\u2198", "\\searrow", true);
  4248. defineSymbol(math, main, rel, "\u21BC", "\\leftharpoonup", true);
  4249. defineSymbol(math, main, rel, "\u21C0", "\\rightharpoonup", true);
  4250. defineSymbol(math, main, rel, "\u2199", "\\swarrow", true);
  4251. defineSymbol(math, main, rel, "\u21BD", "\\leftharpoondown", true);
  4252. defineSymbol(math, main, rel, "\u21C1", "\\rightharpoondown", true);
  4253. defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true);
  4254. defineSymbol(math, main, rel, "\u21CC", "\\rightleftharpoons", true); // AMS Negated Binary Relations
  4255. defineSymbol(math, ams, rel, "\u226E", "\\nless", true); // Symbol names preceeded by "@" each have a corresponding macro.
  4256. defineSymbol(math, ams, rel, "\uE010", "\\@nleqslant");
  4257. defineSymbol(math, ams, rel, "\uE011", "\\@nleqq");
  4258. defineSymbol(math, ams, rel, "\u2A87", "\\lneq", true);
  4259. defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true);
  4260. defineSymbol(math, ams, rel, "\uE00C", "\\@lvertneqq");
  4261. defineSymbol(math, ams, rel, "\u22E6", "\\lnsim", true);
  4262. defineSymbol(math, ams, rel, "\u2A89", "\\lnapprox", true);
  4263. defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); // unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym.
  4264. defineSymbol(math, ams, rel, "\u22E0", "\\npreceq", true);
  4265. defineSymbol(math, ams, rel, "\u22E8", "\\precnsim", true);
  4266. defineSymbol(math, ams, rel, "\u2AB9", "\\precnapprox", true);
  4267. defineSymbol(math, ams, rel, "\u2241", "\\nsim", true);
  4268. defineSymbol(math, ams, rel, "\uE006", "\\@nshortmid");
  4269. defineSymbol(math, ams, rel, "\u2224", "\\nmid", true);
  4270. defineSymbol(math, ams, rel, "\u22AC", "\\nvdash", true);
  4271. defineSymbol(math, ams, rel, "\u22AD", "\\nvDash", true);
  4272. defineSymbol(math, ams, rel, "\u22EA", "\\ntriangleleft");
  4273. defineSymbol(math, ams, rel, "\u22EC", "\\ntrianglelefteq", true);
  4274. defineSymbol(math, ams, rel, "\u228A", "\\subsetneq", true);
  4275. defineSymbol(math, ams, rel, "\uE01A", "\\@varsubsetneq");
  4276. defineSymbol(math, ams, rel, "\u2ACB", "\\subsetneqq", true);
  4277. defineSymbol(math, ams, rel, "\uE017", "\\@varsubsetneqq");
  4278. defineSymbol(math, ams, rel, "\u226F", "\\ngtr", true);
  4279. defineSymbol(math, ams, rel, "\uE00F", "\\@ngeqslant");
  4280. defineSymbol(math, ams, rel, "\uE00E", "\\@ngeqq");
  4281. defineSymbol(math, ams, rel, "\u2A88", "\\gneq", true);
  4282. defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true);
  4283. defineSymbol(math, ams, rel, "\uE00D", "\\@gvertneqq");
  4284. defineSymbol(math, ams, rel, "\u22E7", "\\gnsim", true);
  4285. defineSymbol(math, ams, rel, "\u2A8A", "\\gnapprox", true);
  4286. defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); // unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym.
  4287. defineSymbol(math, ams, rel, "\u22E1", "\\nsucceq", true);
  4288. defineSymbol(math, ams, rel, "\u22E9", "\\succnsim", true);
  4289. defineSymbol(math, ams, rel, "\u2ABA", "\\succnapprox", true); // unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym.
  4290. defineSymbol(math, ams, rel, "\u2246", "\\ncong", true);
  4291. defineSymbol(math, ams, rel, "\uE007", "\\@nshortparallel");
  4292. defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true);
  4293. defineSymbol(math, ams, rel, "\u22AF", "\\nVDash", true);
  4294. defineSymbol(math, ams, rel, "\u22EB", "\\ntriangleright");
  4295. defineSymbol(math, ams, rel, "\u22ED", "\\ntrianglerighteq", true);
  4296. defineSymbol(math, ams, rel, "\uE018", "\\@nsupseteqq");
  4297. defineSymbol(math, ams, rel, "\u228B", "\\supsetneq", true);
  4298. defineSymbol(math, ams, rel, "\uE01B", "\\@varsupsetneq");
  4299. defineSymbol(math, ams, rel, "\u2ACC", "\\supsetneqq", true);
  4300. defineSymbol(math, ams, rel, "\uE019", "\\@varsupsetneqq");
  4301. defineSymbol(math, ams, rel, "\u22AE", "\\nVdash", true);
  4302. defineSymbol(math, ams, rel, "\u2AB5", "\\precneqq", true);
  4303. defineSymbol(math, ams, rel, "\u2AB6", "\\succneqq", true);
  4304. defineSymbol(math, ams, rel, "\uE016", "\\@nsubseteqq");
  4305. defineSymbol(math, ams, bin, "\u22B4", "\\unlhd");
  4306. defineSymbol(math, ams, bin, "\u22B5", "\\unrhd"); // AMS Negated Arrows
  4307. defineSymbol(math, ams, rel, "\u219A", "\\nleftarrow", true);
  4308. defineSymbol(math, ams, rel, "\u219B", "\\nrightarrow", true);
  4309. defineSymbol(math, ams, rel, "\u21CD", "\\nLeftarrow", true);
  4310. defineSymbol(math, ams, rel, "\u21CF", "\\nRightarrow", true);
  4311. defineSymbol(math, ams, rel, "\u21AE", "\\nleftrightarrow", true);
  4312. defineSymbol(math, ams, rel, "\u21CE", "\\nLeftrightarrow", true); // AMS Misc
  4313. defineSymbol(math, ams, rel, "\u25B3", "\\vartriangle");
  4314. defineSymbol(math, ams, textord, "\u210F", "\\hslash");
  4315. defineSymbol(math, ams, textord, "\u25BD", "\\triangledown");
  4316. defineSymbol(math, ams, textord, "\u25CA", "\\lozenge");
  4317. defineSymbol(math, ams, textord, "\u24C8", "\\circledS");
  4318. defineSymbol(math, ams, textord, "\xAE", "\\circledR");
  4319. defineSymbol(symbols_text, ams, textord, "\xAE", "\\circledR");
  4320. defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true);
  4321. defineSymbol(math, ams, textord, "\u2204", "\\nexists");
  4322. defineSymbol(math, ams, textord, "\u2127", "\\mho");
  4323. defineSymbol(math, ams, textord, "\u2132", "\\Finv", true);
  4324. defineSymbol(math, ams, textord, "\u2141", "\\Game", true);
  4325. defineSymbol(math, ams, textord, "\u2035", "\\backprime");
  4326. defineSymbol(math, ams, textord, "\u25B2", "\\blacktriangle");
  4327. defineSymbol(math, ams, textord, "\u25BC", "\\blacktriangledown");
  4328. defineSymbol(math, ams, textord, "\u25A0", "\\blacksquare");
  4329. defineSymbol(math, ams, textord, "\u29EB", "\\blacklozenge");
  4330. defineSymbol(math, ams, textord, "\u2605", "\\bigstar");
  4331. defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true);
  4332. defineSymbol(math, ams, textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 to \matheth. We map to AMS function \eth
  4333. defineSymbol(math, ams, textord, "\xF0", "\\eth", true);
  4334. defineSymbol(symbols_text, main, textord, "\xF0", "\xF0");
  4335. defineSymbol(math, ams, textord, "\u2571", "\\diagup");
  4336. defineSymbol(math, ams, textord, "\u2572", "\\diagdown");
  4337. defineSymbol(math, ams, textord, "\u25A1", "\\square");
  4338. defineSymbol(math, ams, textord, "\u25A1", "\\Box");
  4339. defineSymbol(math, ams, textord, "\u25CA", "\\Diamond"); // unicode-math maps U+A5 to \mathyen. We map to AMS function \yen
  4340. defineSymbol(math, ams, textord, "\xA5", "\\yen", true);
  4341. defineSymbol(symbols_text, ams, textord, "\xA5", "\\yen", true);
  4342. defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true);
  4343. defineSymbol(symbols_text, ams, textord, "\u2713", "\\checkmark"); // AMS Hebrew
  4344. defineSymbol(math, ams, textord, "\u2136", "\\beth", true);
  4345. defineSymbol(math, ams, textord, "\u2138", "\\daleth", true);
  4346. defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); // AMS Greek
  4347. defineSymbol(math, ams, textord, "\u03DD", "\\digamma", true);
  4348. defineSymbol(math, ams, textord, "\u03F0", "\\varkappa"); // AMS Delimiters
  4349. defineSymbol(math, ams, symbols_open, "\u250C", "\\@ulcorner", true);
  4350. defineSymbol(math, ams, symbols_close, "\u2510", "\\@urcorner", true);
  4351. defineSymbol(math, ams, symbols_open, "\u2514", "\\@llcorner", true);
  4352. defineSymbol(math, ams, symbols_close, "\u2518", "\\@lrcorner", true); // AMS Binary Relations
  4353. defineSymbol(math, ams, rel, "\u2266", "\\leqq", true);
  4354. defineSymbol(math, ams, rel, "\u2A7D", "\\leqslant", true);
  4355. defineSymbol(math, ams, rel, "\u2A95", "\\eqslantless", true);
  4356. defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true);
  4357. defineSymbol(math, ams, rel, "\u2A85", "\\lessapprox", true);
  4358. defineSymbol(math, ams, rel, "\u224A", "\\approxeq", true);
  4359. defineSymbol(math, ams, bin, "\u22D6", "\\lessdot");
  4360. defineSymbol(math, ams, rel, "\u22D8", "\\lll", true);
  4361. defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true);
  4362. defineSymbol(math, ams, rel, "\u22DA", "\\lesseqgtr", true);
  4363. defineSymbol(math, ams, rel, "\u2A8B", "\\lesseqqgtr", true);
  4364. defineSymbol(math, ams, rel, "\u2251", "\\doteqdot");
  4365. defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true);
  4366. defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true);
  4367. defineSymbol(math, ams, rel, "\u223D", "\\backsim", true);
  4368. defineSymbol(math, ams, rel, "\u22CD", "\\backsimeq", true);
  4369. defineSymbol(math, ams, rel, "\u2AC5", "\\subseteqq", true);
  4370. defineSymbol(math, ams, rel, "\u22D0", "\\Subset", true);
  4371. defineSymbol(math, ams, rel, "\u228F", "\\sqsubset", true);
  4372. defineSymbol(math, ams, rel, "\u227C", "\\preccurlyeq", true);
  4373. defineSymbol(math, ams, rel, "\u22DE", "\\curlyeqprec", true);
  4374. defineSymbol(math, ams, rel, "\u227E", "\\precsim", true);
  4375. defineSymbol(math, ams, rel, "\u2AB7", "\\precapprox", true);
  4376. defineSymbol(math, ams, rel, "\u22B2", "\\vartriangleleft");
  4377. defineSymbol(math, ams, rel, "\u22B4", "\\trianglelefteq");
  4378. defineSymbol(math, ams, rel, "\u22A8", "\\vDash", true);
  4379. defineSymbol(math, ams, rel, "\u22AA", "\\Vvdash", true);
  4380. defineSymbol(math, ams, rel, "\u2323", "\\smallsmile");
  4381. defineSymbol(math, ams, rel, "\u2322", "\\smallfrown");
  4382. defineSymbol(math, ams, rel, "\u224F", "\\bumpeq", true);
  4383. defineSymbol(math, ams, rel, "\u224E", "\\Bumpeq", true);
  4384. defineSymbol(math, ams, rel, "\u2267", "\\geqq", true);
  4385. defineSymbol(math, ams, rel, "\u2A7E", "\\geqslant", true);
  4386. defineSymbol(math, ams, rel, "\u2A96", "\\eqslantgtr", true);
  4387. defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true);
  4388. defineSymbol(math, ams, rel, "\u2A86", "\\gtrapprox", true);
  4389. defineSymbol(math, ams, bin, "\u22D7", "\\gtrdot");
  4390. defineSymbol(math, ams, rel, "\u22D9", "\\ggg", true);
  4391. defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true);
  4392. defineSymbol(math, ams, rel, "\u22DB", "\\gtreqless", true);
  4393. defineSymbol(math, ams, rel, "\u2A8C", "\\gtreqqless", true);
  4394. defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true);
  4395. defineSymbol(math, ams, rel, "\u2257", "\\circeq", true);
  4396. defineSymbol(math, ams, rel, "\u225C", "\\triangleq", true);
  4397. defineSymbol(math, ams, rel, "\u223C", "\\thicksim");
  4398. defineSymbol(math, ams, rel, "\u2248", "\\thickapprox");
  4399. defineSymbol(math, ams, rel, "\u2AC6", "\\supseteqq", true);
  4400. defineSymbol(math, ams, rel, "\u22D1", "\\Supset", true);
  4401. defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true);
  4402. defineSymbol(math, ams, rel, "\u227D", "\\succcurlyeq", true);
  4403. defineSymbol(math, ams, rel, "\u22DF", "\\curlyeqsucc", true);
  4404. defineSymbol(math, ams, rel, "\u227F", "\\succsim", true);
  4405. defineSymbol(math, ams, rel, "\u2AB8", "\\succapprox", true);
  4406. defineSymbol(math, ams, rel, "\u22B3", "\\vartriangleright");
  4407. defineSymbol(math, ams, rel, "\u22B5", "\\trianglerighteq");
  4408. defineSymbol(math, ams, rel, "\u22A9", "\\Vdash", true);
  4409. defineSymbol(math, ams, rel, "\u2223", "\\shortmid");
  4410. defineSymbol(math, ams, rel, "\u2225", "\\shortparallel");
  4411. defineSymbol(math, ams, rel, "\u226C", "\\between", true);
  4412. defineSymbol(math, ams, rel, "\u22D4", "\\pitchfork", true);
  4413. defineSymbol(math, ams, rel, "\u221D", "\\varpropto");
  4414. defineSymbol(math, ams, rel, "\u25C0", "\\blacktriangleleft"); // unicode-math says that \therefore is a mathord atom.
  4415. // We kept the amssymb atom type, which is rel.
  4416. defineSymbol(math, ams, rel, "\u2234", "\\therefore", true);
  4417. defineSymbol(math, ams, rel, "\u220D", "\\backepsilon");
  4418. defineSymbol(math, ams, rel, "\u25B6", "\\blacktriangleright"); // unicode-math says that \because is a mathord atom.
  4419. // We kept the amssymb atom type, which is rel.
  4420. defineSymbol(math, ams, rel, "\u2235", "\\because", true);
  4421. defineSymbol(math, ams, rel, "\u22D8", "\\llless");
  4422. defineSymbol(math, ams, rel, "\u22D9", "\\gggtr");
  4423. defineSymbol(math, ams, bin, "\u22B2", "\\lhd");
  4424. defineSymbol(math, ams, bin, "\u22B3", "\\rhd");
  4425. defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true);
  4426. defineSymbol(math, main, rel, "\u22C8", "\\Join");
  4427. defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); // AMS Binary Operators
  4428. defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true);
  4429. defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus");
  4430. defineSymbol(math, ams, bin, "\u22D2", "\\Cap", true);
  4431. defineSymbol(math, ams, bin, "\u22D3", "\\Cup", true);
  4432. defineSymbol(math, ams, bin, "\u2A5E", "\\doublebarwedge", true);
  4433. defineSymbol(math, ams, bin, "\u229F", "\\boxminus", true);
  4434. defineSymbol(math, ams, bin, "\u229E", "\\boxplus", true);
  4435. defineSymbol(math, ams, bin, "\u22C7", "\\divideontimes", true);
  4436. defineSymbol(math, ams, bin, "\u22C9", "\\ltimes", true);
  4437. defineSymbol(math, ams, bin, "\u22CA", "\\rtimes", true);
  4438. defineSymbol(math, ams, bin, "\u22CB", "\\leftthreetimes", true);
  4439. defineSymbol(math, ams, bin, "\u22CC", "\\rightthreetimes", true);
  4440. defineSymbol(math, ams, bin, "\u22CF", "\\curlywedge", true);
  4441. defineSymbol(math, ams, bin, "\u22CE", "\\curlyvee", true);
  4442. defineSymbol(math, ams, bin, "\u229D", "\\circleddash", true);
  4443. defineSymbol(math, ams, bin, "\u229B", "\\circledast", true);
  4444. defineSymbol(math, ams, bin, "\u22C5", "\\centerdot");
  4445. defineSymbol(math, ams, bin, "\u22BA", "\\intercal", true);
  4446. defineSymbol(math, ams, bin, "\u22D2", "\\doublecap");
  4447. defineSymbol(math, ams, bin, "\u22D3", "\\doublecup");
  4448. defineSymbol(math, ams, bin, "\u22A0", "\\boxtimes", true); // AMS Arrows
  4449. // Note: unicode-math maps \u21e2 to their own function \rightdasharrow.
  4450. // We'll map it to AMS function \dashrightarrow. It produces the same atom.
  4451. defineSymbol(math, ams, rel, "\u21E2", "\\dashrightarrow", true); // unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym.
  4452. defineSymbol(math, ams, rel, "\u21E0", "\\dashleftarrow", true);
  4453. defineSymbol(math, ams, rel, "\u21C7", "\\leftleftarrows", true);
  4454. defineSymbol(math, ams, rel, "\u21C6", "\\leftrightarrows", true);
  4455. defineSymbol(math, ams, rel, "\u21DA", "\\Lleftarrow", true);
  4456. defineSymbol(math, ams, rel, "\u219E", "\\twoheadleftarrow", true);
  4457. defineSymbol(math, ams, rel, "\u21A2", "\\leftarrowtail", true);
  4458. defineSymbol(math, ams, rel, "\u21AB", "\\looparrowleft", true);
  4459. defineSymbol(math, ams, rel, "\u21CB", "\\leftrightharpoons", true);
  4460. defineSymbol(math, ams, rel, "\u21B6", "\\curvearrowleft", true); // unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym.
  4461. defineSymbol(math, ams, rel, "\u21BA", "\\circlearrowleft", true);
  4462. defineSymbol(math, ams, rel, "\u21B0", "\\Lsh", true);
  4463. defineSymbol(math, ams, rel, "\u21C8", "\\upuparrows", true);
  4464. defineSymbol(math, ams, rel, "\u21BF", "\\upharpoonleft", true);
  4465. defineSymbol(math, ams, rel, "\u21C3", "\\downharpoonleft", true);
  4466. defineSymbol(math, main, rel, "\u22B6", "\\origof", true); // not in font
  4467. defineSymbol(math, main, rel, "\u22B7", "\\imageof", true); // not in font
  4468. defineSymbol(math, ams, rel, "\u22B8", "\\multimap", true);
  4469. defineSymbol(math, ams, rel, "\u21AD", "\\leftrightsquigarrow", true);
  4470. defineSymbol(math, ams, rel, "\u21C9", "\\rightrightarrows", true);
  4471. defineSymbol(math, ams, rel, "\u21C4", "\\rightleftarrows", true);
  4472. defineSymbol(math, ams, rel, "\u21A0", "\\twoheadrightarrow", true);
  4473. defineSymbol(math, ams, rel, "\u21A3", "\\rightarrowtail", true);
  4474. defineSymbol(math, ams, rel, "\u21AC", "\\looparrowright", true);
  4475. defineSymbol(math, ams, rel, "\u21B7", "\\curvearrowright", true); // unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym.
  4476. defineSymbol(math, ams, rel, "\u21BB", "\\circlearrowright", true);
  4477. defineSymbol(math, ams, rel, "\u21B1", "\\Rsh", true);
  4478. defineSymbol(math, ams, rel, "\u21CA", "\\downdownarrows", true);
  4479. defineSymbol(math, ams, rel, "\u21BE", "\\upharpoonright", true);
  4480. defineSymbol(math, ams, rel, "\u21C2", "\\downharpoonright", true);
  4481. defineSymbol(math, ams, rel, "\u21DD", "\\rightsquigarrow", true);
  4482. defineSymbol(math, ams, rel, "\u21DD", "\\leadsto");
  4483. defineSymbol(math, ams, rel, "\u21DB", "\\Rrightarrow", true);
  4484. defineSymbol(math, ams, rel, "\u21BE", "\\restriction");
  4485. defineSymbol(math, main, textord, "\u2018", "`");
  4486. defineSymbol(math, main, textord, "$", "\\$");
  4487. defineSymbol(symbols_text, main, textord, "$", "\\$");
  4488. defineSymbol(symbols_text, main, textord, "$", "\\textdollar");
  4489. defineSymbol(math, main, textord, "%", "\\%");
  4490. defineSymbol(symbols_text, main, textord, "%", "\\%");
  4491. defineSymbol(math, main, textord, "_", "\\_");
  4492. defineSymbol(symbols_text, main, textord, "_", "\\_");
  4493. defineSymbol(symbols_text, main, textord, "_", "\\textunderscore");
  4494. defineSymbol(math, main, textord, "\u2220", "\\angle", true);
  4495. defineSymbol(math, main, textord, "\u221E", "\\infty", true);
  4496. defineSymbol(math, main, textord, "\u2032", "\\prime");
  4497. defineSymbol(math, main, textord, "\u25B3", "\\triangle");
  4498. defineSymbol(math, main, textord, "\u0393", "\\Gamma", true);
  4499. defineSymbol(math, main, textord, "\u0394", "\\Delta", true);
  4500. defineSymbol(math, main, textord, "\u0398", "\\Theta", true);
  4501. defineSymbol(math, main, textord, "\u039B", "\\Lambda", true);
  4502. defineSymbol(math, main, textord, "\u039E", "\\Xi", true);
  4503. defineSymbol(math, main, textord, "\u03A0", "\\Pi", true);
  4504. defineSymbol(math, main, textord, "\u03A3", "\\Sigma", true);
  4505. defineSymbol(math, main, textord, "\u03A5", "\\Upsilon", true);
  4506. defineSymbol(math, main, textord, "\u03A6", "\\Phi", true);
  4507. defineSymbol(math, main, textord, "\u03A8", "\\Psi", true);
  4508. defineSymbol(math, main, textord, "\u03A9", "\\Omega", true);
  4509. defineSymbol(math, main, textord, "A", "\u0391");
  4510. defineSymbol(math, main, textord, "B", "\u0392");
  4511. defineSymbol(math, main, textord, "E", "\u0395");
  4512. defineSymbol(math, main, textord, "Z", "\u0396");
  4513. defineSymbol(math, main, textord, "H", "\u0397");
  4514. defineSymbol(math, main, textord, "I", "\u0399");
  4515. defineSymbol(math, main, textord, "K", "\u039A");
  4516. defineSymbol(math, main, textord, "M", "\u039C");
  4517. defineSymbol(math, main, textord, "N", "\u039D");
  4518. defineSymbol(math, main, textord, "O", "\u039F");
  4519. defineSymbol(math, main, textord, "P", "\u03A1");
  4520. defineSymbol(math, main, textord, "T", "\u03A4");
  4521. defineSymbol(math, main, textord, "X", "\u03A7");
  4522. defineSymbol(math, main, textord, "\xAC", "\\neg", true);
  4523. defineSymbol(math, main, textord, "\xAC", "\\lnot");
  4524. defineSymbol(math, main, textord, "\u22A4", "\\top");
  4525. defineSymbol(math, main, textord, "\u22A5", "\\bot");
  4526. defineSymbol(math, main, textord, "\u2205", "\\emptyset");
  4527. defineSymbol(math, ams, textord, "\u2205", "\\varnothing");
  4528. defineSymbol(math, main, mathord, "\u03B1", "\\alpha", true);
  4529. defineSymbol(math, main, mathord, "\u03B2", "\\beta", true);
  4530. defineSymbol(math, main, mathord, "\u03B3", "\\gamma", true);
  4531. defineSymbol(math, main, mathord, "\u03B4", "\\delta", true);
  4532. defineSymbol(math, main, mathord, "\u03F5", "\\epsilon", true);
  4533. defineSymbol(math, main, mathord, "\u03B6", "\\zeta", true);
  4534. defineSymbol(math, main, mathord, "\u03B7", "\\eta", true);
  4535. defineSymbol(math, main, mathord, "\u03B8", "\\theta", true);
  4536. defineSymbol(math, main, mathord, "\u03B9", "\\iota", true);
  4537. defineSymbol(math, main, mathord, "\u03BA", "\\kappa", true);
  4538. defineSymbol(math, main, mathord, "\u03BB", "\\lambda", true);
  4539. defineSymbol(math, main, mathord, "\u03BC", "\\mu", true);
  4540. defineSymbol(math, main, mathord, "\u03BD", "\\nu", true);
  4541. defineSymbol(math, main, mathord, "\u03BE", "\\xi", true);
  4542. defineSymbol(math, main, mathord, "\u03BF", "\\omicron", true);
  4543. defineSymbol(math, main, mathord, "\u03C0", "\\pi", true);
  4544. defineSymbol(math, main, mathord, "\u03C1", "\\rho", true);
  4545. defineSymbol(math, main, mathord, "\u03C3", "\\sigma", true);
  4546. defineSymbol(math, main, mathord, "\u03C4", "\\tau", true);
  4547. defineSymbol(math, main, mathord, "\u03C5", "\\upsilon", true);
  4548. defineSymbol(math, main, mathord, "\u03D5", "\\phi", true);
  4549. defineSymbol(math, main, mathord, "\u03C7", "\\chi", true);
  4550. defineSymbol(math, main, mathord, "\u03C8", "\\psi", true);
  4551. defineSymbol(math, main, mathord, "\u03C9", "\\omega", true);
  4552. defineSymbol(math, main, mathord, "\u03B5", "\\varepsilon", true);
  4553. defineSymbol(math, main, mathord, "\u03D1", "\\vartheta", true);
  4554. defineSymbol(math, main, mathord, "\u03D6", "\\varpi", true);
  4555. defineSymbol(math, main, mathord, "\u03F1", "\\varrho", true);
  4556. defineSymbol(math, main, mathord, "\u03C2", "\\varsigma", true);
  4557. defineSymbol(math, main, mathord, "\u03C6", "\\varphi", true);
  4558. defineSymbol(math, main, bin, "\u2217", "*", true);
  4559. defineSymbol(math, main, bin, "+", "+");
  4560. defineSymbol(math, main, bin, "\u2212", "-", true);
  4561. defineSymbol(math, main, bin, "\u22C5", "\\cdot", true);
  4562. defineSymbol(math, main, bin, "\u2218", "\\circ", true);
  4563. defineSymbol(math, main, bin, "\xF7", "\\div", true);
  4564. defineSymbol(math, main, bin, "\xB1", "\\pm", true);
  4565. defineSymbol(math, main, bin, "\xD7", "\\times", true);
  4566. defineSymbol(math, main, bin, "\u2229", "\\cap", true);
  4567. defineSymbol(math, main, bin, "\u222A", "\\cup", true);
  4568. defineSymbol(math, main, bin, "\u2216", "\\setminus", true);
  4569. defineSymbol(math, main, bin, "\u2227", "\\land");
  4570. defineSymbol(math, main, bin, "\u2228", "\\lor");
  4571. defineSymbol(math, main, bin, "\u2227", "\\wedge", true);
  4572. defineSymbol(math, main, bin, "\u2228", "\\vee", true);
  4573. defineSymbol(math, main, textord, "\u221A", "\\surd");
  4574. defineSymbol(math, main, symbols_open, "\u27E8", "\\langle", true);
  4575. defineSymbol(math, main, symbols_open, "\u2223", "\\lvert");
  4576. defineSymbol(math, main, symbols_open, "\u2225", "\\lVert");
  4577. defineSymbol(math, main, symbols_close, "?", "?");
  4578. defineSymbol(math, main, symbols_close, "!", "!");
  4579. defineSymbol(math, main, symbols_close, "\u27E9", "\\rangle", true);
  4580. defineSymbol(math, main, symbols_close, "\u2223", "\\rvert");
  4581. defineSymbol(math, main, symbols_close, "\u2225", "\\rVert");
  4582. defineSymbol(math, main, rel, "=", "=");
  4583. defineSymbol(math, main, rel, ":", ":");
  4584. defineSymbol(math, main, rel, "\u2248", "\\approx", true);
  4585. defineSymbol(math, main, rel, "\u2245", "\\cong", true);
  4586. defineSymbol(math, main, rel, "\u2265", "\\ge");
  4587. defineSymbol(math, main, rel, "\u2265", "\\geq", true);
  4588. defineSymbol(math, main, rel, "\u2190", "\\gets");
  4589. defineSymbol(math, main, rel, ">", "\\gt", true);
  4590. defineSymbol(math, main, rel, "\u2208", "\\in", true);
  4591. defineSymbol(math, main, rel, "\uE020", "\\@not");
  4592. defineSymbol(math, main, rel, "\u2282", "\\subset", true);
  4593. defineSymbol(math, main, rel, "\u2283", "\\supset", true);
  4594. defineSymbol(math, main, rel, "\u2286", "\\subseteq", true);
  4595. defineSymbol(math, main, rel, "\u2287", "\\supseteq", true);
  4596. defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true);
  4597. defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true);
  4598. defineSymbol(math, main, rel, "\u22A8", "\\models");
  4599. defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true);
  4600. defineSymbol(math, main, rel, "\u2264", "\\le");
  4601. defineSymbol(math, main, rel, "\u2264", "\\leq", true);
  4602. defineSymbol(math, main, rel, "<", "\\lt", true);
  4603. defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true);
  4604. defineSymbol(math, main, rel, "\u2192", "\\to");
  4605. defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true);
  4606. defineSymbol(math, ams, rel, "\u2270", "\\nleq", true);
  4607. defineSymbol(math, main, spacing, "\xA0", "\\ ");
  4608. defineSymbol(math, main, spacing, "\xA0", "\\space"); // Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{%
  4609. defineSymbol(math, main, spacing, "\xA0", "\\nobreakspace");
  4610. defineSymbol(symbols_text, main, spacing, "\xA0", "\\ ");
  4611. defineSymbol(symbols_text, main, spacing, "\xA0", " ");
  4612. defineSymbol(symbols_text, main, spacing, "\xA0", "\\space");
  4613. defineSymbol(symbols_text, main, spacing, "\xA0", "\\nobreakspace");
  4614. defineSymbol(math, main, spacing, null, "\\nobreak");
  4615. defineSymbol(math, main, spacing, null, "\\allowbreak");
  4616. defineSymbol(math, main, punct, ",", ",");
  4617. defineSymbol(math, main, punct, ";", ";");
  4618. defineSymbol(math, ams, bin, "\u22BC", "\\barwedge", true);
  4619. defineSymbol(math, ams, bin, "\u22BB", "\\veebar", true);
  4620. defineSymbol(math, main, bin, "\u2299", "\\odot", true);
  4621. defineSymbol(math, main, bin, "\u2295", "\\oplus", true);
  4622. defineSymbol(math, main, bin, "\u2297", "\\otimes", true);
  4623. defineSymbol(math, main, textord, "\u2202", "\\partial", true);
  4624. defineSymbol(math, main, bin, "\u2298", "\\oslash", true);
  4625. defineSymbol(math, ams, bin, "\u229A", "\\circledcirc", true);
  4626. defineSymbol(math, ams, bin, "\u22A1", "\\boxdot", true);
  4627. defineSymbol(math, main, bin, "\u25B3", "\\bigtriangleup");
  4628. defineSymbol(math, main, bin, "\u25BD", "\\bigtriangledown");
  4629. defineSymbol(math, main, bin, "\u2020", "\\dagger");
  4630. defineSymbol(math, main, bin, "\u22C4", "\\diamond");
  4631. defineSymbol(math, main, bin, "\u22C6", "\\star");
  4632. defineSymbol(math, main, bin, "\u25C3", "\\triangleleft");
  4633. defineSymbol(math, main, bin, "\u25B9", "\\triangleright");
  4634. defineSymbol(math, main, symbols_open, "{", "\\{");
  4635. defineSymbol(symbols_text, main, textord, "{", "\\{");
  4636. defineSymbol(symbols_text, main, textord, "{", "\\textbraceleft");
  4637. defineSymbol(math, main, symbols_close, "}", "\\}");
  4638. defineSymbol(symbols_text, main, textord, "}", "\\}");
  4639. defineSymbol(symbols_text, main, textord, "}", "\\textbraceright");
  4640. defineSymbol(math, main, symbols_open, "{", "\\lbrace");
  4641. defineSymbol(math, main, symbols_close, "}", "\\rbrace");
  4642. defineSymbol(math, main, symbols_open, "[", "\\lbrack", true);
  4643. defineSymbol(symbols_text, main, textord, "[", "\\lbrack", true);
  4644. defineSymbol(math, main, symbols_close, "]", "\\rbrack", true);
  4645. defineSymbol(symbols_text, main, textord, "]", "\\rbrack", true);
  4646. defineSymbol(math, main, symbols_open, "(", "\\lparen", true);
  4647. defineSymbol(math, main, symbols_close, ")", "\\rparen", true);
  4648. defineSymbol(symbols_text, main, textord, "<", "\\textless", true); // in T1 fontenc
  4649. defineSymbol(symbols_text, main, textord, ">", "\\textgreater", true); // in T1 fontenc
  4650. defineSymbol(math, main, symbols_open, "\u230A", "\\lfloor", true);
  4651. defineSymbol(math, main, symbols_close, "\u230B", "\\rfloor", true);
  4652. defineSymbol(math, main, symbols_open, "\u2308", "\\lceil", true);
  4653. defineSymbol(math, main, symbols_close, "\u2309", "\\rceil", true);
  4654. defineSymbol(math, main, textord, "\\", "\\backslash");
  4655. defineSymbol(math, main, textord, "\u2223", "|");
  4656. defineSymbol(math, main, textord, "\u2223", "\\vert");
  4657. defineSymbol(symbols_text, main, textord, "|", "\\textbar", true); // in T1 fontenc
  4658. defineSymbol(math, main, textord, "\u2225", "\\|");
  4659. defineSymbol(math, main, textord, "\u2225", "\\Vert");
  4660. defineSymbol(symbols_text, main, textord, "\u2225", "\\textbardbl");
  4661. defineSymbol(symbols_text, main, textord, "~", "\\textasciitilde");
  4662. defineSymbol(symbols_text, main, textord, "\\", "\\textbackslash");
  4663. defineSymbol(symbols_text, main, textord, "^", "\\textasciicircum");
  4664. defineSymbol(math, main, rel, "\u2191", "\\uparrow", true);
  4665. defineSymbol(math, main, rel, "\u21D1", "\\Uparrow", true);
  4666. defineSymbol(math, main, rel, "\u2193", "\\downarrow", true);
  4667. defineSymbol(math, main, rel, "\u21D3", "\\Downarrow", true);
  4668. defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true);
  4669. defineSymbol(math, main, rel, "\u21D5", "\\Updownarrow", true);
  4670. defineSymbol(math, main, op, "\u2210", "\\coprod");
  4671. defineSymbol(math, main, op, "\u22C1", "\\bigvee");
  4672. defineSymbol(math, main, op, "\u22C0", "\\bigwedge");
  4673. defineSymbol(math, main, op, "\u2A04", "\\biguplus");
  4674. defineSymbol(math, main, op, "\u22C2", "\\bigcap");
  4675. defineSymbol(math, main, op, "\u22C3", "\\bigcup");
  4676. defineSymbol(math, main, op, "\u222B", "\\int");
  4677. defineSymbol(math, main, op, "\u222B", "\\intop");
  4678. defineSymbol(math, main, op, "\u222C", "\\iint");
  4679. defineSymbol(math, main, op, "\u222D", "\\iiint");
  4680. defineSymbol(math, main, op, "\u220F", "\\prod");
  4681. defineSymbol(math, main, op, "\u2211", "\\sum");
  4682. defineSymbol(math, main, op, "\u2A02", "\\bigotimes");
  4683. defineSymbol(math, main, op, "\u2A01", "\\bigoplus");
  4684. defineSymbol(math, main, op, "\u2A00", "\\bigodot");
  4685. defineSymbol(math, main, op, "\u222E", "\\oint");
  4686. defineSymbol(math, main, op, "\u222F", "\\oiint");
  4687. defineSymbol(math, main, op, "\u2230", "\\oiiint");
  4688. defineSymbol(math, main, op, "\u2A06", "\\bigsqcup");
  4689. defineSymbol(math, main, op, "\u222B", "\\smallint");
  4690. defineSymbol(symbols_text, main, inner, "\u2026", "\\textellipsis");
  4691. defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
  4692. defineSymbol(symbols_text, main, inner, "\u2026", "\\ldots", true);
  4693. defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
  4694. defineSymbol(math, main, inner, "\u22EF", "\\@cdots", true);
  4695. defineSymbol(math, main, inner, "\u22F1", "\\ddots", true);
  4696. defineSymbol(math, main, textord, "\u22EE", "\\varvdots"); // \vdots is a macro
  4697. defineSymbol(math, main, accent, "\u02CA", "\\acute");
  4698. defineSymbol(math, main, accent, "\u02CB", "\\grave");
  4699. defineSymbol(math, main, accent, "\xA8", "\\ddot");
  4700. defineSymbol(math, main, accent, "~", "\\tilde");
  4701. defineSymbol(math, main, accent, "\u02C9", "\\bar");
  4702. defineSymbol(math, main, accent, "\u02D8", "\\breve");
  4703. defineSymbol(math, main, accent, "\u02C7", "\\check");
  4704. defineSymbol(math, main, accent, "^", "\\hat");
  4705. defineSymbol(math, main, accent, "\u20D7", "\\vec");
  4706. defineSymbol(math, main, accent, "\u02D9", "\\dot");
  4707. defineSymbol(math, main, accent, "\u02DA", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA
  4708. defineSymbol(math, main, mathord, "\uE131", "\\@imath");
  4709. defineSymbol(math, main, mathord, "\uE237", "\\@jmath");
  4710. defineSymbol(math, main, textord, "\u0131", "\u0131");
  4711. defineSymbol(math, main, textord, "\u0237", "\u0237");
  4712. defineSymbol(symbols_text, main, textord, "\u0131", "\\i", true);
  4713. defineSymbol(symbols_text, main, textord, "\u0237", "\\j", true);
  4714. defineSymbol(symbols_text, main, textord, "\xDF", "\\ss", true);
  4715. defineSymbol(symbols_text, main, textord, "\xE6", "\\ae", true);
  4716. defineSymbol(symbols_text, main, textord, "\u0153", "\\oe", true);
  4717. defineSymbol(symbols_text, main, textord, "\xF8", "\\o", true);
  4718. defineSymbol(symbols_text, main, textord, "\xC6", "\\AE", true);
  4719. defineSymbol(symbols_text, main, textord, "\u0152", "\\OE", true);
  4720. defineSymbol(symbols_text, main, textord, "\xD8", "\\O", true);
  4721. defineSymbol(symbols_text, main, accent, "\u02CA", "\\'"); // acute
  4722. defineSymbol(symbols_text, main, accent, "\u02CB", "\\`"); // grave
  4723. defineSymbol(symbols_text, main, accent, "\u02C6", "\\^"); // circumflex
  4724. defineSymbol(symbols_text, main, accent, "\u02DC", "\\~"); // tilde
  4725. defineSymbol(symbols_text, main, accent, "\u02C9", "\\="); // macron
  4726. defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve
  4727. defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above
  4728. defineSymbol(symbols_text, main, accent, "\xB8", "\\c"); // cedilla
  4729. defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above
  4730. defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron
  4731. defineSymbol(symbols_text, main, accent, "\xA8", '\\"'); // diaresis
  4732. defineSymbol(symbols_text, main, accent, "\u02DD", "\\H"); // double acute
  4733. defineSymbol(symbols_text, main, accent, "\u25EF", "\\textcircled"); // \bigcirc glyph
  4734. // These ligatures are detected and created in Parser.js's `formLigatures`.
  4735. var ligatures = {
  4736. "--": true,
  4737. "---": true,
  4738. "``": true,
  4739. "''": true
  4740. };
  4741. defineSymbol(symbols_text, main, textord, "\u2013", "--", true);
  4742. defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash");
  4743. defineSymbol(symbols_text, main, textord, "\u2014", "---", true);
  4744. defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash");
  4745. defineSymbol(symbols_text, main, textord, "\u2018", "`", true);
  4746. defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft");
  4747. defineSymbol(symbols_text, main, textord, "\u2019", "'", true);
  4748. defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright");
  4749. defineSymbol(symbols_text, main, textord, "\u201C", "``", true);
  4750. defineSymbol(symbols_text, main, textord, "\u201C", "\\textquotedblleft");
  4751. defineSymbol(symbols_text, main, textord, "\u201D", "''", true);
  4752. defineSymbol(symbols_text, main, textord, "\u201D", "\\textquotedblright"); // \degree from gensymb package
  4753. defineSymbol(math, main, textord, "\xB0", "\\degree", true);
  4754. defineSymbol(symbols_text, main, textord, "\xB0", "\\degree"); // \textdegree from inputenc package
  4755. defineSymbol(symbols_text, main, textord, "\xB0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math
  4756. // mode, but among our fonts, only Main-Regular defines this character "163".
  4757. defineSymbol(math, main, textord, "\xA3", "\\pounds");
  4758. defineSymbol(math, main, textord, "\xA3", "\\mathsterling", true);
  4759. defineSymbol(symbols_text, main, textord, "\xA3", "\\pounds");
  4760. defineSymbol(symbols_text, main, textord, "\xA3", "\\textsterling", true);
  4761. defineSymbol(math, ams, textord, "\u2720", "\\maltese");
  4762. defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards.
  4763. // All of these are textords in math mode
  4764. var mathTextSymbols = "0123456789/@.\"";
  4765. for (var i = 0; i < mathTextSymbols.length; i++) {
  4766. var ch = mathTextSymbols.charAt(i);
  4767. defineSymbol(math, main, textord, ch, ch);
  4768. } // All of these are textords in text mode
  4769. var textSymbols = "0123456789!@*()-=+\";:?/.,";
  4770. for (var _i = 0; _i < textSymbols.length; _i++) {
  4771. var _ch = textSymbols.charAt(_i);
  4772. defineSymbol(symbols_text, main, textord, _ch, _ch);
  4773. } // All of these are textords in text mode, and mathords in math mode
  4774. var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  4775. for (var _i2 = 0; _i2 < letters.length; _i2++) {
  4776. var _ch2 = letters.charAt(_i2);
  4777. defineSymbol(math, main, mathord, _ch2, _ch2);
  4778. defineSymbol(symbols_text, main, textord, _ch2, _ch2);
  4779. } // Blackboard bold and script letters in Unicode range
  4780. defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
  4781. defineSymbol(symbols_text, ams, textord, "C", "\u2102");
  4782. defineSymbol(math, ams, textord, "H", "\u210D");
  4783. defineSymbol(symbols_text, ams, textord, "H", "\u210D");
  4784. defineSymbol(math, ams, textord, "N", "\u2115");
  4785. defineSymbol(symbols_text, ams, textord, "N", "\u2115");
  4786. defineSymbol(math, ams, textord, "P", "\u2119");
  4787. defineSymbol(symbols_text, ams, textord, "P", "\u2119");
  4788. defineSymbol(math, ams, textord, "Q", "\u211A");
  4789. defineSymbol(symbols_text, ams, textord, "Q", "\u211A");
  4790. defineSymbol(math, ams, textord, "R", "\u211D");
  4791. defineSymbol(symbols_text, ams, textord, "R", "\u211D");
  4792. defineSymbol(math, ams, textord, "Z", "\u2124");
  4793. defineSymbol(symbols_text, ams, textord, "Z", "\u2124");
  4794. defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant
  4795. defineSymbol(symbols_text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters.
  4796. // We support some letters in the Unicode range U+1D400 to U+1D7FF,
  4797. // Mathematical Alphanumeric Symbols.
  4798. // Some editors do not deal well with wide characters. So don't write the
  4799. // string into this file. Instead, create the string from the surrogate pair.
  4800. var wideChar = "";
  4801. for (var _i3 = 0; _i3 < letters.length; _i3++) {
  4802. var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair.
  4803. // 0xD835 is the high surrogate for all letters in the range we support.
  4804. // 0xDC00 is the low surrogate for bold A.
  4805. wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
  4806. defineSymbol(math, main, mathord, _ch3, wideChar);
  4807. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4808. wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic
  4809. defineSymbol(math, main, mathord, _ch3, wideChar);
  4810. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4811. wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic
  4812. defineSymbol(math, main, mathord, _ch3, wideChar);
  4813. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4814. wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur
  4815. defineSymbol(math, main, mathord, _ch3, wideChar);
  4816. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4817. wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif
  4818. defineSymbol(math, main, mathord, _ch3, wideChar);
  4819. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4820. wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold
  4821. defineSymbol(math, main, mathord, _ch3, wideChar);
  4822. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4823. wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic
  4824. defineSymbol(math, main, mathord, _ch3, wideChar);
  4825. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4826. wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace
  4827. defineSymbol(math, main, mathord, _ch3, wideChar);
  4828. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4829. if (_i3 < 26) {
  4830. // KaTeX fonts have only capital letters for blackboard bold and script.
  4831. // See exception for k below.
  4832. wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck
  4833. defineSymbol(math, main, mathord, _ch3, wideChar);
  4834. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4835. wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script
  4836. defineSymbol(math, main, mathord, _ch3, wideChar);
  4837. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4838. } // TODO: Add bold script when it is supported by a KaTeX font.
  4839. } // "k" is the only double struck lower case letter in the KaTeX fonts.
  4840. wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
  4841. defineSymbol(math, main, mathord, "k", wideChar);
  4842. defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals
  4843. for (var _i4 = 0; _i4 < 10; _i4++) {
  4844. var _ch4 = _i4.toString();
  4845. wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold
  4846. defineSymbol(math, main, mathord, _ch4, wideChar);
  4847. defineSymbol(symbols_text, main, textord, _ch4, wideChar);
  4848. wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif
  4849. defineSymbol(math, main, mathord, _ch4, wideChar);
  4850. defineSymbol(symbols_text, main, textord, _ch4, wideChar);
  4851. wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans
  4852. defineSymbol(math, main, mathord, _ch4, wideChar);
  4853. defineSymbol(symbols_text, main, textord, _ch4, wideChar);
  4854. wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace
  4855. defineSymbol(math, main, mathord, _ch4, wideChar);
  4856. defineSymbol(symbols_text, main, textord, _ch4, wideChar);
  4857. } // We add these Latin-1 letters as symbols for backwards-compatibility,
  4858. // but they are not actually in the font, nor are they supported by the
  4859. // Unicode accent mechanism, so they fall back to Times font and look ugly.
  4860. // TODO(edemaine): Fix this.
  4861. var extraLatin = "\xD0\xDE\xFE";
  4862. for (var _i5 = 0; _i5 < extraLatin.length; _i5++) {
  4863. var _ch5 = extraLatin.charAt(_i5);
  4864. defineSymbol(math, main, mathord, _ch5, _ch5);
  4865. defineSymbol(symbols_text, main, textord, _ch5, _ch5);
  4866. }
  4867. ;// CONCATENATED MODULE: ./src/wide-character.js
  4868. /**
  4869. * This file provides support for Unicode range U+1D400 to U+1D7FF,
  4870. * Mathematical Alphanumeric Symbols.
  4871. *
  4872. * Function wideCharacterFont takes a wide character as input and returns
  4873. * the font information necessary to render it properly.
  4874. */
  4875. /**
  4876. * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf
  4877. * That document sorts characters into groups by font type, say bold or italic.
  4878. *
  4879. * In the arrays below, each subarray consists three elements:
  4880. * * The CSS class of that group when in math mode.
  4881. * * The CSS class of that group when in text mode.
  4882. * * The font name, so that KaTeX can get font metrics.
  4883. */
  4884. var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright
  4885. ["mathbf", "textbf", "Main-Bold"], // a-z bold upright
  4886. ["mathnormal", "textit", "Math-Italic"], // A-Z italic
  4887. ["mathnormal", "textit", "Math-Italic"], // a-z italic
  4888. ["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic
  4889. ["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic
  4890. // Map fancy A-Z letters to script, not calligraphic.
  4891. // This aligns with unicode-math and math fonts (except Cambria Math).
  4892. ["mathscr", "textscr", "Script-Regular"], // A-Z script
  4893. ["", "", ""], // a-z script. No font
  4894. ["", "", ""], // A-Z bold script. No font
  4895. ["", "", ""], // a-z bold script. No font
  4896. ["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur
  4897. ["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur
  4898. ["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
  4899. ["mathbb", "textbb", "AMS-Regular"], // k double-struck
  4900. ["", "", ""], // A-Z bold Fraktur No font metrics
  4901. ["", "", ""], // a-z bold Fraktur. No font.
  4902. ["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
  4903. ["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
  4904. ["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif
  4905. ["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif
  4906. ["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif
  4907. ["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif
  4908. ["", "", ""], // A-Z bold italic sans. No font
  4909. ["", "", ""], // a-z bold italic sans. No font
  4910. ["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace
  4911. ["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace
  4912. ];
  4913. var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold
  4914. ["", "", ""], // 0-9 double-struck. No KaTeX font.
  4915. ["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif
  4916. ["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif
  4917. ["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace
  4918. ];
  4919. var wideCharacterFont = function wideCharacterFont(wideChar, mode) {
  4920. // IE doesn't support codePointAt(). So work with the surrogate pair.
  4921. var H = wideChar.charCodeAt(0); // high surrogate
  4922. var L = wideChar.charCodeAt(1); // low surrogate
  4923. var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000;
  4924. var j = mode === "math" ? 0 : 1; // column index for CSS class.
  4925. if (0x1D400 <= codePoint && codePoint < 0x1D6A4) {
  4926. // wideLatinLetterData contains exactly 26 chars on each row.
  4927. // So we can calculate the relevant row. No traverse necessary.
  4928. var i = Math.floor((codePoint - 0x1D400) / 26);
  4929. return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]];
  4930. } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) {
  4931. // Numerals, ten per row.
  4932. var _i = Math.floor((codePoint - 0x1D7CE) / 10);
  4933. return [wideNumeralData[_i][2], wideNumeralData[_i][j]];
  4934. } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) {
  4935. // dotless i or j
  4936. return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]];
  4937. } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) {
  4938. // Greek letters. Not supported, yet.
  4939. return ["", ""];
  4940. } else {
  4941. // We don't support any wide characters outside 1D400–1D7FF.
  4942. throw new src_ParseError("Unsupported character: " + wideChar);
  4943. }
  4944. };
  4945. ;// CONCATENATED MODULE: ./src/buildCommon.js
  4946. /* eslint no-console:0 */
  4947. /**
  4948. * This module contains general functions that can be used for building
  4949. * different kinds of domTree nodes in a consistent manner.
  4950. */
  4951. /**
  4952. * Looks up the given symbol in fontMetrics, after applying any symbol
  4953. * replacements defined in symbol.js
  4954. */
  4955. var lookupSymbol = function lookupSymbol(value, // TODO(#963): Use a union type for this.
  4956. fontName, mode) {
  4957. // Replace the value with its replaced value from symbol.js
  4958. if (src_symbols[mode][value] && src_symbols[mode][value].replace) {
  4959. value = src_symbols[mode][value].replace;
  4960. }
  4961. return {
  4962. value: value,
  4963. metrics: getCharacterMetrics(value, fontName, mode)
  4964. };
  4965. };
  4966. /**
  4967. * Makes a symbolNode after translation via the list of symbols in symbols.js.
  4968. * Correctly pulls out metrics for the character, and optionally takes a list of
  4969. * classes to be attached to the node.
  4970. *
  4971. * TODO: make argument order closer to makeSpan
  4972. * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
  4973. * should if present come first in `classes`.
  4974. * TODO(#953): Make `options` mandatory and always pass it in.
  4975. */
  4976. var makeSymbol = function makeSymbol(value, fontName, mode, options, classes) {
  4977. var lookup = lookupSymbol(value, fontName, mode);
  4978. var metrics = lookup.metrics;
  4979. value = lookup.value;
  4980. var symbolNode;
  4981. if (metrics) {
  4982. var italic = metrics.italic;
  4983. if (mode === "text" || options && options.font === "mathit") {
  4984. italic = 0;
  4985. }
  4986. symbolNode = new SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes);
  4987. } else {
  4988. // TODO(emily): Figure out a good way to only print this in development
  4989. typeof console !== "undefined" && console.warn("No character metrics " + ("for '" + value + "' in style '" + fontName + "' and mode '" + mode + "'"));
  4990. symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes);
  4991. }
  4992. if (options) {
  4993. symbolNode.maxFontSize = options.sizeMultiplier;
  4994. if (options.style.isTight()) {
  4995. symbolNode.classes.push("mtight");
  4996. }
  4997. var color = options.getColor();
  4998. if (color) {
  4999. symbolNode.style.color = color;
  5000. }
  5001. }
  5002. return symbolNode;
  5003. };
  5004. /**
  5005. * Makes a symbol in Main-Regular or AMS-Regular.
  5006. * Used for rel, bin, open, close, inner, and punct.
  5007. */
  5008. var mathsym = function mathsym(value, mode, options, classes) {
  5009. if (classes === void 0) {
  5010. classes = [];
  5011. }
  5012. // Decide what font to render the symbol in by its entry in the symbols
  5013. // table.
  5014. // Have a special case for when the value = \ because the \ is used as a
  5015. // textord in unsupported command errors but cannot be parsed as a regular
  5016. // text ordinal and is therefore not present as a symbol in the symbols
  5017. // table for text, as well as a special case for boldsymbol because it
  5018. // can be used for bold + and -
  5019. if (options.font === "boldsymbol" && lookupSymbol(value, "Main-Bold", mode).metrics) {
  5020. return makeSymbol(value, "Main-Bold", mode, options, classes.concat(["mathbf"]));
  5021. } else if (value === "\\" || src_symbols[mode][value].font === "main") {
  5022. return makeSymbol(value, "Main-Regular", mode, options, classes);
  5023. } else {
  5024. return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"]));
  5025. }
  5026. };
  5027. /**
  5028. * Determines which of the two font names (Main-Bold and Math-BoldItalic) and
  5029. * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol",
  5030. * depending on the symbol. Use this function instead of fontMap for font
  5031. * "boldsymbol".
  5032. */
  5033. var boldsymbol = function boldsymbol(value, mode, options, classes, type) {
  5034. if (type !== "textord" && lookupSymbol(value, "Math-BoldItalic", mode).metrics) {
  5035. return {
  5036. fontName: "Math-BoldItalic",
  5037. fontClass: "boldsymbol"
  5038. };
  5039. } else {
  5040. // Some glyphs do not exist in Math-BoldItalic so we need to use
  5041. // Main-Bold instead.
  5042. return {
  5043. fontName: "Main-Bold",
  5044. fontClass: "mathbf"
  5045. };
  5046. }
  5047. };
  5048. /**
  5049. * Makes either a mathord or textord in the correct font and color.
  5050. */
  5051. var makeOrd = function makeOrd(group, options, type) {
  5052. var mode = group.mode;
  5053. var text = group.text;
  5054. var classes = ["mord"]; // Math mode or Old font (i.e. \rm)
  5055. var isFont = mode === "math" || mode === "text" && options.font;
  5056. var fontOrFamily = isFont ? options.font : options.fontFamily;
  5057. if (text.charCodeAt(0) === 0xD835) {
  5058. // surrogate pairs get special treatment
  5059. var _wideCharacterFont = wideCharacterFont(text, mode),
  5060. wideFontName = _wideCharacterFont[0],
  5061. wideFontClass = _wideCharacterFont[1];
  5062. return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass));
  5063. } else if (fontOrFamily) {
  5064. var fontName;
  5065. var fontClasses;
  5066. if (fontOrFamily === "boldsymbol") {
  5067. var fontData = boldsymbol(text, mode, options, classes, type);
  5068. fontName = fontData.fontName;
  5069. fontClasses = [fontData.fontClass];
  5070. } else if (isFont) {
  5071. fontName = fontMap[fontOrFamily].fontName;
  5072. fontClasses = [fontOrFamily];
  5073. } else {
  5074. fontName = retrieveTextFontName(fontOrFamily, options.fontWeight, options.fontShape);
  5075. fontClasses = [fontOrFamily, options.fontWeight, options.fontShape];
  5076. }
  5077. if (lookupSymbol(text, fontName, mode).metrics) {
  5078. return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses));
  5079. } else if (ligatures.hasOwnProperty(text) && fontName.slice(0, 10) === "Typewriter") {
  5080. // Deconstruct ligatures in monospace fonts (\texttt, \tt).
  5081. var parts = [];
  5082. for (var i = 0; i < text.length; i++) {
  5083. parts.push(makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses)));
  5084. }
  5085. return makeFragment(parts);
  5086. }
  5087. } // Makes a symbol in the default font for mathords and textords.
  5088. if (type === "mathord") {
  5089. return makeSymbol(text, "Math-Italic", mode, options, classes.concat(["mathnormal"]));
  5090. } else if (type === "textord") {
  5091. var font = src_symbols[mode][text] && src_symbols[mode][text].font;
  5092. if (font === "ams") {
  5093. var _fontName = retrieveTextFontName("amsrm", options.fontWeight, options.fontShape);
  5094. return makeSymbol(text, _fontName, mode, options, classes.concat("amsrm", options.fontWeight, options.fontShape));
  5095. } else if (font === "main" || !font) {
  5096. var _fontName2 = retrieveTextFontName("textrm", options.fontWeight, options.fontShape);
  5097. return makeSymbol(text, _fontName2, mode, options, classes.concat(options.fontWeight, options.fontShape));
  5098. } else {
  5099. // fonts added by plugins
  5100. var _fontName3 = retrieveTextFontName(font, options.fontWeight, options.fontShape); // We add font name as a css class
  5101. return makeSymbol(text, _fontName3, mode, options, classes.concat(_fontName3, options.fontWeight, options.fontShape));
  5102. }
  5103. } else {
  5104. throw new Error("unexpected type: " + type + " in makeOrd");
  5105. }
  5106. };
  5107. /**
  5108. * Returns true if subsequent symbolNodes have the same classes, skew, maxFont,
  5109. * and styles.
  5110. */
  5111. var canCombine = function canCombine(prev, next) {
  5112. if (createClass(prev.classes) !== createClass(next.classes) || prev.skew !== next.skew || prev.maxFontSize !== next.maxFontSize) {
  5113. return false;
  5114. } // If prev and next both are just "mbin"s or "mord"s we don't combine them
  5115. // so that the proper spacing can be preserved.
  5116. if (prev.classes.length === 1) {
  5117. var cls = prev.classes[0];
  5118. if (cls === "mbin" || cls === "mord") {
  5119. return false;
  5120. }
  5121. }
  5122. for (var style in prev.style) {
  5123. if (prev.style.hasOwnProperty(style) && prev.style[style] !== next.style[style]) {
  5124. return false;
  5125. }
  5126. }
  5127. for (var _style in next.style) {
  5128. if (next.style.hasOwnProperty(_style) && prev.style[_style] !== next.style[_style]) {
  5129. return false;
  5130. }
  5131. }
  5132. return true;
  5133. };
  5134. /**
  5135. * Combine consecutive domTree.symbolNodes into a single symbolNode.
  5136. * Note: this function mutates the argument.
  5137. */
  5138. var tryCombineChars = function tryCombineChars(chars) {
  5139. for (var i = 0; i < chars.length - 1; i++) {
  5140. var prev = chars[i];
  5141. var next = chars[i + 1];
  5142. if (prev instanceof SymbolNode && next instanceof SymbolNode && canCombine(prev, next)) {
  5143. prev.text += next.text;
  5144. prev.height = Math.max(prev.height, next.height);
  5145. prev.depth = Math.max(prev.depth, next.depth); // Use the last character's italic correction since we use
  5146. // it to add padding to the right of the span created from
  5147. // the combined characters.
  5148. prev.italic = next.italic;
  5149. chars.splice(i + 1, 1);
  5150. i--;
  5151. }
  5152. }
  5153. return chars;
  5154. };
  5155. /**
  5156. * Calculate the height, depth, and maxFontSize of an element based on its
  5157. * children.
  5158. */
  5159. var sizeElementFromChildren = function sizeElementFromChildren(elem) {
  5160. var height = 0;
  5161. var depth = 0;
  5162. var maxFontSize = 0;
  5163. for (var i = 0; i < elem.children.length; i++) {
  5164. var child = elem.children[i];
  5165. if (child.height > height) {
  5166. height = child.height;
  5167. }
  5168. if (child.depth > depth) {
  5169. depth = child.depth;
  5170. }
  5171. if (child.maxFontSize > maxFontSize) {
  5172. maxFontSize = child.maxFontSize;
  5173. }
  5174. }
  5175. elem.height = height;
  5176. elem.depth = depth;
  5177. elem.maxFontSize = maxFontSize;
  5178. };
  5179. /**
  5180. * Makes a span with the given list of classes, list of children, and options.
  5181. *
  5182. * TODO(#953): Ensure that `options` is always provided (currently some call
  5183. * sites don't pass it) and make the type below mandatory.
  5184. * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
  5185. * should if present come first in `classes`.
  5186. */
  5187. var makeSpan = function makeSpan(classes, children, options, style) {
  5188. var span = new Span(classes, children, options, style);
  5189. sizeElementFromChildren(span);
  5190. return span;
  5191. }; // SVG one is simpler -- doesn't require height, depth, max-font setting.
  5192. // This is also a separate method for typesafety.
  5193. var makeSvgSpan = function makeSvgSpan(classes, children, options, style) {
  5194. return new Span(classes, children, options, style);
  5195. };
  5196. var makeLineSpan = function makeLineSpan(className, options, thickness) {
  5197. var line = makeSpan([className], [], options);
  5198. line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness);
  5199. line.style.borderBottomWidth = makeEm(line.height);
  5200. line.maxFontSize = 1.0;
  5201. return line;
  5202. };
  5203. /**
  5204. * Makes an anchor with the given href, list of classes, list of children,
  5205. * and options.
  5206. */
  5207. var makeAnchor = function makeAnchor(href, classes, children, options) {
  5208. var anchor = new Anchor(href, classes, children, options);
  5209. sizeElementFromChildren(anchor);
  5210. return anchor;
  5211. };
  5212. /**
  5213. * Makes a document fragment with the given list of children.
  5214. */
  5215. var makeFragment = function makeFragment(children) {
  5216. var fragment = new DocumentFragment(children);
  5217. sizeElementFromChildren(fragment);
  5218. return fragment;
  5219. };
  5220. /**
  5221. * Wraps group in a span if it's a document fragment, allowing to apply classes
  5222. * and styles
  5223. */
  5224. var wrapFragment = function wrapFragment(group, options) {
  5225. if (group instanceof DocumentFragment) {
  5226. return makeSpan([], [group], options);
  5227. }
  5228. return group;
  5229. }; // These are exact object types to catch typos in the names of the optional fields.
  5230. // Computes the updated `children` list and the overall depth.
  5231. //
  5232. // This helper function for makeVList makes it easier to enforce type safety by
  5233. // allowing early exits (returns) in the logic.
  5234. var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) {
  5235. if (params.positionType === "individualShift") {
  5236. var oldChildren = params.children;
  5237. var children = [oldChildren[0]]; // Add in kerns to the list of params.children to get each element to be
  5238. // shifted to the correct specified shift
  5239. var _depth = -oldChildren[0].shift - oldChildren[0].elem.depth;
  5240. var currPos = _depth;
  5241. for (var i = 1; i < oldChildren.length; i++) {
  5242. var diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth;
  5243. var size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth);
  5244. currPos = currPos + diff;
  5245. children.push({
  5246. type: "kern",
  5247. size: size
  5248. });
  5249. children.push(oldChildren[i]);
  5250. }
  5251. return {
  5252. children: children,
  5253. depth: _depth
  5254. };
  5255. }
  5256. var depth;
  5257. if (params.positionType === "top") {
  5258. // We always start at the bottom, so calculate the bottom by adding up
  5259. // all the sizes
  5260. var bottom = params.positionData;
  5261. for (var _i = 0; _i < params.children.length; _i++) {
  5262. var child = params.children[_i];
  5263. bottom -= child.type === "kern" ? child.size : child.elem.height + child.elem.depth;
  5264. }
  5265. depth = bottom;
  5266. } else if (params.positionType === "bottom") {
  5267. depth = -params.positionData;
  5268. } else {
  5269. var firstChild = params.children[0];
  5270. if (firstChild.type !== "elem") {
  5271. throw new Error('First child must have type "elem".');
  5272. }
  5273. if (params.positionType === "shift") {
  5274. depth = -firstChild.elem.depth - params.positionData;
  5275. } else if (params.positionType === "firstBaseline") {
  5276. depth = -firstChild.elem.depth;
  5277. } else {
  5278. throw new Error("Invalid positionType " + params.positionType + ".");
  5279. }
  5280. }
  5281. return {
  5282. children: params.children,
  5283. depth: depth
  5284. };
  5285. };
  5286. /**
  5287. * Makes a vertical list by stacking elements and kerns on top of each other.
  5288. * Allows for many different ways of specifying the positioning method.
  5289. *
  5290. * See VListParam documentation above.
  5291. */
  5292. var makeVList = function makeVList(params, options) {
  5293. var _getVListChildrenAndD = getVListChildrenAndDepth(params),
  5294. children = _getVListChildrenAndD.children,
  5295. depth = _getVListChildrenAndD.depth; // Create a strut that is taller than any list item. The strut is added to
  5296. // each item, where it will determine the item's baseline. Since it has
  5297. // `overflow:hidden`, the strut's top edge will sit on the item's line box's
  5298. // top edge and the strut's bottom edge will sit on the item's baseline,
  5299. // with no additional line-height spacing. This allows the item baseline to
  5300. // be positioned precisely without worrying about font ascent and
  5301. // line-height.
  5302. var pstrutSize = 0;
  5303. for (var i = 0; i < children.length; i++) {
  5304. var child = children[i];
  5305. if (child.type === "elem") {
  5306. var elem = child.elem;
  5307. pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height);
  5308. }
  5309. }
  5310. pstrutSize += 2;
  5311. var pstrut = makeSpan(["pstrut"], []);
  5312. pstrut.style.height = makeEm(pstrutSize); // Create a new list of actual children at the correct offsets
  5313. var realChildren = [];
  5314. var minPos = depth;
  5315. var maxPos = depth;
  5316. var currPos = depth;
  5317. for (var _i2 = 0; _i2 < children.length; _i2++) {
  5318. var _child = children[_i2];
  5319. if (_child.type === "kern") {
  5320. currPos += _child.size;
  5321. } else {
  5322. var _elem = _child.elem;
  5323. var classes = _child.wrapperClasses || [];
  5324. var style = _child.wrapperStyle || {};
  5325. var childWrap = makeSpan(classes, [pstrut, _elem], undefined, style);
  5326. childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth);
  5327. if (_child.marginLeft) {
  5328. childWrap.style.marginLeft = _child.marginLeft;
  5329. }
  5330. if (_child.marginRight) {
  5331. childWrap.style.marginRight = _child.marginRight;
  5332. }
  5333. realChildren.push(childWrap);
  5334. currPos += _elem.height + _elem.depth;
  5335. }
  5336. minPos = Math.min(minPos, currPos);
  5337. maxPos = Math.max(maxPos, currPos);
  5338. } // The vlist contents go in a table-cell with `vertical-align:bottom`.
  5339. // This cell's bottom edge will determine the containing table's baseline
  5340. // without overly expanding the containing line-box.
  5341. var vlist = makeSpan(["vlist"], realChildren);
  5342. vlist.style.height = makeEm(maxPos); // A second row is used if necessary to represent the vlist's depth.
  5343. var rows;
  5344. if (minPos < 0) {
  5345. // We will define depth in an empty span with display: table-cell.
  5346. // It should render with the height that we define. But Chrome, in
  5347. // contenteditable mode only, treats that span as if it contains some
  5348. // text content. And that min-height over-rides our desired height.
  5349. // So we put another empty span inside the depth strut span.
  5350. var emptySpan = makeSpan([], []);
  5351. var depthStrut = makeSpan(["vlist"], [emptySpan]);
  5352. depthStrut.style.height = makeEm(-minPos); // Safari wants the first row to have inline content; otherwise it
  5353. // puts the bottom of the *second* row on the baseline.
  5354. var topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200B")]);
  5355. rows = [makeSpan(["vlist-r"], [vlist, topStrut]), makeSpan(["vlist-r"], [depthStrut])];
  5356. } else {
  5357. rows = [makeSpan(["vlist-r"], [vlist])];
  5358. }
  5359. var vtable = makeSpan(["vlist-t"], rows);
  5360. if (rows.length === 2) {
  5361. vtable.classes.push("vlist-t2");
  5362. }
  5363. vtable.height = maxPos;
  5364. vtable.depth = -minPos;
  5365. return vtable;
  5366. }; // Glue is a concept from TeX which is a flexible space between elements in
  5367. // either a vertical or horizontal list. In KaTeX, at least for now, it's
  5368. // static space between elements in a horizontal layout.
  5369. var makeGlue = function makeGlue(measurement, options) {
  5370. // Make an empty span for the space
  5371. var rule = makeSpan(["mspace"], [], options);
  5372. var size = calculateSize(measurement, options);
  5373. rule.style.marginRight = makeEm(size);
  5374. return rule;
  5375. }; // Takes font options, and returns the appropriate fontLookup name
  5376. var retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeight, fontShape) {
  5377. var baseFontName = "";
  5378. switch (fontFamily) {
  5379. case "amsrm":
  5380. baseFontName = "AMS";
  5381. break;
  5382. case "textrm":
  5383. baseFontName = "Main";
  5384. break;
  5385. case "textsf":
  5386. baseFontName = "SansSerif";
  5387. break;
  5388. case "texttt":
  5389. baseFontName = "Typewriter";
  5390. break;
  5391. default:
  5392. baseFontName = fontFamily;
  5393. // use fonts added by a plugin
  5394. }
  5395. var fontStylesName;
  5396. if (fontWeight === "textbf" && fontShape === "textit") {
  5397. fontStylesName = "BoldItalic";
  5398. } else if (fontWeight === "textbf") {
  5399. fontStylesName = "Bold";
  5400. } else if (fontWeight === "textit") {
  5401. fontStylesName = "Italic";
  5402. } else {
  5403. fontStylesName = "Regular";
  5404. }
  5405. return baseFontName + "-" + fontStylesName;
  5406. };
  5407. /**
  5408. * Maps TeX font commands to objects containing:
  5409. * - variant: string used for "mathvariant" attribute in buildMathML.js
  5410. * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics
  5411. */
  5412. // A map between tex font commands an MathML mathvariant attribute values
  5413. var fontMap = {
  5414. // styles
  5415. "mathbf": {
  5416. variant: "bold",
  5417. fontName: "Main-Bold"
  5418. },
  5419. "mathrm": {
  5420. variant: "normal",
  5421. fontName: "Main-Regular"
  5422. },
  5423. "textit": {
  5424. variant: "italic",
  5425. fontName: "Main-Italic"
  5426. },
  5427. "mathit": {
  5428. variant: "italic",
  5429. fontName: "Main-Italic"
  5430. },
  5431. "mathnormal": {
  5432. variant: "italic",
  5433. fontName: "Math-Italic"
  5434. },
  5435. // "boldsymbol" is missing because they require the use of multiple fonts:
  5436. // Math-BoldItalic and Main-Bold. This is handled by a special case in
  5437. // makeOrd which ends up calling boldsymbol.
  5438. // families
  5439. "mathbb": {
  5440. variant: "double-struck",
  5441. fontName: "AMS-Regular"
  5442. },
  5443. "mathcal": {
  5444. variant: "script",
  5445. fontName: "Caligraphic-Regular"
  5446. },
  5447. "mathfrak": {
  5448. variant: "fraktur",
  5449. fontName: "Fraktur-Regular"
  5450. },
  5451. "mathscr": {
  5452. variant: "script",
  5453. fontName: "Script-Regular"
  5454. },
  5455. "mathsf": {
  5456. variant: "sans-serif",
  5457. fontName: "SansSerif-Regular"
  5458. },
  5459. "mathtt": {
  5460. variant: "monospace",
  5461. fontName: "Typewriter-Regular"
  5462. }
  5463. };
  5464. var svgData = {
  5465. // path, width, height
  5466. vec: ["vec", 0.471, 0.714],
  5467. // values from the font glyph
  5468. oiintSize1: ["oiintSize1", 0.957, 0.499],
  5469. // oval to overlay the integrand
  5470. oiintSize2: ["oiintSize2", 1.472, 0.659],
  5471. oiiintSize1: ["oiiintSize1", 1.304, 0.499],
  5472. oiiintSize2: ["oiiintSize2", 1.98, 0.659]
  5473. };
  5474. var staticSvg = function staticSvg(value, options) {
  5475. // Create a span with inline SVG for the element.
  5476. var _svgData$value = svgData[value],
  5477. pathName = _svgData$value[0],
  5478. width = _svgData$value[1],
  5479. height = _svgData$value[2];
  5480. var path = new PathNode(pathName);
  5481. var svgNode = new SvgNode([path], {
  5482. "width": makeEm(width),
  5483. "height": makeEm(height),
  5484. // Override CSS rule `.katex svg { width: 100% }`
  5485. "style": "width:" + makeEm(width),
  5486. "viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
  5487. "preserveAspectRatio": "xMinYMin"
  5488. });
  5489. var span = makeSvgSpan(["overlay"], [svgNode], options);
  5490. span.height = height;
  5491. span.style.height = makeEm(height);
  5492. span.style.width = makeEm(width);
  5493. return span;
  5494. };
  5495. /* harmony default export */ var buildCommon = ({
  5496. fontMap: fontMap,
  5497. makeSymbol: makeSymbol,
  5498. mathsym: mathsym,
  5499. makeSpan: makeSpan,
  5500. makeSvgSpan: makeSvgSpan,
  5501. makeLineSpan: makeLineSpan,
  5502. makeAnchor: makeAnchor,
  5503. makeFragment: makeFragment,
  5504. wrapFragment: wrapFragment,
  5505. makeVList: makeVList,
  5506. makeOrd: makeOrd,
  5507. makeGlue: makeGlue,
  5508. staticSvg: staticSvg,
  5509. svgData: svgData,
  5510. tryCombineChars: tryCombineChars
  5511. });
  5512. ;// CONCATENATED MODULE: ./src/spacingData.js
  5513. /**
  5514. * Describes spaces between different classes of atoms.
  5515. */
  5516. var thinspace = {
  5517. number: 3,
  5518. unit: "mu"
  5519. };
  5520. var mediumspace = {
  5521. number: 4,
  5522. unit: "mu"
  5523. };
  5524. var thickspace = {
  5525. number: 5,
  5526. unit: "mu"
  5527. }; // Making the type below exact with all optional fields doesn't work due to
  5528. // - https://github.com/facebook/flow/issues/4582
  5529. // - https://github.com/facebook/flow/issues/5688
  5530. // However, since *all* fields are optional, $Shape<> works as suggested in 5688
  5531. // above.
  5532. // Spacing relationships for display and text styles
  5533. var spacings = {
  5534. mord: {
  5535. mop: thinspace,
  5536. mbin: mediumspace,
  5537. mrel: thickspace,
  5538. minner: thinspace
  5539. },
  5540. mop: {
  5541. mord: thinspace,
  5542. mop: thinspace,
  5543. mrel: thickspace,
  5544. minner: thinspace
  5545. },
  5546. mbin: {
  5547. mord: mediumspace,
  5548. mop: mediumspace,
  5549. mopen: mediumspace,
  5550. minner: mediumspace
  5551. },
  5552. mrel: {
  5553. mord: thickspace,
  5554. mop: thickspace,
  5555. mopen: thickspace,
  5556. minner: thickspace
  5557. },
  5558. mopen: {},
  5559. mclose: {
  5560. mop: thinspace,
  5561. mbin: mediumspace,
  5562. mrel: thickspace,
  5563. minner: thinspace
  5564. },
  5565. mpunct: {
  5566. mord: thinspace,
  5567. mop: thinspace,
  5568. mrel: thickspace,
  5569. mopen: thinspace,
  5570. mclose: thinspace,
  5571. mpunct: thinspace,
  5572. minner: thinspace
  5573. },
  5574. minner: {
  5575. mord: thinspace,
  5576. mop: thinspace,
  5577. mbin: mediumspace,
  5578. mrel: thickspace,
  5579. mopen: thinspace,
  5580. mpunct: thinspace,
  5581. minner: thinspace
  5582. }
  5583. }; // Spacing relationships for script and scriptscript styles
  5584. var tightSpacings = {
  5585. mord: {
  5586. mop: thinspace
  5587. },
  5588. mop: {
  5589. mord: thinspace,
  5590. mop: thinspace
  5591. },
  5592. mbin: {},
  5593. mrel: {},
  5594. mopen: {},
  5595. mclose: {
  5596. mop: thinspace
  5597. },
  5598. mpunct: {},
  5599. minner: {
  5600. mop: thinspace
  5601. }
  5602. };
  5603. ;// CONCATENATED MODULE: ./src/defineFunction.js
  5604. /** Context provided to function handlers for error messages. */
  5605. // Note: reverse the order of the return type union will cause a flow error.
  5606. // See https://github.com/facebook/flow/issues/3663.
  5607. // More general version of `HtmlBuilder` for nodes (e.g. \sum, accent types)
  5608. // whose presence impacts super/subscripting. In this case, ParseNode<"supsub">
  5609. // delegates its HTML building to the HtmlBuilder corresponding to these nodes.
  5610. /**
  5611. * Final function spec for use at parse time.
  5612. * This is almost identical to `FunctionPropSpec`, except it
  5613. * 1. includes the function handler, and
  5614. * 2. requires all arguments except argTypes.
  5615. * It is generated by `defineFunction()` below.
  5616. */
  5617. /**
  5618. * All registered functions.
  5619. * `functions.js` just exports this same dictionary again and makes it public.
  5620. * `Parser.js` requires this dictionary.
  5621. */
  5622. var _functions = {};
  5623. /**
  5624. * All HTML builders. Should be only used in the `define*` and the `build*ML`
  5625. * functions.
  5626. */
  5627. var _htmlGroupBuilders = {};
  5628. /**
  5629. * All MathML builders. Should be only used in the `define*` and the `build*ML`
  5630. * functions.
  5631. */
  5632. var _mathmlGroupBuilders = {};
  5633. function defineFunction(_ref) {
  5634. var type = _ref.type,
  5635. names = _ref.names,
  5636. props = _ref.props,
  5637. handler = _ref.handler,
  5638. htmlBuilder = _ref.htmlBuilder,
  5639. mathmlBuilder = _ref.mathmlBuilder;
  5640. // Set default values of functions
  5641. var data = {
  5642. type: type,
  5643. numArgs: props.numArgs,
  5644. argTypes: props.argTypes,
  5645. allowedInArgument: !!props.allowedInArgument,
  5646. allowedInText: !!props.allowedInText,
  5647. allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath,
  5648. numOptionalArgs: props.numOptionalArgs || 0,
  5649. infix: !!props.infix,
  5650. primitive: !!props.primitive,
  5651. handler: handler
  5652. };
  5653. for (var i = 0; i < names.length; ++i) {
  5654. _functions[names[i]] = data;
  5655. }
  5656. if (type) {
  5657. if (htmlBuilder) {
  5658. _htmlGroupBuilders[type] = htmlBuilder;
  5659. }
  5660. if (mathmlBuilder) {
  5661. _mathmlGroupBuilders[type] = mathmlBuilder;
  5662. }
  5663. }
  5664. }
  5665. /**
  5666. * Use this to register only the HTML and MathML builders for a function (e.g.
  5667. * if the function's ParseNode is generated in Parser.js rather than via a
  5668. * stand-alone handler provided to `defineFunction`).
  5669. */
  5670. function defineFunctionBuilders(_ref2) {
  5671. var type = _ref2.type,
  5672. htmlBuilder = _ref2.htmlBuilder,
  5673. mathmlBuilder = _ref2.mathmlBuilder;
  5674. defineFunction({
  5675. type: type,
  5676. names: [],
  5677. props: {
  5678. numArgs: 0
  5679. },
  5680. handler: function handler() {
  5681. throw new Error('Should never be called.');
  5682. },
  5683. htmlBuilder: htmlBuilder,
  5684. mathmlBuilder: mathmlBuilder
  5685. });
  5686. }
  5687. var normalizeArgument = function normalizeArgument(arg) {
  5688. return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg;
  5689. }; // Since the corresponding buildHTML/buildMathML function expects a
  5690. // list of elements, we normalize for different kinds of arguments
  5691. var ordargument = function ordargument(arg) {
  5692. return arg.type === "ordgroup" ? arg.body : [arg];
  5693. };
  5694. ;// CONCATENATED MODULE: ./src/buildHTML.js
  5695. /**
  5696. * This file does the main work of building a domTree structure from a parse
  5697. * tree. The entry point is the `buildHTML` function, which takes a parse tree.
  5698. * Then, the buildExpression, buildGroup, and various groupBuilders functions
  5699. * are called, to produce a final HTML tree.
  5700. */
  5701. var buildHTML_makeSpan = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`)
  5702. // depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6,
  5703. // and the text before Rule 19.
  5704. var binLeftCanceller = ["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"];
  5705. var binRightCanceller = ["rightmost", "mrel", "mclose", "mpunct"];
  5706. var styleMap = {
  5707. "display": src_Style.DISPLAY,
  5708. "text": src_Style.TEXT,
  5709. "script": src_Style.SCRIPT,
  5710. "scriptscript": src_Style.SCRIPTSCRIPT
  5711. };
  5712. var DomEnum = {
  5713. mord: "mord",
  5714. mop: "mop",
  5715. mbin: "mbin",
  5716. mrel: "mrel",
  5717. mopen: "mopen",
  5718. mclose: "mclose",
  5719. mpunct: "mpunct",
  5720. minner: "minner"
  5721. };
  5722. /**
  5723. * Take a list of nodes, build them in order, and return a list of the built
  5724. * nodes. documentFragments are flattened into their contents, so the
  5725. * returned list contains no fragments. `isRealGroup` is true if `expression`
  5726. * is a real group (no atoms will be added on either side), as opposed to
  5727. * a partial group (e.g. one created by \color). `surrounding` is an array
  5728. * consisting type of nodes that will be added to the left and right.
  5729. */
  5730. var buildExpression = function buildExpression(expression, options, isRealGroup, surrounding) {
  5731. if (surrounding === void 0) {
  5732. surrounding = [null, null];
  5733. }
  5734. // Parse expressions into `groups`.
  5735. var groups = [];
  5736. for (var i = 0; i < expression.length; i++) {
  5737. var output = buildGroup(expression[i], options);
  5738. if (output instanceof DocumentFragment) {
  5739. var children = output.children;
  5740. groups.push.apply(groups, children);
  5741. } else {
  5742. groups.push(output);
  5743. }
  5744. } // Combine consecutive domTree.symbolNodes into a single symbolNode.
  5745. buildCommon.tryCombineChars(groups); // If `expression` is a partial group, let the parent handle spacings
  5746. // to avoid processing groups multiple times.
  5747. if (!isRealGroup) {
  5748. return groups;
  5749. }
  5750. var glueOptions = options;
  5751. if (expression.length === 1) {
  5752. var node = expression[0];
  5753. if (node.type === "sizing") {
  5754. glueOptions = options.havingSize(node.size);
  5755. } else if (node.type === "styling") {
  5756. glueOptions = options.havingStyle(styleMap[node.style]);
  5757. }
  5758. } // Dummy spans for determining spacings between surrounding atoms.
  5759. // If `expression` has no atoms on the left or right, class "leftmost"
  5760. // or "rightmost", respectively, is used to indicate it.
  5761. var dummyPrev = buildHTML_makeSpan([surrounding[0] || "leftmost"], [], options);
  5762. var dummyNext = buildHTML_makeSpan([surrounding[1] || "rightmost"], [], options); // TODO: These code assumes that a node's math class is the first element
  5763. // of its `classes` array. A later cleanup should ensure this, for
  5764. // instance by changing the signature of `makeSpan`.
  5765. // Before determining what spaces to insert, perform bin cancellation.
  5766. // Binary operators change to ordinary symbols in some contexts.
  5767. var isRoot = isRealGroup === "root";
  5768. traverseNonSpaceNodes(groups, function (node, prev) {
  5769. var prevType = prev.classes[0];
  5770. var type = node.classes[0];
  5771. if (prevType === "mbin" && utils.contains(binRightCanceller, type)) {
  5772. prev.classes[0] = "mord";
  5773. } else if (type === "mbin" && utils.contains(binLeftCanceller, prevType)) {
  5774. node.classes[0] = "mord";
  5775. }
  5776. }, {
  5777. node: dummyPrev
  5778. }, dummyNext, isRoot);
  5779. traverseNonSpaceNodes(groups, function (node, prev) {
  5780. var prevType = getTypeOfDomTree(prev);
  5781. var type = getTypeOfDomTree(node); // 'mtight' indicates that the node is script or scriptscript style.
  5782. var space = prevType && type ? node.hasClass("mtight") ? tightSpacings[prevType][type] : spacings[prevType][type] : null;
  5783. if (space) {
  5784. // Insert glue (spacing) after the `prev`.
  5785. return buildCommon.makeGlue(space, glueOptions);
  5786. }
  5787. }, {
  5788. node: dummyPrev
  5789. }, dummyNext, isRoot);
  5790. return groups;
  5791. }; // Depth-first traverse non-space `nodes`, calling `callback` with the current and
  5792. // previous node as arguments, optionally returning a node to insert after the
  5793. // previous node. `prev` is an object with the previous node and `insertAfter`
  5794. // function to insert after it. `next` is a node that will be added to the right.
  5795. // Used for bin cancellation and inserting spacings.
  5796. var traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev, next, isRoot) {
  5797. if (next) {
  5798. // temporarily append the right node, if exists
  5799. nodes.push(next);
  5800. }
  5801. var i = 0;
  5802. for (; i < nodes.length; i++) {
  5803. var node = nodes[i];
  5804. var partialGroup = checkPartialGroup(node);
  5805. if (partialGroup) {
  5806. // Recursive DFS
  5807. // $FlowFixMe: make nodes a $ReadOnlyArray by returning a new array
  5808. traverseNonSpaceNodes(partialGroup.children, callback, prev, null, isRoot);
  5809. continue;
  5810. } // Ignore explicit spaces (e.g., \;, \,) when determining what implicit
  5811. // spacing should go between atoms of different classes
  5812. var nonspace = !node.hasClass("mspace");
  5813. if (nonspace) {
  5814. var result = callback(node, prev.node);
  5815. if (result) {
  5816. if (prev.insertAfter) {
  5817. prev.insertAfter(result);
  5818. } else {
  5819. // insert at front
  5820. nodes.unshift(result);
  5821. i++;
  5822. }
  5823. }
  5824. }
  5825. if (nonspace) {
  5826. prev.node = node;
  5827. } else if (isRoot && node.hasClass("newline")) {
  5828. prev.node = buildHTML_makeSpan(["leftmost"]); // treat like beginning of line
  5829. }
  5830. prev.insertAfter = function (index) {
  5831. return function (n) {
  5832. nodes.splice(index + 1, 0, n);
  5833. i++;
  5834. };
  5835. }(i);
  5836. }
  5837. if (next) {
  5838. nodes.pop();
  5839. }
  5840. }; // Check if given node is a partial group, i.e., does not affect spacing around.
  5841. var checkPartialGroup = function checkPartialGroup(node) {
  5842. if (node instanceof DocumentFragment || node instanceof Anchor || node instanceof Span && node.hasClass("enclosing")) {
  5843. return node;
  5844. }
  5845. return null;
  5846. }; // Return the outermost node of a domTree.
  5847. var getOutermostNode = function getOutermostNode(node, side) {
  5848. var partialGroup = checkPartialGroup(node);
  5849. if (partialGroup) {
  5850. var children = partialGroup.children;
  5851. if (children.length) {
  5852. if (side === "right") {
  5853. return getOutermostNode(children[children.length - 1], "right");
  5854. } else if (side === "left") {
  5855. return getOutermostNode(children[0], "left");
  5856. }
  5857. }
  5858. }
  5859. return node;
  5860. }; // Return math atom class (mclass) of a domTree.
  5861. // If `side` is given, it will get the type of the outermost node at given side.
  5862. var getTypeOfDomTree = function getTypeOfDomTree(node, side) {
  5863. if (!node) {
  5864. return null;
  5865. }
  5866. if (side) {
  5867. node = getOutermostNode(node, side);
  5868. } // This makes a lot of assumptions as to where the type of atom
  5869. // appears. We should do a better job of enforcing this.
  5870. return DomEnum[node.classes[0]] || null;
  5871. };
  5872. var makeNullDelimiter = function makeNullDelimiter(options, classes) {
  5873. var moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses());
  5874. return buildHTML_makeSpan(classes.concat(moreClasses));
  5875. };
  5876. /**
  5877. * buildGroup is the function that takes a group and calls the correct groupType
  5878. * function for it. It also handles the interaction of size and style changes
  5879. * between parents and children.
  5880. */
  5881. var buildGroup = function buildGroup(group, options, baseOptions) {
  5882. if (!group) {
  5883. return buildHTML_makeSpan();
  5884. }
  5885. if (_htmlGroupBuilders[group.type]) {
  5886. // Call the groupBuilders function
  5887. // $FlowFixMe
  5888. var groupNode = _htmlGroupBuilders[group.type](group, options); // If the size changed between the parent and the current group, account
  5889. // for that size difference.
  5890. if (baseOptions && options.size !== baseOptions.size) {
  5891. groupNode = buildHTML_makeSpan(options.sizingClasses(baseOptions), [groupNode], options);
  5892. var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier;
  5893. groupNode.height *= multiplier;
  5894. groupNode.depth *= multiplier;
  5895. }
  5896. return groupNode;
  5897. } else {
  5898. throw new src_ParseError("Got group of unknown type: '" + group.type + "'");
  5899. }
  5900. };
  5901. /**
  5902. * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`)
  5903. * into an unbreakable HTML node of class .base, with proper struts to
  5904. * guarantee correct vertical extent. `buildHTML` calls this repeatedly to
  5905. * make up the entire expression as a sequence of unbreakable units.
  5906. */
  5907. function buildHTMLUnbreakable(children, options) {
  5908. // Compute height and depth of this chunk.
  5909. var body = buildHTML_makeSpan(["base"], children, options); // Add strut, which ensures that the top of the HTML element falls at
  5910. // the height of the expression, and the bottom of the HTML element
  5911. // falls at the depth of the expression.
  5912. var strut = buildHTML_makeSpan(["strut"]);
  5913. strut.style.height = makeEm(body.height + body.depth);
  5914. if (body.depth) {
  5915. strut.style.verticalAlign = makeEm(-body.depth);
  5916. }
  5917. body.children.unshift(strut);
  5918. return body;
  5919. }
  5920. /**
  5921. * Take an entire parse tree, and build it into an appropriate set of HTML
  5922. * nodes.
  5923. */
  5924. function buildHTML(tree, options) {
  5925. // Strip off outer tag wrapper for processing below.
  5926. var tag = null;
  5927. if (tree.length === 1 && tree[0].type === "tag") {
  5928. tag = tree[0].tag;
  5929. tree = tree[0].body;
  5930. } // Build the expression contained in the tree
  5931. var expression = buildExpression(tree, options, "root");
  5932. var eqnNum;
  5933. if (expression.length === 2 && expression[1].hasClass("tag")) {
  5934. // An environment with automatic equation numbers, e.g. {gather}.
  5935. eqnNum = expression.pop();
  5936. }
  5937. var children = []; // Create one base node for each chunk between potential line breaks.
  5938. // The TeXBook [p.173] says "A formula will be broken only after a
  5939. // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary
  5940. // operation symbol like $+$ or $-$ or $\times$, where the relation or
  5941. // binary operation is on the ``outer level'' of the formula (i.e., not
  5942. // enclosed in {...} and not part of an \over construction)."
  5943. var parts = [];
  5944. for (var i = 0; i < expression.length; i++) {
  5945. parts.push(expression[i]);
  5946. if (expression[i].hasClass("mbin") || expression[i].hasClass("mrel") || expression[i].hasClass("allowbreak")) {
  5947. // Put any post-operator glue on same line as operator.
  5948. // Watch for \nobreak along the way, and stop at \newline.
  5949. var nobreak = false;
  5950. while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) {
  5951. i++;
  5952. parts.push(expression[i]);
  5953. if (expression[i].hasClass("nobreak")) {
  5954. nobreak = true;
  5955. }
  5956. } // Don't allow break if \nobreak among the post-operator glue.
  5957. if (!nobreak) {
  5958. children.push(buildHTMLUnbreakable(parts, options));
  5959. parts = [];
  5960. }
  5961. } else if (expression[i].hasClass("newline")) {
  5962. // Write the line except the newline
  5963. parts.pop();
  5964. if (parts.length > 0) {
  5965. children.push(buildHTMLUnbreakable(parts, options));
  5966. parts = [];
  5967. } // Put the newline at the top level
  5968. children.push(expression[i]);
  5969. }
  5970. }
  5971. if (parts.length > 0) {
  5972. children.push(buildHTMLUnbreakable(parts, options));
  5973. } // Now, if there was a tag, build it too and append it as a final child.
  5974. var tagChild;
  5975. if (tag) {
  5976. tagChild = buildHTMLUnbreakable(buildExpression(tag, options, true));
  5977. tagChild.classes = ["tag"];
  5978. children.push(tagChild);
  5979. } else if (eqnNum) {
  5980. children.push(eqnNum);
  5981. }
  5982. var htmlNode = buildHTML_makeSpan(["katex-html"], children);
  5983. htmlNode.setAttribute("aria-hidden", "true"); // Adjust the strut of the tag to be the maximum height of all children
  5984. // (the height of the enclosing htmlNode) for proper vertical alignment.
  5985. if (tagChild) {
  5986. var strut = tagChild.children[0];
  5987. strut.style.height = makeEm(htmlNode.height + htmlNode.depth);
  5988. if (htmlNode.depth) {
  5989. strut.style.verticalAlign = makeEm(-htmlNode.depth);
  5990. }
  5991. }
  5992. return htmlNode;
  5993. }
  5994. ;// CONCATENATED MODULE: ./src/mathMLTree.js
  5995. /**
  5996. * These objects store data about MathML nodes. This is the MathML equivalent
  5997. * of the types in domTree.js. Since MathML handles its own rendering, and
  5998. * since we're mainly using MathML to improve accessibility, we don't manage
  5999. * any of the styling state that the plain DOM nodes do.
  6000. *
  6001. * The `toNode` and `toMarkup` functions work simlarly to how they do in
  6002. * domTree.js, creating namespaced DOM nodes and HTML text markup respectively.
  6003. */
  6004. function newDocumentFragment(children) {
  6005. return new DocumentFragment(children);
  6006. }
  6007. /**
  6008. * This node represents a general purpose MathML node of any type. The
  6009. * constructor requires the type of node to create (for example, `"mo"` or
  6010. * `"mspace"`, corresponding to `<mo>` and `<mspace>` tags).
  6011. */
  6012. var MathNode = /*#__PURE__*/function () {
  6013. function MathNode(type, children, classes) {
  6014. this.type = void 0;
  6015. this.attributes = void 0;
  6016. this.children = void 0;
  6017. this.classes = void 0;
  6018. this.type = type;
  6019. this.attributes = {};
  6020. this.children = children || [];
  6021. this.classes = classes || [];
  6022. }
  6023. /**
  6024. * Sets an attribute on a MathML node. MathML depends on attributes to convey a
  6025. * semantic content, so this is used heavily.
  6026. */
  6027. var _proto = MathNode.prototype;
  6028. _proto.setAttribute = function setAttribute(name, value) {
  6029. this.attributes[name] = value;
  6030. }
  6031. /**
  6032. * Gets an attribute on a MathML node.
  6033. */
  6034. ;
  6035. _proto.getAttribute = function getAttribute(name) {
  6036. return this.attributes[name];
  6037. }
  6038. /**
  6039. * Converts the math node into a MathML-namespaced DOM element.
  6040. */
  6041. ;
  6042. _proto.toNode = function toNode() {
  6043. var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type);
  6044. for (var attr in this.attributes) {
  6045. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  6046. node.setAttribute(attr, this.attributes[attr]);
  6047. }
  6048. }
  6049. if (this.classes.length > 0) {
  6050. node.className = createClass(this.classes);
  6051. }
  6052. for (var i = 0; i < this.children.length; i++) {
  6053. node.appendChild(this.children[i].toNode());
  6054. }
  6055. return node;
  6056. }
  6057. /**
  6058. * Converts the math node into an HTML markup string.
  6059. */
  6060. ;
  6061. _proto.toMarkup = function toMarkup() {
  6062. var markup = "<" + this.type; // Add the attributes
  6063. for (var attr in this.attributes) {
  6064. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  6065. markup += " " + attr + "=\"";
  6066. markup += utils.escape(this.attributes[attr]);
  6067. markup += "\"";
  6068. }
  6069. }
  6070. if (this.classes.length > 0) {
  6071. markup += " class =\"" + utils.escape(createClass(this.classes)) + "\"";
  6072. }
  6073. markup += ">";
  6074. for (var i = 0; i < this.children.length; i++) {
  6075. markup += this.children[i].toMarkup();
  6076. }
  6077. markup += "</" + this.type + ">";
  6078. return markup;
  6079. }
  6080. /**
  6081. * Converts the math node into a string, similar to innerText, but escaped.
  6082. */
  6083. ;
  6084. _proto.toText = function toText() {
  6085. return this.children.map(function (child) {
  6086. return child.toText();
  6087. }).join("");
  6088. };
  6089. return MathNode;
  6090. }();
  6091. /**
  6092. * This node represents a piece of text.
  6093. */
  6094. var TextNode = /*#__PURE__*/function () {
  6095. function TextNode(text) {
  6096. this.text = void 0;
  6097. this.text = text;
  6098. }
  6099. /**
  6100. * Converts the text node into a DOM text node.
  6101. */
  6102. var _proto2 = TextNode.prototype;
  6103. _proto2.toNode = function toNode() {
  6104. return document.createTextNode(this.text);
  6105. }
  6106. /**
  6107. * Converts the text node into escaped HTML markup
  6108. * (representing the text itself).
  6109. */
  6110. ;
  6111. _proto2.toMarkup = function toMarkup() {
  6112. return utils.escape(this.toText());
  6113. }
  6114. /**
  6115. * Converts the text node into a string
  6116. * (representing the text iteself).
  6117. */
  6118. ;
  6119. _proto2.toText = function toText() {
  6120. return this.text;
  6121. };
  6122. return TextNode;
  6123. }();
  6124. /**
  6125. * This node represents a space, but may render as <mspace.../> or as text,
  6126. * depending on the width.
  6127. */
  6128. var SpaceNode = /*#__PURE__*/function () {
  6129. /**
  6130. * Create a Space node with width given in CSS ems.
  6131. */
  6132. function SpaceNode(width) {
  6133. this.width = void 0;
  6134. this.character = void 0;
  6135. this.width = width; // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html
  6136. // for a table of space-like characters. We use Unicode
  6137. // representations instead of &LongNames; as it's not clear how to
  6138. // make the latter via document.createTextNode.
  6139. if (width >= 0.05555 && width <= 0.05556) {
  6140. this.character = "\u200A"; // &VeryThinSpace;
  6141. } else if (width >= 0.1666 && width <= 0.1667) {
  6142. this.character = "\u2009"; // &ThinSpace;
  6143. } else if (width >= 0.2222 && width <= 0.2223) {
  6144. this.character = "\u2005"; // &MediumSpace;
  6145. } else if (width >= 0.2777 && width <= 0.2778) {
  6146. this.character = "\u2005\u200A"; // &ThickSpace;
  6147. } else if (width >= -0.05556 && width <= -0.05555) {
  6148. this.character = "\u200A\u2063"; // &NegativeVeryThinSpace;
  6149. } else if (width >= -0.1667 && width <= -0.1666) {
  6150. this.character = "\u2009\u2063"; // &NegativeThinSpace;
  6151. } else if (width >= -0.2223 && width <= -0.2222) {
  6152. this.character = "\u205F\u2063"; // &NegativeMediumSpace;
  6153. } else if (width >= -0.2778 && width <= -0.2777) {
  6154. this.character = "\u2005\u2063"; // &NegativeThickSpace;
  6155. } else {
  6156. this.character = null;
  6157. }
  6158. }
  6159. /**
  6160. * Converts the math node into a MathML-namespaced DOM element.
  6161. */
  6162. var _proto3 = SpaceNode.prototype;
  6163. _proto3.toNode = function toNode() {
  6164. if (this.character) {
  6165. return document.createTextNode(this.character);
  6166. } else {
  6167. var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace");
  6168. node.setAttribute("width", makeEm(this.width));
  6169. return node;
  6170. }
  6171. }
  6172. /**
  6173. * Converts the math node into an HTML markup string.
  6174. */
  6175. ;
  6176. _proto3.toMarkup = function toMarkup() {
  6177. if (this.character) {
  6178. return "<mtext>" + this.character + "</mtext>";
  6179. } else {
  6180. return "<mspace width=\"" + makeEm(this.width) + "\"/>";
  6181. }
  6182. }
  6183. /**
  6184. * Converts the math node into a string, similar to innerText.
  6185. */
  6186. ;
  6187. _proto3.toText = function toText() {
  6188. if (this.character) {
  6189. return this.character;
  6190. } else {
  6191. return " ";
  6192. }
  6193. };
  6194. return SpaceNode;
  6195. }();
  6196. /* harmony default export */ var mathMLTree = ({
  6197. MathNode: MathNode,
  6198. TextNode: TextNode,
  6199. SpaceNode: SpaceNode,
  6200. newDocumentFragment: newDocumentFragment
  6201. });
  6202. ;// CONCATENATED MODULE: ./src/buildMathML.js
  6203. /**
  6204. * This file converts a parse tree into a cooresponding MathML tree. The main
  6205. * entry point is the `buildMathML` function, which takes a parse tree from the
  6206. * parser.
  6207. */
  6208. /**
  6209. * Takes a symbol and converts it into a MathML text node after performing
  6210. * optional replacement from symbols.js.
  6211. */
  6212. var makeText = function makeText(text, mode, options) {
  6213. if (src_symbols[mode][text] && src_symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.slice(4, 6) === "tt" || options.font && options.font.slice(4, 6) === "tt"))) {
  6214. text = src_symbols[mode][text].replace;
  6215. }
  6216. return new mathMLTree.TextNode(text);
  6217. };
  6218. /**
  6219. * Wrap the given array of nodes in an <mrow> node if needed, i.e.,
  6220. * unless the array has length 1. Always returns a single node.
  6221. */
  6222. var makeRow = function makeRow(body) {
  6223. if (body.length === 1) {
  6224. return body[0];
  6225. } else {
  6226. return new mathMLTree.MathNode("mrow", body);
  6227. }
  6228. };
  6229. /**
  6230. * Returns the math variant as a string or null if none is required.
  6231. */
  6232. var getVariant = function getVariant(group, options) {
  6233. // Handle \text... font specifiers as best we can.
  6234. // MathML has a limited list of allowable mathvariant specifiers; see
  6235. // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt
  6236. if (options.fontFamily === "texttt") {
  6237. return "monospace";
  6238. } else if (options.fontFamily === "textsf") {
  6239. if (options.fontShape === "textit" && options.fontWeight === "textbf") {
  6240. return "sans-serif-bold-italic";
  6241. } else if (options.fontShape === "textit") {
  6242. return "sans-serif-italic";
  6243. } else if (options.fontWeight === "textbf") {
  6244. return "bold-sans-serif";
  6245. } else {
  6246. return "sans-serif";
  6247. }
  6248. } else if (options.fontShape === "textit" && options.fontWeight === "textbf") {
  6249. return "bold-italic";
  6250. } else if (options.fontShape === "textit") {
  6251. return "italic";
  6252. } else if (options.fontWeight === "textbf") {
  6253. return "bold";
  6254. }
  6255. var font = options.font;
  6256. if (!font || font === "mathnormal") {
  6257. return null;
  6258. }
  6259. var mode = group.mode;
  6260. if (font === "mathit") {
  6261. return "italic";
  6262. } else if (font === "boldsymbol") {
  6263. return group.type === "textord" ? "bold" : "bold-italic";
  6264. } else if (font === "mathbf") {
  6265. return "bold";
  6266. } else if (font === "mathbb") {
  6267. return "double-struck";
  6268. } else if (font === "mathfrak") {
  6269. return "fraktur";
  6270. } else if (font === "mathscr" || font === "mathcal") {
  6271. // MathML makes no distinction between script and caligrahpic
  6272. return "script";
  6273. } else if (font === "mathsf") {
  6274. return "sans-serif";
  6275. } else if (font === "mathtt") {
  6276. return "monospace";
  6277. }
  6278. var text = group.text;
  6279. if (utils.contains(["\\imath", "\\jmath"], text)) {
  6280. return null;
  6281. }
  6282. if (src_symbols[mode][text] && src_symbols[mode][text].replace) {
  6283. text = src_symbols[mode][text].replace;
  6284. }
  6285. var fontName = buildCommon.fontMap[font].fontName;
  6286. if (getCharacterMetrics(text, fontName, mode)) {
  6287. return buildCommon.fontMap[font].variant;
  6288. }
  6289. return null;
  6290. };
  6291. /**
  6292. * Takes a list of nodes, builds them, and returns a list of the generated
  6293. * MathML nodes. Also combine consecutive <mtext> outputs into a single
  6294. * <mtext> tag.
  6295. */
  6296. var buildMathML_buildExpression = function buildExpression(expression, options, isOrdgroup) {
  6297. if (expression.length === 1) {
  6298. var group = buildMathML_buildGroup(expression[0], options);
  6299. if (isOrdgroup && group instanceof MathNode && group.type === "mo") {
  6300. // When TeX writers want to suppress spacing on an operator,
  6301. // they often put the operator by itself inside braces.
  6302. group.setAttribute("lspace", "0em");
  6303. group.setAttribute("rspace", "0em");
  6304. }
  6305. return [group];
  6306. }
  6307. var groups = [];
  6308. var lastGroup;
  6309. for (var i = 0; i < expression.length; i++) {
  6310. var _group = buildMathML_buildGroup(expression[i], options);
  6311. if (_group instanceof MathNode && lastGroup instanceof MathNode) {
  6312. // Concatenate adjacent <mtext>s
  6313. if (_group.type === 'mtext' && lastGroup.type === 'mtext' && _group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) {
  6314. var _lastGroup$children;
  6315. (_lastGroup$children = lastGroup.children).push.apply(_lastGroup$children, _group.children);
  6316. continue; // Concatenate adjacent <mn>s
  6317. } else if (_group.type === 'mn' && lastGroup.type === 'mn') {
  6318. var _lastGroup$children2;
  6319. (_lastGroup$children2 = lastGroup.children).push.apply(_lastGroup$children2, _group.children);
  6320. continue; // Concatenate <mn>...</mn> followed by <mi>.</mi>
  6321. } else if (_group.type === 'mi' && _group.children.length === 1 && lastGroup.type === 'mn') {
  6322. var child = _group.children[0];
  6323. if (child instanceof TextNode && child.text === '.') {
  6324. var _lastGroup$children3;
  6325. (_lastGroup$children3 = lastGroup.children).push.apply(_lastGroup$children3, _group.children);
  6326. continue;
  6327. }
  6328. } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) {
  6329. var lastChild = lastGroup.children[0];
  6330. if (lastChild instanceof TextNode && lastChild.text === "\u0338" && (_group.type === 'mo' || _group.type === 'mi' || _group.type === 'mn')) {
  6331. var _child = _group.children[0];
  6332. if (_child instanceof TextNode && _child.text.length > 0) {
  6333. // Overlay with combining character long solidus
  6334. _child.text = _child.text.slice(0, 1) + "\u0338" + _child.text.slice(1);
  6335. groups.pop();
  6336. }
  6337. }
  6338. }
  6339. }
  6340. groups.push(_group);
  6341. lastGroup = _group;
  6342. }
  6343. return groups;
  6344. };
  6345. /**
  6346. * Equivalent to buildExpression, but wraps the elements in an <mrow>
  6347. * if there's more than one. Returns a single node instead of an array.
  6348. */
  6349. var buildExpressionRow = function buildExpressionRow(expression, options, isOrdgroup) {
  6350. return makeRow(buildMathML_buildExpression(expression, options, isOrdgroup));
  6351. };
  6352. /**
  6353. * Takes a group from the parser and calls the appropriate groupBuilders function
  6354. * on it to produce a MathML node.
  6355. */
  6356. var buildMathML_buildGroup = function buildGroup(group, options) {
  6357. if (!group) {
  6358. return new mathMLTree.MathNode("mrow");
  6359. }
  6360. if (_mathmlGroupBuilders[group.type]) {
  6361. // Call the groupBuilders function
  6362. // $FlowFixMe
  6363. var result = _mathmlGroupBuilders[group.type](group, options); // $FlowFixMe
  6364. return result;
  6365. } else {
  6366. throw new src_ParseError("Got group of unknown type: '" + group.type + "'");
  6367. }
  6368. };
  6369. /**
  6370. * Takes a full parse tree and settings and builds a MathML representation of
  6371. * it. In particular, we put the elements from building the parse tree into a
  6372. * <semantics> tag so we can also include that TeX source as an annotation.
  6373. *
  6374. * Note that we actually return a domTree element with a `<math>` inside it so
  6375. * we can do appropriate styling.
  6376. */
  6377. function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) {
  6378. var expression = buildMathML_buildExpression(tree, options); // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes
  6379. // and add spacing nodes. This is necessary only adjacent to math operators
  6380. // like \sin or \lim or to subsup elements that contain math operators.
  6381. // MathML takes care of the other spacing issues.
  6382. // Wrap up the expression in an mrow so it is presented in the semantics
  6383. // tag correctly, unless it's a single <mrow> or <mtable>.
  6384. var wrapper;
  6385. if (expression.length === 1 && expression[0] instanceof MathNode && utils.contains(["mrow", "mtable"], expression[0].type)) {
  6386. wrapper = expression[0];
  6387. } else {
  6388. wrapper = new mathMLTree.MathNode("mrow", expression);
  6389. } // Build a TeX annotation of the source
  6390. var annotation = new mathMLTree.MathNode("annotation", [new mathMLTree.TextNode(texExpression)]);
  6391. annotation.setAttribute("encoding", "application/x-tex");
  6392. var semantics = new mathMLTree.MathNode("semantics", [wrapper, annotation]);
  6393. var math = new mathMLTree.MathNode("math", [semantics]);
  6394. math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
  6395. if (isDisplayMode) {
  6396. math.setAttribute("display", "block");
  6397. } // You can't style <math> nodes, so we wrap the node in a span.
  6398. // NOTE: The span class is not typed to have <math> nodes as children, and
  6399. // we don't want to make the children type more generic since the children
  6400. // of span are expected to have more fields in `buildHtml` contexts.
  6401. var wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; // $FlowFixMe
  6402. return buildCommon.makeSpan([wrapperClass], [math]);
  6403. }
  6404. ;// CONCATENATED MODULE: ./src/buildTree.js
  6405. var optionsFromSettings = function optionsFromSettings(settings) {
  6406. return new src_Options({
  6407. style: settings.displayMode ? src_Style.DISPLAY : src_Style.TEXT,
  6408. maxSize: settings.maxSize,
  6409. minRuleThickness: settings.minRuleThickness
  6410. });
  6411. };
  6412. var displayWrap = function displayWrap(node, settings) {
  6413. if (settings.displayMode) {
  6414. var classes = ["katex-display"];
  6415. if (settings.leqno) {
  6416. classes.push("leqno");
  6417. }
  6418. if (settings.fleqn) {
  6419. classes.push("fleqn");
  6420. }
  6421. node = buildCommon.makeSpan(classes, [node]);
  6422. }
  6423. return node;
  6424. };
  6425. var buildTree = function buildTree(tree, expression, settings) {
  6426. var options = optionsFromSettings(settings);
  6427. var katexNode;
  6428. if (settings.output === "mathml") {
  6429. return buildMathML(tree, expression, options, settings.displayMode, true);
  6430. } else if (settings.output === "html") {
  6431. var htmlNode = buildHTML(tree, options);
  6432. katexNode = buildCommon.makeSpan(["katex"], [htmlNode]);
  6433. } else {
  6434. var mathMLNode = buildMathML(tree, expression, options, settings.displayMode, false);
  6435. var _htmlNode = buildHTML(tree, options);
  6436. katexNode = buildCommon.makeSpan(["katex"], [mathMLNode, _htmlNode]);
  6437. }
  6438. return displayWrap(katexNode, settings);
  6439. };
  6440. var buildHTMLTree = function buildHTMLTree(tree, expression, settings) {
  6441. var options = optionsFromSettings(settings);
  6442. var htmlNode = buildHTML(tree, options);
  6443. var katexNode = buildCommon.makeSpan(["katex"], [htmlNode]);
  6444. return displayWrap(katexNode, settings);
  6445. };
  6446. /* harmony default export */ var src_buildTree = ((/* unused pure expression or super */ null && (buildTree)));
  6447. ;// CONCATENATED MODULE: ./src/stretchy.js
  6448. /**
  6449. * This file provides support to buildMathML.js and buildHTML.js
  6450. * for stretchy wide elements rendered from SVG files
  6451. * and other CSS trickery.
  6452. */
  6453. var stretchyCodePoint = {
  6454. widehat: "^",
  6455. widecheck: "ˇ",
  6456. widetilde: "~",
  6457. utilde: "~",
  6458. overleftarrow: "\u2190",
  6459. underleftarrow: "\u2190",
  6460. xleftarrow: "\u2190",
  6461. overrightarrow: "\u2192",
  6462. underrightarrow: "\u2192",
  6463. xrightarrow: "\u2192",
  6464. underbrace: "\u23DF",
  6465. overbrace: "\u23DE",
  6466. overgroup: "\u23E0",
  6467. undergroup: "\u23E1",
  6468. overleftrightarrow: "\u2194",
  6469. underleftrightarrow: "\u2194",
  6470. xleftrightarrow: "\u2194",
  6471. Overrightarrow: "\u21D2",
  6472. xRightarrow: "\u21D2",
  6473. overleftharpoon: "\u21BC",
  6474. xleftharpoonup: "\u21BC",
  6475. overrightharpoon: "\u21C0",
  6476. xrightharpoonup: "\u21C0",
  6477. xLeftarrow: "\u21D0",
  6478. xLeftrightarrow: "\u21D4",
  6479. xhookleftarrow: "\u21A9",
  6480. xhookrightarrow: "\u21AA",
  6481. xmapsto: "\u21A6",
  6482. xrightharpoondown: "\u21C1",
  6483. xleftharpoondown: "\u21BD",
  6484. xrightleftharpoons: "\u21CC",
  6485. xleftrightharpoons: "\u21CB",
  6486. xtwoheadleftarrow: "\u219E",
  6487. xtwoheadrightarrow: "\u21A0",
  6488. xlongequal: "=",
  6489. xtofrom: "\u21C4",
  6490. xrightleftarrows: "\u21C4",
  6491. xrightequilibrium: "\u21CC",
  6492. // Not a perfect match.
  6493. xleftequilibrium: "\u21CB",
  6494. // None better available.
  6495. "\\cdrightarrow": "\u2192",
  6496. "\\cdleftarrow": "\u2190",
  6497. "\\cdlongequal": "="
  6498. };
  6499. var mathMLnode = function mathMLnode(label) {
  6500. var node = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(stretchyCodePoint[label.replace(/^\\/, '')])]);
  6501. node.setAttribute("stretchy", "true");
  6502. return node;
  6503. }; // Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts.
  6504. // Copyright (c) 2009-2010, Design Science, Inc. (<www.mathjax.org>)
  6505. // Copyright (c) 2014-2017 Khan Academy (<www.khanacademy.org>)
  6506. // Licensed under the SIL Open Font License, Version 1.1.
  6507. // See \nhttp://scripts.sil.org/OFL
  6508. // Very Long SVGs
  6509. // Many of the KaTeX stretchy wide elements use a long SVG image and an
  6510. // overflow: hidden tactic to achieve a stretchy image while avoiding
  6511. // distortion of arrowheads or brace corners.
  6512. // The SVG typically contains a very long (400 em) arrow.
  6513. // The SVG is in a container span that has overflow: hidden, so the span
  6514. // acts like a window that exposes only part of the SVG.
  6515. // The SVG always has a longer, thinner aspect ratio than the container span.
  6516. // After the SVG fills 100% of the height of the container span,
  6517. // there is a long arrow shaft left over. That left-over shaft is not shown.
  6518. // Instead, it is sliced off because the span's CSS has overflow: hidden.
  6519. // Thus, the reader sees an arrow that matches the subject matter width
  6520. // without distortion.
  6521. // Some functions, such as \cancel, need to vary their aspect ratio. These
  6522. // functions do not get the overflow SVG treatment.
  6523. // Second Brush Stroke
  6524. // Low resolution monitors struggle to display images in fine detail.
  6525. // So browsers apply anti-aliasing. A long straight arrow shaft therefore
  6526. // will sometimes appear as if it has a blurred edge.
  6527. // To mitigate this, these SVG files contain a second "brush-stroke" on the
  6528. // arrow shafts. That is, a second long thin rectangular SVG path has been
  6529. // written directly on top of each arrow shaft. This reinforcement causes
  6530. // some of the screen pixels to display as black instead of the anti-aliased
  6531. // gray pixel that a single path would generate. So we get arrow shafts
  6532. // whose edges appear to be sharper.
  6533. // In the katexImagesData object just below, the dimensions all
  6534. // correspond to path geometry inside the relevant SVG.
  6535. // For example, \overrightarrow uses the same arrowhead as glyph U+2192
  6536. // from the KaTeX Main font. The scaling factor is 1000.
  6537. // That is, inside the font, that arrowhead is 522 units tall, which
  6538. // corresponds to 0.522 em inside the document.
  6539. var katexImagesData = {
  6540. // path(s), minWidth, height, align
  6541. overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"],
  6542. overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"],
  6543. underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"],
  6544. underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"],
  6545. xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"],
  6546. "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"],
  6547. // CD minwwidth2.5pc
  6548. xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"],
  6549. "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"],
  6550. Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"],
  6551. xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"],
  6552. xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"],
  6553. overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"],
  6554. xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"],
  6555. xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"],
  6556. overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"],
  6557. xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"],
  6558. xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"],
  6559. xlongequal: [["longequal"], 0.888, 334, "xMinYMin"],
  6560. "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"],
  6561. xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"],
  6562. xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"],
  6563. overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522],
  6564. overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548],
  6565. underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], 1.6, 548],
  6566. underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522],
  6567. xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522],
  6568. xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560],
  6569. xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716],
  6570. xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], 1.75, 716],
  6571. xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522],
  6572. xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522],
  6573. overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522],
  6574. underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522],
  6575. overgroup: [["leftgroup", "rightgroup"], 0.888, 342],
  6576. undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342],
  6577. xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522],
  6578. xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528],
  6579. // The next three arrows are from the mhchem package.
  6580. // In mhchem.sty, min-length is 2.0em. But these arrows might appear in the
  6581. // document as \xrightarrow or \xrightleftharpoons. Those have
  6582. // min-length = 1.75em, so we set min-length on these next three to match.
  6583. xrightleftarrows: [["baraboveleftarrow", "rightarrowabovebar"], 1.75, 901],
  6584. xrightequilibrium: [["baraboveshortleftharpoon", "rightharpoonaboveshortbar"], 1.75, 716],
  6585. xleftequilibrium: [["shortbaraboveleftharpoon", "shortrightharpoonabovebar"], 1.75, 716]
  6586. };
  6587. var groupLength = function groupLength(arg) {
  6588. if (arg.type === "ordgroup") {
  6589. return arg.body.length;
  6590. } else {
  6591. return 1;
  6592. }
  6593. };
  6594. var svgSpan = function svgSpan(group, options) {
  6595. // Create a span with inline SVG for the element.
  6596. function buildSvgSpan_() {
  6597. var viewBoxWidth = 400000; // default
  6598. var label = group.label.slice(1);
  6599. if (utils.contains(["widehat", "widecheck", "widetilde", "utilde"], label)) {
  6600. // Each type in the `if` statement corresponds to one of the ParseNode
  6601. // types below. This narrowing is required to access `grp.base`.
  6602. // $FlowFixMe
  6603. var grp = group; // There are four SVG images available for each function.
  6604. // Choose a taller image when there are more characters.
  6605. var numChars = groupLength(grp.base);
  6606. var viewBoxHeight;
  6607. var pathName;
  6608. var _height;
  6609. if (numChars > 5) {
  6610. if (label === "widehat" || label === "widecheck") {
  6611. viewBoxHeight = 420;
  6612. viewBoxWidth = 2364;
  6613. _height = 0.42;
  6614. pathName = label + "4";
  6615. } else {
  6616. viewBoxHeight = 312;
  6617. viewBoxWidth = 2340;
  6618. _height = 0.34;
  6619. pathName = "tilde4";
  6620. }
  6621. } else {
  6622. var imgIndex = [1, 1, 2, 2, 3, 3][numChars];
  6623. if (label === "widehat" || label === "widecheck") {
  6624. viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex];
  6625. viewBoxHeight = [0, 239, 300, 360, 420][imgIndex];
  6626. _height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex];
  6627. pathName = label + imgIndex;
  6628. } else {
  6629. viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex];
  6630. viewBoxHeight = [0, 260, 286, 306, 312][imgIndex];
  6631. _height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex];
  6632. pathName = "tilde" + imgIndex;
  6633. }
  6634. }
  6635. var path = new PathNode(pathName);
  6636. var svgNode = new SvgNode([path], {
  6637. "width": "100%",
  6638. "height": makeEm(_height),
  6639. "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight,
  6640. "preserveAspectRatio": "none"
  6641. });
  6642. return {
  6643. span: buildCommon.makeSvgSpan([], [svgNode], options),
  6644. minWidth: 0,
  6645. height: _height
  6646. };
  6647. } else {
  6648. var spans = [];
  6649. var data = katexImagesData[label];
  6650. var paths = data[0],
  6651. _minWidth = data[1],
  6652. _viewBoxHeight = data[2];
  6653. var _height2 = _viewBoxHeight / 1000;
  6654. var numSvgChildren = paths.length;
  6655. var widthClasses;
  6656. var aligns;
  6657. if (numSvgChildren === 1) {
  6658. // $FlowFixMe: All these cases must be of the 4-tuple type.
  6659. var align1 = data[3];
  6660. widthClasses = ["hide-tail"];
  6661. aligns = [align1];
  6662. } else if (numSvgChildren === 2) {
  6663. widthClasses = ["halfarrow-left", "halfarrow-right"];
  6664. aligns = ["xMinYMin", "xMaxYMin"];
  6665. } else if (numSvgChildren === 3) {
  6666. widthClasses = ["brace-left", "brace-center", "brace-right"];
  6667. aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"];
  6668. } else {
  6669. throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children.");
  6670. }
  6671. for (var i = 0; i < numSvgChildren; i++) {
  6672. var _path = new PathNode(paths[i]);
  6673. var _svgNode = new SvgNode([_path], {
  6674. "width": "400em",
  6675. "height": makeEm(_height2),
  6676. "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight,
  6677. "preserveAspectRatio": aligns[i] + " slice"
  6678. });
  6679. var _span = buildCommon.makeSvgSpan([widthClasses[i]], [_svgNode], options);
  6680. if (numSvgChildren === 1) {
  6681. return {
  6682. span: _span,
  6683. minWidth: _minWidth,
  6684. height: _height2
  6685. };
  6686. } else {
  6687. _span.style.height = makeEm(_height2);
  6688. spans.push(_span);
  6689. }
  6690. }
  6691. return {
  6692. span: buildCommon.makeSpan(["stretchy"], spans, options),
  6693. minWidth: _minWidth,
  6694. height: _height2
  6695. };
  6696. }
  6697. } // buildSvgSpan_()
  6698. var _buildSvgSpan_ = buildSvgSpan_(),
  6699. span = _buildSvgSpan_.span,
  6700. minWidth = _buildSvgSpan_.minWidth,
  6701. height = _buildSvgSpan_.height; // Note that we are returning span.depth = 0.
  6702. // Any adjustments relative to the baseline must be done in buildHTML.
  6703. span.height = height;
  6704. span.style.height = makeEm(height);
  6705. if (minWidth > 0) {
  6706. span.style.minWidth = makeEm(minWidth);
  6707. }
  6708. return span;
  6709. };
  6710. var encloseSpan = function encloseSpan(inner, label, topPad, bottomPad, options) {
  6711. // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl
  6712. var img;
  6713. var totalHeight = inner.height + inner.depth + topPad + bottomPad;
  6714. if (/fbox|color|angl/.test(label)) {
  6715. img = buildCommon.makeSpan(["stretchy", label], [], options);
  6716. if (label === "fbox") {
  6717. var color = options.color && options.getColor();
  6718. if (color) {
  6719. img.style.borderColor = color;
  6720. }
  6721. }
  6722. } else {
  6723. // \cancel, \bcancel, or \xcancel
  6724. // Since \cancel's SVG is inline and it omits the viewBox attribute,
  6725. // its stroke-width will not vary with span area.
  6726. var lines = [];
  6727. if (/^[bx]cancel$/.test(label)) {
  6728. lines.push(new LineNode({
  6729. "x1": "0",
  6730. "y1": "0",
  6731. "x2": "100%",
  6732. "y2": "100%",
  6733. "stroke-width": "0.046em"
  6734. }));
  6735. }
  6736. if (/^x?cancel$/.test(label)) {
  6737. lines.push(new LineNode({
  6738. "x1": "0",
  6739. "y1": "100%",
  6740. "x2": "100%",
  6741. "y2": "0",
  6742. "stroke-width": "0.046em"
  6743. }));
  6744. }
  6745. var svgNode = new SvgNode(lines, {
  6746. "width": "100%",
  6747. "height": makeEm(totalHeight)
  6748. });
  6749. img = buildCommon.makeSvgSpan([], [svgNode], options);
  6750. }
  6751. img.height = totalHeight;
  6752. img.style.height = makeEm(totalHeight);
  6753. return img;
  6754. };
  6755. /* harmony default export */ var stretchy = ({
  6756. encloseSpan: encloseSpan,
  6757. mathMLnode: mathMLnode,
  6758. svgSpan: svgSpan
  6759. });
  6760. ;// CONCATENATED MODULE: ./src/parseNode.js
  6761. /**
  6762. * Asserts that the node is of the given type and returns it with stricter
  6763. * typing. Throws if the node's type does not match.
  6764. */
  6765. function assertNodeType(node, type) {
  6766. if (!node || node.type !== type) {
  6767. throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node)));
  6768. } // $FlowFixMe, >=0.125
  6769. return node;
  6770. }
  6771. /**
  6772. * Returns the node more strictly typed iff it is of the given type. Otherwise,
  6773. * returns null.
  6774. */
  6775. function assertSymbolNodeType(node) {
  6776. var typedNode = checkSymbolNodeType(node);
  6777. if (!typedNode) {
  6778. throw new Error("Expected node of symbol group type, but got " + (node ? "node of type " + node.type : String(node)));
  6779. }
  6780. return typedNode;
  6781. }
  6782. /**
  6783. * Returns the node more strictly typed iff it is of the given type. Otherwise,
  6784. * returns null.
  6785. */
  6786. function checkSymbolNodeType(node) {
  6787. if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) {
  6788. // $FlowFixMe
  6789. return node;
  6790. }
  6791. return null;
  6792. }
  6793. ;// CONCATENATED MODULE: ./src/functions/accent.js
  6794. // NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but
  6795. // also "supsub" since an accent can affect super/subscripting.
  6796. var htmlBuilder = function htmlBuilder(grp, options) {
  6797. // Accents are handled in the TeXbook pg. 443, rule 12.
  6798. var base;
  6799. var group;
  6800. var supSubGroup;
  6801. if (grp && grp.type === "supsub") {
  6802. // If our base is a character box, and we have superscripts and
  6803. // subscripts, the supsub will defer to us. In particular, we want
  6804. // to attach the superscripts and subscripts to the inner body (so
  6805. // that the position of the superscripts and subscripts won't be
  6806. // affected by the height of the accent). We accomplish this by
  6807. // sticking the base of the accent into the base of the supsub, and
  6808. // rendering that, while keeping track of where the accent is.
  6809. // The real accent group is the base of the supsub group
  6810. group = assertNodeType(grp.base, "accent"); // The character box is the base of the accent group
  6811. base = group.base; // Stick the character box into the base of the supsub group
  6812. grp.base = base; // Rerender the supsub group with its new base, and store that
  6813. // result.
  6814. supSubGroup = assertSpan(buildGroup(grp, options)); // reset original base
  6815. grp.base = group;
  6816. } else {
  6817. group = assertNodeType(grp, "accent");
  6818. base = group.base;
  6819. } // Build the base group
  6820. var body = buildGroup(base, options.havingCrampedStyle()); // Does the accent need to shift for the skew of a character?
  6821. var mustShift = group.isShifty && utils.isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the
  6822. // nucleus is not a single character, let s = 0; otherwise set s to the
  6823. // kern amount for the nucleus followed by the \skewchar of its font."
  6824. // Note that our skew metrics are just the kern between each character
  6825. // and the skewchar.
  6826. var skew = 0;
  6827. if (mustShift) {
  6828. // If the base is a character box, then we want the skew of the
  6829. // innermost character. To do that, we find the innermost character:
  6830. var baseChar = utils.getBaseElem(base); // Then, we render its group to get the symbol inside it
  6831. var baseGroup = buildGroup(baseChar, options.havingCrampedStyle()); // Finally, we pull the skew off of the symbol.
  6832. skew = assertSymbolDomNode(baseGroup).skew; // Note that we now throw away baseGroup, because the layers we
  6833. // removed with getBaseElem might contain things like \color which
  6834. // we can't get rid of.
  6835. // TODO(emily): Find a better way to get the skew
  6836. }
  6837. var accentBelow = group.label === "\\c"; // calculate the amount of space between the body and the accent
  6838. var clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight); // Build the accent
  6839. var accentBody;
  6840. if (!group.isStretchy) {
  6841. var accent;
  6842. var width;
  6843. if (group.label === "\\vec") {
  6844. // Before version 0.9, \vec used the combining font glyph U+20D7.
  6845. // But browsers, especially Safari, are not consistent in how they
  6846. // render combining characters when not preceded by a character.
  6847. // So now we use an SVG.
  6848. // If Safari reforms, we should consider reverting to the glyph.
  6849. accent = buildCommon.staticSvg("vec", options);
  6850. width = buildCommon.svgData.vec[1];
  6851. } else {
  6852. accent = buildCommon.makeOrd({
  6853. mode: group.mode,
  6854. text: group.label
  6855. }, options, "textord");
  6856. accent = assertSymbolDomNode(accent); // Remove the italic correction of the accent, because it only serves to
  6857. // shift the accent over to a place we don't want.
  6858. accent.italic = 0;
  6859. width = accent.width;
  6860. if (accentBelow) {
  6861. clearance += accent.depth;
  6862. }
  6863. }
  6864. accentBody = buildCommon.makeSpan(["accent-body"], [accent]); // "Full" accents expand the width of the resulting symbol to be
  6865. // at least the width of the accent, and overlap directly onto the
  6866. // character without any vertical offset.
  6867. var accentFull = group.label === "\\textcircled";
  6868. if (accentFull) {
  6869. accentBody.classes.push('accent-full');
  6870. clearance = body.height;
  6871. } // Shift the accent over by the skew.
  6872. var left = skew; // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }`
  6873. // so that the accent doesn't contribute to the bounding box.
  6874. // We need to shift the character by its width (effectively half
  6875. // its width) to compensate.
  6876. if (!accentFull) {
  6877. left -= width / 2;
  6878. }
  6879. accentBody.style.left = makeEm(left); // \textcircled uses the \bigcirc glyph, so it needs some
  6880. // vertical adjustment to match LaTeX.
  6881. if (group.label === "\\textcircled") {
  6882. accentBody.style.top = ".2em";
  6883. }
  6884. accentBody = buildCommon.makeVList({
  6885. positionType: "firstBaseline",
  6886. children: [{
  6887. type: "elem",
  6888. elem: body
  6889. }, {
  6890. type: "kern",
  6891. size: -clearance
  6892. }, {
  6893. type: "elem",
  6894. elem: accentBody
  6895. }]
  6896. }, options);
  6897. } else {
  6898. accentBody = stretchy.svgSpan(group, options);
  6899. accentBody = buildCommon.makeVList({
  6900. positionType: "firstBaseline",
  6901. children: [{
  6902. type: "elem",
  6903. elem: body
  6904. }, {
  6905. type: "elem",
  6906. elem: accentBody,
  6907. wrapperClasses: ["svg-align"],
  6908. wrapperStyle: skew > 0 ? {
  6909. width: "calc(100% - " + makeEm(2 * skew) + ")",
  6910. marginLeft: makeEm(2 * skew)
  6911. } : undefined
  6912. }]
  6913. }, options);
  6914. }
  6915. var accentWrap = buildCommon.makeSpan(["mord", "accent"], [accentBody], options);
  6916. if (supSubGroup) {
  6917. // Here, we replace the "base" child of the supsub with our newly
  6918. // generated accent.
  6919. supSubGroup.children[0] = accentWrap; // Since we don't rerun the height calculation after replacing the
  6920. // accent, we manually recalculate height.
  6921. supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); // Accents should always be ords, even when their innards are not.
  6922. supSubGroup.classes[0] = "mord";
  6923. return supSubGroup;
  6924. } else {
  6925. return accentWrap;
  6926. }
  6927. };
  6928. var mathmlBuilder = function mathmlBuilder(group, options) {
  6929. var accentNode = group.isStretchy ? stretchy.mathMLnode(group.label) : new mathMLTree.MathNode("mo", [makeText(group.label, group.mode)]);
  6930. var node = new mathMLTree.MathNode("mover", [buildMathML_buildGroup(group.base, options), accentNode]);
  6931. node.setAttribute("accent", "true");
  6932. return node;
  6933. };
  6934. var NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(function (accent) {
  6935. return "\\" + accent;
  6936. }).join("|")); // Accents
  6937. defineFunction({
  6938. type: "accent",
  6939. names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"],
  6940. props: {
  6941. numArgs: 1
  6942. },
  6943. handler: function handler(context, args) {
  6944. var base = normalizeArgument(args[0]);
  6945. var isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName);
  6946. var isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck";
  6947. return {
  6948. type: "accent",
  6949. mode: context.parser.mode,
  6950. label: context.funcName,
  6951. isStretchy: isStretchy,
  6952. isShifty: isShifty,
  6953. base: base
  6954. };
  6955. },
  6956. htmlBuilder: htmlBuilder,
  6957. mathmlBuilder: mathmlBuilder
  6958. }); // Text-mode accents
  6959. defineFunction({
  6960. type: "accent",
  6961. names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"],
  6962. props: {
  6963. numArgs: 1,
  6964. allowedInText: true,
  6965. allowedInMath: true,
  6966. // unless in strict mode
  6967. argTypes: ["primitive"]
  6968. },
  6969. handler: function handler(context, args) {
  6970. var base = args[0];
  6971. var mode = context.parser.mode;
  6972. if (mode === "math") {
  6973. context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode");
  6974. mode = "text";
  6975. }
  6976. return {
  6977. type: "accent",
  6978. mode: mode,
  6979. label: context.funcName,
  6980. isStretchy: false,
  6981. isShifty: true,
  6982. base: base
  6983. };
  6984. },
  6985. htmlBuilder: htmlBuilder,
  6986. mathmlBuilder: mathmlBuilder
  6987. });
  6988. ;// CONCATENATED MODULE: ./src/functions/accentunder.js
  6989. // Horizontal overlap functions
  6990. defineFunction({
  6991. type: "accentUnder",
  6992. names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"],
  6993. props: {
  6994. numArgs: 1
  6995. },
  6996. handler: function handler(_ref, args) {
  6997. var parser = _ref.parser,
  6998. funcName = _ref.funcName;
  6999. var base = args[0];
  7000. return {
  7001. type: "accentUnder",
  7002. mode: parser.mode,
  7003. label: funcName,
  7004. base: base
  7005. };
  7006. },
  7007. htmlBuilder: function htmlBuilder(group, options) {
  7008. // Treat under accents much like underlines.
  7009. var innerGroup = buildGroup(group.base, options);
  7010. var accentBody = stretchy.svgSpan(group, options);
  7011. var kern = group.label === "\\utilde" ? 0.12 : 0; // Generate the vlist, with the appropriate kerns
  7012. var vlist = buildCommon.makeVList({
  7013. positionType: "top",
  7014. positionData: innerGroup.height,
  7015. children: [{
  7016. type: "elem",
  7017. elem: accentBody,
  7018. wrapperClasses: ["svg-align"]
  7019. }, {
  7020. type: "kern",
  7021. size: kern
  7022. }, {
  7023. type: "elem",
  7024. elem: innerGroup
  7025. }]
  7026. }, options);
  7027. return buildCommon.makeSpan(["mord", "accentunder"], [vlist], options);
  7028. },
  7029. mathmlBuilder: function mathmlBuilder(group, options) {
  7030. var accentNode = stretchy.mathMLnode(group.label);
  7031. var node = new mathMLTree.MathNode("munder", [buildMathML_buildGroup(group.base, options), accentNode]);
  7032. node.setAttribute("accentunder", "true");
  7033. return node;
  7034. }
  7035. });
  7036. ;// CONCATENATED MODULE: ./src/functions/arrow.js
  7037. // Helper function
  7038. var paddedNode = function paddedNode(group) {
  7039. var node = new mathMLTree.MathNode("mpadded", group ? [group] : []);
  7040. node.setAttribute("width", "+0.6em");
  7041. node.setAttribute("lspace", "0.3em");
  7042. return node;
  7043. }; // Stretchy arrows with an optional argument
  7044. defineFunction({
  7045. type: "xArrow",
  7046. names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", // The next 3 functions are here to support the mhchem extension.
  7047. // Direct use of these functions is discouraged and may break someday.
  7048. "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium", // The next 3 functions are here only to support the {CD} environment.
  7049. "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"],
  7050. props: {
  7051. numArgs: 1,
  7052. numOptionalArgs: 1
  7053. },
  7054. handler: function handler(_ref, args, optArgs) {
  7055. var parser = _ref.parser,
  7056. funcName = _ref.funcName;
  7057. return {
  7058. type: "xArrow",
  7059. mode: parser.mode,
  7060. label: funcName,
  7061. body: args[0],
  7062. below: optArgs[0]
  7063. };
  7064. },
  7065. // Flow is unable to correctly infer the type of `group`, even though it's
  7066. // unamibiguously determined from the passed-in `type` above.
  7067. htmlBuilder: function htmlBuilder(group, options) {
  7068. var style = options.style; // Build the argument groups in the appropriate style.
  7069. // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}%
  7070. // Some groups can return document fragments. Handle those by wrapping
  7071. // them in a span.
  7072. var newOptions = options.havingStyle(style.sup());
  7073. var upperGroup = buildCommon.wrapFragment(buildGroup(group.body, newOptions, options), options);
  7074. var arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd";
  7075. upperGroup.classes.push(arrowPrefix + "-arrow-pad");
  7076. var lowerGroup;
  7077. if (group.below) {
  7078. // Build the lower group
  7079. newOptions = options.havingStyle(style.sub());
  7080. lowerGroup = buildCommon.wrapFragment(buildGroup(group.below, newOptions, options), options);
  7081. lowerGroup.classes.push(arrowPrefix + "-arrow-pad");
  7082. }
  7083. var arrowBody = stretchy.svgSpan(group, options); // Re shift: Note that stretchy.svgSpan returned arrowBody.depth = 0.
  7084. // The point we want on the math axis is at 0.5 * arrowBody.height.
  7085. var arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi
  7086. var upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu
  7087. if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") {
  7088. upperShift -= upperGroup.depth; // shift up if depth encroaches
  7089. } // Generate the vlist
  7090. var vlist;
  7091. if (lowerGroup) {
  7092. var lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111;
  7093. vlist = buildCommon.makeVList({
  7094. positionType: "individualShift",
  7095. children: [{
  7096. type: "elem",
  7097. elem: upperGroup,
  7098. shift: upperShift
  7099. }, {
  7100. type: "elem",
  7101. elem: arrowBody,
  7102. shift: arrowShift
  7103. }, {
  7104. type: "elem",
  7105. elem: lowerGroup,
  7106. shift: lowerShift
  7107. }]
  7108. }, options);
  7109. } else {
  7110. vlist = buildCommon.makeVList({
  7111. positionType: "individualShift",
  7112. children: [{
  7113. type: "elem",
  7114. elem: upperGroup,
  7115. shift: upperShift
  7116. }, {
  7117. type: "elem",
  7118. elem: arrowBody,
  7119. shift: arrowShift
  7120. }]
  7121. }, options);
  7122. } // $FlowFixMe: Replace this with passing "svg-align" into makeVList.
  7123. vlist.children[0].children[0].children[1].classes.push("svg-align");
  7124. return buildCommon.makeSpan(["mrel", "x-arrow"], [vlist], options);
  7125. },
  7126. mathmlBuilder: function mathmlBuilder(group, options) {
  7127. var arrowNode = stretchy.mathMLnode(group.label);
  7128. arrowNode.setAttribute("minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em");
  7129. var node;
  7130. if (group.body) {
  7131. var upperNode = paddedNode(buildMathML_buildGroup(group.body, options));
  7132. if (group.below) {
  7133. var lowerNode = paddedNode(buildMathML_buildGroup(group.below, options));
  7134. node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]);
  7135. } else {
  7136. node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]);
  7137. }
  7138. } else if (group.below) {
  7139. var _lowerNode = paddedNode(buildMathML_buildGroup(group.below, options));
  7140. node = new mathMLTree.MathNode("munder", [arrowNode, _lowerNode]);
  7141. } else {
  7142. // This should never happen.
  7143. // Parser.js throws an error if there is no argument.
  7144. node = paddedNode();
  7145. node = new mathMLTree.MathNode("mover", [arrowNode, node]);
  7146. }
  7147. return node;
  7148. }
  7149. });
  7150. ;// CONCATENATED MODULE: ./src/functions/mclass.js
  7151. var mclass_makeSpan = buildCommon.makeSpan;
  7152. function mclass_htmlBuilder(group, options) {
  7153. var elements = buildExpression(group.body, options, true);
  7154. return mclass_makeSpan([group.mclass], elements, options);
  7155. }
  7156. function mclass_mathmlBuilder(group, options) {
  7157. var node;
  7158. var inner = buildMathML_buildExpression(group.body, options);
  7159. if (group.mclass === "minner") {
  7160. node = new mathMLTree.MathNode("mpadded", inner);
  7161. } else if (group.mclass === "mord") {
  7162. if (group.isCharacterBox) {
  7163. node = inner[0];
  7164. node.type = "mi";
  7165. } else {
  7166. node = new mathMLTree.MathNode("mi", inner);
  7167. }
  7168. } else {
  7169. if (group.isCharacterBox) {
  7170. node = inner[0];
  7171. node.type = "mo";
  7172. } else {
  7173. node = new mathMLTree.MathNode("mo", inner);
  7174. } // Set spacing based on what is the most likely adjacent atom type.
  7175. // See TeXbook p170.
  7176. if (group.mclass === "mbin") {
  7177. node.attributes.lspace = "0.22em"; // medium space
  7178. node.attributes.rspace = "0.22em";
  7179. } else if (group.mclass === "mpunct") {
  7180. node.attributes.lspace = "0em";
  7181. node.attributes.rspace = "0.17em"; // thinspace
  7182. } else if (group.mclass === "mopen" || group.mclass === "mclose") {
  7183. node.attributes.lspace = "0em";
  7184. node.attributes.rspace = "0em";
  7185. } else if (group.mclass === "minner") {
  7186. node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option
  7187. node.attributes.width = "+0.1111em";
  7188. } // MathML <mo> default space is 5/18 em, so <mrel> needs no action.
  7189. // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
  7190. }
  7191. return node;
  7192. } // Math class commands except \mathop
  7193. defineFunction({
  7194. type: "mclass",
  7195. names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"],
  7196. props: {
  7197. numArgs: 1,
  7198. primitive: true
  7199. },
  7200. handler: function handler(_ref, args) {
  7201. var parser = _ref.parser,
  7202. funcName = _ref.funcName;
  7203. var body = args[0];
  7204. return {
  7205. type: "mclass",
  7206. mode: parser.mode,
  7207. mclass: "m" + funcName.slice(5),
  7208. // TODO(kevinb): don't prefix with 'm'
  7209. body: ordargument(body),
  7210. isCharacterBox: utils.isCharacterBox(body)
  7211. };
  7212. },
  7213. htmlBuilder: mclass_htmlBuilder,
  7214. mathmlBuilder: mclass_mathmlBuilder
  7215. });
  7216. var binrelClass = function binrelClass(arg) {
  7217. // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument.
  7218. // (by rendering separately and with {}s before and after, and measuring
  7219. // the change in spacing). We'll do roughly the same by detecting the
  7220. // atom type directly.
  7221. var atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg;
  7222. if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) {
  7223. return "m" + atom.family;
  7224. } else {
  7225. return "mord";
  7226. }
  7227. }; // \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord.
  7228. // This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX.
  7229. defineFunction({
  7230. type: "mclass",
  7231. names: ["\\@binrel"],
  7232. props: {
  7233. numArgs: 2
  7234. },
  7235. handler: function handler(_ref2, args) {
  7236. var parser = _ref2.parser;
  7237. return {
  7238. type: "mclass",
  7239. mode: parser.mode,
  7240. mclass: binrelClass(args[0]),
  7241. body: ordargument(args[1]),
  7242. isCharacterBox: utils.isCharacterBox(args[1])
  7243. };
  7244. }
  7245. }); // Build a relation or stacked op by placing one symbol on top of another
  7246. defineFunction({
  7247. type: "mclass",
  7248. names: ["\\stackrel", "\\overset", "\\underset"],
  7249. props: {
  7250. numArgs: 2
  7251. },
  7252. handler: function handler(_ref3, args) {
  7253. var parser = _ref3.parser,
  7254. funcName = _ref3.funcName;
  7255. var baseArg = args[1];
  7256. var shiftedArg = args[0];
  7257. var mclass;
  7258. if (funcName !== "\\stackrel") {
  7259. // LaTeX applies \binrel spacing to \overset and \underset.
  7260. mclass = binrelClass(baseArg);
  7261. } else {
  7262. mclass = "mrel"; // for \stackrel
  7263. }
  7264. var baseOp = {
  7265. type: "op",
  7266. mode: baseArg.mode,
  7267. limits: true,
  7268. alwaysHandleSupSub: true,
  7269. parentIsSupSub: false,
  7270. symbol: false,
  7271. suppressBaseShift: funcName !== "\\stackrel",
  7272. body: ordargument(baseArg)
  7273. };
  7274. var supsub = {
  7275. type: "supsub",
  7276. mode: shiftedArg.mode,
  7277. base: baseOp,
  7278. sup: funcName === "\\underset" ? null : shiftedArg,
  7279. sub: funcName === "\\underset" ? shiftedArg : null
  7280. };
  7281. return {
  7282. type: "mclass",
  7283. mode: parser.mode,
  7284. mclass: mclass,
  7285. body: [supsub],
  7286. isCharacterBox: utils.isCharacterBox(supsub)
  7287. };
  7288. },
  7289. htmlBuilder: mclass_htmlBuilder,
  7290. mathmlBuilder: mclass_mathmlBuilder
  7291. });
  7292. ;// CONCATENATED MODULE: ./src/functions/pmb.js
  7293. // \pmb is a simulation of bold font.
  7294. // The version of \pmb in ambsy.sty works by typesetting three copies
  7295. // with small offsets. We use CSS text-shadow.
  7296. // It's a hack. Not as good as a real bold font. Better than nothing.
  7297. defineFunction({
  7298. type: "pmb",
  7299. names: ["\\pmb"],
  7300. props: {
  7301. numArgs: 1,
  7302. allowedInText: true
  7303. },
  7304. handler: function handler(_ref, args) {
  7305. var parser = _ref.parser;
  7306. return {
  7307. type: "pmb",
  7308. mode: parser.mode,
  7309. mclass: binrelClass(args[0]),
  7310. body: ordargument(args[0])
  7311. };
  7312. },
  7313. htmlBuilder: function htmlBuilder(group, options) {
  7314. var elements = buildExpression(group.body, options, true);
  7315. var node = buildCommon.makeSpan([group.mclass], elements, options);
  7316. node.style.textShadow = "0.02em 0.01em 0.04px";
  7317. return node;
  7318. },
  7319. mathmlBuilder: function mathmlBuilder(group, style) {
  7320. var inner = buildMathML_buildExpression(group.body, style); // Wrap with an <mstyle> element.
  7321. var node = new mathMLTree.MathNode("mstyle", inner);
  7322. node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px");
  7323. return node;
  7324. }
  7325. });
  7326. ;// CONCATENATED MODULE: ./src/environments/cd.js
  7327. var cdArrowFunctionName = {
  7328. ">": "\\\\cdrightarrow",
  7329. "<": "\\\\cdleftarrow",
  7330. "=": "\\\\cdlongequal",
  7331. "A": "\\uparrow",
  7332. "V": "\\downarrow",
  7333. "|": "\\Vert",
  7334. ".": "no arrow"
  7335. };
  7336. var newCell = function newCell() {
  7337. // Create an empty cell, to be filled below with parse nodes.
  7338. // The parseTree from this module must be constructed like the
  7339. // one created by parseArray(), so an empty CD cell must
  7340. // be a ParseNode<"styling">. And CD is always displaystyle.
  7341. // So these values are fixed and flow can do implicit typing.
  7342. return {
  7343. type: "styling",
  7344. body: [],
  7345. mode: "math",
  7346. style: "display"
  7347. };
  7348. };
  7349. var isStartOfArrow = function isStartOfArrow(node) {
  7350. return node.type === "textord" && node.text === "@";
  7351. };
  7352. var isLabelEnd = function isLabelEnd(node, endChar) {
  7353. return (node.type === "mathord" || node.type === "atom") && node.text === endChar;
  7354. };
  7355. function cdArrow(arrowChar, labels, parser) {
  7356. // Return a parse tree of an arrow and its labels.
  7357. // This acts in a way similar to a macro expansion.
  7358. var funcName = cdArrowFunctionName[arrowChar];
  7359. switch (funcName) {
  7360. case "\\\\cdrightarrow":
  7361. case "\\\\cdleftarrow":
  7362. return parser.callFunction(funcName, [labels[0]], [labels[1]]);
  7363. case "\\uparrow":
  7364. case "\\downarrow":
  7365. {
  7366. var leftLabel = parser.callFunction("\\\\cdleft", [labels[0]], []);
  7367. var bareArrow = {
  7368. type: "atom",
  7369. text: funcName,
  7370. mode: "math",
  7371. family: "rel"
  7372. };
  7373. var sizedArrow = parser.callFunction("\\Big", [bareArrow], []);
  7374. var rightLabel = parser.callFunction("\\\\cdright", [labels[1]], []);
  7375. var arrowGroup = {
  7376. type: "ordgroup",
  7377. mode: "math",
  7378. body: [leftLabel, sizedArrow, rightLabel]
  7379. };
  7380. return parser.callFunction("\\\\cdparent", [arrowGroup], []);
  7381. }
  7382. case "\\\\cdlongequal":
  7383. return parser.callFunction("\\\\cdlongequal", [], []);
  7384. case "\\Vert":
  7385. {
  7386. var arrow = {
  7387. type: "textord",
  7388. text: "\\Vert",
  7389. mode: "math"
  7390. };
  7391. return parser.callFunction("\\Big", [arrow], []);
  7392. }
  7393. default:
  7394. return {
  7395. type: "textord",
  7396. text: " ",
  7397. mode: "math"
  7398. };
  7399. }
  7400. }
  7401. function parseCD(parser) {
  7402. // Get the array's parse nodes with \\ temporarily mapped to \cr.
  7403. var parsedRows = [];
  7404. parser.gullet.beginGroup();
  7405. parser.gullet.macros.set("\\cr", "\\\\\\relax");
  7406. parser.gullet.beginGroup();
  7407. while (true) {
  7408. // eslint-disable-line no-constant-condition
  7409. // Get the parse nodes for the next row.
  7410. parsedRows.push(parser.parseExpression(false, "\\\\"));
  7411. parser.gullet.endGroup();
  7412. parser.gullet.beginGroup();
  7413. var next = parser.fetch().text;
  7414. if (next === "&" || next === "\\\\") {
  7415. parser.consume();
  7416. } else if (next === "\\end") {
  7417. if (parsedRows[parsedRows.length - 1].length === 0) {
  7418. parsedRows.pop(); // final row ended in \\
  7419. }
  7420. break;
  7421. } else {
  7422. throw new src_ParseError("Expected \\\\ or \\cr or \\end", parser.nextToken);
  7423. }
  7424. }
  7425. var row = [];
  7426. var body = [row]; // Loop thru the parse nodes. Collect them into cells and arrows.
  7427. for (var i = 0; i < parsedRows.length; i++) {
  7428. // Start a new row.
  7429. var rowNodes = parsedRows[i]; // Create the first cell.
  7430. var cell = newCell();
  7431. for (var j = 0; j < rowNodes.length; j++) {
  7432. if (!isStartOfArrow(rowNodes[j])) {
  7433. // If a parseNode is not an arrow, it goes into a cell.
  7434. cell.body.push(rowNodes[j]);
  7435. } else {
  7436. // Parse node j is an "@", the start of an arrow.
  7437. // Before starting on the arrow, push the cell into `row`.
  7438. row.push(cell); // Now collect parseNodes into an arrow.
  7439. // The character after "@" defines the arrow type.
  7440. j += 1;
  7441. var arrowChar = assertSymbolNodeType(rowNodes[j]).text; // Create two empty label nodes. We may or may not use them.
  7442. var labels = new Array(2);
  7443. labels[0] = {
  7444. type: "ordgroup",
  7445. mode: "math",
  7446. body: []
  7447. };
  7448. labels[1] = {
  7449. type: "ordgroup",
  7450. mode: "math",
  7451. body: []
  7452. }; // Process the arrow.
  7453. if ("=|.".indexOf(arrowChar) > -1) {// Three "arrows", ``@=`, `@|`, and `@.`, do not take labels.
  7454. // Do nothing here.
  7455. } else if ("<>AV".indexOf(arrowChar) > -1) {
  7456. // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take
  7457. // two optional labels. E.g. the right-point arrow syntax is
  7458. // really: @>{optional label}>{optional label}>
  7459. // Collect parseNodes into labels.
  7460. for (var labelNum = 0; labelNum < 2; labelNum++) {
  7461. var inLabel = true;
  7462. for (var k = j + 1; k < rowNodes.length; k++) {
  7463. if (isLabelEnd(rowNodes[k], arrowChar)) {
  7464. inLabel = false;
  7465. j = k;
  7466. break;
  7467. }
  7468. if (isStartOfArrow(rowNodes[k])) {
  7469. throw new src_ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[k]);
  7470. }
  7471. labels[labelNum].body.push(rowNodes[k]);
  7472. }
  7473. if (inLabel) {
  7474. // isLabelEnd never returned a true.
  7475. throw new src_ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[j]);
  7476. }
  7477. }
  7478. } else {
  7479. throw new src_ParseError("Expected one of \"<>AV=|.\" after @", rowNodes[j]);
  7480. } // Now join the arrow to its labels.
  7481. var arrow = cdArrow(arrowChar, labels, parser); // Wrap the arrow in ParseNode<"styling">.
  7482. // This is done to match parseArray() behavior.
  7483. var wrappedArrow = {
  7484. type: "styling",
  7485. body: [arrow],
  7486. mode: "math",
  7487. style: "display" // CD is always displaystyle.
  7488. };
  7489. row.push(wrappedArrow); // In CD's syntax, cells are implicit. That is, everything that
  7490. // is not an arrow gets collected into a cell. So create an empty
  7491. // cell now. It will collect upcoming parseNodes.
  7492. cell = newCell();
  7493. }
  7494. }
  7495. if (i % 2 === 0) {
  7496. // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell
  7497. // The last cell is not yet pushed into `row`, so:
  7498. row.push(cell);
  7499. } else {
  7500. // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow
  7501. // Remove the empty cell that was placed at the beginning of `row`.
  7502. row.shift();
  7503. }
  7504. row = [];
  7505. body.push(row);
  7506. } // End row group
  7507. parser.gullet.endGroup(); // End array group defining \\
  7508. parser.gullet.endGroup(); // define column separation.
  7509. var cols = new Array(body[0].length).fill({
  7510. type: "align",
  7511. align: "c",
  7512. pregap: 0.25,
  7513. // CD package sets \enskip between columns.
  7514. postgap: 0.25 // So pre and post each get half an \enskip, i.e. 0.25em.
  7515. });
  7516. return {
  7517. type: "array",
  7518. mode: "math",
  7519. body: body,
  7520. arraystretch: 1,
  7521. addJot: true,
  7522. rowGaps: [null],
  7523. cols: cols,
  7524. colSeparationType: "CD",
  7525. hLinesBeforeRow: new Array(body.length + 1).fill([])
  7526. };
  7527. } // The functions below are not available for general use.
  7528. // They are here only for internal use by the {CD} environment in placing labels
  7529. // next to vertical arrows.
  7530. // We don't need any such functions for horizontal arrows because we can reuse
  7531. // the functionality that already exists for extensible arrows.
  7532. defineFunction({
  7533. type: "cdlabel",
  7534. names: ["\\\\cdleft", "\\\\cdright"],
  7535. props: {
  7536. numArgs: 1
  7537. },
  7538. handler: function handler(_ref, args) {
  7539. var parser = _ref.parser,
  7540. funcName = _ref.funcName;
  7541. return {
  7542. type: "cdlabel",
  7543. mode: parser.mode,
  7544. side: funcName.slice(4),
  7545. label: args[0]
  7546. };
  7547. },
  7548. htmlBuilder: function htmlBuilder(group, options) {
  7549. var newOptions = options.havingStyle(options.style.sup());
  7550. var label = buildCommon.wrapFragment(buildGroup(group.label, newOptions, options), options);
  7551. label.classes.push("cd-label-" + group.side);
  7552. label.style.bottom = makeEm(0.8 - label.depth); // Zero out label height & depth, so vertical align of arrow is set
  7553. // by the arrow height, not by the label.
  7554. label.height = 0;
  7555. label.depth = 0;
  7556. return label;
  7557. },
  7558. mathmlBuilder: function mathmlBuilder(group, options) {
  7559. var label = new mathMLTree.MathNode("mrow", [buildMathML_buildGroup(group.label, options)]);
  7560. label = new mathMLTree.MathNode("mpadded", [label]);
  7561. label.setAttribute("width", "0");
  7562. if (group.side === "left") {
  7563. label.setAttribute("lspace", "-1width");
  7564. } // We have to guess at vertical alignment. We know the arrow is 1.8em tall,
  7565. // But we don't know the height or depth of the label.
  7566. label.setAttribute("voffset", "0.7em");
  7567. label = new mathMLTree.MathNode("mstyle", [label]);
  7568. label.setAttribute("displaystyle", "false");
  7569. label.setAttribute("scriptlevel", "1");
  7570. return label;
  7571. }
  7572. });
  7573. defineFunction({
  7574. type: "cdlabelparent",
  7575. names: ["\\\\cdparent"],
  7576. props: {
  7577. numArgs: 1
  7578. },
  7579. handler: function handler(_ref2, args) {
  7580. var parser = _ref2.parser;
  7581. return {
  7582. type: "cdlabelparent",
  7583. mode: parser.mode,
  7584. fragment: args[0]
  7585. };
  7586. },
  7587. htmlBuilder: function htmlBuilder(group, options) {
  7588. // Wrap the vertical arrow and its labels.
  7589. // The parent gets position: relative. The child gets position: absolute.
  7590. // So CSS can locate the label correctly.
  7591. var parent = buildCommon.wrapFragment(buildGroup(group.fragment, options), options);
  7592. parent.classes.push("cd-vert-arrow");
  7593. return parent;
  7594. },
  7595. mathmlBuilder: function mathmlBuilder(group, options) {
  7596. return new mathMLTree.MathNode("mrow", [buildMathML_buildGroup(group.fragment, options)]);
  7597. }
  7598. });
  7599. ;// CONCATENATED MODULE: ./src/functions/char.js
  7600. // \@char is an internal function that takes a grouped decimal argument like
  7601. // {123} and converts into symbol with code 123. It is used by the *macro*
  7602. // \char defined in macros.js.
  7603. defineFunction({
  7604. type: "textord",
  7605. names: ["\\@char"],
  7606. props: {
  7607. numArgs: 1,
  7608. allowedInText: true
  7609. },
  7610. handler: function handler(_ref, args) {
  7611. var parser = _ref.parser;
  7612. var arg = assertNodeType(args[0], "ordgroup");
  7613. var group = arg.body;
  7614. var number = "";
  7615. for (var i = 0; i < group.length; i++) {
  7616. var node = assertNodeType(group[i], "textord");
  7617. number += node.text;
  7618. }
  7619. var code = parseInt(number);
  7620. var text;
  7621. if (isNaN(code)) {
  7622. throw new src_ParseError("\\@char has non-numeric argument " + number); // If we drop IE support, the following code could be replaced with
  7623. // text = String.fromCodePoint(code)
  7624. } else if (code < 0 || code >= 0x10ffff) {
  7625. throw new src_ParseError("\\@char with invalid code point " + number);
  7626. } else if (code <= 0xffff) {
  7627. text = String.fromCharCode(code);
  7628. } else {
  7629. // Astral code point; split into surrogate halves
  7630. code -= 0x10000;
  7631. text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00);
  7632. }
  7633. return {
  7634. type: "textord",
  7635. mode: parser.mode,
  7636. text: text
  7637. };
  7638. }
  7639. });
  7640. ;// CONCATENATED MODULE: ./src/functions/color.js
  7641. var color_htmlBuilder = function htmlBuilder(group, options) {
  7642. var elements = buildExpression(group.body, options.withColor(group.color), false); // \color isn't supposed to affect the type of the elements it contains.
  7643. // To accomplish this, we wrap the results in a fragment, so the inner
  7644. // elements will be able to directly interact with their neighbors. For
  7645. // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3`
  7646. return buildCommon.makeFragment(elements);
  7647. };
  7648. var color_mathmlBuilder = function mathmlBuilder(group, options) {
  7649. var inner = buildMathML_buildExpression(group.body, options.withColor(group.color));
  7650. var node = new mathMLTree.MathNode("mstyle", inner);
  7651. node.setAttribute("mathcolor", group.color);
  7652. return node;
  7653. };
  7654. defineFunction({
  7655. type: "color",
  7656. names: ["\\textcolor"],
  7657. props: {
  7658. numArgs: 2,
  7659. allowedInText: true,
  7660. argTypes: ["color", "original"]
  7661. },
  7662. handler: function handler(_ref, args) {
  7663. var parser = _ref.parser;
  7664. var color = assertNodeType(args[0], "color-token").color;
  7665. var body = args[1];
  7666. return {
  7667. type: "color",
  7668. mode: parser.mode,
  7669. color: color,
  7670. body: ordargument(body)
  7671. };
  7672. },
  7673. htmlBuilder: color_htmlBuilder,
  7674. mathmlBuilder: color_mathmlBuilder
  7675. });
  7676. defineFunction({
  7677. type: "color",
  7678. names: ["\\color"],
  7679. props: {
  7680. numArgs: 1,
  7681. allowedInText: true,
  7682. argTypes: ["color"]
  7683. },
  7684. handler: function handler(_ref2, args) {
  7685. var parser = _ref2.parser,
  7686. breakOnTokenText = _ref2.breakOnTokenText;
  7687. var color = assertNodeType(args[0], "color-token").color; // Set macro \current@color in current namespace to store the current
  7688. // color, mimicking the behavior of color.sty.
  7689. // This is currently used just to correctly color a \right
  7690. // that follows a \color command.
  7691. parser.gullet.macros.set("\\current@color", color); // Parse out the implicit body that should be colored.
  7692. var body = parser.parseExpression(true, breakOnTokenText);
  7693. return {
  7694. type: "color",
  7695. mode: parser.mode,
  7696. color: color,
  7697. body: body
  7698. };
  7699. },
  7700. htmlBuilder: color_htmlBuilder,
  7701. mathmlBuilder: color_mathmlBuilder
  7702. });
  7703. ;// CONCATENATED MODULE: ./src/functions/cr.js
  7704. // Row breaks within tabular environments, and line breaks at top level
  7705. // \DeclareRobustCommand\\{...\@xnewline}
  7706. defineFunction({
  7707. type: "cr",
  7708. names: ["\\\\"],
  7709. props: {
  7710. numArgs: 0,
  7711. numOptionalArgs: 1,
  7712. argTypes: ["size"],
  7713. allowedInText: true
  7714. },
  7715. handler: function handler(_ref, args, optArgs) {
  7716. var parser = _ref.parser;
  7717. var size = optArgs[0];
  7718. var newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode");
  7719. return {
  7720. type: "cr",
  7721. mode: parser.mode,
  7722. newLine: newLine,
  7723. size: size && assertNodeType(size, "size").value
  7724. };
  7725. },
  7726. // The following builders are called only at the top level,
  7727. // not within tabular/array environments.
  7728. htmlBuilder: function htmlBuilder(group, options) {
  7729. var span = buildCommon.makeSpan(["mspace"], [], options);
  7730. if (group.newLine) {
  7731. span.classes.push("newline");
  7732. if (group.size) {
  7733. span.style.marginTop = makeEm(calculateSize(group.size, options));
  7734. }
  7735. }
  7736. return span;
  7737. },
  7738. mathmlBuilder: function mathmlBuilder(group, options) {
  7739. var node = new mathMLTree.MathNode("mspace");
  7740. if (group.newLine) {
  7741. node.setAttribute("linebreak", "newline");
  7742. if (group.size) {
  7743. node.setAttribute("height", makeEm(calculateSize(group.size, options)));
  7744. }
  7745. }
  7746. return node;
  7747. }
  7748. });
  7749. ;// CONCATENATED MODULE: ./src/functions/def.js
  7750. var globalMap = {
  7751. "\\global": "\\global",
  7752. "\\long": "\\\\globallong",
  7753. "\\\\globallong": "\\\\globallong",
  7754. "\\def": "\\gdef",
  7755. "\\gdef": "\\gdef",
  7756. "\\edef": "\\xdef",
  7757. "\\xdef": "\\xdef",
  7758. "\\let": "\\\\globallet",
  7759. "\\futurelet": "\\\\globalfuture"
  7760. };
  7761. var checkControlSequence = function checkControlSequence(tok) {
  7762. var name = tok.text;
  7763. if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) {
  7764. throw new src_ParseError("Expected a control sequence", tok);
  7765. }
  7766. return name;
  7767. };
  7768. var getRHS = function getRHS(parser) {
  7769. var tok = parser.gullet.popToken();
  7770. if (tok.text === "=") {
  7771. // consume optional equals
  7772. tok = parser.gullet.popToken();
  7773. if (tok.text === " ") {
  7774. // consume one optional space
  7775. tok = parser.gullet.popToken();
  7776. }
  7777. }
  7778. return tok;
  7779. };
  7780. var letCommand = function letCommand(parser, name, tok, global) {
  7781. var macro = parser.gullet.macros.get(tok.text);
  7782. if (macro == null) {
  7783. // don't expand it later even if a macro with the same name is defined
  7784. // e.g., \let\foo=\frac \def\frac{\relax} \frac12
  7785. tok.noexpand = true;
  7786. macro = {
  7787. tokens: [tok],
  7788. numArgs: 0,
  7789. // reproduce the same behavior in expansion
  7790. unexpandable: !parser.gullet.isExpandable(tok.text)
  7791. };
  7792. }
  7793. parser.gullet.macros.set(name, macro, global);
  7794. }; // <assignment> -> <non-macro assignment>|<macro assignment>
  7795. // <non-macro assignment> -> <simple assignment>|\global<non-macro assignment>
  7796. // <macro assignment> -> <definition>|<prefix><macro assignment>
  7797. // <prefix> -> \global|\long|\outer
  7798. defineFunction({
  7799. type: "internal",
  7800. names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly
  7801. ],
  7802. props: {
  7803. numArgs: 0,
  7804. allowedInText: true
  7805. },
  7806. handler: function handler(_ref) {
  7807. var parser = _ref.parser,
  7808. funcName = _ref.funcName;
  7809. parser.consumeSpaces();
  7810. var token = parser.fetch();
  7811. if (globalMap[token.text]) {
  7812. // KaTeX doesn't have \par, so ignore \long
  7813. if (funcName === "\\global" || funcName === "\\\\globallong") {
  7814. token.text = globalMap[token.text];
  7815. }
  7816. return assertNodeType(parser.parseFunction(), "internal");
  7817. }
  7818. throw new src_ParseError("Invalid token after macro prefix", token);
  7819. }
  7820. }); // Basic support for macro definitions: \def, \gdef, \edef, \xdef
  7821. // <definition> -> <def><control sequence><definition text>
  7822. // <def> -> \def|\gdef|\edef|\xdef
  7823. // <definition text> -> <parameter text><left brace><balanced text><right brace>
  7824. defineFunction({
  7825. type: "internal",
  7826. names: ["\\def", "\\gdef", "\\edef", "\\xdef"],
  7827. props: {
  7828. numArgs: 0,
  7829. allowedInText: true,
  7830. primitive: true
  7831. },
  7832. handler: function handler(_ref2) {
  7833. var parser = _ref2.parser,
  7834. funcName = _ref2.funcName;
  7835. var tok = parser.gullet.popToken();
  7836. var name = tok.text;
  7837. if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) {
  7838. throw new src_ParseError("Expected a control sequence", tok);
  7839. }
  7840. var numArgs = 0;
  7841. var insert;
  7842. var delimiters = [[]]; // <parameter text> contains no braces
  7843. while (parser.gullet.future().text !== "{") {
  7844. tok = parser.gullet.popToken();
  7845. if (tok.text === "#") {
  7846. // If the very last character of the <parameter text> is #, so that
  7847. // this # is immediately followed by {, TeX will behave as if the {
  7848. // had been inserted at the right end of both the parameter text
  7849. // and the replacement text.
  7850. if (parser.gullet.future().text === "{") {
  7851. insert = parser.gullet.future();
  7852. delimiters[numArgs].push("{");
  7853. break;
  7854. } // A parameter, the first appearance of # must be followed by 1,
  7855. // the next by 2, and so on; up to nine #’s are allowed
  7856. tok = parser.gullet.popToken();
  7857. if (!/^[1-9]$/.test(tok.text)) {
  7858. throw new src_ParseError("Invalid argument number \"" + tok.text + "\"");
  7859. }
  7860. if (parseInt(tok.text) !== numArgs + 1) {
  7861. throw new src_ParseError("Argument number \"" + tok.text + "\" out of order");
  7862. }
  7863. numArgs++;
  7864. delimiters.push([]);
  7865. } else if (tok.text === "EOF") {
  7866. throw new src_ParseError("Expected a macro definition");
  7867. } else {
  7868. delimiters[numArgs].push(tok.text);
  7869. }
  7870. } // replacement text, enclosed in '{' and '}' and properly nested
  7871. var _parser$gullet$consum = parser.gullet.consumeArg(),
  7872. tokens = _parser$gullet$consum.tokens;
  7873. if (insert) {
  7874. tokens.unshift(insert);
  7875. }
  7876. if (funcName === "\\edef" || funcName === "\\xdef") {
  7877. tokens = parser.gullet.expandTokens(tokens);
  7878. tokens.reverse(); // to fit in with stack order
  7879. } // Final arg is the expansion of the macro
  7880. parser.gullet.macros.set(name, {
  7881. tokens: tokens,
  7882. numArgs: numArgs,
  7883. delimiters: delimiters
  7884. }, funcName === globalMap[funcName]);
  7885. return {
  7886. type: "internal",
  7887. mode: parser.mode
  7888. };
  7889. }
  7890. }); // <simple assignment> -> <let assignment>
  7891. // <let assignment> -> \futurelet<control sequence><token><token>
  7892. // | \let<control sequence><equals><one optional space><token>
  7893. // <equals> -> <optional spaces>|<optional spaces>=
  7894. defineFunction({
  7895. type: "internal",
  7896. names: ["\\let", "\\\\globallet" // can’t be entered directly
  7897. ],
  7898. props: {
  7899. numArgs: 0,
  7900. allowedInText: true,
  7901. primitive: true
  7902. },
  7903. handler: function handler(_ref3) {
  7904. var parser = _ref3.parser,
  7905. funcName = _ref3.funcName;
  7906. var name = checkControlSequence(parser.gullet.popToken());
  7907. parser.gullet.consumeSpaces();
  7908. var tok = getRHS(parser);
  7909. letCommand(parser, name, tok, funcName === "\\\\globallet");
  7910. return {
  7911. type: "internal",
  7912. mode: parser.mode
  7913. };
  7914. }
  7915. }); // ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf
  7916. defineFunction({
  7917. type: "internal",
  7918. names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly
  7919. ],
  7920. props: {
  7921. numArgs: 0,
  7922. allowedInText: true,
  7923. primitive: true
  7924. },
  7925. handler: function handler(_ref4) {
  7926. var parser = _ref4.parser,
  7927. funcName = _ref4.funcName;
  7928. var name = checkControlSequence(parser.gullet.popToken());
  7929. var middle = parser.gullet.popToken();
  7930. var tok = parser.gullet.popToken();
  7931. letCommand(parser, name, tok, funcName === "\\\\globalfuture");
  7932. parser.gullet.pushToken(tok);
  7933. parser.gullet.pushToken(middle);
  7934. return {
  7935. type: "internal",
  7936. mode: parser.mode
  7937. };
  7938. }
  7939. });
  7940. ;// CONCATENATED MODULE: ./src/delimiter.js
  7941. /**
  7942. * This file deals with creating delimiters of various sizes. The TeXbook
  7943. * discusses these routines on page 441-442, in the "Another subroutine sets box
  7944. * x to a specified variable delimiter" paragraph.
  7945. *
  7946. * There are three main routines here. `makeSmallDelim` makes a delimiter in the
  7947. * normal font, but in either text, script, or scriptscript style.
  7948. * `makeLargeDelim` makes a delimiter in textstyle, but in one of the Size1,
  7949. * Size2, Size3, or Size4 fonts. `makeStackedDelim` makes a delimiter out of
  7950. * smaller pieces that are stacked on top of one another.
  7951. *
  7952. * The functions take a parameter `center`, which determines if the delimiter
  7953. * should be centered around the axis.
  7954. *
  7955. * Then, there are three exposed functions. `sizedDelim` makes a delimiter in
  7956. * one of the given sizes. This is used for things like `\bigl`.
  7957. * `customSizedDelim` makes a delimiter with a given total height+depth. It is
  7958. * called in places like `\sqrt`. `leftRightDelim` makes an appropriate
  7959. * delimiter which surrounds an expression of a given height an depth. It is
  7960. * used in `\left` and `\right`.
  7961. */
  7962. /**
  7963. * Get the metrics for a given symbol and font, after transformation (i.e.
  7964. * after following replacement from symbols.js)
  7965. */
  7966. var getMetrics = function getMetrics(symbol, font, mode) {
  7967. var replace = src_symbols.math[symbol] && src_symbols.math[symbol].replace;
  7968. var metrics = getCharacterMetrics(replace || symbol, font, mode);
  7969. if (!metrics) {
  7970. throw new Error("Unsupported symbol " + symbol + " and font size " + font + ".");
  7971. }
  7972. return metrics;
  7973. };
  7974. /**
  7975. * Puts a delimiter span in a given style, and adds appropriate height, depth,
  7976. * and maxFontSizes.
  7977. */
  7978. var styleWrap = function styleWrap(delim, toStyle, options, classes) {
  7979. var newOptions = options.havingBaseStyle(toStyle);
  7980. var span = buildCommon.makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options);
  7981. var delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier;
  7982. span.height *= delimSizeMultiplier;
  7983. span.depth *= delimSizeMultiplier;
  7984. span.maxFontSize = newOptions.sizeMultiplier;
  7985. return span;
  7986. };
  7987. var centerSpan = function centerSpan(span, options, style) {
  7988. var newOptions = options.havingBaseStyle(style);
  7989. var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight;
  7990. span.classes.push("delimcenter");
  7991. span.style.top = makeEm(shift);
  7992. span.height -= shift;
  7993. span.depth += shift;
  7994. };
  7995. /**
  7996. * Makes a small delimiter. This is a delimiter that comes in the Main-Regular
  7997. * font, but is restyled to either be in textstyle, scriptstyle, or
  7998. * scriptscriptstyle.
  7999. */
  8000. var makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) {
  8001. var text = buildCommon.makeSymbol(delim, "Main-Regular", mode, options);
  8002. var span = styleWrap(text, style, options, classes);
  8003. if (center) {
  8004. centerSpan(span, options, style);
  8005. }
  8006. return span;
  8007. };
  8008. /**
  8009. * Builds a symbol in the given font size (note size is an integer)
  8010. */
  8011. var mathrmSize = function mathrmSize(value, size, mode, options) {
  8012. return buildCommon.makeSymbol(value, "Size" + size + "-Regular", mode, options);
  8013. };
  8014. /**
  8015. * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2,
  8016. * Size3, or Size4 fonts. It is always rendered in textstyle.
  8017. */
  8018. var makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) {
  8019. var inner = mathrmSize(delim, size, mode, options);
  8020. var span = styleWrap(buildCommon.makeSpan(["delimsizing", "size" + size], [inner], options), src_Style.TEXT, options, classes);
  8021. if (center) {
  8022. centerSpan(span, options, src_Style.TEXT);
  8023. }
  8024. return span;
  8025. };
  8026. /**
  8027. * Make a span from a font glyph with the given offset and in the given font.
  8028. * This is used in makeStackedDelim to make the stacking pieces for the delimiter.
  8029. */
  8030. var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) {
  8031. var sizeClass; // Apply the correct CSS class to choose the right font.
  8032. if (font === "Size1-Regular") {
  8033. sizeClass = "delim-size1";
  8034. } else
  8035. /* if (font === "Size4-Regular") */
  8036. {
  8037. sizeClass = "delim-size4";
  8038. }
  8039. var corner = buildCommon.makeSpan(["delimsizinginner", sizeClass], [buildCommon.makeSpan([], [buildCommon.makeSymbol(symbol, font, mode)])]); // Since this will be passed into `makeVList` in the end, wrap the element
  8040. // in the appropriate tag that VList uses.
  8041. return {
  8042. type: "elem",
  8043. elem: corner
  8044. };
  8045. };
  8046. var makeInner = function makeInner(ch, height, options) {
  8047. // Create a span with inline SVG for the inner part of a tall stacked delimiter.
  8048. var width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4] : fontMetricsData["Size1-Regular"][ch.charCodeAt(0)][4];
  8049. var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height)));
  8050. var svgNode = new SvgNode([path], {
  8051. "width": makeEm(width),
  8052. "height": makeEm(height),
  8053. // Override CSS rule `.katex svg { width: 100% }`
  8054. "style": "width:" + makeEm(width),
  8055. "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height),
  8056. "preserveAspectRatio": "xMinYMin"
  8057. });
  8058. var span = buildCommon.makeSvgSpan([], [svgNode], options);
  8059. span.height = height;
  8060. span.style.height = makeEm(height);
  8061. span.style.width = makeEm(width);
  8062. return {
  8063. type: "elem",
  8064. elem: span
  8065. };
  8066. }; // Helpers for makeStackedDelim
  8067. var lapInEms = 0.008;
  8068. var lap = {
  8069. type: "kern",
  8070. size: -1 * lapInEms
  8071. };
  8072. var verts = ["|", "\\lvert", "\\rvert", "\\vert"];
  8073. var doubleVerts = ["\\|", "\\lVert", "\\rVert", "\\Vert"];
  8074. /**
  8075. * Make a stacked delimiter out of a given delimiter, with the total height at
  8076. * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook.
  8077. */
  8078. var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) {
  8079. // There are four parts, the top, an optional middle, a repeated part, and a
  8080. // bottom.
  8081. var top;
  8082. var middle;
  8083. var repeat;
  8084. var bottom;
  8085. var svgLabel = "";
  8086. var viewBoxWidth = 0;
  8087. top = repeat = bottom = delim;
  8088. middle = null; // Also keep track of what font the delimiters are in
  8089. var font = "Size1-Regular"; // We set the parts and font based on the symbol. Note that we use
  8090. // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the
  8091. // repeats of the arrows
  8092. if (delim === "\\uparrow") {
  8093. repeat = bottom = "\u23D0";
  8094. } else if (delim === "\\Uparrow") {
  8095. repeat = bottom = "\u2016";
  8096. } else if (delim === "\\downarrow") {
  8097. top = repeat = "\u23D0";
  8098. } else if (delim === "\\Downarrow") {
  8099. top = repeat = "\u2016";
  8100. } else if (delim === "\\updownarrow") {
  8101. top = "\\uparrow";
  8102. repeat = "\u23D0";
  8103. bottom = "\\downarrow";
  8104. } else if (delim === "\\Updownarrow") {
  8105. top = "\\Uparrow";
  8106. repeat = "\u2016";
  8107. bottom = "\\Downarrow";
  8108. } else if (utils.contains(verts, delim)) {
  8109. repeat = "\u2223";
  8110. svgLabel = "vert";
  8111. viewBoxWidth = 333;
  8112. } else if (utils.contains(doubleVerts, delim)) {
  8113. repeat = "\u2225";
  8114. svgLabel = "doublevert";
  8115. viewBoxWidth = 556;
  8116. } else if (delim === "[" || delim === "\\lbrack") {
  8117. top = "\u23A1";
  8118. repeat = "\u23A2";
  8119. bottom = "\u23A3";
  8120. font = "Size4-Regular";
  8121. svgLabel = "lbrack";
  8122. viewBoxWidth = 667;
  8123. } else if (delim === "]" || delim === "\\rbrack") {
  8124. top = "\u23A4";
  8125. repeat = "\u23A5";
  8126. bottom = "\u23A6";
  8127. font = "Size4-Regular";
  8128. svgLabel = "rbrack";
  8129. viewBoxWidth = 667;
  8130. } else if (delim === "\\lfloor" || delim === "\u230A") {
  8131. repeat = top = "\u23A2";
  8132. bottom = "\u23A3";
  8133. font = "Size4-Regular";
  8134. svgLabel = "lfloor";
  8135. viewBoxWidth = 667;
  8136. } else if (delim === "\\lceil" || delim === "\u2308") {
  8137. top = "\u23A1";
  8138. repeat = bottom = "\u23A2";
  8139. font = "Size4-Regular";
  8140. svgLabel = "lceil";
  8141. viewBoxWidth = 667;
  8142. } else if (delim === "\\rfloor" || delim === "\u230B") {
  8143. repeat = top = "\u23A5";
  8144. bottom = "\u23A6";
  8145. font = "Size4-Regular";
  8146. svgLabel = "rfloor";
  8147. viewBoxWidth = 667;
  8148. } else if (delim === "\\rceil" || delim === "\u2309") {
  8149. top = "\u23A4";
  8150. repeat = bottom = "\u23A5";
  8151. font = "Size4-Regular";
  8152. svgLabel = "rceil";
  8153. viewBoxWidth = 667;
  8154. } else if (delim === "(" || delim === "\\lparen") {
  8155. top = "\u239B";
  8156. repeat = "\u239C";
  8157. bottom = "\u239D";
  8158. font = "Size4-Regular";
  8159. svgLabel = "lparen";
  8160. viewBoxWidth = 875;
  8161. } else if (delim === ")" || delim === "\\rparen") {
  8162. top = "\u239E";
  8163. repeat = "\u239F";
  8164. bottom = "\u23A0";
  8165. font = "Size4-Regular";
  8166. svgLabel = "rparen";
  8167. viewBoxWidth = 875;
  8168. } else if (delim === "\\{" || delim === "\\lbrace") {
  8169. top = "\u23A7";
  8170. middle = "\u23A8";
  8171. bottom = "\u23A9";
  8172. repeat = "\u23AA";
  8173. font = "Size4-Regular";
  8174. } else if (delim === "\\}" || delim === "\\rbrace") {
  8175. top = "\u23AB";
  8176. middle = "\u23AC";
  8177. bottom = "\u23AD";
  8178. repeat = "\u23AA";
  8179. font = "Size4-Regular";
  8180. } else if (delim === "\\lgroup" || delim === "\u27EE") {
  8181. top = "\u23A7";
  8182. bottom = "\u23A9";
  8183. repeat = "\u23AA";
  8184. font = "Size4-Regular";
  8185. } else if (delim === "\\rgroup" || delim === "\u27EF") {
  8186. top = "\u23AB";
  8187. bottom = "\u23AD";
  8188. repeat = "\u23AA";
  8189. font = "Size4-Regular";
  8190. } else if (delim === "\\lmoustache" || delim === "\u23B0") {
  8191. top = "\u23A7";
  8192. bottom = "\u23AD";
  8193. repeat = "\u23AA";
  8194. font = "Size4-Regular";
  8195. } else if (delim === "\\rmoustache" || delim === "\u23B1") {
  8196. top = "\u23AB";
  8197. bottom = "\u23A9";
  8198. repeat = "\u23AA";
  8199. font = "Size4-Regular";
  8200. } // Get the metrics of the four sections
  8201. var topMetrics = getMetrics(top, font, mode);
  8202. var topHeightTotal = topMetrics.height + topMetrics.depth;
  8203. var repeatMetrics = getMetrics(repeat, font, mode);
  8204. var repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth;
  8205. var bottomMetrics = getMetrics(bottom, font, mode);
  8206. var bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth;
  8207. var middleHeightTotal = 0;
  8208. var middleFactor = 1;
  8209. if (middle !== null) {
  8210. var middleMetrics = getMetrics(middle, font, mode);
  8211. middleHeightTotal = middleMetrics.height + middleMetrics.depth;
  8212. middleFactor = 2; // repeat symmetrically above and below middle
  8213. } // Calcuate the minimal height that the delimiter can have.
  8214. // It is at least the size of the top, bottom, and optional middle combined.
  8215. var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; // Compute the number of copies of the repeat symbol we will need
  8216. var repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); // Compute the total height of the delimiter including all the symbols
  8217. var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; // The center of the delimiter is placed at the center of the axis. Note
  8218. // that in this context, "center" means that the delimiter should be
  8219. // centered around the axis in the current style, while normally it is
  8220. // centered around the axis in textstyle.
  8221. var axisHeight = options.fontMetrics().axisHeight;
  8222. if (center) {
  8223. axisHeight *= options.sizeMultiplier;
  8224. } // Calculate the depth
  8225. var depth = realHeightTotal / 2 - axisHeight; // Now, we start building the pieces that will go into the vlist
  8226. // Keep a list of the pieces of the stacked delimiter
  8227. var stack = [];
  8228. if (svgLabel.length > 0) {
  8229. // Instead of stacking glyphs, create a single SVG.
  8230. // This evades browser problems with imprecise positioning of spans.
  8231. var midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal;
  8232. var viewBoxHeight = Math.round(realHeightTotal * 1000);
  8233. var pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000));
  8234. var path = new PathNode(svgLabel, pathStr);
  8235. var width = (viewBoxWidth / 1000).toFixed(3) + "em";
  8236. var height = (viewBoxHeight / 1000).toFixed(3) + "em";
  8237. var svg = new SvgNode([path], {
  8238. "width": width,
  8239. "height": height,
  8240. "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight
  8241. });
  8242. var wrapper = buildCommon.makeSvgSpan([], [svg], options);
  8243. wrapper.height = viewBoxHeight / 1000;
  8244. wrapper.style.width = width;
  8245. wrapper.style.height = height;
  8246. stack.push({
  8247. type: "elem",
  8248. elem: wrapper
  8249. });
  8250. } else {
  8251. // Stack glyphs
  8252. // Start by adding the bottom symbol
  8253. stack.push(makeGlyphSpan(bottom, font, mode));
  8254. stack.push(lap); // overlap
  8255. if (middle === null) {
  8256. // The middle section will be an SVG. Make it an extra 0.016em tall.
  8257. // We'll overlap by 0.008em at top and bottom.
  8258. var innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms;
  8259. stack.push(makeInner(repeat, innerHeight, options));
  8260. } else {
  8261. // When there is a middle bit, we need the middle part and two repeated
  8262. // sections
  8263. var _innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms;
  8264. stack.push(makeInner(repeat, _innerHeight, options)); // Now insert the middle of the brace.
  8265. stack.push(lap);
  8266. stack.push(makeGlyphSpan(middle, font, mode));
  8267. stack.push(lap);
  8268. stack.push(makeInner(repeat, _innerHeight, options));
  8269. } // Add the top symbol
  8270. stack.push(lap);
  8271. stack.push(makeGlyphSpan(top, font, mode));
  8272. } // Finally, build the vlist
  8273. var newOptions = options.havingBaseStyle(src_Style.TEXT);
  8274. var inner = buildCommon.makeVList({
  8275. positionType: "bottom",
  8276. positionData: depth,
  8277. children: stack
  8278. }, newOptions);
  8279. return styleWrap(buildCommon.makeSpan(["delimsizing", "mult"], [inner], newOptions), src_Style.TEXT, options, classes);
  8280. }; // All surds have 0.08em padding above the viniculum inside the SVG.
  8281. // That keeps browser span height rounding error from pinching the line.
  8282. var vbPad = 80; // padding above the surd, measured inside the viewBox.
  8283. var emPad = 0.08; // padding, in ems, measured in the document.
  8284. var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum, options) {
  8285. var path = sqrtPath(sqrtName, extraViniculum, viewBoxHeight);
  8286. var pathNode = new PathNode(sqrtName, path);
  8287. var svg = new SvgNode([pathNode], {
  8288. // Note: 1000:1 ratio of viewBox to document em width.
  8289. "width": "400em",
  8290. "height": makeEm(height),
  8291. "viewBox": "0 0 400000 " + viewBoxHeight,
  8292. "preserveAspectRatio": "xMinYMin slice"
  8293. });
  8294. return buildCommon.makeSvgSpan(["hide-tail"], [svg], options);
  8295. };
  8296. /**
  8297. * Make a sqrt image of the given height,
  8298. */
  8299. var makeSqrtImage = function makeSqrtImage(height, options) {
  8300. // Define a newOptions that removes the effect of size changes such as \Huge.
  8301. // We don't pick different a height surd for \Huge. For it, we scale up.
  8302. var newOptions = options.havingBaseSizing(); // Pick the desired surd glyph from a sequence of surds.
  8303. var delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions);
  8304. var sizeMultiplier = newOptions.sizeMultiplier; // default
  8305. // The standard sqrt SVGs each have a 0.04em thick viniculum.
  8306. // If Settings.minRuleThickness is larger than that, we add extraViniculum.
  8307. var extraViniculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); // Create a span containing an SVG image of a sqrt symbol.
  8308. var span;
  8309. var spanHeight = 0;
  8310. var texHeight = 0;
  8311. var viewBoxHeight = 0;
  8312. var advanceWidth; // We create viewBoxes with 80 units of "padding" above each surd.
  8313. // Then browser rounding error on the parent span height will not
  8314. // encroach on the ink of the viniculum. But that padding is not
  8315. // included in the TeX-like `height` used for calculation of
  8316. // vertical alignment. So texHeight = span.height < span.style.height.
  8317. if (delim.type === "small") {
  8318. // Get an SVG that is derived from glyph U+221A in font KaTeX-Main.
  8319. // 1000 unit normal glyph height.
  8320. viewBoxHeight = 1000 + 1000 * extraViniculum + vbPad;
  8321. if (height < 1.0) {
  8322. sizeMultiplier = 1.0; // mimic a \textfont radical
  8323. } else if (height < 1.4) {
  8324. sizeMultiplier = 0.7; // mimic a \scriptfont radical
  8325. }
  8326. spanHeight = (1.0 + extraViniculum + emPad) / sizeMultiplier;
  8327. texHeight = (1.00 + extraViniculum) / sizeMultiplier;
  8328. span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraViniculum, options);
  8329. span.style.minWidth = "0.853em";
  8330. advanceWidth = 0.833 / sizeMultiplier; // from the font.
  8331. } else if (delim.type === "large") {
  8332. // These SVGs come from fonts: KaTeX_Size1, _Size2, etc.
  8333. viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size];
  8334. texHeight = (sizeToMaxHeight[delim.size] + extraViniculum) / sizeMultiplier;
  8335. spanHeight = (sizeToMaxHeight[delim.size] + extraViniculum + emPad) / sizeMultiplier;
  8336. span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraViniculum, options);
  8337. span.style.minWidth = "1.02em";
  8338. advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font.
  8339. } else {
  8340. // Tall sqrt. In TeX, this would be stacked using multiple glyphs.
  8341. // We'll use a single SVG to accomplish the same thing.
  8342. spanHeight = height + extraViniculum + emPad;
  8343. texHeight = height + extraViniculum;
  8344. viewBoxHeight = Math.floor(1000 * height + extraViniculum) + vbPad;
  8345. span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraViniculum, options);
  8346. span.style.minWidth = "0.742em";
  8347. advanceWidth = 1.056;
  8348. }
  8349. span.height = texHeight;
  8350. span.style.height = makeEm(spanHeight);
  8351. return {
  8352. span: span,
  8353. advanceWidth: advanceWidth,
  8354. // Calculate the actual line width.
  8355. // This actually should depend on the chosen font -- e.g. \boldmath
  8356. // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and
  8357. // have thicker rules.
  8358. ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraViniculum) * sizeMultiplier
  8359. };
  8360. }; // There are three kinds of delimiters, delimiters that stack when they become
  8361. // too large
  8362. var stackLargeDelimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230A", "\u230B", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]; // delimiters that always stack
  8363. var stackAlwaysDelimiters = ["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27EE", "\u27EF", "\\lmoustache", "\\rmoustache", "\u23B0", "\u23B1"]; // and delimiters that never stack
  8364. var stackNeverDelimiters = ["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]; // Metrics of the different sizes. Found by looking at TeX's output of
  8365. // $\bigl| // \Bigl| \biggl| \Biggl| \showlists$
  8366. // Used to create stacked delimiters of appropriate sizes in makeSizedDelim.
  8367. var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0];
  8368. /**
  8369. * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4.
  8370. */
  8371. var makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) {
  8372. // < and > turn into \langle and \rangle in delimiters
  8373. if (delim === "<" || delim === "\\lt" || delim === "\u27E8") {
  8374. delim = "\\langle";
  8375. } else if (delim === ">" || delim === "\\gt" || delim === "\u27E9") {
  8376. delim = "\\rangle";
  8377. } // Sized delimiters are never centered.
  8378. if (utils.contains(stackLargeDelimiters, delim) || utils.contains(stackNeverDelimiters, delim)) {
  8379. return makeLargeDelim(delim, size, false, options, mode, classes);
  8380. } else if (utils.contains(stackAlwaysDelimiters, delim)) {
  8381. return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes);
  8382. } else {
  8383. throw new src_ParseError("Illegal delimiter: '" + delim + "'");
  8384. }
  8385. };
  8386. /**
  8387. * There are three different sequences of delimiter sizes that the delimiters
  8388. * follow depending on the kind of delimiter. This is used when creating custom
  8389. * sized delimiters to decide whether to create a small, large, or stacked
  8390. * delimiter.
  8391. *
  8392. * In real TeX, these sequences aren't explicitly defined, but are instead
  8393. * defined inside the font metrics. Since there are only three sequences that
  8394. * are possible for the delimiters that TeX defines, it is easier to just encode
  8395. * them explicitly here.
  8396. */
  8397. // Delimiters that never stack try small delimiters and large delimiters only
  8398. var stackNeverDelimiterSequence = [{
  8399. type: "small",
  8400. style: src_Style.SCRIPTSCRIPT
  8401. }, {
  8402. type: "small",
  8403. style: src_Style.SCRIPT
  8404. }, {
  8405. type: "small",
  8406. style: src_Style.TEXT
  8407. }, {
  8408. type: "large",
  8409. size: 1
  8410. }, {
  8411. type: "large",
  8412. size: 2
  8413. }, {
  8414. type: "large",
  8415. size: 3
  8416. }, {
  8417. type: "large",
  8418. size: 4
  8419. }]; // Delimiters that always stack try the small delimiters first, then stack
  8420. var stackAlwaysDelimiterSequence = [{
  8421. type: "small",
  8422. style: src_Style.SCRIPTSCRIPT
  8423. }, {
  8424. type: "small",
  8425. style: src_Style.SCRIPT
  8426. }, {
  8427. type: "small",
  8428. style: src_Style.TEXT
  8429. }, {
  8430. type: "stack"
  8431. }]; // Delimiters that stack when large try the small and then large delimiters, and
  8432. // stack afterwards
  8433. var stackLargeDelimiterSequence = [{
  8434. type: "small",
  8435. style: src_Style.SCRIPTSCRIPT
  8436. }, {
  8437. type: "small",
  8438. style: src_Style.SCRIPT
  8439. }, {
  8440. type: "small",
  8441. style: src_Style.TEXT
  8442. }, {
  8443. type: "large",
  8444. size: 1
  8445. }, {
  8446. type: "large",
  8447. size: 2
  8448. }, {
  8449. type: "large",
  8450. size: 3
  8451. }, {
  8452. type: "large",
  8453. size: 4
  8454. }, {
  8455. type: "stack"
  8456. }];
  8457. /**
  8458. * Get the font used in a delimiter based on what kind of delimiter it is.
  8459. * TODO(#963) Use more specific font family return type once that is introduced.
  8460. */
  8461. var delimTypeToFont = function delimTypeToFont(type) {
  8462. if (type.type === "small") {
  8463. return "Main-Regular";
  8464. } else if (type.type === "large") {
  8465. return "Size" + type.size + "-Regular";
  8466. } else if (type.type === "stack") {
  8467. return "Size4-Regular";
  8468. } else {
  8469. throw new Error("Add support for delim type '" + type.type + "' here.");
  8470. }
  8471. };
  8472. /**
  8473. * Traverse a sequence of types of delimiters to decide what kind of delimiter
  8474. * should be used to create a delimiter of the given height+depth.
  8475. */
  8476. var traverseSequence = function traverseSequence(delim, height, sequence, options) {
  8477. // Here, we choose the index we should start at in the sequences. In smaller
  8478. // sizes (which correspond to larger numbers in style.size) we start earlier
  8479. // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts
  8480. // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2
  8481. var start = Math.min(2, 3 - options.style.size);
  8482. for (var i = start; i < sequence.length; i++) {
  8483. if (sequence[i].type === "stack") {
  8484. // This is always the last delimiter, so we just break the loop now.
  8485. break;
  8486. }
  8487. var metrics = getMetrics(delim, delimTypeToFont(sequence[i]), "math");
  8488. var heightDepth = metrics.height + metrics.depth; // Small delimiters are scaled down versions of the same font, so we
  8489. // account for the style change size.
  8490. if (sequence[i].type === "small") {
  8491. var newOptions = options.havingBaseStyle(sequence[i].style);
  8492. heightDepth *= newOptions.sizeMultiplier;
  8493. } // Check if the delimiter at this size works for the given height.
  8494. if (heightDepth > height) {
  8495. return sequence[i];
  8496. }
  8497. } // If we reached the end of the sequence, return the last sequence element.
  8498. return sequence[sequence.length - 1];
  8499. };
  8500. /**
  8501. * Make a delimiter of a given height+depth, with optional centering. Here, we
  8502. * traverse the sequences, and create a delimiter that the sequence tells us to.
  8503. */
  8504. var makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) {
  8505. if (delim === "<" || delim === "\\lt" || delim === "\u27E8") {
  8506. delim = "\\langle";
  8507. } else if (delim === ">" || delim === "\\gt" || delim === "\u27E9") {
  8508. delim = "\\rangle";
  8509. } // Decide what sequence to use
  8510. var sequence;
  8511. if (utils.contains(stackNeverDelimiters, delim)) {
  8512. sequence = stackNeverDelimiterSequence;
  8513. } else if (utils.contains(stackLargeDelimiters, delim)) {
  8514. sequence = stackLargeDelimiterSequence;
  8515. } else {
  8516. sequence = stackAlwaysDelimiterSequence;
  8517. } // Look through the sequence
  8518. var delimType = traverseSequence(delim, height, sequence, options); // Get the delimiter from font glyphs.
  8519. // Depending on the sequence element we decided on, call the
  8520. // appropriate function.
  8521. if (delimType.type === "small") {
  8522. return makeSmallDelim(delim, delimType.style, center, options, mode, classes);
  8523. } else if (delimType.type === "large") {
  8524. return makeLargeDelim(delim, delimType.size, center, options, mode, classes);
  8525. } else
  8526. /* if (delimType.type === "stack") */
  8527. {
  8528. return makeStackedDelim(delim, height, center, options, mode, classes);
  8529. }
  8530. };
  8531. /**
  8532. * Make a delimiter for use with `\left` and `\right`, given a height and depth
  8533. * of an expression that the delimiters surround.
  8534. */
  8535. var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) {
  8536. // We always center \left/\right delimiters, so the axis is always shifted
  8537. var axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; // Taken from TeX source, tex.web, function make_left_right
  8538. var delimiterFactor = 901;
  8539. var delimiterExtend = 5.0 / options.fontMetrics().ptPerEm;
  8540. var maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight);
  8541. var totalHeight = Math.max( // In real TeX, calculations are done using integral values which are
  8542. // 65536 per pt, or 655360 per em. So, the division here truncates in
  8543. // TeX but doesn't here, producing different results. If we wanted to
  8544. // exactly match TeX's calculation, we could do
  8545. // Math.floor(655360 * maxDistFromAxis / 500) *
  8546. // delimiterFactor / 655360
  8547. // (To see the difference, compare
  8548. // x^{x^{\left(\rule{0.1em}{0.68em}\right)}}
  8549. // in TeX and KaTeX)
  8550. maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend); // Finally, we defer to `makeCustomSizedDelim` with our calculated total
  8551. // height
  8552. return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes);
  8553. };
  8554. /* harmony default export */ var delimiter = ({
  8555. sqrtImage: makeSqrtImage,
  8556. sizedDelim: makeSizedDelim,
  8557. sizeToMaxHeight: sizeToMaxHeight,
  8558. customSizedDelim: makeCustomSizedDelim,
  8559. leftRightDelim: makeLeftRightDelim
  8560. });
  8561. ;// CONCATENATED MODULE: ./src/functions/delimsizing.js
  8562. // Extra data needed for the delimiter handler down below
  8563. var delimiterSizes = {
  8564. "\\bigl": {
  8565. mclass: "mopen",
  8566. size: 1
  8567. },
  8568. "\\Bigl": {
  8569. mclass: "mopen",
  8570. size: 2
  8571. },
  8572. "\\biggl": {
  8573. mclass: "mopen",
  8574. size: 3
  8575. },
  8576. "\\Biggl": {
  8577. mclass: "mopen",
  8578. size: 4
  8579. },
  8580. "\\bigr": {
  8581. mclass: "mclose",
  8582. size: 1
  8583. },
  8584. "\\Bigr": {
  8585. mclass: "mclose",
  8586. size: 2
  8587. },
  8588. "\\biggr": {
  8589. mclass: "mclose",
  8590. size: 3
  8591. },
  8592. "\\Biggr": {
  8593. mclass: "mclose",
  8594. size: 4
  8595. },
  8596. "\\bigm": {
  8597. mclass: "mrel",
  8598. size: 1
  8599. },
  8600. "\\Bigm": {
  8601. mclass: "mrel",
  8602. size: 2
  8603. },
  8604. "\\biggm": {
  8605. mclass: "mrel",
  8606. size: 3
  8607. },
  8608. "\\Biggm": {
  8609. mclass: "mrel",
  8610. size: 4
  8611. },
  8612. "\\big": {
  8613. mclass: "mord",
  8614. size: 1
  8615. },
  8616. "\\Big": {
  8617. mclass: "mord",
  8618. size: 2
  8619. },
  8620. "\\bigg": {
  8621. mclass: "mord",
  8622. size: 3
  8623. },
  8624. "\\Bigg": {
  8625. mclass: "mord",
  8626. size: 4
  8627. }
  8628. };
  8629. var delimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230A", "\u230B", "\\lceil", "\\rceil", "\u2308", "\u2309", "<", ">", "\\langle", "\u27E8", "\\rangle", "\u27E9", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27EE", "\u27EF", "\\lmoustache", "\\rmoustache", "\u23B0", "\u23B1", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."];
  8630. // Delimiter functions
  8631. function checkDelimiter(delim, context) {
  8632. var symDelim = checkSymbolNodeType(delim);
  8633. if (symDelim && utils.contains(delimiters, symDelim.text)) {
  8634. return symDelim;
  8635. } else if (symDelim) {
  8636. throw new src_ParseError("Invalid delimiter '" + symDelim.text + "' after '" + context.funcName + "'", delim);
  8637. } else {
  8638. throw new src_ParseError("Invalid delimiter type '" + delim.type + "'", delim);
  8639. }
  8640. }
  8641. defineFunction({
  8642. type: "delimsizing",
  8643. names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"],
  8644. props: {
  8645. numArgs: 1,
  8646. argTypes: ["primitive"]
  8647. },
  8648. handler: function handler(context, args) {
  8649. var delim = checkDelimiter(args[0], context);
  8650. return {
  8651. type: "delimsizing",
  8652. mode: context.parser.mode,
  8653. size: delimiterSizes[context.funcName].size,
  8654. mclass: delimiterSizes[context.funcName].mclass,
  8655. delim: delim.text
  8656. };
  8657. },
  8658. htmlBuilder: function htmlBuilder(group, options) {
  8659. if (group.delim === ".") {
  8660. // Empty delimiters still count as elements, even though they don't
  8661. // show anything.
  8662. return buildCommon.makeSpan([group.mclass]);
  8663. } // Use delimiter.sizedDelim to generate the delimiter.
  8664. return delimiter.sizedDelim(group.delim, group.size, options, group.mode, [group.mclass]);
  8665. },
  8666. mathmlBuilder: function mathmlBuilder(group) {
  8667. var children = [];
  8668. if (group.delim !== ".") {
  8669. children.push(makeText(group.delim, group.mode));
  8670. }
  8671. var node = new mathMLTree.MathNode("mo", children);
  8672. if (group.mclass === "mopen" || group.mclass === "mclose") {
  8673. // Only some of the delimsizing functions act as fences, and they
  8674. // return "mopen" or "mclose" mclass.
  8675. node.setAttribute("fence", "true");
  8676. } else {
  8677. // Explicitly disable fencing if it's not a fence, to override the
  8678. // defaults.
  8679. node.setAttribute("fence", "false");
  8680. }
  8681. node.setAttribute("stretchy", "true");
  8682. var size = makeEm(delimiter.sizeToMaxHeight[group.size]);
  8683. node.setAttribute("minsize", size);
  8684. node.setAttribute("maxsize", size);
  8685. return node;
  8686. }
  8687. });
  8688. function assertParsed(group) {
  8689. if (!group.body) {
  8690. throw new Error("Bug: The leftright ParseNode wasn't fully parsed.");
  8691. }
  8692. }
  8693. defineFunction({
  8694. type: "leftright-right",
  8695. names: ["\\right"],
  8696. props: {
  8697. numArgs: 1,
  8698. primitive: true
  8699. },
  8700. handler: function handler(context, args) {
  8701. // \left case below triggers parsing of \right in
  8702. // `const right = parser.parseFunction();`
  8703. // uses this return value.
  8704. var color = context.parser.gullet.macros.get("\\current@color");
  8705. if (color && typeof color !== "string") {
  8706. throw new src_ParseError("\\current@color set to non-string in \\right");
  8707. }
  8708. return {
  8709. type: "leftright-right",
  8710. mode: context.parser.mode,
  8711. delim: checkDelimiter(args[0], context).text,
  8712. color: color // undefined if not set via \color
  8713. };
  8714. }
  8715. });
  8716. defineFunction({
  8717. type: "leftright",
  8718. names: ["\\left"],
  8719. props: {
  8720. numArgs: 1,
  8721. primitive: true
  8722. },
  8723. handler: function handler(context, args) {
  8724. var delim = checkDelimiter(args[0], context);
  8725. var parser = context.parser; // Parse out the implicit body
  8726. ++parser.leftrightDepth; // parseExpression stops before '\\right'
  8727. var body = parser.parseExpression(false);
  8728. --parser.leftrightDepth; // Check the next token
  8729. parser.expect("\\right", false);
  8730. var right = assertNodeType(parser.parseFunction(), "leftright-right");
  8731. return {
  8732. type: "leftright",
  8733. mode: parser.mode,
  8734. body: body,
  8735. left: delim.text,
  8736. right: right.delim,
  8737. rightColor: right.color
  8738. };
  8739. },
  8740. htmlBuilder: function htmlBuilder(group, options) {
  8741. assertParsed(group); // Build the inner expression
  8742. var inner = buildExpression(group.body, options, true, ["mopen", "mclose"]);
  8743. var innerHeight = 0;
  8744. var innerDepth = 0;
  8745. var hadMiddle = false; // Calculate its height and depth
  8746. for (var i = 0; i < inner.length; i++) {
  8747. // Property `isMiddle` not defined on `span`. See comment in
  8748. // "middle"'s htmlBuilder.
  8749. // $FlowFixMe
  8750. if (inner[i].isMiddle) {
  8751. hadMiddle = true;
  8752. } else {
  8753. innerHeight = Math.max(inner[i].height, innerHeight);
  8754. innerDepth = Math.max(inner[i].depth, innerDepth);
  8755. }
  8756. } // The size of delimiters is the same, regardless of what style we are
  8757. // in. Thus, to correctly calculate the size of delimiter we need around
  8758. // a group, we scale down the inner size based on the size.
  8759. innerHeight *= options.sizeMultiplier;
  8760. innerDepth *= options.sizeMultiplier;
  8761. var leftDelim;
  8762. if (group.left === ".") {
  8763. // Empty delimiters in \left and \right make null delimiter spaces.
  8764. leftDelim = makeNullDelimiter(options, ["mopen"]);
  8765. } else {
  8766. // Otherwise, use leftRightDelim to generate the correct sized
  8767. // delimiter.
  8768. leftDelim = delimiter.leftRightDelim(group.left, innerHeight, innerDepth, options, group.mode, ["mopen"]);
  8769. } // Add it to the beginning of the expression
  8770. inner.unshift(leftDelim); // Handle middle delimiters
  8771. if (hadMiddle) {
  8772. for (var _i = 1; _i < inner.length; _i++) {
  8773. var middleDelim = inner[_i]; // Property `isMiddle` not defined on `span`. See comment in
  8774. // "middle"'s htmlBuilder.
  8775. // $FlowFixMe
  8776. var isMiddle = middleDelim.isMiddle;
  8777. if (isMiddle) {
  8778. // Apply the options that were active when \middle was called
  8779. inner[_i] = delimiter.leftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []);
  8780. }
  8781. }
  8782. }
  8783. var rightDelim; // Same for the right delimiter, but using color specified by \color
  8784. if (group.right === ".") {
  8785. rightDelim = makeNullDelimiter(options, ["mclose"]);
  8786. } else {
  8787. var colorOptions = group.rightColor ? options.withColor(group.rightColor) : options;
  8788. rightDelim = delimiter.leftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]);
  8789. } // Add it to the end of the expression.
  8790. inner.push(rightDelim);
  8791. return buildCommon.makeSpan(["minner"], inner, options);
  8792. },
  8793. mathmlBuilder: function mathmlBuilder(group, options) {
  8794. assertParsed(group);
  8795. var inner = buildMathML_buildExpression(group.body, options);
  8796. if (group.left !== ".") {
  8797. var leftNode = new mathMLTree.MathNode("mo", [makeText(group.left, group.mode)]);
  8798. leftNode.setAttribute("fence", "true");
  8799. inner.unshift(leftNode);
  8800. }
  8801. if (group.right !== ".") {
  8802. var rightNode = new mathMLTree.MathNode("mo", [makeText(group.right, group.mode)]);
  8803. rightNode.setAttribute("fence", "true");
  8804. if (group.rightColor) {
  8805. rightNode.setAttribute("mathcolor", group.rightColor);
  8806. }
  8807. inner.push(rightNode);
  8808. }
  8809. return makeRow(inner);
  8810. }
  8811. });
  8812. defineFunction({
  8813. type: "middle",
  8814. names: ["\\middle"],
  8815. props: {
  8816. numArgs: 1,
  8817. primitive: true
  8818. },
  8819. handler: function handler(context, args) {
  8820. var delim = checkDelimiter(args[0], context);
  8821. if (!context.parser.leftrightDepth) {
  8822. throw new src_ParseError("\\middle without preceding \\left", delim);
  8823. }
  8824. return {
  8825. type: "middle",
  8826. mode: context.parser.mode,
  8827. delim: delim.text
  8828. };
  8829. },
  8830. htmlBuilder: function htmlBuilder(group, options) {
  8831. var middleDelim;
  8832. if (group.delim === ".") {
  8833. middleDelim = makeNullDelimiter(options, []);
  8834. } else {
  8835. middleDelim = delimiter.sizedDelim(group.delim, 1, options, group.mode, []);
  8836. var isMiddle = {
  8837. delim: group.delim,
  8838. options: options
  8839. }; // Property `isMiddle` not defined on `span`. It is only used in
  8840. // this file above.
  8841. // TODO: Fix this violation of the `span` type and possibly rename
  8842. // things since `isMiddle` sounds like a boolean, but is a struct.
  8843. // $FlowFixMe
  8844. middleDelim.isMiddle = isMiddle;
  8845. }
  8846. return middleDelim;
  8847. },
  8848. mathmlBuilder: function mathmlBuilder(group, options) {
  8849. // A Firefox \middle will strech a character vertically only if it
  8850. // is in the fence part of the operator dictionary at:
  8851. // https://www.w3.org/TR/MathML3/appendixc.html.
  8852. // So we need to avoid U+2223 and use plain "|" instead.
  8853. var textNode = group.delim === "\\vert" || group.delim === "|" ? makeText("|", "text") : makeText(group.delim, group.mode);
  8854. var middleNode = new mathMLTree.MathNode("mo", [textNode]);
  8855. middleNode.setAttribute("fence", "true"); // MathML gives 5/18em spacing to each <mo> element.
  8856. // \middle should get delimiter spacing instead.
  8857. middleNode.setAttribute("lspace", "0.05em");
  8858. middleNode.setAttribute("rspace", "0.05em");
  8859. return middleNode;
  8860. }
  8861. });
  8862. ;// CONCATENATED MODULE: ./src/functions/enclose.js
  8863. var enclose_htmlBuilder = function htmlBuilder(group, options) {
  8864. // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase
  8865. // Some groups can return document fragments. Handle those by wrapping
  8866. // them in a span.
  8867. var inner = buildCommon.wrapFragment(buildGroup(group.body, options), options);
  8868. var label = group.label.slice(1);
  8869. var scale = options.sizeMultiplier;
  8870. var img;
  8871. var imgShift = 0; // In the LaTeX cancel package, line geometry is slightly different
  8872. // depending on whether the subject is wider than it is tall, or vice versa.
  8873. // We don't know the width of a group, so as a proxy, we test if
  8874. // the subject is a single character. This captures most of the
  8875. // subjects that should get the "tall" treatment.
  8876. var isSingleChar = utils.isCharacterBox(group.body);
  8877. if (label === "sout") {
  8878. img = buildCommon.makeSpan(["stretchy", "sout"]);
  8879. img.height = options.fontMetrics().defaultRuleThickness / scale;
  8880. imgShift = -0.5 * options.fontMetrics().xHeight;
  8881. } else if (label === "phase") {
  8882. // Set a couple of dimensions from the steinmetz package.
  8883. var lineWeight = calculateSize({
  8884. number: 0.6,
  8885. unit: "pt"
  8886. }, options);
  8887. var clearance = calculateSize({
  8888. number: 0.35,
  8889. unit: "ex"
  8890. }, options); // Prevent size changes like \Huge from affecting line thickness
  8891. var newOptions = options.havingBaseSizing();
  8892. scale = scale / newOptions.sizeMultiplier;
  8893. var angleHeight = inner.height + inner.depth + lineWeight + clearance; // Reserve a left pad for the angle.
  8894. inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); // Create an SVG
  8895. var viewBoxHeight = Math.floor(1000 * angleHeight * scale);
  8896. var path = phasePath(viewBoxHeight);
  8897. var svgNode = new SvgNode([new PathNode("phase", path)], {
  8898. "width": "400em",
  8899. "height": makeEm(viewBoxHeight / 1000),
  8900. "viewBox": "0 0 400000 " + viewBoxHeight,
  8901. "preserveAspectRatio": "xMinYMin slice"
  8902. }); // Wrap it in a span with overflow: hidden.
  8903. img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options);
  8904. img.style.height = makeEm(angleHeight);
  8905. imgShift = inner.depth + lineWeight + clearance;
  8906. } else {
  8907. // Add horizontal padding
  8908. if (/cancel/.test(label)) {
  8909. if (!isSingleChar) {
  8910. inner.classes.push("cancel-pad");
  8911. }
  8912. } else if (label === "angl") {
  8913. inner.classes.push("anglpad");
  8914. } else {
  8915. inner.classes.push("boxpad");
  8916. } // Add vertical padding
  8917. var topPad = 0;
  8918. var bottomPad = 0;
  8919. var ruleThickness = 0; // ref: cancel package: \advance\totalheight2\p@ % "+2"
  8920. if (/box/.test(label)) {
  8921. ruleThickness = Math.max(options.fontMetrics().fboxrule, // default
  8922. options.minRuleThickness // User override.
  8923. );
  8924. topPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness);
  8925. bottomPad = topPad;
  8926. } else if (label === "angl") {
  8927. ruleThickness = Math.max(options.fontMetrics().defaultRuleThickness, options.minRuleThickness);
  8928. topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself.
  8929. bottomPad = Math.max(0, 0.25 - inner.depth);
  8930. } else {
  8931. topPad = isSingleChar ? 0.2 : 0;
  8932. bottomPad = topPad;
  8933. }
  8934. img = stretchy.encloseSpan(inner, label, topPad, bottomPad, options);
  8935. if (/fbox|boxed|fcolorbox/.test(label)) {
  8936. img.style.borderStyle = "solid";
  8937. img.style.borderWidth = makeEm(ruleThickness);
  8938. } else if (label === "angl" && ruleThickness !== 0.049) {
  8939. img.style.borderTopWidth = makeEm(ruleThickness);
  8940. img.style.borderRightWidth = makeEm(ruleThickness);
  8941. }
  8942. imgShift = inner.depth + bottomPad;
  8943. if (group.backgroundColor) {
  8944. img.style.backgroundColor = group.backgroundColor;
  8945. if (group.borderColor) {
  8946. img.style.borderColor = group.borderColor;
  8947. }
  8948. }
  8949. }
  8950. var vlist;
  8951. if (group.backgroundColor) {
  8952. vlist = buildCommon.makeVList({
  8953. positionType: "individualShift",
  8954. children: [// Put the color background behind inner;
  8955. {
  8956. type: "elem",
  8957. elem: img,
  8958. shift: imgShift
  8959. }, {
  8960. type: "elem",
  8961. elem: inner,
  8962. shift: 0
  8963. }]
  8964. }, options);
  8965. } else {
  8966. var classes = /cancel|phase/.test(label) ? ["svg-align"] : [];
  8967. vlist = buildCommon.makeVList({
  8968. positionType: "individualShift",
  8969. children: [// Write the \cancel stroke on top of inner.
  8970. {
  8971. type: "elem",
  8972. elem: inner,
  8973. shift: 0
  8974. }, {
  8975. type: "elem",
  8976. elem: img,
  8977. shift: imgShift,
  8978. wrapperClasses: classes
  8979. }]
  8980. }, options);
  8981. }
  8982. if (/cancel/.test(label)) {
  8983. // The cancel package documentation says that cancel lines add their height
  8984. // to the expression, but tests show that isn't how it actually works.
  8985. vlist.height = inner.height;
  8986. vlist.depth = inner.depth;
  8987. }
  8988. if (/cancel/.test(label) && !isSingleChar) {
  8989. // cancel does not create horiz space for its line extension.
  8990. return buildCommon.makeSpan(["mord", "cancel-lap"], [vlist], options);
  8991. } else {
  8992. return buildCommon.makeSpan(["mord"], [vlist], options);
  8993. }
  8994. };
  8995. var enclose_mathmlBuilder = function mathmlBuilder(group, options) {
  8996. var fboxsep = 0;
  8997. var node = new mathMLTree.MathNode(group.label.indexOf("colorbox") > -1 ? "mpadded" : "menclose", [buildMathML_buildGroup(group.body, options)]);
  8998. switch (group.label) {
  8999. case "\\cancel":
  9000. node.setAttribute("notation", "updiagonalstrike");
  9001. break;
  9002. case "\\bcancel":
  9003. node.setAttribute("notation", "downdiagonalstrike");
  9004. break;
  9005. case "\\phase":
  9006. node.setAttribute("notation", "phasorangle");
  9007. break;
  9008. case "\\sout":
  9009. node.setAttribute("notation", "horizontalstrike");
  9010. break;
  9011. case "\\fbox":
  9012. node.setAttribute("notation", "box");
  9013. break;
  9014. case "\\angl":
  9015. node.setAttribute("notation", "actuarial");
  9016. break;
  9017. case "\\fcolorbox":
  9018. case "\\colorbox":
  9019. // <menclose> doesn't have a good notation option. So use <mpadded>
  9020. // instead. Set some attributes that come included with <menclose>.
  9021. fboxsep = options.fontMetrics().fboxsep * options.fontMetrics().ptPerEm;
  9022. node.setAttribute("width", "+" + 2 * fboxsep + "pt");
  9023. node.setAttribute("height", "+" + 2 * fboxsep + "pt");
  9024. node.setAttribute("lspace", fboxsep + "pt"); //
  9025. node.setAttribute("voffset", fboxsep + "pt");
  9026. if (group.label === "\\fcolorbox") {
  9027. var thk = Math.max(options.fontMetrics().fboxrule, // default
  9028. options.minRuleThickness // user override
  9029. );
  9030. node.setAttribute("style", "border: " + thk + "em solid " + String(group.borderColor));
  9031. }
  9032. break;
  9033. case "\\xcancel":
  9034. node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
  9035. break;
  9036. }
  9037. if (group.backgroundColor) {
  9038. node.setAttribute("mathbackground", group.backgroundColor);
  9039. }
  9040. return node;
  9041. };
  9042. defineFunction({
  9043. type: "enclose",
  9044. names: ["\\colorbox"],
  9045. props: {
  9046. numArgs: 2,
  9047. allowedInText: true,
  9048. argTypes: ["color", "text"]
  9049. },
  9050. handler: function handler(_ref, args, optArgs) {
  9051. var parser = _ref.parser,
  9052. funcName = _ref.funcName;
  9053. var color = assertNodeType(args[0], "color-token").color;
  9054. var body = args[1];
  9055. return {
  9056. type: "enclose",
  9057. mode: parser.mode,
  9058. label: funcName,
  9059. backgroundColor: color,
  9060. body: body
  9061. };
  9062. },
  9063. htmlBuilder: enclose_htmlBuilder,
  9064. mathmlBuilder: enclose_mathmlBuilder
  9065. });
  9066. defineFunction({
  9067. type: "enclose",
  9068. names: ["\\fcolorbox"],
  9069. props: {
  9070. numArgs: 3,
  9071. allowedInText: true,
  9072. argTypes: ["color", "color", "text"]
  9073. },
  9074. handler: function handler(_ref2, args, optArgs) {
  9075. var parser = _ref2.parser,
  9076. funcName = _ref2.funcName;
  9077. var borderColor = assertNodeType(args[0], "color-token").color;
  9078. var backgroundColor = assertNodeType(args[1], "color-token").color;
  9079. var body = args[2];
  9080. return {
  9081. type: "enclose",
  9082. mode: parser.mode,
  9083. label: funcName,
  9084. backgroundColor: backgroundColor,
  9085. borderColor: borderColor,
  9086. body: body
  9087. };
  9088. },
  9089. htmlBuilder: enclose_htmlBuilder,
  9090. mathmlBuilder: enclose_mathmlBuilder
  9091. });
  9092. defineFunction({
  9093. type: "enclose",
  9094. names: ["\\fbox"],
  9095. props: {
  9096. numArgs: 1,
  9097. argTypes: ["hbox"],
  9098. allowedInText: true
  9099. },
  9100. handler: function handler(_ref3, args) {
  9101. var parser = _ref3.parser;
  9102. return {
  9103. type: "enclose",
  9104. mode: parser.mode,
  9105. label: "\\fbox",
  9106. body: args[0]
  9107. };
  9108. }
  9109. });
  9110. defineFunction({
  9111. type: "enclose",
  9112. names: ["\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\phase"],
  9113. props: {
  9114. numArgs: 1
  9115. },
  9116. handler: function handler(_ref4, args) {
  9117. var parser = _ref4.parser,
  9118. funcName = _ref4.funcName;
  9119. var body = args[0];
  9120. return {
  9121. type: "enclose",
  9122. mode: parser.mode,
  9123. label: funcName,
  9124. body: body
  9125. };
  9126. },
  9127. htmlBuilder: enclose_htmlBuilder,
  9128. mathmlBuilder: enclose_mathmlBuilder
  9129. });
  9130. defineFunction({
  9131. type: "enclose",
  9132. names: ["\\angl"],
  9133. props: {
  9134. numArgs: 1,
  9135. argTypes: ["hbox"],
  9136. allowedInText: false
  9137. },
  9138. handler: function handler(_ref5, args) {
  9139. var parser = _ref5.parser;
  9140. return {
  9141. type: "enclose",
  9142. mode: parser.mode,
  9143. label: "\\angl",
  9144. body: args[0]
  9145. };
  9146. }
  9147. });
  9148. ;// CONCATENATED MODULE: ./src/defineEnvironment.js
  9149. /**
  9150. * All registered environments.
  9151. * `environments.js` exports this same dictionary again and makes it public.
  9152. * `Parser.js` requires this dictionary via `environments.js`.
  9153. */
  9154. var _environments = {};
  9155. function defineEnvironment(_ref) {
  9156. var type = _ref.type,
  9157. names = _ref.names,
  9158. props = _ref.props,
  9159. handler = _ref.handler,
  9160. htmlBuilder = _ref.htmlBuilder,
  9161. mathmlBuilder = _ref.mathmlBuilder;
  9162. // Set default values of environments.
  9163. var data = {
  9164. type: type,
  9165. numArgs: props.numArgs || 0,
  9166. allowedInText: false,
  9167. numOptionalArgs: 0,
  9168. handler: handler
  9169. };
  9170. for (var i = 0; i < names.length; ++i) {
  9171. // TODO: The value type of _environments should be a type union of all
  9172. // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is
  9173. // an existential type.
  9174. _environments[names[i]] = data;
  9175. }
  9176. if (htmlBuilder) {
  9177. _htmlGroupBuilders[type] = htmlBuilder;
  9178. }
  9179. if (mathmlBuilder) {
  9180. _mathmlGroupBuilders[type] = mathmlBuilder;
  9181. }
  9182. }
  9183. ;// CONCATENATED MODULE: ./src/defineMacro.js
  9184. /**
  9185. * All registered global/built-in macros.
  9186. * `macros.js` exports this same dictionary again and makes it public.
  9187. * `Parser.js` requires this dictionary via `macros.js`.
  9188. */
  9189. var _macros = {}; // This function might one day accept an additional argument and do more things.
  9190. function defineMacro(name, body) {
  9191. _macros[name] = body;
  9192. }
  9193. ;// CONCATENATED MODULE: ./src/SourceLocation.js
  9194. /**
  9195. * Lexing or parsing positional information for error reporting.
  9196. * This object is immutable.
  9197. */
  9198. var SourceLocation = /*#__PURE__*/function () {
  9199. // The + prefix indicates that these fields aren't writeable
  9200. // Lexer holding the input string.
  9201. // Start offset, zero-based inclusive.
  9202. // End offset, zero-based exclusive.
  9203. function SourceLocation(lexer, start, end) {
  9204. this.lexer = void 0;
  9205. this.start = void 0;
  9206. this.end = void 0;
  9207. this.lexer = lexer;
  9208. this.start = start;
  9209. this.end = end;
  9210. }
  9211. /**
  9212. * Merges two `SourceLocation`s from location providers, given they are
  9213. * provided in order of appearance.
  9214. * - Returns the first one's location if only the first is provided.
  9215. * - Returns a merged range of the first and the last if both are provided
  9216. * and their lexers match.
  9217. * - Otherwise, returns null.
  9218. */
  9219. SourceLocation.range = function range(first, second) {
  9220. if (!second) {
  9221. return first && first.loc;
  9222. } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) {
  9223. return null;
  9224. } else {
  9225. return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end);
  9226. }
  9227. };
  9228. return SourceLocation;
  9229. }();
  9230. ;// CONCATENATED MODULE: ./src/Token.js
  9231. /**
  9232. * Interface required to break circular dependency between Token, Lexer, and
  9233. * ParseError.
  9234. */
  9235. /**
  9236. * The resulting token returned from `lex`.
  9237. *
  9238. * It consists of the token text plus some position information.
  9239. * The position information is essentially a range in an input string,
  9240. * but instead of referencing the bare input string, we refer to the lexer.
  9241. * That way it is possible to attach extra metadata to the input string,
  9242. * like for example a file name or similar.
  9243. *
  9244. * The position information is optional, so it is OK to construct synthetic
  9245. * tokens if appropriate. Not providing available position information may
  9246. * lead to degraded error reporting, though.
  9247. */
  9248. var Token = /*#__PURE__*/function () {
  9249. // don't expand the token
  9250. // used in \noexpand
  9251. function Token(text, // the text of this token
  9252. loc) {
  9253. this.text = void 0;
  9254. this.loc = void 0;
  9255. this.noexpand = void 0;
  9256. this.treatAsRelax = void 0;
  9257. this.text = text;
  9258. this.loc = loc;
  9259. }
  9260. /**
  9261. * Given a pair of tokens (this and endToken), compute a `Token` encompassing
  9262. * the whole input range enclosed by these two.
  9263. */
  9264. var _proto = Token.prototype;
  9265. _proto.range = function range(endToken, // last token of the range, inclusive
  9266. text // the text of the newly constructed token
  9267. ) {
  9268. return new Token(text, SourceLocation.range(this, endToken));
  9269. };
  9270. return Token;
  9271. }();
  9272. ;// CONCATENATED MODULE: ./src/environments/array.js
  9273. // Helper functions
  9274. function getHLines(parser) {
  9275. // Return an array. The array length = number of hlines.
  9276. // Each element in the array tells if the line is dashed.
  9277. var hlineInfo = [];
  9278. parser.consumeSpaces();
  9279. var nxt = parser.fetch().text;
  9280. while (nxt === "\\hline" || nxt === "\\hdashline") {
  9281. parser.consume();
  9282. hlineInfo.push(nxt === "\\hdashline");
  9283. parser.consumeSpaces();
  9284. nxt = parser.fetch().text;
  9285. }
  9286. return hlineInfo;
  9287. }
  9288. var validateAmsEnvironmentContext = function validateAmsEnvironmentContext(context) {
  9289. var settings = context.parser.settings;
  9290. if (!settings.displayMode) {
  9291. throw new src_ParseError("{" + context.envName + "} can be used only in" + " display mode.");
  9292. }
  9293. }; // autoTag (an argument to parseArray) can be one of three values:
  9294. // * undefined: Regular (not-top-level) array; no tags on each row
  9295. // * true: Automatic equation numbering, overridable by \tag
  9296. // * false: Tags allowed on each row, but no automatic numbering
  9297. // This function *doesn't* work with the "split" environment name.
  9298. function getAutoTag(name) {
  9299. if (name.indexOf("ed") === -1) {
  9300. return name.indexOf("*") === -1;
  9301. } // return undefined;
  9302. }
  9303. /**
  9304. * Parse the body of the environment, with rows delimited by \\ and
  9305. * columns delimited by &, and create a nested list in row-major order
  9306. * with one group per cell. If given an optional argument style
  9307. * ("text", "display", etc.), then each cell is cast into that style.
  9308. */
  9309. function parseArray(parser, _ref, style) {
  9310. var hskipBeforeAndAfter = _ref.hskipBeforeAndAfter,
  9311. addJot = _ref.addJot,
  9312. cols = _ref.cols,
  9313. arraystretch = _ref.arraystretch,
  9314. colSeparationType = _ref.colSeparationType,
  9315. autoTag = _ref.autoTag,
  9316. singleRow = _ref.singleRow,
  9317. emptySingleRow = _ref.emptySingleRow,
  9318. maxNumCols = _ref.maxNumCols,
  9319. leqno = _ref.leqno;
  9320. parser.gullet.beginGroup();
  9321. if (!singleRow) {
  9322. // \cr is equivalent to \\ without the optional size argument (see below)
  9323. // TODO: provide helpful error when \cr is used outside array environment
  9324. parser.gullet.macros.set("\\cr", "\\\\\\relax");
  9325. } // Get current arraystretch if it's not set by the environment
  9326. if (!arraystretch) {
  9327. var stretch = parser.gullet.expandMacroAsText("\\arraystretch");
  9328. if (stretch == null) {
  9329. // Default \arraystretch from lttab.dtx
  9330. arraystretch = 1;
  9331. } else {
  9332. arraystretch = parseFloat(stretch);
  9333. if (!arraystretch || arraystretch < 0) {
  9334. throw new src_ParseError("Invalid \\arraystretch: " + stretch);
  9335. }
  9336. }
  9337. } // Start group for first cell
  9338. parser.gullet.beginGroup();
  9339. var row = [];
  9340. var body = [row];
  9341. var rowGaps = [];
  9342. var hLinesBeforeRow = [];
  9343. var tags = autoTag != null ? [] : undefined; // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent
  9344. // whether this row should have an equation number. Simulate this with
  9345. // a \@eqnsw macro set to 1 or 0.
  9346. function beginRow() {
  9347. if (autoTag) {
  9348. parser.gullet.macros.set("\\@eqnsw", "1", true);
  9349. }
  9350. }
  9351. function endRow() {
  9352. if (tags) {
  9353. if (parser.gullet.macros.get("\\df@tag")) {
  9354. tags.push(parser.subparse([new Token("\\df@tag")]));
  9355. parser.gullet.macros.set("\\df@tag", undefined, true);
  9356. } else {
  9357. tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1");
  9358. }
  9359. }
  9360. }
  9361. beginRow(); // Test for \hline at the top of the array.
  9362. hLinesBeforeRow.push(getHLines(parser));
  9363. while (true) {
  9364. // eslint-disable-line no-constant-condition
  9365. // Parse each cell in its own group (namespace)
  9366. var cell = parser.parseExpression(false, singleRow ? "\\end" : "\\\\");
  9367. parser.gullet.endGroup();
  9368. parser.gullet.beginGroup();
  9369. cell = {
  9370. type: "ordgroup",
  9371. mode: parser.mode,
  9372. body: cell
  9373. };
  9374. if (style) {
  9375. cell = {
  9376. type: "styling",
  9377. mode: parser.mode,
  9378. style: style,
  9379. body: [cell]
  9380. };
  9381. }
  9382. row.push(cell);
  9383. var next = parser.fetch().text;
  9384. if (next === "&") {
  9385. if (maxNumCols && row.length === maxNumCols) {
  9386. if (singleRow || colSeparationType) {
  9387. // {equation} or {split}
  9388. throw new src_ParseError("Too many tab characters: &", parser.nextToken);
  9389. } else {
  9390. // {array} environment
  9391. parser.settings.reportNonstrict("textEnv", "Too few columns " + "specified in the {array} column argument.");
  9392. }
  9393. }
  9394. parser.consume();
  9395. } else if (next === "\\end") {
  9396. endRow(); // Arrays terminate newlines with `\crcr` which consumes a `\cr` if
  9397. // the last line is empty. However, AMS environments keep the
  9398. // empty row if it's the only one.
  9399. // NOTE: Currently, `cell` is the last item added into `row`.
  9400. if (row.length === 1 && cell.type === "styling" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) {
  9401. body.pop();
  9402. }
  9403. if (hLinesBeforeRow.length < body.length + 1) {
  9404. hLinesBeforeRow.push([]);
  9405. }
  9406. break;
  9407. } else if (next === "\\\\") {
  9408. parser.consume();
  9409. var size = void 0; // \def\Let@{\let\\\math@cr}
  9410. // \def\math@cr{...\math@cr@}
  9411. // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}}
  9412. // \def\math@cr@@[#1]{...\math@cr@@@...}
  9413. // \def\math@cr@@@{\cr}
  9414. if (parser.gullet.future().text !== " ") {
  9415. size = parser.parseSizeGroup(true);
  9416. }
  9417. rowGaps.push(size ? size.value : null);
  9418. endRow(); // check for \hline(s) following the row separator
  9419. hLinesBeforeRow.push(getHLines(parser));
  9420. row = [];
  9421. body.push(row);
  9422. beginRow();
  9423. } else {
  9424. throw new src_ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken);
  9425. }
  9426. } // End cell group
  9427. parser.gullet.endGroup(); // End array group defining \cr
  9428. parser.gullet.endGroup();
  9429. return {
  9430. type: "array",
  9431. mode: parser.mode,
  9432. addJot: addJot,
  9433. arraystretch: arraystretch,
  9434. body: body,
  9435. cols: cols,
  9436. rowGaps: rowGaps,
  9437. hskipBeforeAndAfter: hskipBeforeAndAfter,
  9438. hLinesBeforeRow: hLinesBeforeRow,
  9439. colSeparationType: colSeparationType,
  9440. tags: tags,
  9441. leqno: leqno
  9442. };
  9443. } // Decides on a style for cells in an array according to whether the given
  9444. // environment name starts with the letter 'd'.
  9445. function dCellStyle(envName) {
  9446. if (envName.slice(0, 1) === "d") {
  9447. return "display";
  9448. } else {
  9449. return "text";
  9450. }
  9451. }
  9452. var array_htmlBuilder = function htmlBuilder(group, options) {
  9453. var r;
  9454. var c;
  9455. var nr = group.body.length;
  9456. var hLinesBeforeRow = group.hLinesBeforeRow;
  9457. var nc = 0;
  9458. var body = new Array(nr);
  9459. var hlines = [];
  9460. var ruleThickness = Math.max( // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em.
  9461. options.fontMetrics().arrayRuleWidth, options.minRuleThickness // User override.
  9462. ); // Horizontal spacing
  9463. var pt = 1 / options.fontMetrics().ptPerEm;
  9464. var arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls
  9465. if (group.colSeparationType && group.colSeparationType === "small") {
  9466. // We're in a {smallmatrix}. Default column space is \thickspace,
  9467. // i.e. 5/18em = 0.2778em, per amsmath.dtx for {smallmatrix}.
  9468. // But that needs adjustment because LaTeX applies \scriptstyle to the
  9469. // entire array, including the colspace, but this function applies
  9470. // \scriptstyle only inside each element.
  9471. var localMultiplier = options.havingStyle(src_Style.SCRIPT).sizeMultiplier;
  9472. arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier);
  9473. } // Vertical spacing
  9474. var baselineskip = group.colSeparationType === "CD" ? calculateSize({
  9475. number: 3,
  9476. unit: "ex"
  9477. }, options) : 12 * pt; // see size10.clo
  9478. // Default \jot from ltmath.dtx
  9479. // TODO(edemaine): allow overriding \jot via \setlength (#687)
  9480. var jot = 3 * pt;
  9481. var arrayskip = group.arraystretch * baselineskip;
  9482. var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and
  9483. var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx
  9484. var totalHeight = 0; // Set a position for \hline(s) at the top of the array, if any.
  9485. function setHLinePos(hlinesInGap) {
  9486. for (var i = 0; i < hlinesInGap.length; ++i) {
  9487. if (i > 0) {
  9488. totalHeight += 0.25;
  9489. }
  9490. hlines.push({
  9491. pos: totalHeight,
  9492. isDashed: hlinesInGap[i]
  9493. });
  9494. }
  9495. }
  9496. setHLinePos(hLinesBeforeRow[0]);
  9497. for (r = 0; r < group.body.length; ++r) {
  9498. var inrow = group.body[r];
  9499. var height = arstrutHeight; // \@array adds an \@arstrut
  9500. var depth = arstrutDepth; // to each tow (via the template)
  9501. if (nc < inrow.length) {
  9502. nc = inrow.length;
  9503. }
  9504. var outrow = new Array(inrow.length);
  9505. for (c = 0; c < inrow.length; ++c) {
  9506. var elt = buildGroup(inrow[c], options);
  9507. if (depth < elt.depth) {
  9508. depth = elt.depth;
  9509. }
  9510. if (height < elt.height) {
  9511. height = elt.height;
  9512. }
  9513. outrow[c] = elt;
  9514. }
  9515. var rowGap = group.rowGaps[r];
  9516. var gap = 0;
  9517. if (rowGap) {
  9518. gap = calculateSize(rowGap, options);
  9519. if (gap > 0) {
  9520. // \@argarraycr
  9521. gap += arstrutDepth;
  9522. if (depth < gap) {
  9523. depth = gap; // \@xargarraycr
  9524. }
  9525. gap = 0;
  9526. }
  9527. } // In AMS multiline environments such as aligned and gathered, rows
  9528. // correspond to lines that have additional \jot added to the
  9529. // \baselineskip via \openup.
  9530. if (group.addJot) {
  9531. depth += jot;
  9532. }
  9533. outrow.height = height;
  9534. outrow.depth = depth;
  9535. totalHeight += height;
  9536. outrow.pos = totalHeight;
  9537. totalHeight += depth + gap; // \@yargarraycr
  9538. body[r] = outrow; // Set a position for \hline(s), if any.
  9539. setHLinePos(hLinesBeforeRow[r + 1]);
  9540. }
  9541. var offset = totalHeight / 2 + options.fontMetrics().axisHeight;
  9542. var colDescriptions = group.cols || [];
  9543. var cols = [];
  9544. var colSep;
  9545. var colDescrNum;
  9546. var tagSpans = [];
  9547. if (group.tags && group.tags.some(function (tag) {
  9548. return tag;
  9549. })) {
  9550. // An environment with manual tags and/or automatic equation numbers.
  9551. // Create node(s), the latter of which trigger CSS counter increment.
  9552. for (r = 0; r < nr; ++r) {
  9553. var rw = body[r];
  9554. var shift = rw.pos - offset;
  9555. var tag = group.tags[r];
  9556. var tagSpan = void 0;
  9557. if (tag === true) {
  9558. // automatic numbering
  9559. tagSpan = buildCommon.makeSpan(["eqn-num"], [], options);
  9560. } else if (tag === false) {
  9561. // \nonumber/\notag or starred environment
  9562. tagSpan = buildCommon.makeSpan([], [], options);
  9563. } else {
  9564. // manual \tag
  9565. tagSpan = buildCommon.makeSpan([], buildExpression(tag, options, true), options);
  9566. }
  9567. tagSpan.depth = rw.depth;
  9568. tagSpan.height = rw.height;
  9569. tagSpans.push({
  9570. type: "elem",
  9571. elem: tagSpan,
  9572. shift: shift
  9573. });
  9574. }
  9575. }
  9576. for (c = 0, colDescrNum = 0; // Continue while either there are more columns or more column
  9577. // descriptions, so trailing separators don't get lost.
  9578. c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) {
  9579. var colDescr = colDescriptions[colDescrNum] || {};
  9580. var firstSeparator = true;
  9581. while (colDescr.type === "separator") {
  9582. // If there is more than one separator in a row, add a space
  9583. // between them.
  9584. if (!firstSeparator) {
  9585. colSep = buildCommon.makeSpan(["arraycolsep"], []);
  9586. colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep);
  9587. cols.push(colSep);
  9588. }
  9589. if (colDescr.separator === "|" || colDescr.separator === ":") {
  9590. var lineType = colDescr.separator === "|" ? "solid" : "dashed";
  9591. var separator = buildCommon.makeSpan(["vertical-separator"], [], options);
  9592. separator.style.height = makeEm(totalHeight);
  9593. separator.style.borderRightWidth = makeEm(ruleThickness);
  9594. separator.style.borderRightStyle = lineType;
  9595. separator.style.margin = "0 " + makeEm(-ruleThickness / 2);
  9596. var _shift = totalHeight - offset;
  9597. if (_shift) {
  9598. separator.style.verticalAlign = makeEm(-_shift);
  9599. }
  9600. cols.push(separator);
  9601. } else {
  9602. throw new src_ParseError("Invalid separator type: " + colDescr.separator);
  9603. }
  9604. colDescrNum++;
  9605. colDescr = colDescriptions[colDescrNum] || {};
  9606. firstSeparator = false;
  9607. }
  9608. if (c >= nc) {
  9609. continue;
  9610. }
  9611. var sepwidth = void 0;
  9612. if (c > 0 || group.hskipBeforeAndAfter) {
  9613. sepwidth = utils.deflt(colDescr.pregap, arraycolsep);
  9614. if (sepwidth !== 0) {
  9615. colSep = buildCommon.makeSpan(["arraycolsep"], []);
  9616. colSep.style.width = makeEm(sepwidth);
  9617. cols.push(colSep);
  9618. }
  9619. }
  9620. var col = [];
  9621. for (r = 0; r < nr; ++r) {
  9622. var row = body[r];
  9623. var elem = row[c];
  9624. if (!elem) {
  9625. continue;
  9626. }
  9627. var _shift2 = row.pos - offset;
  9628. elem.depth = row.depth;
  9629. elem.height = row.height;
  9630. col.push({
  9631. type: "elem",
  9632. elem: elem,
  9633. shift: _shift2
  9634. });
  9635. }
  9636. col = buildCommon.makeVList({
  9637. positionType: "individualShift",
  9638. children: col
  9639. }, options);
  9640. col = buildCommon.makeSpan(["col-align-" + (colDescr.align || "c")], [col]);
  9641. cols.push(col);
  9642. if (c < nc - 1 || group.hskipBeforeAndAfter) {
  9643. sepwidth = utils.deflt(colDescr.postgap, arraycolsep);
  9644. if (sepwidth !== 0) {
  9645. colSep = buildCommon.makeSpan(["arraycolsep"], []);
  9646. colSep.style.width = makeEm(sepwidth);
  9647. cols.push(colSep);
  9648. }
  9649. }
  9650. }
  9651. body = buildCommon.makeSpan(["mtable"], cols); // Add \hline(s), if any.
  9652. if (hlines.length > 0) {
  9653. var line = buildCommon.makeLineSpan("hline", options, ruleThickness);
  9654. var dashes = buildCommon.makeLineSpan("hdashline", options, ruleThickness);
  9655. var vListElems = [{
  9656. type: "elem",
  9657. elem: body,
  9658. shift: 0
  9659. }];
  9660. while (hlines.length > 0) {
  9661. var hline = hlines.pop();
  9662. var lineShift = hline.pos - offset;
  9663. if (hline.isDashed) {
  9664. vListElems.push({
  9665. type: "elem",
  9666. elem: dashes,
  9667. shift: lineShift
  9668. });
  9669. } else {
  9670. vListElems.push({
  9671. type: "elem",
  9672. elem: line,
  9673. shift: lineShift
  9674. });
  9675. }
  9676. }
  9677. body = buildCommon.makeVList({
  9678. positionType: "individualShift",
  9679. children: vListElems
  9680. }, options);
  9681. }
  9682. if (tagSpans.length === 0) {
  9683. return buildCommon.makeSpan(["mord"], [body], options);
  9684. } else {
  9685. var eqnNumCol = buildCommon.makeVList({
  9686. positionType: "individualShift",
  9687. children: tagSpans
  9688. }, options);
  9689. eqnNumCol = buildCommon.makeSpan(["tag"], [eqnNumCol], options);
  9690. return buildCommon.makeFragment([body, eqnNumCol]);
  9691. }
  9692. };
  9693. var alignMap = {
  9694. c: "center ",
  9695. l: "left ",
  9696. r: "right "
  9697. };
  9698. var array_mathmlBuilder = function mathmlBuilder(group, options) {
  9699. var tbl = [];
  9700. var glue = new mathMLTree.MathNode("mtd", [], ["mtr-glue"]);
  9701. var tag = new mathMLTree.MathNode("mtd", [], ["mml-eqn-num"]);
  9702. for (var i = 0; i < group.body.length; i++) {
  9703. var rw = group.body[i];
  9704. var row = [];
  9705. for (var j = 0; j < rw.length; j++) {
  9706. row.push(new mathMLTree.MathNode("mtd", [buildMathML_buildGroup(rw[j], options)]));
  9707. }
  9708. if (group.tags && group.tags[i]) {
  9709. row.unshift(glue);
  9710. row.push(glue);
  9711. if (group.leqno) {
  9712. row.unshift(tag);
  9713. } else {
  9714. row.push(tag);
  9715. }
  9716. }
  9717. tbl.push(new mathMLTree.MathNode("mtr", row));
  9718. }
  9719. var table = new mathMLTree.MathNode("mtable", tbl); // Set column alignment, row spacing, column spacing, and
  9720. // array lines by setting attributes on the table element.
  9721. // Set the row spacing. In MathML, we specify a gap distance.
  9722. // We do not use rowGap[] because MathML automatically increases
  9723. // cell height with the height/depth of the element content.
  9724. // LaTeX \arraystretch multiplies the row baseline-to-baseline distance.
  9725. // We simulate this by adding (arraystretch - 1)em to the gap. This
  9726. // does a reasonable job of adjusting arrays containing 1 em tall content.
  9727. // The 0.16 and 0.09 values are found emprically. They produce an array
  9728. // similar to LaTeX and in which content does not interfere with \hines.
  9729. var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray}
  9730. : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
  9731. table.setAttribute("rowspacing", makeEm(gap)); // MathML table lines go only between cells.
  9732. // To place a line on an edge we'll use <menclose>, if necessary.
  9733. var menclose = "";
  9734. var align = "";
  9735. if (group.cols && group.cols.length > 0) {
  9736. // Find column alignment, column spacing, and vertical lines.
  9737. var cols = group.cols;
  9738. var columnLines = "";
  9739. var prevTypeWasAlign = false;
  9740. var iStart = 0;
  9741. var iEnd = cols.length;
  9742. if (cols[0].type === "separator") {
  9743. menclose += "top ";
  9744. iStart = 1;
  9745. }
  9746. if (cols[cols.length - 1].type === "separator") {
  9747. menclose += "bottom ";
  9748. iEnd -= 1;
  9749. }
  9750. for (var _i = iStart; _i < iEnd; _i++) {
  9751. if (cols[_i].type === "align") {
  9752. align += alignMap[cols[_i].align];
  9753. if (prevTypeWasAlign) {
  9754. columnLines += "none ";
  9755. }
  9756. prevTypeWasAlign = true;
  9757. } else if (cols[_i].type === "separator") {
  9758. // MathML accepts only single lines between cells.
  9759. // So we read only the first of consecutive separators.
  9760. if (prevTypeWasAlign) {
  9761. columnLines += cols[_i].separator === "|" ? "solid " : "dashed ";
  9762. prevTypeWasAlign = false;
  9763. }
  9764. }
  9765. }
  9766. table.setAttribute("columnalign", align.trim());
  9767. if (/[sd]/.test(columnLines)) {
  9768. table.setAttribute("columnlines", columnLines.trim());
  9769. }
  9770. } // Set column spacing.
  9771. if (group.colSeparationType === "align") {
  9772. var _cols = group.cols || [];
  9773. var spacing = "";
  9774. for (var _i2 = 1; _i2 < _cols.length; _i2++) {
  9775. spacing += _i2 % 2 ? "0em " : "1em ";
  9776. }
  9777. table.setAttribute("columnspacing", spacing.trim());
  9778. } else if (group.colSeparationType === "alignat" || group.colSeparationType === "gather") {
  9779. table.setAttribute("columnspacing", "0em");
  9780. } else if (group.colSeparationType === "small") {
  9781. table.setAttribute("columnspacing", "0.2778em");
  9782. } else if (group.colSeparationType === "CD") {
  9783. table.setAttribute("columnspacing", "0.5em");
  9784. } else {
  9785. table.setAttribute("columnspacing", "1em");
  9786. } // Address \hline and \hdashline
  9787. var rowLines = "";
  9788. var hlines = group.hLinesBeforeRow;
  9789. menclose += hlines[0].length > 0 ? "left " : "";
  9790. menclose += hlines[hlines.length - 1].length > 0 ? "right " : "";
  9791. for (var _i3 = 1; _i3 < hlines.length - 1; _i3++) {
  9792. rowLines += hlines[_i3].length === 0 ? "none " // MathML accepts only a single line between rows. Read one element.
  9793. : hlines[_i3][0] ? "dashed " : "solid ";
  9794. }
  9795. if (/[sd]/.test(rowLines)) {
  9796. table.setAttribute("rowlines", rowLines.trim());
  9797. }
  9798. if (menclose !== "") {
  9799. table = new mathMLTree.MathNode("menclose", [table]);
  9800. table.setAttribute("notation", menclose.trim());
  9801. }
  9802. if (group.arraystretch && group.arraystretch < 1) {
  9803. // A small array. Wrap in scriptstyle so row gap is not too large.
  9804. table = new mathMLTree.MathNode("mstyle", [table]);
  9805. table.setAttribute("scriptlevel", "1");
  9806. }
  9807. return table;
  9808. }; // Convenience function for align, align*, aligned, alignat, alignat*, alignedat.
  9809. var alignedHandler = function alignedHandler(context, args) {
  9810. if (context.envName.indexOf("ed") === -1) {
  9811. validateAmsEnvironmentContext(context);
  9812. }
  9813. var cols = [];
  9814. var separationType = context.envName.indexOf("at") > -1 ? "alignat" : "align";
  9815. var isSplit = context.envName === "split";
  9816. var res = parseArray(context.parser, {
  9817. cols: cols,
  9818. addJot: true,
  9819. autoTag: isSplit ? undefined : getAutoTag(context.envName),
  9820. emptySingleRow: true,
  9821. colSeparationType: separationType,
  9822. maxNumCols: isSplit ? 2 : undefined,
  9823. leqno: context.parser.settings.leqno
  9824. }, "display"); // Determining number of columns.
  9825. // 1. If the first argument is given, we use it as a number of columns,
  9826. // and makes sure that each row doesn't exceed that number.
  9827. // 2. Otherwise, just count number of columns = maximum number
  9828. // of cells in each row ("aligned" mode -- isAligned will be true).
  9829. //
  9830. // At the same time, prepend empty group {} at beginning of every second
  9831. // cell in each row (starting with second cell) so that operators become
  9832. // binary. This behavior is implemented in amsmath's \start@aligned.
  9833. var numMaths;
  9834. var numCols = 0;
  9835. var emptyGroup = {
  9836. type: "ordgroup",
  9837. mode: context.mode,
  9838. body: []
  9839. };
  9840. if (args[0] && args[0].type === "ordgroup") {
  9841. var arg0 = "";
  9842. for (var i = 0; i < args[0].body.length; i++) {
  9843. var textord = assertNodeType(args[0].body[i], "textord");
  9844. arg0 += textord.text;
  9845. }
  9846. numMaths = Number(arg0);
  9847. numCols = numMaths * 2;
  9848. }
  9849. var isAligned = !numCols;
  9850. res.body.forEach(function (row) {
  9851. for (var _i4 = 1; _i4 < row.length; _i4 += 2) {
  9852. // Modify ordgroup node within styling node
  9853. var styling = assertNodeType(row[_i4], "styling");
  9854. var ordgroup = assertNodeType(styling.body[0], "ordgroup");
  9855. ordgroup.body.unshift(emptyGroup);
  9856. }
  9857. if (!isAligned) {
  9858. // Case 1
  9859. var curMaths = row.length / 2;
  9860. if (numMaths < curMaths) {
  9861. throw new src_ParseError("Too many math in a row: " + ("expected " + numMaths + ", but got " + curMaths), row[0]);
  9862. }
  9863. } else if (numCols < row.length) {
  9864. // Case 2
  9865. numCols = row.length;
  9866. }
  9867. }); // Adjusting alignment.
  9868. // In aligned mode, we add one \qquad between columns;
  9869. // otherwise we add nothing.
  9870. for (var _i5 = 0; _i5 < numCols; ++_i5) {
  9871. var align = "r";
  9872. var pregap = 0;
  9873. if (_i5 % 2 === 1) {
  9874. align = "l";
  9875. } else if (_i5 > 0 && isAligned) {
  9876. // "aligned" mode.
  9877. pregap = 1; // add one \quad
  9878. }
  9879. cols[_i5] = {
  9880. type: "align",
  9881. align: align,
  9882. pregap: pregap,
  9883. postgap: 0
  9884. };
  9885. }
  9886. res.colSeparationType = isAligned ? "align" : "alignat";
  9887. return res;
  9888. }; // Arrays are part of LaTeX, defined in lttab.dtx so its documentation
  9889. // is part of the source2e.pdf file of LaTeX2e source documentation.
  9890. // {darray} is an {array} environment where cells are set in \displaystyle,
  9891. // as defined in nccmath.sty.
  9892. defineEnvironment({
  9893. type: "array",
  9894. names: ["array", "darray"],
  9895. props: {
  9896. numArgs: 1
  9897. },
  9898. handler: function handler(context, args) {
  9899. // Since no types are specified above, the two possibilities are
  9900. // - The argument is wrapped in {} or [], in which case Parser's
  9901. // parseGroup() returns an "ordgroup" wrapping some symbol node.
  9902. // - The argument is a bare symbol node.
  9903. var symNode = checkSymbolNodeType(args[0]);
  9904. var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body;
  9905. var cols = colalign.map(function (nde) {
  9906. var node = assertSymbolNodeType(nde);
  9907. var ca = node.text;
  9908. if ("lcr".indexOf(ca) !== -1) {
  9909. return {
  9910. type: "align",
  9911. align: ca
  9912. };
  9913. } else if (ca === "|") {
  9914. return {
  9915. type: "separator",
  9916. separator: "|"
  9917. };
  9918. } else if (ca === ":") {
  9919. return {
  9920. type: "separator",
  9921. separator: ":"
  9922. };
  9923. }
  9924. throw new src_ParseError("Unknown column alignment: " + ca, nde);
  9925. });
  9926. var res = {
  9927. cols: cols,
  9928. hskipBeforeAndAfter: true,
  9929. // \@preamble in lttab.dtx
  9930. maxNumCols: cols.length
  9931. };
  9932. return parseArray(context.parser, res, dCellStyle(context.envName));
  9933. },
  9934. htmlBuilder: array_htmlBuilder,
  9935. mathmlBuilder: array_mathmlBuilder
  9936. }); // The matrix environments of amsmath builds on the array environment
  9937. // of LaTeX, which is discussed above.
  9938. // The mathtools package adds starred versions of the same environments.
  9939. // These have an optional argument to choose left|center|right justification.
  9940. defineEnvironment({
  9941. type: "array",
  9942. names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix", "matrix*", "pmatrix*", "bmatrix*", "Bmatrix*", "vmatrix*", "Vmatrix*"],
  9943. props: {
  9944. numArgs: 0
  9945. },
  9946. handler: function handler(context) {
  9947. var delimiters = {
  9948. "matrix": null,
  9949. "pmatrix": ["(", ")"],
  9950. "bmatrix": ["[", "]"],
  9951. "Bmatrix": ["\\{", "\\}"],
  9952. "vmatrix": ["|", "|"],
  9953. "Vmatrix": ["\\Vert", "\\Vert"]
  9954. }[context.envName.replace("*", "")]; // \hskip -\arraycolsep in amsmath
  9955. var colAlign = "c";
  9956. var payload = {
  9957. hskipBeforeAndAfter: false,
  9958. cols: [{
  9959. type: "align",
  9960. align: colAlign
  9961. }]
  9962. };
  9963. if (context.envName.charAt(context.envName.length - 1) === "*") {
  9964. // It's one of the mathtools starred functions.
  9965. // Parse the optional alignment argument.
  9966. var parser = context.parser;
  9967. parser.consumeSpaces();
  9968. if (parser.fetch().text === "[") {
  9969. parser.consume();
  9970. parser.consumeSpaces();
  9971. colAlign = parser.fetch().text;
  9972. if ("lcr".indexOf(colAlign) === -1) {
  9973. throw new src_ParseError("Expected l or c or r", parser.nextToken);
  9974. }
  9975. parser.consume();
  9976. parser.consumeSpaces();
  9977. parser.expect("]");
  9978. parser.consume();
  9979. payload.cols = [{
  9980. type: "align",
  9981. align: colAlign
  9982. }];
  9983. }
  9984. }
  9985. var res = parseArray(context.parser, payload, dCellStyle(context.envName)); // Populate cols with the correct number of column alignment specs.
  9986. var numCols = Math.max.apply(Math, [0].concat(res.body.map(function (row) {
  9987. return row.length;
  9988. })));
  9989. res.cols = new Array(numCols).fill({
  9990. type: "align",
  9991. align: colAlign
  9992. });
  9993. return delimiters ? {
  9994. type: "leftright",
  9995. mode: context.mode,
  9996. body: [res],
  9997. left: delimiters[0],
  9998. right: delimiters[1],
  9999. rightColor: undefined // \right uninfluenced by \color in array
  10000. } : res;
  10001. },
  10002. htmlBuilder: array_htmlBuilder,
  10003. mathmlBuilder: array_mathmlBuilder
  10004. });
  10005. defineEnvironment({
  10006. type: "array",
  10007. names: ["smallmatrix"],
  10008. props: {
  10009. numArgs: 0
  10010. },
  10011. handler: function handler(context) {
  10012. var payload = {
  10013. arraystretch: 0.5
  10014. };
  10015. var res = parseArray(context.parser, payload, "script");
  10016. res.colSeparationType = "small";
  10017. return res;
  10018. },
  10019. htmlBuilder: array_htmlBuilder,
  10020. mathmlBuilder: array_mathmlBuilder
  10021. });
  10022. defineEnvironment({
  10023. type: "array",
  10024. names: ["subarray"],
  10025. props: {
  10026. numArgs: 1
  10027. },
  10028. handler: function handler(context, args) {
  10029. // Parsing of {subarray} is similar to {array}
  10030. var symNode = checkSymbolNodeType(args[0]);
  10031. var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body;
  10032. var cols = colalign.map(function (nde) {
  10033. var node = assertSymbolNodeType(nde);
  10034. var ca = node.text; // {subarray} only recognizes "l" & "c"
  10035. if ("lc".indexOf(ca) !== -1) {
  10036. return {
  10037. type: "align",
  10038. align: ca
  10039. };
  10040. }
  10041. throw new src_ParseError("Unknown column alignment: " + ca, nde);
  10042. });
  10043. if (cols.length > 1) {
  10044. throw new src_ParseError("{subarray} can contain only one column");
  10045. }
  10046. var res = {
  10047. cols: cols,
  10048. hskipBeforeAndAfter: false,
  10049. arraystretch: 0.5
  10050. };
  10051. res = parseArray(context.parser, res, "script");
  10052. if (res.body.length > 0 && res.body[0].length > 1) {
  10053. throw new src_ParseError("{subarray} can contain only one column");
  10054. }
  10055. return res;
  10056. },
  10057. htmlBuilder: array_htmlBuilder,
  10058. mathmlBuilder: array_mathmlBuilder
  10059. }); // A cases environment (in amsmath.sty) is almost equivalent to
  10060. // \def\arraystretch{1.2}%
  10061. // \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right.
  10062. // {dcases} is a {cases} environment where cells are set in \displaystyle,
  10063. // as defined in mathtools.sty.
  10064. // {rcases} is another mathtools environment. It's brace is on the right side.
  10065. defineEnvironment({
  10066. type: "array",
  10067. names: ["cases", "dcases", "rcases", "drcases"],
  10068. props: {
  10069. numArgs: 0
  10070. },
  10071. handler: function handler(context) {
  10072. var payload = {
  10073. arraystretch: 1.2,
  10074. cols: [{
  10075. type: "align",
  10076. align: "l",
  10077. pregap: 0,
  10078. // TODO(kevinb) get the current style.
  10079. // For now we use the metrics for TEXT style which is what we were
  10080. // doing before. Before attempting to get the current style we
  10081. // should look at TeX's behavior especially for \over and matrices.
  10082. postgap: 1.0
  10083. /* 1em quad */
  10084. }, {
  10085. type: "align",
  10086. align: "l",
  10087. pregap: 0,
  10088. postgap: 0
  10089. }]
  10090. };
  10091. var res = parseArray(context.parser, payload, dCellStyle(context.envName));
  10092. return {
  10093. type: "leftright",
  10094. mode: context.mode,
  10095. body: [res],
  10096. left: context.envName.indexOf("r") > -1 ? "." : "\\{",
  10097. right: context.envName.indexOf("r") > -1 ? "\\}" : ".",
  10098. rightColor: undefined
  10099. };
  10100. },
  10101. htmlBuilder: array_htmlBuilder,
  10102. mathmlBuilder: array_mathmlBuilder
  10103. }); // In the align environment, one uses ampersands, &, to specify number of
  10104. // columns in each row, and to locate spacing between each column.
  10105. // align gets automatic numbering. align* and aligned do not.
  10106. // The alignedat environment can be used in math mode.
  10107. // Note that we assume \nomallineskiplimit to be zero,
  10108. // so that \strut@ is the same as \strut.
  10109. defineEnvironment({
  10110. type: "array",
  10111. names: ["align", "align*", "aligned", "split"],
  10112. props: {
  10113. numArgs: 0
  10114. },
  10115. handler: alignedHandler,
  10116. htmlBuilder: array_htmlBuilder,
  10117. mathmlBuilder: array_mathmlBuilder
  10118. }); // A gathered environment is like an array environment with one centered
  10119. // column, but where rows are considered lines so get \jot line spacing
  10120. // and contents are set in \displaystyle.
  10121. defineEnvironment({
  10122. type: "array",
  10123. names: ["gathered", "gather", "gather*"],
  10124. props: {
  10125. numArgs: 0
  10126. },
  10127. handler: function handler(context) {
  10128. if (utils.contains(["gather", "gather*"], context.envName)) {
  10129. validateAmsEnvironmentContext(context);
  10130. }
  10131. var res = {
  10132. cols: [{
  10133. type: "align",
  10134. align: "c"
  10135. }],
  10136. addJot: true,
  10137. colSeparationType: "gather",
  10138. autoTag: getAutoTag(context.envName),
  10139. emptySingleRow: true,
  10140. leqno: context.parser.settings.leqno
  10141. };
  10142. return parseArray(context.parser, res, "display");
  10143. },
  10144. htmlBuilder: array_htmlBuilder,
  10145. mathmlBuilder: array_mathmlBuilder
  10146. }); // alignat environment is like an align environment, but one must explicitly
  10147. // specify maximum number of columns in each row, and can adjust spacing between
  10148. // each columns.
  10149. defineEnvironment({
  10150. type: "array",
  10151. names: ["alignat", "alignat*", "alignedat"],
  10152. props: {
  10153. numArgs: 1
  10154. },
  10155. handler: alignedHandler,
  10156. htmlBuilder: array_htmlBuilder,
  10157. mathmlBuilder: array_mathmlBuilder
  10158. });
  10159. defineEnvironment({
  10160. type: "array",
  10161. names: ["equation", "equation*"],
  10162. props: {
  10163. numArgs: 0
  10164. },
  10165. handler: function handler(context) {
  10166. validateAmsEnvironmentContext(context);
  10167. var res = {
  10168. autoTag: getAutoTag(context.envName),
  10169. emptySingleRow: true,
  10170. singleRow: true,
  10171. maxNumCols: 1,
  10172. leqno: context.parser.settings.leqno
  10173. };
  10174. return parseArray(context.parser, res, "display");
  10175. },
  10176. htmlBuilder: array_htmlBuilder,
  10177. mathmlBuilder: array_mathmlBuilder
  10178. });
  10179. defineEnvironment({
  10180. type: "array",
  10181. names: ["CD"],
  10182. props: {
  10183. numArgs: 0
  10184. },
  10185. handler: function handler(context) {
  10186. validateAmsEnvironmentContext(context);
  10187. return parseCD(context.parser);
  10188. },
  10189. htmlBuilder: array_htmlBuilder,
  10190. mathmlBuilder: array_mathmlBuilder
  10191. });
  10192. defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}");
  10193. defineMacro("\\notag", "\\nonumber"); // Catch \hline outside array environment
  10194. defineFunction({
  10195. type: "text",
  10196. // Doesn't matter what this is.
  10197. names: ["\\hline", "\\hdashline"],
  10198. props: {
  10199. numArgs: 0,
  10200. allowedInText: true,
  10201. allowedInMath: true
  10202. },
  10203. handler: function handler(context, args) {
  10204. throw new src_ParseError(context.funcName + " valid only within array environment");
  10205. }
  10206. });
  10207. ;// CONCATENATED MODULE: ./src/environments.js
  10208. var environments = _environments;
  10209. /* harmony default export */ var src_environments = (environments); // All environment definitions should be imported below
  10210. ;// CONCATENATED MODULE: ./src/functions/environment.js
  10211. // Environment delimiters. HTML/MathML rendering is defined in the corresponding
  10212. // defineEnvironment definitions.
  10213. defineFunction({
  10214. type: "environment",
  10215. names: ["\\begin", "\\end"],
  10216. props: {
  10217. numArgs: 1,
  10218. argTypes: ["text"]
  10219. },
  10220. handler: function handler(_ref, args) {
  10221. var parser = _ref.parser,
  10222. funcName = _ref.funcName;
  10223. var nameGroup = args[0];
  10224. if (nameGroup.type !== "ordgroup") {
  10225. throw new src_ParseError("Invalid environment name", nameGroup);
  10226. }
  10227. var envName = "";
  10228. for (var i = 0; i < nameGroup.body.length; ++i) {
  10229. envName += assertNodeType(nameGroup.body[i], "textord").text;
  10230. }
  10231. if (funcName === "\\begin") {
  10232. // begin...end is similar to left...right
  10233. if (!src_environments.hasOwnProperty(envName)) {
  10234. throw new src_ParseError("No such environment: " + envName, nameGroup);
  10235. } // Build the environment object. Arguments and other information will
  10236. // be made available to the begin and end methods using properties.
  10237. var env = src_environments[envName];
  10238. var _parser$parseArgument = parser.parseArguments("\\begin{" + envName + "}", env),
  10239. _args = _parser$parseArgument.args,
  10240. optArgs = _parser$parseArgument.optArgs;
  10241. var context = {
  10242. mode: parser.mode,
  10243. envName: envName,
  10244. parser: parser
  10245. };
  10246. var result = env.handler(context, _args, optArgs);
  10247. parser.expect("\\end", false);
  10248. var endNameToken = parser.nextToken;
  10249. var end = assertNodeType(parser.parseFunction(), "environment");
  10250. if (end.name !== envName) {
  10251. throw new src_ParseError("Mismatch: \\begin{" + envName + "} matched by \\end{" + end.name + "}", endNameToken);
  10252. } // $FlowFixMe, "environment" handler returns an environment ParseNode
  10253. return result;
  10254. }
  10255. return {
  10256. type: "environment",
  10257. mode: parser.mode,
  10258. name: envName,
  10259. nameGroup: nameGroup
  10260. };
  10261. }
  10262. });
  10263. ;// CONCATENATED MODULE: ./src/functions/font.js
  10264. // TODO(kevinb): implement \\sl and \\sc
  10265. var font_htmlBuilder = function htmlBuilder(group, options) {
  10266. var font = group.font;
  10267. var newOptions = options.withFont(font);
  10268. return buildGroup(group.body, newOptions);
  10269. };
  10270. var font_mathmlBuilder = function mathmlBuilder(group, options) {
  10271. var font = group.font;
  10272. var newOptions = options.withFont(font);
  10273. return buildMathML_buildGroup(group.body, newOptions);
  10274. };
  10275. var fontAliases = {
  10276. "\\Bbb": "\\mathbb",
  10277. "\\bold": "\\mathbf",
  10278. "\\frak": "\\mathfrak",
  10279. "\\bm": "\\boldsymbol"
  10280. };
  10281. defineFunction({
  10282. type: "font",
  10283. names: [// styles, except \boldsymbol defined below
  10284. "\\mathrm", "\\mathit", "\\mathbf", "\\mathnormal", // families
  10285. "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt", // aliases, except \bm defined below
  10286. "\\Bbb", "\\bold", "\\frak"],
  10287. props: {
  10288. numArgs: 1,
  10289. allowedInArgument: true
  10290. },
  10291. handler: function handler(_ref, args) {
  10292. var parser = _ref.parser,
  10293. funcName = _ref.funcName;
  10294. var body = normalizeArgument(args[0]);
  10295. var func = funcName;
  10296. if (func in fontAliases) {
  10297. func = fontAliases[func];
  10298. }
  10299. return {
  10300. type: "font",
  10301. mode: parser.mode,
  10302. font: func.slice(1),
  10303. body: body
  10304. };
  10305. },
  10306. htmlBuilder: font_htmlBuilder,
  10307. mathmlBuilder: font_mathmlBuilder
  10308. });
  10309. defineFunction({
  10310. type: "mclass",
  10311. names: ["\\boldsymbol", "\\bm"],
  10312. props: {
  10313. numArgs: 1
  10314. },
  10315. handler: function handler(_ref2, args) {
  10316. var parser = _ref2.parser;
  10317. var body = args[0];
  10318. var isCharacterBox = utils.isCharacterBox(body); // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the
  10319. // argument's bin|rel|ord status
  10320. return {
  10321. type: "mclass",
  10322. mode: parser.mode,
  10323. mclass: binrelClass(body),
  10324. body: [{
  10325. type: "font",
  10326. mode: parser.mode,
  10327. font: "boldsymbol",
  10328. body: body
  10329. }],
  10330. isCharacterBox: isCharacterBox
  10331. };
  10332. }
  10333. }); // Old font changing functions
  10334. defineFunction({
  10335. type: "font",
  10336. names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"],
  10337. props: {
  10338. numArgs: 0,
  10339. allowedInText: true
  10340. },
  10341. handler: function handler(_ref3, args) {
  10342. var parser = _ref3.parser,
  10343. funcName = _ref3.funcName,
  10344. breakOnTokenText = _ref3.breakOnTokenText;
  10345. var mode = parser.mode;
  10346. var body = parser.parseExpression(true, breakOnTokenText);
  10347. var style = "math" + funcName.slice(1);
  10348. return {
  10349. type: "font",
  10350. mode: mode,
  10351. font: style,
  10352. body: {
  10353. type: "ordgroup",
  10354. mode: parser.mode,
  10355. body: body
  10356. }
  10357. };
  10358. },
  10359. htmlBuilder: font_htmlBuilder,
  10360. mathmlBuilder: font_mathmlBuilder
  10361. });
  10362. ;// CONCATENATED MODULE: ./src/functions/genfrac.js
  10363. var adjustStyle = function adjustStyle(size, originalStyle) {
  10364. // Figure out what style this fraction should be in based on the
  10365. // function used
  10366. var style = originalStyle;
  10367. if (size === "display") {
  10368. // Get display style as a default.
  10369. // If incoming style is sub/sup, use style.text() to get correct size.
  10370. style = style.id >= src_Style.SCRIPT.id ? style.text() : src_Style.DISPLAY;
  10371. } else if (size === "text" && style.size === src_Style.DISPLAY.size) {
  10372. // We're in a \tfrac but incoming style is displaystyle, so:
  10373. style = src_Style.TEXT;
  10374. } else if (size === "script") {
  10375. style = src_Style.SCRIPT;
  10376. } else if (size === "scriptscript") {
  10377. style = src_Style.SCRIPTSCRIPT;
  10378. }
  10379. return style;
  10380. };
  10381. var genfrac_htmlBuilder = function htmlBuilder(group, options) {
  10382. // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e).
  10383. var style = adjustStyle(group.size, options.style);
  10384. var nstyle = style.fracNum();
  10385. var dstyle = style.fracDen();
  10386. var newOptions;
  10387. newOptions = options.havingStyle(nstyle);
  10388. var numerm = buildGroup(group.numer, newOptions, options);
  10389. if (group.continued) {
  10390. // \cfrac inserts a \strut into the numerator.
  10391. // Get \strut dimensions from TeXbook page 353.
  10392. var hStrut = 8.5 / options.fontMetrics().ptPerEm;
  10393. var dStrut = 3.5 / options.fontMetrics().ptPerEm;
  10394. numerm.height = numerm.height < hStrut ? hStrut : numerm.height;
  10395. numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth;
  10396. }
  10397. newOptions = options.havingStyle(dstyle);
  10398. var denomm = buildGroup(group.denom, newOptions, options);
  10399. var rule;
  10400. var ruleWidth;
  10401. var ruleSpacing;
  10402. if (group.hasBarLine) {
  10403. if (group.barSize) {
  10404. ruleWidth = calculateSize(group.barSize, options);
  10405. rule = buildCommon.makeLineSpan("frac-line", options, ruleWidth);
  10406. } else {
  10407. rule = buildCommon.makeLineSpan("frac-line", options);
  10408. }
  10409. ruleWidth = rule.height;
  10410. ruleSpacing = rule.height;
  10411. } else {
  10412. rule = null;
  10413. ruleWidth = 0;
  10414. ruleSpacing = options.fontMetrics().defaultRuleThickness;
  10415. } // Rule 15b
  10416. var numShift;
  10417. var clearance;
  10418. var denomShift;
  10419. if (style.size === src_Style.DISPLAY.size || group.size === "display") {
  10420. numShift = options.fontMetrics().num1;
  10421. if (ruleWidth > 0) {
  10422. clearance = 3 * ruleSpacing;
  10423. } else {
  10424. clearance = 7 * ruleSpacing;
  10425. }
  10426. denomShift = options.fontMetrics().denom1;
  10427. } else {
  10428. if (ruleWidth > 0) {
  10429. numShift = options.fontMetrics().num2;
  10430. clearance = ruleSpacing;
  10431. } else {
  10432. numShift = options.fontMetrics().num3;
  10433. clearance = 3 * ruleSpacing;
  10434. }
  10435. denomShift = options.fontMetrics().denom2;
  10436. }
  10437. var frac;
  10438. if (!rule) {
  10439. // Rule 15c
  10440. var candidateClearance = numShift - numerm.depth - (denomm.height - denomShift);
  10441. if (candidateClearance < clearance) {
  10442. numShift += 0.5 * (clearance - candidateClearance);
  10443. denomShift += 0.5 * (clearance - candidateClearance);
  10444. }
  10445. frac = buildCommon.makeVList({
  10446. positionType: "individualShift",
  10447. children: [{
  10448. type: "elem",
  10449. elem: denomm,
  10450. shift: denomShift
  10451. }, {
  10452. type: "elem",
  10453. elem: numerm,
  10454. shift: -numShift
  10455. }]
  10456. }, options);
  10457. } else {
  10458. // Rule 15d
  10459. var axisHeight = options.fontMetrics().axisHeight;
  10460. if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) {
  10461. numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth));
  10462. }
  10463. if (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift) < clearance) {
  10464. denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift));
  10465. }
  10466. var midShift = -(axisHeight - 0.5 * ruleWidth);
  10467. frac = buildCommon.makeVList({
  10468. positionType: "individualShift",
  10469. children: [{
  10470. type: "elem",
  10471. elem: denomm,
  10472. shift: denomShift
  10473. }, {
  10474. type: "elem",
  10475. elem: rule,
  10476. shift: midShift
  10477. }, {
  10478. type: "elem",
  10479. elem: numerm,
  10480. shift: -numShift
  10481. }]
  10482. }, options);
  10483. } // Since we manually change the style sometimes (with \dfrac or \tfrac),
  10484. // account for the possible size change here.
  10485. newOptions = options.havingStyle(style);
  10486. frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier;
  10487. frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; // Rule 15e
  10488. var delimSize;
  10489. if (style.size === src_Style.DISPLAY.size) {
  10490. delimSize = options.fontMetrics().delim1;
  10491. } else if (style.size === src_Style.SCRIPTSCRIPT.size) {
  10492. delimSize = options.havingStyle(src_Style.SCRIPT).fontMetrics().delim2;
  10493. } else {
  10494. delimSize = options.fontMetrics().delim2;
  10495. }
  10496. var leftDelim;
  10497. var rightDelim;
  10498. if (group.leftDelim == null) {
  10499. leftDelim = makeNullDelimiter(options, ["mopen"]);
  10500. } else {
  10501. leftDelim = delimiter.customSizedDelim(group.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]);
  10502. }
  10503. if (group.continued) {
  10504. rightDelim = buildCommon.makeSpan([]); // zero width for \cfrac
  10505. } else if (group.rightDelim == null) {
  10506. rightDelim = makeNullDelimiter(options, ["mclose"]);
  10507. } else {
  10508. rightDelim = delimiter.customSizedDelim(group.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]);
  10509. }
  10510. return buildCommon.makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, buildCommon.makeSpan(["mfrac"], [frac]), rightDelim], options);
  10511. };
  10512. var genfrac_mathmlBuilder = function mathmlBuilder(group, options) {
  10513. var node = new mathMLTree.MathNode("mfrac", [buildMathML_buildGroup(group.numer, options), buildMathML_buildGroup(group.denom, options)]);
  10514. if (!group.hasBarLine) {
  10515. node.setAttribute("linethickness", "0px");
  10516. } else if (group.barSize) {
  10517. var ruleWidth = calculateSize(group.barSize, options);
  10518. node.setAttribute("linethickness", makeEm(ruleWidth));
  10519. }
  10520. var style = adjustStyle(group.size, options.style);
  10521. if (style.size !== options.style.size) {
  10522. node = new mathMLTree.MathNode("mstyle", [node]);
  10523. var isDisplay = style.size === src_Style.DISPLAY.size ? "true" : "false";
  10524. node.setAttribute("displaystyle", isDisplay);
  10525. node.setAttribute("scriptlevel", "0");
  10526. }
  10527. if (group.leftDelim != null || group.rightDelim != null) {
  10528. var withDelims = [];
  10529. if (group.leftDelim != null) {
  10530. var leftOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.leftDelim.replace("\\", ""))]);
  10531. leftOp.setAttribute("fence", "true");
  10532. withDelims.push(leftOp);
  10533. }
  10534. withDelims.push(node);
  10535. if (group.rightDelim != null) {
  10536. var rightOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.rightDelim.replace("\\", ""))]);
  10537. rightOp.setAttribute("fence", "true");
  10538. withDelims.push(rightOp);
  10539. }
  10540. return makeRow(withDelims);
  10541. }
  10542. return node;
  10543. };
  10544. defineFunction({
  10545. type: "genfrac",
  10546. names: ["\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac", // can’t be entered directly
  10547. "\\\\bracefrac", "\\\\brackfrac" // ditto
  10548. ],
  10549. props: {
  10550. numArgs: 2,
  10551. allowedInArgument: true
  10552. },
  10553. handler: function handler(_ref, args) {
  10554. var parser = _ref.parser,
  10555. funcName = _ref.funcName;
  10556. var numer = args[0];
  10557. var denom = args[1];
  10558. var hasBarLine;
  10559. var leftDelim = null;
  10560. var rightDelim = null;
  10561. var size = "auto";
  10562. switch (funcName) {
  10563. case "\\dfrac":
  10564. case "\\frac":
  10565. case "\\tfrac":
  10566. hasBarLine = true;
  10567. break;
  10568. case "\\\\atopfrac":
  10569. hasBarLine = false;
  10570. break;
  10571. case "\\dbinom":
  10572. case "\\binom":
  10573. case "\\tbinom":
  10574. hasBarLine = false;
  10575. leftDelim = "(";
  10576. rightDelim = ")";
  10577. break;
  10578. case "\\\\bracefrac":
  10579. hasBarLine = false;
  10580. leftDelim = "\\{";
  10581. rightDelim = "\\}";
  10582. break;
  10583. case "\\\\brackfrac":
  10584. hasBarLine = false;
  10585. leftDelim = "[";
  10586. rightDelim = "]";
  10587. break;
  10588. default:
  10589. throw new Error("Unrecognized genfrac command");
  10590. }
  10591. switch (funcName) {
  10592. case "\\dfrac":
  10593. case "\\dbinom":
  10594. size = "display";
  10595. break;
  10596. case "\\tfrac":
  10597. case "\\tbinom":
  10598. size = "text";
  10599. break;
  10600. }
  10601. return {
  10602. type: "genfrac",
  10603. mode: parser.mode,
  10604. continued: false,
  10605. numer: numer,
  10606. denom: denom,
  10607. hasBarLine: hasBarLine,
  10608. leftDelim: leftDelim,
  10609. rightDelim: rightDelim,
  10610. size: size,
  10611. barSize: null
  10612. };
  10613. },
  10614. htmlBuilder: genfrac_htmlBuilder,
  10615. mathmlBuilder: genfrac_mathmlBuilder
  10616. });
  10617. defineFunction({
  10618. type: "genfrac",
  10619. names: ["\\cfrac"],
  10620. props: {
  10621. numArgs: 2
  10622. },
  10623. handler: function handler(_ref2, args) {
  10624. var parser = _ref2.parser,
  10625. funcName = _ref2.funcName;
  10626. var numer = args[0];
  10627. var denom = args[1];
  10628. return {
  10629. type: "genfrac",
  10630. mode: parser.mode,
  10631. continued: true,
  10632. numer: numer,
  10633. denom: denom,
  10634. hasBarLine: true,
  10635. leftDelim: null,
  10636. rightDelim: null,
  10637. size: "display",
  10638. barSize: null
  10639. };
  10640. }
  10641. }); // Infix generalized fractions -- these are not rendered directly, but replaced
  10642. // immediately by one of the variants above.
  10643. defineFunction({
  10644. type: "infix",
  10645. names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"],
  10646. props: {
  10647. numArgs: 0,
  10648. infix: true
  10649. },
  10650. handler: function handler(_ref3) {
  10651. var parser = _ref3.parser,
  10652. funcName = _ref3.funcName,
  10653. token = _ref3.token;
  10654. var replaceWith;
  10655. switch (funcName) {
  10656. case "\\over":
  10657. replaceWith = "\\frac";
  10658. break;
  10659. case "\\choose":
  10660. replaceWith = "\\binom";
  10661. break;
  10662. case "\\atop":
  10663. replaceWith = "\\\\atopfrac";
  10664. break;
  10665. case "\\brace":
  10666. replaceWith = "\\\\bracefrac";
  10667. break;
  10668. case "\\brack":
  10669. replaceWith = "\\\\brackfrac";
  10670. break;
  10671. default:
  10672. throw new Error("Unrecognized infix genfrac command");
  10673. }
  10674. return {
  10675. type: "infix",
  10676. mode: parser.mode,
  10677. replaceWith: replaceWith,
  10678. token: token
  10679. };
  10680. }
  10681. });
  10682. var stylArray = ["display", "text", "script", "scriptscript"];
  10683. var delimFromValue = function delimFromValue(delimString) {
  10684. var delim = null;
  10685. if (delimString.length > 0) {
  10686. delim = delimString;
  10687. delim = delim === "." ? null : delim;
  10688. }
  10689. return delim;
  10690. };
  10691. defineFunction({
  10692. type: "genfrac",
  10693. names: ["\\genfrac"],
  10694. props: {
  10695. numArgs: 6,
  10696. allowedInArgument: true,
  10697. argTypes: ["math", "math", "size", "text", "math", "math"]
  10698. },
  10699. handler: function handler(_ref4, args) {
  10700. var parser = _ref4.parser;
  10701. var numer = args[4];
  10702. var denom = args[5]; // Look into the parse nodes to get the desired delimiters.
  10703. var leftNode = normalizeArgument(args[0]);
  10704. var leftDelim = leftNode.type === "atom" && leftNode.family === "open" ? delimFromValue(leftNode.text) : null;
  10705. var rightNode = normalizeArgument(args[1]);
  10706. var rightDelim = rightNode.type === "atom" && rightNode.family === "close" ? delimFromValue(rightNode.text) : null;
  10707. var barNode = assertNodeType(args[2], "size");
  10708. var hasBarLine;
  10709. var barSize = null;
  10710. if (barNode.isBlank) {
  10711. // \genfrac acts differently than \above.
  10712. // \genfrac treats an empty size group as a signal to use a
  10713. // standard bar size. \above would see size = 0 and omit the bar.
  10714. hasBarLine = true;
  10715. } else {
  10716. barSize = barNode.value;
  10717. hasBarLine = barSize.number > 0;
  10718. } // Find out if we want displaystyle, textstyle, etc.
  10719. var size = "auto";
  10720. var styl = args[3];
  10721. if (styl.type === "ordgroup") {
  10722. if (styl.body.length > 0) {
  10723. var textOrd = assertNodeType(styl.body[0], "textord");
  10724. size = stylArray[Number(textOrd.text)];
  10725. }
  10726. } else {
  10727. styl = assertNodeType(styl, "textord");
  10728. size = stylArray[Number(styl.text)];
  10729. }
  10730. return {
  10731. type: "genfrac",
  10732. mode: parser.mode,
  10733. numer: numer,
  10734. denom: denom,
  10735. continued: false,
  10736. hasBarLine: hasBarLine,
  10737. barSize: barSize,
  10738. leftDelim: leftDelim,
  10739. rightDelim: rightDelim,
  10740. size: size
  10741. };
  10742. },
  10743. htmlBuilder: genfrac_htmlBuilder,
  10744. mathmlBuilder: genfrac_mathmlBuilder
  10745. }); // \above is an infix fraction that also defines a fraction bar size.
  10746. defineFunction({
  10747. type: "infix",
  10748. names: ["\\above"],
  10749. props: {
  10750. numArgs: 1,
  10751. argTypes: ["size"],
  10752. infix: true
  10753. },
  10754. handler: function handler(_ref5, args) {
  10755. var parser = _ref5.parser,
  10756. funcName = _ref5.funcName,
  10757. token = _ref5.token;
  10758. return {
  10759. type: "infix",
  10760. mode: parser.mode,
  10761. replaceWith: "\\\\abovefrac",
  10762. size: assertNodeType(args[0], "size").value,
  10763. token: token
  10764. };
  10765. }
  10766. });
  10767. defineFunction({
  10768. type: "genfrac",
  10769. names: ["\\\\abovefrac"],
  10770. props: {
  10771. numArgs: 3,
  10772. argTypes: ["math", "size", "math"]
  10773. },
  10774. handler: function handler(_ref6, args) {
  10775. var parser = _ref6.parser,
  10776. funcName = _ref6.funcName;
  10777. var numer = args[0];
  10778. var barSize = assert(assertNodeType(args[1], "infix").size);
  10779. var denom = args[2];
  10780. var hasBarLine = barSize.number > 0;
  10781. return {
  10782. type: "genfrac",
  10783. mode: parser.mode,
  10784. numer: numer,
  10785. denom: denom,
  10786. continued: false,
  10787. hasBarLine: hasBarLine,
  10788. barSize: barSize,
  10789. leftDelim: null,
  10790. rightDelim: null,
  10791. size: "auto"
  10792. };
  10793. },
  10794. htmlBuilder: genfrac_htmlBuilder,
  10795. mathmlBuilder: genfrac_mathmlBuilder
  10796. });
  10797. ;// CONCATENATED MODULE: ./src/functions/horizBrace.js
  10798. // NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but
  10799. // also "supsub" since an over/underbrace can affect super/subscripting.
  10800. var horizBrace_htmlBuilder = function htmlBuilder(grp, options) {
  10801. var style = options.style; // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node.
  10802. var supSubGroup;
  10803. var group;
  10804. if (grp.type === "supsub") {
  10805. // Ref: LaTeX source2e: }}}}\limits}
  10806. // i.e. LaTeX treats the brace similar to an op and passes it
  10807. // with \limits, so we need to assign supsub style.
  10808. supSubGroup = grp.sup ? buildGroup(grp.sup, options.havingStyle(style.sup()), options) : buildGroup(grp.sub, options.havingStyle(style.sub()), options);
  10809. group = assertNodeType(grp.base, "horizBrace");
  10810. } else {
  10811. group = assertNodeType(grp, "horizBrace");
  10812. } // Build the base group
  10813. var body = buildGroup(group.base, options.havingBaseStyle(src_Style.DISPLAY)); // Create the stretchy element
  10814. var braceBody = stretchy.svgSpan(group, options); // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓
  10815. // This first vlist contains the content and the brace: equation
  10816. var vlist;
  10817. if (group.isOver) {
  10818. vlist = buildCommon.makeVList({
  10819. positionType: "firstBaseline",
  10820. children: [{
  10821. type: "elem",
  10822. elem: body
  10823. }, {
  10824. type: "kern",
  10825. size: 0.1
  10826. }, {
  10827. type: "elem",
  10828. elem: braceBody
  10829. }]
  10830. }, options); // $FlowFixMe: Replace this with passing "svg-align" into makeVList.
  10831. vlist.children[0].children[0].children[1].classes.push("svg-align");
  10832. } else {
  10833. vlist = buildCommon.makeVList({
  10834. positionType: "bottom",
  10835. positionData: body.depth + 0.1 + braceBody.height,
  10836. children: [{
  10837. type: "elem",
  10838. elem: braceBody
  10839. }, {
  10840. type: "kern",
  10841. size: 0.1
  10842. }, {
  10843. type: "elem",
  10844. elem: body
  10845. }]
  10846. }, options); // $FlowFixMe: Replace this with passing "svg-align" into makeVList.
  10847. vlist.children[0].children[0].children[0].classes.push("svg-align");
  10848. }
  10849. if (supSubGroup) {
  10850. // To write the supsub, wrap the first vlist in another vlist:
  10851. // They can't all go in the same vlist, because the note might be
  10852. // wider than the equation. We want the equation to control the
  10853. // brace width.
  10854. // note long note long note
  10855. // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓
  10856. // equation eqn eqn
  10857. var vSpan = buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options);
  10858. if (group.isOver) {
  10859. vlist = buildCommon.makeVList({
  10860. positionType: "firstBaseline",
  10861. children: [{
  10862. type: "elem",
  10863. elem: vSpan
  10864. }, {
  10865. type: "kern",
  10866. size: 0.2
  10867. }, {
  10868. type: "elem",
  10869. elem: supSubGroup
  10870. }]
  10871. }, options);
  10872. } else {
  10873. vlist = buildCommon.makeVList({
  10874. positionType: "bottom",
  10875. positionData: vSpan.depth + 0.2 + supSubGroup.height + supSubGroup.depth,
  10876. children: [{
  10877. type: "elem",
  10878. elem: supSubGroup
  10879. }, {
  10880. type: "kern",
  10881. size: 0.2
  10882. }, {
  10883. type: "elem",
  10884. elem: vSpan
  10885. }]
  10886. }, options);
  10887. }
  10888. }
  10889. return buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options);
  10890. };
  10891. var horizBrace_mathmlBuilder = function mathmlBuilder(group, options) {
  10892. var accentNode = stretchy.mathMLnode(group.label);
  10893. return new mathMLTree.MathNode(group.isOver ? "mover" : "munder", [buildMathML_buildGroup(group.base, options), accentNode]);
  10894. }; // Horizontal stretchy braces
  10895. defineFunction({
  10896. type: "horizBrace",
  10897. names: ["\\overbrace", "\\underbrace"],
  10898. props: {
  10899. numArgs: 1
  10900. },
  10901. handler: function handler(_ref, args) {
  10902. var parser = _ref.parser,
  10903. funcName = _ref.funcName;
  10904. return {
  10905. type: "horizBrace",
  10906. mode: parser.mode,
  10907. label: funcName,
  10908. isOver: /^\\over/.test(funcName),
  10909. base: args[0]
  10910. };
  10911. },
  10912. htmlBuilder: horizBrace_htmlBuilder,
  10913. mathmlBuilder: horizBrace_mathmlBuilder
  10914. });
  10915. ;// CONCATENATED MODULE: ./src/functions/href.js
  10916. defineFunction({
  10917. type: "href",
  10918. names: ["\\href"],
  10919. props: {
  10920. numArgs: 2,
  10921. argTypes: ["url", "original"],
  10922. allowedInText: true
  10923. },
  10924. handler: function handler(_ref, args) {
  10925. var parser = _ref.parser;
  10926. var body = args[1];
  10927. var href = assertNodeType(args[0], "url").url;
  10928. if (!parser.settings.isTrusted({
  10929. command: "\\href",
  10930. url: href
  10931. })) {
  10932. return parser.formatUnsupportedCmd("\\href");
  10933. }
  10934. return {
  10935. type: "href",
  10936. mode: parser.mode,
  10937. href: href,
  10938. body: ordargument(body)
  10939. };
  10940. },
  10941. htmlBuilder: function htmlBuilder(group, options) {
  10942. var elements = buildExpression(group.body, options, false);
  10943. return buildCommon.makeAnchor(group.href, [], elements, options);
  10944. },
  10945. mathmlBuilder: function mathmlBuilder(group, options) {
  10946. var math = buildExpressionRow(group.body, options);
  10947. if (!(math instanceof MathNode)) {
  10948. math = new MathNode("mrow", [math]);
  10949. }
  10950. math.setAttribute("href", group.href);
  10951. return math;
  10952. }
  10953. });
  10954. defineFunction({
  10955. type: "href",
  10956. names: ["\\url"],
  10957. props: {
  10958. numArgs: 1,
  10959. argTypes: ["url"],
  10960. allowedInText: true
  10961. },
  10962. handler: function handler(_ref2, args) {
  10963. var parser = _ref2.parser;
  10964. var href = assertNodeType(args[0], "url").url;
  10965. if (!parser.settings.isTrusted({
  10966. command: "\\url",
  10967. url: href
  10968. })) {
  10969. return parser.formatUnsupportedCmd("\\url");
  10970. }
  10971. var chars = [];
  10972. for (var i = 0; i < href.length; i++) {
  10973. var c = href[i];
  10974. if (c === "~") {
  10975. c = "\\textasciitilde";
  10976. }
  10977. chars.push({
  10978. type: "textord",
  10979. mode: "text",
  10980. text: c
  10981. });
  10982. }
  10983. var body = {
  10984. type: "text",
  10985. mode: parser.mode,
  10986. font: "\\texttt",
  10987. body: chars
  10988. };
  10989. return {
  10990. type: "href",
  10991. mode: parser.mode,
  10992. href: href,
  10993. body: ordargument(body)
  10994. };
  10995. }
  10996. });
  10997. ;// CONCATENATED MODULE: ./src/functions/hbox.js
  10998. // \hbox is provided for compatibility with LaTeX \vcenter.
  10999. // In LaTeX, \vcenter can act only on a box, as in
  11000. // \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}}
  11001. // This function by itself doesn't do anything but prevent a soft line break.
  11002. defineFunction({
  11003. type: "hbox",
  11004. names: ["\\hbox"],
  11005. props: {
  11006. numArgs: 1,
  11007. argTypes: ["text"],
  11008. allowedInText: true,
  11009. primitive: true
  11010. },
  11011. handler: function handler(_ref, args) {
  11012. var parser = _ref.parser;
  11013. return {
  11014. type: "hbox",
  11015. mode: parser.mode,
  11016. body: ordargument(args[0])
  11017. };
  11018. },
  11019. htmlBuilder: function htmlBuilder(group, options) {
  11020. var elements = buildExpression(group.body, options, false);
  11021. return buildCommon.makeFragment(elements);
  11022. },
  11023. mathmlBuilder: function mathmlBuilder(group, options) {
  11024. return new mathMLTree.MathNode("mrow", buildMathML_buildExpression(group.body, options));
  11025. }
  11026. });
  11027. ;// CONCATENATED MODULE: ./src/functions/html.js
  11028. defineFunction({
  11029. type: "html",
  11030. names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"],
  11031. props: {
  11032. numArgs: 2,
  11033. argTypes: ["raw", "original"],
  11034. allowedInText: true
  11035. },
  11036. handler: function handler(_ref, args) {
  11037. var parser = _ref.parser,
  11038. funcName = _ref.funcName,
  11039. token = _ref.token;
  11040. var value = assertNodeType(args[0], "raw").string;
  11041. var body = args[1];
  11042. if (parser.settings.strict) {
  11043. parser.settings.reportNonstrict("htmlExtension", "HTML extension is disabled on strict mode");
  11044. }
  11045. var trustContext;
  11046. var attributes = {};
  11047. switch (funcName) {
  11048. case "\\htmlClass":
  11049. attributes.class = value;
  11050. trustContext = {
  11051. command: "\\htmlClass",
  11052. class: value
  11053. };
  11054. break;
  11055. case "\\htmlId":
  11056. attributes.id = value;
  11057. trustContext = {
  11058. command: "\\htmlId",
  11059. id: value
  11060. };
  11061. break;
  11062. case "\\htmlStyle":
  11063. attributes.style = value;
  11064. trustContext = {
  11065. command: "\\htmlStyle",
  11066. style: value
  11067. };
  11068. break;
  11069. case "\\htmlData":
  11070. {
  11071. var data = value.split(",");
  11072. for (var i = 0; i < data.length; i++) {
  11073. var keyVal = data[i].split("=");
  11074. if (keyVal.length !== 2) {
  11075. throw new src_ParseError("Error parsing key-value for \\htmlData");
  11076. }
  11077. attributes["data-" + keyVal[0].trim()] = keyVal[1].trim();
  11078. }
  11079. trustContext = {
  11080. command: "\\htmlData",
  11081. attributes: attributes
  11082. };
  11083. break;
  11084. }
  11085. default:
  11086. throw new Error("Unrecognized html command");
  11087. }
  11088. if (!parser.settings.isTrusted(trustContext)) {
  11089. return parser.formatUnsupportedCmd(funcName);
  11090. }
  11091. return {
  11092. type: "html",
  11093. mode: parser.mode,
  11094. attributes: attributes,
  11095. body: ordargument(body)
  11096. };
  11097. },
  11098. htmlBuilder: function htmlBuilder(group, options) {
  11099. var elements = buildExpression(group.body, options, false);
  11100. var classes = ["enclosing"];
  11101. if (group.attributes.class) {
  11102. classes.push.apply(classes, group.attributes.class.trim().split(/\s+/));
  11103. }
  11104. var span = buildCommon.makeSpan(classes, elements, options);
  11105. for (var attr in group.attributes) {
  11106. if (attr !== "class" && group.attributes.hasOwnProperty(attr)) {
  11107. span.setAttribute(attr, group.attributes[attr]);
  11108. }
  11109. }
  11110. return span;
  11111. },
  11112. mathmlBuilder: function mathmlBuilder(group, options) {
  11113. return buildExpressionRow(group.body, options);
  11114. }
  11115. });
  11116. ;// CONCATENATED MODULE: ./src/functions/htmlmathml.js
  11117. defineFunction({
  11118. type: "htmlmathml",
  11119. names: ["\\html@mathml"],
  11120. props: {
  11121. numArgs: 2,
  11122. allowedInText: true
  11123. },
  11124. handler: function handler(_ref, args) {
  11125. var parser = _ref.parser;
  11126. return {
  11127. type: "htmlmathml",
  11128. mode: parser.mode,
  11129. html: ordargument(args[0]),
  11130. mathml: ordargument(args[1])
  11131. };
  11132. },
  11133. htmlBuilder: function htmlBuilder(group, options) {
  11134. var elements = buildExpression(group.html, options, false);
  11135. return buildCommon.makeFragment(elements);
  11136. },
  11137. mathmlBuilder: function mathmlBuilder(group, options) {
  11138. return buildExpressionRow(group.mathml, options);
  11139. }
  11140. });
  11141. ;// CONCATENATED MODULE: ./src/functions/includegraphics.js
  11142. var sizeData = function sizeData(str) {
  11143. if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) {
  11144. // str is a number with no unit specified.
  11145. // default unit is bp, per graphix package.
  11146. return {
  11147. number: +str,
  11148. unit: "bp"
  11149. };
  11150. } else {
  11151. var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str);
  11152. if (!match) {
  11153. throw new src_ParseError("Invalid size: '" + str + "' in \\includegraphics");
  11154. }
  11155. var data = {
  11156. number: +(match[1] + match[2]),
  11157. // sign + magnitude, cast to number
  11158. unit: match[3]
  11159. };
  11160. if (!validUnit(data)) {
  11161. throw new src_ParseError("Invalid unit: '" + data.unit + "' in \\includegraphics.");
  11162. }
  11163. return data;
  11164. }
  11165. };
  11166. defineFunction({
  11167. type: "includegraphics",
  11168. names: ["\\includegraphics"],
  11169. props: {
  11170. numArgs: 1,
  11171. numOptionalArgs: 1,
  11172. argTypes: ["raw", "url"],
  11173. allowedInText: false
  11174. },
  11175. handler: function handler(_ref, args, optArgs) {
  11176. var parser = _ref.parser;
  11177. var width = {
  11178. number: 0,
  11179. unit: "em"
  11180. };
  11181. var height = {
  11182. number: 0.9,
  11183. unit: "em"
  11184. }; // sorta character sized.
  11185. var totalheight = {
  11186. number: 0,
  11187. unit: "em"
  11188. };
  11189. var alt = "";
  11190. if (optArgs[0]) {
  11191. var attributeStr = assertNodeType(optArgs[0], "raw").string; // Parser.js does not parse key/value pairs. We get a string.
  11192. var attributes = attributeStr.split(",");
  11193. for (var i = 0; i < attributes.length; i++) {
  11194. var keyVal = attributes[i].split("=");
  11195. if (keyVal.length === 2) {
  11196. var str = keyVal[1].trim();
  11197. switch (keyVal[0].trim()) {
  11198. case "alt":
  11199. alt = str;
  11200. break;
  11201. case "width":
  11202. width = sizeData(str);
  11203. break;
  11204. case "height":
  11205. height = sizeData(str);
  11206. break;
  11207. case "totalheight":
  11208. totalheight = sizeData(str);
  11209. break;
  11210. default:
  11211. throw new src_ParseError("Invalid key: '" + keyVal[0] + "' in \\includegraphics.");
  11212. }
  11213. }
  11214. }
  11215. }
  11216. var src = assertNodeType(args[0], "url").url;
  11217. if (alt === "") {
  11218. // No alt given. Use the file name. Strip away the path.
  11219. alt = src;
  11220. alt = alt.replace(/^.*[\\/]/, '');
  11221. alt = alt.substring(0, alt.lastIndexOf('.'));
  11222. }
  11223. if (!parser.settings.isTrusted({
  11224. command: "\\includegraphics",
  11225. url: src
  11226. })) {
  11227. return parser.formatUnsupportedCmd("\\includegraphics");
  11228. }
  11229. return {
  11230. type: "includegraphics",
  11231. mode: parser.mode,
  11232. alt: alt,
  11233. width: width,
  11234. height: height,
  11235. totalheight: totalheight,
  11236. src: src
  11237. };
  11238. },
  11239. htmlBuilder: function htmlBuilder(group, options) {
  11240. var height = calculateSize(group.height, options);
  11241. var depth = 0;
  11242. if (group.totalheight.number > 0) {
  11243. depth = calculateSize(group.totalheight, options) - height;
  11244. }
  11245. var width = 0;
  11246. if (group.width.number > 0) {
  11247. width = calculateSize(group.width, options);
  11248. }
  11249. var style = {
  11250. height: makeEm(height + depth)
  11251. };
  11252. if (width > 0) {
  11253. style.width = makeEm(width);
  11254. }
  11255. if (depth > 0) {
  11256. style.verticalAlign = makeEm(-depth);
  11257. }
  11258. var node = new Img(group.src, group.alt, style);
  11259. node.height = height;
  11260. node.depth = depth;
  11261. return node;
  11262. },
  11263. mathmlBuilder: function mathmlBuilder(group, options) {
  11264. var node = new mathMLTree.MathNode("mglyph", []);
  11265. node.setAttribute("alt", group.alt);
  11266. var height = calculateSize(group.height, options);
  11267. var depth = 0;
  11268. if (group.totalheight.number > 0) {
  11269. depth = calculateSize(group.totalheight, options) - height;
  11270. node.setAttribute("valign", makeEm(-depth));
  11271. }
  11272. node.setAttribute("height", makeEm(height + depth));
  11273. if (group.width.number > 0) {
  11274. var width = calculateSize(group.width, options);
  11275. node.setAttribute("width", makeEm(width));
  11276. }
  11277. node.setAttribute("src", group.src);
  11278. return node;
  11279. }
  11280. });
  11281. ;// CONCATENATED MODULE: ./src/functions/kern.js
  11282. // Horizontal spacing commands
  11283. // TODO: \hskip and \mskip should support plus and minus in lengths
  11284. defineFunction({
  11285. type: "kern",
  11286. names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"],
  11287. props: {
  11288. numArgs: 1,
  11289. argTypes: ["size"],
  11290. primitive: true,
  11291. allowedInText: true
  11292. },
  11293. handler: function handler(_ref, args) {
  11294. var parser = _ref.parser,
  11295. funcName = _ref.funcName;
  11296. var size = assertNodeType(args[0], "size");
  11297. if (parser.settings.strict) {
  11298. var mathFunction = funcName[1] === 'm'; // \mkern, \mskip
  11299. var muUnit = size.value.unit === 'mu';
  11300. if (mathFunction) {
  11301. if (!muUnit) {
  11302. parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " supports only mu units, " + ("not " + size.value.unit + " units"));
  11303. }
  11304. if (parser.mode !== "math") {
  11305. parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " works only in math mode");
  11306. }
  11307. } else {
  11308. // !mathFunction
  11309. if (muUnit) {
  11310. parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " doesn't support mu units");
  11311. }
  11312. }
  11313. }
  11314. return {
  11315. type: "kern",
  11316. mode: parser.mode,
  11317. dimension: size.value
  11318. };
  11319. },
  11320. htmlBuilder: function htmlBuilder(group, options) {
  11321. return buildCommon.makeGlue(group.dimension, options);
  11322. },
  11323. mathmlBuilder: function mathmlBuilder(group, options) {
  11324. var dimension = calculateSize(group.dimension, options);
  11325. return new mathMLTree.SpaceNode(dimension);
  11326. }
  11327. });
  11328. ;// CONCATENATED MODULE: ./src/functions/lap.js
  11329. // Horizontal overlap functions
  11330. defineFunction({
  11331. type: "lap",
  11332. names: ["\\mathllap", "\\mathrlap", "\\mathclap"],
  11333. props: {
  11334. numArgs: 1,
  11335. allowedInText: true
  11336. },
  11337. handler: function handler(_ref, args) {
  11338. var parser = _ref.parser,
  11339. funcName = _ref.funcName;
  11340. var body = args[0];
  11341. return {
  11342. type: "lap",
  11343. mode: parser.mode,
  11344. alignment: funcName.slice(5),
  11345. body: body
  11346. };
  11347. },
  11348. htmlBuilder: function htmlBuilder(group, options) {
  11349. // mathllap, mathrlap, mathclap
  11350. var inner;
  11351. if (group.alignment === "clap") {
  11352. // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/
  11353. inner = buildCommon.makeSpan([], [buildGroup(group.body, options)]); // wrap, since CSS will center a .clap > .inner > span
  11354. inner = buildCommon.makeSpan(["inner"], [inner], options);
  11355. } else {
  11356. inner = buildCommon.makeSpan(["inner"], [buildGroup(group.body, options)]);
  11357. }
  11358. var fix = buildCommon.makeSpan(["fix"], []);
  11359. var node = buildCommon.makeSpan([group.alignment], [inner, fix], options); // At this point, we have correctly set horizontal alignment of the
  11360. // two items involved in the lap.
  11361. // Next, use a strut to set the height of the HTML bounding box.
  11362. // Otherwise, a tall argument may be misplaced.
  11363. // This code resolved issue #1153
  11364. var strut = buildCommon.makeSpan(["strut"]);
  11365. strut.style.height = makeEm(node.height + node.depth);
  11366. if (node.depth) {
  11367. strut.style.verticalAlign = makeEm(-node.depth);
  11368. }
  11369. node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall.
  11370. // This code resolves issue #1234
  11371. node = buildCommon.makeSpan(["thinbox"], [node], options);
  11372. return buildCommon.makeSpan(["mord", "vbox"], [node], options);
  11373. },
  11374. mathmlBuilder: function mathmlBuilder(group, options) {
  11375. // mathllap, mathrlap, mathclap
  11376. var node = new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]);
  11377. if (group.alignment !== "rlap") {
  11378. var offset = group.alignment === "llap" ? "-1" : "-0.5";
  11379. node.setAttribute("lspace", offset + "width");
  11380. }
  11381. node.setAttribute("width", "0px");
  11382. return node;
  11383. }
  11384. });
  11385. ;// CONCATENATED MODULE: ./src/functions/math.js
  11386. // Switching from text mode back to math mode
  11387. defineFunction({
  11388. type: "styling",
  11389. names: ["\\(", "$"],
  11390. props: {
  11391. numArgs: 0,
  11392. allowedInText: true,
  11393. allowedInMath: false
  11394. },
  11395. handler: function handler(_ref, args) {
  11396. var funcName = _ref.funcName,
  11397. parser = _ref.parser;
  11398. var outerMode = parser.mode;
  11399. parser.switchMode("math");
  11400. var close = funcName === "\\(" ? "\\)" : "$";
  11401. var body = parser.parseExpression(false, close);
  11402. parser.expect(close);
  11403. parser.switchMode(outerMode);
  11404. return {
  11405. type: "styling",
  11406. mode: parser.mode,
  11407. style: "text",
  11408. body: body
  11409. };
  11410. }
  11411. }); // Check for extra closing math delimiters
  11412. defineFunction({
  11413. type: "text",
  11414. // Doesn't matter what this is.
  11415. names: ["\\)", "\\]"],
  11416. props: {
  11417. numArgs: 0,
  11418. allowedInText: true,
  11419. allowedInMath: false
  11420. },
  11421. handler: function handler(context, args) {
  11422. throw new src_ParseError("Mismatched " + context.funcName);
  11423. }
  11424. });
  11425. ;// CONCATENATED MODULE: ./src/functions/mathchoice.js
  11426. var chooseMathStyle = function chooseMathStyle(group, options) {
  11427. switch (options.style.size) {
  11428. case src_Style.DISPLAY.size:
  11429. return group.display;
  11430. case src_Style.TEXT.size:
  11431. return group.text;
  11432. case src_Style.SCRIPT.size:
  11433. return group.script;
  11434. case src_Style.SCRIPTSCRIPT.size:
  11435. return group.scriptscript;
  11436. default:
  11437. return group.text;
  11438. }
  11439. };
  11440. defineFunction({
  11441. type: "mathchoice",
  11442. names: ["\\mathchoice"],
  11443. props: {
  11444. numArgs: 4,
  11445. primitive: true
  11446. },
  11447. handler: function handler(_ref, args) {
  11448. var parser = _ref.parser;
  11449. return {
  11450. type: "mathchoice",
  11451. mode: parser.mode,
  11452. display: ordargument(args[0]),
  11453. text: ordargument(args[1]),
  11454. script: ordargument(args[2]),
  11455. scriptscript: ordargument(args[3])
  11456. };
  11457. },
  11458. htmlBuilder: function htmlBuilder(group, options) {
  11459. var body = chooseMathStyle(group, options);
  11460. var elements = buildExpression(body, options, false);
  11461. return buildCommon.makeFragment(elements);
  11462. },
  11463. mathmlBuilder: function mathmlBuilder(group, options) {
  11464. var body = chooseMathStyle(group, options);
  11465. return buildExpressionRow(body, options);
  11466. }
  11467. });
  11468. ;// CONCATENATED MODULE: ./src/functions/utils/assembleSupSub.js
  11469. // For an operator with limits, assemble the base, sup, and sub into a span.
  11470. var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift) {
  11471. base = buildCommon.makeSpan([], [base]);
  11472. var subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup);
  11473. var sub;
  11474. var sup; // We manually have to handle the superscripts and subscripts. This,
  11475. // aside from the kern calculations, is copied from supsub.
  11476. if (supGroup) {
  11477. var elem = buildGroup(supGroup, options.havingStyle(style.sup()), options);
  11478. sup = {
  11479. elem: elem,
  11480. kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth)
  11481. };
  11482. }
  11483. if (subGroup) {
  11484. var _elem = buildGroup(subGroup, options.havingStyle(style.sub()), options);
  11485. sub = {
  11486. elem: _elem,
  11487. kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - _elem.height)
  11488. };
  11489. } // Build the final group as a vlist of the possible subscript, base,
  11490. // and possible superscript.
  11491. var finalGroup;
  11492. if (sup && sub) {
  11493. var bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift;
  11494. finalGroup = buildCommon.makeVList({
  11495. positionType: "bottom",
  11496. positionData: bottom,
  11497. children: [{
  11498. type: "kern",
  11499. size: options.fontMetrics().bigOpSpacing5
  11500. }, {
  11501. type: "elem",
  11502. elem: sub.elem,
  11503. marginLeft: makeEm(-slant)
  11504. }, {
  11505. type: "kern",
  11506. size: sub.kern
  11507. }, {
  11508. type: "elem",
  11509. elem: base
  11510. }, {
  11511. type: "kern",
  11512. size: sup.kern
  11513. }, {
  11514. type: "elem",
  11515. elem: sup.elem,
  11516. marginLeft: makeEm(slant)
  11517. }, {
  11518. type: "kern",
  11519. size: options.fontMetrics().bigOpSpacing5
  11520. }]
  11521. }, options);
  11522. } else if (sub) {
  11523. var top = base.height - baseShift; // Shift the limits by the slant of the symbol. Note
  11524. // that we are supposed to shift the limits by 1/2 of the slant,
  11525. // but since we are centering the limits adding a full slant of
  11526. // margin will shift by 1/2 that.
  11527. finalGroup = buildCommon.makeVList({
  11528. positionType: "top",
  11529. positionData: top,
  11530. children: [{
  11531. type: "kern",
  11532. size: options.fontMetrics().bigOpSpacing5
  11533. }, {
  11534. type: "elem",
  11535. elem: sub.elem,
  11536. marginLeft: makeEm(-slant)
  11537. }, {
  11538. type: "kern",
  11539. size: sub.kern
  11540. }, {
  11541. type: "elem",
  11542. elem: base
  11543. }]
  11544. }, options);
  11545. } else if (sup) {
  11546. var _bottom = base.depth + baseShift;
  11547. finalGroup = buildCommon.makeVList({
  11548. positionType: "bottom",
  11549. positionData: _bottom,
  11550. children: [{
  11551. type: "elem",
  11552. elem: base
  11553. }, {
  11554. type: "kern",
  11555. size: sup.kern
  11556. }, {
  11557. type: "elem",
  11558. elem: sup.elem,
  11559. marginLeft: makeEm(slant)
  11560. }, {
  11561. type: "kern",
  11562. size: options.fontMetrics().bigOpSpacing5
  11563. }]
  11564. }, options);
  11565. } else {
  11566. // This case probably shouldn't occur (this would mean the
  11567. // supsub was sending us a group with no superscript or
  11568. // subscript) but be safe.
  11569. return base;
  11570. }
  11571. var parts = [finalGroup];
  11572. if (sub && slant !== 0 && !subIsSingleCharacter) {
  11573. // A negative margin-left was applied to the lower limit.
  11574. // Avoid an overlap by placing a spacer on the left on the group.
  11575. var spacer = buildCommon.makeSpan(["mspace"], [], options);
  11576. spacer.style.marginRight = makeEm(slant);
  11577. parts.unshift(spacer);
  11578. }
  11579. return buildCommon.makeSpan(["mop", "op-limits"], parts, options);
  11580. };
  11581. ;// CONCATENATED MODULE: ./src/functions/op.js
  11582. // Limits, symbols
  11583. // Most operators have a large successor symbol, but these don't.
  11584. var noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also
  11585. // "supsub" since some of them (like \int) can affect super/subscripting.
  11586. var op_htmlBuilder = function htmlBuilder(grp, options) {
  11587. // Operators are handled in the TeXbook pg. 443-444, rule 13(a).
  11588. var supGroup;
  11589. var subGroup;
  11590. var hasLimits = false;
  11591. var group;
  11592. if (grp.type === "supsub") {
  11593. // If we have limits, supsub will pass us its group to handle. Pull
  11594. // out the superscript and subscript and set the group to the op in
  11595. // its base.
  11596. supGroup = grp.sup;
  11597. subGroup = grp.sub;
  11598. group = assertNodeType(grp.base, "op");
  11599. hasLimits = true;
  11600. } else {
  11601. group = assertNodeType(grp, "op");
  11602. }
  11603. var style = options.style;
  11604. var large = false;
  11605. if (style.size === src_Style.DISPLAY.size && group.symbol && !utils.contains(noSuccessor, group.name)) {
  11606. // Most symbol operators get larger in displaystyle (rule 13)
  11607. large = true;
  11608. }
  11609. var base;
  11610. if (group.symbol) {
  11611. // If this is a symbol, create the symbol.
  11612. var fontName = large ? "Size2-Regular" : "Size1-Regular";
  11613. var stash = "";
  11614. if (group.name === "\\oiint" || group.name === "\\oiiint") {
  11615. // No font glyphs yet, so use a glyph w/o the oval.
  11616. // TODO: When font glyphs are available, delete this code.
  11617. stash = group.name.slice(1);
  11618. group.name = stash === "oiint" ? "\\iint" : "\\iiint";
  11619. }
  11620. base = buildCommon.makeSymbol(group.name, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]);
  11621. if (stash.length > 0) {
  11622. // We're in \oiint or \oiiint. Overlay the oval.
  11623. // TODO: When font glyphs are available, delete this code.
  11624. var italic = base.italic;
  11625. var oval = buildCommon.staticSvg(stash + "Size" + (large ? "2" : "1"), options);
  11626. base = buildCommon.makeVList({
  11627. positionType: "individualShift",
  11628. children: [{
  11629. type: "elem",
  11630. elem: base,
  11631. shift: 0
  11632. }, {
  11633. type: "elem",
  11634. elem: oval,
  11635. shift: large ? 0.08 : 0
  11636. }]
  11637. }, options);
  11638. group.name = "\\" + stash;
  11639. base.classes.unshift("mop"); // $FlowFixMe
  11640. base.italic = italic;
  11641. }
  11642. } else if (group.body) {
  11643. // If this is a list, compose that list.
  11644. var inner = buildExpression(group.body, options, true);
  11645. if (inner.length === 1 && inner[0] instanceof SymbolNode) {
  11646. base = inner[0];
  11647. base.classes[0] = "mop"; // replace old mclass
  11648. } else {
  11649. base = buildCommon.makeSpan(["mop"], inner, options);
  11650. }
  11651. } else {
  11652. // Otherwise, this is a text operator. Build the text from the
  11653. // operator's name.
  11654. var output = [];
  11655. for (var i = 1; i < group.name.length; i++) {
  11656. output.push(buildCommon.mathsym(group.name[i], group.mode, options));
  11657. }
  11658. base = buildCommon.makeSpan(["mop"], output, options);
  11659. } // If content of op is a single symbol, shift it vertically.
  11660. var baseShift = 0;
  11661. var slant = 0;
  11662. if ((base instanceof SymbolNode || group.name === "\\oiint" || group.name === "\\oiiint") && !group.suppressBaseShift) {
  11663. // We suppress the shift of the base of \overset and \underset. Otherwise,
  11664. // shift the symbol so its center lies on the axis (rule 13). It
  11665. // appears that our fonts have the centers of the symbols already
  11666. // almost on the axis, so these numbers are very small. Note we
  11667. // don't actually apply this here, but instead it is used either in
  11668. // the vlist creation or separately when there are no limits.
  11669. baseShift = (base.height - base.depth) / 2 - options.fontMetrics().axisHeight; // The slant of the symbol is just its italic correction.
  11670. // $FlowFixMe
  11671. slant = base.italic;
  11672. }
  11673. if (hasLimits) {
  11674. return assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift);
  11675. } else {
  11676. if (baseShift) {
  11677. base.style.position = "relative";
  11678. base.style.top = makeEm(baseShift);
  11679. }
  11680. return base;
  11681. }
  11682. };
  11683. var op_mathmlBuilder = function mathmlBuilder(group, options) {
  11684. var node;
  11685. if (group.symbol) {
  11686. // This is a symbol. Just add the symbol.
  11687. node = new MathNode("mo", [makeText(group.name, group.mode)]);
  11688. if (utils.contains(noSuccessor, group.name)) {
  11689. node.setAttribute("largeop", "false");
  11690. }
  11691. } else if (group.body) {
  11692. // This is an operator with children. Add them.
  11693. node = new MathNode("mo", buildMathML_buildExpression(group.body, options));
  11694. } else {
  11695. // This is a text operator. Add all of the characters from the
  11696. // operator's name.
  11697. node = new MathNode("mi", [new TextNode(group.name.slice(1))]); // Append an <mo>&ApplyFunction;</mo>.
  11698. // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
  11699. var operator = new MathNode("mo", [makeText("\u2061", "text")]);
  11700. if (group.parentIsSupSub) {
  11701. node = new MathNode("mrow", [node, operator]);
  11702. } else {
  11703. node = newDocumentFragment([node, operator]);
  11704. }
  11705. }
  11706. return node;
  11707. };
  11708. var singleCharBigOps = {
  11709. "\u220F": "\\prod",
  11710. "\u2210": "\\coprod",
  11711. "\u2211": "\\sum",
  11712. "\u22C0": "\\bigwedge",
  11713. "\u22C1": "\\bigvee",
  11714. "\u22C2": "\\bigcap",
  11715. "\u22C3": "\\bigcup",
  11716. "\u2A00": "\\bigodot",
  11717. "\u2A01": "\\bigoplus",
  11718. "\u2A02": "\\bigotimes",
  11719. "\u2A04": "\\biguplus",
  11720. "\u2A06": "\\bigsqcup"
  11721. };
  11722. defineFunction({
  11723. type: "op",
  11724. names: ["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", "\u2210", "\u2211", "\u22C0", "\u22C1", "\u22C2", "\u22C3", "\u2A00", "\u2A01", "\u2A02", "\u2A04", "\u2A06"],
  11725. props: {
  11726. numArgs: 0
  11727. },
  11728. handler: function handler(_ref, args) {
  11729. var parser = _ref.parser,
  11730. funcName = _ref.funcName;
  11731. var fName = funcName;
  11732. if (fName.length === 1) {
  11733. fName = singleCharBigOps[fName];
  11734. }
  11735. return {
  11736. type: "op",
  11737. mode: parser.mode,
  11738. limits: true,
  11739. parentIsSupSub: false,
  11740. symbol: true,
  11741. name: fName
  11742. };
  11743. },
  11744. htmlBuilder: op_htmlBuilder,
  11745. mathmlBuilder: op_mathmlBuilder
  11746. }); // Note: calling defineFunction with a type that's already been defined only
  11747. // works because the same htmlBuilder and mathmlBuilder are being used.
  11748. defineFunction({
  11749. type: "op",
  11750. names: ["\\mathop"],
  11751. props: {
  11752. numArgs: 1,
  11753. primitive: true
  11754. },
  11755. handler: function handler(_ref2, args) {
  11756. var parser = _ref2.parser;
  11757. var body = args[0];
  11758. return {
  11759. type: "op",
  11760. mode: parser.mode,
  11761. limits: false,
  11762. parentIsSupSub: false,
  11763. symbol: false,
  11764. body: ordargument(body)
  11765. };
  11766. },
  11767. htmlBuilder: op_htmlBuilder,
  11768. mathmlBuilder: op_mathmlBuilder
  11769. }); // There are 2 flags for operators; whether they produce limits in
  11770. // displaystyle, and whether they are symbols and should grow in
  11771. // displaystyle. These four groups cover the four possible choices.
  11772. var singleCharIntegrals = {
  11773. "\u222B": "\\int",
  11774. "\u222C": "\\iint",
  11775. "\u222D": "\\iiint",
  11776. "\u222E": "\\oint",
  11777. "\u222F": "\\oiint",
  11778. "\u2230": "\\oiiint"
  11779. }; // No limits, not symbols
  11780. defineFunction({
  11781. type: "op",
  11782. names: ["\\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"],
  11783. props: {
  11784. numArgs: 0
  11785. },
  11786. handler: function handler(_ref3) {
  11787. var parser = _ref3.parser,
  11788. funcName = _ref3.funcName;
  11789. return {
  11790. type: "op",
  11791. mode: parser.mode,
  11792. limits: false,
  11793. parentIsSupSub: false,
  11794. symbol: false,
  11795. name: funcName
  11796. };
  11797. },
  11798. htmlBuilder: op_htmlBuilder,
  11799. mathmlBuilder: op_mathmlBuilder
  11800. }); // Limits, not symbols
  11801. defineFunction({
  11802. type: "op",
  11803. names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"],
  11804. props: {
  11805. numArgs: 0
  11806. },
  11807. handler: function handler(_ref4) {
  11808. var parser = _ref4.parser,
  11809. funcName = _ref4.funcName;
  11810. return {
  11811. type: "op",
  11812. mode: parser.mode,
  11813. limits: true,
  11814. parentIsSupSub: false,
  11815. symbol: false,
  11816. name: funcName
  11817. };
  11818. },
  11819. htmlBuilder: op_htmlBuilder,
  11820. mathmlBuilder: op_mathmlBuilder
  11821. }); // No limits, symbols
  11822. defineFunction({
  11823. type: "op",
  11824. names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222B", "\u222C", "\u222D", "\u222E", "\u222F", "\u2230"],
  11825. props: {
  11826. numArgs: 0
  11827. },
  11828. handler: function handler(_ref5) {
  11829. var parser = _ref5.parser,
  11830. funcName = _ref5.funcName;
  11831. var fName = funcName;
  11832. if (fName.length === 1) {
  11833. fName = singleCharIntegrals[fName];
  11834. }
  11835. return {
  11836. type: "op",
  11837. mode: parser.mode,
  11838. limits: false,
  11839. parentIsSupSub: false,
  11840. symbol: true,
  11841. name: fName
  11842. };
  11843. },
  11844. htmlBuilder: op_htmlBuilder,
  11845. mathmlBuilder: op_mathmlBuilder
  11846. });
  11847. ;// CONCATENATED MODULE: ./src/functions/operatorname.js
  11848. // NOTE: Unlike most `htmlBuilder`s, this one handles not only
  11849. // "operatorname", but also "supsub" since \operatorname* can
  11850. // affect super/subscripting.
  11851. var operatorname_htmlBuilder = function htmlBuilder(grp, options) {
  11852. // Operators are handled in the TeXbook pg. 443-444, rule 13(a).
  11853. var supGroup;
  11854. var subGroup;
  11855. var hasLimits = false;
  11856. var group;
  11857. if (grp.type === "supsub") {
  11858. // If we have limits, supsub will pass us its group to handle. Pull
  11859. // out the superscript and subscript and set the group to the op in
  11860. // its base.
  11861. supGroup = grp.sup;
  11862. subGroup = grp.sub;
  11863. group = assertNodeType(grp.base, "operatorname");
  11864. hasLimits = true;
  11865. } else {
  11866. group = assertNodeType(grp, "operatorname");
  11867. }
  11868. var base;
  11869. if (group.body.length > 0) {
  11870. var body = group.body.map(function (child) {
  11871. // $FlowFixMe: Check if the node has a string `text` property.
  11872. var childText = child.text;
  11873. if (typeof childText === "string") {
  11874. return {
  11875. type: "textord",
  11876. mode: child.mode,
  11877. text: childText
  11878. };
  11879. } else {
  11880. return child;
  11881. }
  11882. }); // Consolidate function names into symbol characters.
  11883. var expression = buildExpression(body, options.withFont("mathrm"), true);
  11884. for (var i = 0; i < expression.length; i++) {
  11885. var child = expression[i];
  11886. if (child instanceof SymbolNode) {
  11887. // Per amsopn package,
  11888. // change minus to hyphen and \ast to asterisk
  11889. child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
  11890. }
  11891. }
  11892. base = buildCommon.makeSpan(["mop"], expression, options);
  11893. } else {
  11894. base = buildCommon.makeSpan(["mop"], [], options);
  11895. }
  11896. if (hasLimits) {
  11897. return assembleSupSub(base, supGroup, subGroup, options, options.style, 0, 0);
  11898. } else {
  11899. return base;
  11900. }
  11901. };
  11902. var operatorname_mathmlBuilder = function mathmlBuilder(group, options) {
  11903. // The steps taken here are similar to the html version.
  11904. var expression = buildMathML_buildExpression(group.body, options.withFont("mathrm")); // Is expression a string or has it something like a fraction?
  11905. var isAllString = true; // default
  11906. for (var i = 0; i < expression.length; i++) {
  11907. var node = expression[i];
  11908. if (node instanceof mathMLTree.SpaceNode) {// Do nothing
  11909. } else if (node instanceof mathMLTree.MathNode) {
  11910. switch (node.type) {
  11911. case "mi":
  11912. case "mn":
  11913. case "ms":
  11914. case "mspace":
  11915. case "mtext":
  11916. break;
  11917. // Do nothing yet.
  11918. case "mo":
  11919. {
  11920. var child = node.children[0];
  11921. if (node.children.length === 1 && child instanceof mathMLTree.TextNode) {
  11922. child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
  11923. } else {
  11924. isAllString = false;
  11925. }
  11926. break;
  11927. }
  11928. default:
  11929. isAllString = false;
  11930. }
  11931. } else {
  11932. isAllString = false;
  11933. }
  11934. }
  11935. if (isAllString) {
  11936. // Write a single TextNode instead of multiple nested tags.
  11937. var word = expression.map(function (node) {
  11938. return node.toText();
  11939. }).join("");
  11940. expression = [new mathMLTree.TextNode(word)];
  11941. }
  11942. var identifier = new mathMLTree.MathNode("mi", expression);
  11943. identifier.setAttribute("mathvariant", "normal"); // \u2061 is the same as &ApplyFunction;
  11944. // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp
  11945. var operator = new mathMLTree.MathNode("mo", [makeText("\u2061", "text")]);
  11946. if (group.parentIsSupSub) {
  11947. return new mathMLTree.MathNode("mrow", [identifier, operator]);
  11948. } else {
  11949. return mathMLTree.newDocumentFragment([identifier, operator]);
  11950. }
  11951. }; // \operatorname
  11952. // amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@
  11953. defineFunction({
  11954. type: "operatorname",
  11955. names: ["\\operatorname@", "\\operatornamewithlimits"],
  11956. props: {
  11957. numArgs: 1
  11958. },
  11959. handler: function handler(_ref, args) {
  11960. var parser = _ref.parser,
  11961. funcName = _ref.funcName;
  11962. var body = args[0];
  11963. return {
  11964. type: "operatorname",
  11965. mode: parser.mode,
  11966. body: ordargument(body),
  11967. alwaysHandleSupSub: funcName === "\\operatornamewithlimits",
  11968. limits: false,
  11969. parentIsSupSub: false
  11970. };
  11971. },
  11972. htmlBuilder: operatorname_htmlBuilder,
  11973. mathmlBuilder: operatorname_mathmlBuilder
  11974. });
  11975. defineMacro("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@");
  11976. ;// CONCATENATED MODULE: ./src/functions/ordgroup.js
  11977. defineFunctionBuilders({
  11978. type: "ordgroup",
  11979. htmlBuilder: function htmlBuilder(group, options) {
  11980. if (group.semisimple) {
  11981. return buildCommon.makeFragment(buildExpression(group.body, options, false));
  11982. }
  11983. return buildCommon.makeSpan(["mord"], buildExpression(group.body, options, true), options);
  11984. },
  11985. mathmlBuilder: function mathmlBuilder(group, options) {
  11986. return buildExpressionRow(group.body, options, true);
  11987. }
  11988. });
  11989. ;// CONCATENATED MODULE: ./src/functions/overline.js
  11990. defineFunction({
  11991. type: "overline",
  11992. names: ["\\overline"],
  11993. props: {
  11994. numArgs: 1
  11995. },
  11996. handler: function handler(_ref, args) {
  11997. var parser = _ref.parser;
  11998. var body = args[0];
  11999. return {
  12000. type: "overline",
  12001. mode: parser.mode,
  12002. body: body
  12003. };
  12004. },
  12005. htmlBuilder: function htmlBuilder(group, options) {
  12006. // Overlines are handled in the TeXbook pg 443, Rule 9.
  12007. // Build the inner group in the cramped style.
  12008. var innerGroup = buildGroup(group.body, options.havingCrampedStyle()); // Create the line above the body
  12009. var line = buildCommon.makeLineSpan("overline-line", options); // Generate the vlist, with the appropriate kerns
  12010. var defaultRuleThickness = options.fontMetrics().defaultRuleThickness;
  12011. var vlist = buildCommon.makeVList({
  12012. positionType: "firstBaseline",
  12013. children: [{
  12014. type: "elem",
  12015. elem: innerGroup
  12016. }, {
  12017. type: "kern",
  12018. size: 3 * defaultRuleThickness
  12019. }, {
  12020. type: "elem",
  12021. elem: line
  12022. }, {
  12023. type: "kern",
  12024. size: defaultRuleThickness
  12025. }]
  12026. }, options);
  12027. return buildCommon.makeSpan(["mord", "overline"], [vlist], options);
  12028. },
  12029. mathmlBuilder: function mathmlBuilder(group, options) {
  12030. var operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203E")]);
  12031. operator.setAttribute("stretchy", "true");
  12032. var node = new mathMLTree.MathNode("mover", [buildMathML_buildGroup(group.body, options), operator]);
  12033. node.setAttribute("accent", "true");
  12034. return node;
  12035. }
  12036. });
  12037. ;// CONCATENATED MODULE: ./src/functions/phantom.js
  12038. defineFunction({
  12039. type: "phantom",
  12040. names: ["\\phantom"],
  12041. props: {
  12042. numArgs: 1,
  12043. allowedInText: true
  12044. },
  12045. handler: function handler(_ref, args) {
  12046. var parser = _ref.parser;
  12047. var body = args[0];
  12048. return {
  12049. type: "phantom",
  12050. mode: parser.mode,
  12051. body: ordargument(body)
  12052. };
  12053. },
  12054. htmlBuilder: function htmlBuilder(group, options) {
  12055. var elements = buildExpression(group.body, options.withPhantom(), false); // \phantom isn't supposed to affect the elements it contains.
  12056. // See "color" for more details.
  12057. return buildCommon.makeFragment(elements);
  12058. },
  12059. mathmlBuilder: function mathmlBuilder(group, options) {
  12060. var inner = buildMathML_buildExpression(group.body, options);
  12061. return new mathMLTree.MathNode("mphantom", inner);
  12062. }
  12063. });
  12064. defineFunction({
  12065. type: "hphantom",
  12066. names: ["\\hphantom"],
  12067. props: {
  12068. numArgs: 1,
  12069. allowedInText: true
  12070. },
  12071. handler: function handler(_ref2, args) {
  12072. var parser = _ref2.parser;
  12073. var body = args[0];
  12074. return {
  12075. type: "hphantom",
  12076. mode: parser.mode,
  12077. body: body
  12078. };
  12079. },
  12080. htmlBuilder: function htmlBuilder(group, options) {
  12081. var node = buildCommon.makeSpan([], [buildGroup(group.body, options.withPhantom())]);
  12082. node.height = 0;
  12083. node.depth = 0;
  12084. if (node.children) {
  12085. for (var i = 0; i < node.children.length; i++) {
  12086. node.children[i].height = 0;
  12087. node.children[i].depth = 0;
  12088. }
  12089. } // See smash for comment re: use of makeVList
  12090. node = buildCommon.makeVList({
  12091. positionType: "firstBaseline",
  12092. children: [{
  12093. type: "elem",
  12094. elem: node
  12095. }]
  12096. }, options); // For spacing, TeX treats \smash as a math group (same spacing as ord).
  12097. return buildCommon.makeSpan(["mord"], [node], options);
  12098. },
  12099. mathmlBuilder: function mathmlBuilder(group, options) {
  12100. var inner = buildMathML_buildExpression(ordargument(group.body), options);
  12101. var phantom = new mathMLTree.MathNode("mphantom", inner);
  12102. var node = new mathMLTree.MathNode("mpadded", [phantom]);
  12103. node.setAttribute("height", "0px");
  12104. node.setAttribute("depth", "0px");
  12105. return node;
  12106. }
  12107. });
  12108. defineFunction({
  12109. type: "vphantom",
  12110. names: ["\\vphantom"],
  12111. props: {
  12112. numArgs: 1,
  12113. allowedInText: true
  12114. },
  12115. handler: function handler(_ref3, args) {
  12116. var parser = _ref3.parser;
  12117. var body = args[0];
  12118. return {
  12119. type: "vphantom",
  12120. mode: parser.mode,
  12121. body: body
  12122. };
  12123. },
  12124. htmlBuilder: function htmlBuilder(group, options) {
  12125. var inner = buildCommon.makeSpan(["inner"], [buildGroup(group.body, options.withPhantom())]);
  12126. var fix = buildCommon.makeSpan(["fix"], []);
  12127. return buildCommon.makeSpan(["mord", "rlap"], [inner, fix], options);
  12128. },
  12129. mathmlBuilder: function mathmlBuilder(group, options) {
  12130. var inner = buildMathML_buildExpression(ordargument(group.body), options);
  12131. var phantom = new mathMLTree.MathNode("mphantom", inner);
  12132. var node = new mathMLTree.MathNode("mpadded", [phantom]);
  12133. node.setAttribute("width", "0px");
  12134. return node;
  12135. }
  12136. });
  12137. ;// CONCATENATED MODULE: ./src/functions/raisebox.js
  12138. // Box manipulation
  12139. defineFunction({
  12140. type: "raisebox",
  12141. names: ["\\raisebox"],
  12142. props: {
  12143. numArgs: 2,
  12144. argTypes: ["size", "hbox"],
  12145. allowedInText: true
  12146. },
  12147. handler: function handler(_ref, args) {
  12148. var parser = _ref.parser;
  12149. var amount = assertNodeType(args[0], "size").value;
  12150. var body = args[1];
  12151. return {
  12152. type: "raisebox",
  12153. mode: parser.mode,
  12154. dy: amount,
  12155. body: body
  12156. };
  12157. },
  12158. htmlBuilder: function htmlBuilder(group, options) {
  12159. var body = buildGroup(group.body, options);
  12160. var dy = calculateSize(group.dy, options);
  12161. return buildCommon.makeVList({
  12162. positionType: "shift",
  12163. positionData: -dy,
  12164. children: [{
  12165. type: "elem",
  12166. elem: body
  12167. }]
  12168. }, options);
  12169. },
  12170. mathmlBuilder: function mathmlBuilder(group, options) {
  12171. var node = new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]);
  12172. var dy = group.dy.number + group.dy.unit;
  12173. node.setAttribute("voffset", dy);
  12174. return node;
  12175. }
  12176. });
  12177. ;// CONCATENATED MODULE: ./src/functions/relax.js
  12178. defineFunction({
  12179. type: "internal",
  12180. names: ["\\relax"],
  12181. props: {
  12182. numArgs: 0,
  12183. allowedInText: true
  12184. },
  12185. handler: function handler(_ref) {
  12186. var parser = _ref.parser;
  12187. return {
  12188. type: "internal",
  12189. mode: parser.mode
  12190. };
  12191. }
  12192. });
  12193. ;// CONCATENATED MODULE: ./src/functions/rule.js
  12194. defineFunction({
  12195. type: "rule",
  12196. names: ["\\rule"],
  12197. props: {
  12198. numArgs: 2,
  12199. numOptionalArgs: 1,
  12200. argTypes: ["size", "size", "size"]
  12201. },
  12202. handler: function handler(_ref, args, optArgs) {
  12203. var parser = _ref.parser;
  12204. var shift = optArgs[0];
  12205. var width = assertNodeType(args[0], "size");
  12206. var height = assertNodeType(args[1], "size");
  12207. return {
  12208. type: "rule",
  12209. mode: parser.mode,
  12210. shift: shift && assertNodeType(shift, "size").value,
  12211. width: width.value,
  12212. height: height.value
  12213. };
  12214. },
  12215. htmlBuilder: function htmlBuilder(group, options) {
  12216. // Make an empty span for the rule
  12217. var rule = buildCommon.makeSpan(["mord", "rule"], [], options); // Calculate the shift, width, and height of the rule, and account for units
  12218. var width = calculateSize(group.width, options);
  12219. var height = calculateSize(group.height, options);
  12220. var shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size
  12221. rule.style.borderRightWidth = makeEm(width);
  12222. rule.style.borderTopWidth = makeEm(height);
  12223. rule.style.bottom = makeEm(shift); // Record the height and width
  12224. rule.width = width;
  12225. rule.height = height + shift;
  12226. rule.depth = -shift; // Font size is the number large enough that the browser will
  12227. // reserve at least `absHeight` space above the baseline.
  12228. // The 1.125 factor was empirically determined
  12229. rule.maxFontSize = height * 1.125 * options.sizeMultiplier;
  12230. return rule;
  12231. },
  12232. mathmlBuilder: function mathmlBuilder(group, options) {
  12233. var width = calculateSize(group.width, options);
  12234. var height = calculateSize(group.height, options);
  12235. var shift = group.shift ? calculateSize(group.shift, options) : 0;
  12236. var color = options.color && options.getColor() || "black";
  12237. var rule = new mathMLTree.MathNode("mspace");
  12238. rule.setAttribute("mathbackground", color);
  12239. rule.setAttribute("width", makeEm(width));
  12240. rule.setAttribute("height", makeEm(height));
  12241. var wrapper = new mathMLTree.MathNode("mpadded", [rule]);
  12242. if (shift >= 0) {
  12243. wrapper.setAttribute("height", makeEm(shift));
  12244. } else {
  12245. wrapper.setAttribute("height", makeEm(shift));
  12246. wrapper.setAttribute("depth", makeEm(-shift));
  12247. }
  12248. wrapper.setAttribute("voffset", makeEm(shift));
  12249. return wrapper;
  12250. }
  12251. });
  12252. ;// CONCATENATED MODULE: ./src/functions/sizing.js
  12253. function sizingGroup(value, options, baseOptions) {
  12254. var inner = buildExpression(value, options, false);
  12255. var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize
  12256. // manually. Handle nested size changes.
  12257. for (var i = 0; i < inner.length; i++) {
  12258. var pos = inner[i].classes.indexOf("sizing");
  12259. if (pos < 0) {
  12260. Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions));
  12261. } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) {
  12262. // This is a nested size change: e.g., inner[i] is the "b" in
  12263. // `\Huge a \small b`. Override the old size (the `reset-` class)
  12264. // but not the new size.
  12265. inner[i].classes[pos + 1] = "reset-size" + baseOptions.size;
  12266. }
  12267. inner[i].height *= multiplier;
  12268. inner[i].depth *= multiplier;
  12269. }
  12270. return buildCommon.makeFragment(inner);
  12271. }
  12272. var sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"];
  12273. var sizing_htmlBuilder = function htmlBuilder(group, options) {
  12274. // Handle sizing operators like \Huge. Real TeX doesn't actually allow
  12275. // these functions inside of math expressions, so we do some special
  12276. // handling.
  12277. var newOptions = options.havingSize(group.size);
  12278. return sizingGroup(group.body, newOptions, options);
  12279. };
  12280. defineFunction({
  12281. type: "sizing",
  12282. names: sizeFuncs,
  12283. props: {
  12284. numArgs: 0,
  12285. allowedInText: true
  12286. },
  12287. handler: function handler(_ref, args) {
  12288. var breakOnTokenText = _ref.breakOnTokenText,
  12289. funcName = _ref.funcName,
  12290. parser = _ref.parser;
  12291. var body = parser.parseExpression(false, breakOnTokenText);
  12292. return {
  12293. type: "sizing",
  12294. mode: parser.mode,
  12295. // Figure out what size to use based on the list of functions above
  12296. size: sizeFuncs.indexOf(funcName) + 1,
  12297. body: body
  12298. };
  12299. },
  12300. htmlBuilder: sizing_htmlBuilder,
  12301. mathmlBuilder: function mathmlBuilder(group, options) {
  12302. var newOptions = options.havingSize(group.size);
  12303. var inner = buildMathML_buildExpression(group.body, newOptions);
  12304. var node = new mathMLTree.MathNode("mstyle", inner); // TODO(emily): This doesn't produce the correct size for nested size
  12305. // changes, because we don't keep state of what style we're currently
  12306. // in, so we can't reset the size to normal before changing it. Now
  12307. // that we're passing an options parameter we should be able to fix
  12308. // this.
  12309. node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier));
  12310. return node;
  12311. }
  12312. });
  12313. ;// CONCATENATED MODULE: ./src/functions/smash.js
  12314. // smash, with optional [tb], as in AMS
  12315. defineFunction({
  12316. type: "smash",
  12317. names: ["\\smash"],
  12318. props: {
  12319. numArgs: 1,
  12320. numOptionalArgs: 1,
  12321. allowedInText: true
  12322. },
  12323. handler: function handler(_ref, args, optArgs) {
  12324. var parser = _ref.parser;
  12325. var smashHeight = false;
  12326. var smashDepth = false;
  12327. var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup");
  12328. if (tbArg) {
  12329. // Optional [tb] argument is engaged.
  12330. // ref: amsmath: \renewcommand{\smash}[1][tb]{%
  12331. // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}%
  12332. var letter = "";
  12333. for (var i = 0; i < tbArg.body.length; ++i) {
  12334. var node = tbArg.body[i]; // $FlowFixMe: Not every node type has a `text` property.
  12335. letter = node.text;
  12336. if (letter === "t") {
  12337. smashHeight = true;
  12338. } else if (letter === "b") {
  12339. smashDepth = true;
  12340. } else {
  12341. smashHeight = false;
  12342. smashDepth = false;
  12343. break;
  12344. }
  12345. }
  12346. } else {
  12347. smashHeight = true;
  12348. smashDepth = true;
  12349. }
  12350. var body = args[0];
  12351. return {
  12352. type: "smash",
  12353. mode: parser.mode,
  12354. body: body,
  12355. smashHeight: smashHeight,
  12356. smashDepth: smashDepth
  12357. };
  12358. },
  12359. htmlBuilder: function htmlBuilder(group, options) {
  12360. var node = buildCommon.makeSpan([], [buildGroup(group.body, options)]);
  12361. if (!group.smashHeight && !group.smashDepth) {
  12362. return node;
  12363. }
  12364. if (group.smashHeight) {
  12365. node.height = 0; // In order to influence makeVList, we have to reset the children.
  12366. if (node.children) {
  12367. for (var i = 0; i < node.children.length; i++) {
  12368. node.children[i].height = 0;
  12369. }
  12370. }
  12371. }
  12372. if (group.smashDepth) {
  12373. node.depth = 0;
  12374. if (node.children) {
  12375. for (var _i = 0; _i < node.children.length; _i++) {
  12376. node.children[_i].depth = 0;
  12377. }
  12378. }
  12379. } // At this point, we've reset the TeX-like height and depth values.
  12380. // But the span still has an HTML line height.
  12381. // makeVList applies "display: table-cell", which prevents the browser
  12382. // from acting on that line height. So we'll call makeVList now.
  12383. var smashedNode = buildCommon.makeVList({
  12384. positionType: "firstBaseline",
  12385. children: [{
  12386. type: "elem",
  12387. elem: node
  12388. }]
  12389. }, options); // For spacing, TeX treats \hphantom as a math group (same spacing as ord).
  12390. return buildCommon.makeSpan(["mord"], [smashedNode], options);
  12391. },
  12392. mathmlBuilder: function mathmlBuilder(group, options) {
  12393. var node = new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]);
  12394. if (group.smashHeight) {
  12395. node.setAttribute("height", "0px");
  12396. }
  12397. if (group.smashDepth) {
  12398. node.setAttribute("depth", "0px");
  12399. }
  12400. return node;
  12401. }
  12402. });
  12403. ;// CONCATENATED MODULE: ./src/functions/sqrt.js
  12404. defineFunction({
  12405. type: "sqrt",
  12406. names: ["\\sqrt"],
  12407. props: {
  12408. numArgs: 1,
  12409. numOptionalArgs: 1
  12410. },
  12411. handler: function handler(_ref, args, optArgs) {
  12412. var parser = _ref.parser;
  12413. var index = optArgs[0];
  12414. var body = args[0];
  12415. return {
  12416. type: "sqrt",
  12417. mode: parser.mode,
  12418. body: body,
  12419. index: index
  12420. };
  12421. },
  12422. htmlBuilder: function htmlBuilder(group, options) {
  12423. // Square roots are handled in the TeXbook pg. 443, Rule 11.
  12424. // First, we do the same steps as in overline to build the inner group
  12425. // and line
  12426. var inner = buildGroup(group.body, options.havingCrampedStyle());
  12427. if (inner.height === 0) {
  12428. // Render a small surd.
  12429. inner.height = options.fontMetrics().xHeight;
  12430. } // Some groups can return document fragments. Handle those by wrapping
  12431. // them in a span.
  12432. inner = buildCommon.wrapFragment(inner, options); // Calculate the minimum size for the \surd delimiter
  12433. var metrics = options.fontMetrics();
  12434. var theta = metrics.defaultRuleThickness;
  12435. var phi = theta;
  12436. if (options.style.id < src_Style.TEXT.id) {
  12437. phi = options.fontMetrics().xHeight;
  12438. } // Calculate the clearance between the body and line
  12439. var lineClearance = theta + phi / 4;
  12440. var minDelimiterHeight = inner.height + inner.depth + lineClearance + theta; // Create a sqrt SVG of the required minimum size
  12441. var _delimiter$sqrtImage = delimiter.sqrtImage(minDelimiterHeight, options),
  12442. img = _delimiter$sqrtImage.span,
  12443. ruleWidth = _delimiter$sqrtImage.ruleWidth,
  12444. advanceWidth = _delimiter$sqrtImage.advanceWidth;
  12445. var delimDepth = img.height - ruleWidth; // Adjust the clearance based on the delimiter size
  12446. if (delimDepth > inner.height + inner.depth + lineClearance) {
  12447. lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2;
  12448. } // Shift the sqrt image
  12449. var imgShift = img.height - inner.height - lineClearance - ruleWidth;
  12450. inner.style.paddingLeft = makeEm(advanceWidth); // Overlay the image and the argument.
  12451. var body = buildCommon.makeVList({
  12452. positionType: "firstBaseline",
  12453. children: [{
  12454. type: "elem",
  12455. elem: inner,
  12456. wrapperClasses: ["svg-align"]
  12457. }, {
  12458. type: "kern",
  12459. size: -(inner.height + imgShift)
  12460. }, {
  12461. type: "elem",
  12462. elem: img
  12463. }, {
  12464. type: "kern",
  12465. size: ruleWidth
  12466. }]
  12467. }, options);
  12468. if (!group.index) {
  12469. return buildCommon.makeSpan(["mord", "sqrt"], [body], options);
  12470. } else {
  12471. // Handle the optional root index
  12472. // The index is always in scriptscript style
  12473. var newOptions = options.havingStyle(src_Style.SCRIPTSCRIPT);
  12474. var rootm = buildGroup(group.index, newOptions, options); // The amount the index is shifted by. This is taken from the TeX
  12475. // source, in the definition of `\r@@t`.
  12476. var toShift = 0.6 * (body.height - body.depth); // Build a VList with the superscript shifted up correctly
  12477. var rootVList = buildCommon.makeVList({
  12478. positionType: "shift",
  12479. positionData: -toShift,
  12480. children: [{
  12481. type: "elem",
  12482. elem: rootm
  12483. }]
  12484. }, options); // Add a class surrounding it so we can add on the appropriate
  12485. // kerning
  12486. var rootVListWrap = buildCommon.makeSpan(["root"], [rootVList]);
  12487. return buildCommon.makeSpan(["mord", "sqrt"], [rootVListWrap, body], options);
  12488. }
  12489. },
  12490. mathmlBuilder: function mathmlBuilder(group, options) {
  12491. var body = group.body,
  12492. index = group.index;
  12493. return index ? new mathMLTree.MathNode("mroot", [buildMathML_buildGroup(body, options), buildMathML_buildGroup(index, options)]) : new mathMLTree.MathNode("msqrt", [buildMathML_buildGroup(body, options)]);
  12494. }
  12495. });
  12496. ;// CONCATENATED MODULE: ./src/functions/styling.js
  12497. var styling_styleMap = {
  12498. "display": src_Style.DISPLAY,
  12499. "text": src_Style.TEXT,
  12500. "script": src_Style.SCRIPT,
  12501. "scriptscript": src_Style.SCRIPTSCRIPT
  12502. };
  12503. defineFunction({
  12504. type: "styling",
  12505. names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"],
  12506. props: {
  12507. numArgs: 0,
  12508. allowedInText: true,
  12509. primitive: true
  12510. },
  12511. handler: function handler(_ref, args) {
  12512. var breakOnTokenText = _ref.breakOnTokenText,
  12513. funcName = _ref.funcName,
  12514. parser = _ref.parser;
  12515. // parse out the implicit body
  12516. var body = parser.parseExpression(true, breakOnTokenText); // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g.
  12517. // here and in buildHTML and de-dupe the enumeration of all the styles).
  12518. // $FlowFixMe: The names above exactly match the styles.
  12519. var style = funcName.slice(1, funcName.length - 5);
  12520. return {
  12521. type: "styling",
  12522. mode: parser.mode,
  12523. // Figure out what style to use by pulling out the style from
  12524. // the function name
  12525. style: style,
  12526. body: body
  12527. };
  12528. },
  12529. htmlBuilder: function htmlBuilder(group, options) {
  12530. // Style changes are handled in the TeXbook on pg. 442, Rule 3.
  12531. var newStyle = styling_styleMap[group.style];
  12532. var newOptions = options.havingStyle(newStyle).withFont('');
  12533. return sizingGroup(group.body, newOptions, options);
  12534. },
  12535. mathmlBuilder: function mathmlBuilder(group, options) {
  12536. // Figure out what style we're changing to.
  12537. var newStyle = styling_styleMap[group.style];
  12538. var newOptions = options.havingStyle(newStyle);
  12539. var inner = buildMathML_buildExpression(group.body, newOptions);
  12540. var node = new mathMLTree.MathNode("mstyle", inner);
  12541. var styleAttributes = {
  12542. "display": ["0", "true"],
  12543. "text": ["0", "false"],
  12544. "script": ["1", "false"],
  12545. "scriptscript": ["2", "false"]
  12546. };
  12547. var attr = styleAttributes[group.style];
  12548. node.setAttribute("scriptlevel", attr[0]);
  12549. node.setAttribute("displaystyle", attr[1]);
  12550. return node;
  12551. }
  12552. });
  12553. ;// CONCATENATED MODULE: ./src/functions/supsub.js
  12554. /**
  12555. * Sometimes, groups perform special rules when they have superscripts or
  12556. * subscripts attached to them. This function lets the `supsub` group know that
  12557. * Sometimes, groups perform special rules when they have superscripts or
  12558. * its inner element should handle the superscripts and subscripts instead of
  12559. * handling them itself.
  12560. */
  12561. var htmlBuilderDelegate = function htmlBuilderDelegate(group, options) {
  12562. var base = group.base;
  12563. if (!base) {
  12564. return null;
  12565. } else if (base.type === "op") {
  12566. // Operators handle supsubs differently when they have limits
  12567. // (e.g. `\displaystyle\sum_2^3`)
  12568. var delegate = base.limits && (options.style.size === src_Style.DISPLAY.size || base.alwaysHandleSupSub);
  12569. return delegate ? op_htmlBuilder : null;
  12570. } else if (base.type === "operatorname") {
  12571. var _delegate = base.alwaysHandleSupSub && (options.style.size === src_Style.DISPLAY.size || base.limits);
  12572. return _delegate ? operatorname_htmlBuilder : null;
  12573. } else if (base.type === "accent") {
  12574. return utils.isCharacterBox(base.base) ? htmlBuilder : null;
  12575. } else if (base.type === "horizBrace") {
  12576. var isSup = !group.sub;
  12577. return isSup === base.isOver ? horizBrace_htmlBuilder : null;
  12578. } else {
  12579. return null;
  12580. }
  12581. }; // Super scripts and subscripts, whose precise placement can depend on other
  12582. // functions that precede them.
  12583. defineFunctionBuilders({
  12584. type: "supsub",
  12585. htmlBuilder: function htmlBuilder(group, options) {
  12586. // Superscript and subscripts are handled in the TeXbook on page
  12587. // 445-446, rules 18(a-f).
  12588. // Here is where we defer to the inner group if it should handle
  12589. // superscripts and subscripts itself.
  12590. var builderDelegate = htmlBuilderDelegate(group, options);
  12591. if (builderDelegate) {
  12592. return builderDelegate(group, options);
  12593. }
  12594. var valueBase = group.base,
  12595. valueSup = group.sup,
  12596. valueSub = group.sub;
  12597. var base = buildGroup(valueBase, options);
  12598. var supm;
  12599. var subm;
  12600. var metrics = options.fontMetrics(); // Rule 18a
  12601. var supShift = 0;
  12602. var subShift = 0;
  12603. var isCharacterBox = valueBase && utils.isCharacterBox(valueBase);
  12604. if (valueSup) {
  12605. var newOptions = options.havingStyle(options.style.sup());
  12606. supm = buildGroup(valueSup, newOptions, options);
  12607. if (!isCharacterBox) {
  12608. supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier;
  12609. }
  12610. }
  12611. if (valueSub) {
  12612. var _newOptions = options.havingStyle(options.style.sub());
  12613. subm = buildGroup(valueSub, _newOptions, options);
  12614. if (!isCharacterBox) {
  12615. subShift = base.depth + _newOptions.fontMetrics().subDrop * _newOptions.sizeMultiplier / options.sizeMultiplier;
  12616. }
  12617. } // Rule 18c
  12618. var minSupShift;
  12619. if (options.style === src_Style.DISPLAY) {
  12620. minSupShift = metrics.sup1;
  12621. } else if (options.style.cramped) {
  12622. minSupShift = metrics.sup3;
  12623. } else {
  12624. minSupShift = metrics.sup2;
  12625. } // scriptspace is a font-size-independent size, so scale it
  12626. // appropriately for use as the marginRight.
  12627. var multiplier = options.sizeMultiplier;
  12628. var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier);
  12629. var marginLeft = null;
  12630. if (subm) {
  12631. // Subscripts shouldn't be shifted by the base's italic correction.
  12632. // Account for that by shifting the subscript back the appropriate
  12633. // amount. Note we only do this when the base is a single symbol.
  12634. var isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint");
  12635. if (base instanceof SymbolNode || isOiint) {
  12636. // $FlowFixMe
  12637. marginLeft = makeEm(-base.italic);
  12638. }
  12639. }
  12640. var supsub;
  12641. if (supm && subm) {
  12642. supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight);
  12643. subShift = Math.max(subShift, metrics.sub2);
  12644. var ruleWidth = metrics.defaultRuleThickness; // Rule 18e
  12645. var maxWidth = 4 * ruleWidth;
  12646. if (supShift - supm.depth - (subm.height - subShift) < maxWidth) {
  12647. subShift = maxWidth - (supShift - supm.depth) + subm.height;
  12648. var psi = 0.8 * metrics.xHeight - (supShift - supm.depth);
  12649. if (psi > 0) {
  12650. supShift += psi;
  12651. subShift -= psi;
  12652. }
  12653. }
  12654. var vlistElem = [{
  12655. type: "elem",
  12656. elem: subm,
  12657. shift: subShift,
  12658. marginRight: marginRight,
  12659. marginLeft: marginLeft
  12660. }, {
  12661. type: "elem",
  12662. elem: supm,
  12663. shift: -supShift,
  12664. marginRight: marginRight
  12665. }];
  12666. supsub = buildCommon.makeVList({
  12667. positionType: "individualShift",
  12668. children: vlistElem
  12669. }, options);
  12670. } else if (subm) {
  12671. // Rule 18b
  12672. subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight);
  12673. var _vlistElem = [{
  12674. type: "elem",
  12675. elem: subm,
  12676. marginLeft: marginLeft,
  12677. marginRight: marginRight
  12678. }];
  12679. supsub = buildCommon.makeVList({
  12680. positionType: "shift",
  12681. positionData: subShift,
  12682. children: _vlistElem
  12683. }, options);
  12684. } else if (supm) {
  12685. // Rule 18c, d
  12686. supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight);
  12687. supsub = buildCommon.makeVList({
  12688. positionType: "shift",
  12689. positionData: -supShift,
  12690. children: [{
  12691. type: "elem",
  12692. elem: supm,
  12693. marginRight: marginRight
  12694. }]
  12695. }, options);
  12696. } else {
  12697. throw new Error("supsub must have either sup or sub.");
  12698. } // Wrap the supsub vlist in a span.msupsub to reset text-align.
  12699. var mclass = getTypeOfDomTree(base, "right") || "mord";
  12700. return buildCommon.makeSpan([mclass], [base, buildCommon.makeSpan(["msupsub"], [supsub])], options);
  12701. },
  12702. mathmlBuilder: function mathmlBuilder(group, options) {
  12703. // Is the inner group a relevant horizonal brace?
  12704. var isBrace = false;
  12705. var isOver;
  12706. var isSup;
  12707. if (group.base && group.base.type === "horizBrace") {
  12708. isSup = !!group.sup;
  12709. if (isSup === group.base.isOver) {
  12710. isBrace = true;
  12711. isOver = group.base.isOver;
  12712. }
  12713. }
  12714. if (group.base && (group.base.type === "op" || group.base.type === "operatorname")) {
  12715. group.base.parentIsSupSub = true;
  12716. }
  12717. var children = [buildMathML_buildGroup(group.base, options)];
  12718. if (group.sub) {
  12719. children.push(buildMathML_buildGroup(group.sub, options));
  12720. }
  12721. if (group.sup) {
  12722. children.push(buildMathML_buildGroup(group.sup, options));
  12723. }
  12724. var nodeType;
  12725. if (isBrace) {
  12726. nodeType = isOver ? "mover" : "munder";
  12727. } else if (!group.sub) {
  12728. var base = group.base;
  12729. if (base && base.type === "op" && base.limits && (options.style === src_Style.DISPLAY || base.alwaysHandleSupSub)) {
  12730. nodeType = "mover";
  12731. } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === src_Style.DISPLAY)) {
  12732. nodeType = "mover";
  12733. } else {
  12734. nodeType = "msup";
  12735. }
  12736. } else if (!group.sup) {
  12737. var _base = group.base;
  12738. if (_base && _base.type === "op" && _base.limits && (options.style === src_Style.DISPLAY || _base.alwaysHandleSupSub)) {
  12739. nodeType = "munder";
  12740. } else if (_base && _base.type === "operatorname" && _base.alwaysHandleSupSub && (_base.limits || options.style === src_Style.DISPLAY)) {
  12741. nodeType = "munder";
  12742. } else {
  12743. nodeType = "msub";
  12744. }
  12745. } else {
  12746. var _base2 = group.base;
  12747. if (_base2 && _base2.type === "op" && _base2.limits && options.style === src_Style.DISPLAY) {
  12748. nodeType = "munderover";
  12749. } else if (_base2 && _base2.type === "operatorname" && _base2.alwaysHandleSupSub && (options.style === src_Style.DISPLAY || _base2.limits)) {
  12750. nodeType = "munderover";
  12751. } else {
  12752. nodeType = "msubsup";
  12753. }
  12754. }
  12755. return new mathMLTree.MathNode(nodeType, children);
  12756. }
  12757. });
  12758. ;// CONCATENATED MODULE: ./src/functions/symbolsOp.js
  12759. // Operator ParseNodes created in Parser.js from symbol Groups in src/symbols.js.
  12760. defineFunctionBuilders({
  12761. type: "atom",
  12762. htmlBuilder: function htmlBuilder(group, options) {
  12763. return buildCommon.mathsym(group.text, group.mode, options, ["m" + group.family]);
  12764. },
  12765. mathmlBuilder: function mathmlBuilder(group, options) {
  12766. var node = new mathMLTree.MathNode("mo", [makeText(group.text, group.mode)]);
  12767. if (group.family === "bin") {
  12768. var variant = getVariant(group, options);
  12769. if (variant === "bold-italic") {
  12770. node.setAttribute("mathvariant", variant);
  12771. }
  12772. } else if (group.family === "punct") {
  12773. node.setAttribute("separator", "true");
  12774. } else if (group.family === "open" || group.family === "close") {
  12775. // Delims built here should not stretch vertically.
  12776. // See delimsizing.js for stretchy delims.
  12777. node.setAttribute("stretchy", "false");
  12778. }
  12779. return node;
  12780. }
  12781. });
  12782. ;// CONCATENATED MODULE: ./src/functions/symbolsOrd.js
  12783. // "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in
  12784. // src/symbols.js.
  12785. var defaultVariant = {
  12786. "mi": "italic",
  12787. "mn": "normal",
  12788. "mtext": "normal"
  12789. };
  12790. defineFunctionBuilders({
  12791. type: "mathord",
  12792. htmlBuilder: function htmlBuilder(group, options) {
  12793. return buildCommon.makeOrd(group, options, "mathord");
  12794. },
  12795. mathmlBuilder: function mathmlBuilder(group, options) {
  12796. var node = new mathMLTree.MathNode("mi", [makeText(group.text, group.mode, options)]);
  12797. var variant = getVariant(group, options) || "italic";
  12798. if (variant !== defaultVariant[node.type]) {
  12799. node.setAttribute("mathvariant", variant);
  12800. }
  12801. return node;
  12802. }
  12803. });
  12804. defineFunctionBuilders({
  12805. type: "textord",
  12806. htmlBuilder: function htmlBuilder(group, options) {
  12807. return buildCommon.makeOrd(group, options, "textord");
  12808. },
  12809. mathmlBuilder: function mathmlBuilder(group, options) {
  12810. var text = makeText(group.text, group.mode, options);
  12811. var variant = getVariant(group, options) || "normal";
  12812. var node;
  12813. if (group.mode === 'text') {
  12814. node = new mathMLTree.MathNode("mtext", [text]);
  12815. } else if (/[0-9]/.test(group.text)) {
  12816. node = new mathMLTree.MathNode("mn", [text]);
  12817. } else if (group.text === "\\prime") {
  12818. node = new mathMLTree.MathNode("mo", [text]);
  12819. } else {
  12820. node = new mathMLTree.MathNode("mi", [text]);
  12821. }
  12822. if (variant !== defaultVariant[node.type]) {
  12823. node.setAttribute("mathvariant", variant);
  12824. }
  12825. return node;
  12826. }
  12827. });
  12828. ;// CONCATENATED MODULE: ./src/functions/symbolsSpacing.js
  12829. // A map of CSS-based spacing functions to their CSS class.
  12830. var cssSpace = {
  12831. "\\nobreak": "nobreak",
  12832. "\\allowbreak": "allowbreak"
  12833. }; // A lookup table to determine whether a spacing function/symbol should be
  12834. // treated like a regular space character. If a symbol or command is a key
  12835. // in this table, then it should be a regular space character. Furthermore,
  12836. // the associated value may have a `className` specifying an extra CSS class
  12837. // to add to the created `span`.
  12838. var regularSpace = {
  12839. " ": {},
  12840. "\\ ": {},
  12841. "~": {
  12842. className: "nobreak"
  12843. },
  12844. "\\space": {},
  12845. "\\nobreakspace": {
  12846. className: "nobreak"
  12847. }
  12848. }; // ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in
  12849. // src/symbols.js.
  12850. defineFunctionBuilders({
  12851. type: "spacing",
  12852. htmlBuilder: function htmlBuilder(group, options) {
  12853. if (regularSpace.hasOwnProperty(group.text)) {
  12854. var className = regularSpace[group.text].className || ""; // Spaces are generated by adding an actual space. Each of these
  12855. // things has an entry in the symbols table, so these will be turned
  12856. // into appropriate outputs.
  12857. if (group.mode === "text") {
  12858. var ord = buildCommon.makeOrd(group, options, "textord");
  12859. ord.classes.push(className);
  12860. return ord;
  12861. } else {
  12862. return buildCommon.makeSpan(["mspace", className], [buildCommon.mathsym(group.text, group.mode, options)], options);
  12863. }
  12864. } else if (cssSpace.hasOwnProperty(group.text)) {
  12865. // Spaces based on just a CSS class.
  12866. return buildCommon.makeSpan(["mspace", cssSpace[group.text]], [], options);
  12867. } else {
  12868. throw new src_ParseError("Unknown type of space \"" + group.text + "\"");
  12869. }
  12870. },
  12871. mathmlBuilder: function mathmlBuilder(group, options) {
  12872. var node;
  12873. if (regularSpace.hasOwnProperty(group.text)) {
  12874. node = new mathMLTree.MathNode("mtext", [new mathMLTree.TextNode("\xA0")]);
  12875. } else if (cssSpace.hasOwnProperty(group.text)) {
  12876. // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored
  12877. return new mathMLTree.MathNode("mspace");
  12878. } else {
  12879. throw new src_ParseError("Unknown type of space \"" + group.text + "\"");
  12880. }
  12881. return node;
  12882. }
  12883. });
  12884. ;// CONCATENATED MODULE: ./src/functions/tag.js
  12885. var pad = function pad() {
  12886. var padNode = new mathMLTree.MathNode("mtd", []);
  12887. padNode.setAttribute("width", "50%");
  12888. return padNode;
  12889. };
  12890. defineFunctionBuilders({
  12891. type: "tag",
  12892. mathmlBuilder: function mathmlBuilder(group, options) {
  12893. var table = new mathMLTree.MathNode("mtable", [new mathMLTree.MathNode("mtr", [pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.body, options)]), pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.tag, options)])])]);
  12894. table.setAttribute("width", "100%");
  12895. return table; // TODO: Left-aligned tags.
  12896. // Currently, the group and options passed here do not contain
  12897. // enough info to set tag alignment. `leqno` is in Settings but it is
  12898. // not passed to Options. On the HTML side, leqno is
  12899. // set by a CSS class applied in buildTree.js. That would have worked
  12900. // in MathML if browsers supported <mlabeledtr>. Since they don't, we
  12901. // need to rewrite the way this function is called.
  12902. }
  12903. });
  12904. ;// CONCATENATED MODULE: ./src/functions/text.js
  12905. // Non-mathy text, possibly in a font
  12906. var textFontFamilies = {
  12907. "\\text": undefined,
  12908. "\\textrm": "textrm",
  12909. "\\textsf": "textsf",
  12910. "\\texttt": "texttt",
  12911. "\\textnormal": "textrm"
  12912. };
  12913. var textFontWeights = {
  12914. "\\textbf": "textbf",
  12915. "\\textmd": "textmd"
  12916. };
  12917. var textFontShapes = {
  12918. "\\textit": "textit",
  12919. "\\textup": "textup"
  12920. };
  12921. var optionsWithFont = function optionsWithFont(group, options) {
  12922. var font = group.font; // Checks if the argument is a font family or a font style.
  12923. if (!font) {
  12924. return options;
  12925. } else if (textFontFamilies[font]) {
  12926. return options.withTextFontFamily(textFontFamilies[font]);
  12927. } else if (textFontWeights[font]) {
  12928. return options.withTextFontWeight(textFontWeights[font]);
  12929. } else {
  12930. return options.withTextFontShape(textFontShapes[font]);
  12931. }
  12932. };
  12933. defineFunction({
  12934. type: "text",
  12935. names: [// Font families
  12936. "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", // Font weights
  12937. "\\textbf", "\\textmd", // Font Shapes
  12938. "\\textit", "\\textup"],
  12939. props: {
  12940. numArgs: 1,
  12941. argTypes: ["text"],
  12942. allowedInArgument: true,
  12943. allowedInText: true
  12944. },
  12945. handler: function handler(_ref, args) {
  12946. var parser = _ref.parser,
  12947. funcName = _ref.funcName;
  12948. var body = args[0];
  12949. return {
  12950. type: "text",
  12951. mode: parser.mode,
  12952. body: ordargument(body),
  12953. font: funcName
  12954. };
  12955. },
  12956. htmlBuilder: function htmlBuilder(group, options) {
  12957. var newOptions = optionsWithFont(group, options);
  12958. var inner = buildExpression(group.body, newOptions, true);
  12959. return buildCommon.makeSpan(["mord", "text"], inner, newOptions);
  12960. },
  12961. mathmlBuilder: function mathmlBuilder(group, options) {
  12962. var newOptions = optionsWithFont(group, options);
  12963. return buildExpressionRow(group.body, newOptions);
  12964. }
  12965. });
  12966. ;// CONCATENATED MODULE: ./src/functions/underline.js
  12967. defineFunction({
  12968. type: "underline",
  12969. names: ["\\underline"],
  12970. props: {
  12971. numArgs: 1,
  12972. allowedInText: true
  12973. },
  12974. handler: function handler(_ref, args) {
  12975. var parser = _ref.parser;
  12976. return {
  12977. type: "underline",
  12978. mode: parser.mode,
  12979. body: args[0]
  12980. };
  12981. },
  12982. htmlBuilder: function htmlBuilder(group, options) {
  12983. // Underlines are handled in the TeXbook pg 443, Rule 10.
  12984. // Build the inner group.
  12985. var innerGroup = buildGroup(group.body, options); // Create the line to go below the body
  12986. var line = buildCommon.makeLineSpan("underline-line", options); // Generate the vlist, with the appropriate kerns
  12987. var defaultRuleThickness = options.fontMetrics().defaultRuleThickness;
  12988. var vlist = buildCommon.makeVList({
  12989. positionType: "top",
  12990. positionData: innerGroup.height,
  12991. children: [{
  12992. type: "kern",
  12993. size: defaultRuleThickness
  12994. }, {
  12995. type: "elem",
  12996. elem: line
  12997. }, {
  12998. type: "kern",
  12999. size: 3 * defaultRuleThickness
  13000. }, {
  13001. type: "elem",
  13002. elem: innerGroup
  13003. }]
  13004. }, options);
  13005. return buildCommon.makeSpan(["mord", "underline"], [vlist], options);
  13006. },
  13007. mathmlBuilder: function mathmlBuilder(group, options) {
  13008. var operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203E")]);
  13009. operator.setAttribute("stretchy", "true");
  13010. var node = new mathMLTree.MathNode("munder", [buildMathML_buildGroup(group.body, options), operator]);
  13011. node.setAttribute("accentunder", "true");
  13012. return node;
  13013. }
  13014. });
  13015. ;// CONCATENATED MODULE: ./src/functions/vcenter.js
  13016. // \vcenter: Vertically center the argument group on the math axis.
  13017. defineFunction({
  13018. type: "vcenter",
  13019. names: ["\\vcenter"],
  13020. props: {
  13021. numArgs: 1,
  13022. argTypes: ["original"],
  13023. // In LaTeX, \vcenter can act only on a box.
  13024. allowedInText: false
  13025. },
  13026. handler: function handler(_ref, args) {
  13027. var parser = _ref.parser;
  13028. return {
  13029. type: "vcenter",
  13030. mode: parser.mode,
  13031. body: args[0]
  13032. };
  13033. },
  13034. htmlBuilder: function htmlBuilder(group, options) {
  13035. var body = buildGroup(group.body, options);
  13036. var axisHeight = options.fontMetrics().axisHeight;
  13037. var dy = 0.5 * (body.height - axisHeight - (body.depth + axisHeight));
  13038. return buildCommon.makeVList({
  13039. positionType: "shift",
  13040. positionData: dy,
  13041. children: [{
  13042. type: "elem",
  13043. elem: body
  13044. }]
  13045. }, options);
  13046. },
  13047. mathmlBuilder: function mathmlBuilder(group, options) {
  13048. // There is no way to do this in MathML.
  13049. // Write a class as a breadcrumb in case some post-processor wants
  13050. // to perform a vcenter adjustment.
  13051. return new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)], ["vcenter"]);
  13052. }
  13053. });
  13054. ;// CONCATENATED MODULE: ./src/functions/verb.js
  13055. defineFunction({
  13056. type: "verb",
  13057. names: ["\\verb"],
  13058. props: {
  13059. numArgs: 0,
  13060. allowedInText: true
  13061. },
  13062. handler: function handler(context, args, optArgs) {
  13063. // \verb and \verb* are dealt with directly in Parser.js.
  13064. // If we end up here, it's because of a failure to match the two delimiters
  13065. // in the regex in Lexer.js. LaTeX raises the following error when \verb is
  13066. // terminated by end of line (or file).
  13067. throw new src_ParseError("\\verb ended by end of line instead of matching delimiter");
  13068. },
  13069. htmlBuilder: function htmlBuilder(group, options) {
  13070. var text = makeVerb(group);
  13071. var body = []; // \verb enters text mode and therefore is sized like \textstyle
  13072. var newOptions = options.havingStyle(options.style.text());
  13073. for (var i = 0; i < text.length; i++) {
  13074. var c = text[i];
  13075. if (c === '~') {
  13076. c = '\\textasciitilde';
  13077. }
  13078. body.push(buildCommon.makeSymbol(c, "Typewriter-Regular", group.mode, newOptions, ["mord", "texttt"]));
  13079. }
  13080. return buildCommon.makeSpan(["mord", "text"].concat(newOptions.sizingClasses(options)), buildCommon.tryCombineChars(body), newOptions);
  13081. },
  13082. mathmlBuilder: function mathmlBuilder(group, options) {
  13083. var text = new mathMLTree.TextNode(makeVerb(group));
  13084. var node = new mathMLTree.MathNode("mtext", [text]);
  13085. node.setAttribute("mathvariant", "monospace");
  13086. return node;
  13087. }
  13088. });
  13089. /**
  13090. * Converts verb group into body string.
  13091. *
  13092. * \verb* replaces each space with an open box \u2423
  13093. * \verb replaces each space with a no-break space \xA0
  13094. */
  13095. var makeVerb = function makeVerb(group) {
  13096. return group.body.replace(/ /g, group.star ? "\u2423" : '\xA0');
  13097. };
  13098. ;// CONCATENATED MODULE: ./src/functions.js
  13099. /** Include this to ensure that all functions are defined. */
  13100. var functions = _functions;
  13101. /* harmony default export */ var src_functions = (functions); // TODO(kevinb): have functions return an object and call defineFunction with
  13102. // that object in this file instead of relying on side-effects.
  13103. ;// CONCATENATED MODULE: ./src/Lexer.js
  13104. /**
  13105. * The Lexer class handles tokenizing the input in various ways. Since our
  13106. * parser expects us to be able to backtrack, the lexer allows lexing from any
  13107. * given starting point.
  13108. *
  13109. * Its main exposed function is the `lex` function, which takes a position to
  13110. * lex from and a type of token to lex. It defers to the appropriate `_innerLex`
  13111. * function.
  13112. *
  13113. * The various `_innerLex` functions perform the actual lexing of different
  13114. * kinds.
  13115. */
  13116. /* The following tokenRegex
  13117. * - matches typical whitespace (but not NBSP etc.) using its first group
  13118. * - does not match any control character \x00-\x1f except whitespace
  13119. * - does not match a bare backslash
  13120. * - matches any ASCII character except those just mentioned
  13121. * - does not match the BMP private use area \uE000-\uF8FF
  13122. * - does not match bare surrogate code units
  13123. * - matches any BMP character except for those just described
  13124. * - matches any valid Unicode surrogate pair
  13125. * - matches a backslash followed by one or more whitespace characters
  13126. * - matches a backslash followed by one or more letters then whitespace
  13127. * - matches a backslash followed by any BMP character
  13128. * Capturing groups:
  13129. * [1] regular whitespace
  13130. * [2] backslash followed by whitespace
  13131. * [3] anything else, which may include:
  13132. * [4] left character of \verb*
  13133. * [5] left character of \verb
  13134. * [6] backslash followed by word, excluding any trailing whitespace
  13135. * Just because the Lexer matches something doesn't mean it's valid input:
  13136. * If there is no matching function or symbol definition, the Parser will
  13137. * still reject the input.
  13138. */
  13139. var spaceRegexString = "[ \r\n\t]";
  13140. var controlWordRegexString = "\\\\[a-zA-Z@]+";
  13141. var controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]";
  13142. var controlWordWhitespaceRegexString = "(" + controlWordRegexString + ")" + spaceRegexString + "*";
  13143. var controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*";
  13144. var combiningDiacriticalMarkString = "[\u0300-\u036F]";
  13145. var combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$");
  13146. var tokenRegexString = "(" + spaceRegexString + "+)|" + ( // whitespace
  13147. controlSpaceRegexString + "|") + // \whitespace
  13148. "([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + ( // single codepoint
  13149. combiningDiacriticalMarkString + "*") + // ...plus accents
  13150. "|[\uD800-\uDBFF][\uDC00-\uDFFF]" + ( // surrogate pair
  13151. combiningDiacriticalMarkString + "*") + // ...plus accents
  13152. "|\\\\verb\\*([^]).*?\\4" + // \verb*
  13153. "|\\\\verb([^*a-zA-Z]).*?\\5" + ( // \verb unstarred
  13154. "|" + controlWordWhitespaceRegexString) + ( // \macroName + spaces
  13155. "|" + controlSymbolRegexString + ")"); // \\, \', etc.
  13156. /** Main Lexer class */
  13157. var Lexer = /*#__PURE__*/function () {
  13158. // Category codes. The lexer only supports comment characters (14) for now.
  13159. // MacroExpander additionally distinguishes active (13).
  13160. function Lexer(input, settings) {
  13161. this.input = void 0;
  13162. this.settings = void 0;
  13163. this.tokenRegex = void 0;
  13164. this.catcodes = void 0;
  13165. // Separate accents from characters
  13166. this.input = input;
  13167. this.settings = settings;
  13168. this.tokenRegex = new RegExp(tokenRegexString, 'g');
  13169. this.catcodes = {
  13170. "%": 14,
  13171. // comment character
  13172. "~": 13 // active character
  13173. };
  13174. }
  13175. var _proto = Lexer.prototype;
  13176. _proto.setCatcode = function setCatcode(char, code) {
  13177. this.catcodes[char] = code;
  13178. }
  13179. /**
  13180. * This function lexes a single token.
  13181. */
  13182. ;
  13183. _proto.lex = function lex() {
  13184. var input = this.input;
  13185. var pos = this.tokenRegex.lastIndex;
  13186. if (pos === input.length) {
  13187. return new Token("EOF", new SourceLocation(this, pos, pos));
  13188. }
  13189. var match = this.tokenRegex.exec(input);
  13190. if (match === null || match.index !== pos) {
  13191. throw new src_ParseError("Unexpected character: '" + input[pos] + "'", new Token(input[pos], new SourceLocation(this, pos, pos + 1)));
  13192. }
  13193. var text = match[6] || match[3] || (match[2] ? "\\ " : " ");
  13194. if (this.catcodes[text] === 14) {
  13195. // comment character
  13196. var nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex);
  13197. if (nlIndex === -1) {
  13198. this.tokenRegex.lastIndex = input.length; // EOF
  13199. this.settings.reportNonstrict("commentAtEnd", "% comment has no terminating newline; LaTeX would " + "fail because of commenting the end of math mode (e.g. $)");
  13200. } else {
  13201. this.tokenRegex.lastIndex = nlIndex + 1;
  13202. }
  13203. return this.lex();
  13204. }
  13205. return new Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex));
  13206. };
  13207. return Lexer;
  13208. }();
  13209. ;// CONCATENATED MODULE: ./src/Namespace.js
  13210. /**
  13211. * A `Namespace` refers to a space of nameable things like macros or lengths,
  13212. * which can be `set` either globally or local to a nested group, using an
  13213. * undo stack similar to how TeX implements this functionality.
  13214. * Performance-wise, `get` and local `set` take constant time, while global
  13215. * `set` takes time proportional to the depth of group nesting.
  13216. */
  13217. var Namespace = /*#__PURE__*/function () {
  13218. /**
  13219. * Both arguments are optional. The first argument is an object of
  13220. * built-in mappings which never change. The second argument is an object
  13221. * of initial (global-level) mappings, which will constantly change
  13222. * according to any global/top-level `set`s done.
  13223. */
  13224. function Namespace(builtins, globalMacros) {
  13225. if (builtins === void 0) {
  13226. builtins = {};
  13227. }
  13228. if (globalMacros === void 0) {
  13229. globalMacros = {};
  13230. }
  13231. this.current = void 0;
  13232. this.builtins = void 0;
  13233. this.undefStack = void 0;
  13234. this.current = globalMacros;
  13235. this.builtins = builtins;
  13236. this.undefStack = [];
  13237. }
  13238. /**
  13239. * Start a new nested group, affecting future local `set`s.
  13240. */
  13241. var _proto = Namespace.prototype;
  13242. _proto.beginGroup = function beginGroup() {
  13243. this.undefStack.push({});
  13244. }
  13245. /**
  13246. * End current nested group, restoring values before the group began.
  13247. */
  13248. ;
  13249. _proto.endGroup = function endGroup() {
  13250. if (this.undefStack.length === 0) {
  13251. throw new src_ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug");
  13252. }
  13253. var undefs = this.undefStack.pop();
  13254. for (var undef in undefs) {
  13255. if (undefs.hasOwnProperty(undef)) {
  13256. if (undefs[undef] == null) {
  13257. delete this.current[undef];
  13258. } else {
  13259. this.current[undef] = undefs[undef];
  13260. }
  13261. }
  13262. }
  13263. }
  13264. /**
  13265. * Ends all currently nested groups (if any), restoring values before the
  13266. * groups began. Useful in case of an error in the middle of parsing.
  13267. */
  13268. ;
  13269. _proto.endGroups = function endGroups() {
  13270. while (this.undefStack.length > 0) {
  13271. this.endGroup();
  13272. }
  13273. }
  13274. /**
  13275. * Detect whether `name` has a definition. Equivalent to
  13276. * `get(name) != null`.
  13277. */
  13278. ;
  13279. _proto.has = function has(name) {
  13280. return this.current.hasOwnProperty(name) || this.builtins.hasOwnProperty(name);
  13281. }
  13282. /**
  13283. * Get the current value of a name, or `undefined` if there is no value.
  13284. *
  13285. * Note: Do not use `if (namespace.get(...))` to detect whether a macro
  13286. * is defined, as the definition may be the empty string which evaluates
  13287. * to `false` in JavaScript. Use `if (namespace.get(...) != null)` or
  13288. * `if (namespace.has(...))`.
  13289. */
  13290. ;
  13291. _proto.get = function get(name) {
  13292. if (this.current.hasOwnProperty(name)) {
  13293. return this.current[name];
  13294. } else {
  13295. return this.builtins[name];
  13296. }
  13297. }
  13298. /**
  13299. * Set the current value of a name, and optionally set it globally too.
  13300. * Local set() sets the current value and (when appropriate) adds an undo
  13301. * operation to the undo stack. Global set() may change the undo
  13302. * operation at every level, so takes time linear in their number.
  13303. * A value of undefined means to delete existing definitions.
  13304. */
  13305. ;
  13306. _proto.set = function set(name, value, global) {
  13307. if (global === void 0) {
  13308. global = false;
  13309. }
  13310. if (global) {
  13311. // Global set is equivalent to setting in all groups. Simulate this
  13312. // by destroying any undos currently scheduled for this name,
  13313. // and adding an undo with the *new* value (in case it later gets
  13314. // locally reset within this environment).
  13315. for (var i = 0; i < this.undefStack.length; i++) {
  13316. delete this.undefStack[i][name];
  13317. }
  13318. if (this.undefStack.length > 0) {
  13319. this.undefStack[this.undefStack.length - 1][name] = value;
  13320. }
  13321. } else {
  13322. // Undo this set at end of this group (possibly to `undefined`),
  13323. // unless an undo is already in place, in which case that older
  13324. // value is the correct one.
  13325. var top = this.undefStack[this.undefStack.length - 1];
  13326. if (top && !top.hasOwnProperty(name)) {
  13327. top[name] = this.current[name];
  13328. }
  13329. }
  13330. if (value == null) {
  13331. delete this.current[name];
  13332. } else {
  13333. this.current[name] = value;
  13334. }
  13335. };
  13336. return Namespace;
  13337. }();
  13338. ;// CONCATENATED MODULE: ./src/macros.js
  13339. /**
  13340. * Predefined macros for KaTeX.
  13341. * This can be used to define some commands in terms of others.
  13342. */
  13343. // Export global macros object from defineMacro
  13344. var macros = _macros;
  13345. /* harmony default export */ var src_macros = (macros);
  13346. //////////////////////////////////////////////////////////////////////
  13347. // macro tools
  13348. defineMacro("\\noexpand", function (context) {
  13349. // The expansion is the token itself; but that token is interpreted
  13350. // as if its meaning were ‘\relax’ if it is a control sequence that
  13351. // would ordinarily be expanded by TeX’s expansion rules.
  13352. var t = context.popToken();
  13353. if (context.isExpandable(t.text)) {
  13354. t.noexpand = true;
  13355. t.treatAsRelax = true;
  13356. }
  13357. return {
  13358. tokens: [t],
  13359. numArgs: 0
  13360. };
  13361. });
  13362. defineMacro("\\expandafter", function (context) {
  13363. // TeX first reads the token that comes immediately after \expandafter,
  13364. // without expanding it; let’s call this token t. Then TeX reads the
  13365. // token that comes after t (and possibly more tokens, if that token
  13366. // has an argument), replacing it by its expansion. Finally TeX puts
  13367. // t back in front of that expansion.
  13368. var t = context.popToken();
  13369. context.expandOnce(true); // expand only an expandable token
  13370. return {
  13371. tokens: [t],
  13372. numArgs: 0
  13373. };
  13374. }); // LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2
  13375. // TeX source: \long\def\@firstoftwo#1#2{#1}
  13376. defineMacro("\\@firstoftwo", function (context) {
  13377. var args = context.consumeArgs(2);
  13378. return {
  13379. tokens: args[0],
  13380. numArgs: 0
  13381. };
  13382. }); // LaTeX's \@secondoftwo{#1}{#2} expands to #2, skipping #1
  13383. // TeX source: \long\def\@secondoftwo#1#2{#2}
  13384. defineMacro("\\@secondoftwo", function (context) {
  13385. var args = context.consumeArgs(2);
  13386. return {
  13387. tokens: args[1],
  13388. numArgs: 0
  13389. };
  13390. }); // LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded)
  13391. // symbol that isn't a space, consuming any spaces but not consuming the
  13392. // first nonspace character. If that nonspace character matches #1, then
  13393. // the macro expands to #2; otherwise, it expands to #3.
  13394. defineMacro("\\@ifnextchar", function (context) {
  13395. var args = context.consumeArgs(3); // symbol, if, else
  13396. context.consumeSpaces();
  13397. var nextToken = context.future();
  13398. if (args[0].length === 1 && args[0][0].text === nextToken.text) {
  13399. return {
  13400. tokens: args[1],
  13401. numArgs: 0
  13402. };
  13403. } else {
  13404. return {
  13405. tokens: args[2],
  13406. numArgs: 0
  13407. };
  13408. }
  13409. }); // LaTeX's \@ifstar{#1}{#2} looks ahead to the next (unexpanded) symbol.
  13410. // If it is `*`, then it consumes the symbol, and the macro expands to #1;
  13411. // otherwise, the macro expands to #2 (without consuming the symbol).
  13412. // TeX source: \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}}
  13413. defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); // LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode
  13414. defineMacro("\\TextOrMath", function (context) {
  13415. var args = context.consumeArgs(2);
  13416. if (context.mode === 'text') {
  13417. return {
  13418. tokens: args[0],
  13419. numArgs: 0
  13420. };
  13421. } else {
  13422. return {
  13423. tokens: args[1],
  13424. numArgs: 0
  13425. };
  13426. }
  13427. }); // Lookup table for parsing numbers in base 8 through 16
  13428. var digitToNumber = {
  13429. "0": 0,
  13430. "1": 1,
  13431. "2": 2,
  13432. "3": 3,
  13433. "4": 4,
  13434. "5": 5,
  13435. "6": 6,
  13436. "7": 7,
  13437. "8": 8,
  13438. "9": 9,
  13439. "a": 10,
  13440. "A": 10,
  13441. "b": 11,
  13442. "B": 11,
  13443. "c": 12,
  13444. "C": 12,
  13445. "d": 13,
  13446. "D": 13,
  13447. "e": 14,
  13448. "E": 14,
  13449. "f": 15,
  13450. "F": 15
  13451. }; // TeX \char makes a literal character (catcode 12) using the following forms:
  13452. // (see The TeXBook, p. 43)
  13453. // \char123 -- decimal
  13454. // \char'123 -- octal
  13455. // \char"123 -- hex
  13456. // \char`x -- character that can be written (i.e. isn't active)
  13457. // \char`\x -- character that cannot be written (e.g. %)
  13458. // These all refer to characters from the font, so we turn them into special
  13459. // calls to a function \@char dealt with in the Parser.
  13460. defineMacro("\\char", function (context) {
  13461. var token = context.popToken();
  13462. var base;
  13463. var number = '';
  13464. if (token.text === "'") {
  13465. base = 8;
  13466. token = context.popToken();
  13467. } else if (token.text === '"') {
  13468. base = 16;
  13469. token = context.popToken();
  13470. } else if (token.text === "`") {
  13471. token = context.popToken();
  13472. if (token.text[0] === "\\") {
  13473. number = token.text.charCodeAt(1);
  13474. } else if (token.text === "EOF") {
  13475. throw new src_ParseError("\\char` missing argument");
  13476. } else {
  13477. number = token.text.charCodeAt(0);
  13478. }
  13479. } else {
  13480. base = 10;
  13481. }
  13482. if (base) {
  13483. // Parse a number in the given base, starting with first `token`.
  13484. number = digitToNumber[token.text];
  13485. if (number == null || number >= base) {
  13486. throw new src_ParseError("Invalid base-" + base + " digit " + token.text);
  13487. }
  13488. var digit;
  13489. while ((digit = digitToNumber[context.future().text]) != null && digit < base) {
  13490. number *= base;
  13491. number += digit;
  13492. context.popToken();
  13493. }
  13494. }
  13495. return "\\@char{" + number + "}";
  13496. }); // \newcommand{\macro}[args]{definition}
  13497. // \renewcommand{\macro}[args]{definition}
  13498. // TODO: Optional arguments: \newcommand{\macro}[args][default]{definition}
  13499. var newcommand = function newcommand(context, existsOK, nonexistsOK) {
  13500. var arg = context.consumeArg().tokens;
  13501. if (arg.length !== 1) {
  13502. throw new src_ParseError("\\newcommand's first argument must be a macro name");
  13503. }
  13504. var name = arg[0].text;
  13505. var exists = context.isDefined(name);
  13506. if (exists && !existsOK) {
  13507. throw new src_ParseError("\\newcommand{" + name + "} attempting to redefine " + (name + "; use \\renewcommand"));
  13508. }
  13509. if (!exists && !nonexistsOK) {
  13510. throw new src_ParseError("\\renewcommand{" + name + "} when command " + name + " " + "does not yet exist; use \\newcommand");
  13511. }
  13512. var numArgs = 0;
  13513. arg = context.consumeArg().tokens;
  13514. if (arg.length === 1 && arg[0].text === "[") {
  13515. var argText = '';
  13516. var token = context.expandNextToken();
  13517. while (token.text !== "]" && token.text !== "EOF") {
  13518. // TODO: Should properly expand arg, e.g., ignore {}s
  13519. argText += token.text;
  13520. token = context.expandNextToken();
  13521. }
  13522. if (!argText.match(/^\s*[0-9]+\s*$/)) {
  13523. throw new src_ParseError("Invalid number of arguments: " + argText);
  13524. }
  13525. numArgs = parseInt(argText);
  13526. arg = context.consumeArg().tokens;
  13527. } // Final arg is the expansion of the macro
  13528. context.macros.set(name, {
  13529. tokens: arg,
  13530. numArgs: numArgs
  13531. });
  13532. return '';
  13533. };
  13534. defineMacro("\\newcommand", function (context) {
  13535. return newcommand(context, false, true);
  13536. });
  13537. defineMacro("\\renewcommand", function (context) {
  13538. return newcommand(context, true, false);
  13539. });
  13540. defineMacro("\\providecommand", function (context) {
  13541. return newcommand(context, true, true);
  13542. }); // terminal (console) tools
  13543. defineMacro("\\message", function (context) {
  13544. var arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console
  13545. console.log(arg.reverse().map(function (token) {
  13546. return token.text;
  13547. }).join(""));
  13548. return '';
  13549. });
  13550. defineMacro("\\errmessage", function (context) {
  13551. var arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console
  13552. console.error(arg.reverse().map(function (token) {
  13553. return token.text;
  13554. }).join(""));
  13555. return '';
  13556. });
  13557. defineMacro("\\show", function (context) {
  13558. var tok = context.popToken();
  13559. var name = tok.text; // eslint-disable-next-line no-console
  13560. console.log(tok, context.macros.get(name), src_functions[name], src_symbols.math[name], src_symbols.text[name]);
  13561. return '';
  13562. }); //////////////////////////////////////////////////////////////////////
  13563. // Grouping
  13564. // \let\bgroup={ \let\egroup=}
  13565. defineMacro("\\bgroup", "{");
  13566. defineMacro("\\egroup", "}"); // Symbols from latex.ltx:
  13567. // \def~{\nobreakspace{}}
  13568. // \def\lq{`}
  13569. // \def\rq{'}
  13570. // \def \aa {\r a}
  13571. // \def \AA {\r A}
  13572. defineMacro("~", "\\nobreakspace");
  13573. defineMacro("\\lq", "`");
  13574. defineMacro("\\rq", "'");
  13575. defineMacro("\\aa", "\\r a");
  13576. defineMacro("\\AA", "\\r A"); // Copyright (C) and registered (R) symbols. Use raw symbol in MathML.
  13577. // \DeclareTextCommandDefault{\textcopyright}{\textcircled{c}}
  13578. // \DeclareTextCommandDefault{\textregistered}{\textcircled{%
  13579. // \check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}}
  13580. // \DeclareRobustCommand{\copyright}{%
  13581. // \ifmmode{\nfss@text{\textcopyright}}\else\textcopyright\fi}
  13582. defineMacro("\\textcopyright", "\\html@mathml{\\textcircled{c}}{\\char`©}");
  13583. defineMacro("\\copyright", "\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}");
  13584. defineMacro("\\textregistered", "\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"); // Characters omitted from Unicode range 1D400–1D7FF
  13585. defineMacro("\u212C", "\\mathscr{B}"); // script
  13586. defineMacro("\u2130", "\\mathscr{E}");
  13587. defineMacro("\u2131", "\\mathscr{F}");
  13588. defineMacro("\u210B", "\\mathscr{H}");
  13589. defineMacro("\u2110", "\\mathscr{I}");
  13590. defineMacro("\u2112", "\\mathscr{L}");
  13591. defineMacro("\u2133", "\\mathscr{M}");
  13592. defineMacro("\u211B", "\\mathscr{R}");
  13593. defineMacro("\u212D", "\\mathfrak{C}"); // Fraktur
  13594. defineMacro("\u210C", "\\mathfrak{H}");
  13595. defineMacro("\u2128", "\\mathfrak{Z}"); // Define \Bbbk with a macro that works in both HTML and MathML.
  13596. defineMacro("\\Bbbk", "\\Bbb{k}"); // Unicode middle dot
  13597. // The KaTeX fonts do not contain U+00B7. Instead, \cdotp displays
  13598. // the dot at U+22C5 and gives it punct spacing.
  13599. defineMacro("\xB7", "\\cdotp"); // \llap and \rlap render their contents in text mode
  13600. defineMacro("\\llap", "\\mathllap{\\textrm{#1}}");
  13601. defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}");
  13602. defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); // \mathstrut from the TeXbook, p 360
  13603. defineMacro("\\mathstrut", "\\vphantom{(}"); // \underbar from TeXbook p 353
  13604. defineMacro("\\underbar", "\\underline{\\text{#1}}"); // \not is defined by base/fontmath.ltx via
  13605. // \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36}
  13606. // It's thus treated like a \mathrel, but defined by a symbol that has zero
  13607. // width but extends to the right. We use \rlap to get that spacing.
  13608. // For MathML we write U+0338 here. buildMathML.js will then do the overlay.
  13609. defineMacro("\\not", '\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}'); // Negated symbols from base/fontmath.ltx:
  13610. // \def\neq{\not=} \let\ne=\neq
  13611. // \DeclareRobustCommand
  13612. // \notin{\mathrel{\m@th\mathpalette\c@ncel\in}}
  13613. // \def\c@ncel#1#2{\m@th\ooalign{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}}
  13614. defineMacro("\\neq", "\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}");
  13615. defineMacro("\\ne", "\\neq");
  13616. defineMacro("\u2260", "\\neq");
  13617. defineMacro("\\notin", "\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}" + "{\\mathrel{\\char`∉}}");
  13618. defineMacro("\u2209", "\\notin"); // Unicode stacked relations
  13619. defineMacro("\u2258", "\\html@mathml{" + "\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}" + "}{\\mathrel{\\char`\u2258}}");
  13620. defineMacro("\u2259", "\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}");
  13621. defineMacro("\u225A", "\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}");
  13622. defineMacro("\u225B", "\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}" + "{\\mathrel{\\char`\u225B}}");
  13623. defineMacro("\u225D", "\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}" + "{\\mathrel{\\char`\u225D}}");
  13624. defineMacro("\u225E", "\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}" + "{\\mathrel{\\char`\u225E}}");
  13625. defineMacro("\u225F", "\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}"); // Misc Unicode
  13626. defineMacro("\u27C2", "\\perp");
  13627. defineMacro("\u203C", "\\mathclose{!\\mkern-0.8mu!}");
  13628. defineMacro("\u220C", "\\notni");
  13629. defineMacro("\u231C", "\\ulcorner");
  13630. defineMacro("\u231D", "\\urcorner");
  13631. defineMacro("\u231E", "\\llcorner");
  13632. defineMacro("\u231F", "\\lrcorner");
  13633. defineMacro("\xA9", "\\copyright");
  13634. defineMacro("\xAE", "\\textregistered");
  13635. defineMacro("\uFE0F", "\\textregistered"); // The KaTeX fonts have corners at codepoints that don't match Unicode.
  13636. // For MathML purposes, use the Unicode code point.
  13637. defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}");
  13638. defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}");
  13639. defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}");
  13640. defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); //////////////////////////////////////////////////////////////////////
  13641. // LaTeX_2ε
  13642. // \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@
  13643. // \kern6\p@\hbox{.}\hbox{.}\hbox{.}}}
  13644. // We'll call \varvdots, which gets a glyph from symbols.js.
  13645. // The zero-width rule gets us an equivalent to the vertical 6pt kern.
  13646. defineMacro("\\vdots", "\\mathord{\\varvdots\\rule{0pt}{15pt}}");
  13647. defineMacro("\u22EE", "\\vdots"); //////////////////////////////////////////////////////////////////////
  13648. // amsmath.sty
  13649. // http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf
  13650. // Italic Greek capital letters. AMS defines these with \DeclareMathSymbol,
  13651. // but they are equivalent to \mathit{\Letter}.
  13652. defineMacro("\\varGamma", "\\mathit{\\Gamma}");
  13653. defineMacro("\\varDelta", "\\mathit{\\Delta}");
  13654. defineMacro("\\varTheta", "\\mathit{\\Theta}");
  13655. defineMacro("\\varLambda", "\\mathit{\\Lambda}");
  13656. defineMacro("\\varXi", "\\mathit{\\Xi}");
  13657. defineMacro("\\varPi", "\\mathit{\\Pi}");
  13658. defineMacro("\\varSigma", "\\mathit{\\Sigma}");
  13659. defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}");
  13660. defineMacro("\\varPhi", "\\mathit{\\Phi}");
  13661. defineMacro("\\varPsi", "\\mathit{\\Psi}");
  13662. defineMacro("\\varOmega", "\\mathit{\\Omega}"); //\newcommand{\substack}[1]{\subarray{c}#1\endsubarray}
  13663. defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
  13664. // \mkern-\thinmuskip{:}\mskip6muplus1mu\relax}
  13665. defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
  13666. defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); // \def\iff{\DOTSB\;\Longleftrightarrow\;}
  13667. // \def\implies{\DOTSB\;\Longrightarrow\;}
  13668. // \def\impliedby{\DOTSB\;\Longleftarrow\;}
  13669. defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;");
  13670. defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;");
  13671. defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); // AMSMath's automatic \dots, based on \mdots@@ macro.
  13672. var dotsByToken = {
  13673. ',': '\\dotsc',
  13674. '\\not': '\\dotsb',
  13675. // \keybin@ checks for the following:
  13676. '+': '\\dotsb',
  13677. '=': '\\dotsb',
  13678. '<': '\\dotsb',
  13679. '>': '\\dotsb',
  13680. '-': '\\dotsb',
  13681. '*': '\\dotsb',
  13682. ':': '\\dotsb',
  13683. // Symbols whose definition starts with \DOTSB:
  13684. '\\DOTSB': '\\dotsb',
  13685. '\\coprod': '\\dotsb',
  13686. '\\bigvee': '\\dotsb',
  13687. '\\bigwedge': '\\dotsb',
  13688. '\\biguplus': '\\dotsb',
  13689. '\\bigcap': '\\dotsb',
  13690. '\\bigcup': '\\dotsb',
  13691. '\\prod': '\\dotsb',
  13692. '\\sum': '\\dotsb',
  13693. '\\bigotimes': '\\dotsb',
  13694. '\\bigoplus': '\\dotsb',
  13695. '\\bigodot': '\\dotsb',
  13696. '\\bigsqcup': '\\dotsb',
  13697. '\\And': '\\dotsb',
  13698. '\\longrightarrow': '\\dotsb',
  13699. '\\Longrightarrow': '\\dotsb',
  13700. '\\longleftarrow': '\\dotsb',
  13701. '\\Longleftarrow': '\\dotsb',
  13702. '\\longleftrightarrow': '\\dotsb',
  13703. '\\Longleftrightarrow': '\\dotsb',
  13704. '\\mapsto': '\\dotsb',
  13705. '\\longmapsto': '\\dotsb',
  13706. '\\hookrightarrow': '\\dotsb',
  13707. '\\doteq': '\\dotsb',
  13708. // Symbols whose definition starts with \mathbin:
  13709. '\\mathbin': '\\dotsb',
  13710. // Symbols whose definition starts with \mathrel:
  13711. '\\mathrel': '\\dotsb',
  13712. '\\relbar': '\\dotsb',
  13713. '\\Relbar': '\\dotsb',
  13714. '\\xrightarrow': '\\dotsb',
  13715. '\\xleftarrow': '\\dotsb',
  13716. // Symbols whose definition starts with \DOTSI:
  13717. '\\DOTSI': '\\dotsi',
  13718. '\\int': '\\dotsi',
  13719. '\\oint': '\\dotsi',
  13720. '\\iint': '\\dotsi',
  13721. '\\iiint': '\\dotsi',
  13722. '\\iiiint': '\\dotsi',
  13723. '\\idotsint': '\\dotsi',
  13724. // Symbols whose definition starts with \DOTSX:
  13725. '\\DOTSX': '\\dotsx'
  13726. };
  13727. defineMacro("\\dots", function (context) {
  13728. // TODO: If used in text mode, should expand to \textellipsis.
  13729. // However, in KaTeX, \textellipsis and \ldots behave the same
  13730. // (in text mode), and it's unlikely we'd see any of the math commands
  13731. // that affect the behavior of \dots when in text mode. So fine for now
  13732. // (until we support \ifmmode ... \else ... \fi).
  13733. var thedots = '\\dotso';
  13734. var next = context.expandAfterFuture().text;
  13735. if (next in dotsByToken) {
  13736. thedots = dotsByToken[next];
  13737. } else if (next.slice(0, 4) === '\\not') {
  13738. thedots = '\\dotsb';
  13739. } else if (next in src_symbols.math) {
  13740. if (utils.contains(['bin', 'rel'], src_symbols.math[next].group)) {
  13741. thedots = '\\dotsb';
  13742. }
  13743. }
  13744. return thedots;
  13745. });
  13746. var spaceAfterDots = {
  13747. // \rightdelim@ checks for the following:
  13748. ')': true,
  13749. ']': true,
  13750. '\\rbrack': true,
  13751. '\\}': true,
  13752. '\\rbrace': true,
  13753. '\\rangle': true,
  13754. '\\rceil': true,
  13755. '\\rfloor': true,
  13756. '\\rgroup': true,
  13757. '\\rmoustache': true,
  13758. '\\right': true,
  13759. '\\bigr': true,
  13760. '\\biggr': true,
  13761. '\\Bigr': true,
  13762. '\\Biggr': true,
  13763. // \extra@ also tests for the following:
  13764. '$': true,
  13765. // \extrap@ checks for the following:
  13766. ';': true,
  13767. '.': true,
  13768. ',': true
  13769. };
  13770. defineMacro("\\dotso", function (context) {
  13771. var next = context.future().text;
  13772. if (next in spaceAfterDots) {
  13773. return "\\ldots\\,";
  13774. } else {
  13775. return "\\ldots";
  13776. }
  13777. });
  13778. defineMacro("\\dotsc", function (context) {
  13779. var next = context.future().text; // \dotsc uses \extra@ but not \extrap@, instead specially checking for
  13780. // ';' and '.', but doesn't check for ','.
  13781. if (next in spaceAfterDots && next !== ',') {
  13782. return "\\ldots\\,";
  13783. } else {
  13784. return "\\ldots";
  13785. }
  13786. });
  13787. defineMacro("\\cdots", function (context) {
  13788. var next = context.future().text;
  13789. if (next in spaceAfterDots) {
  13790. return "\\@cdots\\,";
  13791. } else {
  13792. return "\\@cdots";
  13793. }
  13794. });
  13795. defineMacro("\\dotsb", "\\cdots");
  13796. defineMacro("\\dotsm", "\\cdots");
  13797. defineMacro("\\dotsi", "\\!\\cdots"); // amsmath doesn't actually define \dotsx, but \dots followed by a macro
  13798. // starting with \DOTSX implies \dotso, and then \extra@ detects this case
  13799. // and forces the added `\,`.
  13800. defineMacro("\\dotsx", "\\ldots\\,"); // \let\DOTSI\relax
  13801. // \let\DOTSB\relax
  13802. // \let\DOTSX\relax
  13803. defineMacro("\\DOTSI", "\\relax");
  13804. defineMacro("\\DOTSB", "\\relax");
  13805. defineMacro("\\DOTSX", "\\relax"); // Spacing, based on amsmath.sty's override of LaTeX defaults
  13806. // \DeclareRobustCommand{\tmspace}[3]{%
  13807. // \ifmmode\mskip#1#2\else\kern#1#3\fi\relax}
  13808. defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"); // \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}}
  13809. // TODO: math mode should use \thinmuskip
  13810. defineMacro("\\,", "\\tmspace+{3mu}{.1667em}"); // \let\thinspace\,
  13811. defineMacro("\\thinspace", "\\,"); // \def\>{\mskip\medmuskip}
  13812. // \renewcommand{\:}{\tmspace+\medmuskip{.2222em}}
  13813. // TODO: \> and math mode of \: should use \medmuskip = 4mu plus 2mu minus 4mu
  13814. defineMacro("\\>", "\\mskip{4mu}");
  13815. defineMacro("\\:", "\\tmspace+{4mu}{.2222em}"); // \let\medspace\:
  13816. defineMacro("\\medspace", "\\:"); // \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}}
  13817. // TODO: math mode should use \thickmuskip = 5mu plus 5mu
  13818. defineMacro("\\;", "\\tmspace+{5mu}{.2777em}"); // \let\thickspace\;
  13819. defineMacro("\\thickspace", "\\;"); // \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}}
  13820. // TODO: math mode should use \thinmuskip
  13821. defineMacro("\\!", "\\tmspace-{3mu}{.1667em}"); // \let\negthinspace\!
  13822. defineMacro("\\negthinspace", "\\!"); // \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}}
  13823. // TODO: math mode should use \medmuskip
  13824. defineMacro("\\negmedspace", "\\tmspace-{4mu}{.2222em}"); // \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}}
  13825. // TODO: math mode should use \thickmuskip
  13826. defineMacro("\\negthickspace", "\\tmspace-{5mu}{.277em}"); // \def\enspace{\kern.5em }
  13827. defineMacro("\\enspace", "\\kern.5em "); // \def\enskip{\hskip.5em\relax}
  13828. defineMacro("\\enskip", "\\hskip.5em\\relax"); // \def\quad{\hskip1em\relax}
  13829. defineMacro("\\quad", "\\hskip1em\\relax"); // \def\qquad{\hskip2em\relax}
  13830. defineMacro("\\qquad", "\\hskip2em\\relax"); // \tag@in@display form of \tag
  13831. defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren");
  13832. defineMacro("\\tag@paren", "\\tag@literal{({#1})}");
  13833. defineMacro("\\tag@literal", function (context) {
  13834. if (context.macros.get("\\df@tag")) {
  13835. throw new src_ParseError("Multiple \\tag");
  13836. }
  13837. return "\\gdef\\df@tag{\\text{#1}}";
  13838. }); // \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin
  13839. // {\operator@font mod}\penalty900
  13840. // \mkern5mu\nonscript\mskip-\medmuskip}
  13841. // \newcommand{\pod}[1]{\allowbreak
  13842. // \if@display\mkern18mu\else\mkern8mu\fi(#1)}
  13843. // \renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}}
  13844. // \newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu
  13845. // \else\mkern12mu\fi{\operator@font mod}\,\,#1}
  13846. // TODO: math mode should use \medmuskip = 4mu plus 2mu minus 4mu
  13847. defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + "\\mathbin{\\rm mod}" + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}");
  13848. defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");
  13849. defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}");
  13850. defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); //////////////////////////////////////////////////////////////////////
  13851. // LaTeX source2e
  13852. // \expandafter\let\expandafter\@normalcr
  13853. // \csname\expandafter\@gobble\string\\ \endcsname
  13854. // \DeclareRobustCommand\newline{\@normalcr\relax}
  13855. defineMacro("\\newline", "\\\\\\relax"); // \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@}
  13856. // TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't
  13857. // support \@ yet, so that's omitted, and we add \text so that the result
  13858. // doesn't look funny in math mode.
  13859. defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX" + "}{TeX}}"); // \DeclareRobustCommand{\LaTeX}{L\kern-.36em%
  13860. // {\sbox\z@ T%
  13861. // \vbox to\ht\z@{\hbox{\check@mathfonts
  13862. // \fontsize\sf@size\z@
  13863. // \math@fontsfalse\selectfont
  13864. // A}%
  13865. // \vss}%
  13866. // }%
  13867. // \kern-.15em%
  13868. // \TeX}
  13869. // This code aligns the top of the A with the T (from the perspective of TeX's
  13870. // boxes, though visually the A appears to extend above slightly).
  13871. // We compute the corresponding \raisebox when A is rendered in \normalsize
  13872. // \scriptstyle, which has a scale factor of 0.7 (see Options.js).
  13873. var latexRaiseA = makeEm(fontMetricsData["Main-Regular"]["T".charCodeAt(0)][1] - 0.7 * fontMetricsData["Main-Regular"]["A".charCodeAt(0)][1]);
  13874. defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo
  13875. defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
  13876. // \def\@hspace#1{\hskip #1\relax}
  13877. // \def\@hspacer#1{\vrule \@width\z@\nobreak
  13878. // \hskip #1\hskip \z@skip}
  13879. defineMacro("\\hspace", "\\@ifstar\\@hspacer\\@hspace");
  13880. defineMacro("\\@hspace", "\\hskip #1\\relax");
  13881. defineMacro("\\@hspacer", "\\rule{0pt}{0pt}\\hskip #1\\relax"); //////////////////////////////////////////////////////////////////////
  13882. // mathtools.sty
  13883. //\providecommand\ordinarycolon{:}
  13884. defineMacro("\\ordinarycolon", ":"); //\def\vcentcolon{\mathrel{\mathop\ordinarycolon}}
  13885. //TODO(edemaine): Not yet centered. Fix via \raisebox or #726
  13886. defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}"); // \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon}
  13887. defineMacro("\\dblcolon", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" + "{\\mathop{\\char\"2237}}"); // \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=}
  13888. defineMacro("\\coloneqq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2254}}"); // ≔
  13889. // \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=}
  13890. defineMacro("\\Coloneqq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2237\\char\"3d}}"); // \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
  13891. defineMacro("\\coloneq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"3a\\char\"2212}}"); // \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
  13892. defineMacro("\\Coloneq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"2237\\char\"2212}}"); // \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon}
  13893. defineMacro("\\eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2255}}"); // ≕
  13894. // \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon}
  13895. defineMacro("\\Eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"3d\\char\"2237}}"); // \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon}
  13896. defineMacro("\\eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2239}}"); // \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon}
  13897. defineMacro("\\Eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"2212\\char\"2237}}"); // \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx}
  13898. defineMacro("\\colonapprox", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"3a\\char\"2248}}"); // \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx}
  13899. defineMacro("\\Colonapprox", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"2237\\char\"2248}}"); // \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim}
  13900. defineMacro("\\colonsim", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"3a\\char\"223c}}"); // \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim}
  13901. defineMacro("\\Colonsim", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"2237\\char\"223c}}"); // Some Unicode characters are implemented with macros to mathtools functions.
  13902. defineMacro("\u2237", "\\dblcolon"); // ::
  13903. defineMacro("\u2239", "\\eqcolon"); // -:
  13904. defineMacro("\u2254", "\\coloneqq"); // :=
  13905. defineMacro("\u2255", "\\eqqcolon"); // =:
  13906. defineMacro("\u2A74", "\\Coloneqq"); // ::=
  13907. //////////////////////////////////////////////////////////////////////
  13908. // colonequals.sty
  13909. // Alternate names for mathtools's macros:
  13910. defineMacro("\\ratio", "\\vcentcolon");
  13911. defineMacro("\\coloncolon", "\\dblcolon");
  13912. defineMacro("\\colonequals", "\\coloneqq");
  13913. defineMacro("\\coloncolonequals", "\\Coloneqq");
  13914. defineMacro("\\equalscolon", "\\eqqcolon");
  13915. defineMacro("\\equalscoloncolon", "\\Eqqcolon");
  13916. defineMacro("\\colonminus", "\\coloneq");
  13917. defineMacro("\\coloncolonminus", "\\Coloneq");
  13918. defineMacro("\\minuscolon", "\\eqcolon");
  13919. defineMacro("\\minuscoloncolon", "\\Eqcolon"); // \colonapprox name is same in mathtools and colonequals.
  13920. defineMacro("\\coloncolonapprox", "\\Colonapprox"); // \colonsim name is same in mathtools and colonequals.
  13921. defineMacro("\\coloncolonsim", "\\Colonsim"); // Additional macros, implemented by analogy with mathtools definitions:
  13922. defineMacro("\\simcolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}");
  13923. defineMacro("\\simcoloncolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}");
  13924. defineMacro("\\approxcolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}");
  13925. defineMacro("\\approxcoloncolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"); // Present in newtxmath, pxfonts and txfonts
  13926. defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}");
  13927. defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}");
  13928. defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); //////////////////////////////////////////////////////////////////////
  13929. // From amsopn.sty
  13930. defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}");
  13931. defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}");
  13932. defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}");
  13933. defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}");
  13934. defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}");
  13935. defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); //////////////////////////////////////////////////////////////////////
  13936. // MathML alternates for KaTeX glyphs in the Unicode private area
  13937. defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}");
  13938. defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}");
  13939. defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}");
  13940. defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}");
  13941. defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}");
  13942. defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}");
  13943. defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}");
  13944. defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}");
  13945. defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}");
  13946. defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}");
  13947. defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}");
  13948. defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}");
  13949. defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}");
  13950. defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}");
  13951. defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}");
  13952. defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); //////////////////////////////////////////////////////////////////////
  13953. // stmaryrd and semantic
  13954. // The stmaryrd and semantic packages render the next four items by calling a
  13955. // glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros.
  13956. defineMacro("\\llbracket", "\\html@mathml{" + "\\mathopen{[\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u27E6}}");
  13957. defineMacro("\\rrbracket", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu]}}" + "{\\mathclose{\\char`\u27E7}}");
  13958. defineMacro("\u27E6", "\\llbracket"); // blackboard bold [
  13959. defineMacro("\u27E7", "\\rrbracket"); // blackboard bold ]
  13960. defineMacro("\\lBrace", "\\html@mathml{" + "\\mathopen{\\{\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u2983}}");
  13961. defineMacro("\\rBrace", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu\\}}}" + "{\\mathclose{\\char`\u2984}}");
  13962. defineMacro("\u2983", "\\lBrace"); // blackboard bold {
  13963. defineMacro("\u2984", "\\rBrace"); // blackboard bold }
  13964. // TODO: Create variable sized versions of the last two items. I believe that
  13965. // will require new font glyphs.
  13966. // The stmaryrd function `\minuso` provides a "Plimsoll" symbol that
  13967. // superimposes the characters \circ and \mathminus. Used in chemistry.
  13968. defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + "{\\char`⦵}}");
  13969. defineMacro("⦵", "\\minuso"); //////////////////////////////////////////////////////////////////////
  13970. // texvc.sty
  13971. // The texvc package contains macros available in mediawiki pages.
  13972. // We omit the functions deprecated at
  13973. // https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax
  13974. // We also omit texvc's \O, which conflicts with \text{\O}
  13975. defineMacro("\\darr", "\\downarrow");
  13976. defineMacro("\\dArr", "\\Downarrow");
  13977. defineMacro("\\Darr", "\\Downarrow");
  13978. defineMacro("\\lang", "\\langle");
  13979. defineMacro("\\rang", "\\rangle");
  13980. defineMacro("\\uarr", "\\uparrow");
  13981. defineMacro("\\uArr", "\\Uparrow");
  13982. defineMacro("\\Uarr", "\\Uparrow");
  13983. defineMacro("\\N", "\\mathbb{N}");
  13984. defineMacro("\\R", "\\mathbb{R}");
  13985. defineMacro("\\Z", "\\mathbb{Z}");
  13986. defineMacro("\\alef", "\\aleph");
  13987. defineMacro("\\alefsym", "\\aleph");
  13988. defineMacro("\\Alpha", "\\mathrm{A}");
  13989. defineMacro("\\Beta", "\\mathrm{B}");
  13990. defineMacro("\\bull", "\\bullet");
  13991. defineMacro("\\Chi", "\\mathrm{X}");
  13992. defineMacro("\\clubs", "\\clubsuit");
  13993. defineMacro("\\cnums", "\\mathbb{C}");
  13994. defineMacro("\\Complex", "\\mathbb{C}");
  13995. defineMacro("\\Dagger", "\\ddagger");
  13996. defineMacro("\\diamonds", "\\diamondsuit");
  13997. defineMacro("\\empty", "\\emptyset");
  13998. defineMacro("\\Epsilon", "\\mathrm{E}");
  13999. defineMacro("\\Eta", "\\mathrm{H}");
  14000. defineMacro("\\exist", "\\exists");
  14001. defineMacro("\\harr", "\\leftrightarrow");
  14002. defineMacro("\\hArr", "\\Leftrightarrow");
  14003. defineMacro("\\Harr", "\\Leftrightarrow");
  14004. defineMacro("\\hearts", "\\heartsuit");
  14005. defineMacro("\\image", "\\Im");
  14006. defineMacro("\\infin", "\\infty");
  14007. defineMacro("\\Iota", "\\mathrm{I}");
  14008. defineMacro("\\isin", "\\in");
  14009. defineMacro("\\Kappa", "\\mathrm{K}");
  14010. defineMacro("\\larr", "\\leftarrow");
  14011. defineMacro("\\lArr", "\\Leftarrow");
  14012. defineMacro("\\Larr", "\\Leftarrow");
  14013. defineMacro("\\lrarr", "\\leftrightarrow");
  14014. defineMacro("\\lrArr", "\\Leftrightarrow");
  14015. defineMacro("\\Lrarr", "\\Leftrightarrow");
  14016. defineMacro("\\Mu", "\\mathrm{M}");
  14017. defineMacro("\\natnums", "\\mathbb{N}");
  14018. defineMacro("\\Nu", "\\mathrm{N}");
  14019. defineMacro("\\Omicron", "\\mathrm{O}");
  14020. defineMacro("\\plusmn", "\\pm");
  14021. defineMacro("\\rarr", "\\rightarrow");
  14022. defineMacro("\\rArr", "\\Rightarrow");
  14023. defineMacro("\\Rarr", "\\Rightarrow");
  14024. defineMacro("\\real", "\\Re");
  14025. defineMacro("\\reals", "\\mathbb{R}");
  14026. defineMacro("\\Reals", "\\mathbb{R}");
  14027. defineMacro("\\Rho", "\\mathrm{P}");
  14028. defineMacro("\\sdot", "\\cdot");
  14029. defineMacro("\\sect", "\\S");
  14030. defineMacro("\\spades", "\\spadesuit");
  14031. defineMacro("\\sub", "\\subset");
  14032. defineMacro("\\sube", "\\subseteq");
  14033. defineMacro("\\supe", "\\supseteq");
  14034. defineMacro("\\Tau", "\\mathrm{T}");
  14035. defineMacro("\\thetasym", "\\vartheta"); // TODO: defineMacro("\\varcoppa", "\\\mbox{\\coppa}");
  14036. defineMacro("\\weierp", "\\wp");
  14037. defineMacro("\\Zeta", "\\mathrm{Z}"); //////////////////////////////////////////////////////////////////////
  14038. // statmath.sty
  14039. // https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf
  14040. defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}");
  14041. defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}");
  14042. defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); //////////////////////////////////////////////////////////////////////
  14043. // braket.sty
  14044. // http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf
  14045. defineMacro("\\bra", "\\mathinner{\\langle{#1}|}");
  14046. defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}");
  14047. defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}");
  14048. defineMacro("\\Bra", "\\left\\langle#1\\right|");
  14049. defineMacro("\\Ket", "\\left|#1\\right\\rangle");
  14050. var braketHelper = function braketHelper(one) {
  14051. return function (context) {
  14052. var left = context.consumeArg().tokens;
  14053. var middle = context.consumeArg().tokens;
  14054. var middleDouble = context.consumeArg().tokens;
  14055. var right = context.consumeArg().tokens;
  14056. var oldMiddle = context.macros.get("|");
  14057. var oldMiddleDouble = context.macros.get("\\|");
  14058. context.macros.beginGroup();
  14059. var midMacro = function midMacro(double) {
  14060. return function (context) {
  14061. if (one) {
  14062. // Only modify the first instance of | or \|
  14063. context.macros.set("|", oldMiddle);
  14064. if (middleDouble.length) {
  14065. context.macros.set("\\|", oldMiddleDouble);
  14066. }
  14067. }
  14068. var doubled = double;
  14069. if (!double && middleDouble.length) {
  14070. // Mimic \@ifnextchar
  14071. var nextToken = context.future();
  14072. if (nextToken.text === "|") {
  14073. context.popToken();
  14074. doubled = true;
  14075. }
  14076. }
  14077. return {
  14078. tokens: doubled ? middleDouble : middle,
  14079. numArgs: 0
  14080. };
  14081. };
  14082. };
  14083. context.macros.set("|", midMacro(false));
  14084. if (middleDouble.length) {
  14085. context.macros.set("\\|", midMacro(true));
  14086. }
  14087. var arg = context.consumeArg().tokens;
  14088. var expanded = context.expandTokens([].concat(right, arg, left));
  14089. context.macros.endGroup();
  14090. return {
  14091. tokens: expanded.reverse(),
  14092. numArgs: 0
  14093. };
  14094. };
  14095. };
  14096. defineMacro("\\bra@ket", braketHelper(false));
  14097. defineMacro("\\bra@set", braketHelper(true));
  14098. defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}");
  14099. defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}");
  14100. defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"); // has no support for special || or \|
  14101. //////////////////////////////////////////////////////////////////////
  14102. // actuarialangle.dtx
  14103. defineMacro("\\angln", "{\\angl n}"); // Custom Khan Academy colors, should be moved to an optional package
  14104. defineMacro("\\blue", "\\textcolor{##6495ed}{#1}");
  14105. defineMacro("\\orange", "\\textcolor{##ffa500}{#1}");
  14106. defineMacro("\\pink", "\\textcolor{##ff00af}{#1}");
  14107. defineMacro("\\red", "\\textcolor{##df0030}{#1}");
  14108. defineMacro("\\green", "\\textcolor{##28ae7b}{#1}");
  14109. defineMacro("\\gray", "\\textcolor{gray}{#1}");
  14110. defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}");
  14111. defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}");
  14112. defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}");
  14113. defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}");
  14114. defineMacro("\\blueD", "\\textcolor{##11accd}{#1}");
  14115. defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}");
  14116. defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}");
  14117. defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}");
  14118. defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}");
  14119. defineMacro("\\tealD", "\\textcolor{##01a995}{#1}");
  14120. defineMacro("\\tealE", "\\textcolor{##208170}{#1}");
  14121. defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}");
  14122. defineMacro("\\greenB", "\\textcolor{##8af281}{#1}");
  14123. defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}");
  14124. defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}");
  14125. defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}");
  14126. defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}");
  14127. defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}");
  14128. defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}");
  14129. defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}");
  14130. defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}");
  14131. defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}");
  14132. defineMacro("\\redB", "\\textcolor{##ff8482}{#1}");
  14133. defineMacro("\\redC", "\\textcolor{##f9685d}{#1}");
  14134. defineMacro("\\redD", "\\textcolor{##e84d39}{#1}");
  14135. defineMacro("\\redE", "\\textcolor{##bc2612}{#1}");
  14136. defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}");
  14137. defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}");
  14138. defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}");
  14139. defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}");
  14140. defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}");
  14141. defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}");
  14142. defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}");
  14143. defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}");
  14144. defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}");
  14145. defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}");
  14146. defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}");
  14147. defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}");
  14148. defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}");
  14149. defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}");
  14150. defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}");
  14151. defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}");
  14152. defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}");
  14153. defineMacro("\\grayE", "\\textcolor{##babec2}{#1}");
  14154. defineMacro("\\grayF", "\\textcolor{##888d93}{#1}");
  14155. defineMacro("\\grayG", "\\textcolor{##626569}{#1}");
  14156. defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}");
  14157. defineMacro("\\grayI", "\\textcolor{##21242c}{#1}");
  14158. defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}");
  14159. defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}");
  14160. ;// CONCATENATED MODULE: ./src/MacroExpander.js
  14161. /**
  14162. * This file contains the “gullet” where macros are expanded
  14163. * until only non-macro tokens remain.
  14164. */
  14165. // List of commands that act like macros but aren't defined as a macro,
  14166. // function, or symbol. Used in `isDefined`.
  14167. var implicitCommands = {
  14168. "^": true,
  14169. // Parser.js
  14170. "_": true,
  14171. // Parser.js
  14172. "\\limits": true,
  14173. // Parser.js
  14174. "\\nolimits": true // Parser.js
  14175. };
  14176. var MacroExpander = /*#__PURE__*/function () {
  14177. function MacroExpander(input, settings, mode) {
  14178. this.settings = void 0;
  14179. this.expansionCount = void 0;
  14180. this.lexer = void 0;
  14181. this.macros = void 0;
  14182. this.stack = void 0;
  14183. this.mode = void 0;
  14184. this.settings = settings;
  14185. this.expansionCount = 0;
  14186. this.feed(input); // Make new global namespace
  14187. this.macros = new Namespace(src_macros, settings.macros);
  14188. this.mode = mode;
  14189. this.stack = []; // contains tokens in REVERSE order
  14190. }
  14191. /**
  14192. * Feed a new input string to the same MacroExpander
  14193. * (with existing macros etc.).
  14194. */
  14195. var _proto = MacroExpander.prototype;
  14196. _proto.feed = function feed(input) {
  14197. this.lexer = new Lexer(input, this.settings);
  14198. }
  14199. /**
  14200. * Switches between "text" and "math" modes.
  14201. */
  14202. ;
  14203. _proto.switchMode = function switchMode(newMode) {
  14204. this.mode = newMode;
  14205. }
  14206. /**
  14207. * Start a new group nesting within all namespaces.
  14208. */
  14209. ;
  14210. _proto.beginGroup = function beginGroup() {
  14211. this.macros.beginGroup();
  14212. }
  14213. /**
  14214. * End current group nesting within all namespaces.
  14215. */
  14216. ;
  14217. _proto.endGroup = function endGroup() {
  14218. this.macros.endGroup();
  14219. }
  14220. /**
  14221. * Ends all currently nested groups (if any), restoring values before the
  14222. * groups began. Useful in case of an error in the middle of parsing.
  14223. */
  14224. ;
  14225. _proto.endGroups = function endGroups() {
  14226. this.macros.endGroups();
  14227. }
  14228. /**
  14229. * Returns the topmost token on the stack, without expanding it.
  14230. * Similar in behavior to TeX's `\futurelet`.
  14231. */
  14232. ;
  14233. _proto.future = function future() {
  14234. if (this.stack.length === 0) {
  14235. this.pushToken(this.lexer.lex());
  14236. }
  14237. return this.stack[this.stack.length - 1];
  14238. }
  14239. /**
  14240. * Remove and return the next unexpanded token.
  14241. */
  14242. ;
  14243. _proto.popToken = function popToken() {
  14244. this.future(); // ensure non-empty stack
  14245. return this.stack.pop();
  14246. }
  14247. /**
  14248. * Add a given token to the token stack. In particular, this get be used
  14249. * to put back a token returned from one of the other methods.
  14250. */
  14251. ;
  14252. _proto.pushToken = function pushToken(token) {
  14253. this.stack.push(token);
  14254. }
  14255. /**
  14256. * Append an array of tokens to the token stack.
  14257. */
  14258. ;
  14259. _proto.pushTokens = function pushTokens(tokens) {
  14260. var _this$stack;
  14261. (_this$stack = this.stack).push.apply(_this$stack, tokens);
  14262. }
  14263. /**
  14264. * Find an macro argument without expanding tokens and append the array of
  14265. * tokens to the token stack. Uses Token as a container for the result.
  14266. */
  14267. ;
  14268. _proto.scanArgument = function scanArgument(isOptional) {
  14269. var start;
  14270. var end;
  14271. var tokens;
  14272. if (isOptional) {
  14273. this.consumeSpaces(); // \@ifnextchar gobbles any space following it
  14274. if (this.future().text !== "[") {
  14275. return null;
  14276. }
  14277. start = this.popToken(); // don't include [ in tokens
  14278. var _this$consumeArg = this.consumeArg(["]"]);
  14279. tokens = _this$consumeArg.tokens;
  14280. end = _this$consumeArg.end;
  14281. } else {
  14282. var _this$consumeArg2 = this.consumeArg();
  14283. tokens = _this$consumeArg2.tokens;
  14284. start = _this$consumeArg2.start;
  14285. end = _this$consumeArg2.end;
  14286. } // indicate the end of an argument
  14287. this.pushToken(new Token("EOF", end.loc));
  14288. this.pushTokens(tokens);
  14289. return start.range(end, "");
  14290. }
  14291. /**
  14292. * Consume all following space tokens, without expansion.
  14293. */
  14294. ;
  14295. _proto.consumeSpaces = function consumeSpaces() {
  14296. for (;;) {
  14297. var token = this.future();
  14298. if (token.text === " ") {
  14299. this.stack.pop();
  14300. } else {
  14301. break;
  14302. }
  14303. }
  14304. }
  14305. /**
  14306. * Consume an argument from the token stream, and return the resulting array
  14307. * of tokens and start/end token.
  14308. */
  14309. ;
  14310. _proto.consumeArg = function consumeArg(delims) {
  14311. // The argument for a delimited parameter is the shortest (possibly
  14312. // empty) sequence of tokens with properly nested {...} groups that is
  14313. // followed ... by this particular list of non-parameter tokens.
  14314. // The argument for an undelimited parameter is the next nonblank
  14315. // token, unless that token is ‘{’, when the argument will be the
  14316. // entire {...} group that follows.
  14317. var tokens = [];
  14318. var isDelimited = delims && delims.length > 0;
  14319. if (!isDelimited) {
  14320. // Ignore spaces between arguments. As the TeXbook says:
  14321. // "After you have said ‘\def\row#1#2{...}’, you are allowed to
  14322. // put spaces between the arguments (e.g., ‘\row x n’), because
  14323. // TeX doesn’t use single spaces as undelimited arguments."
  14324. this.consumeSpaces();
  14325. }
  14326. var start = this.future();
  14327. var tok;
  14328. var depth = 0;
  14329. var match = 0;
  14330. do {
  14331. tok = this.popToken();
  14332. tokens.push(tok);
  14333. if (tok.text === "{") {
  14334. ++depth;
  14335. } else if (tok.text === "}") {
  14336. --depth;
  14337. if (depth === -1) {
  14338. throw new src_ParseError("Extra }", tok);
  14339. }
  14340. } else if (tok.text === "EOF") {
  14341. throw new src_ParseError("Unexpected end of input in a macro argument" + ", expected '" + (delims && isDelimited ? delims[match] : "}") + "'", tok);
  14342. }
  14343. if (delims && isDelimited) {
  14344. if ((depth === 0 || depth === 1 && delims[match] === "{") && tok.text === delims[match]) {
  14345. ++match;
  14346. if (match === delims.length) {
  14347. // don't include delims in tokens
  14348. tokens.splice(-match, match);
  14349. break;
  14350. }
  14351. } else {
  14352. match = 0;
  14353. }
  14354. }
  14355. } while (depth !== 0 || isDelimited); // If the argument found ... has the form ‘{<nested tokens>}’,
  14356. // ... the outermost braces enclosing the argument are removed
  14357. if (start.text === "{" && tokens[tokens.length - 1].text === "}") {
  14358. tokens.pop();
  14359. tokens.shift();
  14360. }
  14361. tokens.reverse(); // to fit in with stack order
  14362. return {
  14363. tokens: tokens,
  14364. start: start,
  14365. end: tok
  14366. };
  14367. }
  14368. /**
  14369. * Consume the specified number of (delimited) arguments from the token
  14370. * stream and return the resulting array of arguments.
  14371. */
  14372. ;
  14373. _proto.consumeArgs = function consumeArgs(numArgs, delimiters) {
  14374. if (delimiters) {
  14375. if (delimiters.length !== numArgs + 1) {
  14376. throw new src_ParseError("The length of delimiters doesn't match the number of args!");
  14377. }
  14378. var delims = delimiters[0];
  14379. for (var i = 0; i < delims.length; i++) {
  14380. var tok = this.popToken();
  14381. if (delims[i] !== tok.text) {
  14382. throw new src_ParseError("Use of the macro doesn't match its definition", tok);
  14383. }
  14384. }
  14385. }
  14386. var args = [];
  14387. for (var _i = 0; _i < numArgs; _i++) {
  14388. args.push(this.consumeArg(delimiters && delimiters[_i + 1]).tokens);
  14389. }
  14390. return args;
  14391. }
  14392. /**
  14393. * Expand the next token only once if possible.
  14394. *
  14395. * If the token is expanded, the resulting tokens will be pushed onto
  14396. * the stack in reverse order and will be returned as an array,
  14397. * also in reverse order.
  14398. *
  14399. * If not, the next token will be returned without removing it
  14400. * from the stack. This case can be detected by a `Token` return value
  14401. * instead of an `Array` return value.
  14402. *
  14403. * In either case, the next token will be on the top of the stack,
  14404. * or the stack will be empty.
  14405. *
  14406. * Used to implement `expandAfterFuture` and `expandNextToken`.
  14407. *
  14408. * If expandableOnly, only expandable tokens are expanded and
  14409. * an undefined control sequence results in an error.
  14410. */
  14411. ;
  14412. _proto.expandOnce = function expandOnce(expandableOnly) {
  14413. var topToken = this.popToken();
  14414. var name = topToken.text;
  14415. var expansion = !topToken.noexpand ? this._getExpansion(name) : null;
  14416. if (expansion == null || expandableOnly && expansion.unexpandable) {
  14417. if (expandableOnly && expansion == null && name[0] === "\\" && !this.isDefined(name)) {
  14418. throw new src_ParseError("Undefined control sequence: " + name);
  14419. }
  14420. this.pushToken(topToken);
  14421. return topToken;
  14422. }
  14423. this.expansionCount++;
  14424. if (this.expansionCount > this.settings.maxExpand) {
  14425. throw new src_ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting");
  14426. }
  14427. var tokens = expansion.tokens;
  14428. var args = this.consumeArgs(expansion.numArgs, expansion.delimiters);
  14429. if (expansion.numArgs) {
  14430. // paste arguments in place of the placeholders
  14431. tokens = tokens.slice(); // make a shallow copy
  14432. for (var i = tokens.length - 1; i >= 0; --i) {
  14433. var tok = tokens[i];
  14434. if (tok.text === "#") {
  14435. if (i === 0) {
  14436. throw new src_ParseError("Incomplete placeholder at end of macro body", tok);
  14437. }
  14438. tok = tokens[--i]; // next token on stack
  14439. if (tok.text === "#") {
  14440. // ## → #
  14441. tokens.splice(i + 1, 1); // drop first #
  14442. } else if (/^[1-9]$/.test(tok.text)) {
  14443. var _tokens;
  14444. // replace the placeholder with the indicated argument
  14445. (_tokens = tokens).splice.apply(_tokens, [i, 2].concat(args[+tok.text - 1]));
  14446. } else {
  14447. throw new src_ParseError("Not a valid argument number", tok);
  14448. }
  14449. }
  14450. }
  14451. } // Concatenate expansion onto top of stack.
  14452. this.pushTokens(tokens);
  14453. return tokens;
  14454. }
  14455. /**
  14456. * Expand the next token only once (if possible), and return the resulting
  14457. * top token on the stack (without removing anything from the stack).
  14458. * Similar in behavior to TeX's `\expandafter\futurelet`.
  14459. * Equivalent to expandOnce() followed by future().
  14460. */
  14461. ;
  14462. _proto.expandAfterFuture = function expandAfterFuture() {
  14463. this.expandOnce();
  14464. return this.future();
  14465. }
  14466. /**
  14467. * Recursively expand first token, then return first non-expandable token.
  14468. */
  14469. ;
  14470. _proto.expandNextToken = function expandNextToken() {
  14471. for (;;) {
  14472. var expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded.
  14473. if (expanded instanceof Token) {
  14474. // the token after \noexpand is interpreted as if its meaning
  14475. // were ‘\relax’
  14476. if (expanded.treatAsRelax) {
  14477. expanded.text = "\\relax";
  14478. }
  14479. return this.stack.pop(); // === expanded
  14480. }
  14481. } // Flow unable to figure out that this pathway is impossible.
  14482. // https://github.com/facebook/flow/issues/4808
  14483. throw new Error(); // eslint-disable-line no-unreachable
  14484. }
  14485. /**
  14486. * Fully expand the given macro name and return the resulting list of
  14487. * tokens, or return `undefined` if no such macro is defined.
  14488. */
  14489. ;
  14490. _proto.expandMacro = function expandMacro(name) {
  14491. return this.macros.has(name) ? this.expandTokens([new Token(name)]) : undefined;
  14492. }
  14493. /**
  14494. * Fully expand the given token stream and return the resulting list of
  14495. * tokens. Note that the input tokens are in reverse order, but the
  14496. * output tokens are in forward order.
  14497. */
  14498. ;
  14499. _proto.expandTokens = function expandTokens(tokens) {
  14500. var output = [];
  14501. var oldStackLength = this.stack.length;
  14502. this.pushTokens(tokens);
  14503. while (this.stack.length > oldStackLength) {
  14504. var expanded = this.expandOnce(true); // expand only expandable tokens
  14505. // expandOnce returns Token if and only if it's fully expanded.
  14506. if (expanded instanceof Token) {
  14507. if (expanded.treatAsRelax) {
  14508. // the expansion of \noexpand is the token itself
  14509. expanded.noexpand = false;
  14510. expanded.treatAsRelax = false;
  14511. }
  14512. output.push(this.stack.pop());
  14513. }
  14514. }
  14515. return output;
  14516. }
  14517. /**
  14518. * Fully expand the given macro name and return the result as a string,
  14519. * or return `undefined` if no such macro is defined.
  14520. */
  14521. ;
  14522. _proto.expandMacroAsText = function expandMacroAsText(name) {
  14523. var tokens = this.expandMacro(name);
  14524. if (tokens) {
  14525. return tokens.map(function (token) {
  14526. return token.text;
  14527. }).join("");
  14528. } else {
  14529. return tokens;
  14530. }
  14531. }
  14532. /**
  14533. * Returns the expanded macro as a reversed array of tokens and a macro
  14534. * argument count. Or returns `null` if no such macro.
  14535. */
  14536. ;
  14537. _proto._getExpansion = function _getExpansion(name) {
  14538. var definition = this.macros.get(name);
  14539. if (definition == null) {
  14540. // mainly checking for undefined here
  14541. return definition;
  14542. } // If a single character has an associated catcode other than 13
  14543. // (active character), then don't expand it.
  14544. if (name.length === 1) {
  14545. var catcode = this.lexer.catcodes[name];
  14546. if (catcode != null && catcode !== 13) {
  14547. return;
  14548. }
  14549. }
  14550. var expansion = typeof definition === "function" ? definition(this) : definition;
  14551. if (typeof expansion === "string") {
  14552. var numArgs = 0;
  14553. if (expansion.indexOf("#") !== -1) {
  14554. var stripped = expansion.replace(/##/g, "");
  14555. while (stripped.indexOf("#" + (numArgs + 1)) !== -1) {
  14556. ++numArgs;
  14557. }
  14558. }
  14559. var bodyLexer = new Lexer(expansion, this.settings);
  14560. var tokens = [];
  14561. var tok = bodyLexer.lex();
  14562. while (tok.text !== "EOF") {
  14563. tokens.push(tok);
  14564. tok = bodyLexer.lex();
  14565. }
  14566. tokens.reverse(); // to fit in with stack using push and pop
  14567. var expanded = {
  14568. tokens: tokens,
  14569. numArgs: numArgs
  14570. };
  14571. return expanded;
  14572. }
  14573. return expansion;
  14574. }
  14575. /**
  14576. * Determine whether a command is currently "defined" (has some
  14577. * functionality), meaning that it's a macro (in the current group),
  14578. * a function, a symbol, or one of the special commands listed in
  14579. * `implicitCommands`.
  14580. */
  14581. ;
  14582. _proto.isDefined = function isDefined(name) {
  14583. return this.macros.has(name) || src_functions.hasOwnProperty(name) || src_symbols.math.hasOwnProperty(name) || src_symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name);
  14584. }
  14585. /**
  14586. * Determine whether a command is expandable.
  14587. */
  14588. ;
  14589. _proto.isExpandable = function isExpandable(name) {
  14590. var macro = this.macros.get(name);
  14591. return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable : src_functions.hasOwnProperty(name) && !src_functions[name].primitive;
  14592. };
  14593. return MacroExpander;
  14594. }();
  14595. ;// CONCATENATED MODULE: ./src/unicodeSupOrSub.js
  14596. // Helpers for Parser.js handling of Unicode (sub|super)script characters.
  14597. var unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/;
  14598. var uSubsAndSups = Object.freeze({
  14599. '₊': '+',
  14600. '₋': '-',
  14601. '₌': '=',
  14602. '₍': '(',
  14603. '₎': ')',
  14604. '₀': '0',
  14605. '₁': '1',
  14606. '₂': '2',
  14607. '₃': '3',
  14608. '₄': '4',
  14609. '₅': '5',
  14610. '₆': '6',
  14611. '₇': '7',
  14612. '₈': '8',
  14613. '₉': '9',
  14614. "\u2090": 'a',
  14615. "\u2091": 'e',
  14616. "\u2095": 'h',
  14617. "\u1D62": 'i',
  14618. "\u2C7C": 'j',
  14619. "\u2096": 'k',
  14620. "\u2097": 'l',
  14621. "\u2098": 'm',
  14622. "\u2099": 'n',
  14623. "\u2092": 'o',
  14624. "\u209A": 'p',
  14625. "\u1D63": 'r',
  14626. "\u209B": 's',
  14627. "\u209C": 't',
  14628. "\u1D64": 'u',
  14629. "\u1D65": 'v',
  14630. "\u2093": 'x',
  14631. "\u1D66": 'β',
  14632. "\u1D67": 'γ',
  14633. "\u1D68": 'ρ',
  14634. "\u1D69": "\u03D5",
  14635. "\u1D6A": 'χ',
  14636. '⁺': '+',
  14637. '⁻': '-',
  14638. '⁼': '=',
  14639. '⁽': '(',
  14640. '⁾': ')',
  14641. '⁰': '0',
  14642. '¹': '1',
  14643. '²': '2',
  14644. '³': '3',
  14645. '⁴': '4',
  14646. '⁵': '5',
  14647. '⁶': '6',
  14648. '⁷': '7',
  14649. '⁸': '8',
  14650. '⁹': '9',
  14651. "\u1D2C": 'A',
  14652. "\u1D2E": 'B',
  14653. "\u1D30": 'D',
  14654. "\u1D31": 'E',
  14655. "\u1D33": 'G',
  14656. "\u1D34": 'H',
  14657. "\u1D35": 'I',
  14658. "\u1D36": 'J',
  14659. "\u1D37": 'K',
  14660. "\u1D38": 'L',
  14661. "\u1D39": 'M',
  14662. "\u1D3A": 'N',
  14663. "\u1D3C": 'O',
  14664. "\u1D3E": 'P',
  14665. "\u1D3F": 'R',
  14666. "\u1D40": 'T',
  14667. "\u1D41": 'U',
  14668. "\u2C7D": 'V',
  14669. "\u1D42": 'W',
  14670. "\u1D43": 'a',
  14671. "\u1D47": 'b',
  14672. "\u1D9C": 'c',
  14673. "\u1D48": 'd',
  14674. "\u1D49": 'e',
  14675. "\u1DA0": 'f',
  14676. "\u1D4D": 'g',
  14677. "\u02B0": 'h',
  14678. "\u2071": 'i',
  14679. "\u02B2": 'j',
  14680. "\u1D4F": 'k',
  14681. "\u02E1": 'l',
  14682. "\u1D50": 'm',
  14683. "\u207F": 'n',
  14684. "\u1D52": 'o',
  14685. "\u1D56": 'p',
  14686. "\u02B3": 'r',
  14687. "\u02E2": 's',
  14688. "\u1D57": 't',
  14689. "\u1D58": 'u',
  14690. "\u1D5B": 'v',
  14691. "\u02B7": 'w',
  14692. "\u02E3": 'x',
  14693. "\u02B8": 'y',
  14694. "\u1DBB": 'z',
  14695. "\u1D5D": 'β',
  14696. "\u1D5E": 'γ',
  14697. "\u1D5F": 'δ',
  14698. "\u1D60": "\u03D5",
  14699. "\u1D61": 'χ',
  14700. "\u1DBF": 'θ'
  14701. });
  14702. ;// CONCATENATED MODULE: ./src/Parser.js
  14703. /* eslint no-constant-condition:0 */
  14704. // Pre-evaluate both modules as unicodeSymbols require String.normalize()
  14705. var unicodeAccents = {
  14706. "́": {
  14707. "text": "\\'",
  14708. "math": "\\acute"
  14709. },
  14710. "̀": {
  14711. "text": "\\`",
  14712. "math": "\\grave"
  14713. },
  14714. "̈": {
  14715. "text": "\\\"",
  14716. "math": "\\ddot"
  14717. },
  14718. "̃": {
  14719. "text": "\\~",
  14720. "math": "\\tilde"
  14721. },
  14722. "̄": {
  14723. "text": "\\=",
  14724. "math": "\\bar"
  14725. },
  14726. "̆": {
  14727. "text": "\\u",
  14728. "math": "\\breve"
  14729. },
  14730. "̌": {
  14731. "text": "\\v",
  14732. "math": "\\check"
  14733. },
  14734. "̂": {
  14735. "text": "\\^",
  14736. "math": "\\hat"
  14737. },
  14738. "̇": {
  14739. "text": "\\.",
  14740. "math": "\\dot"
  14741. },
  14742. "̊": {
  14743. "text": "\\r",
  14744. "math": "\\mathring"
  14745. },
  14746. "̋": {
  14747. "text": "\\H"
  14748. },
  14749. "̧": {
  14750. "text": "\\c"
  14751. }
  14752. };
  14753. var unicodeSymbols = {
  14754. "á": "á",
  14755. "à": "à",
  14756. "ä": "ä",
  14757. "ǟ": "ǟ",
  14758. "ã": "ã",
  14759. "ā": "ā",
  14760. "ă": "ă",
  14761. "ắ": "ắ",
  14762. "ằ": "ằ",
  14763. "ẵ": "ẵ",
  14764. "ǎ": "ǎ",
  14765. "â": "â",
  14766. "ấ": "ấ",
  14767. "ầ": "ầ",
  14768. "ẫ": "ẫ",
  14769. "ȧ": "ȧ",
  14770. "ǡ": "ǡ",
  14771. "å": "å",
  14772. "ǻ": "ǻ",
  14773. "ḃ": "ḃ",
  14774. "ć": "ć",
  14775. "ḉ": "ḉ",
  14776. "č": "č",
  14777. "ĉ": "ĉ",
  14778. "ċ": "ċ",
  14779. "ç": "ç",
  14780. "ď": "ď",
  14781. "ḋ": "ḋ",
  14782. "ḑ": "ḑ",
  14783. "é": "é",
  14784. "è": "è",
  14785. "ë": "ë",
  14786. "ẽ": "ẽ",
  14787. "ē": "ē",
  14788. "ḗ": "ḗ",
  14789. "ḕ": "ḕ",
  14790. "ĕ": "ĕ",
  14791. "ḝ": "ḝ",
  14792. "ě": "ě",
  14793. "ê": "ê",
  14794. "ế": "ế",
  14795. "ề": "ề",
  14796. "ễ": "ễ",
  14797. "ė": "ė",
  14798. "ȩ": "ȩ",
  14799. "ḟ": "ḟ",
  14800. "ǵ": "ǵ",
  14801. "ḡ": "ḡ",
  14802. "ğ": "ğ",
  14803. "ǧ": "ǧ",
  14804. "ĝ": "ĝ",
  14805. "ġ": "ġ",
  14806. "ģ": "ģ",
  14807. "ḧ": "ḧ",
  14808. "ȟ": "ȟ",
  14809. "ĥ": "ĥ",
  14810. "ḣ": "ḣ",
  14811. "ḩ": "ḩ",
  14812. "í": "í",
  14813. "ì": "ì",
  14814. "ï": "ï",
  14815. "ḯ": "ḯ",
  14816. "ĩ": "ĩ",
  14817. "ī": "ī",
  14818. "ĭ": "ĭ",
  14819. "ǐ": "ǐ",
  14820. "î": "î",
  14821. "ǰ": "ǰ",
  14822. "ĵ": "ĵ",
  14823. "ḱ": "ḱ",
  14824. "ǩ": "ǩ",
  14825. "ķ": "ķ",
  14826. "ĺ": "ĺ",
  14827. "ľ": "ľ",
  14828. "ļ": "ļ",
  14829. "ḿ": "ḿ",
  14830. "ṁ": "ṁ",
  14831. "ń": "ń",
  14832. "ǹ": "ǹ",
  14833. "ñ": "ñ",
  14834. "ň": "ň",
  14835. "ṅ": "ṅ",
  14836. "ņ": "ņ",
  14837. "ó": "ó",
  14838. "ò": "ò",
  14839. "ö": "ö",
  14840. "ȫ": "ȫ",
  14841. "õ": "õ",
  14842. "ṍ": "ṍ",
  14843. "ṏ": "ṏ",
  14844. "ȭ": "ȭ",
  14845. "ō": "ō",
  14846. "ṓ": "ṓ",
  14847. "ṑ": "ṑ",
  14848. "ŏ": "ŏ",
  14849. "ǒ": "ǒ",
  14850. "ô": "ô",
  14851. "ố": "ố",
  14852. "ồ": "ồ",
  14853. "ỗ": "ỗ",
  14854. "ȯ": "ȯ",
  14855. "ȱ": "ȱ",
  14856. "ő": "ő",
  14857. "ṕ": "ṕ",
  14858. "ṗ": "ṗ",
  14859. "ŕ": "ŕ",
  14860. "ř": "ř",
  14861. "ṙ": "ṙ",
  14862. "ŗ": "ŗ",
  14863. "ś": "ś",
  14864. "ṥ": "ṥ",
  14865. "š": "š",
  14866. "ṧ": "ṧ",
  14867. "ŝ": "ŝ",
  14868. "ṡ": "ṡ",
  14869. "ş": "ş",
  14870. "ẗ": "ẗ",
  14871. "ť": "ť",
  14872. "ṫ": "ṫ",
  14873. "ţ": "ţ",
  14874. "ú": "ú",
  14875. "ù": "ù",
  14876. "ü": "ü",
  14877. "ǘ": "ǘ",
  14878. "ǜ": "ǜ",
  14879. "ǖ": "ǖ",
  14880. "ǚ": "ǚ",
  14881. "ũ": "ũ",
  14882. "ṹ": "ṹ",
  14883. "ū": "ū",
  14884. "ṻ": "ṻ",
  14885. "ŭ": "ŭ",
  14886. "ǔ": "ǔ",
  14887. "û": "û",
  14888. "ů": "ů",
  14889. "ű": "ű",
  14890. "ṽ": "ṽ",
  14891. "ẃ": "ẃ",
  14892. "ẁ": "ẁ",
  14893. "ẅ": "ẅ",
  14894. "ŵ": "ŵ",
  14895. "ẇ": "ẇ",
  14896. "ẘ": "ẘ",
  14897. "ẍ": "ẍ",
  14898. "ẋ": "ẋ",
  14899. "ý": "ý",
  14900. "ỳ": "ỳ",
  14901. "ÿ": "ÿ",
  14902. "ỹ": "ỹ",
  14903. "ȳ": "ȳ",
  14904. "ŷ": "ŷ",
  14905. "ẏ": "ẏ",
  14906. "ẙ": "ẙ",
  14907. "ź": "ź",
  14908. "ž": "ž",
  14909. "ẑ": "ẑ",
  14910. "ż": "ż",
  14911. "Á": "Á",
  14912. "À": "À",
  14913. "Ä": "Ä",
  14914. "Ǟ": "Ǟ",
  14915. "Ã": "Ã",
  14916. "Ā": "Ā",
  14917. "Ă": "Ă",
  14918. "Ắ": "Ắ",
  14919. "Ằ": "Ằ",
  14920. "Ẵ": "Ẵ",
  14921. "Ǎ": "Ǎ",
  14922. "Â": "Â",
  14923. "Ấ": "Ấ",
  14924. "Ầ": "Ầ",
  14925. "Ẫ": "Ẫ",
  14926. "Ȧ": "Ȧ",
  14927. "Ǡ": "Ǡ",
  14928. "Å": "Å",
  14929. "Ǻ": "Ǻ",
  14930. "Ḃ": "Ḃ",
  14931. "Ć": "Ć",
  14932. "Ḉ": "Ḉ",
  14933. "Č": "Č",
  14934. "Ĉ": "Ĉ",
  14935. "Ċ": "Ċ",
  14936. "Ç": "Ç",
  14937. "Ď": "Ď",
  14938. "Ḋ": "Ḋ",
  14939. "Ḑ": "Ḑ",
  14940. "É": "É",
  14941. "È": "È",
  14942. "Ë": "Ë",
  14943. "Ẽ": "Ẽ",
  14944. "Ē": "Ē",
  14945. "Ḗ": "Ḗ",
  14946. "Ḕ": "Ḕ",
  14947. "Ĕ": "Ĕ",
  14948. "Ḝ": "Ḝ",
  14949. "Ě": "Ě",
  14950. "Ê": "Ê",
  14951. "Ế": "Ế",
  14952. "Ề": "Ề",
  14953. "Ễ": "Ễ",
  14954. "Ė": "Ė",
  14955. "Ȩ": "Ȩ",
  14956. "Ḟ": "Ḟ",
  14957. "Ǵ": "Ǵ",
  14958. "Ḡ": "Ḡ",
  14959. "Ğ": "Ğ",
  14960. "Ǧ": "Ǧ",
  14961. "Ĝ": "Ĝ",
  14962. "Ġ": "Ġ",
  14963. "Ģ": "Ģ",
  14964. "Ḧ": "Ḧ",
  14965. "Ȟ": "Ȟ",
  14966. "Ĥ": "Ĥ",
  14967. "Ḣ": "Ḣ",
  14968. "Ḩ": "Ḩ",
  14969. "Í": "Í",
  14970. "Ì": "Ì",
  14971. "Ï": "Ï",
  14972. "Ḯ": "Ḯ",
  14973. "Ĩ": "Ĩ",
  14974. "Ī": "Ī",
  14975. "Ĭ": "Ĭ",
  14976. "Ǐ": "Ǐ",
  14977. "Î": "Î",
  14978. "İ": "İ",
  14979. "Ĵ": "Ĵ",
  14980. "Ḱ": "Ḱ",
  14981. "Ǩ": "Ǩ",
  14982. "Ķ": "Ķ",
  14983. "Ĺ": "Ĺ",
  14984. "Ľ": "Ľ",
  14985. "Ļ": "Ļ",
  14986. "Ḿ": "Ḿ",
  14987. "Ṁ": "Ṁ",
  14988. "Ń": "Ń",
  14989. "Ǹ": "Ǹ",
  14990. "Ñ": "Ñ",
  14991. "Ň": "Ň",
  14992. "Ṅ": "Ṅ",
  14993. "Ņ": "Ņ",
  14994. "Ó": "Ó",
  14995. "Ò": "Ò",
  14996. "Ö": "Ö",
  14997. "Ȫ": "Ȫ",
  14998. "Õ": "Õ",
  14999. "Ṍ": "Ṍ",
  15000. "Ṏ": "Ṏ",
  15001. "Ȭ": "Ȭ",
  15002. "Ō": "Ō",
  15003. "Ṓ": "Ṓ",
  15004. "Ṑ": "Ṑ",
  15005. "Ŏ": "Ŏ",
  15006. "Ǒ": "Ǒ",
  15007. "Ô": "Ô",
  15008. "Ố": "Ố",
  15009. "Ồ": "Ồ",
  15010. "Ỗ": "Ỗ",
  15011. "Ȯ": "Ȯ",
  15012. "Ȱ": "Ȱ",
  15013. "Ő": "Ő",
  15014. "Ṕ": "Ṕ",
  15015. "Ṗ": "Ṗ",
  15016. "Ŕ": "Ŕ",
  15017. "Ř": "Ř",
  15018. "Ṙ": "Ṙ",
  15019. "Ŗ": "Ŗ",
  15020. "Ś": "Ś",
  15021. "Ṥ": "Ṥ",
  15022. "Š": "Š",
  15023. "Ṧ": "Ṧ",
  15024. "Ŝ": "Ŝ",
  15025. "Ṡ": "Ṡ",
  15026. "Ş": "Ş",
  15027. "Ť": "Ť",
  15028. "Ṫ": "Ṫ",
  15029. "Ţ": "Ţ",
  15030. "Ú": "Ú",
  15031. "Ù": "Ù",
  15032. "Ü": "Ü",
  15033. "Ǘ": "Ǘ",
  15034. "Ǜ": "Ǜ",
  15035. "Ǖ": "Ǖ",
  15036. "Ǚ": "Ǚ",
  15037. "Ũ": "Ũ",
  15038. "Ṹ": "Ṹ",
  15039. "Ū": "Ū",
  15040. "Ṻ": "Ṻ",
  15041. "Ŭ": "Ŭ",
  15042. "Ǔ": "Ǔ",
  15043. "Û": "Û",
  15044. "Ů": "Ů",
  15045. "Ű": "Ű",
  15046. "Ṽ": "Ṽ",
  15047. "Ẃ": "Ẃ",
  15048. "Ẁ": "Ẁ",
  15049. "Ẅ": "Ẅ",
  15050. "Ŵ": "Ŵ",
  15051. "Ẇ": "Ẇ",
  15052. "Ẍ": "Ẍ",
  15053. "Ẋ": "Ẋ",
  15054. "Ý": "Ý",
  15055. "Ỳ": "Ỳ",
  15056. "Ÿ": "Ÿ",
  15057. "Ỹ": "Ỹ",
  15058. "Ȳ": "Ȳ",
  15059. "Ŷ": "Ŷ",
  15060. "Ẏ": "Ẏ",
  15061. "Ź": "Ź",
  15062. "Ž": "Ž",
  15063. "Ẑ": "Ẑ",
  15064. "Ż": "Ż",
  15065. "ά": "ά",
  15066. "ὰ": "ὰ",
  15067. "ᾱ": "ᾱ",
  15068. "ᾰ": "ᾰ",
  15069. "έ": "έ",
  15070. "ὲ": "ὲ",
  15071. "ή": "ή",
  15072. "ὴ": "ὴ",
  15073. "ί": "ί",
  15074. "ὶ": "ὶ",
  15075. "ϊ": "ϊ",
  15076. "ΐ": "ΐ",
  15077. "ῒ": "ῒ",
  15078. "ῑ": "ῑ",
  15079. "ῐ": "ῐ",
  15080. "ό": "ό",
  15081. "ὸ": "ὸ",
  15082. "ύ": "ύ",
  15083. "ὺ": "ὺ",
  15084. "ϋ": "ϋ",
  15085. "ΰ": "ΰ",
  15086. "ῢ": "ῢ",
  15087. "ῡ": "ῡ",
  15088. "ῠ": "ῠ",
  15089. "ώ": "ώ",
  15090. "ὼ": "ὼ",
  15091. "Ύ": "Ύ",
  15092. "Ὺ": "Ὺ",
  15093. "Ϋ": "Ϋ",
  15094. "Ῡ": "Ῡ",
  15095. "Ῠ": "Ῠ",
  15096. "Ώ": "Ώ",
  15097. "Ὼ": "Ὼ"
  15098. };
  15099. /**
  15100. * This file contains the parser used to parse out a TeX expression from the
  15101. * input. Since TeX isn't context-free, standard parsers don't work particularly
  15102. * well.
  15103. *
  15104. * The strategy of this parser is as such:
  15105. *
  15106. * The main functions (the `.parse...` ones) take a position in the current
  15107. * parse string to parse tokens from. The lexer (found in Lexer.js, stored at
  15108. * this.gullet.lexer) also supports pulling out tokens at arbitrary places. When
  15109. * individual tokens are needed at a position, the lexer is called to pull out a
  15110. * token, which is then used.
  15111. *
  15112. * The parser has a property called "mode" indicating the mode that
  15113. * the parser is currently in. Currently it has to be one of "math" or
  15114. * "text", which denotes whether the current environment is a math-y
  15115. * one or a text-y one (e.g. inside \text). Currently, this serves to
  15116. * limit the functions which can be used in text mode.
  15117. *
  15118. * The main functions then return an object which contains the useful data that
  15119. * was parsed at its given point, and a new position at the end of the parsed
  15120. * data. The main functions can call each other and continue the parsing by
  15121. * using the returned position as a new starting point.
  15122. *
  15123. * There are also extra `.handle...` functions, which pull out some reused
  15124. * functionality into self-contained functions.
  15125. *
  15126. * The functions return ParseNodes.
  15127. */
  15128. var Parser = /*#__PURE__*/function () {
  15129. function Parser(input, settings) {
  15130. this.mode = void 0;
  15131. this.gullet = void 0;
  15132. this.settings = void 0;
  15133. this.leftrightDepth = void 0;
  15134. this.nextToken = void 0;
  15135. // Start in math mode
  15136. this.mode = "math"; // Create a new macro expander (gullet) and (indirectly via that) also a
  15137. // new lexer (mouth) for this parser (stomach, in the language of TeX)
  15138. this.gullet = new MacroExpander(input, settings, this.mode); // Store the settings for use in parsing
  15139. this.settings = settings; // Count leftright depth (for \middle errors)
  15140. this.leftrightDepth = 0;
  15141. }
  15142. /**
  15143. * Checks a result to make sure it has the right type, and throws an
  15144. * appropriate error otherwise.
  15145. */
  15146. var _proto = Parser.prototype;
  15147. _proto.expect = function expect(text, consume) {
  15148. if (consume === void 0) {
  15149. consume = true;
  15150. }
  15151. if (this.fetch().text !== text) {
  15152. throw new src_ParseError("Expected '" + text + "', got '" + this.fetch().text + "'", this.fetch());
  15153. }
  15154. if (consume) {
  15155. this.consume();
  15156. }
  15157. }
  15158. /**
  15159. * Discards the current lookahead token, considering it consumed.
  15160. */
  15161. ;
  15162. _proto.consume = function consume() {
  15163. this.nextToken = null;
  15164. }
  15165. /**
  15166. * Return the current lookahead token, or if there isn't one (at the
  15167. * beginning, or if the previous lookahead token was consume()d),
  15168. * fetch the next token as the new lookahead token and return it.
  15169. */
  15170. ;
  15171. _proto.fetch = function fetch() {
  15172. if (this.nextToken == null) {
  15173. this.nextToken = this.gullet.expandNextToken();
  15174. }
  15175. return this.nextToken;
  15176. }
  15177. /**
  15178. * Switches between "text" and "math" modes.
  15179. */
  15180. ;
  15181. _proto.switchMode = function switchMode(newMode) {
  15182. this.mode = newMode;
  15183. this.gullet.switchMode(newMode);
  15184. }
  15185. /**
  15186. * Main parsing function, which parses an entire input.
  15187. */
  15188. ;
  15189. _proto.parse = function parse() {
  15190. if (!this.settings.globalGroup) {
  15191. // Create a group namespace for the math expression.
  15192. // (LaTeX creates a new group for every $...$, $$...$$, \[...\].)
  15193. this.gullet.beginGroup();
  15194. } // Use old \color behavior (same as LaTeX's \textcolor) if requested.
  15195. // We do this within the group for the math expression, so it doesn't
  15196. // pollute settings.macros.
  15197. if (this.settings.colorIsTextColor) {
  15198. this.gullet.macros.set("\\color", "\\textcolor");
  15199. }
  15200. try {
  15201. // Try to parse the input
  15202. var parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end
  15203. this.expect("EOF"); // End the group namespace for the expression
  15204. if (!this.settings.globalGroup) {
  15205. this.gullet.endGroup();
  15206. }
  15207. return parse; // Close any leftover groups in case of a parse error.
  15208. } finally {
  15209. this.gullet.endGroups();
  15210. }
  15211. }
  15212. /**
  15213. * Fully parse a separate sequence of tokens as a separate job.
  15214. * Tokens should be specified in reverse order, as in a MacroDefinition.
  15215. */
  15216. ;
  15217. _proto.subparse = function subparse(tokens) {
  15218. // Save the next token from the current job.
  15219. var oldToken = this.nextToken;
  15220. this.consume(); // Run the new job, terminating it with an excess '}'
  15221. this.gullet.pushToken(new Token("}"));
  15222. this.gullet.pushTokens(tokens);
  15223. var parse = this.parseExpression(false);
  15224. this.expect("}"); // Restore the next token from the current job.
  15225. this.nextToken = oldToken;
  15226. return parse;
  15227. };
  15228. /**
  15229. * Parses an "expression", which is a list of atoms.
  15230. *
  15231. * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This
  15232. * happens when functions have higher precendence han infix
  15233. * nodes in implicit parses.
  15234. *
  15235. * `breakOnTokenText`: The text of the token that the expression should end
  15236. * with, or `null` if something else should end the
  15237. * expression.
  15238. */
  15239. _proto.parseExpression = function parseExpression(breakOnInfix, breakOnTokenText) {
  15240. var body = []; // Keep adding atoms to the body until we can't parse any more atoms (either
  15241. // we reached the end, a }, or a \right)
  15242. while (true) {
  15243. // Ignore spaces in math mode
  15244. if (this.mode === "math") {
  15245. this.consumeSpaces();
  15246. }
  15247. var lex = this.fetch();
  15248. if (Parser.endOfExpression.indexOf(lex.text) !== -1) {
  15249. break;
  15250. }
  15251. if (breakOnTokenText && lex.text === breakOnTokenText) {
  15252. break;
  15253. }
  15254. if (breakOnInfix && src_functions[lex.text] && src_functions[lex.text].infix) {
  15255. break;
  15256. }
  15257. var atom = this.parseAtom(breakOnTokenText);
  15258. if (!atom) {
  15259. break;
  15260. } else if (atom.type === "internal") {
  15261. continue;
  15262. }
  15263. body.push(atom);
  15264. }
  15265. if (this.mode === "text") {
  15266. this.formLigatures(body);
  15267. }
  15268. return this.handleInfixNodes(body);
  15269. }
  15270. /**
  15271. * Rewrites infix operators such as \over with corresponding commands such
  15272. * as \frac.
  15273. *
  15274. * There can only be one infix operator per group. If there's more than one
  15275. * then the expression is ambiguous. This can be resolved by adding {}.
  15276. */
  15277. ;
  15278. _proto.handleInfixNodes = function handleInfixNodes(body) {
  15279. var overIndex = -1;
  15280. var funcName;
  15281. for (var i = 0; i < body.length; i++) {
  15282. if (body[i].type === "infix") {
  15283. if (overIndex !== -1) {
  15284. throw new src_ParseError("only one infix operator per group", body[i].token);
  15285. }
  15286. overIndex = i;
  15287. funcName = body[i].replaceWith;
  15288. }
  15289. }
  15290. if (overIndex !== -1 && funcName) {
  15291. var numerNode;
  15292. var denomNode;
  15293. var numerBody = body.slice(0, overIndex);
  15294. var denomBody = body.slice(overIndex + 1);
  15295. if (numerBody.length === 1 && numerBody[0].type === "ordgroup") {
  15296. numerNode = numerBody[0];
  15297. } else {
  15298. numerNode = {
  15299. type: "ordgroup",
  15300. mode: this.mode,
  15301. body: numerBody
  15302. };
  15303. }
  15304. if (denomBody.length === 1 && denomBody[0].type === "ordgroup") {
  15305. denomNode = denomBody[0];
  15306. } else {
  15307. denomNode = {
  15308. type: "ordgroup",
  15309. mode: this.mode,
  15310. body: denomBody
  15311. };
  15312. }
  15313. var node;
  15314. if (funcName === "\\\\abovefrac") {
  15315. node = this.callFunction(funcName, [numerNode, body[overIndex], denomNode], []);
  15316. } else {
  15317. node = this.callFunction(funcName, [numerNode, denomNode], []);
  15318. }
  15319. return [node];
  15320. } else {
  15321. return body;
  15322. }
  15323. }
  15324. /**
  15325. * Handle a subscript or superscript with nice errors.
  15326. */
  15327. ;
  15328. _proto.handleSupSubscript = function handleSupSubscript(name // For error reporting.
  15329. ) {
  15330. var symbolToken = this.fetch();
  15331. var symbol = symbolToken.text;
  15332. this.consume();
  15333. this.consumeSpaces(); // ignore spaces before sup/subscript argument
  15334. var group = this.parseGroup(name);
  15335. if (!group) {
  15336. throw new src_ParseError("Expected group after '" + symbol + "'", symbolToken);
  15337. }
  15338. return group;
  15339. }
  15340. /**
  15341. * Converts the textual input of an unsupported command into a text node
  15342. * contained within a color node whose color is determined by errorColor
  15343. */
  15344. ;
  15345. _proto.formatUnsupportedCmd = function formatUnsupportedCmd(text) {
  15346. var textordArray = [];
  15347. for (var i = 0; i < text.length; i++) {
  15348. textordArray.push({
  15349. type: "textord",
  15350. mode: "text",
  15351. text: text[i]
  15352. });
  15353. }
  15354. var textNode = {
  15355. type: "text",
  15356. mode: this.mode,
  15357. body: textordArray
  15358. };
  15359. var colorNode = {
  15360. type: "color",
  15361. mode: this.mode,
  15362. color: this.settings.errorColor,
  15363. body: [textNode]
  15364. };
  15365. return colorNode;
  15366. }
  15367. /**
  15368. * Parses a group with optional super/subscripts.
  15369. */
  15370. ;
  15371. _proto.parseAtom = function parseAtom(breakOnTokenText) {
  15372. // The body of an atom is an implicit group, so that things like
  15373. // \left(x\right)^2 work correctly.
  15374. var base = this.parseGroup("atom", breakOnTokenText); // In text mode, we don't have superscripts or subscripts
  15375. if (this.mode === "text") {
  15376. return base;
  15377. } // Note that base may be empty (i.e. null) at this point.
  15378. var superscript;
  15379. var subscript;
  15380. while (true) {
  15381. // Guaranteed in math mode, so eat any spaces first.
  15382. this.consumeSpaces(); // Lex the first token
  15383. var lex = this.fetch();
  15384. if (lex.text === "\\limits" || lex.text === "\\nolimits") {
  15385. // We got a limit control
  15386. if (base && base.type === "op") {
  15387. var limits = lex.text === "\\limits";
  15388. base.limits = limits;
  15389. base.alwaysHandleSupSub = true;
  15390. } else if (base && base.type === "operatorname") {
  15391. if (base.alwaysHandleSupSub) {
  15392. base.limits = lex.text === "\\limits";
  15393. }
  15394. } else {
  15395. throw new src_ParseError("Limit controls must follow a math operator", lex);
  15396. }
  15397. this.consume();
  15398. } else if (lex.text === "^") {
  15399. // We got a superscript start
  15400. if (superscript) {
  15401. throw new src_ParseError("Double superscript", lex);
  15402. }
  15403. superscript = this.handleSupSubscript("superscript");
  15404. } else if (lex.text === "_") {
  15405. // We got a subscript start
  15406. if (subscript) {
  15407. throw new src_ParseError("Double subscript", lex);
  15408. }
  15409. subscript = this.handleSupSubscript("subscript");
  15410. } else if (lex.text === "'") {
  15411. // We got a prime
  15412. if (superscript) {
  15413. throw new src_ParseError("Double superscript", lex);
  15414. }
  15415. var prime = {
  15416. type: "textord",
  15417. mode: this.mode,
  15418. text: "\\prime"
  15419. }; // Many primes can be grouped together, so we handle this here
  15420. var primes = [prime];
  15421. this.consume(); // Keep lexing tokens until we get something that's not a prime
  15422. while (this.fetch().text === "'") {
  15423. // For each one, add another prime to the list
  15424. primes.push(prime);
  15425. this.consume();
  15426. } // If there's a superscript following the primes, combine that
  15427. // superscript in with the primes.
  15428. if (this.fetch().text === "^") {
  15429. primes.push(this.handleSupSubscript("superscript"));
  15430. } // Put everything into an ordgroup as the superscript
  15431. superscript = {
  15432. type: "ordgroup",
  15433. mode: this.mode,
  15434. body: primes
  15435. };
  15436. } else if (uSubsAndSups[lex.text]) {
  15437. // A Unicode subscript or superscript character.
  15438. // We treat these similarly to the unicode-math package.
  15439. // So we render a string of Unicode (sub|super)scripts the
  15440. // same as a (sub|super)script of regular characters.
  15441. var str = uSubsAndSups[lex.text];
  15442. var isSub = unicodeSubRegEx.test(lex.text);
  15443. this.consume(); // Continue fetching tokens to fill out the string.
  15444. while (true) {
  15445. var token = this.fetch().text;
  15446. if (!uSubsAndSups[token]) {
  15447. break;
  15448. }
  15449. if (unicodeSubRegEx.test(token) !== isSub) {
  15450. break;
  15451. }
  15452. this.consume();
  15453. str += uSubsAndSups[token];
  15454. } // Now create a (sub|super)script.
  15455. var body = new Parser(str, this.settings).parse();
  15456. if (isSub) {
  15457. subscript = {
  15458. type: "ordgroup",
  15459. mode: "math",
  15460. body: body
  15461. };
  15462. } else {
  15463. superscript = {
  15464. type: "ordgroup",
  15465. mode: "math",
  15466. body: body
  15467. };
  15468. }
  15469. } else {
  15470. // If it wasn't ^, _, or ', stop parsing super/subscripts
  15471. break;
  15472. }
  15473. } // Base must be set if superscript or subscript are set per logic above,
  15474. // but need to check here for type check to pass.
  15475. if (superscript || subscript) {
  15476. // If we got either a superscript or subscript, create a supsub
  15477. return {
  15478. type: "supsub",
  15479. mode: this.mode,
  15480. base: base,
  15481. sup: superscript,
  15482. sub: subscript
  15483. };
  15484. } else {
  15485. // Otherwise return the original body
  15486. return base;
  15487. }
  15488. }
  15489. /**
  15490. * Parses an entire function, including its base and all of its arguments.
  15491. */
  15492. ;
  15493. _proto.parseFunction = function parseFunction(breakOnTokenText, name // For determining its context
  15494. ) {
  15495. var token = this.fetch();
  15496. var func = token.text;
  15497. var funcData = src_functions[func];
  15498. if (!funcData) {
  15499. return null;
  15500. }
  15501. this.consume(); // consume command token
  15502. if (name && name !== "atom" && !funcData.allowedInArgument) {
  15503. throw new src_ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token);
  15504. } else if (this.mode === "text" && !funcData.allowedInText) {
  15505. throw new src_ParseError("Can't use function '" + func + "' in text mode", token);
  15506. } else if (this.mode === "math" && funcData.allowedInMath === false) {
  15507. throw new src_ParseError("Can't use function '" + func + "' in math mode", token);
  15508. }
  15509. var _this$parseArguments = this.parseArguments(func, funcData),
  15510. args = _this$parseArguments.args,
  15511. optArgs = _this$parseArguments.optArgs;
  15512. return this.callFunction(func, args, optArgs, token, breakOnTokenText);
  15513. }
  15514. /**
  15515. * Call a function handler with a suitable context and arguments.
  15516. */
  15517. ;
  15518. _proto.callFunction = function callFunction(name, args, optArgs, token, breakOnTokenText) {
  15519. var context = {
  15520. funcName: name,
  15521. parser: this,
  15522. token: token,
  15523. breakOnTokenText: breakOnTokenText
  15524. };
  15525. var func = src_functions[name];
  15526. if (func && func.handler) {
  15527. return func.handler(context, args, optArgs);
  15528. } else {
  15529. throw new src_ParseError("No function handler for " + name);
  15530. }
  15531. }
  15532. /**
  15533. * Parses the arguments of a function or environment
  15534. */
  15535. ;
  15536. _proto.parseArguments = function parseArguments(func, // Should look like "\name" or "\begin{name}".
  15537. funcData) {
  15538. var totalArgs = funcData.numArgs + funcData.numOptionalArgs;
  15539. if (totalArgs === 0) {
  15540. return {
  15541. args: [],
  15542. optArgs: []
  15543. };
  15544. }
  15545. var args = [];
  15546. var optArgs = [];
  15547. for (var i = 0; i < totalArgs; i++) {
  15548. var argType = funcData.argTypes && funcData.argTypes[i];
  15549. var isOptional = i < funcData.numOptionalArgs;
  15550. if (funcData.primitive && argType == null || // \sqrt expands into primitive if optional argument doesn't exist
  15551. funcData.type === "sqrt" && i === 1 && optArgs[0] == null) {
  15552. argType = "primitive";
  15553. }
  15554. var arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional);
  15555. if (isOptional) {
  15556. optArgs.push(arg);
  15557. } else if (arg != null) {
  15558. args.push(arg);
  15559. } else {
  15560. // should be unreachable
  15561. throw new src_ParseError("Null argument, please report this as a bug");
  15562. }
  15563. }
  15564. return {
  15565. args: args,
  15566. optArgs: optArgs
  15567. };
  15568. }
  15569. /**
  15570. * Parses a group when the mode is changing.
  15571. */
  15572. ;
  15573. _proto.parseGroupOfType = function parseGroupOfType(name, type, optional) {
  15574. switch (type) {
  15575. case "color":
  15576. return this.parseColorGroup(optional);
  15577. case "size":
  15578. return this.parseSizeGroup(optional);
  15579. case "url":
  15580. return this.parseUrlGroup(optional);
  15581. case "math":
  15582. case "text":
  15583. return this.parseArgumentGroup(optional, type);
  15584. case "hbox":
  15585. {
  15586. // hbox argument type wraps the argument in the equivalent of
  15587. // \hbox, which is like \text but switching to \textstyle size.
  15588. var group = this.parseArgumentGroup(optional, "text");
  15589. return group != null ? {
  15590. type: "styling",
  15591. mode: group.mode,
  15592. body: [group],
  15593. style: "text" // simulate \textstyle
  15594. } : null;
  15595. }
  15596. case "raw":
  15597. {
  15598. var token = this.parseStringGroup("raw", optional);
  15599. return token != null ? {
  15600. type: "raw",
  15601. mode: "text",
  15602. string: token.text
  15603. } : null;
  15604. }
  15605. case "primitive":
  15606. {
  15607. if (optional) {
  15608. throw new src_ParseError("A primitive argument cannot be optional");
  15609. }
  15610. var _group = this.parseGroup(name);
  15611. if (_group == null) {
  15612. throw new src_ParseError("Expected group as " + name, this.fetch());
  15613. }
  15614. return _group;
  15615. }
  15616. case "original":
  15617. case null:
  15618. case undefined:
  15619. return this.parseArgumentGroup(optional);
  15620. default:
  15621. throw new src_ParseError("Unknown group type as " + name, this.fetch());
  15622. }
  15623. }
  15624. /**
  15625. * Discard any space tokens, fetching the next non-space token.
  15626. */
  15627. ;
  15628. _proto.consumeSpaces = function consumeSpaces() {
  15629. while (this.fetch().text === " ") {
  15630. this.consume();
  15631. }
  15632. }
  15633. /**
  15634. * Parses a group, essentially returning the string formed by the
  15635. * brace-enclosed tokens plus some position information.
  15636. */
  15637. ;
  15638. _proto.parseStringGroup = function parseStringGroup(modeName, // Used to describe the mode in error messages.
  15639. optional) {
  15640. var argToken = this.gullet.scanArgument(optional);
  15641. if (argToken == null) {
  15642. return null;
  15643. }
  15644. var str = "";
  15645. var nextToken;
  15646. while ((nextToken = this.fetch()).text !== "EOF") {
  15647. str += nextToken.text;
  15648. this.consume();
  15649. }
  15650. this.consume(); // consume the end of the argument
  15651. argToken.text = str;
  15652. return argToken;
  15653. }
  15654. /**
  15655. * Parses a regex-delimited group: the largest sequence of tokens
  15656. * whose concatenated strings match `regex`. Returns the string
  15657. * formed by the tokens plus some position information.
  15658. */
  15659. ;
  15660. _proto.parseRegexGroup = function parseRegexGroup(regex, modeName // Used to describe the mode in error messages.
  15661. ) {
  15662. var firstToken = this.fetch();
  15663. var lastToken = firstToken;
  15664. var str = "";
  15665. var nextToken;
  15666. while ((nextToken = this.fetch()).text !== "EOF" && regex.test(str + nextToken.text)) {
  15667. lastToken = nextToken;
  15668. str += lastToken.text;
  15669. this.consume();
  15670. }
  15671. if (str === "") {
  15672. throw new src_ParseError("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken);
  15673. }
  15674. return firstToken.range(lastToken, str);
  15675. }
  15676. /**
  15677. * Parses a color description.
  15678. */
  15679. ;
  15680. _proto.parseColorGroup = function parseColorGroup(optional) {
  15681. var res = this.parseStringGroup("color", optional);
  15682. if (res == null) {
  15683. return null;
  15684. }
  15685. var match = /^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i.exec(res.text);
  15686. if (!match) {
  15687. throw new src_ParseError("Invalid color: '" + res.text + "'", res);
  15688. }
  15689. var color = match[0];
  15690. if (/^[0-9a-f]{6}$/i.test(color)) {
  15691. // We allow a 6-digit HTML color spec without a leading "#".
  15692. // This follows the xcolor package's HTML color model.
  15693. // Predefined color names are all missed by this RegEx pattern.
  15694. color = "#" + color;
  15695. }
  15696. return {
  15697. type: "color-token",
  15698. mode: this.mode,
  15699. color: color
  15700. };
  15701. }
  15702. /**
  15703. * Parses a size specification, consisting of magnitude and unit.
  15704. */
  15705. ;
  15706. _proto.parseSizeGroup = function parseSizeGroup(optional) {
  15707. var res;
  15708. var isBlank = false; // don't expand before parseStringGroup
  15709. this.gullet.consumeSpaces();
  15710. if (!optional && this.gullet.future().text !== "{") {
  15711. res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size");
  15712. } else {
  15713. res = this.parseStringGroup("size", optional);
  15714. }
  15715. if (!res) {
  15716. return null;
  15717. }
  15718. if (!optional && res.text.length === 0) {
  15719. // Because we've tested for what is !optional, this block won't
  15720. // affect \kern, \hspace, etc. It will capture the mandatory arguments
  15721. // to \genfrac and \above.
  15722. res.text = "0pt"; // Enable \above{}
  15723. isBlank = true; // This is here specifically for \genfrac
  15724. }
  15725. var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text);
  15726. if (!match) {
  15727. throw new src_ParseError("Invalid size: '" + res.text + "'", res);
  15728. }
  15729. var data = {
  15730. number: +(match[1] + match[2]),
  15731. // sign + magnitude, cast to number
  15732. unit: match[3]
  15733. };
  15734. if (!validUnit(data)) {
  15735. throw new src_ParseError("Invalid unit: '" + data.unit + "'", res);
  15736. }
  15737. return {
  15738. type: "size",
  15739. mode: this.mode,
  15740. value: data,
  15741. isBlank: isBlank
  15742. };
  15743. }
  15744. /**
  15745. * Parses an URL, checking escaped letters and allowed protocols,
  15746. * and setting the catcode of % as an active character (as in \hyperref).
  15747. */
  15748. ;
  15749. _proto.parseUrlGroup = function parseUrlGroup(optional) {
  15750. this.gullet.lexer.setCatcode("%", 13); // active character
  15751. this.gullet.lexer.setCatcode("~", 12); // other character
  15752. var res = this.parseStringGroup("url", optional);
  15753. this.gullet.lexer.setCatcode("%", 14); // comment character
  15754. this.gullet.lexer.setCatcode("~", 13); // active character
  15755. if (res == null) {
  15756. return null;
  15757. } // hyperref package allows backslashes alone in href, but doesn't
  15758. // generate valid links in such cases; we interpret this as
  15759. // "undefined" behaviour, and keep them as-is. Some browser will
  15760. // replace backslashes with forward slashes.
  15761. var url = res.text.replace(/\\([#$%&~_^{}])/g, '$1');
  15762. return {
  15763. type: "url",
  15764. mode: this.mode,
  15765. url: url
  15766. };
  15767. }
  15768. /**
  15769. * Parses an argument with the mode specified.
  15770. */
  15771. ;
  15772. _proto.parseArgumentGroup = function parseArgumentGroup(optional, mode) {
  15773. var argToken = this.gullet.scanArgument(optional);
  15774. if (argToken == null) {
  15775. return null;
  15776. }
  15777. var outerMode = this.mode;
  15778. if (mode) {
  15779. // Switch to specified mode
  15780. this.switchMode(mode);
  15781. }
  15782. this.gullet.beginGroup();
  15783. var expression = this.parseExpression(false, "EOF"); // TODO: find an alternative way to denote the end
  15784. this.expect("EOF"); // expect the end of the argument
  15785. this.gullet.endGroup();
  15786. var result = {
  15787. type: "ordgroup",
  15788. mode: this.mode,
  15789. loc: argToken.loc,
  15790. body: expression
  15791. };
  15792. if (mode) {
  15793. // Switch mode back
  15794. this.switchMode(outerMode);
  15795. }
  15796. return result;
  15797. }
  15798. /**
  15799. * Parses an ordinary group, which is either a single nucleus (like "x")
  15800. * or an expression in braces (like "{x+y}") or an implicit group, a group
  15801. * that starts at the current position, and ends right before a higher explicit
  15802. * group ends, or at EOF.
  15803. */
  15804. ;
  15805. _proto.parseGroup = function parseGroup(name, // For error reporting.
  15806. breakOnTokenText) {
  15807. var firstToken = this.fetch();
  15808. var text = firstToken.text;
  15809. var result; // Try to parse an open brace or \begingroup
  15810. if (text === "{" || text === "\\begingroup") {
  15811. this.consume();
  15812. var groupEnd = text === "{" ? "}" : "\\endgroup";
  15813. this.gullet.beginGroup(); // If we get a brace, parse an expression
  15814. var expression = this.parseExpression(false, groupEnd);
  15815. var lastToken = this.fetch();
  15816. this.expect(groupEnd); // Check that we got a matching closing brace
  15817. this.gullet.endGroup();
  15818. result = {
  15819. type: "ordgroup",
  15820. mode: this.mode,
  15821. loc: SourceLocation.range(firstToken, lastToken),
  15822. body: expression,
  15823. // A group formed by \begingroup...\endgroup is a semi-simple group
  15824. // which doesn't affect spacing in math mode, i.e., is transparent.
  15825. // https://tex.stackexchange.com/questions/1930/when-should-one-
  15826. // use-begingroup-instead-of-bgroup
  15827. semisimple: text === "\\begingroup" || undefined
  15828. };
  15829. } else {
  15830. // If there exists a function with this name, parse the function.
  15831. // Otherwise, just return a nucleus
  15832. result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol();
  15833. if (result == null && text[0] === "\\" && !implicitCommands.hasOwnProperty(text)) {
  15834. if (this.settings.throwOnError) {
  15835. throw new src_ParseError("Undefined control sequence: " + text, firstToken);
  15836. }
  15837. result = this.formatUnsupportedCmd(text);
  15838. this.consume();
  15839. }
  15840. }
  15841. return result;
  15842. }
  15843. /**
  15844. * Form ligature-like combinations of characters for text mode.
  15845. * This includes inputs like "--", "---", "``" and "''".
  15846. * The result will simply replace multiple textord nodes with a single
  15847. * character in each value by a single textord node having multiple
  15848. * characters in its value. The representation is still ASCII source.
  15849. * The group will be modified in place.
  15850. */
  15851. ;
  15852. _proto.formLigatures = function formLigatures(group) {
  15853. var n = group.length - 1;
  15854. for (var i = 0; i < n; ++i) {
  15855. var a = group[i]; // $FlowFixMe: Not every node type has a `text` property.
  15856. var v = a.text;
  15857. if (v === "-" && group[i + 1].text === "-") {
  15858. if (i + 1 < n && group[i + 2].text === "-") {
  15859. group.splice(i, 3, {
  15860. type: "textord",
  15861. mode: "text",
  15862. loc: SourceLocation.range(a, group[i + 2]),
  15863. text: "---"
  15864. });
  15865. n -= 2;
  15866. } else {
  15867. group.splice(i, 2, {
  15868. type: "textord",
  15869. mode: "text",
  15870. loc: SourceLocation.range(a, group[i + 1]),
  15871. text: "--"
  15872. });
  15873. n -= 1;
  15874. }
  15875. }
  15876. if ((v === "'" || v === "`") && group[i + 1].text === v) {
  15877. group.splice(i, 2, {
  15878. type: "textord",
  15879. mode: "text",
  15880. loc: SourceLocation.range(a, group[i + 1]),
  15881. text: v + v
  15882. });
  15883. n -= 1;
  15884. }
  15885. }
  15886. }
  15887. /**
  15888. * Parse a single symbol out of the string. Here, we handle single character
  15889. * symbols and special functions like \verb.
  15890. */
  15891. ;
  15892. _proto.parseSymbol = function parseSymbol() {
  15893. var nucleus = this.fetch();
  15894. var text = nucleus.text;
  15895. if (/^\\verb[^a-zA-Z]/.test(text)) {
  15896. this.consume();
  15897. var arg = text.slice(5);
  15898. var star = arg.charAt(0) === "*";
  15899. if (star) {
  15900. arg = arg.slice(1);
  15901. } // Lexer's tokenRegex is constructed to always have matching
  15902. // first/last characters.
  15903. if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) {
  15904. throw new src_ParseError("\\verb assertion failed --\n please report what input caused this bug");
  15905. }
  15906. arg = arg.slice(1, -1); // remove first and last char
  15907. return {
  15908. type: "verb",
  15909. mode: "text",
  15910. body: arg,
  15911. star: star
  15912. };
  15913. } // At this point, we should have a symbol, possibly with accents.
  15914. // First expand any accented base symbol according to unicodeSymbols.
  15915. if (unicodeSymbols.hasOwnProperty(text[0]) && !src_symbols[this.mode][text[0]]) {
  15916. // This behavior is not strict (XeTeX-compatible) in math mode.
  15917. if (this.settings.strict && this.mode === "math") {
  15918. this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus);
  15919. }
  15920. text = unicodeSymbols[text[0]] + text.slice(1);
  15921. } // Strip off any combining characters
  15922. var match = combiningDiacriticalMarksEndRegex.exec(text);
  15923. if (match) {
  15924. text = text.substring(0, match.index);
  15925. if (text === 'i') {
  15926. text = "\u0131"; // dotless i, in math and text mode
  15927. } else if (text === 'j') {
  15928. text = "\u0237"; // dotless j, in math and text mode
  15929. }
  15930. } // Recognize base symbol
  15931. var symbol;
  15932. if (src_symbols[this.mode][text]) {
  15933. if (this.settings.strict && this.mode === 'math' && extraLatin.indexOf(text) >= 0) {
  15934. this.settings.reportNonstrict("unicodeTextInMathMode", "Latin-1/Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus);
  15935. }
  15936. var group = src_symbols[this.mode][text].group;
  15937. var loc = SourceLocation.range(nucleus);
  15938. var s;
  15939. if (ATOMS.hasOwnProperty(group)) {
  15940. // $FlowFixMe
  15941. var family = group;
  15942. s = {
  15943. type: "atom",
  15944. mode: this.mode,
  15945. family: family,
  15946. loc: loc,
  15947. text: text
  15948. };
  15949. } else {
  15950. // $FlowFixMe
  15951. s = {
  15952. type: group,
  15953. mode: this.mode,
  15954. loc: loc,
  15955. text: text
  15956. };
  15957. } // $FlowFixMe
  15958. symbol = s;
  15959. } else if (text.charCodeAt(0) >= 0x80) {
  15960. // no symbol for e.g. ^
  15961. if (this.settings.strict) {
  15962. if (!supportedCodepoint(text.charCodeAt(0))) {
  15963. this.settings.reportNonstrict("unknownSymbol", "Unrecognized Unicode character \"" + text[0] + "\"" + (" (" + text.charCodeAt(0) + ")"), nucleus);
  15964. } else if (this.mode === "math") {
  15965. this.settings.reportNonstrict("unicodeTextInMathMode", "Unicode text character \"" + text[0] + "\" used in math mode", nucleus);
  15966. }
  15967. } // All nonmathematical Unicode characters are rendered as if they
  15968. // are in text mode (wrapped in \text) because that's what it
  15969. // takes to render them in LaTeX. Setting `mode: this.mode` is
  15970. // another natural choice (the user requested math mode), but
  15971. // this makes it more difficult for getCharacterMetrics() to
  15972. // distinguish Unicode characters without metrics and those for
  15973. // which we want to simulate the letter M.
  15974. symbol = {
  15975. type: "textord",
  15976. mode: "text",
  15977. loc: SourceLocation.range(nucleus),
  15978. text: text
  15979. };
  15980. } else {
  15981. return null; // EOF, ^, _, {, }, etc.
  15982. }
  15983. this.consume(); // Transform combining characters into accents
  15984. if (match) {
  15985. for (var i = 0; i < match[0].length; i++) {
  15986. var accent = match[0][i];
  15987. if (!unicodeAccents[accent]) {
  15988. throw new src_ParseError("Unknown accent ' " + accent + "'", nucleus);
  15989. }
  15990. var command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text;
  15991. if (!command) {
  15992. throw new src_ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus);
  15993. }
  15994. symbol = {
  15995. type: "accent",
  15996. mode: this.mode,
  15997. loc: SourceLocation.range(nucleus),
  15998. label: command,
  15999. isStretchy: false,
  16000. isShifty: true,
  16001. // $FlowFixMe
  16002. base: symbol
  16003. };
  16004. }
  16005. } // $FlowFixMe
  16006. return symbol;
  16007. };
  16008. return Parser;
  16009. }();
  16010. Parser.endOfExpression = ["}", "\\endgroup", "\\end", "\\right", "&"];
  16011. ;// CONCATENATED MODULE: ./src/parseTree.js
  16012. /**
  16013. * Provides a single function for parsing an expression using a Parser
  16014. * TODO(emily): Remove this
  16015. */
  16016. /**
  16017. * Parses an expression using a Parser, then returns the parsed result.
  16018. */
  16019. var parseTree = function parseTree(toParse, settings) {
  16020. if (!(typeof toParse === 'string' || toParse instanceof String)) {
  16021. throw new TypeError('KaTeX can only parse string typed expression');
  16022. }
  16023. var parser = new Parser(toParse, settings); // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors
  16024. delete parser.gullet.macros.current["\\df@tag"];
  16025. var tree = parser.parse(); // Prevent a color definition from persisting between calls to katex.render().
  16026. delete parser.gullet.macros.current["\\current@color"];
  16027. delete parser.gullet.macros.current["\\color"]; // If the input used \tag, it will set the \df@tag macro to the tag.
  16028. // In this case, we separately parse the tag and wrap the tree.
  16029. if (parser.gullet.macros.get("\\df@tag")) {
  16030. if (!settings.displayMode) {
  16031. throw new src_ParseError("\\tag works only in display equations");
  16032. }
  16033. tree = [{
  16034. type: "tag",
  16035. mode: "text",
  16036. body: tree,
  16037. tag: parser.subparse([new Token("\\df@tag")])
  16038. }];
  16039. }
  16040. return tree;
  16041. };
  16042. /* harmony default export */ var src_parseTree = (parseTree);
  16043. ;// CONCATENATED MODULE: ./katex.js
  16044. /* eslint no-console:0 */
  16045. /**
  16046. * This is the main entry point for KaTeX. Here, we expose functions for
  16047. * rendering expressions either to DOM nodes or to markup strings.
  16048. *
  16049. * We also expose the ParseError class to check if errors thrown from KaTeX are
  16050. * errors in the expression, or errors in javascript handling.
  16051. */
  16052. /**
  16053. * Parse and build an expression, and place that expression in the DOM node
  16054. * given.
  16055. */
  16056. var render = function render(expression, baseNode, options) {
  16057. baseNode.textContent = "";
  16058. var node = renderToDomTree(expression, options).toNode();
  16059. baseNode.appendChild(node);
  16060. }; // KaTeX's styles don't work properly in quirks mode. Print out an error, and
  16061. // disable rendering.
  16062. if (typeof document !== "undefined") {
  16063. if (document.compatMode !== "CSS1Compat") {
  16064. typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype.");
  16065. render = function render() {
  16066. throw new src_ParseError("KaTeX doesn't work in quirks mode.");
  16067. };
  16068. }
  16069. }
  16070. /**
  16071. * Parse and build an expression, and return the markup for that.
  16072. */
  16073. var renderToString = function renderToString(expression, options) {
  16074. var markup = renderToDomTree(expression, options).toMarkup();
  16075. return markup;
  16076. };
  16077. /**
  16078. * Parse an expression and return the parse tree.
  16079. */
  16080. var generateParseTree = function generateParseTree(expression, options) {
  16081. var settings = new Settings(options);
  16082. return src_parseTree(expression, settings);
  16083. };
  16084. /**
  16085. * If the given error is a KaTeX ParseError and options.throwOnError is false,
  16086. * renders the invalid LaTeX as a span with hover title giving the KaTeX
  16087. * error message. Otherwise, simply throws the error.
  16088. */
  16089. var renderError = function renderError(error, expression, options) {
  16090. if (options.throwOnError || !(error instanceof src_ParseError)) {
  16091. throw error;
  16092. }
  16093. var node = buildCommon.makeSpan(["katex-error"], [new SymbolNode(expression)]);
  16094. node.setAttribute("title", error.toString());
  16095. node.setAttribute("style", "color:" + options.errorColor);
  16096. return node;
  16097. };
  16098. /**
  16099. * Generates and returns the katex build tree. This is used for advanced
  16100. * use cases (like rendering to custom output).
  16101. */
  16102. var renderToDomTree = function renderToDomTree(expression, options) {
  16103. var settings = new Settings(options);
  16104. try {
  16105. var tree = src_parseTree(expression, settings);
  16106. return buildTree(tree, expression, settings);
  16107. } catch (error) {
  16108. return renderError(error, expression, settings);
  16109. }
  16110. };
  16111. /**
  16112. * Generates and returns the katex build tree, with just HTML (no MathML).
  16113. * This is used for advanced use cases (like rendering to custom output).
  16114. */
  16115. var renderToHTMLTree = function renderToHTMLTree(expression, options) {
  16116. var settings = new Settings(options);
  16117. try {
  16118. var tree = src_parseTree(expression, settings);
  16119. return buildHTMLTree(tree, expression, settings);
  16120. } catch (error) {
  16121. return renderError(error, expression, settings);
  16122. }
  16123. };
  16124. /* harmony default export */ var katex = ({
  16125. /**
  16126. * Current KaTeX version
  16127. */
  16128. version: "0.16.2",
  16129. /**
  16130. * Renders the given LaTeX into an HTML+MathML combination, and adds
  16131. * it as a child to the specified DOM node.
  16132. */
  16133. render: render,
  16134. /**
  16135. * Renders the given LaTeX into an HTML+MathML combination string,
  16136. * for sending to the client.
  16137. */
  16138. renderToString: renderToString,
  16139. /**
  16140. * KaTeX error, usually during parsing.
  16141. */
  16142. ParseError: src_ParseError,
  16143. /**
  16144. * The shema of Settings
  16145. */
  16146. SETTINGS_SCHEMA: SETTINGS_SCHEMA,
  16147. /**
  16148. * Parses the given LaTeX into KaTeX's internal parse tree structure,
  16149. * without rendering to HTML or MathML.
  16150. *
  16151. * NOTE: This method is not currently recommended for public use.
  16152. * The internal tree representation is unstable and is very likely
  16153. * to change. Use at your own risk.
  16154. */
  16155. __parse: generateParseTree,
  16156. /**
  16157. * Renders the given LaTeX into an HTML+MathML internal DOM tree
  16158. * representation, without flattening that representation to a string.
  16159. *
  16160. * NOTE: This method is not currently recommended for public use.
  16161. * The internal tree representation is unstable and is very likely
  16162. * to change. Use at your own risk.
  16163. */
  16164. __renderToDomTree: renderToDomTree,
  16165. /**
  16166. * Renders the given LaTeX into an HTML internal DOM tree representation,
  16167. * without MathML and without flattening that representation to a string.
  16168. *
  16169. * NOTE: This method is not currently recommended for public use.
  16170. * The internal tree representation is unstable and is very likely
  16171. * to change. Use at your own risk.
  16172. */
  16173. __renderToHTMLTree: renderToHTMLTree,
  16174. /**
  16175. * extends internal font metrics object with a new object
  16176. * each key in the new object represents a font name
  16177. */
  16178. __setFontMetrics: setFontMetrics,
  16179. /**
  16180. * adds a new symbol to builtin symbols table
  16181. */
  16182. __defineSymbol: defineSymbol,
  16183. /**
  16184. * adds a new macro to builtin macro list
  16185. */
  16186. __defineMacro: defineMacro,
  16187. /**
  16188. * Expose the dom tree node types, which can be useful for type checking nodes.
  16189. *
  16190. * NOTE: This method is not currently recommended for public use.
  16191. * The internal tree representation is unstable and is very likely
  16192. * to change. Use at your own risk.
  16193. */
  16194. __domTree: {
  16195. Span: Span,
  16196. Anchor: Anchor,
  16197. SymbolNode: SymbolNode,
  16198. SvgNode: SvgNode,
  16199. PathNode: PathNode,
  16200. LineNode: LineNode
  16201. }
  16202. });
  16203. ;// CONCATENATED MODULE: ./katex.webpack.js
  16204. /**
  16205. * This is the webpack entry point for KaTeX. As ECMAScript, flow[1] and jest[2]
  16206. * doesn't support CSS modules natively, a separate entry point is used and
  16207. * it is not flowtyped.
  16208. *
  16209. * [1] https://gist.github.com/lambdahands/d19e0da96285b749f0ef
  16210. * [2] https://facebook.github.io/jest/docs/en/webpack.html
  16211. */
  16212. /* harmony default export */ var katex_webpack = (katex);
  16213. __webpack_exports__ = __webpack_exports__["default"];
  16214. /******/ return __webpack_exports__;
  16215. /******/ })()
  16216. ;
  16217. });