katex.mjs 584 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496
  1. /**
  2. * This is the ParseError class, which is the main error thrown by KaTeX
  3. * functions when something has gone wrong. This is used to distinguish internal
  4. * errors from errors in the expression that the user provided.
  5. *
  6. * If possible, a caller should provide a Token or ParseNode with information
  7. * about where in the source string the problem occurred.
  8. */
  9. class ParseError extends Error {
  10. // Error start position based on passed-in Token or ParseNode.
  11. // Length of affected text based on passed-in Token or ParseNode.
  12. // The underlying error message without any context added.
  13. constructor(message,
  14. // The error message
  15. token) {
  16. var error = "KaTeX parse error: " + message;
  17. var start;
  18. var end;
  19. var loc = token && token.loc;
  20. if (loc && loc.start <= loc.end) {
  21. // If we have the input and a position, make the error a bit fancier
  22. // Get the input
  23. var input = loc.lexer.input;
  24. // Prepend some information
  25. start = loc.start;
  26. end = loc.end;
  27. if (start === input.length) {
  28. error += " at end of input: ";
  29. } else {
  30. error += " at position " + (start + 1) + ": ";
  31. }
  32. // Underline token in question using combining underscores
  33. var underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332");
  34. // Extract some context from the input and add it to the error
  35. var left;
  36. if (start > 15) {
  37. left = "…" + input.slice(start - 15, start);
  38. } else {
  39. left = input.slice(0, start);
  40. }
  41. var right;
  42. if (end + 15 < input.length) {
  43. right = input.slice(end, end + 15) + "…";
  44. } else {
  45. right = input.slice(end);
  46. }
  47. error += left + underlined + right;
  48. }
  49. super(error);
  50. this.name = "ParseError";
  51. Object.setPrototypeOf(this, ParseError.prototype);
  52. this.position = start;
  53. if (start != null && end != null) {
  54. this.length = end - start;
  55. }
  56. this.rawMessage = message;
  57. }
  58. }
  59. /**
  60. * This file contains a list of utility functions which are useful in other
  61. * files.
  62. */
  63. // hyphenate and escape adapted from Facebook's React under Apache 2 license
  64. var uppercase = /([A-Z])/g;
  65. var hyphenate = str => str.replace(uppercase, "-$1").toLowerCase();
  66. var ESCAPE_LOOKUP = {
  67. "&": "&amp;",
  68. ">": "&gt;",
  69. "<": "&lt;",
  70. "\"": "&quot;",
  71. "'": "&#x27;"
  72. };
  73. var ESCAPE_REGEX = /[&><"']/g;
  74. /**
  75. * Escapes text to prevent scripting attacks.
  76. */
  77. var escape = text => String(text).replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]);
  78. /**
  79. * Sometimes we want to pull out the innermost element of a group. In most
  80. * cases, this will just be the group itself, but when ordgroups and colors have
  81. * a single element, we want to pull that out.
  82. */
  83. var getBaseElem = group => {
  84. if (group.type === "ordgroup") {
  85. if (group.body.length === 1) {
  86. return getBaseElem(group.body[0]);
  87. } else {
  88. return group;
  89. }
  90. } else if (group.type === "color") {
  91. if (group.body.length === 1) {
  92. return getBaseElem(group.body[0]);
  93. } else {
  94. return group;
  95. }
  96. } else if (group.type === "font") {
  97. return getBaseElem(group.body);
  98. } else {
  99. return group;
  100. }
  101. };
  102. var characterNodesTypes = new Set(["mathord", "textord", "atom"]);
  103. /**
  104. * TeXbook algorithms often reference "character boxes", which are simply groups
  105. * with a single character in them. To decide if something is a character box,
  106. * we find its innermost group, and see if it is a single character.
  107. */
  108. var isCharacterBox = group => characterNodesTypes.has(getBaseElem(group).type);
  109. /**
  110. * Return the protocol of a URL, or "_relative" if the URL does not specify a
  111. * protocol (and thus is relative), or `null` if URL has invalid protocol
  112. * (so should be outright rejected).
  113. */
  114. var protocolFromUrl = url => {
  115. // Check for possible leading protocol.
  116. // https://url.spec.whatwg.org/#url-parsing strips leading whitespace
  117. // (U+20) or C0 control (U+00-U+1F) characters.
  118. // eslint-disable-next-line no-control-regex
  119. var protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(url);
  120. if (!protocol) {
  121. return "_relative";
  122. }
  123. // Reject weird colons
  124. if (protocol[2] !== ":") {
  125. return null;
  126. }
  127. // Reject invalid characters in scheme according to
  128. // https://datatracker.ietf.org/doc/html/rfc3986#section-3.1
  129. if (!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(protocol[1])) {
  130. return null;
  131. }
  132. // Lowercase the protocol
  133. return protocol[1].toLowerCase();
  134. };
  135. /* eslint no-console:0 */
  136. // TODO: automatically generate documentation
  137. // TODO: check all properties on Settings exist
  138. // TODO: check the type of a property on Settings matches
  139. var SETTINGS_SCHEMA = {
  140. displayMode: {
  141. type: "boolean",
  142. 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.",
  143. cli: "-d, --display-mode"
  144. },
  145. output: {
  146. type: {
  147. enum: ["htmlAndMathml", "html", "mathml"]
  148. },
  149. description: "Determines the markup language of the output.",
  150. cli: "-F, --format <type>"
  151. },
  152. leqno: {
  153. type: "boolean",
  154. description: "Render display math in leqno style (left-justified tags)."
  155. },
  156. fleqn: {
  157. type: "boolean",
  158. description: "Render display math flush left."
  159. },
  160. throwOnError: {
  161. type: "boolean",
  162. default: true,
  163. cli: "-t, --no-throw-on-error",
  164. cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error."
  165. },
  166. errorColor: {
  167. type: "string",
  168. default: "#cc0000",
  169. cli: "-c, --error-color <color>",
  170. cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.",
  171. cliProcessor: color => "#" + color
  172. },
  173. macros: {
  174. type: "object",
  175. cli: "-m, --macro <def>",
  176. cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).",
  177. cliDefault: [],
  178. cliProcessor: (def, defs) => {
  179. defs.push(def);
  180. return defs;
  181. }
  182. },
  183. minRuleThickness: {
  184. type: "number",
  185. 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`.",
  186. processor: t => Math.max(0, t),
  187. cli: "--min-rule-thickness <size>",
  188. cliProcessor: parseFloat
  189. },
  190. colorIsTextColor: {
  191. type: "boolean",
  192. description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.",
  193. cli: "-b, --color-is-text-color"
  194. },
  195. strict: {
  196. type: [{
  197. enum: ["warn", "ignore", "error"]
  198. }, "boolean", "function"],
  199. description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.",
  200. cli: "-S, --strict",
  201. cliDefault: false
  202. },
  203. trust: {
  204. type: ["boolean", "function"],
  205. description: "Trust the input, enabling all HTML features such as \\url.",
  206. cli: "-T, --trust"
  207. },
  208. maxSize: {
  209. type: "number",
  210. default: Infinity,
  211. 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",
  212. processor: s => Math.max(0, s),
  213. cli: "-s, --max-size <n>",
  214. cliProcessor: parseInt
  215. },
  216. maxExpand: {
  217. type: "number",
  218. default: 1000,
  219. 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.",
  220. processor: n => Math.max(0, n),
  221. cli: "-e, --max-expand <n>",
  222. cliProcessor: n => n === "Infinity" ? Infinity : parseInt(n)
  223. },
  224. globalGroup: {
  225. type: "boolean",
  226. cli: false
  227. }
  228. };
  229. function getDefaultValue(schema) {
  230. if ("default" in schema) {
  231. return schema.default;
  232. }
  233. var type = schema.type;
  234. var defaultType = Array.isArray(type) ? type[0] : type;
  235. if (typeof defaultType !== 'string') {
  236. return defaultType.enum[0];
  237. }
  238. switch (defaultType) {
  239. case 'boolean':
  240. return false;
  241. case 'string':
  242. return '';
  243. case 'number':
  244. return 0;
  245. case 'object':
  246. return {};
  247. }
  248. }
  249. /**
  250. * The main Settings object
  251. *
  252. * The current options stored are:
  253. * - displayMode: Whether the expression should be typeset as inline math
  254. * (false, the default), meaning that the math starts in
  255. * \textstyle and is placed in an inline-block); or as display
  256. * math (true), meaning that the math starts in \displaystyle
  257. * and is placed in a block with vertical margin.
  258. */
  259. class Settings {
  260. constructor(options) {
  261. if (options === void 0) {
  262. options = {};
  263. }
  264. // allow null options
  265. options = options || {};
  266. for (var prop of Object.keys(SETTINGS_SCHEMA)) {
  267. var schema = SETTINGS_SCHEMA[prop];
  268. var optionValue = options[prop];
  269. // TODO: validate options
  270. this[prop] = optionValue !== undefined ? schema.processor ? schema.processor(optionValue) : optionValue : getDefaultValue(schema);
  271. }
  272. }
  273. /**
  274. * Report nonstrict (non-LaTeX-compatible) input.
  275. * Can safely not be called if `this.strict` is false in JavaScript.
  276. */
  277. reportNonstrict(errorCode, errorMsg, token) {
  278. var strict = this.strict;
  279. if (typeof strict === "function") {
  280. // Allow return value of strict function to be boolean or string
  281. // (or null/undefined, meaning no further processing).
  282. strict = strict(errorCode, errorMsg, token);
  283. }
  284. if (!strict || strict === "ignore") {
  285. return;
  286. } else if (strict === true || strict === "error") {
  287. throw new ParseError("LaTeX-incompatible input and strict mode is set to 'error': " + (errorMsg + " [" + errorCode + "]"), token);
  288. } else if (strict === "warn") {
  289. typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]"));
  290. } else {
  291. // won't happen in type-safe code
  292. typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]"));
  293. }
  294. }
  295. /**
  296. * Check whether to apply strict (LaTeX-adhering) behavior for unusual
  297. * input (like `\\`). Unlike `nonstrict`, will not throw an error;
  298. * instead, "error" translates to a return value of `true`, while "ignore"
  299. * translates to a return value of `false`. May still print a warning:
  300. * "warn" prints a warning and returns `false`.
  301. * This is for the second category of `errorCode`s listed in the README.
  302. */
  303. useStrictBehavior(errorCode, errorMsg, token) {
  304. var strict = this.strict;
  305. if (typeof strict === "function") {
  306. // Allow return value of strict function to be boolean or string
  307. // (or null/undefined, meaning no further processing).
  308. // But catch any exceptions thrown by function, treating them
  309. // like "error".
  310. try {
  311. strict = strict(errorCode, errorMsg, token);
  312. } catch (error) {
  313. strict = "error";
  314. }
  315. }
  316. if (!strict || strict === "ignore") {
  317. return false;
  318. } else if (strict === true || strict === "error") {
  319. return true;
  320. } else if (strict === "warn") {
  321. typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]"));
  322. return false;
  323. } else {
  324. // won't happen in type-safe code
  325. typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]"));
  326. return false;
  327. }
  328. }
  329. /**
  330. * Check whether to test potentially dangerous input, and return
  331. * `true` (trusted) or `false` (untrusted). The sole argument `context`
  332. * should be an object with `command` field specifying the relevant LaTeX
  333. * command (as a string starting with `\`), and any other arguments, etc.
  334. * If `context` has a `url` field, a `protocol` field will automatically
  335. * get added by this function (changing the specified object).
  336. */
  337. isTrusted(context) {
  338. if ("url" in context && context.url && !context.protocol) {
  339. var protocol = protocolFromUrl(context.url);
  340. if (protocol == null) {
  341. return false;
  342. }
  343. context.protocol = protocol;
  344. }
  345. var trust = typeof this.trust === "function" ? this.trust(context) : this.trust;
  346. return Boolean(trust);
  347. }
  348. }
  349. /**
  350. * This file contains information and classes for the various kinds of styles
  351. * used in TeX. It provides a generic `Style` class, which holds information
  352. * about a specific style. It then provides instances of all the different kinds
  353. * of styles possible, and provides functions to move between them and get
  354. * information about them.
  355. */
  356. /**
  357. * The main style class. Contains a unique id for the style, a size (which is
  358. * the same for cramped and uncramped version of a style), and a cramped flag.
  359. */
  360. class Style {
  361. constructor(id, size, cramped) {
  362. this.id = id;
  363. this.size = size;
  364. this.cramped = cramped;
  365. }
  366. /**
  367. * Get the style of a superscript given a base in the current style.
  368. */
  369. sup() {
  370. return styles[sup[this.id]];
  371. }
  372. /**
  373. * Get the style of a subscript given a base in the current style.
  374. */
  375. sub() {
  376. return styles[sub[this.id]];
  377. }
  378. /**
  379. * Get the style of a fraction numerator given the fraction in the current
  380. * style.
  381. */
  382. fracNum() {
  383. return styles[fracNum[this.id]];
  384. }
  385. /**
  386. * Get the style of a fraction denominator given the fraction in the current
  387. * style.
  388. */
  389. fracDen() {
  390. return styles[fracDen[this.id]];
  391. }
  392. /**
  393. * Get the cramped version of a style (in particular, cramping a cramped style
  394. * doesn't change the style).
  395. */
  396. cramp() {
  397. return styles[cramp[this.id]];
  398. }
  399. /**
  400. * Get a text or display version of this style.
  401. */
  402. text() {
  403. return styles[text$1[this.id]];
  404. }
  405. /**
  406. * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle)
  407. */
  408. isTight() {
  409. return this.size >= 2;
  410. }
  411. }
  412. // IDs of the different styles
  413. var D = 0;
  414. var Dc = 1;
  415. var T = 2;
  416. var Tc = 3;
  417. var S = 4;
  418. var Sc = 5;
  419. var SS = 6;
  420. var SSc = 7;
  421. // Instances of the different styles
  422. 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)];
  423. // Lookup tables for switching from one style to another
  424. var sup = [S, Sc, S, Sc, SS, SSc, SS, SSc];
  425. var sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc];
  426. var fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc];
  427. var fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc];
  428. var cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc];
  429. var text$1 = [D, Dc, T, Tc, T, Tc, T, Tc];
  430. // We only export some of the styles.
  431. var Style$1 = {
  432. DISPLAY: styles[D],
  433. TEXT: styles[T],
  434. SCRIPT: styles[S],
  435. SCRIPTSCRIPT: styles[SS]
  436. };
  437. /*
  438. * This file defines the Unicode scripts and script families that we
  439. * support. To add new scripts or families, just add a new entry to the
  440. * scriptData array below. Adding scripts to the scriptData array allows
  441. * characters from that script to appear in \text{} environments.
  442. */
  443. /**
  444. * Unicode block data for the families of scripts we support in \text{}.
  445. * Scripts only need to appear here if they do not have font metrics.
  446. */
  447. var scriptData = [{
  448. // Latin characters beyond the Latin-1 characters we have metrics for.
  449. // Needed for Czech, Hungarian and Turkish text, for example.
  450. name: 'latin',
  451. blocks: [[0x0100, 0x024f],
  452. // Latin Extended-A and Latin Extended-B
  453. [0x0300, 0x036f] // Combining Diacritical marks
  454. ]
  455. }, {
  456. // The Cyrillic script used by Russian and related languages.
  457. // A Cyrillic subset used to be supported as explicitly defined
  458. // symbols in symbols.js
  459. name: 'cyrillic',
  460. blocks: [[0x0400, 0x04ff]]
  461. }, {
  462. // Armenian
  463. name: 'armenian',
  464. blocks: [[0x0530, 0x058F]]
  465. }, {
  466. // The Brahmic scripts of South and Southeast Asia
  467. // Devanagari (0900–097F)
  468. // Bengali (0980–09FF)
  469. // Gurmukhi (0A00–0A7F)
  470. // Gujarati (0A80–0AFF)
  471. // Oriya (0B00–0B7F)
  472. // Tamil (0B80–0BFF)
  473. // Telugu (0C00–0C7F)
  474. // Kannada (0C80–0CFF)
  475. // Malayalam (0D00–0D7F)
  476. // Sinhala (0D80–0DFF)
  477. // Thai (0E00–0E7F)
  478. // Lao (0E80–0EFF)
  479. // Tibetan (0F00–0FFF)
  480. // Myanmar (1000–109F)
  481. name: 'brahmic',
  482. blocks: [[0x0900, 0x109F]]
  483. }, {
  484. name: 'georgian',
  485. blocks: [[0x10A0, 0x10ff]]
  486. }, {
  487. // Chinese and Japanese.
  488. // The "k" in cjk is for Korean, but we've separated Korean out
  489. name: "cjk",
  490. blocks: [[0x3000, 0x30FF],
  491. // CJK symbols and punctuation, Hiragana, Katakana
  492. [0x4E00, 0x9FAF],
  493. // CJK ideograms
  494. [0xFF00, 0xFF60] // Fullwidth punctuation
  495. // TODO: add halfwidth Katakana and Romanji glyphs
  496. ]
  497. }, {
  498. // Korean
  499. name: 'hangul',
  500. blocks: [[0xAC00, 0xD7AF]]
  501. }];
  502. /**
  503. * Given a codepoint, return the name of the script or script family
  504. * it is from, or null if it is not part of a known block
  505. */
  506. function scriptFromCodepoint(codepoint) {
  507. for (var i = 0; i < scriptData.length; i++) {
  508. var script = scriptData[i];
  509. for (var _i = 0; _i < script.blocks.length; _i++) {
  510. var block = script.blocks[_i];
  511. if (codepoint >= block[0] && codepoint <= block[1]) {
  512. return script.name;
  513. }
  514. }
  515. }
  516. return null;
  517. }
  518. /**
  519. * A flattened version of all the supported blocks in a single array.
  520. * This is an optimization to make supportedCodepoint() fast.
  521. */
  522. var allBlocks = [];
  523. scriptData.forEach(s => s.blocks.forEach(b => allBlocks.push(...b)));
  524. /**
  525. * Given a codepoint, return true if it falls within one of the
  526. * scripts or script families defined above and false otherwise.
  527. *
  528. * Micro benchmarks shows that this is faster than
  529. * /[\u3000-\u30FF\u4E00-\u9FAF\uFF00-\uFF60\uAC00-\uD7AF\u0900-\u109F]/.test()
  530. * in Firefox, Chrome and Node.
  531. */
  532. function supportedCodepoint(codepoint) {
  533. for (var i = 0; i < allBlocks.length; i += 2) {
  534. if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) {
  535. return true;
  536. }
  537. }
  538. return false;
  539. }
  540. /**
  541. * This file provides support to domTree.js and delimiter.js.
  542. * It's a storehouse of path geometry for SVG images.
  543. */
  544. // In all paths below, the viewBox-to-em scale is 1000:1.
  545. var hLinePad = 80; // padding above a sqrt vinculum. Prevents image cropping.
  546. // The vinculum of a \sqrt can be made thicker by a KaTeX rendering option.
  547. // Think of variable extraVinculum as two detours in the SVG path.
  548. // The detour begins at the lower left of the area labeled extraVinculum below.
  549. // The detour proceeds one extraVinculum distance up and slightly to the right,
  550. // displacing the radiused corner between surd and vinculum. The radius is
  551. // traversed as usual, then the detour resumes. It goes right, to the end of
  552. // the very long vinculum, then down one extraVinculum distance,
  553. // after which it resumes regular path geometry for the radical.
  554. /* vinculum
  555. /
  556. /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraVinculum
  557. / █████████████████████←0.04em (40 unit) std vinculum thickness
  558. / /
  559. / /
  560. / /\
  561. / / surd
  562. */
  563. var sqrtMain = function sqrtMain(extraVinculum, hLinePad) {
  564. // sqrtMain path geometry is from glyph U221A in the font KaTeX Main
  565. return "M95," + (622 + extraVinculum + 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" + extraVinculum / 2.075 + " -" + extraVinculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraVinculum) + "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 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z";
  566. };
  567. var sqrtSize1 = function sqrtSize1(extraVinculum, hLinePad) {
  568. // size1 is from glyph U221A in the font KaTeX_Size1-Regular
  569. return "M263," + (601 + extraVinculum + 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" + extraVinculum / 2.084 + " -" + extraVinculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraVinculum) + "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 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z";
  570. };
  571. var sqrtSize2 = function sqrtSize2(extraVinculum, hLinePad) {
  572. // size2 is from glyph U221A in the font KaTeX_Size2-Regular
  573. return "M983 " + (10 + extraVinculum + hLinePad) + "\nl" + extraVinculum / 3.13 + " -" + extraVinculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraVinculum) + "\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 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z";
  574. };
  575. var sqrtSize3 = function sqrtSize3(extraVinculum, hLinePad) {
  576. // size3 is from glyph U221A in the font KaTeX_Size3-Regular
  577. return "M424," + (2398 + extraVinculum + 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" + extraVinculum / 4.223 + " -" + extraVinculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraVinculum) + "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 + extraVinculum) + " " + hLinePad + "\nh400000v" + (40 + extraVinculum) + "h-400000z";
  578. };
  579. var sqrtSize4 = function sqrtSize4(extraVinculum, hLinePad) {
  580. // size4 is from glyph U221A in the font KaTeX_Size4-Regular
  581. return "M473," + (2713 + extraVinculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraVinculum / 5.298 + " -" + extraVinculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraVinculum) + "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 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "H1017.7z";
  582. };
  583. var phasePath = function phasePath(y) {
  584. var x = y / 2; // x coordinate at top of angle
  585. return "M400000 " + y + " H0 L" + x + " 0 l65 45 L145 " + (y - 80) + " H400000z";
  586. };
  587. var sqrtTall = function sqrtTall(extraVinculum, hLinePad, viewBoxHeight) {
  588. // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular
  589. // One path edge has a variable length. It runs vertically from the vinculum
  590. // to a point near (14 units) the bottom of the surd. The vinculum
  591. // is normally 40 units thick. So the length of the line in question is:
  592. var vertSegment = viewBoxHeight - 54 - hLinePad - extraVinculum;
  593. return "M702 " + (extraVinculum + hLinePad) + "H400000" + (40 + extraVinculum) + "\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 + extraVinculum) + "H742z";
  594. };
  595. var sqrtPath = function sqrtPath(size, extraVinculum, viewBoxHeight) {
  596. extraVinculum = 1000 * extraVinculum; // Convert from document ems to viewBox.
  597. var path = "";
  598. switch (size) {
  599. case "sqrtMain":
  600. path = sqrtMain(extraVinculum, hLinePad);
  601. break;
  602. case "sqrtSize1":
  603. path = sqrtSize1(extraVinculum, hLinePad);
  604. break;
  605. case "sqrtSize2":
  606. path = sqrtSize2(extraVinculum, hLinePad);
  607. break;
  608. case "sqrtSize3":
  609. path = sqrtSize3(extraVinculum, hLinePad);
  610. break;
  611. case "sqrtSize4":
  612. path = sqrtSize4(extraVinculum, hLinePad);
  613. break;
  614. case "sqrtTall":
  615. path = sqrtTall(extraVinculum, hLinePad, viewBoxHeight);
  616. }
  617. return path;
  618. };
  619. var innerPath = function innerPath(name, height) {
  620. // The inner part of stretchy tall delimiters
  621. switch (name) {
  622. case "\u239c":
  623. return "M291 0 H417 V" + height + " H291z M291 0 H417 V" + height + " H291z";
  624. case "\u2223":
  625. return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z";
  626. case "\u2225":
  627. 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");
  628. case "\u239f":
  629. return "M457 0 H583 V" + height + " H457z M457 0 H583 V" + height + " H457z";
  630. case "\u23a2":
  631. return "M319 0 H403 V" + height + " H319z M319 0 H403 V" + height + " H319z";
  632. case "\u23a5":
  633. return "M263 0 H347 V" + height + " H263z M263 0 H347 V" + height + " H263z";
  634. case "\u23aa":
  635. return "M384 0 H504 V" + height + " H384z M384 0 H504 V" + height + " H384z";
  636. case "\u23d0":
  637. return "M312 0 H355 V" + height + " H312z M312 0 H355 V" + height + " H312z";
  638. case "\u2016":
  639. 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");
  640. default:
  641. return "";
  642. }
  643. };
  644. var path = {
  645. // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main
  646. 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",
  647. // doublerightarrow is from glyph U+21D2 in font KaTeX Main
  648. 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",
  649. // leftarrow is from glyph U+2190 in font KaTeX Main
  650. 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",
  651. // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular
  652. 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",
  653. 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",
  654. // overgroup is from the MnSymbol package (public domain)
  655. 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",
  656. 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",
  657. // Harpoons are from glyph U+21BD in font KaTeX Main
  658. 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",
  659. 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",
  660. 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",
  661. 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",
  662. // hook is from glyph U+21A9 in font KaTeX Main
  663. 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",
  664. leftlinesegment: "M40 281 V428 H0 V94 H40 V241 H400000 v40z\nM40 281 V428 H0 V94 H40 V241 H400000 v40z",
  665. leftbracketunder: "M0 0 h120 V290 H399995 v120 H0z\nM0 0 h120 V290 H399995 v120 H0z",
  666. leftbracketover: "M0 440 h120 V150 H399995 v-120 H0z\nM0 440 h120 V150 H399995 v-120 H0z",
  667. leftmapsto: "M40 281 V448H0V74H40V241H400000v40z\nM40 281 V448H0V74H40V241H400000v40z",
  668. // tofrom is from glyph U+21C4 in font KaTeX AMS Regular
  669. 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",
  670. longequal: "M0 50 h400000 v40H0z m0 194h40000v40H0z\nM0 50 h400000 v40H0z m0 194h40000v40H0z",
  671. 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",
  672. 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",
  673. 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",
  674. 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",
  675. 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",
  676. 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",
  677. 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",
  678. 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",
  679. 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",
  680. 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",
  681. 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",
  682. 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",
  683. 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",
  684. 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",
  685. 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",
  686. 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",
  687. rightlinesegment: "M399960 241 V94 h40 V428 h-40 V281 H0 v-40z\nM399960 241 V94 h40 V428 h-40 V281 H0 v-40z",
  688. rightbracketunder: "M399995 0 h-120 V290 H0 v120 H400000z\nM399995 0 h-120 V290 H0 v120 H400000z",
  689. rightbracketover: "M399995 440 h-120 V150 H0 v-120 H399995z\nM399995 440 h-120 V150 H0 v-120 H399995z",
  690. 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",
  691. // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular
  692. 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",
  693. 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",
  694. // tilde1 is a modified version of a glyph from the MnSymbol package
  695. 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",
  696. // ditto tilde2, tilde3, & tilde4
  697. 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",
  698. 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",
  699. 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",
  700. // vec is from glyph U+20D7 in font KaTeX Main
  701. 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",
  702. // widehat1 is a modified version of a glyph from the MnSymbol package
  703. 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",
  704. // ditto widehat2, widehat3, & widehat4
  705. 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",
  706. 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",
  707. 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",
  708. // widecheck paths are all inverted versions of widehat
  709. 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",
  710. 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",
  711. 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",
  712. 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",
  713. // The next ten paths support reaction arrows from the mhchem package.
  714. // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX
  715. // baraboveleftarrow is mostly from glyph U+2190 in font KaTeX Main
  716. 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",
  717. // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main
  718. 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",
  719. // The short left harpoon has 0.5em (i.e. 500 units) kern on the left end.
  720. // Ref from mhchem.sty: \rlap{\raisebox{-.22ex}{$\kern0.5em
  721. 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",
  722. 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",
  723. 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",
  724. 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"
  725. };
  726. var tallDelim = function tallDelim(label, midHeight) {
  727. switch (label) {
  728. case "lbrack":
  729. return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 h84z";
  730. case "rbrack":
  731. return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z";
  732. case "vert":
  733. 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";
  734. case "doublevert":
  735. 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";
  736. case "lfloor":
  737. return "M319 602 V0 H403 V602 v" + midHeight + " v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z";
  738. case "rfloor":
  739. return "M319 602 V0 H403 V602 v" + midHeight + " v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z";
  740. case "lceil":
  741. return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v602 h84z\nM403 1759 V0 H319 V1759 v" + midHeight + " v602 h84z";
  742. case "rceil":
  743. return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v602 h84z\nM347 1759 V0 h-84 V1759 v" + midHeight + " v602 h84z";
  744. case "lparen":
  745. 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";
  746. case "rparen":
  747. 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";
  748. default:
  749. // We should not ever get here.
  750. throw new Error("Unknown stretchy delimiter.");
  751. }
  752. };
  753. /**
  754. * This node represents a document fragment, which contains elements, but when
  755. * placed into the DOM doesn't have any representation itself. It only contains
  756. * children and doesn't have any DOM node properties.
  757. */
  758. class DocumentFragment {
  759. // Never used; needed for satisfying interface.
  760. constructor(children) {
  761. this.children = children;
  762. this.classes = [];
  763. this.height = 0;
  764. this.depth = 0;
  765. this.maxFontSize = 0;
  766. this.style = {};
  767. }
  768. hasClass(className) {
  769. return this.classes.includes(className);
  770. }
  771. /** Convert the fragment into a node. */
  772. toNode() {
  773. var frag = document.createDocumentFragment();
  774. for (var i = 0; i < this.children.length; i++) {
  775. frag.appendChild(this.children[i].toNode());
  776. }
  777. return frag;
  778. }
  779. /** Convert the fragment into HTML markup. */
  780. toMarkup() {
  781. var markup = "";
  782. // Simply concatenate the markup for the children together.
  783. for (var i = 0; i < this.children.length; i++) {
  784. markup += this.children[i].toMarkup();
  785. }
  786. return markup;
  787. }
  788. /**
  789. * Converts the math node into a string, similar to innerText. Applies to
  790. * MathDomNode's only.
  791. */
  792. toText() {
  793. // To avoid this, we would subclass documentFragment separately for
  794. // MathML, but polyfills for subclassing is expensive per PR 1469.
  795. // TODO(ts): Only works for ChildType = MathDomNode.
  796. var toText = child => child.toText();
  797. return this.children.map(toText).join("");
  798. }
  799. }
  800. /**
  801. * This file does conversion between units. In particular, it provides
  802. * calculateSize to convert other units into ems.
  803. */
  804. // This table gives the number of TeX pts in one of each *absolute* TeX unit.
  805. // Thus, multiplying a length by this number converts the length from units
  806. // into pts. Dividing the result by ptPerEm gives the number of ems
  807. // *assuming* a font size of ptPerEm (normal size, normal style).
  808. var ptPerUnit = {
  809. // https://en.wikibooks.org/wiki/LaTeX/Lengths and
  810. // https://tex.stackexchange.com/a/8263
  811. "pt": 1,
  812. // TeX point
  813. "mm": 7227 / 2540,
  814. // millimeter
  815. "cm": 7227 / 254,
  816. // centimeter
  817. "in": 72.27,
  818. // inch
  819. "bp": 803 / 800,
  820. // big (PostScript) points
  821. "pc": 12,
  822. // pica
  823. "dd": 1238 / 1157,
  824. // didot
  825. "cc": 14856 / 1157,
  826. // cicero (12 didot)
  827. "nd": 685 / 642,
  828. // new didot
  829. "nc": 1370 / 107,
  830. // new cicero (12 new didot)
  831. "sp": 1 / 65536,
  832. // scaled point (TeX's internal smallest unit)
  833. // https://tex.stackexchange.com/a/41371
  834. "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX
  835. };
  836. // Dictionary of relative units, for fast validity testing.
  837. var relativeUnit = {
  838. "ex": true,
  839. "em": true,
  840. "mu": true
  841. };
  842. /**
  843. * Determine whether the specified unit (either a string defining the unit
  844. * or a "size" parse node containing a unit field) is valid.
  845. */
  846. var validUnit = function validUnit(unit) {
  847. if (typeof unit !== "string") {
  848. unit = unit.unit;
  849. }
  850. return unit in ptPerUnit || unit in relativeUnit || unit === "ex";
  851. };
  852. /*
  853. * Convert a "size" parse node (with numeric "number" and string "unit" fields,
  854. * as parsed by functions.js argType "size") into a CSS em value for the
  855. * current style/scale. `options` gives the current options.
  856. */
  857. var calculateSize = function calculateSize(sizeValue, options) {
  858. var scale;
  859. if (sizeValue.unit in ptPerUnit) {
  860. // Absolute units
  861. scale = ptPerUnit[sizeValue.unit] // Convert unit to pt
  862. / options.fontMetrics().ptPerEm // Convert pt to CSS em
  863. / options.sizeMultiplier; // Unscale to make absolute units
  864. } else if (sizeValue.unit === "mu") {
  865. // `mu` units scale with scriptstyle/scriptscriptstyle.
  866. scale = options.fontMetrics().cssEmPerMu;
  867. } else {
  868. // Other relative units always refer to the *textstyle* font
  869. // in the current size.
  870. var unitOptions;
  871. if (options.style.isTight()) {
  872. // isTight() means current style is script/scriptscript.
  873. unitOptions = options.havingStyle(options.style.text());
  874. } else {
  875. unitOptions = options;
  876. }
  877. // TODO: In TeX these units are relative to the quad of the current
  878. // *text* font, e.g. cmr10. KaTeX instead uses values from the
  879. // comparably-sized *Computer Modern symbol* font. At 10pt, these
  880. // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
  881. // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
  882. // TeX \showlists shows a kern of 1.13889 * fontsize;
  883. // KaTeX shows a kern of 1.171 * fontsize.
  884. if (sizeValue.unit === "ex") {
  885. scale = unitOptions.fontMetrics().xHeight;
  886. } else if (sizeValue.unit === "em") {
  887. scale = unitOptions.fontMetrics().quad;
  888. } else {
  889. throw new ParseError("Invalid unit: '" + sizeValue.unit + "'");
  890. }
  891. if (unitOptions !== options) {
  892. scale *= unitOptions.sizeMultiplier / options.sizeMultiplier;
  893. }
  894. }
  895. return Math.min(sizeValue.number * scale, options.maxSize);
  896. };
  897. /**
  898. * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See
  899. * https://github.com/KaTeX/KaTeX/pull/2460.
  900. */
  901. var makeEm = function makeEm(n) {
  902. return +n.toFixed(4) + "em";
  903. };
  904. /**
  905. * These objects store the data about the DOM nodes we create, as well as some
  906. * extra data. They can then be transformed into real DOM nodes with the
  907. * `toNode` function or HTML markup using `toMarkup`. They are useful for both
  908. * storing extra properties on the nodes, as well as providing a way to easily
  909. * work with the DOM.
  910. *
  911. * Similar functions for working with MathML nodes exist in mathMLTree.js.
  912. *
  913. * TODO: refactor `span` and `anchor` into common superclass when
  914. * target environments support class inheritance
  915. */
  916. /**
  917. * Create an HTML className based on a list of classes. In addition to joining
  918. * with spaces, we also remove empty classes.
  919. */
  920. var createClass = function createClass(classes) {
  921. return classes.filter(cls => cls).join(" ");
  922. };
  923. var initNode = function initNode(classes, options, style) {
  924. this.classes = classes || [];
  925. this.attributes = {};
  926. this.height = 0;
  927. this.depth = 0;
  928. this.maxFontSize = 0;
  929. this.style = style || {};
  930. if (options) {
  931. if (options.style.isTight()) {
  932. this.classes.push("mtight");
  933. }
  934. var color = options.getColor();
  935. if (color) {
  936. this.style.color = color;
  937. }
  938. }
  939. };
  940. /**
  941. * Convert into an HTML node
  942. */
  943. var toNode = function toNode(tagName) {
  944. var node = document.createElement(tagName);
  945. // Apply the class
  946. node.className = createClass(this.classes);
  947. // Apply inline styles
  948. for (var key of Object.keys(this.style)) {
  949. node.style[key] = this.style[key];
  950. }
  951. // Apply attributes
  952. for (var attr of Object.keys(this.attributes)) {
  953. node.setAttribute(attr, this.attributes[attr]);
  954. }
  955. // Append the children, also as HTML nodes
  956. for (var i = 0; i < this.children.length; i++) {
  957. node.appendChild(this.children[i].toNode());
  958. }
  959. return node;
  960. };
  961. /**
  962. * https://w3c.github.io/html-reference/syntax.html#syntax-attributes
  963. *
  964. * > Attribute Names must consist of one or more characters
  965. * other than the space characters, U+0000 NULL,
  966. * '"', "'", ">", "/", "=", the control characters,
  967. * and any characters that are not defined by Unicode.
  968. */
  969. var invalidAttributeNameRegex = /[\s"'>/=\x00-\x1f]/;
  970. /**
  971. * Convert into an HTML markup string
  972. */
  973. var toMarkup = function toMarkup(tagName) {
  974. var markup = "<" + tagName;
  975. // Add the class
  976. if (this.classes.length) {
  977. markup += " class=\"" + escape(createClass(this.classes)) + "\"";
  978. }
  979. var styles = "";
  980. // Add the styles, after hyphenation
  981. for (var key of Object.keys(this.style)) {
  982. styles += hyphenate(key) + ":" + this.style[key] + ";";
  983. }
  984. if (styles) {
  985. markup += " style=\"" + escape(styles) + "\"";
  986. }
  987. // Add the attributes
  988. for (var attr of Object.keys(this.attributes)) {
  989. if (invalidAttributeNameRegex.test(attr)) {
  990. throw new ParseError("Invalid attribute name '" + attr + "'");
  991. }
  992. markup += " " + attr + "=\"" + escape(this.attributes[attr]) + "\"";
  993. }
  994. markup += ">";
  995. // Add the markup of the children, also as markup
  996. for (var i = 0; i < this.children.length; i++) {
  997. markup += this.children[i].toMarkup();
  998. }
  999. markup += "</" + tagName + ">";
  1000. return markup;
  1001. };
  1002. /**
  1003. * This node represents a span node, with a className, a list of children, and
  1004. * an inline style. It also contains information about its height, depth, and
  1005. * maxFontSize.
  1006. *
  1007. * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan
  1008. * otherwise. This typesafety is important when HTML builders access a span's
  1009. * children.
  1010. */
  1011. class Span {
  1012. constructor(classes, children, options, style) {
  1013. initNode.call(this, classes, options, style);
  1014. this.children = children || [];
  1015. }
  1016. /**
  1017. * Sets an arbitrary attribute on the span. Warning: use this wisely. Not
  1018. * all browsers support attributes the same, and having too many custom
  1019. * attributes is probably bad.
  1020. */
  1021. setAttribute(attribute, value) {
  1022. this.attributes[attribute] = value;
  1023. }
  1024. hasClass(className) {
  1025. return this.classes.includes(className);
  1026. }
  1027. toNode() {
  1028. return toNode.call(this, "span");
  1029. }
  1030. toMarkup() {
  1031. return toMarkup.call(this, "span");
  1032. }
  1033. }
  1034. /**
  1035. * This node represents an anchor (<a>) element with a hyperlink. See `span`
  1036. * for further details.
  1037. */
  1038. class Anchor {
  1039. constructor(href, classes, children, options) {
  1040. initNode.call(this, classes, options);
  1041. this.children = children || [];
  1042. this.setAttribute('href', href);
  1043. }
  1044. setAttribute(attribute, value) {
  1045. this.attributes[attribute] = value;
  1046. }
  1047. hasClass(className) {
  1048. return this.classes.includes(className);
  1049. }
  1050. toNode() {
  1051. return toNode.call(this, "a");
  1052. }
  1053. toMarkup() {
  1054. return toMarkup.call(this, "a");
  1055. }
  1056. }
  1057. /**
  1058. * This node represents an image embed (<img>) element.
  1059. */
  1060. class Img {
  1061. constructor(src, alt, style) {
  1062. this.alt = alt;
  1063. this.src = src;
  1064. this.classes = ["mord"];
  1065. this.height = 0;
  1066. this.depth = 0;
  1067. this.maxFontSize = 0;
  1068. this.style = style;
  1069. }
  1070. hasClass(className) {
  1071. return this.classes.includes(className);
  1072. }
  1073. toNode() {
  1074. var node = document.createElement("img");
  1075. node.src = this.src;
  1076. node.alt = this.alt;
  1077. node.className = "mord";
  1078. // Apply inline styles
  1079. for (var key of Object.keys(this.style)) {
  1080. node.style[key] = this.style[key];
  1081. }
  1082. return node;
  1083. }
  1084. toMarkup() {
  1085. var markup = "<img src=\"" + escape(this.src) + "\"" + (" alt=\"" + escape(this.alt) + "\"");
  1086. // Add the styles, after hyphenation
  1087. var styles = "";
  1088. for (var key of Object.keys(this.style)) {
  1089. styles += hyphenate(key) + ":" + this.style[key] + ";";
  1090. }
  1091. if (styles) {
  1092. markup += " style=\"" + escape(styles) + "\"";
  1093. }
  1094. markup += "'/>";
  1095. return markup;
  1096. }
  1097. }
  1098. var iCombinations = {
  1099. 'î': '\u0131\u0302',
  1100. 'ï': '\u0131\u0308',
  1101. 'í': '\u0131\u0301',
  1102. // 'ī': '\u0131\u0304', // enable when we add Extended Latin
  1103. 'ì': '\u0131\u0300'
  1104. };
  1105. /**
  1106. * A symbol node contains information about a single symbol. It either renders
  1107. * to a single text node, or a span with a single text node in it, depending on
  1108. * whether it has CSS classes, styles, or needs italic correction.
  1109. */
  1110. class SymbolNode {
  1111. constructor(text, height, depth, italic, skew, width, classes, style) {
  1112. this.text = text;
  1113. this.height = height || 0;
  1114. this.depth = depth || 0;
  1115. this.italic = italic || 0;
  1116. this.skew = skew || 0;
  1117. this.width = width || 0;
  1118. this.classes = classes || [];
  1119. this.style = style || {};
  1120. this.maxFontSize = 0;
  1121. // Mark text from non-Latin scripts with specific classes so that we
  1122. // can specify which fonts to use. This allows us to render these
  1123. // characters with a serif font in situations where the browser would
  1124. // either default to a sans serif or render a placeholder character.
  1125. // We use CSS class names like cjk_fallback, hangul_fallback and
  1126. // brahmic_fallback. See ./unicodeScripts.js for the set of possible
  1127. // script names
  1128. var script = scriptFromCodepoint(this.text.charCodeAt(0));
  1129. if (script) {
  1130. this.classes.push(script + "_fallback");
  1131. }
  1132. if (/[îïíì]/.test(this.text)) {
  1133. // add ī when we add Extended Latin
  1134. this.text = iCombinations[this.text];
  1135. }
  1136. }
  1137. hasClass(className) {
  1138. return this.classes.includes(className);
  1139. }
  1140. /**
  1141. * Creates a text node or span from a symbol node. Note that a span is only
  1142. * created if it is needed.
  1143. */
  1144. toNode() {
  1145. var node = document.createTextNode(this.text);
  1146. var span = null;
  1147. if (this.italic > 0) {
  1148. span = document.createElement("span");
  1149. span.style.marginRight = makeEm(this.italic);
  1150. }
  1151. if (this.classes.length > 0) {
  1152. span = span || document.createElement("span");
  1153. span.className = createClass(this.classes);
  1154. }
  1155. for (var key of Object.keys(this.style)) {
  1156. span = span || document.createElement("span");
  1157. span.style[key] = this.style[key];
  1158. }
  1159. if (span) {
  1160. span.appendChild(node);
  1161. return span;
  1162. } else {
  1163. return node;
  1164. }
  1165. }
  1166. /**
  1167. * Creates markup for a symbol node.
  1168. */
  1169. toMarkup() {
  1170. // TODO(alpert): More duplication than I'd like from
  1171. // span.prototype.toMarkup and symbolNode.prototype.toNode...
  1172. var needsSpan = false;
  1173. var markup = "<span";
  1174. if (this.classes.length) {
  1175. needsSpan = true;
  1176. markup += " class=\"";
  1177. markup += escape(createClass(this.classes));
  1178. markup += "\"";
  1179. }
  1180. var styles = "";
  1181. if (this.italic > 0) {
  1182. styles += "margin-right:" + makeEm(this.italic) + ";";
  1183. }
  1184. for (var key of Object.keys(this.style)) {
  1185. styles += hyphenate(key) + ":" + this.style[key] + ";";
  1186. }
  1187. if (styles) {
  1188. needsSpan = true;
  1189. markup += " style=\"" + escape(styles) + "\"";
  1190. }
  1191. var escaped = escape(this.text);
  1192. if (needsSpan) {
  1193. markup += ">";
  1194. markup += escaped;
  1195. markup += "</span>";
  1196. return markup;
  1197. } else {
  1198. return escaped;
  1199. }
  1200. }
  1201. }
  1202. /**
  1203. * SVG nodes are used to render stretchy wide elements.
  1204. */
  1205. class SvgNode {
  1206. constructor(children, attributes) {
  1207. this.children = children || [];
  1208. this.attributes = attributes || {};
  1209. }
  1210. toNode() {
  1211. var svgNS = "http://www.w3.org/2000/svg";
  1212. var node = document.createElementNS(svgNS, "svg");
  1213. // Apply attributes
  1214. for (var attr of Object.keys(this.attributes)) {
  1215. node.setAttribute(attr, this.attributes[attr]);
  1216. }
  1217. for (var i = 0; i < this.children.length; i++) {
  1218. node.appendChild(this.children[i].toNode());
  1219. }
  1220. return node;
  1221. }
  1222. toMarkup() {
  1223. var markup = "<svg xmlns=\"http://www.w3.org/2000/svg\"";
  1224. // Apply attributes
  1225. for (var attr of Object.keys(this.attributes)) {
  1226. markup += " " + attr + "=\"" + escape(this.attributes[attr]) + "\"";
  1227. }
  1228. markup += ">";
  1229. for (var i = 0; i < this.children.length; i++) {
  1230. markup += this.children[i].toMarkup();
  1231. }
  1232. markup += "</svg>";
  1233. return markup;
  1234. }
  1235. }
  1236. class PathNode {
  1237. constructor(pathName, alternate) {
  1238. this.pathName = pathName;
  1239. this.alternate = alternate; // Used only for \sqrt, \phase, & tall delims
  1240. }
  1241. toNode() {
  1242. var svgNS = "http://www.w3.org/2000/svg";
  1243. var node = document.createElementNS(svgNS, "path");
  1244. if (this.alternate) {
  1245. node.setAttribute("d", this.alternate);
  1246. } else {
  1247. node.setAttribute("d", path[this.pathName]);
  1248. }
  1249. return node;
  1250. }
  1251. toMarkup() {
  1252. if (this.alternate) {
  1253. return "<path d=\"" + escape(this.alternate) + "\"/>";
  1254. } else {
  1255. return "<path d=\"" + escape(path[this.pathName]) + "\"/>";
  1256. }
  1257. }
  1258. }
  1259. class LineNode {
  1260. constructor(attributes) {
  1261. this.attributes = attributes || {};
  1262. }
  1263. toNode() {
  1264. var svgNS = "http://www.w3.org/2000/svg";
  1265. var node = document.createElementNS(svgNS, "line");
  1266. // Apply attributes
  1267. for (var attr of Object.keys(this.attributes)) {
  1268. node.setAttribute(attr, this.attributes[attr]);
  1269. }
  1270. return node;
  1271. }
  1272. toMarkup() {
  1273. var markup = "<line";
  1274. for (var attr of Object.keys(this.attributes)) {
  1275. markup += " " + attr + "=\"" + escape(this.attributes[attr]) + "\"";
  1276. }
  1277. markup += "/>";
  1278. return markup;
  1279. }
  1280. }
  1281. function assertSymbolDomNode(group) {
  1282. if (group instanceof SymbolNode) {
  1283. return group;
  1284. } else {
  1285. throw new Error("Expected symbolNode but got " + String(group) + ".");
  1286. }
  1287. }
  1288. function assertSpan(group) {
  1289. if (group instanceof Span) {
  1290. return group;
  1291. } else {
  1292. throw new Error("Expected span<HtmlDomNode> but got " + String(group) + ".");
  1293. }
  1294. }
  1295. /**
  1296. * Whether an HtmlDomNode has HtmlDomNode children.
  1297. * HtmlDomNode is a base type representing a union of
  1298. * SymbolNode, SvgSpan, DomSpan, Anchor, and documentFragment.
  1299. * In the last three cases, the children are HtmlDomNode[].
  1300. */
  1301. var hasHtmlDomChildren = node => node instanceof Span || node instanceof Anchor || node instanceof DocumentFragment;
  1302. // This file is GENERATED by buildMetrics.sh. DO NOT MODIFY.
  1303. var fontMetricsData = {
  1304. "AMS-Regular": {
  1305. "32": [0, 0, 0, 0, 0.25],
  1306. "65": [0, 0.68889, 0, 0, 0.72222],
  1307. "66": [0, 0.68889, 0, 0, 0.66667],
  1308. "67": [0, 0.68889, 0, 0, 0.72222],
  1309. "68": [0, 0.68889, 0, 0, 0.72222],
  1310. "69": [0, 0.68889, 0, 0, 0.66667],
  1311. "70": [0, 0.68889, 0, 0, 0.61111],
  1312. "71": [0, 0.68889, 0, 0, 0.77778],
  1313. "72": [0, 0.68889, 0, 0, 0.77778],
  1314. "73": [0, 0.68889, 0, 0, 0.38889],
  1315. "74": [0.16667, 0.68889, 0, 0, 0.5],
  1316. "75": [0, 0.68889, 0, 0, 0.77778],
  1317. "76": [0, 0.68889, 0, 0, 0.66667],
  1318. "77": [0, 0.68889, 0, 0, 0.94445],
  1319. "78": [0, 0.68889, 0, 0, 0.72222],
  1320. "79": [0.16667, 0.68889, 0, 0, 0.77778],
  1321. "80": [0, 0.68889, 0, 0, 0.61111],
  1322. "81": [0.16667, 0.68889, 0, 0, 0.77778],
  1323. "82": [0, 0.68889, 0, 0, 0.72222],
  1324. "83": [0, 0.68889, 0, 0, 0.55556],
  1325. "84": [0, 0.68889, 0, 0, 0.66667],
  1326. "85": [0, 0.68889, 0, 0, 0.72222],
  1327. "86": [0, 0.68889, 0, 0, 0.72222],
  1328. "87": [0, 0.68889, 0, 0, 1.0],
  1329. "88": [0, 0.68889, 0, 0, 0.72222],
  1330. "89": [0, 0.68889, 0, 0, 0.72222],
  1331. "90": [0, 0.68889, 0, 0, 0.66667],
  1332. "107": [0, 0.68889, 0, 0, 0.55556],
  1333. "160": [0, 0, 0, 0, 0.25],
  1334. "165": [0, 0.675, 0.025, 0, 0.75],
  1335. "174": [0.15559, 0.69224, 0, 0, 0.94666],
  1336. "240": [0, 0.68889, 0, 0, 0.55556],
  1337. "295": [0, 0.68889, 0, 0, 0.54028],
  1338. "710": [0, 0.825, 0, 0, 2.33334],
  1339. "732": [0, 0.9, 0, 0, 2.33334],
  1340. "770": [0, 0.825, 0, 0, 2.33334],
  1341. "771": [0, 0.9, 0, 0, 2.33334],
  1342. "989": [0.08167, 0.58167, 0, 0, 0.77778],
  1343. "1008": [0, 0.43056, 0.04028, 0, 0.66667],
  1344. "8245": [0, 0.54986, 0, 0, 0.275],
  1345. "8463": [0, 0.68889, 0, 0, 0.54028],
  1346. "8487": [0, 0.68889, 0, 0, 0.72222],
  1347. "8498": [0, 0.68889, 0, 0, 0.55556],
  1348. "8502": [0, 0.68889, 0, 0, 0.66667],
  1349. "8503": [0, 0.68889, 0, 0, 0.44445],
  1350. "8504": [0, 0.68889, 0, 0, 0.66667],
  1351. "8513": [0, 0.68889, 0, 0, 0.63889],
  1352. "8592": [-0.03598, 0.46402, 0, 0, 0.5],
  1353. "8594": [-0.03598, 0.46402, 0, 0, 0.5],
  1354. "8602": [-0.13313, 0.36687, 0, 0, 1.0],
  1355. "8603": [-0.13313, 0.36687, 0, 0, 1.0],
  1356. "8606": [0.01354, 0.52239, 0, 0, 1.0],
  1357. "8608": [0.01354, 0.52239, 0, 0, 1.0],
  1358. "8610": [0.01354, 0.52239, 0, 0, 1.11111],
  1359. "8611": [0.01354, 0.52239, 0, 0, 1.11111],
  1360. "8619": [0, 0.54986, 0, 0, 1.0],
  1361. "8620": [0, 0.54986, 0, 0, 1.0],
  1362. "8621": [-0.13313, 0.37788, 0, 0, 1.38889],
  1363. "8622": [-0.13313, 0.36687, 0, 0, 1.0],
  1364. "8624": [0, 0.69224, 0, 0, 0.5],
  1365. "8625": [0, 0.69224, 0, 0, 0.5],
  1366. "8630": [0, 0.43056, 0, 0, 1.0],
  1367. "8631": [0, 0.43056, 0, 0, 1.0],
  1368. "8634": [0.08198, 0.58198, 0, 0, 0.77778],
  1369. "8635": [0.08198, 0.58198, 0, 0, 0.77778],
  1370. "8638": [0.19444, 0.69224, 0, 0, 0.41667],
  1371. "8639": [0.19444, 0.69224, 0, 0, 0.41667],
  1372. "8642": [0.19444, 0.69224, 0, 0, 0.41667],
  1373. "8643": [0.19444, 0.69224, 0, 0, 0.41667],
  1374. "8644": [0.1808, 0.675, 0, 0, 1.0],
  1375. "8646": [0.1808, 0.675, 0, 0, 1.0],
  1376. "8647": [0.1808, 0.675, 0, 0, 1.0],
  1377. "8648": [0.19444, 0.69224, 0, 0, 0.83334],
  1378. "8649": [0.1808, 0.675, 0, 0, 1.0],
  1379. "8650": [0.19444, 0.69224, 0, 0, 0.83334],
  1380. "8651": [0.01354, 0.52239, 0, 0, 1.0],
  1381. "8652": [0.01354, 0.52239, 0, 0, 1.0],
  1382. "8653": [-0.13313, 0.36687, 0, 0, 1.0],
  1383. "8654": [-0.13313, 0.36687, 0, 0, 1.0],
  1384. "8655": [-0.13313, 0.36687, 0, 0, 1.0],
  1385. "8666": [0.13667, 0.63667, 0, 0, 1.0],
  1386. "8667": [0.13667, 0.63667, 0, 0, 1.0],
  1387. "8669": [-0.13313, 0.37788, 0, 0, 1.0],
  1388. "8672": [-0.064, 0.437, 0, 0, 1.334],
  1389. "8674": [-0.064, 0.437, 0, 0, 1.334],
  1390. "8705": [0, 0.825, 0, 0, 0.5],
  1391. "8708": [0, 0.68889, 0, 0, 0.55556],
  1392. "8709": [0.08167, 0.58167, 0, 0, 0.77778],
  1393. "8717": [0, 0.43056, 0, 0, 0.42917],
  1394. "8722": [-0.03598, 0.46402, 0, 0, 0.5],
  1395. "8724": [0.08198, 0.69224, 0, 0, 0.77778],
  1396. "8726": [0.08167, 0.58167, 0, 0, 0.77778],
  1397. "8733": [0, 0.69224, 0, 0, 0.77778],
  1398. "8736": [0, 0.69224, 0, 0, 0.72222],
  1399. "8737": [0, 0.69224, 0, 0, 0.72222],
  1400. "8738": [0.03517, 0.52239, 0, 0, 0.72222],
  1401. "8739": [0.08167, 0.58167, 0, 0, 0.22222],
  1402. "8740": [0.25142, 0.74111, 0, 0, 0.27778],
  1403. "8741": [0.08167, 0.58167, 0, 0, 0.38889],
  1404. "8742": [0.25142, 0.74111, 0, 0, 0.5],
  1405. "8756": [0, 0.69224, 0, 0, 0.66667],
  1406. "8757": [0, 0.69224, 0, 0, 0.66667],
  1407. "8764": [-0.13313, 0.36687, 0, 0, 0.77778],
  1408. "8765": [-0.13313, 0.37788, 0, 0, 0.77778],
  1409. "8769": [-0.13313, 0.36687, 0, 0, 0.77778],
  1410. "8770": [-0.03625, 0.46375, 0, 0, 0.77778],
  1411. "8774": [0.30274, 0.79383, 0, 0, 0.77778],
  1412. "8776": [-0.01688, 0.48312, 0, 0, 0.77778],
  1413. "8778": [0.08167, 0.58167, 0, 0, 0.77778],
  1414. "8782": [0.06062, 0.54986, 0, 0, 0.77778],
  1415. "8783": [0.06062, 0.54986, 0, 0, 0.77778],
  1416. "8785": [0.08198, 0.58198, 0, 0, 0.77778],
  1417. "8786": [0.08198, 0.58198, 0, 0, 0.77778],
  1418. "8787": [0.08198, 0.58198, 0, 0, 0.77778],
  1419. "8790": [0, 0.69224, 0, 0, 0.77778],
  1420. "8791": [0.22958, 0.72958, 0, 0, 0.77778],
  1421. "8796": [0.08198, 0.91667, 0, 0, 0.77778],
  1422. "8806": [0.25583, 0.75583, 0, 0, 0.77778],
  1423. "8807": [0.25583, 0.75583, 0, 0, 0.77778],
  1424. "8808": [0.25142, 0.75726, 0, 0, 0.77778],
  1425. "8809": [0.25142, 0.75726, 0, 0, 0.77778],
  1426. "8812": [0.25583, 0.75583, 0, 0, 0.5],
  1427. "8814": [0.20576, 0.70576, 0, 0, 0.77778],
  1428. "8815": [0.20576, 0.70576, 0, 0, 0.77778],
  1429. "8816": [0.30274, 0.79383, 0, 0, 0.77778],
  1430. "8817": [0.30274, 0.79383, 0, 0, 0.77778],
  1431. "8818": [0.22958, 0.72958, 0, 0, 0.77778],
  1432. "8819": [0.22958, 0.72958, 0, 0, 0.77778],
  1433. "8822": [0.1808, 0.675, 0, 0, 0.77778],
  1434. "8823": [0.1808, 0.675, 0, 0, 0.77778],
  1435. "8828": [0.13667, 0.63667, 0, 0, 0.77778],
  1436. "8829": [0.13667, 0.63667, 0, 0, 0.77778],
  1437. "8830": [0.22958, 0.72958, 0, 0, 0.77778],
  1438. "8831": [0.22958, 0.72958, 0, 0, 0.77778],
  1439. "8832": [0.20576, 0.70576, 0, 0, 0.77778],
  1440. "8833": [0.20576, 0.70576, 0, 0, 0.77778],
  1441. "8840": [0.30274, 0.79383, 0, 0, 0.77778],
  1442. "8841": [0.30274, 0.79383, 0, 0, 0.77778],
  1443. "8842": [0.13597, 0.63597, 0, 0, 0.77778],
  1444. "8843": [0.13597, 0.63597, 0, 0, 0.77778],
  1445. "8847": [0.03517, 0.54986, 0, 0, 0.77778],
  1446. "8848": [0.03517, 0.54986, 0, 0, 0.77778],
  1447. "8858": [0.08198, 0.58198, 0, 0, 0.77778],
  1448. "8859": [0.08198, 0.58198, 0, 0, 0.77778],
  1449. "8861": [0.08198, 0.58198, 0, 0, 0.77778],
  1450. "8862": [0, 0.675, 0, 0, 0.77778],
  1451. "8863": [0, 0.675, 0, 0, 0.77778],
  1452. "8864": [0, 0.675, 0, 0, 0.77778],
  1453. "8865": [0, 0.675, 0, 0, 0.77778],
  1454. "8872": [0, 0.69224, 0, 0, 0.61111],
  1455. "8873": [0, 0.69224, 0, 0, 0.72222],
  1456. "8874": [0, 0.69224, 0, 0, 0.88889],
  1457. "8876": [0, 0.68889, 0, 0, 0.61111],
  1458. "8877": [0, 0.68889, 0, 0, 0.61111],
  1459. "8878": [0, 0.68889, 0, 0, 0.72222],
  1460. "8879": [0, 0.68889, 0, 0, 0.72222],
  1461. "8882": [0.03517, 0.54986, 0, 0, 0.77778],
  1462. "8883": [0.03517, 0.54986, 0, 0, 0.77778],
  1463. "8884": [0.13667, 0.63667, 0, 0, 0.77778],
  1464. "8885": [0.13667, 0.63667, 0, 0, 0.77778],
  1465. "8888": [0, 0.54986, 0, 0, 1.11111],
  1466. "8890": [0.19444, 0.43056, 0, 0, 0.55556],
  1467. "8891": [0.19444, 0.69224, 0, 0, 0.61111],
  1468. "8892": [0.19444, 0.69224, 0, 0, 0.61111],
  1469. "8901": [0, 0.54986, 0, 0, 0.27778],
  1470. "8903": [0.08167, 0.58167, 0, 0, 0.77778],
  1471. "8905": [0.08167, 0.58167, 0, 0, 0.77778],
  1472. "8906": [0.08167, 0.58167, 0, 0, 0.77778],
  1473. "8907": [0, 0.69224, 0, 0, 0.77778],
  1474. "8908": [0, 0.69224, 0, 0, 0.77778],
  1475. "8909": [-0.03598, 0.46402, 0, 0, 0.77778],
  1476. "8910": [0, 0.54986, 0, 0, 0.76042],
  1477. "8911": [0, 0.54986, 0, 0, 0.76042],
  1478. "8912": [0.03517, 0.54986, 0, 0, 0.77778],
  1479. "8913": [0.03517, 0.54986, 0, 0, 0.77778],
  1480. "8914": [0, 0.54986, 0, 0, 0.66667],
  1481. "8915": [0, 0.54986, 0, 0, 0.66667],
  1482. "8916": [0, 0.69224, 0, 0, 0.66667],
  1483. "8918": [0.0391, 0.5391, 0, 0, 0.77778],
  1484. "8919": [0.0391, 0.5391, 0, 0, 0.77778],
  1485. "8920": [0.03517, 0.54986, 0, 0, 1.33334],
  1486. "8921": [0.03517, 0.54986, 0, 0, 1.33334],
  1487. "8922": [0.38569, 0.88569, 0, 0, 0.77778],
  1488. "8923": [0.38569, 0.88569, 0, 0, 0.77778],
  1489. "8926": [0.13667, 0.63667, 0, 0, 0.77778],
  1490. "8927": [0.13667, 0.63667, 0, 0, 0.77778],
  1491. "8928": [0.30274, 0.79383, 0, 0, 0.77778],
  1492. "8929": [0.30274, 0.79383, 0, 0, 0.77778],
  1493. "8934": [0.23222, 0.74111, 0, 0, 0.77778],
  1494. "8935": [0.23222, 0.74111, 0, 0, 0.77778],
  1495. "8936": [0.23222, 0.74111, 0, 0, 0.77778],
  1496. "8937": [0.23222, 0.74111, 0, 0, 0.77778],
  1497. "8938": [0.20576, 0.70576, 0, 0, 0.77778],
  1498. "8939": [0.20576, 0.70576, 0, 0, 0.77778],
  1499. "8940": [0.30274, 0.79383, 0, 0, 0.77778],
  1500. "8941": [0.30274, 0.79383, 0, 0, 0.77778],
  1501. "8994": [0.19444, 0.69224, 0, 0, 0.77778],
  1502. "8995": [0.19444, 0.69224, 0, 0, 0.77778],
  1503. "9416": [0.15559, 0.69224, 0, 0, 0.90222],
  1504. "9484": [0, 0.69224, 0, 0, 0.5],
  1505. "9488": [0, 0.69224, 0, 0, 0.5],
  1506. "9492": [0, 0.37788, 0, 0, 0.5],
  1507. "9496": [0, 0.37788, 0, 0, 0.5],
  1508. "9585": [0.19444, 0.68889, 0, 0, 0.88889],
  1509. "9586": [0.19444, 0.74111, 0, 0, 0.88889],
  1510. "9632": [0, 0.675, 0, 0, 0.77778],
  1511. "9633": [0, 0.675, 0, 0, 0.77778],
  1512. "9650": [0, 0.54986, 0, 0, 0.72222],
  1513. "9651": [0, 0.54986, 0, 0, 0.72222],
  1514. "9654": [0.03517, 0.54986, 0, 0, 0.77778],
  1515. "9660": [0, 0.54986, 0, 0, 0.72222],
  1516. "9661": [0, 0.54986, 0, 0, 0.72222],
  1517. "9664": [0.03517, 0.54986, 0, 0, 0.77778],
  1518. "9674": [0.11111, 0.69224, 0, 0, 0.66667],
  1519. "9733": [0.19444, 0.69224, 0, 0, 0.94445],
  1520. "10003": [0, 0.69224, 0, 0, 0.83334],
  1521. "10016": [0, 0.69224, 0, 0, 0.83334],
  1522. "10731": [0.11111, 0.69224, 0, 0, 0.66667],
  1523. "10846": [0.19444, 0.75583, 0, 0, 0.61111],
  1524. "10877": [0.13667, 0.63667, 0, 0, 0.77778],
  1525. "10878": [0.13667, 0.63667, 0, 0, 0.77778],
  1526. "10885": [0.25583, 0.75583, 0, 0, 0.77778],
  1527. "10886": [0.25583, 0.75583, 0, 0, 0.77778],
  1528. "10887": [0.13597, 0.63597, 0, 0, 0.77778],
  1529. "10888": [0.13597, 0.63597, 0, 0, 0.77778],
  1530. "10889": [0.26167, 0.75726, 0, 0, 0.77778],
  1531. "10890": [0.26167, 0.75726, 0, 0, 0.77778],
  1532. "10891": [0.48256, 0.98256, 0, 0, 0.77778],
  1533. "10892": [0.48256, 0.98256, 0, 0, 0.77778],
  1534. "10901": [0.13667, 0.63667, 0, 0, 0.77778],
  1535. "10902": [0.13667, 0.63667, 0, 0, 0.77778],
  1536. "10933": [0.25142, 0.75726, 0, 0, 0.77778],
  1537. "10934": [0.25142, 0.75726, 0, 0, 0.77778],
  1538. "10935": [0.26167, 0.75726, 0, 0, 0.77778],
  1539. "10936": [0.26167, 0.75726, 0, 0, 0.77778],
  1540. "10937": [0.26167, 0.75726, 0, 0, 0.77778],
  1541. "10938": [0.26167, 0.75726, 0, 0, 0.77778],
  1542. "10949": [0.25583, 0.75583, 0, 0, 0.77778],
  1543. "10950": [0.25583, 0.75583, 0, 0, 0.77778],
  1544. "10955": [0.28481, 0.79383, 0, 0, 0.77778],
  1545. "10956": [0.28481, 0.79383, 0, 0, 0.77778],
  1546. "57350": [0.08167, 0.58167, 0, 0, 0.22222],
  1547. "57351": [0.08167, 0.58167, 0, 0, 0.38889],
  1548. "57352": [0.08167, 0.58167, 0, 0, 0.77778],
  1549. "57353": [0, 0.43056, 0.04028, 0, 0.66667],
  1550. "57356": [0.25142, 0.75726, 0, 0, 0.77778],
  1551. "57357": [0.25142, 0.75726, 0, 0, 0.77778],
  1552. "57358": [0.41951, 0.91951, 0, 0, 0.77778],
  1553. "57359": [0.30274, 0.79383, 0, 0, 0.77778],
  1554. "57360": [0.30274, 0.79383, 0, 0, 0.77778],
  1555. "57361": [0.41951, 0.91951, 0, 0, 0.77778],
  1556. "57366": [0.25142, 0.75726, 0, 0, 0.77778],
  1557. "57367": [0.25142, 0.75726, 0, 0, 0.77778],
  1558. "57368": [0.25142, 0.75726, 0, 0, 0.77778],
  1559. "57369": [0.25142, 0.75726, 0, 0, 0.77778],
  1560. "57370": [0.13597, 0.63597, 0, 0, 0.77778],
  1561. "57371": [0.13597, 0.63597, 0, 0, 0.77778]
  1562. },
  1563. "Caligraphic-Regular": {
  1564. "32": [0, 0, 0, 0, 0.25],
  1565. "65": [0, 0.68333, 0, 0.19445, 0.79847],
  1566. "66": [0, 0.68333, 0.03041, 0.13889, 0.65681],
  1567. "67": [0, 0.68333, 0.05834, 0.13889, 0.52653],
  1568. "68": [0, 0.68333, 0.02778, 0.08334, 0.77139],
  1569. "69": [0, 0.68333, 0.08944, 0.11111, 0.52778],
  1570. "70": [0, 0.68333, 0.09931, 0.11111, 0.71875],
  1571. "71": [0.09722, 0.68333, 0.0593, 0.11111, 0.59487],
  1572. "72": [0, 0.68333, 0.00965, 0.11111, 0.84452],
  1573. "73": [0, 0.68333, 0.07382, 0, 0.54452],
  1574. "74": [0.09722, 0.68333, 0.18472, 0.16667, 0.67778],
  1575. "75": [0, 0.68333, 0.01445, 0.05556, 0.76195],
  1576. "76": [0, 0.68333, 0, 0.13889, 0.68972],
  1577. "77": [0, 0.68333, 0, 0.13889, 1.2009],
  1578. "78": [0, 0.68333, 0.14736, 0.08334, 0.82049],
  1579. "79": [0, 0.68333, 0.02778, 0.11111, 0.79611],
  1580. "80": [0, 0.68333, 0.08222, 0.08334, 0.69556],
  1581. "81": [0.09722, 0.68333, 0, 0.11111, 0.81667],
  1582. "82": [0, 0.68333, 0, 0.08334, 0.8475],
  1583. "83": [0, 0.68333, 0.075, 0.13889, 0.60556],
  1584. "84": [0, 0.68333, 0.25417, 0, 0.54464],
  1585. "85": [0, 0.68333, 0.09931, 0.08334, 0.62583],
  1586. "86": [0, 0.68333, 0.08222, 0, 0.61278],
  1587. "87": [0, 0.68333, 0.08222, 0.08334, 0.98778],
  1588. "88": [0, 0.68333, 0.14643, 0.13889, 0.7133],
  1589. "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834],
  1590. "90": [0, 0.68333, 0.07944, 0.13889, 0.72473],
  1591. "160": [0, 0, 0, 0, 0.25]
  1592. },
  1593. "Fraktur-Regular": {
  1594. "32": [0, 0, 0, 0, 0.25],
  1595. "33": [0, 0.69141, 0, 0, 0.29574],
  1596. "34": [0, 0.69141, 0, 0, 0.21471],
  1597. "38": [0, 0.69141, 0, 0, 0.73786],
  1598. "39": [0, 0.69141, 0, 0, 0.21201],
  1599. "40": [0.24982, 0.74947, 0, 0, 0.38865],
  1600. "41": [0.24982, 0.74947, 0, 0, 0.38865],
  1601. "42": [0, 0.62119, 0, 0, 0.27764],
  1602. "43": [0.08319, 0.58283, 0, 0, 0.75623],
  1603. "44": [0, 0.10803, 0, 0, 0.27764],
  1604. "45": [0.08319, 0.58283, 0, 0, 0.75623],
  1605. "46": [0, 0.10803, 0, 0, 0.27764],
  1606. "47": [0.24982, 0.74947, 0, 0, 0.50181],
  1607. "48": [0, 0.47534, 0, 0, 0.50181],
  1608. "49": [0, 0.47534, 0, 0, 0.50181],
  1609. "50": [0, 0.47534, 0, 0, 0.50181],
  1610. "51": [0.18906, 0.47534, 0, 0, 0.50181],
  1611. "52": [0.18906, 0.47534, 0, 0, 0.50181],
  1612. "53": [0.18906, 0.47534, 0, 0, 0.50181],
  1613. "54": [0, 0.69141, 0, 0, 0.50181],
  1614. "55": [0.18906, 0.47534, 0, 0, 0.50181],
  1615. "56": [0, 0.69141, 0, 0, 0.50181],
  1616. "57": [0.18906, 0.47534, 0, 0, 0.50181],
  1617. "58": [0, 0.47534, 0, 0, 0.21606],
  1618. "59": [0.12604, 0.47534, 0, 0, 0.21606],
  1619. "61": [-0.13099, 0.36866, 0, 0, 0.75623],
  1620. "63": [0, 0.69141, 0, 0, 0.36245],
  1621. "65": [0, 0.69141, 0, 0, 0.7176],
  1622. "66": [0, 0.69141, 0, 0, 0.88397],
  1623. "67": [0, 0.69141, 0, 0, 0.61254],
  1624. "68": [0, 0.69141, 0, 0, 0.83158],
  1625. "69": [0, 0.69141, 0, 0, 0.66278],
  1626. "70": [0.12604, 0.69141, 0, 0, 0.61119],
  1627. "71": [0, 0.69141, 0, 0, 0.78539],
  1628. "72": [0.06302, 0.69141, 0, 0, 0.7203],
  1629. "73": [0, 0.69141, 0, 0, 0.55448],
  1630. "74": [0.12604, 0.69141, 0, 0, 0.55231],
  1631. "75": [0, 0.69141, 0, 0, 0.66845],
  1632. "76": [0, 0.69141, 0, 0, 0.66602],
  1633. "77": [0, 0.69141, 0, 0, 1.04953],
  1634. "78": [0, 0.69141, 0, 0, 0.83212],
  1635. "79": [0, 0.69141, 0, 0, 0.82699],
  1636. "80": [0.18906, 0.69141, 0, 0, 0.82753],
  1637. "81": [0.03781, 0.69141, 0, 0, 0.82699],
  1638. "82": [0, 0.69141, 0, 0, 0.82807],
  1639. "83": [0, 0.69141, 0, 0, 0.82861],
  1640. "84": [0, 0.69141, 0, 0, 0.66899],
  1641. "85": [0, 0.69141, 0, 0, 0.64576],
  1642. "86": [0, 0.69141, 0, 0, 0.83131],
  1643. "87": [0, 0.69141, 0, 0, 1.04602],
  1644. "88": [0, 0.69141, 0, 0, 0.71922],
  1645. "89": [0.18906, 0.69141, 0, 0, 0.83293],
  1646. "90": [0.12604, 0.69141, 0, 0, 0.60201],
  1647. "91": [0.24982, 0.74947, 0, 0, 0.27764],
  1648. "93": [0.24982, 0.74947, 0, 0, 0.27764],
  1649. "94": [0, 0.69141, 0, 0, 0.49965],
  1650. "97": [0, 0.47534, 0, 0, 0.50046],
  1651. "98": [0, 0.69141, 0, 0, 0.51315],
  1652. "99": [0, 0.47534, 0, 0, 0.38946],
  1653. "100": [0, 0.62119, 0, 0, 0.49857],
  1654. "101": [0, 0.47534, 0, 0, 0.40053],
  1655. "102": [0.18906, 0.69141, 0, 0, 0.32626],
  1656. "103": [0.18906, 0.47534, 0, 0, 0.5037],
  1657. "104": [0.18906, 0.69141, 0, 0, 0.52126],
  1658. "105": [0, 0.69141, 0, 0, 0.27899],
  1659. "106": [0, 0.69141, 0, 0, 0.28088],
  1660. "107": [0, 0.69141, 0, 0, 0.38946],
  1661. "108": [0, 0.69141, 0, 0, 0.27953],
  1662. "109": [0, 0.47534, 0, 0, 0.76676],
  1663. "110": [0, 0.47534, 0, 0, 0.52666],
  1664. "111": [0, 0.47534, 0, 0, 0.48885],
  1665. "112": [0.18906, 0.52396, 0, 0, 0.50046],
  1666. "113": [0.18906, 0.47534, 0, 0, 0.48912],
  1667. "114": [0, 0.47534, 0, 0, 0.38919],
  1668. "115": [0, 0.47534, 0, 0, 0.44266],
  1669. "116": [0, 0.62119, 0, 0, 0.33301],
  1670. "117": [0, 0.47534, 0, 0, 0.5172],
  1671. "118": [0, 0.52396, 0, 0, 0.5118],
  1672. "119": [0, 0.52396, 0, 0, 0.77351],
  1673. "120": [0.18906, 0.47534, 0, 0, 0.38865],
  1674. "121": [0.18906, 0.47534, 0, 0, 0.49884],
  1675. "122": [0.18906, 0.47534, 0, 0, 0.39054],
  1676. "160": [0, 0, 0, 0, 0.25],
  1677. "8216": [0, 0.69141, 0, 0, 0.21471],
  1678. "8217": [0, 0.69141, 0, 0, 0.21471],
  1679. "58112": [0, 0.62119, 0, 0, 0.49749],
  1680. "58113": [0, 0.62119, 0, 0, 0.4983],
  1681. "58114": [0.18906, 0.69141, 0, 0, 0.33328],
  1682. "58115": [0.18906, 0.69141, 0, 0, 0.32923],
  1683. "58116": [0.18906, 0.47534, 0, 0, 0.50343],
  1684. "58117": [0, 0.69141, 0, 0, 0.33301],
  1685. "58118": [0, 0.62119, 0, 0, 0.33409],
  1686. "58119": [0, 0.47534, 0, 0, 0.50073]
  1687. },
  1688. "Main-Bold": {
  1689. "32": [0, 0, 0, 0, 0.25],
  1690. "33": [0, 0.69444, 0, 0, 0.35],
  1691. "34": [0, 0.69444, 0, 0, 0.60278],
  1692. "35": [0.19444, 0.69444, 0, 0, 0.95833],
  1693. "36": [0.05556, 0.75, 0, 0, 0.575],
  1694. "37": [0.05556, 0.75, 0, 0, 0.95833],
  1695. "38": [0, 0.69444, 0, 0, 0.89444],
  1696. "39": [0, 0.69444, 0, 0, 0.31944],
  1697. "40": [0.25, 0.75, 0, 0, 0.44722],
  1698. "41": [0.25, 0.75, 0, 0, 0.44722],
  1699. "42": [0, 0.75, 0, 0, 0.575],
  1700. "43": [0.13333, 0.63333, 0, 0, 0.89444],
  1701. "44": [0.19444, 0.15556, 0, 0, 0.31944],
  1702. "45": [0, 0.44444, 0, 0, 0.38333],
  1703. "46": [0, 0.15556, 0, 0, 0.31944],
  1704. "47": [0.25, 0.75, 0, 0, 0.575],
  1705. "48": [0, 0.64444, 0, 0, 0.575],
  1706. "49": [0, 0.64444, 0, 0, 0.575],
  1707. "50": [0, 0.64444, 0, 0, 0.575],
  1708. "51": [0, 0.64444, 0, 0, 0.575],
  1709. "52": [0, 0.64444, 0, 0, 0.575],
  1710. "53": [0, 0.64444, 0, 0, 0.575],
  1711. "54": [0, 0.64444, 0, 0, 0.575],
  1712. "55": [0, 0.64444, 0, 0, 0.575],
  1713. "56": [0, 0.64444, 0, 0, 0.575],
  1714. "57": [0, 0.64444, 0, 0, 0.575],
  1715. "58": [0, 0.44444, 0, 0, 0.31944],
  1716. "59": [0.19444, 0.44444, 0, 0, 0.31944],
  1717. "60": [0.08556, 0.58556, 0, 0, 0.89444],
  1718. "61": [-0.10889, 0.39111, 0, 0, 0.89444],
  1719. "62": [0.08556, 0.58556, 0, 0, 0.89444],
  1720. "63": [0, 0.69444, 0, 0, 0.54305],
  1721. "64": [0, 0.69444, 0, 0, 0.89444],
  1722. "65": [0, 0.68611, 0, 0, 0.86944],
  1723. "66": [0, 0.68611, 0, 0, 0.81805],
  1724. "67": [0, 0.68611, 0, 0, 0.83055],
  1725. "68": [0, 0.68611, 0, 0, 0.88194],
  1726. "69": [0, 0.68611, 0, 0, 0.75555],
  1727. "70": [0, 0.68611, 0, 0, 0.72361],
  1728. "71": [0, 0.68611, 0, 0, 0.90416],
  1729. "72": [0, 0.68611, 0, 0, 0.9],
  1730. "73": [0, 0.68611, 0, 0, 0.43611],
  1731. "74": [0, 0.68611, 0, 0, 0.59444],
  1732. "75": [0, 0.68611, 0, 0, 0.90138],
  1733. "76": [0, 0.68611, 0, 0, 0.69166],
  1734. "77": [0, 0.68611, 0, 0, 1.09166],
  1735. "78": [0, 0.68611, 0, 0, 0.9],
  1736. "79": [0, 0.68611, 0, 0, 0.86388],
  1737. "80": [0, 0.68611, 0, 0, 0.78611],
  1738. "81": [0.19444, 0.68611, 0, 0, 0.86388],
  1739. "82": [0, 0.68611, 0, 0, 0.8625],
  1740. "83": [0, 0.68611, 0, 0, 0.63889],
  1741. "84": [0, 0.68611, 0, 0, 0.8],
  1742. "85": [0, 0.68611, 0, 0, 0.88472],
  1743. "86": [0, 0.68611, 0.01597, 0, 0.86944],
  1744. "87": [0, 0.68611, 0.01597, 0, 1.18888],
  1745. "88": [0, 0.68611, 0, 0, 0.86944],
  1746. "89": [0, 0.68611, 0.02875, 0, 0.86944],
  1747. "90": [0, 0.68611, 0, 0, 0.70277],
  1748. "91": [0.25, 0.75, 0, 0, 0.31944],
  1749. "92": [0.25, 0.75, 0, 0, 0.575],
  1750. "93": [0.25, 0.75, 0, 0, 0.31944],
  1751. "94": [0, 0.69444, 0, 0, 0.575],
  1752. "95": [0.31, 0.13444, 0.03194, 0, 0.575],
  1753. "97": [0, 0.44444, 0, 0, 0.55902],
  1754. "98": [0, 0.69444, 0, 0, 0.63889],
  1755. "99": [0, 0.44444, 0, 0, 0.51111],
  1756. "100": [0, 0.69444, 0, 0, 0.63889],
  1757. "101": [0, 0.44444, 0, 0, 0.52708],
  1758. "102": [0, 0.69444, 0.10903, 0, 0.35139],
  1759. "103": [0.19444, 0.44444, 0.01597, 0, 0.575],
  1760. "104": [0, 0.69444, 0, 0, 0.63889],
  1761. "105": [0, 0.69444, 0, 0, 0.31944],
  1762. "106": [0.19444, 0.69444, 0, 0, 0.35139],
  1763. "107": [0, 0.69444, 0, 0, 0.60694],
  1764. "108": [0, 0.69444, 0, 0, 0.31944],
  1765. "109": [0, 0.44444, 0, 0, 0.95833],
  1766. "110": [0, 0.44444, 0, 0, 0.63889],
  1767. "111": [0, 0.44444, 0, 0, 0.575],
  1768. "112": [0.19444, 0.44444, 0, 0, 0.63889],
  1769. "113": [0.19444, 0.44444, 0, 0, 0.60694],
  1770. "114": [0, 0.44444, 0, 0, 0.47361],
  1771. "115": [0, 0.44444, 0, 0, 0.45361],
  1772. "116": [0, 0.63492, 0, 0, 0.44722],
  1773. "117": [0, 0.44444, 0, 0, 0.63889],
  1774. "118": [0, 0.44444, 0.01597, 0, 0.60694],
  1775. "119": [0, 0.44444, 0.01597, 0, 0.83055],
  1776. "120": [0, 0.44444, 0, 0, 0.60694],
  1777. "121": [0.19444, 0.44444, 0.01597, 0, 0.60694],
  1778. "122": [0, 0.44444, 0, 0, 0.51111],
  1779. "123": [0.25, 0.75, 0, 0, 0.575],
  1780. "124": [0.25, 0.75, 0, 0, 0.31944],
  1781. "125": [0.25, 0.75, 0, 0, 0.575],
  1782. "126": [0.35, 0.34444, 0, 0, 0.575],
  1783. "160": [0, 0, 0, 0, 0.25],
  1784. "163": [0, 0.69444, 0, 0, 0.86853],
  1785. "168": [0, 0.69444, 0, 0, 0.575],
  1786. "172": [0, 0.44444, 0, 0, 0.76666],
  1787. "176": [0, 0.69444, 0, 0, 0.86944],
  1788. "177": [0.13333, 0.63333, 0, 0, 0.89444],
  1789. "184": [0.17014, 0, 0, 0, 0.51111],
  1790. "198": [0, 0.68611, 0, 0, 1.04166],
  1791. "215": [0.13333, 0.63333, 0, 0, 0.89444],
  1792. "216": [0.04861, 0.73472, 0, 0, 0.89444],
  1793. "223": [0, 0.69444, 0, 0, 0.59722],
  1794. "230": [0, 0.44444, 0, 0, 0.83055],
  1795. "247": [0.13333, 0.63333, 0, 0, 0.89444],
  1796. "248": [0.09722, 0.54167, 0, 0, 0.575],
  1797. "305": [0, 0.44444, 0, 0, 0.31944],
  1798. "338": [0, 0.68611, 0, 0, 1.16944],
  1799. "339": [0, 0.44444, 0, 0, 0.89444],
  1800. "567": [0.19444, 0.44444, 0, 0, 0.35139],
  1801. "710": [0, 0.69444, 0, 0, 0.575],
  1802. "711": [0, 0.63194, 0, 0, 0.575],
  1803. "713": [0, 0.59611, 0, 0, 0.575],
  1804. "714": [0, 0.69444, 0, 0, 0.575],
  1805. "715": [0, 0.69444, 0, 0, 0.575],
  1806. "728": [0, 0.69444, 0, 0, 0.575],
  1807. "729": [0, 0.69444, 0, 0, 0.31944],
  1808. "730": [0, 0.69444, 0, 0, 0.86944],
  1809. "732": [0, 0.69444, 0, 0, 0.575],
  1810. "733": [0, 0.69444, 0, 0, 0.575],
  1811. "915": [0, 0.68611, 0, 0, 0.69166],
  1812. "916": [0, 0.68611, 0, 0, 0.95833],
  1813. "920": [0, 0.68611, 0, 0, 0.89444],
  1814. "923": [0, 0.68611, 0, 0, 0.80555],
  1815. "926": [0, 0.68611, 0, 0, 0.76666],
  1816. "928": [0, 0.68611, 0, 0, 0.9],
  1817. "931": [0, 0.68611, 0, 0, 0.83055],
  1818. "933": [0, 0.68611, 0, 0, 0.89444],
  1819. "934": [0, 0.68611, 0, 0, 0.83055],
  1820. "936": [0, 0.68611, 0, 0, 0.89444],
  1821. "937": [0, 0.68611, 0, 0, 0.83055],
  1822. "8211": [0, 0.44444, 0.03194, 0, 0.575],
  1823. "8212": [0, 0.44444, 0.03194, 0, 1.14999],
  1824. "8216": [0, 0.69444, 0, 0, 0.31944],
  1825. "8217": [0, 0.69444, 0, 0, 0.31944],
  1826. "8220": [0, 0.69444, 0, 0, 0.60278],
  1827. "8221": [0, 0.69444, 0, 0, 0.60278],
  1828. "8224": [0.19444, 0.69444, 0, 0, 0.51111],
  1829. "8225": [0.19444, 0.69444, 0, 0, 0.51111],
  1830. "8242": [0, 0.55556, 0, 0, 0.34444],
  1831. "8407": [0, 0.72444, 0.15486, 0, 0.575],
  1832. "8463": [0, 0.69444, 0, 0, 0.66759],
  1833. "8465": [0, 0.69444, 0, 0, 0.83055],
  1834. "8467": [0, 0.69444, 0, 0, 0.47361],
  1835. "8472": [0.19444, 0.44444, 0, 0, 0.74027],
  1836. "8476": [0, 0.69444, 0, 0, 0.83055],
  1837. "8501": [0, 0.69444, 0, 0, 0.70277],
  1838. "8592": [-0.10889, 0.39111, 0, 0, 1.14999],
  1839. "8593": [0.19444, 0.69444, 0, 0, 0.575],
  1840. "8594": [-0.10889, 0.39111, 0, 0, 1.14999],
  1841. "8595": [0.19444, 0.69444, 0, 0, 0.575],
  1842. "8596": [-0.10889, 0.39111, 0, 0, 1.14999],
  1843. "8597": [0.25, 0.75, 0, 0, 0.575],
  1844. "8598": [0.19444, 0.69444, 0, 0, 1.14999],
  1845. "8599": [0.19444, 0.69444, 0, 0, 1.14999],
  1846. "8600": [0.19444, 0.69444, 0, 0, 1.14999],
  1847. "8601": [0.19444, 0.69444, 0, 0, 1.14999],
  1848. "8636": [-0.10889, 0.39111, 0, 0, 1.14999],
  1849. "8637": [-0.10889, 0.39111, 0, 0, 1.14999],
  1850. "8640": [-0.10889, 0.39111, 0, 0, 1.14999],
  1851. "8641": [-0.10889, 0.39111, 0, 0, 1.14999],
  1852. "8656": [-0.10889, 0.39111, 0, 0, 1.14999],
  1853. "8657": [0.19444, 0.69444, 0, 0, 0.70277],
  1854. "8658": [-0.10889, 0.39111, 0, 0, 1.14999],
  1855. "8659": [0.19444, 0.69444, 0, 0, 0.70277],
  1856. "8660": [-0.10889, 0.39111, 0, 0, 1.14999],
  1857. "8661": [0.25, 0.75, 0, 0, 0.70277],
  1858. "8704": [0, 0.69444, 0, 0, 0.63889],
  1859. "8706": [0, 0.69444, 0.06389, 0, 0.62847],
  1860. "8707": [0, 0.69444, 0, 0, 0.63889],
  1861. "8709": [0.05556, 0.75, 0, 0, 0.575],
  1862. "8711": [0, 0.68611, 0, 0, 0.95833],
  1863. "8712": [0.08556, 0.58556, 0, 0, 0.76666],
  1864. "8715": [0.08556, 0.58556, 0, 0, 0.76666],
  1865. "8722": [0.13333, 0.63333, 0, 0, 0.89444],
  1866. "8723": [0.13333, 0.63333, 0, 0, 0.89444],
  1867. "8725": [0.25, 0.75, 0, 0, 0.575],
  1868. "8726": [0.25, 0.75, 0, 0, 0.575],
  1869. "8727": [-0.02778, 0.47222, 0, 0, 0.575],
  1870. "8728": [-0.02639, 0.47361, 0, 0, 0.575],
  1871. "8729": [-0.02639, 0.47361, 0, 0, 0.575],
  1872. "8730": [0.18, 0.82, 0, 0, 0.95833],
  1873. "8733": [0, 0.44444, 0, 0, 0.89444],
  1874. "8734": [0, 0.44444, 0, 0, 1.14999],
  1875. "8736": [0, 0.69224, 0, 0, 0.72222],
  1876. "8739": [0.25, 0.75, 0, 0, 0.31944],
  1877. "8741": [0.25, 0.75, 0, 0, 0.575],
  1878. "8743": [0, 0.55556, 0, 0, 0.76666],
  1879. "8744": [0, 0.55556, 0, 0, 0.76666],
  1880. "8745": [0, 0.55556, 0, 0, 0.76666],
  1881. "8746": [0, 0.55556, 0, 0, 0.76666],
  1882. "8747": [0.19444, 0.69444, 0.12778, 0, 0.56875],
  1883. "8764": [-0.10889, 0.39111, 0, 0, 0.89444],
  1884. "8768": [0.19444, 0.69444, 0, 0, 0.31944],
  1885. "8771": [0.00222, 0.50222, 0, 0, 0.89444],
  1886. "8773": [0.027, 0.638, 0, 0, 0.894],
  1887. "8776": [0.02444, 0.52444, 0, 0, 0.89444],
  1888. "8781": [0.00222, 0.50222, 0, 0, 0.89444],
  1889. "8801": [0.00222, 0.50222, 0, 0, 0.89444],
  1890. "8804": [0.19667, 0.69667, 0, 0, 0.89444],
  1891. "8805": [0.19667, 0.69667, 0, 0, 0.89444],
  1892. "8810": [0.08556, 0.58556, 0, 0, 1.14999],
  1893. "8811": [0.08556, 0.58556, 0, 0, 1.14999],
  1894. "8826": [0.08556, 0.58556, 0, 0, 0.89444],
  1895. "8827": [0.08556, 0.58556, 0, 0, 0.89444],
  1896. "8834": [0.08556, 0.58556, 0, 0, 0.89444],
  1897. "8835": [0.08556, 0.58556, 0, 0, 0.89444],
  1898. "8838": [0.19667, 0.69667, 0, 0, 0.89444],
  1899. "8839": [0.19667, 0.69667, 0, 0, 0.89444],
  1900. "8846": [0, 0.55556, 0, 0, 0.76666],
  1901. "8849": [0.19667, 0.69667, 0, 0, 0.89444],
  1902. "8850": [0.19667, 0.69667, 0, 0, 0.89444],
  1903. "8851": [0, 0.55556, 0, 0, 0.76666],
  1904. "8852": [0, 0.55556, 0, 0, 0.76666],
  1905. "8853": [0.13333, 0.63333, 0, 0, 0.89444],
  1906. "8854": [0.13333, 0.63333, 0, 0, 0.89444],
  1907. "8855": [0.13333, 0.63333, 0, 0, 0.89444],
  1908. "8856": [0.13333, 0.63333, 0, 0, 0.89444],
  1909. "8857": [0.13333, 0.63333, 0, 0, 0.89444],
  1910. "8866": [0, 0.69444, 0, 0, 0.70277],
  1911. "8867": [0, 0.69444, 0, 0, 0.70277],
  1912. "8868": [0, 0.69444, 0, 0, 0.89444],
  1913. "8869": [0, 0.69444, 0, 0, 0.89444],
  1914. "8900": [-0.02639, 0.47361, 0, 0, 0.575],
  1915. "8901": [-0.02639, 0.47361, 0, 0, 0.31944],
  1916. "8902": [-0.02778, 0.47222, 0, 0, 0.575],
  1917. "8968": [0.25, 0.75, 0, 0, 0.51111],
  1918. "8969": [0.25, 0.75, 0, 0, 0.51111],
  1919. "8970": [0.25, 0.75, 0, 0, 0.51111],
  1920. "8971": [0.25, 0.75, 0, 0, 0.51111],
  1921. "8994": [-0.13889, 0.36111, 0, 0, 1.14999],
  1922. "8995": [-0.13889, 0.36111, 0, 0, 1.14999],
  1923. "9651": [0.19444, 0.69444, 0, 0, 1.02222],
  1924. "9657": [-0.02778, 0.47222, 0, 0, 0.575],
  1925. "9661": [0.19444, 0.69444, 0, 0, 1.02222],
  1926. "9667": [-0.02778, 0.47222, 0, 0, 0.575],
  1927. "9711": [0.19444, 0.69444, 0, 0, 1.14999],
  1928. "9824": [0.12963, 0.69444, 0, 0, 0.89444],
  1929. "9825": [0.12963, 0.69444, 0, 0, 0.89444],
  1930. "9826": [0.12963, 0.69444, 0, 0, 0.89444],
  1931. "9827": [0.12963, 0.69444, 0, 0, 0.89444],
  1932. "9837": [0, 0.75, 0, 0, 0.44722],
  1933. "9838": [0.19444, 0.69444, 0, 0, 0.44722],
  1934. "9839": [0.19444, 0.69444, 0, 0, 0.44722],
  1935. "10216": [0.25, 0.75, 0, 0, 0.44722],
  1936. "10217": [0.25, 0.75, 0, 0, 0.44722],
  1937. "10815": [0, 0.68611, 0, 0, 0.9],
  1938. "10927": [0.19667, 0.69667, 0, 0, 0.89444],
  1939. "10928": [0.19667, 0.69667, 0, 0, 0.89444],
  1940. "57376": [0.19444, 0.69444, 0, 0, 0]
  1941. },
  1942. "Main-BoldItalic": {
  1943. "32": [0, 0, 0, 0, 0.25],
  1944. "33": [0, 0.69444, 0.11417, 0, 0.38611],
  1945. "34": [0, 0.69444, 0.07939, 0, 0.62055],
  1946. "35": [0.19444, 0.69444, 0.06833, 0, 0.94444],
  1947. "37": [0.05556, 0.75, 0.12861, 0, 0.94444],
  1948. "38": [0, 0.69444, 0.08528, 0, 0.88555],
  1949. "39": [0, 0.69444, 0.12945, 0, 0.35555],
  1950. "40": [0.25, 0.75, 0.15806, 0, 0.47333],
  1951. "41": [0.25, 0.75, 0.03306, 0, 0.47333],
  1952. "42": [0, 0.75, 0.14333, 0, 0.59111],
  1953. "43": [0.10333, 0.60333, 0.03306, 0, 0.88555],
  1954. "44": [0.19444, 0.14722, 0, 0, 0.35555],
  1955. "45": [0, 0.44444, 0.02611, 0, 0.41444],
  1956. "46": [0, 0.14722, 0, 0, 0.35555],
  1957. "47": [0.25, 0.75, 0.15806, 0, 0.59111],
  1958. "48": [0, 0.64444, 0.13167, 0, 0.59111],
  1959. "49": [0, 0.64444, 0.13167, 0, 0.59111],
  1960. "50": [0, 0.64444, 0.13167, 0, 0.59111],
  1961. "51": [0, 0.64444, 0.13167, 0, 0.59111],
  1962. "52": [0.19444, 0.64444, 0.13167, 0, 0.59111],
  1963. "53": [0, 0.64444, 0.13167, 0, 0.59111],
  1964. "54": [0, 0.64444, 0.13167, 0, 0.59111],
  1965. "55": [0.19444, 0.64444, 0.13167, 0, 0.59111],
  1966. "56": [0, 0.64444, 0.13167, 0, 0.59111],
  1967. "57": [0, 0.64444, 0.13167, 0, 0.59111],
  1968. "58": [0, 0.44444, 0.06695, 0, 0.35555],
  1969. "59": [0.19444, 0.44444, 0.06695, 0, 0.35555],
  1970. "61": [-0.10889, 0.39111, 0.06833, 0, 0.88555],
  1971. "63": [0, 0.69444, 0.11472, 0, 0.59111],
  1972. "64": [0, 0.69444, 0.09208, 0, 0.88555],
  1973. "65": [0, 0.68611, 0, 0, 0.86555],
  1974. "66": [0, 0.68611, 0.0992, 0, 0.81666],
  1975. "67": [0, 0.68611, 0.14208, 0, 0.82666],
  1976. "68": [0, 0.68611, 0.09062, 0, 0.87555],
  1977. "69": [0, 0.68611, 0.11431, 0, 0.75666],
  1978. "70": [0, 0.68611, 0.12903, 0, 0.72722],
  1979. "71": [0, 0.68611, 0.07347, 0, 0.89527],
  1980. "72": [0, 0.68611, 0.17208, 0, 0.8961],
  1981. "73": [0, 0.68611, 0.15681, 0, 0.47166],
  1982. "74": [0, 0.68611, 0.145, 0, 0.61055],
  1983. "75": [0, 0.68611, 0.14208, 0, 0.89499],
  1984. "76": [0, 0.68611, 0, 0, 0.69777],
  1985. "77": [0, 0.68611, 0.17208, 0, 1.07277],
  1986. "78": [0, 0.68611, 0.17208, 0, 0.8961],
  1987. "79": [0, 0.68611, 0.09062, 0, 0.85499],
  1988. "80": [0, 0.68611, 0.0992, 0, 0.78721],
  1989. "81": [0.19444, 0.68611, 0.09062, 0, 0.85499],
  1990. "82": [0, 0.68611, 0.02559, 0, 0.85944],
  1991. "83": [0, 0.68611, 0.11264, 0, 0.64999],
  1992. "84": [0, 0.68611, 0.12903, 0, 0.7961],
  1993. "85": [0, 0.68611, 0.17208, 0, 0.88083],
  1994. "86": [0, 0.68611, 0.18625, 0, 0.86555],
  1995. "87": [0, 0.68611, 0.18625, 0, 1.15999],
  1996. "88": [0, 0.68611, 0.15681, 0, 0.86555],
  1997. "89": [0, 0.68611, 0.19803, 0, 0.86555],
  1998. "90": [0, 0.68611, 0.14208, 0, 0.70888],
  1999. "91": [0.25, 0.75, 0.1875, 0, 0.35611],
  2000. "93": [0.25, 0.75, 0.09972, 0, 0.35611],
  2001. "94": [0, 0.69444, 0.06709, 0, 0.59111],
  2002. "95": [0.31, 0.13444, 0.09811, 0, 0.59111],
  2003. "97": [0, 0.44444, 0.09426, 0, 0.59111],
  2004. "98": [0, 0.69444, 0.07861, 0, 0.53222],
  2005. "99": [0, 0.44444, 0.05222, 0, 0.53222],
  2006. "100": [0, 0.69444, 0.10861, 0, 0.59111],
  2007. "101": [0, 0.44444, 0.085, 0, 0.53222],
  2008. "102": [0.19444, 0.69444, 0.21778, 0, 0.4],
  2009. "103": [0.19444, 0.44444, 0.105, 0, 0.53222],
  2010. "104": [0, 0.69444, 0.09426, 0, 0.59111],
  2011. "105": [0, 0.69326, 0.11387, 0, 0.35555],
  2012. "106": [0.19444, 0.69326, 0.1672, 0, 0.35555],
  2013. "107": [0, 0.69444, 0.11111, 0, 0.53222],
  2014. "108": [0, 0.69444, 0.10861, 0, 0.29666],
  2015. "109": [0, 0.44444, 0.09426, 0, 0.94444],
  2016. "110": [0, 0.44444, 0.09426, 0, 0.64999],
  2017. "111": [0, 0.44444, 0.07861, 0, 0.59111],
  2018. "112": [0.19444, 0.44444, 0.07861, 0, 0.59111],
  2019. "113": [0.19444, 0.44444, 0.105, 0, 0.53222],
  2020. "114": [0, 0.44444, 0.11111, 0, 0.50167],
  2021. "115": [0, 0.44444, 0.08167, 0, 0.48694],
  2022. "116": [0, 0.63492, 0.09639, 0, 0.385],
  2023. "117": [0, 0.44444, 0.09426, 0, 0.62055],
  2024. "118": [0, 0.44444, 0.11111, 0, 0.53222],
  2025. "119": [0, 0.44444, 0.11111, 0, 0.76777],
  2026. "120": [0, 0.44444, 0.12583, 0, 0.56055],
  2027. "121": [0.19444, 0.44444, 0.105, 0, 0.56166],
  2028. "122": [0, 0.44444, 0.13889, 0, 0.49055],
  2029. "126": [0.35, 0.34444, 0.11472, 0, 0.59111],
  2030. "160": [0, 0, 0, 0, 0.25],
  2031. "168": [0, 0.69444, 0.11473, 0, 0.59111],
  2032. "176": [0, 0.69444, 0, 0, 0.94888],
  2033. "184": [0.17014, 0, 0, 0, 0.53222],
  2034. "198": [0, 0.68611, 0.11431, 0, 1.02277],
  2035. "216": [0.04861, 0.73472, 0.09062, 0, 0.88555],
  2036. "223": [0.19444, 0.69444, 0.09736, 0, 0.665],
  2037. "230": [0, 0.44444, 0.085, 0, 0.82666],
  2038. "248": [0.09722, 0.54167, 0.09458, 0, 0.59111],
  2039. "305": [0, 0.44444, 0.09426, 0, 0.35555],
  2040. "338": [0, 0.68611, 0.11431, 0, 1.14054],
  2041. "339": [0, 0.44444, 0.085, 0, 0.82666],
  2042. "567": [0.19444, 0.44444, 0.04611, 0, 0.385],
  2043. "710": [0, 0.69444, 0.06709, 0, 0.59111],
  2044. "711": [0, 0.63194, 0.08271, 0, 0.59111],
  2045. "713": [0, 0.59444, 0.10444, 0, 0.59111],
  2046. "714": [0, 0.69444, 0.08528, 0, 0.59111],
  2047. "715": [0, 0.69444, 0, 0, 0.59111],
  2048. "728": [0, 0.69444, 0.10333, 0, 0.59111],
  2049. "729": [0, 0.69444, 0.12945, 0, 0.35555],
  2050. "730": [0, 0.69444, 0, 0, 0.94888],
  2051. "732": [0, 0.69444, 0.11472, 0, 0.59111],
  2052. "733": [0, 0.69444, 0.11472, 0, 0.59111],
  2053. "915": [0, 0.68611, 0.12903, 0, 0.69777],
  2054. "916": [0, 0.68611, 0, 0, 0.94444],
  2055. "920": [0, 0.68611, 0.09062, 0, 0.88555],
  2056. "923": [0, 0.68611, 0, 0, 0.80666],
  2057. "926": [0, 0.68611, 0.15092, 0, 0.76777],
  2058. "928": [0, 0.68611, 0.17208, 0, 0.8961],
  2059. "931": [0, 0.68611, 0.11431, 0, 0.82666],
  2060. "933": [0, 0.68611, 0.10778, 0, 0.88555],
  2061. "934": [0, 0.68611, 0.05632, 0, 0.82666],
  2062. "936": [0, 0.68611, 0.10778, 0, 0.88555],
  2063. "937": [0, 0.68611, 0.0992, 0, 0.82666],
  2064. "8211": [0, 0.44444, 0.09811, 0, 0.59111],
  2065. "8212": [0, 0.44444, 0.09811, 0, 1.18221],
  2066. "8216": [0, 0.69444, 0.12945, 0, 0.35555],
  2067. "8217": [0, 0.69444, 0.12945, 0, 0.35555],
  2068. "8220": [0, 0.69444, 0.16772, 0, 0.62055],
  2069. "8221": [0, 0.69444, 0.07939, 0, 0.62055]
  2070. },
  2071. "Main-Italic": {
  2072. "32": [0, 0, 0, 0, 0.25],
  2073. "33": [0, 0.69444, 0.12417, 0, 0.30667],
  2074. "34": [0, 0.69444, 0.06961, 0, 0.51444],
  2075. "35": [0.19444, 0.69444, 0.06616, 0, 0.81777],
  2076. "37": [0.05556, 0.75, 0.13639, 0, 0.81777],
  2077. "38": [0, 0.69444, 0.09694, 0, 0.76666],
  2078. "39": [0, 0.69444, 0.12417, 0, 0.30667],
  2079. "40": [0.25, 0.75, 0.16194, 0, 0.40889],
  2080. "41": [0.25, 0.75, 0.03694, 0, 0.40889],
  2081. "42": [0, 0.75, 0.14917, 0, 0.51111],
  2082. "43": [0.05667, 0.56167, 0.03694, 0, 0.76666],
  2083. "44": [0.19444, 0.10556, 0, 0, 0.30667],
  2084. "45": [0, 0.43056, 0.02826, 0, 0.35778],
  2085. "46": [0, 0.10556, 0, 0, 0.30667],
  2086. "47": [0.25, 0.75, 0.16194, 0, 0.51111],
  2087. "48": [0, 0.64444, 0.13556, 0, 0.51111],
  2088. "49": [0, 0.64444, 0.13556, 0, 0.51111],
  2089. "50": [0, 0.64444, 0.13556, 0, 0.51111],
  2090. "51": [0, 0.64444, 0.13556, 0, 0.51111],
  2091. "52": [0.19444, 0.64444, 0.13556, 0, 0.51111],
  2092. "53": [0, 0.64444, 0.13556, 0, 0.51111],
  2093. "54": [0, 0.64444, 0.13556, 0, 0.51111],
  2094. "55": [0.19444, 0.64444, 0.13556, 0, 0.51111],
  2095. "56": [0, 0.64444, 0.13556, 0, 0.51111],
  2096. "57": [0, 0.64444, 0.13556, 0, 0.51111],
  2097. "58": [0, 0.43056, 0.0582, 0, 0.30667],
  2098. "59": [0.19444, 0.43056, 0.0582, 0, 0.30667],
  2099. "61": [-0.13313, 0.36687, 0.06616, 0, 0.76666],
  2100. "63": [0, 0.69444, 0.1225, 0, 0.51111],
  2101. "64": [0, 0.69444, 0.09597, 0, 0.76666],
  2102. "65": [0, 0.68333, 0, 0, 0.74333],
  2103. "66": [0, 0.68333, 0.10257, 0, 0.70389],
  2104. "67": [0, 0.68333, 0.14528, 0, 0.71555],
  2105. "68": [0, 0.68333, 0.09403, 0, 0.755],
  2106. "69": [0, 0.68333, 0.12028, 0, 0.67833],
  2107. "70": [0, 0.68333, 0.13305, 0, 0.65277],
  2108. "71": [0, 0.68333, 0.08722, 0, 0.77361],
  2109. "72": [0, 0.68333, 0.16389, 0, 0.74333],
  2110. "73": [0, 0.68333, 0.15806, 0, 0.38555],
  2111. "74": [0, 0.68333, 0.14028, 0, 0.525],
  2112. "75": [0, 0.68333, 0.14528, 0, 0.76888],
  2113. "76": [0, 0.68333, 0, 0, 0.62722],
  2114. "77": [0, 0.68333, 0.16389, 0, 0.89666],
  2115. "78": [0, 0.68333, 0.16389, 0, 0.74333],
  2116. "79": [0, 0.68333, 0.09403, 0, 0.76666],
  2117. "80": [0, 0.68333, 0.10257, 0, 0.67833],
  2118. "81": [0.19444, 0.68333, 0.09403, 0, 0.76666],
  2119. "82": [0, 0.68333, 0.03868, 0, 0.72944],
  2120. "83": [0, 0.68333, 0.11972, 0, 0.56222],
  2121. "84": [0, 0.68333, 0.13305, 0, 0.71555],
  2122. "85": [0, 0.68333, 0.16389, 0, 0.74333],
  2123. "86": [0, 0.68333, 0.18361, 0, 0.74333],
  2124. "87": [0, 0.68333, 0.18361, 0, 0.99888],
  2125. "88": [0, 0.68333, 0.15806, 0, 0.74333],
  2126. "89": [0, 0.68333, 0.19383, 0, 0.74333],
  2127. "90": [0, 0.68333, 0.14528, 0, 0.61333],
  2128. "91": [0.25, 0.75, 0.1875, 0, 0.30667],
  2129. "93": [0.25, 0.75, 0.10528, 0, 0.30667],
  2130. "94": [0, 0.69444, 0.06646, 0, 0.51111],
  2131. "95": [0.31, 0.12056, 0.09208, 0, 0.51111],
  2132. "97": [0, 0.43056, 0.07671, 0, 0.51111],
  2133. "98": [0, 0.69444, 0.06312, 0, 0.46],
  2134. "99": [0, 0.43056, 0.05653, 0, 0.46],
  2135. "100": [0, 0.69444, 0.10333, 0, 0.51111],
  2136. "101": [0, 0.43056, 0.07514, 0, 0.46],
  2137. "102": [0.19444, 0.69444, 0.21194, 0, 0.30667],
  2138. "103": [0.19444, 0.43056, 0.08847, 0, 0.46],
  2139. "104": [0, 0.69444, 0.07671, 0, 0.51111],
  2140. "105": [0, 0.65536, 0.1019, 0, 0.30667],
  2141. "106": [0.19444, 0.65536, 0.14467, 0, 0.30667],
  2142. "107": [0, 0.69444, 0.10764, 0, 0.46],
  2143. "108": [0, 0.69444, 0.10333, 0, 0.25555],
  2144. "109": [0, 0.43056, 0.07671, 0, 0.81777],
  2145. "110": [0, 0.43056, 0.07671, 0, 0.56222],
  2146. "111": [0, 0.43056, 0.06312, 0, 0.51111],
  2147. "112": [0.19444, 0.43056, 0.06312, 0, 0.51111],
  2148. "113": [0.19444, 0.43056, 0.08847, 0, 0.46],
  2149. "114": [0, 0.43056, 0.10764, 0, 0.42166],
  2150. "115": [0, 0.43056, 0.08208, 0, 0.40889],
  2151. "116": [0, 0.61508, 0.09486, 0, 0.33222],
  2152. "117": [0, 0.43056, 0.07671, 0, 0.53666],
  2153. "118": [0, 0.43056, 0.10764, 0, 0.46],
  2154. "119": [0, 0.43056, 0.10764, 0, 0.66444],
  2155. "120": [0, 0.43056, 0.12042, 0, 0.46389],
  2156. "121": [0.19444, 0.43056, 0.08847, 0, 0.48555],
  2157. "122": [0, 0.43056, 0.12292, 0, 0.40889],
  2158. "126": [0.35, 0.31786, 0.11585, 0, 0.51111],
  2159. "160": [0, 0, 0, 0, 0.25],
  2160. "168": [0, 0.66786, 0.10474, 0, 0.51111],
  2161. "176": [0, 0.69444, 0, 0, 0.83129],
  2162. "184": [0.17014, 0, 0, 0, 0.46],
  2163. "198": [0, 0.68333, 0.12028, 0, 0.88277],
  2164. "216": [0.04861, 0.73194, 0.09403, 0, 0.76666],
  2165. "223": [0.19444, 0.69444, 0.10514, 0, 0.53666],
  2166. "230": [0, 0.43056, 0.07514, 0, 0.71555],
  2167. "248": [0.09722, 0.52778, 0.09194, 0, 0.51111],
  2168. "338": [0, 0.68333, 0.12028, 0, 0.98499],
  2169. "339": [0, 0.43056, 0.07514, 0, 0.71555],
  2170. "710": [0, 0.69444, 0.06646, 0, 0.51111],
  2171. "711": [0, 0.62847, 0.08295, 0, 0.51111],
  2172. "713": [0, 0.56167, 0.10333, 0, 0.51111],
  2173. "714": [0, 0.69444, 0.09694, 0, 0.51111],
  2174. "715": [0, 0.69444, 0, 0, 0.51111],
  2175. "728": [0, 0.69444, 0.10806, 0, 0.51111],
  2176. "729": [0, 0.66786, 0.11752, 0, 0.30667],
  2177. "730": [0, 0.69444, 0, 0, 0.83129],
  2178. "732": [0, 0.66786, 0.11585, 0, 0.51111],
  2179. "733": [0, 0.69444, 0.1225, 0, 0.51111],
  2180. "915": [0, 0.68333, 0.13305, 0, 0.62722],
  2181. "916": [0, 0.68333, 0, 0, 0.81777],
  2182. "920": [0, 0.68333, 0.09403, 0, 0.76666],
  2183. "923": [0, 0.68333, 0, 0, 0.69222],
  2184. "926": [0, 0.68333, 0.15294, 0, 0.66444],
  2185. "928": [0, 0.68333, 0.16389, 0, 0.74333],
  2186. "931": [0, 0.68333, 0.12028, 0, 0.71555],
  2187. "933": [0, 0.68333, 0.11111, 0, 0.76666],
  2188. "934": [0, 0.68333, 0.05986, 0, 0.71555],
  2189. "936": [0, 0.68333, 0.11111, 0, 0.76666],
  2190. "937": [0, 0.68333, 0.10257, 0, 0.71555],
  2191. "8211": [0, 0.43056, 0.09208, 0, 0.51111],
  2192. "8212": [0, 0.43056, 0.09208, 0, 1.02222],
  2193. "8216": [0, 0.69444, 0.12417, 0, 0.30667],
  2194. "8217": [0, 0.69444, 0.12417, 0, 0.30667],
  2195. "8220": [0, 0.69444, 0.1685, 0, 0.51444],
  2196. "8221": [0, 0.69444, 0.06961, 0, 0.51444],
  2197. "8463": [0, 0.68889, 0, 0, 0.54028]
  2198. },
  2199. "Main-Regular": {
  2200. "32": [0, 0, 0, 0, 0.25],
  2201. "33": [0, 0.69444, 0, 0, 0.27778],
  2202. "34": [0, 0.69444, 0, 0, 0.5],
  2203. "35": [0.19444, 0.69444, 0, 0, 0.83334],
  2204. "36": [0.05556, 0.75, 0, 0, 0.5],
  2205. "37": [0.05556, 0.75, 0, 0, 0.83334],
  2206. "38": [0, 0.69444, 0, 0, 0.77778],
  2207. "39": [0, 0.69444, 0, 0, 0.27778],
  2208. "40": [0.25, 0.75, 0, 0, 0.38889],
  2209. "41": [0.25, 0.75, 0, 0, 0.38889],
  2210. "42": [0, 0.75, 0, 0, 0.5],
  2211. "43": [0.08333, 0.58333, 0, 0, 0.77778],
  2212. "44": [0.19444, 0.10556, 0, 0, 0.27778],
  2213. "45": [0, 0.43056, 0, 0, 0.33333],
  2214. "46": [0, 0.10556, 0, 0, 0.27778],
  2215. "47": [0.25, 0.75, 0, 0, 0.5],
  2216. "48": [0, 0.64444, 0, 0, 0.5],
  2217. "49": [0, 0.64444, 0, 0, 0.5],
  2218. "50": [0, 0.64444, 0, 0, 0.5],
  2219. "51": [0, 0.64444, 0, 0, 0.5],
  2220. "52": [0, 0.64444, 0, 0, 0.5],
  2221. "53": [0, 0.64444, 0, 0, 0.5],
  2222. "54": [0, 0.64444, 0, 0, 0.5],
  2223. "55": [0, 0.64444, 0, 0, 0.5],
  2224. "56": [0, 0.64444, 0, 0, 0.5],
  2225. "57": [0, 0.64444, 0, 0, 0.5],
  2226. "58": [0, 0.43056, 0, 0, 0.27778],
  2227. "59": [0.19444, 0.43056, 0, 0, 0.27778],
  2228. "60": [0.0391, 0.5391, 0, 0, 0.77778],
  2229. "61": [-0.13313, 0.36687, 0, 0, 0.77778],
  2230. "62": [0.0391, 0.5391, 0, 0, 0.77778],
  2231. "63": [0, 0.69444, 0, 0, 0.47222],
  2232. "64": [0, 0.69444, 0, 0, 0.77778],
  2233. "65": [0, 0.68333, 0, 0, 0.75],
  2234. "66": [0, 0.68333, 0, 0, 0.70834],
  2235. "67": [0, 0.68333, 0, 0, 0.72222],
  2236. "68": [0, 0.68333, 0, 0, 0.76389],
  2237. "69": [0, 0.68333, 0, 0, 0.68056],
  2238. "70": [0, 0.68333, 0, 0, 0.65278],
  2239. "71": [0, 0.68333, 0, 0, 0.78472],
  2240. "72": [0, 0.68333, 0, 0, 0.75],
  2241. "73": [0, 0.68333, 0, 0, 0.36111],
  2242. "74": [0, 0.68333, 0, 0, 0.51389],
  2243. "75": [0, 0.68333, 0, 0, 0.77778],
  2244. "76": [0, 0.68333, 0, 0, 0.625],
  2245. "77": [0, 0.68333, 0, 0, 0.91667],
  2246. "78": [0, 0.68333, 0, 0, 0.75],
  2247. "79": [0, 0.68333, 0, 0, 0.77778],
  2248. "80": [0, 0.68333, 0, 0, 0.68056],
  2249. "81": [0.19444, 0.68333, 0, 0, 0.77778],
  2250. "82": [0, 0.68333, 0, 0, 0.73611],
  2251. "83": [0, 0.68333, 0, 0, 0.55556],
  2252. "84": [0, 0.68333, 0, 0, 0.72222],
  2253. "85": [0, 0.68333, 0, 0, 0.75],
  2254. "86": [0, 0.68333, 0.01389, 0, 0.75],
  2255. "87": [0, 0.68333, 0.01389, 0, 1.02778],
  2256. "88": [0, 0.68333, 0, 0, 0.75],
  2257. "89": [0, 0.68333, 0.025, 0, 0.75],
  2258. "90": [0, 0.68333, 0, 0, 0.61111],
  2259. "91": [0.25, 0.75, 0, 0, 0.27778],
  2260. "92": [0.25, 0.75, 0, 0, 0.5],
  2261. "93": [0.25, 0.75, 0, 0, 0.27778],
  2262. "94": [0, 0.69444, 0, 0, 0.5],
  2263. "95": [0.31, 0.12056, 0.02778, 0, 0.5],
  2264. "97": [0, 0.43056, 0, 0, 0.5],
  2265. "98": [0, 0.69444, 0, 0, 0.55556],
  2266. "99": [0, 0.43056, 0, 0, 0.44445],
  2267. "100": [0, 0.69444, 0, 0, 0.55556],
  2268. "101": [0, 0.43056, 0, 0, 0.44445],
  2269. "102": [0, 0.69444, 0.07778, 0, 0.30556],
  2270. "103": [0.19444, 0.43056, 0.01389, 0, 0.5],
  2271. "104": [0, 0.69444, 0, 0, 0.55556],
  2272. "105": [0, 0.66786, 0, 0, 0.27778],
  2273. "106": [0.19444, 0.66786, 0, 0, 0.30556],
  2274. "107": [0, 0.69444, 0, 0, 0.52778],
  2275. "108": [0, 0.69444, 0, 0, 0.27778],
  2276. "109": [0, 0.43056, 0, 0, 0.83334],
  2277. "110": [0, 0.43056, 0, 0, 0.55556],
  2278. "111": [0, 0.43056, 0, 0, 0.5],
  2279. "112": [0.19444, 0.43056, 0, 0, 0.55556],
  2280. "113": [0.19444, 0.43056, 0, 0, 0.52778],
  2281. "114": [0, 0.43056, 0, 0, 0.39167],
  2282. "115": [0, 0.43056, 0, 0, 0.39445],
  2283. "116": [0, 0.61508, 0, 0, 0.38889],
  2284. "117": [0, 0.43056, 0, 0, 0.55556],
  2285. "118": [0, 0.43056, 0.01389, 0, 0.52778],
  2286. "119": [0, 0.43056, 0.01389, 0, 0.72222],
  2287. "120": [0, 0.43056, 0, 0, 0.52778],
  2288. "121": [0.19444, 0.43056, 0.01389, 0, 0.52778],
  2289. "122": [0, 0.43056, 0, 0, 0.44445],
  2290. "123": [0.25, 0.75, 0, 0, 0.5],
  2291. "124": [0.25, 0.75, 0, 0, 0.27778],
  2292. "125": [0.25, 0.75, 0, 0, 0.5],
  2293. "126": [0.35, 0.31786, 0, 0, 0.5],
  2294. "160": [0, 0, 0, 0, 0.25],
  2295. "163": [0, 0.69444, 0, 0, 0.76909],
  2296. "167": [0.19444, 0.69444, 0, 0, 0.44445],
  2297. "168": [0, 0.66786, 0, 0, 0.5],
  2298. "172": [0, 0.43056, 0, 0, 0.66667],
  2299. "176": [0, 0.69444, 0, 0, 0.75],
  2300. "177": [0.08333, 0.58333, 0, 0, 0.77778],
  2301. "182": [0.19444, 0.69444, 0, 0, 0.61111],
  2302. "184": [0.17014, 0, 0, 0, 0.44445],
  2303. "198": [0, 0.68333, 0, 0, 0.90278],
  2304. "215": [0.08333, 0.58333, 0, 0, 0.77778],
  2305. "216": [0.04861, 0.73194, 0, 0, 0.77778],
  2306. "223": [0, 0.69444, 0, 0, 0.5],
  2307. "230": [0, 0.43056, 0, 0, 0.72222],
  2308. "247": [0.08333, 0.58333, 0, 0, 0.77778],
  2309. "248": [0.09722, 0.52778, 0, 0, 0.5],
  2310. "305": [0, 0.43056, 0, 0, 0.27778],
  2311. "338": [0, 0.68333, 0, 0, 1.01389],
  2312. "339": [0, 0.43056, 0, 0, 0.77778],
  2313. "567": [0.19444, 0.43056, 0, 0, 0.30556],
  2314. "710": [0, 0.69444, 0, 0, 0.5],
  2315. "711": [0, 0.62847, 0, 0, 0.5],
  2316. "713": [0, 0.56778, 0, 0, 0.5],
  2317. "714": [0, 0.69444, 0, 0, 0.5],
  2318. "715": [0, 0.69444, 0, 0, 0.5],
  2319. "728": [0, 0.69444, 0, 0, 0.5],
  2320. "729": [0, 0.66786, 0, 0, 0.27778],
  2321. "730": [0, 0.69444, 0, 0, 0.75],
  2322. "732": [0, 0.66786, 0, 0, 0.5],
  2323. "733": [0, 0.69444, 0, 0, 0.5],
  2324. "915": [0, 0.68333, 0, 0, 0.625],
  2325. "916": [0, 0.68333, 0, 0, 0.83334],
  2326. "920": [0, 0.68333, 0, 0, 0.77778],
  2327. "923": [0, 0.68333, 0, 0, 0.69445],
  2328. "926": [0, 0.68333, 0, 0, 0.66667],
  2329. "928": [0, 0.68333, 0, 0, 0.75],
  2330. "931": [0, 0.68333, 0, 0, 0.72222],
  2331. "933": [0, 0.68333, 0, 0, 0.77778],
  2332. "934": [0, 0.68333, 0, 0, 0.72222],
  2333. "936": [0, 0.68333, 0, 0, 0.77778],
  2334. "937": [0, 0.68333, 0, 0, 0.72222],
  2335. "8211": [0, 0.43056, 0.02778, 0, 0.5],
  2336. "8212": [0, 0.43056, 0.02778, 0, 1.0],
  2337. "8216": [0, 0.69444, 0, 0, 0.27778],
  2338. "8217": [0, 0.69444, 0, 0, 0.27778],
  2339. "8220": [0, 0.69444, 0, 0, 0.5],
  2340. "8221": [0, 0.69444, 0, 0, 0.5],
  2341. "8224": [0.19444, 0.69444, 0, 0, 0.44445],
  2342. "8225": [0.19444, 0.69444, 0, 0, 0.44445],
  2343. "8230": [0, 0.123, 0, 0, 1.172],
  2344. "8242": [0, 0.55556, 0, 0, 0.275],
  2345. "8407": [0, 0.71444, 0.15382, 0, 0.5],
  2346. "8463": [0, 0.68889, 0, 0, 0.54028],
  2347. "8465": [0, 0.69444, 0, 0, 0.72222],
  2348. "8467": [0, 0.69444, 0, 0.11111, 0.41667],
  2349. "8472": [0.19444, 0.43056, 0, 0.11111, 0.63646],
  2350. "8476": [0, 0.69444, 0, 0, 0.72222],
  2351. "8501": [0, 0.69444, 0, 0, 0.61111],
  2352. "8592": [-0.13313, 0.36687, 0, 0, 1.0],
  2353. "8593": [0.19444, 0.69444, 0, 0, 0.5],
  2354. "8594": [-0.13313, 0.36687, 0, 0, 1.0],
  2355. "8595": [0.19444, 0.69444, 0, 0, 0.5],
  2356. "8596": [-0.13313, 0.36687, 0, 0, 1.0],
  2357. "8597": [0.25, 0.75, 0, 0, 0.5],
  2358. "8598": [0.19444, 0.69444, 0, 0, 1.0],
  2359. "8599": [0.19444, 0.69444, 0, 0, 1.0],
  2360. "8600": [0.19444, 0.69444, 0, 0, 1.0],
  2361. "8601": [0.19444, 0.69444, 0, 0, 1.0],
  2362. "8614": [0.011, 0.511, 0, 0, 1.0],
  2363. "8617": [0.011, 0.511, 0, 0, 1.126],
  2364. "8618": [0.011, 0.511, 0, 0, 1.126],
  2365. "8636": [-0.13313, 0.36687, 0, 0, 1.0],
  2366. "8637": [-0.13313, 0.36687, 0, 0, 1.0],
  2367. "8640": [-0.13313, 0.36687, 0, 0, 1.0],
  2368. "8641": [-0.13313, 0.36687, 0, 0, 1.0],
  2369. "8652": [0.011, 0.671, 0, 0, 1.0],
  2370. "8656": [-0.13313, 0.36687, 0, 0, 1.0],
  2371. "8657": [0.19444, 0.69444, 0, 0, 0.61111],
  2372. "8658": [-0.13313, 0.36687, 0, 0, 1.0],
  2373. "8659": [0.19444, 0.69444, 0, 0, 0.61111],
  2374. "8660": [-0.13313, 0.36687, 0, 0, 1.0],
  2375. "8661": [0.25, 0.75, 0, 0, 0.61111],
  2376. "8704": [0, 0.69444, 0, 0, 0.55556],
  2377. "8706": [0, 0.69444, 0.05556, 0.08334, 0.5309],
  2378. "8707": [0, 0.69444, 0, 0, 0.55556],
  2379. "8709": [0.05556, 0.75, 0, 0, 0.5],
  2380. "8711": [0, 0.68333, 0, 0, 0.83334],
  2381. "8712": [0.0391, 0.5391, 0, 0, 0.66667],
  2382. "8715": [0.0391, 0.5391, 0, 0, 0.66667],
  2383. "8722": [0.08333, 0.58333, 0, 0, 0.77778],
  2384. "8723": [0.08333, 0.58333, 0, 0, 0.77778],
  2385. "8725": [0.25, 0.75, 0, 0, 0.5],
  2386. "8726": [0.25, 0.75, 0, 0, 0.5],
  2387. "8727": [-0.03472, 0.46528, 0, 0, 0.5],
  2388. "8728": [-0.05555, 0.44445, 0, 0, 0.5],
  2389. "8729": [-0.05555, 0.44445, 0, 0, 0.5],
  2390. "8730": [0.2, 0.8, 0, 0, 0.83334],
  2391. "8733": [0, 0.43056, 0, 0, 0.77778],
  2392. "8734": [0, 0.43056, 0, 0, 1.0],
  2393. "8736": [0, 0.69224, 0, 0, 0.72222],
  2394. "8739": [0.25, 0.75, 0, 0, 0.27778],
  2395. "8741": [0.25, 0.75, 0, 0, 0.5],
  2396. "8743": [0, 0.55556, 0, 0, 0.66667],
  2397. "8744": [0, 0.55556, 0, 0, 0.66667],
  2398. "8745": [0, 0.55556, 0, 0, 0.66667],
  2399. "8746": [0, 0.55556, 0, 0, 0.66667],
  2400. "8747": [0.19444, 0.69444, 0.11111, 0, 0.41667],
  2401. "8764": [-0.13313, 0.36687, 0, 0, 0.77778],
  2402. "8768": [0.19444, 0.69444, 0, 0, 0.27778],
  2403. "8771": [-0.03625, 0.46375, 0, 0, 0.77778],
  2404. "8773": [-0.022, 0.589, 0, 0, 0.778],
  2405. "8776": [-0.01688, 0.48312, 0, 0, 0.77778],
  2406. "8781": [-0.03625, 0.46375, 0, 0, 0.77778],
  2407. "8784": [-0.133, 0.673, 0, 0, 0.778],
  2408. "8801": [-0.03625, 0.46375, 0, 0, 0.77778],
  2409. "8804": [0.13597, 0.63597, 0, 0, 0.77778],
  2410. "8805": [0.13597, 0.63597, 0, 0, 0.77778],
  2411. "8810": [0.0391, 0.5391, 0, 0, 1.0],
  2412. "8811": [0.0391, 0.5391, 0, 0, 1.0],
  2413. "8826": [0.0391, 0.5391, 0, 0, 0.77778],
  2414. "8827": [0.0391, 0.5391, 0, 0, 0.77778],
  2415. "8834": [0.0391, 0.5391, 0, 0, 0.77778],
  2416. "8835": [0.0391, 0.5391, 0, 0, 0.77778],
  2417. "8838": [0.13597, 0.63597, 0, 0, 0.77778],
  2418. "8839": [0.13597, 0.63597, 0, 0, 0.77778],
  2419. "8846": [0, 0.55556, 0, 0, 0.66667],
  2420. "8849": [0.13597, 0.63597, 0, 0, 0.77778],
  2421. "8850": [0.13597, 0.63597, 0, 0, 0.77778],
  2422. "8851": [0, 0.55556, 0, 0, 0.66667],
  2423. "8852": [0, 0.55556, 0, 0, 0.66667],
  2424. "8853": [0.08333, 0.58333, 0, 0, 0.77778],
  2425. "8854": [0.08333, 0.58333, 0, 0, 0.77778],
  2426. "8855": [0.08333, 0.58333, 0, 0, 0.77778],
  2427. "8856": [0.08333, 0.58333, 0, 0, 0.77778],
  2428. "8857": [0.08333, 0.58333, 0, 0, 0.77778],
  2429. "8866": [0, 0.69444, 0, 0, 0.61111],
  2430. "8867": [0, 0.69444, 0, 0, 0.61111],
  2431. "8868": [0, 0.69444, 0, 0, 0.77778],
  2432. "8869": [0, 0.69444, 0, 0, 0.77778],
  2433. "8872": [0.249, 0.75, 0, 0, 0.867],
  2434. "8900": [-0.05555, 0.44445, 0, 0, 0.5],
  2435. "8901": [-0.05555, 0.44445, 0, 0, 0.27778],
  2436. "8902": [-0.03472, 0.46528, 0, 0, 0.5],
  2437. "8904": [0.005, 0.505, 0, 0, 0.9],
  2438. "8942": [0.03, 0.903, 0, 0, 0.278],
  2439. "8943": [-0.19, 0.313, 0, 0, 1.172],
  2440. "8945": [-0.1, 0.823, 0, 0, 1.282],
  2441. "8968": [0.25, 0.75, 0, 0, 0.44445],
  2442. "8969": [0.25, 0.75, 0, 0, 0.44445],
  2443. "8970": [0.25, 0.75, 0, 0, 0.44445],
  2444. "8971": [0.25, 0.75, 0, 0, 0.44445],
  2445. "8994": [-0.14236, 0.35764, 0, 0, 1.0],
  2446. "8995": [-0.14236, 0.35764, 0, 0, 1.0],
  2447. "9136": [0.244, 0.744, 0, 0, 0.412],
  2448. "9137": [0.244, 0.745, 0, 0, 0.412],
  2449. "9651": [0.19444, 0.69444, 0, 0, 0.88889],
  2450. "9657": [-0.03472, 0.46528, 0, 0, 0.5],
  2451. "9661": [0.19444, 0.69444, 0, 0, 0.88889],
  2452. "9667": [-0.03472, 0.46528, 0, 0, 0.5],
  2453. "9711": [0.19444, 0.69444, 0, 0, 1.0],
  2454. "9824": [0.12963, 0.69444, 0, 0, 0.77778],
  2455. "9825": [0.12963, 0.69444, 0, 0, 0.77778],
  2456. "9826": [0.12963, 0.69444, 0, 0, 0.77778],
  2457. "9827": [0.12963, 0.69444, 0, 0, 0.77778],
  2458. "9837": [0, 0.75, 0, 0, 0.38889],
  2459. "9838": [0.19444, 0.69444, 0, 0, 0.38889],
  2460. "9839": [0.19444, 0.69444, 0, 0, 0.38889],
  2461. "10216": [0.25, 0.75, 0, 0, 0.38889],
  2462. "10217": [0.25, 0.75, 0, 0, 0.38889],
  2463. "10222": [0.244, 0.744, 0, 0, 0.412],
  2464. "10223": [0.244, 0.745, 0, 0, 0.412],
  2465. "10229": [0.011, 0.511, 0, 0, 1.609],
  2466. "10230": [0.011, 0.511, 0, 0, 1.638],
  2467. "10231": [0.011, 0.511, 0, 0, 1.859],
  2468. "10232": [0.024, 0.525, 0, 0, 1.609],
  2469. "10233": [0.024, 0.525, 0, 0, 1.638],
  2470. "10234": [0.024, 0.525, 0, 0, 1.858],
  2471. "10236": [0.011, 0.511, 0, 0, 1.638],
  2472. "10815": [0, 0.68333, 0, 0, 0.75],
  2473. "10927": [0.13597, 0.63597, 0, 0, 0.77778],
  2474. "10928": [0.13597, 0.63597, 0, 0, 0.77778],
  2475. "57376": [0.19444, 0.69444, 0, 0, 0]
  2476. },
  2477. "Math-BoldItalic": {
  2478. "32": [0, 0, 0, 0, 0.25],
  2479. "48": [0, 0.44444, 0, 0, 0.575],
  2480. "49": [0, 0.44444, 0, 0, 0.575],
  2481. "50": [0, 0.44444, 0, 0, 0.575],
  2482. "51": [0.19444, 0.44444, 0, 0, 0.575],
  2483. "52": [0.19444, 0.44444, 0, 0, 0.575],
  2484. "53": [0.19444, 0.44444, 0, 0, 0.575],
  2485. "54": [0, 0.64444, 0, 0, 0.575],
  2486. "55": [0.19444, 0.44444, 0, 0, 0.575],
  2487. "56": [0, 0.64444, 0, 0, 0.575],
  2488. "57": [0.19444, 0.44444, 0, 0, 0.575],
  2489. "65": [0, 0.68611, 0, 0, 0.86944],
  2490. "66": [0, 0.68611, 0.04835, 0, 0.8664],
  2491. "67": [0, 0.68611, 0.06979, 0, 0.81694],
  2492. "68": [0, 0.68611, 0.03194, 0, 0.93812],
  2493. "69": [0, 0.68611, 0.05451, 0, 0.81007],
  2494. "70": [0, 0.68611, 0.15972, 0, 0.68889],
  2495. "71": [0, 0.68611, 0, 0, 0.88673],
  2496. "72": [0, 0.68611, 0.08229, 0, 0.98229],
  2497. "73": [0, 0.68611, 0.07778, 0, 0.51111],
  2498. "74": [0, 0.68611, 0.10069, 0, 0.63125],
  2499. "75": [0, 0.68611, 0.06979, 0, 0.97118],
  2500. "76": [0, 0.68611, 0, 0, 0.75555],
  2501. "77": [0, 0.68611, 0.11424, 0, 1.14201],
  2502. "78": [0, 0.68611, 0.11424, 0, 0.95034],
  2503. "79": [0, 0.68611, 0.03194, 0, 0.83666],
  2504. "80": [0, 0.68611, 0.15972, 0, 0.72309],
  2505. "81": [0.19444, 0.68611, 0, 0, 0.86861],
  2506. "82": [0, 0.68611, 0.00421, 0, 0.87235],
  2507. "83": [0, 0.68611, 0.05382, 0, 0.69271],
  2508. "84": [0, 0.68611, 0.15972, 0, 0.63663],
  2509. "85": [0, 0.68611, 0.11424, 0, 0.80027],
  2510. "86": [0, 0.68611, 0.25555, 0, 0.67778],
  2511. "87": [0, 0.68611, 0.15972, 0, 1.09305],
  2512. "88": [0, 0.68611, 0.07778, 0, 0.94722],
  2513. "89": [0, 0.68611, 0.25555, 0, 0.67458],
  2514. "90": [0, 0.68611, 0.06979, 0, 0.77257],
  2515. "97": [0, 0.44444, 0, 0, 0.63287],
  2516. "98": [0, 0.69444, 0, 0, 0.52083],
  2517. "99": [0, 0.44444, 0, 0, 0.51342],
  2518. "100": [0, 0.69444, 0, 0, 0.60972],
  2519. "101": [0, 0.44444, 0, 0, 0.55361],
  2520. "102": [0.19444, 0.69444, 0.11042, 0, 0.56806],
  2521. "103": [0.19444, 0.44444, 0.03704, 0, 0.5449],
  2522. "104": [0, 0.69444, 0, 0, 0.66759],
  2523. "105": [0, 0.69326, 0, 0, 0.4048],
  2524. "106": [0.19444, 0.69326, 0.0622, 0, 0.47083],
  2525. "107": [0, 0.69444, 0.01852, 0, 0.6037],
  2526. "108": [0, 0.69444, 0.0088, 0, 0.34815],
  2527. "109": [0, 0.44444, 0, 0, 1.0324],
  2528. "110": [0, 0.44444, 0, 0, 0.71296],
  2529. "111": [0, 0.44444, 0, 0, 0.58472],
  2530. "112": [0.19444, 0.44444, 0, 0, 0.60092],
  2531. "113": [0.19444, 0.44444, 0.03704, 0, 0.54213],
  2532. "114": [0, 0.44444, 0.03194, 0, 0.5287],
  2533. "115": [0, 0.44444, 0, 0, 0.53125],
  2534. "116": [0, 0.63492, 0, 0, 0.41528],
  2535. "117": [0, 0.44444, 0, 0, 0.68102],
  2536. "118": [0, 0.44444, 0.03704, 0, 0.56666],
  2537. "119": [0, 0.44444, 0.02778, 0, 0.83148],
  2538. "120": [0, 0.44444, 0, 0, 0.65903],
  2539. "121": [0.19444, 0.44444, 0.03704, 0, 0.59028],
  2540. "122": [0, 0.44444, 0.04213, 0, 0.55509],
  2541. "160": [0, 0, 0, 0, 0.25],
  2542. "915": [0, 0.68611, 0.15972, 0, 0.65694],
  2543. "916": [0, 0.68611, 0, 0, 0.95833],
  2544. "920": [0, 0.68611, 0.03194, 0, 0.86722],
  2545. "923": [0, 0.68611, 0, 0, 0.80555],
  2546. "926": [0, 0.68611, 0.07458, 0, 0.84125],
  2547. "928": [0, 0.68611, 0.08229, 0, 0.98229],
  2548. "931": [0, 0.68611, 0.05451, 0, 0.88507],
  2549. "933": [0, 0.68611, 0.15972, 0, 0.67083],
  2550. "934": [0, 0.68611, 0, 0, 0.76666],
  2551. "936": [0, 0.68611, 0.11653, 0, 0.71402],
  2552. "937": [0, 0.68611, 0.04835, 0, 0.8789],
  2553. "945": [0, 0.44444, 0, 0, 0.76064],
  2554. "946": [0.19444, 0.69444, 0.03403, 0, 0.65972],
  2555. "947": [0.19444, 0.44444, 0.06389, 0, 0.59003],
  2556. "948": [0, 0.69444, 0.03819, 0, 0.52222],
  2557. "949": [0, 0.44444, 0, 0, 0.52882],
  2558. "950": [0.19444, 0.69444, 0.06215, 0, 0.50833],
  2559. "951": [0.19444, 0.44444, 0.03704, 0, 0.6],
  2560. "952": [0, 0.69444, 0.03194, 0, 0.5618],
  2561. "953": [0, 0.44444, 0, 0, 0.41204],
  2562. "954": [0, 0.44444, 0, 0, 0.66759],
  2563. "955": [0, 0.69444, 0, 0, 0.67083],
  2564. "956": [0.19444, 0.44444, 0, 0, 0.70787],
  2565. "957": [0, 0.44444, 0.06898, 0, 0.57685],
  2566. "958": [0.19444, 0.69444, 0.03021, 0, 0.50833],
  2567. "959": [0, 0.44444, 0, 0, 0.58472],
  2568. "960": [0, 0.44444, 0.03704, 0, 0.68241],
  2569. "961": [0.19444, 0.44444, 0, 0, 0.6118],
  2570. "962": [0.09722, 0.44444, 0.07917, 0, 0.42361],
  2571. "963": [0, 0.44444, 0.03704, 0, 0.68588],
  2572. "964": [0, 0.44444, 0.13472, 0, 0.52083],
  2573. "965": [0, 0.44444, 0.03704, 0, 0.63055],
  2574. "966": [0.19444, 0.44444, 0, 0, 0.74722],
  2575. "967": [0.19444, 0.44444, 0, 0, 0.71805],
  2576. "968": [0.19444, 0.69444, 0.03704, 0, 0.75833],
  2577. "969": [0, 0.44444, 0.03704, 0, 0.71782],
  2578. "977": [0, 0.69444, 0, 0, 0.69155],
  2579. "981": [0.19444, 0.69444, 0, 0, 0.7125],
  2580. "982": [0, 0.44444, 0.03194, 0, 0.975],
  2581. "1009": [0.19444, 0.44444, 0, 0, 0.6118],
  2582. "1013": [0, 0.44444, 0, 0, 0.48333],
  2583. "57649": [0, 0.44444, 0, 0, 0.39352],
  2584. "57911": [0.19444, 0.44444, 0, 0, 0.43889]
  2585. },
  2586. "Math-Italic": {
  2587. "32": [0, 0, 0, 0, 0.25],
  2588. "48": [0, 0.43056, 0, 0, 0.5],
  2589. "49": [0, 0.43056, 0, 0, 0.5],
  2590. "50": [0, 0.43056, 0, 0, 0.5],
  2591. "51": [0.19444, 0.43056, 0, 0, 0.5],
  2592. "52": [0.19444, 0.43056, 0, 0, 0.5],
  2593. "53": [0.19444, 0.43056, 0, 0, 0.5],
  2594. "54": [0, 0.64444, 0, 0, 0.5],
  2595. "55": [0.19444, 0.43056, 0, 0, 0.5],
  2596. "56": [0, 0.64444, 0, 0, 0.5],
  2597. "57": [0.19444, 0.43056, 0, 0, 0.5],
  2598. "65": [0, 0.68333, 0, 0.13889, 0.75],
  2599. "66": [0, 0.68333, 0.05017, 0.08334, 0.75851],
  2600. "67": [0, 0.68333, 0.07153, 0.08334, 0.71472],
  2601. "68": [0, 0.68333, 0.02778, 0.05556, 0.82792],
  2602. "69": [0, 0.68333, 0.05764, 0.08334, 0.7382],
  2603. "70": [0, 0.68333, 0.13889, 0.08334, 0.64306],
  2604. "71": [0, 0.68333, 0, 0.08334, 0.78625],
  2605. "72": [0, 0.68333, 0.08125, 0.05556, 0.83125],
  2606. "73": [0, 0.68333, 0.07847, 0.11111, 0.43958],
  2607. "74": [0, 0.68333, 0.09618, 0.16667, 0.55451],
  2608. "75": [0, 0.68333, 0.07153, 0.05556, 0.84931],
  2609. "76": [0, 0.68333, 0, 0.02778, 0.68056],
  2610. "77": [0, 0.68333, 0.10903, 0.08334, 0.97014],
  2611. "78": [0, 0.68333, 0.10903, 0.08334, 0.80347],
  2612. "79": [0, 0.68333, 0.02778, 0.08334, 0.76278],
  2613. "80": [0, 0.68333, 0.13889, 0.08334, 0.64201],
  2614. "81": [0.19444, 0.68333, 0, 0.08334, 0.79056],
  2615. "82": [0, 0.68333, 0.00773, 0.08334, 0.75929],
  2616. "83": [0, 0.68333, 0.05764, 0.08334, 0.6132],
  2617. "84": [0, 0.68333, 0.13889, 0.08334, 0.58438],
  2618. "85": [0, 0.68333, 0.10903, 0.02778, 0.68278],
  2619. "86": [0, 0.68333, 0.22222, 0, 0.58333],
  2620. "87": [0, 0.68333, 0.13889, 0, 0.94445],
  2621. "88": [0, 0.68333, 0.07847, 0.08334, 0.82847],
  2622. "89": [0, 0.68333, 0.22222, 0, 0.58056],
  2623. "90": [0, 0.68333, 0.07153, 0.08334, 0.68264],
  2624. "97": [0, 0.43056, 0, 0, 0.52859],
  2625. "98": [0, 0.69444, 0, 0, 0.42917],
  2626. "99": [0, 0.43056, 0, 0.05556, 0.43276],
  2627. "100": [0, 0.69444, 0, 0.16667, 0.52049],
  2628. "101": [0, 0.43056, 0, 0.05556, 0.46563],
  2629. "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959],
  2630. "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697],
  2631. "104": [0, 0.69444, 0, 0, 0.57616],
  2632. "105": [0, 0.65952, 0, 0, 0.34451],
  2633. "106": [0.19444, 0.65952, 0.05724, 0, 0.41181],
  2634. "107": [0, 0.69444, 0.03148, 0, 0.5206],
  2635. "108": [0, 0.69444, 0.01968, 0.08334, 0.29838],
  2636. "109": [0, 0.43056, 0, 0, 0.87801],
  2637. "110": [0, 0.43056, 0, 0, 0.60023],
  2638. "111": [0, 0.43056, 0, 0.05556, 0.48472],
  2639. "112": [0.19444, 0.43056, 0, 0.08334, 0.50313],
  2640. "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641],
  2641. "114": [0, 0.43056, 0.02778, 0.05556, 0.45116],
  2642. "115": [0, 0.43056, 0, 0.05556, 0.46875],
  2643. "116": [0, 0.61508, 0, 0.08334, 0.36111],
  2644. "117": [0, 0.43056, 0, 0.02778, 0.57246],
  2645. "118": [0, 0.43056, 0.03588, 0.02778, 0.48472],
  2646. "119": [0, 0.43056, 0.02691, 0.08334, 0.71592],
  2647. "120": [0, 0.43056, 0, 0.02778, 0.57153],
  2648. "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028],
  2649. "122": [0, 0.43056, 0.04398, 0.05556, 0.46505],
  2650. "160": [0, 0, 0, 0, 0.25],
  2651. "915": [0, 0.68333, 0.13889, 0.08334, 0.61528],
  2652. "916": [0, 0.68333, 0, 0.16667, 0.83334],
  2653. "920": [0, 0.68333, 0.02778, 0.08334, 0.76278],
  2654. "923": [0, 0.68333, 0, 0.16667, 0.69445],
  2655. "926": [0, 0.68333, 0.07569, 0.08334, 0.74236],
  2656. "928": [0, 0.68333, 0.08125, 0.05556, 0.83125],
  2657. "931": [0, 0.68333, 0.05764, 0.08334, 0.77986],
  2658. "933": [0, 0.68333, 0.13889, 0.05556, 0.58333],
  2659. "934": [0, 0.68333, 0, 0.08334, 0.66667],
  2660. "936": [0, 0.68333, 0.11, 0.05556, 0.61222],
  2661. "937": [0, 0.68333, 0.05017, 0.08334, 0.7724],
  2662. "945": [0, 0.43056, 0.0037, 0.02778, 0.6397],
  2663. "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563],
  2664. "947": [0.19444, 0.43056, 0.05556, 0, 0.51773],
  2665. "948": [0, 0.69444, 0.03785, 0.05556, 0.44444],
  2666. "949": [0, 0.43056, 0, 0.08334, 0.46632],
  2667. "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375],
  2668. "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653],
  2669. "952": [0, 0.69444, 0.02778, 0.08334, 0.46944],
  2670. "953": [0, 0.43056, 0, 0.05556, 0.35394],
  2671. "954": [0, 0.43056, 0, 0, 0.57616],
  2672. "955": [0, 0.69444, 0, 0, 0.58334],
  2673. "956": [0.19444, 0.43056, 0, 0.02778, 0.60255],
  2674. "957": [0, 0.43056, 0.06366, 0.02778, 0.49398],
  2675. "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375],
  2676. "959": [0, 0.43056, 0, 0.05556, 0.48472],
  2677. "960": [0, 0.43056, 0.03588, 0, 0.57003],
  2678. "961": [0.19444, 0.43056, 0, 0.08334, 0.51702],
  2679. "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285],
  2680. "963": [0, 0.43056, 0.03588, 0, 0.57141],
  2681. "964": [0, 0.43056, 0.1132, 0.02778, 0.43715],
  2682. "965": [0, 0.43056, 0.03588, 0.02778, 0.54028],
  2683. "966": [0.19444, 0.43056, 0, 0.08334, 0.65417],
  2684. "967": [0.19444, 0.43056, 0, 0.05556, 0.62569],
  2685. "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139],
  2686. "969": [0, 0.43056, 0.03588, 0, 0.62245],
  2687. "977": [0, 0.69444, 0, 0.08334, 0.59144],
  2688. "981": [0.19444, 0.69444, 0, 0.08334, 0.59583],
  2689. "982": [0, 0.43056, 0.02778, 0, 0.82813],
  2690. "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702],
  2691. "1013": [0, 0.43056, 0, 0.05556, 0.4059],
  2692. "57649": [0, 0.43056, 0, 0.02778, 0.32246],
  2693. "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403]
  2694. },
  2695. "SansSerif-Bold": {
  2696. "32": [0, 0, 0, 0, 0.25],
  2697. "33": [0, 0.69444, 0, 0, 0.36667],
  2698. "34": [0, 0.69444, 0, 0, 0.55834],
  2699. "35": [0.19444, 0.69444, 0, 0, 0.91667],
  2700. "36": [0.05556, 0.75, 0, 0, 0.55],
  2701. "37": [0.05556, 0.75, 0, 0, 1.02912],
  2702. "38": [0, 0.69444, 0, 0, 0.83056],
  2703. "39": [0, 0.69444, 0, 0, 0.30556],
  2704. "40": [0.25, 0.75, 0, 0, 0.42778],
  2705. "41": [0.25, 0.75, 0, 0, 0.42778],
  2706. "42": [0, 0.75, 0, 0, 0.55],
  2707. "43": [0.11667, 0.61667, 0, 0, 0.85556],
  2708. "44": [0.10556, 0.13056, 0, 0, 0.30556],
  2709. "45": [0, 0.45833, 0, 0, 0.36667],
  2710. "46": [0, 0.13056, 0, 0, 0.30556],
  2711. "47": [0.25, 0.75, 0, 0, 0.55],
  2712. "48": [0, 0.69444, 0, 0, 0.55],
  2713. "49": [0, 0.69444, 0, 0, 0.55],
  2714. "50": [0, 0.69444, 0, 0, 0.55],
  2715. "51": [0, 0.69444, 0, 0, 0.55],
  2716. "52": [0, 0.69444, 0, 0, 0.55],
  2717. "53": [0, 0.69444, 0, 0, 0.55],
  2718. "54": [0, 0.69444, 0, 0, 0.55],
  2719. "55": [0, 0.69444, 0, 0, 0.55],
  2720. "56": [0, 0.69444, 0, 0, 0.55],
  2721. "57": [0, 0.69444, 0, 0, 0.55],
  2722. "58": [0, 0.45833, 0, 0, 0.30556],
  2723. "59": [0.10556, 0.45833, 0, 0, 0.30556],
  2724. "61": [-0.09375, 0.40625, 0, 0, 0.85556],
  2725. "63": [0, 0.69444, 0, 0, 0.51945],
  2726. "64": [0, 0.69444, 0, 0, 0.73334],
  2727. "65": [0, 0.69444, 0, 0, 0.73334],
  2728. "66": [0, 0.69444, 0, 0, 0.73334],
  2729. "67": [0, 0.69444, 0, 0, 0.70278],
  2730. "68": [0, 0.69444, 0, 0, 0.79445],
  2731. "69": [0, 0.69444, 0, 0, 0.64167],
  2732. "70": [0, 0.69444, 0, 0, 0.61111],
  2733. "71": [0, 0.69444, 0, 0, 0.73334],
  2734. "72": [0, 0.69444, 0, 0, 0.79445],
  2735. "73": [0, 0.69444, 0, 0, 0.33056],
  2736. "74": [0, 0.69444, 0, 0, 0.51945],
  2737. "75": [0, 0.69444, 0, 0, 0.76389],
  2738. "76": [0, 0.69444, 0, 0, 0.58056],
  2739. "77": [0, 0.69444, 0, 0, 0.97778],
  2740. "78": [0, 0.69444, 0, 0, 0.79445],
  2741. "79": [0, 0.69444, 0, 0, 0.79445],
  2742. "80": [0, 0.69444, 0, 0, 0.70278],
  2743. "81": [0.10556, 0.69444, 0, 0, 0.79445],
  2744. "82": [0, 0.69444, 0, 0, 0.70278],
  2745. "83": [0, 0.69444, 0, 0, 0.61111],
  2746. "84": [0, 0.69444, 0, 0, 0.73334],
  2747. "85": [0, 0.69444, 0, 0, 0.76389],
  2748. "86": [0, 0.69444, 0.01528, 0, 0.73334],
  2749. "87": [0, 0.69444, 0.01528, 0, 1.03889],
  2750. "88": [0, 0.69444, 0, 0, 0.73334],
  2751. "89": [0, 0.69444, 0.0275, 0, 0.73334],
  2752. "90": [0, 0.69444, 0, 0, 0.67223],
  2753. "91": [0.25, 0.75, 0, 0, 0.34306],
  2754. "93": [0.25, 0.75, 0, 0, 0.34306],
  2755. "94": [0, 0.69444, 0, 0, 0.55],
  2756. "95": [0.35, 0.10833, 0.03056, 0, 0.55],
  2757. "97": [0, 0.45833, 0, 0, 0.525],
  2758. "98": [0, 0.69444, 0, 0, 0.56111],
  2759. "99": [0, 0.45833, 0, 0, 0.48889],
  2760. "100": [0, 0.69444, 0, 0, 0.56111],
  2761. "101": [0, 0.45833, 0, 0, 0.51111],
  2762. "102": [0, 0.69444, 0.07639, 0, 0.33611],
  2763. "103": [0.19444, 0.45833, 0.01528, 0, 0.55],
  2764. "104": [0, 0.69444, 0, 0, 0.56111],
  2765. "105": [0, 0.69444, 0, 0, 0.25556],
  2766. "106": [0.19444, 0.69444, 0, 0, 0.28611],
  2767. "107": [0, 0.69444, 0, 0, 0.53056],
  2768. "108": [0, 0.69444, 0, 0, 0.25556],
  2769. "109": [0, 0.45833, 0, 0, 0.86667],
  2770. "110": [0, 0.45833, 0, 0, 0.56111],
  2771. "111": [0, 0.45833, 0, 0, 0.55],
  2772. "112": [0.19444, 0.45833, 0, 0, 0.56111],
  2773. "113": [0.19444, 0.45833, 0, 0, 0.56111],
  2774. "114": [0, 0.45833, 0.01528, 0, 0.37222],
  2775. "115": [0, 0.45833, 0, 0, 0.42167],
  2776. "116": [0, 0.58929, 0, 0, 0.40417],
  2777. "117": [0, 0.45833, 0, 0, 0.56111],
  2778. "118": [0, 0.45833, 0.01528, 0, 0.5],
  2779. "119": [0, 0.45833, 0.01528, 0, 0.74445],
  2780. "120": [0, 0.45833, 0, 0, 0.5],
  2781. "121": [0.19444, 0.45833, 0.01528, 0, 0.5],
  2782. "122": [0, 0.45833, 0, 0, 0.47639],
  2783. "126": [0.35, 0.34444, 0, 0, 0.55],
  2784. "160": [0, 0, 0, 0, 0.25],
  2785. "168": [0, 0.69444, 0, 0, 0.55],
  2786. "176": [0, 0.69444, 0, 0, 0.73334],
  2787. "180": [0, 0.69444, 0, 0, 0.55],
  2788. "184": [0.17014, 0, 0, 0, 0.48889],
  2789. "305": [0, 0.45833, 0, 0, 0.25556],
  2790. "567": [0.19444, 0.45833, 0, 0, 0.28611],
  2791. "710": [0, 0.69444, 0, 0, 0.55],
  2792. "711": [0, 0.63542, 0, 0, 0.55],
  2793. "713": [0, 0.63778, 0, 0, 0.55],
  2794. "728": [0, 0.69444, 0, 0, 0.55],
  2795. "729": [0, 0.69444, 0, 0, 0.30556],
  2796. "730": [0, 0.69444, 0, 0, 0.73334],
  2797. "732": [0, 0.69444, 0, 0, 0.55],
  2798. "733": [0, 0.69444, 0, 0, 0.55],
  2799. "915": [0, 0.69444, 0, 0, 0.58056],
  2800. "916": [0, 0.69444, 0, 0, 0.91667],
  2801. "920": [0, 0.69444, 0, 0, 0.85556],
  2802. "923": [0, 0.69444, 0, 0, 0.67223],
  2803. "926": [0, 0.69444, 0, 0, 0.73334],
  2804. "928": [0, 0.69444, 0, 0, 0.79445],
  2805. "931": [0, 0.69444, 0, 0, 0.79445],
  2806. "933": [0, 0.69444, 0, 0, 0.85556],
  2807. "934": [0, 0.69444, 0, 0, 0.79445],
  2808. "936": [0, 0.69444, 0, 0, 0.85556],
  2809. "937": [0, 0.69444, 0, 0, 0.79445],
  2810. "8211": [0, 0.45833, 0.03056, 0, 0.55],
  2811. "8212": [0, 0.45833, 0.03056, 0, 1.10001],
  2812. "8216": [0, 0.69444, 0, 0, 0.30556],
  2813. "8217": [0, 0.69444, 0, 0, 0.30556],
  2814. "8220": [0, 0.69444, 0, 0, 0.55834],
  2815. "8221": [0, 0.69444, 0, 0, 0.55834]
  2816. },
  2817. "SansSerif-Italic": {
  2818. "32": [0, 0, 0, 0, 0.25],
  2819. "33": [0, 0.69444, 0.05733, 0, 0.31945],
  2820. "34": [0, 0.69444, 0.00316, 0, 0.5],
  2821. "35": [0.19444, 0.69444, 0.05087, 0, 0.83334],
  2822. "36": [0.05556, 0.75, 0.11156, 0, 0.5],
  2823. "37": [0.05556, 0.75, 0.03126, 0, 0.83334],
  2824. "38": [0, 0.69444, 0.03058, 0, 0.75834],
  2825. "39": [0, 0.69444, 0.07816, 0, 0.27778],
  2826. "40": [0.25, 0.75, 0.13164, 0, 0.38889],
  2827. "41": [0.25, 0.75, 0.02536, 0, 0.38889],
  2828. "42": [0, 0.75, 0.11775, 0, 0.5],
  2829. "43": [0.08333, 0.58333, 0.02536, 0, 0.77778],
  2830. "44": [0.125, 0.08333, 0, 0, 0.27778],
  2831. "45": [0, 0.44444, 0.01946, 0, 0.33333],
  2832. "46": [0, 0.08333, 0, 0, 0.27778],
  2833. "47": [0.25, 0.75, 0.13164, 0, 0.5],
  2834. "48": [0, 0.65556, 0.11156, 0, 0.5],
  2835. "49": [0, 0.65556, 0.11156, 0, 0.5],
  2836. "50": [0, 0.65556, 0.11156, 0, 0.5],
  2837. "51": [0, 0.65556, 0.11156, 0, 0.5],
  2838. "52": [0, 0.65556, 0.11156, 0, 0.5],
  2839. "53": [0, 0.65556, 0.11156, 0, 0.5],
  2840. "54": [0, 0.65556, 0.11156, 0, 0.5],
  2841. "55": [0, 0.65556, 0.11156, 0, 0.5],
  2842. "56": [0, 0.65556, 0.11156, 0, 0.5],
  2843. "57": [0, 0.65556, 0.11156, 0, 0.5],
  2844. "58": [0, 0.44444, 0.02502, 0, 0.27778],
  2845. "59": [0.125, 0.44444, 0.02502, 0, 0.27778],
  2846. "61": [-0.13, 0.37, 0.05087, 0, 0.77778],
  2847. "63": [0, 0.69444, 0.11809, 0, 0.47222],
  2848. "64": [0, 0.69444, 0.07555, 0, 0.66667],
  2849. "65": [0, 0.69444, 0, 0, 0.66667],
  2850. "66": [0, 0.69444, 0.08293, 0, 0.66667],
  2851. "67": [0, 0.69444, 0.11983, 0, 0.63889],
  2852. "68": [0, 0.69444, 0.07555, 0, 0.72223],
  2853. "69": [0, 0.69444, 0.11983, 0, 0.59722],
  2854. "70": [0, 0.69444, 0.13372, 0, 0.56945],
  2855. "71": [0, 0.69444, 0.11983, 0, 0.66667],
  2856. "72": [0, 0.69444, 0.08094, 0, 0.70834],
  2857. "73": [0, 0.69444, 0.13372, 0, 0.27778],
  2858. "74": [0, 0.69444, 0.08094, 0, 0.47222],
  2859. "75": [0, 0.69444, 0.11983, 0, 0.69445],
  2860. "76": [0, 0.69444, 0, 0, 0.54167],
  2861. "77": [0, 0.69444, 0.08094, 0, 0.875],
  2862. "78": [0, 0.69444, 0.08094, 0, 0.70834],
  2863. "79": [0, 0.69444, 0.07555, 0, 0.73611],
  2864. "80": [0, 0.69444, 0.08293, 0, 0.63889],
  2865. "81": [0.125, 0.69444, 0.07555, 0, 0.73611],
  2866. "82": [0, 0.69444, 0.08293, 0, 0.64584],
  2867. "83": [0, 0.69444, 0.09205, 0, 0.55556],
  2868. "84": [0, 0.69444, 0.13372, 0, 0.68056],
  2869. "85": [0, 0.69444, 0.08094, 0, 0.6875],
  2870. "86": [0, 0.69444, 0.1615, 0, 0.66667],
  2871. "87": [0, 0.69444, 0.1615, 0, 0.94445],
  2872. "88": [0, 0.69444, 0.13372, 0, 0.66667],
  2873. "89": [0, 0.69444, 0.17261, 0, 0.66667],
  2874. "90": [0, 0.69444, 0.11983, 0, 0.61111],
  2875. "91": [0.25, 0.75, 0.15942, 0, 0.28889],
  2876. "93": [0.25, 0.75, 0.08719, 0, 0.28889],
  2877. "94": [0, 0.69444, 0.0799, 0, 0.5],
  2878. "95": [0.35, 0.09444, 0.08616, 0, 0.5],
  2879. "97": [0, 0.44444, 0.00981, 0, 0.48056],
  2880. "98": [0, 0.69444, 0.03057, 0, 0.51667],
  2881. "99": [0, 0.44444, 0.08336, 0, 0.44445],
  2882. "100": [0, 0.69444, 0.09483, 0, 0.51667],
  2883. "101": [0, 0.44444, 0.06778, 0, 0.44445],
  2884. "102": [0, 0.69444, 0.21705, 0, 0.30556],
  2885. "103": [0.19444, 0.44444, 0.10836, 0, 0.5],
  2886. "104": [0, 0.69444, 0.01778, 0, 0.51667],
  2887. "105": [0, 0.67937, 0.09718, 0, 0.23889],
  2888. "106": [0.19444, 0.67937, 0.09162, 0, 0.26667],
  2889. "107": [0, 0.69444, 0.08336, 0, 0.48889],
  2890. "108": [0, 0.69444, 0.09483, 0, 0.23889],
  2891. "109": [0, 0.44444, 0.01778, 0, 0.79445],
  2892. "110": [0, 0.44444, 0.01778, 0, 0.51667],
  2893. "111": [0, 0.44444, 0.06613, 0, 0.5],
  2894. "112": [0.19444, 0.44444, 0.0389, 0, 0.51667],
  2895. "113": [0.19444, 0.44444, 0.04169, 0, 0.51667],
  2896. "114": [0, 0.44444, 0.10836, 0, 0.34167],
  2897. "115": [0, 0.44444, 0.0778, 0, 0.38333],
  2898. "116": [0, 0.57143, 0.07225, 0, 0.36111],
  2899. "117": [0, 0.44444, 0.04169, 0, 0.51667],
  2900. "118": [0, 0.44444, 0.10836, 0, 0.46111],
  2901. "119": [0, 0.44444, 0.10836, 0, 0.68334],
  2902. "120": [0, 0.44444, 0.09169, 0, 0.46111],
  2903. "121": [0.19444, 0.44444, 0.10836, 0, 0.46111],
  2904. "122": [0, 0.44444, 0.08752, 0, 0.43472],
  2905. "126": [0.35, 0.32659, 0.08826, 0, 0.5],
  2906. "160": [0, 0, 0, 0, 0.25],
  2907. "168": [0, 0.67937, 0.06385, 0, 0.5],
  2908. "176": [0, 0.69444, 0, 0, 0.73752],
  2909. "184": [0.17014, 0, 0, 0, 0.44445],
  2910. "305": [0, 0.44444, 0.04169, 0, 0.23889],
  2911. "567": [0.19444, 0.44444, 0.04169, 0, 0.26667],
  2912. "710": [0, 0.69444, 0.0799, 0, 0.5],
  2913. "711": [0, 0.63194, 0.08432, 0, 0.5],
  2914. "713": [0, 0.60889, 0.08776, 0, 0.5],
  2915. "714": [0, 0.69444, 0.09205, 0, 0.5],
  2916. "715": [0, 0.69444, 0, 0, 0.5],
  2917. "728": [0, 0.69444, 0.09483, 0, 0.5],
  2918. "729": [0, 0.67937, 0.07774, 0, 0.27778],
  2919. "730": [0, 0.69444, 0, 0, 0.73752],
  2920. "732": [0, 0.67659, 0.08826, 0, 0.5],
  2921. "733": [0, 0.69444, 0.09205, 0, 0.5],
  2922. "915": [0, 0.69444, 0.13372, 0, 0.54167],
  2923. "916": [0, 0.69444, 0, 0, 0.83334],
  2924. "920": [0, 0.69444, 0.07555, 0, 0.77778],
  2925. "923": [0, 0.69444, 0, 0, 0.61111],
  2926. "926": [0, 0.69444, 0.12816, 0, 0.66667],
  2927. "928": [0, 0.69444, 0.08094, 0, 0.70834],
  2928. "931": [0, 0.69444, 0.11983, 0, 0.72222],
  2929. "933": [0, 0.69444, 0.09031, 0, 0.77778],
  2930. "934": [0, 0.69444, 0.04603, 0, 0.72222],
  2931. "936": [0, 0.69444, 0.09031, 0, 0.77778],
  2932. "937": [0, 0.69444, 0.08293, 0, 0.72222],
  2933. "8211": [0, 0.44444, 0.08616, 0, 0.5],
  2934. "8212": [0, 0.44444, 0.08616, 0, 1.0],
  2935. "8216": [0, 0.69444, 0.07816, 0, 0.27778],
  2936. "8217": [0, 0.69444, 0.07816, 0, 0.27778],
  2937. "8220": [0, 0.69444, 0.14205, 0, 0.5],
  2938. "8221": [0, 0.69444, 0.00316, 0, 0.5]
  2939. },
  2940. "SansSerif-Regular": {
  2941. "32": [0, 0, 0, 0, 0.25],
  2942. "33": [0, 0.69444, 0, 0, 0.31945],
  2943. "34": [0, 0.69444, 0, 0, 0.5],
  2944. "35": [0.19444, 0.69444, 0, 0, 0.83334],
  2945. "36": [0.05556, 0.75, 0, 0, 0.5],
  2946. "37": [0.05556, 0.75, 0, 0, 0.83334],
  2947. "38": [0, 0.69444, 0, 0, 0.75834],
  2948. "39": [0, 0.69444, 0, 0, 0.27778],
  2949. "40": [0.25, 0.75, 0, 0, 0.38889],
  2950. "41": [0.25, 0.75, 0, 0, 0.38889],
  2951. "42": [0, 0.75, 0, 0, 0.5],
  2952. "43": [0.08333, 0.58333, 0, 0, 0.77778],
  2953. "44": [0.125, 0.08333, 0, 0, 0.27778],
  2954. "45": [0, 0.44444, 0, 0, 0.33333],
  2955. "46": [0, 0.08333, 0, 0, 0.27778],
  2956. "47": [0.25, 0.75, 0, 0, 0.5],
  2957. "48": [0, 0.65556, 0, 0, 0.5],
  2958. "49": [0, 0.65556, 0, 0, 0.5],
  2959. "50": [0, 0.65556, 0, 0, 0.5],
  2960. "51": [0, 0.65556, 0, 0, 0.5],
  2961. "52": [0, 0.65556, 0, 0, 0.5],
  2962. "53": [0, 0.65556, 0, 0, 0.5],
  2963. "54": [0, 0.65556, 0, 0, 0.5],
  2964. "55": [0, 0.65556, 0, 0, 0.5],
  2965. "56": [0, 0.65556, 0, 0, 0.5],
  2966. "57": [0, 0.65556, 0, 0, 0.5],
  2967. "58": [0, 0.44444, 0, 0, 0.27778],
  2968. "59": [0.125, 0.44444, 0, 0, 0.27778],
  2969. "61": [-0.13, 0.37, 0, 0, 0.77778],
  2970. "63": [0, 0.69444, 0, 0, 0.47222],
  2971. "64": [0, 0.69444, 0, 0, 0.66667],
  2972. "65": [0, 0.69444, 0, 0, 0.66667],
  2973. "66": [0, 0.69444, 0, 0, 0.66667],
  2974. "67": [0, 0.69444, 0, 0, 0.63889],
  2975. "68": [0, 0.69444, 0, 0, 0.72223],
  2976. "69": [0, 0.69444, 0, 0, 0.59722],
  2977. "70": [0, 0.69444, 0, 0, 0.56945],
  2978. "71": [0, 0.69444, 0, 0, 0.66667],
  2979. "72": [0, 0.69444, 0, 0, 0.70834],
  2980. "73": [0, 0.69444, 0, 0, 0.27778],
  2981. "74": [0, 0.69444, 0, 0, 0.47222],
  2982. "75": [0, 0.69444, 0, 0, 0.69445],
  2983. "76": [0, 0.69444, 0, 0, 0.54167],
  2984. "77": [0, 0.69444, 0, 0, 0.875],
  2985. "78": [0, 0.69444, 0, 0, 0.70834],
  2986. "79": [0, 0.69444, 0, 0, 0.73611],
  2987. "80": [0, 0.69444, 0, 0, 0.63889],
  2988. "81": [0.125, 0.69444, 0, 0, 0.73611],
  2989. "82": [0, 0.69444, 0, 0, 0.64584],
  2990. "83": [0, 0.69444, 0, 0, 0.55556],
  2991. "84": [0, 0.69444, 0, 0, 0.68056],
  2992. "85": [0, 0.69444, 0, 0, 0.6875],
  2993. "86": [0, 0.69444, 0.01389, 0, 0.66667],
  2994. "87": [0, 0.69444, 0.01389, 0, 0.94445],
  2995. "88": [0, 0.69444, 0, 0, 0.66667],
  2996. "89": [0, 0.69444, 0.025, 0, 0.66667],
  2997. "90": [0, 0.69444, 0, 0, 0.61111],
  2998. "91": [0.25, 0.75, 0, 0, 0.28889],
  2999. "93": [0.25, 0.75, 0, 0, 0.28889],
  3000. "94": [0, 0.69444, 0, 0, 0.5],
  3001. "95": [0.35, 0.09444, 0.02778, 0, 0.5],
  3002. "97": [0, 0.44444, 0, 0, 0.48056],
  3003. "98": [0, 0.69444, 0, 0, 0.51667],
  3004. "99": [0, 0.44444, 0, 0, 0.44445],
  3005. "100": [0, 0.69444, 0, 0, 0.51667],
  3006. "101": [0, 0.44444, 0, 0, 0.44445],
  3007. "102": [0, 0.69444, 0.06944, 0, 0.30556],
  3008. "103": [0.19444, 0.44444, 0.01389, 0, 0.5],
  3009. "104": [0, 0.69444, 0, 0, 0.51667],
  3010. "105": [0, 0.67937, 0, 0, 0.23889],
  3011. "106": [0.19444, 0.67937, 0, 0, 0.26667],
  3012. "107": [0, 0.69444, 0, 0, 0.48889],
  3013. "108": [0, 0.69444, 0, 0, 0.23889],
  3014. "109": [0, 0.44444, 0, 0, 0.79445],
  3015. "110": [0, 0.44444, 0, 0, 0.51667],
  3016. "111": [0, 0.44444, 0, 0, 0.5],
  3017. "112": [0.19444, 0.44444, 0, 0, 0.51667],
  3018. "113": [0.19444, 0.44444, 0, 0, 0.51667],
  3019. "114": [0, 0.44444, 0.01389, 0, 0.34167],
  3020. "115": [0, 0.44444, 0, 0, 0.38333],
  3021. "116": [0, 0.57143, 0, 0, 0.36111],
  3022. "117": [0, 0.44444, 0, 0, 0.51667],
  3023. "118": [0, 0.44444, 0.01389, 0, 0.46111],
  3024. "119": [0, 0.44444, 0.01389, 0, 0.68334],
  3025. "120": [0, 0.44444, 0, 0, 0.46111],
  3026. "121": [0.19444, 0.44444, 0.01389, 0, 0.46111],
  3027. "122": [0, 0.44444, 0, 0, 0.43472],
  3028. "126": [0.35, 0.32659, 0, 0, 0.5],
  3029. "160": [0, 0, 0, 0, 0.25],
  3030. "168": [0, 0.67937, 0, 0, 0.5],
  3031. "176": [0, 0.69444, 0, 0, 0.66667],
  3032. "184": [0.17014, 0, 0, 0, 0.44445],
  3033. "305": [0, 0.44444, 0, 0, 0.23889],
  3034. "567": [0.19444, 0.44444, 0, 0, 0.26667],
  3035. "710": [0, 0.69444, 0, 0, 0.5],
  3036. "711": [0, 0.63194, 0, 0, 0.5],
  3037. "713": [0, 0.60889, 0, 0, 0.5],
  3038. "714": [0, 0.69444, 0, 0, 0.5],
  3039. "715": [0, 0.69444, 0, 0, 0.5],
  3040. "728": [0, 0.69444, 0, 0, 0.5],
  3041. "729": [0, 0.67937, 0, 0, 0.27778],
  3042. "730": [0, 0.69444, 0, 0, 0.66667],
  3043. "732": [0, 0.67659, 0, 0, 0.5],
  3044. "733": [0, 0.69444, 0, 0, 0.5],
  3045. "915": [0, 0.69444, 0, 0, 0.54167],
  3046. "916": [0, 0.69444, 0, 0, 0.83334],
  3047. "920": [0, 0.69444, 0, 0, 0.77778],
  3048. "923": [0, 0.69444, 0, 0, 0.61111],
  3049. "926": [0, 0.69444, 0, 0, 0.66667],
  3050. "928": [0, 0.69444, 0, 0, 0.70834],
  3051. "931": [0, 0.69444, 0, 0, 0.72222],
  3052. "933": [0, 0.69444, 0, 0, 0.77778],
  3053. "934": [0, 0.69444, 0, 0, 0.72222],
  3054. "936": [0, 0.69444, 0, 0, 0.77778],
  3055. "937": [0, 0.69444, 0, 0, 0.72222],
  3056. "8211": [0, 0.44444, 0.02778, 0, 0.5],
  3057. "8212": [0, 0.44444, 0.02778, 0, 1.0],
  3058. "8216": [0, 0.69444, 0, 0, 0.27778],
  3059. "8217": [0, 0.69444, 0, 0, 0.27778],
  3060. "8220": [0, 0.69444, 0, 0, 0.5],
  3061. "8221": [0, 0.69444, 0, 0, 0.5]
  3062. },
  3063. "Script-Regular": {
  3064. "32": [0, 0, 0, 0, 0.25],
  3065. "65": [0, 0.7, 0.22925, 0, 0.80253],
  3066. "66": [0, 0.7, 0.04087, 0, 0.90757],
  3067. "67": [0, 0.7, 0.1689, 0, 0.66619],
  3068. "68": [0, 0.7, 0.09371, 0, 0.77443],
  3069. "69": [0, 0.7, 0.18583, 0, 0.56162],
  3070. "70": [0, 0.7, 0.13634, 0, 0.89544],
  3071. "71": [0, 0.7, 0.17322, 0, 0.60961],
  3072. "72": [0, 0.7, 0.29694, 0, 0.96919],
  3073. "73": [0, 0.7, 0.19189, 0, 0.80907],
  3074. "74": [0.27778, 0.7, 0.19189, 0, 1.05159],
  3075. "75": [0, 0.7, 0.31259, 0, 0.91364],
  3076. "76": [0, 0.7, 0.19189, 0, 0.87373],
  3077. "77": [0, 0.7, 0.15981, 0, 1.08031],
  3078. "78": [0, 0.7, 0.3525, 0, 0.9015],
  3079. "79": [0, 0.7, 0.08078, 0, 0.73787],
  3080. "80": [0, 0.7, 0.08078, 0, 1.01262],
  3081. "81": [0, 0.7, 0.03305, 0, 0.88282],
  3082. "82": [0, 0.7, 0.06259, 0, 0.85],
  3083. "83": [0, 0.7, 0.19189, 0, 0.86767],
  3084. "84": [0, 0.7, 0.29087, 0, 0.74697],
  3085. "85": [0, 0.7, 0.25815, 0, 0.79996],
  3086. "86": [0, 0.7, 0.27523, 0, 0.62204],
  3087. "87": [0, 0.7, 0.27523, 0, 0.80532],
  3088. "88": [0, 0.7, 0.26006, 0, 0.94445],
  3089. "89": [0, 0.7, 0.2939, 0, 0.70961],
  3090. "90": [0, 0.7, 0.24037, 0, 0.8212],
  3091. "160": [0, 0, 0, 0, 0.25]
  3092. },
  3093. "Size1-Regular": {
  3094. "32": [0, 0, 0, 0, 0.25],
  3095. "40": [0.35001, 0.85, 0, 0, 0.45834],
  3096. "41": [0.35001, 0.85, 0, 0, 0.45834],
  3097. "47": [0.35001, 0.85, 0, 0, 0.57778],
  3098. "91": [0.35001, 0.85, 0, 0, 0.41667],
  3099. "92": [0.35001, 0.85, 0, 0, 0.57778],
  3100. "93": [0.35001, 0.85, 0, 0, 0.41667],
  3101. "123": [0.35001, 0.85, 0, 0, 0.58334],
  3102. "125": [0.35001, 0.85, 0, 0, 0.58334],
  3103. "160": [0, 0, 0, 0, 0.25],
  3104. "710": [0, 0.72222, 0, 0, 0.55556],
  3105. "732": [0, 0.72222, 0, 0, 0.55556],
  3106. "770": [0, 0.72222, 0, 0, 0.55556],
  3107. "771": [0, 0.72222, 0, 0, 0.55556],
  3108. "8214": [-0.00099, 0.601, 0, 0, 0.77778],
  3109. "8593": [1e-05, 0.6, 0, 0, 0.66667],
  3110. "8595": [1e-05, 0.6, 0, 0, 0.66667],
  3111. "8657": [1e-05, 0.6, 0, 0, 0.77778],
  3112. "8659": [1e-05, 0.6, 0, 0, 0.77778],
  3113. "8719": [0.25001, 0.75, 0, 0, 0.94445],
  3114. "8720": [0.25001, 0.75, 0, 0, 0.94445],
  3115. "8721": [0.25001, 0.75, 0, 0, 1.05556],
  3116. "8730": [0.35001, 0.85, 0, 0, 1.0],
  3117. "8739": [-0.00599, 0.606, 0, 0, 0.33333],
  3118. "8741": [-0.00599, 0.606, 0, 0, 0.55556],
  3119. "8747": [0.30612, 0.805, 0.19445, 0, 0.47222],
  3120. "8748": [0.306, 0.805, 0.19445, 0, 0.47222],
  3121. "8749": [0.306, 0.805, 0.19445, 0, 0.47222],
  3122. "8750": [0.30612, 0.805, 0.19445, 0, 0.47222],
  3123. "8896": [0.25001, 0.75, 0, 0, 0.83334],
  3124. "8897": [0.25001, 0.75, 0, 0, 0.83334],
  3125. "8898": [0.25001, 0.75, 0, 0, 0.83334],
  3126. "8899": [0.25001, 0.75, 0, 0, 0.83334],
  3127. "8968": [0.35001, 0.85, 0, 0, 0.47222],
  3128. "8969": [0.35001, 0.85, 0, 0, 0.47222],
  3129. "8970": [0.35001, 0.85, 0, 0, 0.47222],
  3130. "8971": [0.35001, 0.85, 0, 0, 0.47222],
  3131. "9168": [-0.00099, 0.601, 0, 0, 0.66667],
  3132. "10216": [0.35001, 0.85, 0, 0, 0.47222],
  3133. "10217": [0.35001, 0.85, 0, 0, 0.47222],
  3134. "10752": [0.25001, 0.75, 0, 0, 1.11111],
  3135. "10753": [0.25001, 0.75, 0, 0, 1.11111],
  3136. "10754": [0.25001, 0.75, 0, 0, 1.11111],
  3137. "10756": [0.25001, 0.75, 0, 0, 0.83334],
  3138. "10758": [0.25001, 0.75, 0, 0, 0.83334]
  3139. },
  3140. "Size2-Regular": {
  3141. "32": [0, 0, 0, 0, 0.25],
  3142. "40": [0.65002, 1.15, 0, 0, 0.59722],
  3143. "41": [0.65002, 1.15, 0, 0, 0.59722],
  3144. "47": [0.65002, 1.15, 0, 0, 0.81111],
  3145. "91": [0.65002, 1.15, 0, 0, 0.47222],
  3146. "92": [0.65002, 1.15, 0, 0, 0.81111],
  3147. "93": [0.65002, 1.15, 0, 0, 0.47222],
  3148. "123": [0.65002, 1.15, 0, 0, 0.66667],
  3149. "125": [0.65002, 1.15, 0, 0, 0.66667],
  3150. "160": [0, 0, 0, 0, 0.25],
  3151. "710": [0, 0.75, 0, 0, 1.0],
  3152. "732": [0, 0.75, 0, 0, 1.0],
  3153. "770": [0, 0.75, 0, 0, 1.0],
  3154. "771": [0, 0.75, 0, 0, 1.0],
  3155. "8719": [0.55001, 1.05, 0, 0, 1.27778],
  3156. "8720": [0.55001, 1.05, 0, 0, 1.27778],
  3157. "8721": [0.55001, 1.05, 0, 0, 1.44445],
  3158. "8730": [0.65002, 1.15, 0, 0, 1.0],
  3159. "8747": [0.86225, 1.36, 0.44445, 0, 0.55556],
  3160. "8748": [0.862, 1.36, 0.44445, 0, 0.55556],
  3161. "8749": [0.862, 1.36, 0.44445, 0, 0.55556],
  3162. "8750": [0.86225, 1.36, 0.44445, 0, 0.55556],
  3163. "8896": [0.55001, 1.05, 0, 0, 1.11111],
  3164. "8897": [0.55001, 1.05, 0, 0, 1.11111],
  3165. "8898": [0.55001, 1.05, 0, 0, 1.11111],
  3166. "8899": [0.55001, 1.05, 0, 0, 1.11111],
  3167. "8968": [0.65002, 1.15, 0, 0, 0.52778],
  3168. "8969": [0.65002, 1.15, 0, 0, 0.52778],
  3169. "8970": [0.65002, 1.15, 0, 0, 0.52778],
  3170. "8971": [0.65002, 1.15, 0, 0, 0.52778],
  3171. "10216": [0.65002, 1.15, 0, 0, 0.61111],
  3172. "10217": [0.65002, 1.15, 0, 0, 0.61111],
  3173. "10752": [0.55001, 1.05, 0, 0, 1.51112],
  3174. "10753": [0.55001, 1.05, 0, 0, 1.51112],
  3175. "10754": [0.55001, 1.05, 0, 0, 1.51112],
  3176. "10756": [0.55001, 1.05, 0, 0, 1.11111],
  3177. "10758": [0.55001, 1.05, 0, 0, 1.11111]
  3178. },
  3179. "Size3-Regular": {
  3180. "32": [0, 0, 0, 0, 0.25],
  3181. "40": [0.95003, 1.45, 0, 0, 0.73611],
  3182. "41": [0.95003, 1.45, 0, 0, 0.73611],
  3183. "47": [0.95003, 1.45, 0, 0, 1.04445],
  3184. "91": [0.95003, 1.45, 0, 0, 0.52778],
  3185. "92": [0.95003, 1.45, 0, 0, 1.04445],
  3186. "93": [0.95003, 1.45, 0, 0, 0.52778],
  3187. "123": [0.95003, 1.45, 0, 0, 0.75],
  3188. "125": [0.95003, 1.45, 0, 0, 0.75],
  3189. "160": [0, 0, 0, 0, 0.25],
  3190. "710": [0, 0.75, 0, 0, 1.44445],
  3191. "732": [0, 0.75, 0, 0, 1.44445],
  3192. "770": [0, 0.75, 0, 0, 1.44445],
  3193. "771": [0, 0.75, 0, 0, 1.44445],
  3194. "8730": [0.95003, 1.45, 0, 0, 1.0],
  3195. "8968": [0.95003, 1.45, 0, 0, 0.58334],
  3196. "8969": [0.95003, 1.45, 0, 0, 0.58334],
  3197. "8970": [0.95003, 1.45, 0, 0, 0.58334],
  3198. "8971": [0.95003, 1.45, 0, 0, 0.58334],
  3199. "10216": [0.95003, 1.45, 0, 0, 0.75],
  3200. "10217": [0.95003, 1.45, 0, 0, 0.75]
  3201. },
  3202. "Size4-Regular": {
  3203. "32": [0, 0, 0, 0, 0.25],
  3204. "40": [1.25003, 1.75, 0, 0, 0.79167],
  3205. "41": [1.25003, 1.75, 0, 0, 0.79167],
  3206. "47": [1.25003, 1.75, 0, 0, 1.27778],
  3207. "91": [1.25003, 1.75, 0, 0, 0.58334],
  3208. "92": [1.25003, 1.75, 0, 0, 1.27778],
  3209. "93": [1.25003, 1.75, 0, 0, 0.58334],
  3210. "123": [1.25003, 1.75, 0, 0, 0.80556],
  3211. "125": [1.25003, 1.75, 0, 0, 0.80556],
  3212. "160": [0, 0, 0, 0, 0.25],
  3213. "710": [0, 0.825, 0, 0, 1.8889],
  3214. "732": [0, 0.825, 0, 0, 1.8889],
  3215. "770": [0, 0.825, 0, 0, 1.8889],
  3216. "771": [0, 0.825, 0, 0, 1.8889],
  3217. "8730": [1.25003, 1.75, 0, 0, 1.0],
  3218. "8968": [1.25003, 1.75, 0, 0, 0.63889],
  3219. "8969": [1.25003, 1.75, 0, 0, 0.63889],
  3220. "8970": [1.25003, 1.75, 0, 0, 0.63889],
  3221. "8971": [1.25003, 1.75, 0, 0, 0.63889],
  3222. "9115": [0.64502, 1.155, 0, 0, 0.875],
  3223. "9116": [1e-05, 0.6, 0, 0, 0.875],
  3224. "9117": [0.64502, 1.155, 0, 0, 0.875],
  3225. "9118": [0.64502, 1.155, 0, 0, 0.875],
  3226. "9119": [1e-05, 0.6, 0, 0, 0.875],
  3227. "9120": [0.64502, 1.155, 0, 0, 0.875],
  3228. "9121": [0.64502, 1.155, 0, 0, 0.66667],
  3229. "9122": [-0.00099, 0.601, 0, 0, 0.66667],
  3230. "9123": [0.64502, 1.155, 0, 0, 0.66667],
  3231. "9124": [0.64502, 1.155, 0, 0, 0.66667],
  3232. "9125": [-0.00099, 0.601, 0, 0, 0.66667],
  3233. "9126": [0.64502, 1.155, 0, 0, 0.66667],
  3234. "9127": [1e-05, 0.9, 0, 0, 0.88889],
  3235. "9128": [0.65002, 1.15, 0, 0, 0.88889],
  3236. "9129": [0.90001, 0, 0, 0, 0.88889],
  3237. "9130": [0, 0.3, 0, 0, 0.88889],
  3238. "9131": [1e-05, 0.9, 0, 0, 0.88889],
  3239. "9132": [0.65002, 1.15, 0, 0, 0.88889],
  3240. "9133": [0.90001, 0, 0, 0, 0.88889],
  3241. "9143": [0.88502, 0.915, 0, 0, 1.05556],
  3242. "10216": [1.25003, 1.75, 0, 0, 0.80556],
  3243. "10217": [1.25003, 1.75, 0, 0, 0.80556],
  3244. "57344": [-0.00499, 0.605, 0, 0, 1.05556],
  3245. "57345": [-0.00499, 0.605, 0, 0, 1.05556],
  3246. "57680": [0, 0.12, 0, 0, 0.45],
  3247. "57681": [0, 0.12, 0, 0, 0.45],
  3248. "57682": [0, 0.12, 0, 0, 0.45],
  3249. "57683": [0, 0.12, 0, 0, 0.45]
  3250. },
  3251. "Typewriter-Regular": {
  3252. "32": [0, 0, 0, 0, 0.525],
  3253. "33": [0, 0.61111, 0, 0, 0.525],
  3254. "34": [0, 0.61111, 0, 0, 0.525],
  3255. "35": [0, 0.61111, 0, 0, 0.525],
  3256. "36": [0.08333, 0.69444, 0, 0, 0.525],
  3257. "37": [0.08333, 0.69444, 0, 0, 0.525],
  3258. "38": [0, 0.61111, 0, 0, 0.525],
  3259. "39": [0, 0.61111, 0, 0, 0.525],
  3260. "40": [0.08333, 0.69444, 0, 0, 0.525],
  3261. "41": [0.08333, 0.69444, 0, 0, 0.525],
  3262. "42": [0, 0.52083, 0, 0, 0.525],
  3263. "43": [-0.08056, 0.53055, 0, 0, 0.525],
  3264. "44": [0.13889, 0.125, 0, 0, 0.525],
  3265. "45": [-0.08056, 0.53055, 0, 0, 0.525],
  3266. "46": [0, 0.125, 0, 0, 0.525],
  3267. "47": [0.08333, 0.69444, 0, 0, 0.525],
  3268. "48": [0, 0.61111, 0, 0, 0.525],
  3269. "49": [0, 0.61111, 0, 0, 0.525],
  3270. "50": [0, 0.61111, 0, 0, 0.525],
  3271. "51": [0, 0.61111, 0, 0, 0.525],
  3272. "52": [0, 0.61111, 0, 0, 0.525],
  3273. "53": [0, 0.61111, 0, 0, 0.525],
  3274. "54": [0, 0.61111, 0, 0, 0.525],
  3275. "55": [0, 0.61111, 0, 0, 0.525],
  3276. "56": [0, 0.61111, 0, 0, 0.525],
  3277. "57": [0, 0.61111, 0, 0, 0.525],
  3278. "58": [0, 0.43056, 0, 0, 0.525],
  3279. "59": [0.13889, 0.43056, 0, 0, 0.525],
  3280. "60": [-0.05556, 0.55556, 0, 0, 0.525],
  3281. "61": [-0.19549, 0.41562, 0, 0, 0.525],
  3282. "62": [-0.05556, 0.55556, 0, 0, 0.525],
  3283. "63": [0, 0.61111, 0, 0, 0.525],
  3284. "64": [0, 0.61111, 0, 0, 0.525],
  3285. "65": [0, 0.61111, 0, 0, 0.525],
  3286. "66": [0, 0.61111, 0, 0, 0.525],
  3287. "67": [0, 0.61111, 0, 0, 0.525],
  3288. "68": [0, 0.61111, 0, 0, 0.525],
  3289. "69": [0, 0.61111, 0, 0, 0.525],
  3290. "70": [0, 0.61111, 0, 0, 0.525],
  3291. "71": [0, 0.61111, 0, 0, 0.525],
  3292. "72": [0, 0.61111, 0, 0, 0.525],
  3293. "73": [0, 0.61111, 0, 0, 0.525],
  3294. "74": [0, 0.61111, 0, 0, 0.525],
  3295. "75": [0, 0.61111, 0, 0, 0.525],
  3296. "76": [0, 0.61111, 0, 0, 0.525],
  3297. "77": [0, 0.61111, 0, 0, 0.525],
  3298. "78": [0, 0.61111, 0, 0, 0.525],
  3299. "79": [0, 0.61111, 0, 0, 0.525],
  3300. "80": [0, 0.61111, 0, 0, 0.525],
  3301. "81": [0.13889, 0.61111, 0, 0, 0.525],
  3302. "82": [0, 0.61111, 0, 0, 0.525],
  3303. "83": [0, 0.61111, 0, 0, 0.525],
  3304. "84": [0, 0.61111, 0, 0, 0.525],
  3305. "85": [0, 0.61111, 0, 0, 0.525],
  3306. "86": [0, 0.61111, 0, 0, 0.525],
  3307. "87": [0, 0.61111, 0, 0, 0.525],
  3308. "88": [0, 0.61111, 0, 0, 0.525],
  3309. "89": [0, 0.61111, 0, 0, 0.525],
  3310. "90": [0, 0.61111, 0, 0, 0.525],
  3311. "91": [0.08333, 0.69444, 0, 0, 0.525],
  3312. "92": [0.08333, 0.69444, 0, 0, 0.525],
  3313. "93": [0.08333, 0.69444, 0, 0, 0.525],
  3314. "94": [0, 0.61111, 0, 0, 0.525],
  3315. "95": [0.09514, 0, 0, 0, 0.525],
  3316. "96": [0, 0.61111, 0, 0, 0.525],
  3317. "97": [0, 0.43056, 0, 0, 0.525],
  3318. "98": [0, 0.61111, 0, 0, 0.525],
  3319. "99": [0, 0.43056, 0, 0, 0.525],
  3320. "100": [0, 0.61111, 0, 0, 0.525],
  3321. "101": [0, 0.43056, 0, 0, 0.525],
  3322. "102": [0, 0.61111, 0, 0, 0.525],
  3323. "103": [0.22222, 0.43056, 0, 0, 0.525],
  3324. "104": [0, 0.61111, 0, 0, 0.525],
  3325. "105": [0, 0.61111, 0, 0, 0.525],
  3326. "106": [0.22222, 0.61111, 0, 0, 0.525],
  3327. "107": [0, 0.61111, 0, 0, 0.525],
  3328. "108": [0, 0.61111, 0, 0, 0.525],
  3329. "109": [0, 0.43056, 0, 0, 0.525],
  3330. "110": [0, 0.43056, 0, 0, 0.525],
  3331. "111": [0, 0.43056, 0, 0, 0.525],
  3332. "112": [0.22222, 0.43056, 0, 0, 0.525],
  3333. "113": [0.22222, 0.43056, 0, 0, 0.525],
  3334. "114": [0, 0.43056, 0, 0, 0.525],
  3335. "115": [0, 0.43056, 0, 0, 0.525],
  3336. "116": [0, 0.55358, 0, 0, 0.525],
  3337. "117": [0, 0.43056, 0, 0, 0.525],
  3338. "118": [0, 0.43056, 0, 0, 0.525],
  3339. "119": [0, 0.43056, 0, 0, 0.525],
  3340. "120": [0, 0.43056, 0, 0, 0.525],
  3341. "121": [0.22222, 0.43056, 0, 0, 0.525],
  3342. "122": [0, 0.43056, 0, 0, 0.525],
  3343. "123": [0.08333, 0.69444, 0, 0, 0.525],
  3344. "124": [0.08333, 0.69444, 0, 0, 0.525],
  3345. "125": [0.08333, 0.69444, 0, 0, 0.525],
  3346. "126": [0, 0.61111, 0, 0, 0.525],
  3347. "127": [0, 0.61111, 0, 0, 0.525],
  3348. "160": [0, 0, 0, 0, 0.525],
  3349. "176": [0, 0.61111, 0, 0, 0.525],
  3350. "184": [0.19445, 0, 0, 0, 0.525],
  3351. "305": [0, 0.43056, 0, 0, 0.525],
  3352. "567": [0.22222, 0.43056, 0, 0, 0.525],
  3353. "711": [0, 0.56597, 0, 0, 0.525],
  3354. "713": [0, 0.56555, 0, 0, 0.525],
  3355. "714": [0, 0.61111, 0, 0, 0.525],
  3356. "715": [0, 0.61111, 0, 0, 0.525],
  3357. "728": [0, 0.61111, 0, 0, 0.525],
  3358. "730": [0, 0.61111, 0, 0, 0.525],
  3359. "770": [0, 0.61111, 0, 0, 0.525],
  3360. "771": [0, 0.61111, 0, 0, 0.525],
  3361. "776": [0, 0.61111, 0, 0, 0.525],
  3362. "915": [0, 0.61111, 0, 0, 0.525],
  3363. "916": [0, 0.61111, 0, 0, 0.525],
  3364. "920": [0, 0.61111, 0, 0, 0.525],
  3365. "923": [0, 0.61111, 0, 0, 0.525],
  3366. "926": [0, 0.61111, 0, 0, 0.525],
  3367. "928": [0, 0.61111, 0, 0, 0.525],
  3368. "931": [0, 0.61111, 0, 0, 0.525],
  3369. "933": [0, 0.61111, 0, 0, 0.525],
  3370. "934": [0, 0.61111, 0, 0, 0.525],
  3371. "936": [0, 0.61111, 0, 0, 0.525],
  3372. "937": [0, 0.61111, 0, 0, 0.525],
  3373. "8216": [0, 0.61111, 0, 0, 0.525],
  3374. "8217": [0, 0.61111, 0, 0, 0.525],
  3375. "8242": [0, 0.61111, 0, 0, 0.525],
  3376. "9251": [0.11111, 0.21944, 0, 0, 0.525]
  3377. }
  3378. };
  3379. /**
  3380. * This file contains metrics regarding fonts and individual symbols. The sigma
  3381. * and xi variables, as well as the metricMap map contain data extracted from
  3382. * TeX, TeX font metrics, and the TTF files. These data are then exposed via the
  3383. * `metrics` variable and the getCharacterMetrics function.
  3384. */
  3385. // In TeX, there are actually three sets of dimensions, one for each of
  3386. // textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
  3387. // 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
  3388. // provided in the arrays below, in that order.
  3389. //
  3390. // The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively.
  3391. // This was determined by running the following script:
  3392. //
  3393. // latex -interaction=nonstopmode \
  3394. // '\documentclass{article}\usepackage{amsmath}\begin{document}' \
  3395. // '$a$ \expandafter\show\the\textfont2' \
  3396. // '\expandafter\show\the\scriptfont2' \
  3397. // '\expandafter\show\the\scriptscriptfont2' \
  3398. // '\stop'
  3399. //
  3400. // The metrics themselves were retrieved using the following commands:
  3401. //
  3402. // tftopl cmsy10
  3403. // tftopl cmsy7
  3404. // tftopl cmsy5
  3405. //
  3406. // The output of each of these commands is quite lengthy. The only part we
  3407. // care about is the FONTDIMEN section. Each value is measured in EMs.
  3408. var sigmasAndXis = {
  3409. slant: [0.250, 0.250, 0.250],
  3410. // sigma1
  3411. space: [0.000, 0.000, 0.000],
  3412. // sigma2
  3413. stretch: [0.000, 0.000, 0.000],
  3414. // sigma3
  3415. shrink: [0.000, 0.000, 0.000],
  3416. // sigma4
  3417. xHeight: [0.431, 0.431, 0.431],
  3418. // sigma5
  3419. quad: [1.000, 1.171, 1.472],
  3420. // sigma6
  3421. extraSpace: [0.000, 0.000, 0.000],
  3422. // sigma7
  3423. num1: [0.677, 0.732, 0.925],
  3424. // sigma8
  3425. num2: [0.394, 0.384, 0.387],
  3426. // sigma9
  3427. num3: [0.444, 0.471, 0.504],
  3428. // sigma10
  3429. denom1: [0.686, 0.752, 1.025],
  3430. // sigma11
  3431. denom2: [0.345, 0.344, 0.532],
  3432. // sigma12
  3433. sup1: [0.413, 0.503, 0.504],
  3434. // sigma13
  3435. sup2: [0.363, 0.431, 0.404],
  3436. // sigma14
  3437. sup3: [0.289, 0.286, 0.294],
  3438. // sigma15
  3439. sub1: [0.150, 0.143, 0.200],
  3440. // sigma16
  3441. sub2: [0.247, 0.286, 0.400],
  3442. // sigma17
  3443. supDrop: [0.386, 0.353, 0.494],
  3444. // sigma18
  3445. subDrop: [0.050, 0.071, 0.100],
  3446. // sigma19
  3447. delim1: [2.390, 1.700, 1.980],
  3448. // sigma20
  3449. delim2: [1.010, 1.157, 1.420],
  3450. // sigma21
  3451. axisHeight: [0.250, 0.250, 0.250],
  3452. // sigma22
  3453. // These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
  3454. // they correspond to the font parameters of the extension fonts (family 3).
  3455. // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
  3456. // match cmex7, we'd use cmex7.tfm values for script and scriptscript
  3457. // values.
  3458. defaultRuleThickness: [0.04, 0.049, 0.049],
  3459. // xi8; cmex7: 0.049
  3460. bigOpSpacing1: [0.111, 0.111, 0.111],
  3461. // xi9
  3462. bigOpSpacing2: [0.166, 0.166, 0.166],
  3463. // xi10
  3464. bigOpSpacing3: [0.2, 0.2, 0.2],
  3465. // xi11
  3466. bigOpSpacing4: [0.6, 0.611, 0.611],
  3467. // xi12; cmex7: 0.611
  3468. bigOpSpacing5: [0.1, 0.143, 0.143],
  3469. // xi13; cmex7: 0.143
  3470. // The \sqrt rule width is taken from the height of the surd character.
  3471. // Since we use the same font at all sizes, this thickness doesn't scale.
  3472. sqrtRuleThickness: [0.04, 0.04, 0.04],
  3473. // This value determines how large a pt is, for metrics which are defined
  3474. // in terms of pts.
  3475. // This value is also used in katex.scss; if you change it make sure the
  3476. // values match.
  3477. ptPerEm: [10.0, 10.0, 10.0],
  3478. // The space between adjacent `|` columns in an array definition. From
  3479. // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
  3480. doubleRuleSep: [0.2, 0.2, 0.2],
  3481. // The width of separator lines in {array} environments. From
  3482. // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
  3483. arrayRuleWidth: [0.04, 0.04, 0.04],
  3484. // Two values from LaTeX source2e:
  3485. fboxsep: [0.3, 0.3, 0.3],
  3486. // 3 pt / ptPerEm
  3487. fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm
  3488. };
  3489. // These are very rough approximations. We default to Times New Roman which
  3490. // should have Latin-1 and Cyrillic characters, but may not depending on the
  3491. // operating system. The metrics do not account for extra height from the
  3492. // accents. In the case of Cyrillic characters which have both ascenders and
  3493. // descenders we prefer approximations with ascenders, primarily to prevent
  3494. // the fraction bar or root line from intersecting the glyph.
  3495. // TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
  3496. var extraCharacterMap = {
  3497. // Latin-1
  3498. 'Å': 'A',
  3499. 'Ð': 'D',
  3500. 'Þ': 'o',
  3501. 'å': 'a',
  3502. 'ð': 'd',
  3503. 'þ': 'o',
  3504. // Cyrillic
  3505. 'А': 'A',
  3506. 'Б': 'B',
  3507. 'В': 'B',
  3508. 'Г': 'F',
  3509. 'Д': 'A',
  3510. 'Е': 'E',
  3511. 'Ж': 'K',
  3512. 'З': '3',
  3513. 'И': 'N',
  3514. 'Й': 'N',
  3515. 'К': 'K',
  3516. 'Л': 'N',
  3517. 'М': 'M',
  3518. 'Н': 'H',
  3519. 'О': 'O',
  3520. 'П': 'N',
  3521. 'Р': 'P',
  3522. 'С': 'C',
  3523. 'Т': 'T',
  3524. 'У': 'y',
  3525. 'Ф': 'O',
  3526. 'Х': 'X',
  3527. 'Ц': 'U',
  3528. 'Ч': 'h',
  3529. 'Ш': 'W',
  3530. 'Щ': 'W',
  3531. 'Ъ': 'B',
  3532. 'Ы': 'X',
  3533. 'Ь': 'B',
  3534. 'Э': '3',
  3535. 'Ю': 'X',
  3536. 'Я': 'R',
  3537. 'а': 'a',
  3538. 'б': 'b',
  3539. 'в': 'a',
  3540. 'г': 'r',
  3541. 'д': 'y',
  3542. 'е': 'e',
  3543. 'ж': 'm',
  3544. 'з': 'e',
  3545. 'и': 'n',
  3546. 'й': 'n',
  3547. 'к': 'n',
  3548. 'л': 'n',
  3549. 'м': 'm',
  3550. 'н': 'n',
  3551. 'о': 'o',
  3552. 'п': 'n',
  3553. 'р': 'p',
  3554. 'с': 'c',
  3555. 'т': 'o',
  3556. 'у': 'y',
  3557. 'ф': 'b',
  3558. 'х': 'x',
  3559. 'ц': 'n',
  3560. 'ч': 'n',
  3561. 'ш': 'w',
  3562. 'щ': 'w',
  3563. 'ъ': 'a',
  3564. 'ы': 'm',
  3565. 'ь': 'a',
  3566. 'э': 'e',
  3567. 'ю': 'm',
  3568. 'я': 'r'
  3569. };
  3570. /**
  3571. * This function adds new font metrics to default metricMap
  3572. * It can also override existing metrics
  3573. */
  3574. function setFontMetrics(fontName, metrics) {
  3575. fontMetricsData[fontName] = metrics;
  3576. }
  3577. /**
  3578. * This function is a convenience function for looking up information in the
  3579. * metricMap table. It takes a character as a string, and a font.
  3580. *
  3581. * Note: the `width` property may be undefined if fontMetricsData.js wasn't
  3582. * built using `Make extended_metrics`.
  3583. */
  3584. function getCharacterMetrics(character, font, mode) {
  3585. if (!fontMetricsData[font]) {
  3586. throw new Error("Font metrics not found for font: " + font + ".");
  3587. }
  3588. var ch = character.charCodeAt(0);
  3589. var metrics = fontMetricsData[font][ch];
  3590. if (!metrics && character[0] in extraCharacterMap) {
  3591. ch = extraCharacterMap[character[0]].charCodeAt(0);
  3592. metrics = fontMetricsData[font][ch];
  3593. }
  3594. if (!metrics && mode === 'text') {
  3595. // We don't typically have font metrics for Asian scripts.
  3596. // But since we support them in text mode, we need to return
  3597. // some sort of metrics.
  3598. // So if the character is in a script we support but we
  3599. // don't have metrics for it, just use the metrics for
  3600. // the Latin capital letter M. This is close enough because
  3601. // we (currently) only care about the height of the glyph
  3602. // not its width.
  3603. if (supportedCodepoint(ch)) {
  3604. metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M'
  3605. }
  3606. }
  3607. if (metrics) {
  3608. return {
  3609. depth: metrics[0],
  3610. height: metrics[1],
  3611. italic: metrics[2],
  3612. skew: metrics[3],
  3613. width: metrics[4]
  3614. };
  3615. }
  3616. }
  3617. var fontMetricsBySizeIndex = {};
  3618. /**
  3619. * Get the font metrics for a given size.
  3620. */
  3621. function getGlobalMetrics(size) {
  3622. var sizeIndex;
  3623. if (size >= 5) {
  3624. sizeIndex = 0;
  3625. } else if (size >= 3) {
  3626. sizeIndex = 1;
  3627. } else {
  3628. sizeIndex = 2;
  3629. }
  3630. if (!fontMetricsBySizeIndex[sizeIndex]) {
  3631. var metrics = fontMetricsBySizeIndex[sizeIndex] = {
  3632. cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18
  3633. };
  3634. for (var key in sigmasAndXis) {
  3635. if (sigmasAndXis.hasOwnProperty(key)) {
  3636. metrics[key] = sigmasAndXis[key][sizeIndex];
  3637. }
  3638. }
  3639. }
  3640. return fontMetricsBySizeIndex[sizeIndex];
  3641. }
  3642. /**
  3643. * This file holds a list of all no-argument functions and single-character
  3644. * symbols (like 'a' or ';').
  3645. *
  3646. * For each of the symbols, there are three properties they can have:
  3647. * - font (required): the font to be used for this symbol. Either "main" (the
  3648. normal font), or "ams" (the ams fonts).
  3649. * - group (required): the ParseNode group type the symbol should have (i.e.
  3650. "textord", "mathord", etc).
  3651. See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types
  3652. * - replace: the character that this symbol or function should be
  3653. * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi
  3654. * character in the main font).
  3655. *
  3656. * The outermost map in the table indicates what mode the symbols should be
  3657. * accepted in (e.g. "math" or "text").
  3658. */
  3659. // Some of these have a "-token" suffix since these are also used as `ParseNode`
  3660. // types for raw text tokens, and we want to avoid conflicts with higher-level
  3661. // `ParseNode` types. These `ParseNode`s are constructed within `Parser` by
  3662. // looking up the `symbols` map.
  3663. var ATOMS = {
  3664. "bin": 1,
  3665. "close": 1,
  3666. "inner": 1,
  3667. "open": 1,
  3668. "punct": 1,
  3669. "rel": 1
  3670. };
  3671. var NON_ATOMS = {
  3672. "accent-token": 1,
  3673. "mathord": 1,
  3674. "op-token": 1,
  3675. "spacing": 1,
  3676. "textord": 1
  3677. };
  3678. var symbols = {
  3679. "math": {},
  3680. "text": {}
  3681. };
  3682. /** `acceptUnicodeChar = true` is only applicable if `replace` is set. */
  3683. function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) {
  3684. symbols[mode][name] = {
  3685. font,
  3686. group,
  3687. replace
  3688. };
  3689. if (acceptUnicodeChar && replace) {
  3690. symbols[mode][replace] = symbols[mode][name];
  3691. }
  3692. }
  3693. // Some abbreviations for commonly used strings.
  3694. // This helps minify the code, and also spotting typos using jshint.
  3695. // modes:
  3696. var math = "math";
  3697. var text = "text";
  3698. // fonts:
  3699. var main = "main";
  3700. var ams = "ams";
  3701. // groups:
  3702. var accent = "accent-token";
  3703. var bin = "bin";
  3704. var close = "close";
  3705. var inner = "inner";
  3706. var mathord = "mathord";
  3707. var op = "op-token";
  3708. var open = "open";
  3709. var punct = "punct";
  3710. var rel = "rel";
  3711. var spacing = "spacing";
  3712. var textord = "textord";
  3713. // Now comes the symbol table
  3714. // Relation Symbols
  3715. defineSymbol(math, main, rel, "\u2261", "\\equiv", true);
  3716. defineSymbol(math, main, rel, "\u227a", "\\prec", true);
  3717. defineSymbol(math, main, rel, "\u227b", "\\succ", true);
  3718. defineSymbol(math, main, rel, "\u223c", "\\sim", true);
  3719. defineSymbol(math, main, rel, "\u22a5", "\\perp");
  3720. defineSymbol(math, main, rel, "\u2aaf", "\\preceq", true);
  3721. defineSymbol(math, main, rel, "\u2ab0", "\\succeq", true);
  3722. defineSymbol(math, main, rel, "\u2243", "\\simeq", true);
  3723. defineSymbol(math, main, rel, "\u2223", "\\mid", true);
  3724. defineSymbol(math, main, rel, "\u226a", "\\ll", true);
  3725. defineSymbol(math, main, rel, "\u226b", "\\gg", true);
  3726. defineSymbol(math, main, rel, "\u224d", "\\asymp", true);
  3727. defineSymbol(math, main, rel, "\u2225", "\\parallel");
  3728. defineSymbol(math, main, rel, "\u22c8", "\\bowtie", true);
  3729. defineSymbol(math, main, rel, "\u2323", "\\smile", true);
  3730. defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true);
  3731. defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true);
  3732. defineSymbol(math, main, rel, "\u2250", "\\doteq", true);
  3733. defineSymbol(math, main, rel, "\u2322", "\\frown", true);
  3734. defineSymbol(math, main, rel, "\u220b", "\\ni", true);
  3735. defineSymbol(math, main, rel, "\u221d", "\\propto", true);
  3736. defineSymbol(math, main, rel, "\u22a2", "\\vdash", true);
  3737. defineSymbol(math, main, rel, "\u22a3", "\\dashv", true);
  3738. defineSymbol(math, main, rel, "\u220b", "\\owns");
  3739. // Punctuation
  3740. defineSymbol(math, main, punct, "\u002e", "\\ldotp");
  3741. defineSymbol(math, main, punct, "\u22c5", "\\cdotp");
  3742. // The KaTeX fonts do not contain U+00B7. Use the centered dot glyph at U+22C5
  3743. // in both modes, but keep math-mode punctuation spacing only in math mode.
  3744. defineSymbol(math, main, punct, "\u22c5", "\u00b7");
  3745. defineSymbol(text, main, textord, "\u22c5", "\u00b7");
  3746. // Misc Symbols
  3747. defineSymbol(math, main, textord, "\u0023", "\\#");
  3748. defineSymbol(text, main, textord, "\u0023", "\\#");
  3749. defineSymbol(math, main, textord, "\u0026", "\\&");
  3750. defineSymbol(text, main, textord, "\u0026", "\\&");
  3751. defineSymbol(math, main, textord, "\u2135", "\\aleph", true);
  3752. defineSymbol(math, main, textord, "\u2200", "\\forall", true);
  3753. defineSymbol(math, main, textord, "\u210f", "\\hbar", true);
  3754. defineSymbol(math, main, textord, "\u2203", "\\exists", true);
  3755. defineSymbol(math, main, textord, "\u2207", "\\nabla", true);
  3756. defineSymbol(math, main, textord, "\u266d", "\\flat", true);
  3757. defineSymbol(math, main, textord, "\u2113", "\\ell", true);
  3758. defineSymbol(math, main, textord, "\u266e", "\\natural", true);
  3759. defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true);
  3760. defineSymbol(math, main, textord, "\u2118", "\\wp", true);
  3761. defineSymbol(math, main, textord, "\u266f", "\\sharp", true);
  3762. defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true);
  3763. defineSymbol(math, main, textord, "\u211c", "\\Re", true);
  3764. defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true);
  3765. defineSymbol(math, main, textord, "\u2111", "\\Im", true);
  3766. defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true);
  3767. defineSymbol(math, main, textord, "\u00a7", "\\S", true);
  3768. defineSymbol(text, main, textord, "\u00a7", "\\S");
  3769. defineSymbol(math, main, textord, "\u00b6", "\\P", true);
  3770. defineSymbol(text, main, textord, "\u00b6", "\\P");
  3771. // Math and Text
  3772. defineSymbol(math, main, textord, "\u2020", "\\dag");
  3773. defineSymbol(text, main, textord, "\u2020", "\\dag");
  3774. defineSymbol(text, main, textord, "\u2020", "\\textdagger");
  3775. defineSymbol(math, main, textord, "\u2021", "\\ddag");
  3776. defineSymbol(text, main, textord, "\u2021", "\\ddag");
  3777. defineSymbol(text, main, textord, "\u2021", "\\textdaggerdbl");
  3778. // Large Delimiters
  3779. defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true);
  3780. defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true);
  3781. defineSymbol(math, main, close, "\u27ef", "\\rgroup", true);
  3782. defineSymbol(math, main, open, "\u27ee", "\\lgroup", true);
  3783. // Binary Operators
  3784. defineSymbol(math, main, bin, "\u2213", "\\mp", true);
  3785. defineSymbol(math, main, bin, "\u2296", "\\ominus", true);
  3786. defineSymbol(math, main, bin, "\u228e", "\\uplus", true);
  3787. defineSymbol(math, main, bin, "\u2293", "\\sqcap", true);
  3788. defineSymbol(math, main, bin, "\u2217", "\\ast");
  3789. defineSymbol(math, main, bin, "\u2294", "\\sqcup", true);
  3790. defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true);
  3791. defineSymbol(math, main, bin, "\u2219", "\\bullet", true);
  3792. defineSymbol(math, main, bin, "\u2021", "\\ddagger");
  3793. defineSymbol(math, main, bin, "\u2240", "\\wr", true);
  3794. defineSymbol(math, main, bin, "\u2a3f", "\\amalg");
  3795. defineSymbol(math, main, bin, "\u0026", "\\And"); // from amsmath
  3796. // Arrow Symbols
  3797. defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow", true);
  3798. defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow", true);
  3799. defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow", true);
  3800. defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow", true);
  3801. defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow", true);
  3802. defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow", true);
  3803. defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true);
  3804. defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow", true);
  3805. defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow", true);
  3806. defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow", true);
  3807. defineSymbol(math, main, rel, "\u21a6", "\\mapsto", true);
  3808. defineSymbol(math, main, rel, "\u27fc", "\\longmapsto", true);
  3809. defineSymbol(math, main, rel, "\u2197", "\\nearrow", true);
  3810. defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow", true);
  3811. defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow", true);
  3812. defineSymbol(math, main, rel, "\u2198", "\\searrow", true);
  3813. defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup", true);
  3814. defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup", true);
  3815. defineSymbol(math, main, rel, "\u2199", "\\swarrow", true);
  3816. defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown", true);
  3817. defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true);
  3818. defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true);
  3819. defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true);
  3820. // AMS Negated Binary Relations
  3821. defineSymbol(math, ams, rel, "\u226e", "\\nless", true);
  3822. // Symbol names preceded by "@" each have a corresponding macro.
  3823. defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant");
  3824. defineSymbol(math, ams, rel, "\ue011", "\\@nleqq");
  3825. defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true);
  3826. defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true);
  3827. defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq");
  3828. defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true);
  3829. defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true);
  3830. defineSymbol(math, ams, rel, "\u2280", "\\nprec", true);
  3831. // unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym.
  3832. defineSymbol(math, ams, rel, "\u22e0", "\\npreceq", true);
  3833. defineSymbol(math, ams, rel, "\u22e8", "\\precnsim", true);
  3834. defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox", true);
  3835. defineSymbol(math, ams, rel, "\u2241", "\\nsim", true);
  3836. defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid");
  3837. defineSymbol(math, ams, rel, "\u2224", "\\nmid", true);
  3838. defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true);
  3839. defineSymbol(math, ams, rel, "\u22ad", "\\nvDash", true);
  3840. defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft");
  3841. defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq", true);
  3842. defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true);
  3843. defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq");
  3844. defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true);
  3845. defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq");
  3846. defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true);
  3847. defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant");
  3848. defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq");
  3849. defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true);
  3850. defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true);
  3851. defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq");
  3852. defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true);
  3853. defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true);
  3854. defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true);
  3855. // unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym.
  3856. defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq", true);
  3857. defineSymbol(math, ams, rel, "\u22e9", "\\succnsim", true);
  3858. defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox", true);
  3859. // unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym.
  3860. defineSymbol(math, ams, rel, "\u2246", "\\ncong", true);
  3861. defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel");
  3862. defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true);
  3863. defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true);
  3864. defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright");
  3865. defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true);
  3866. defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq");
  3867. defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true);
  3868. defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq");
  3869. defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true);
  3870. defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq");
  3871. defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true);
  3872. defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true);
  3873. defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true);
  3874. defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq");
  3875. defineSymbol(math, ams, bin, "\u22b4", "\\unlhd");
  3876. defineSymbol(math, ams, bin, "\u22b5", "\\unrhd");
  3877. // AMS Negated Arrows
  3878. defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow", true);
  3879. defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow", true);
  3880. defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow", true);
  3881. defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow", true);
  3882. defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow", true);
  3883. defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow", true);
  3884. // AMS Misc
  3885. defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle");
  3886. defineSymbol(math, ams, textord, "\u210f", "\\hslash");
  3887. defineSymbol(math, ams, textord, "\u25bd", "\\triangledown");
  3888. defineSymbol(math, ams, textord, "\u25ca", "\\lozenge");
  3889. defineSymbol(math, ams, textord, "\u24c8", "\\circledS");
  3890. defineSymbol(math, ams, textord, "\u00ae", "\\circledR");
  3891. defineSymbol(text, ams, textord, "\u00ae", "\\circledR");
  3892. defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true);
  3893. defineSymbol(math, ams, textord, "\u2204", "\\nexists");
  3894. defineSymbol(math, ams, textord, "\u2127", "\\mho");
  3895. defineSymbol(math, ams, textord, "\u2132", "\\Finv", true);
  3896. defineSymbol(math, ams, textord, "\u2141", "\\Game", true);
  3897. defineSymbol(math, ams, textord, "\u2035", "\\backprime");
  3898. defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle");
  3899. defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown");
  3900. defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare");
  3901. defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge");
  3902. defineSymbol(math, ams, textord, "\u2605", "\\bigstar");
  3903. defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true);
  3904. defineSymbol(math, ams, textord, "\u2201", "\\complement", true);
  3905. // unicode-math maps U+F0 to \matheth. We map to AMS function \eth
  3906. defineSymbol(math, ams, textord, "\u00f0", "\\eth", true);
  3907. defineSymbol(text, main, textord, "\u00f0", "\u00f0");
  3908. defineSymbol(math, ams, textord, "\u2571", "\\diagup");
  3909. defineSymbol(math, ams, textord, "\u2572", "\\diagdown");
  3910. defineSymbol(math, ams, textord, "\u25a1", "\\square");
  3911. defineSymbol(math, ams, textord, "\u25a1", "\\Box");
  3912. defineSymbol(math, ams, textord, "\u25ca", "\\Diamond");
  3913. // unicode-math maps U+A5 to \mathyen. We map to AMS function \yen
  3914. defineSymbol(math, ams, textord, "\u00a5", "\\yen", true);
  3915. defineSymbol(text, ams, textord, "\u00a5", "\\yen", true);
  3916. defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true);
  3917. defineSymbol(text, ams, textord, "\u2713", "\\checkmark");
  3918. // AMS Hebrew
  3919. defineSymbol(math, ams, textord, "\u2136", "\\beth", true);
  3920. defineSymbol(math, ams, textord, "\u2138", "\\daleth", true);
  3921. defineSymbol(math, ams, textord, "\u2137", "\\gimel", true);
  3922. // AMS Greek
  3923. defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true);
  3924. defineSymbol(math, ams, textord, "\u03f0", "\\varkappa");
  3925. // AMS Delimiters
  3926. defineSymbol(math, ams, open, "\u250c", "\\@ulcorner", true);
  3927. defineSymbol(math, ams, close, "\u2510", "\\@urcorner", true);
  3928. defineSymbol(math, ams, open, "\u2514", "\\@llcorner", true);
  3929. defineSymbol(math, ams, close, "\u2518", "\\@lrcorner", true);
  3930. // AMS Binary Relations
  3931. defineSymbol(math, ams, rel, "\u2266", "\\leqq", true);
  3932. defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true);
  3933. defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless", true);
  3934. defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true);
  3935. defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox", true);
  3936. defineSymbol(math, ams, rel, "\u224a", "\\approxeq", true);
  3937. defineSymbol(math, ams, bin, "\u22d6", "\\lessdot");
  3938. defineSymbol(math, ams, rel, "\u22d8", "\\lll", true);
  3939. defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true);
  3940. defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr", true);
  3941. defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr", true);
  3942. defineSymbol(math, ams, rel, "\u2251", "\\doteqdot");
  3943. defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true);
  3944. defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true);
  3945. defineSymbol(math, ams, rel, "\u223d", "\\backsim", true);
  3946. defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq", true);
  3947. defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq", true);
  3948. defineSymbol(math, ams, rel, "\u22d0", "\\Subset", true);
  3949. defineSymbol(math, ams, rel, "\u228f", "\\sqsubset", true);
  3950. defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq", true);
  3951. defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec", true);
  3952. defineSymbol(math, ams, rel, "\u227e", "\\precsim", true);
  3953. defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox", true);
  3954. defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft");
  3955. defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq");
  3956. defineSymbol(math, ams, rel, "\u22a8", "\\vDash", true);
  3957. defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash", true);
  3958. defineSymbol(math, ams, rel, "\u2323", "\\smallsmile");
  3959. defineSymbol(math, ams, rel, "\u2322", "\\smallfrown");
  3960. defineSymbol(math, ams, rel, "\u224f", "\\bumpeq", true);
  3961. defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq", true);
  3962. defineSymbol(math, ams, rel, "\u2267", "\\geqq", true);
  3963. defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant", true);
  3964. defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr", true);
  3965. defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true);
  3966. defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox", true);
  3967. defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot");
  3968. defineSymbol(math, ams, rel, "\u22d9", "\\ggg", true);
  3969. defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true);
  3970. defineSymbol(math, ams, rel, "\u22db", "\\gtreqless", true);
  3971. defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless", true);
  3972. defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true);
  3973. defineSymbol(math, ams, rel, "\u2257", "\\circeq", true);
  3974. defineSymbol(math, ams, rel, "\u225c", "\\triangleq", true);
  3975. defineSymbol(math, ams, rel, "\u223c", "\\thicksim");
  3976. defineSymbol(math, ams, rel, "\u2248", "\\thickapprox");
  3977. defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq", true);
  3978. defineSymbol(math, ams, rel, "\u22d1", "\\Supset", true);
  3979. defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true);
  3980. defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq", true);
  3981. defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc", true);
  3982. defineSymbol(math, ams, rel, "\u227f", "\\succsim", true);
  3983. defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox", true);
  3984. defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright");
  3985. defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq");
  3986. defineSymbol(math, ams, rel, "\u22a9", "\\Vdash", true);
  3987. defineSymbol(math, ams, rel, "\u2223", "\\shortmid");
  3988. defineSymbol(math, ams, rel, "\u2225", "\\shortparallel");
  3989. defineSymbol(math, ams, rel, "\u226c", "\\between", true);
  3990. defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork", true);
  3991. defineSymbol(math, ams, rel, "\u221d", "\\varpropto");
  3992. defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft");
  3993. // unicode-math says that \therefore is a mathord atom.
  3994. // We kept the amssymb atom type, which is rel.
  3995. defineSymbol(math, ams, rel, "\u2234", "\\therefore", true);
  3996. defineSymbol(math, ams, rel, "\u220d", "\\backepsilon");
  3997. defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright");
  3998. // unicode-math says that \because is a mathord atom.
  3999. // We kept the amssymb atom type, which is rel.
  4000. defineSymbol(math, ams, rel, "\u2235", "\\because", true);
  4001. defineSymbol(math, ams, rel, "\u22d8", "\\llless");
  4002. defineSymbol(math, ams, rel, "\u22d9", "\\gggtr");
  4003. defineSymbol(math, ams, bin, "\u22b2", "\\lhd");
  4004. defineSymbol(math, ams, bin, "\u22b3", "\\rhd");
  4005. defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true);
  4006. defineSymbol(math, main, rel, "\u22c8", "\\Join");
  4007. defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true);
  4008. // AMS Binary Operators
  4009. defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true);
  4010. defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus");
  4011. defineSymbol(math, ams, bin, "\u22d2", "\\Cap", true);
  4012. defineSymbol(math, ams, bin, "\u22d3", "\\Cup", true);
  4013. defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge", true);
  4014. defineSymbol(math, ams, bin, "\u229f", "\\boxminus", true);
  4015. defineSymbol(math, ams, bin, "\u229e", "\\boxplus", true);
  4016. defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes", true);
  4017. defineSymbol(math, ams, bin, "\u22c9", "\\ltimes", true);
  4018. defineSymbol(math, ams, bin, "\u22ca", "\\rtimes", true);
  4019. defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes", true);
  4020. defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes", true);
  4021. defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge", true);
  4022. defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee", true);
  4023. defineSymbol(math, ams, bin, "\u229d", "\\circleddash", true);
  4024. defineSymbol(math, ams, bin, "\u229b", "\\circledast", true);
  4025. defineSymbol(math, ams, bin, "\u22c5", "\\centerdot");
  4026. defineSymbol(math, ams, bin, "\u22ba", "\\intercal", true);
  4027. defineSymbol(math, ams, bin, "\u22d2", "\\doublecap");
  4028. defineSymbol(math, ams, bin, "\u22d3", "\\doublecup");
  4029. defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes", true);
  4030. // AMS Arrows
  4031. // Note: unicode-math maps \u21e2 to their own function \rightdasharrow.
  4032. // We'll map it to AMS function \dashrightarrow. It produces the same atom.
  4033. defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow", true);
  4034. // unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym.
  4035. defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow", true);
  4036. defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows", true);
  4037. defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows", true);
  4038. defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow", true);
  4039. defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow", true);
  4040. defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail", true);
  4041. defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft", true);
  4042. defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons", true);
  4043. defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft", true);
  4044. // unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym.
  4045. defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft", true);
  4046. defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true);
  4047. defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true);
  4048. defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true);
  4049. defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true);
  4050. defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font
  4051. defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font
  4052. defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true);
  4053. defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true);
  4054. defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true);
  4055. defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows", true);
  4056. defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow", true);
  4057. defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail", true);
  4058. defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright", true);
  4059. defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright", true);
  4060. // unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym.
  4061. defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright", true);
  4062. defineSymbol(math, ams, rel, "\u21b1", "\\Rsh", true);
  4063. defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows", true);
  4064. defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright", true);
  4065. defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright", true);
  4066. defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow", true);
  4067. defineSymbol(math, ams, rel, "\u21dd", "\\leadsto");
  4068. defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true);
  4069. defineSymbol(math, ams, rel, "\u21be", "\\restriction");
  4070. defineSymbol(math, main, textord, "\u2018", "`");
  4071. defineSymbol(math, main, textord, "$", "\\$");
  4072. defineSymbol(text, main, textord, "$", "\\$");
  4073. defineSymbol(text, main, textord, "$", "\\textdollar");
  4074. defineSymbol(math, main, textord, "%", "\\%");
  4075. defineSymbol(text, main, textord, "%", "\\%");
  4076. defineSymbol(math, main, textord, "_", "\\_");
  4077. defineSymbol(text, main, textord, "_", "\\_");
  4078. defineSymbol(text, main, textord, "_", "\\textunderscore");
  4079. defineSymbol(math, main, textord, "\u2220", "\\angle", true);
  4080. defineSymbol(math, main, textord, "\u221e", "\\infty", true);
  4081. defineSymbol(math, main, textord, "\u2032", "\\prime");
  4082. defineSymbol(math, main, textord, "\u25b3", "\\triangle");
  4083. defineSymbol(math, main, textord, "\u0393", "\\Gamma", true);
  4084. defineSymbol(math, main, textord, "\u0394", "\\Delta", true);
  4085. defineSymbol(math, main, textord, "\u0398", "\\Theta", true);
  4086. defineSymbol(math, main, textord, "\u039b", "\\Lambda", true);
  4087. defineSymbol(math, main, textord, "\u039e", "\\Xi", true);
  4088. defineSymbol(math, main, textord, "\u03a0", "\\Pi", true);
  4089. defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true);
  4090. defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true);
  4091. defineSymbol(math, main, textord, "\u03a6", "\\Phi", true);
  4092. defineSymbol(math, main, textord, "\u03a8", "\\Psi", true);
  4093. defineSymbol(math, main, textord, "\u03a9", "\\Omega", true);
  4094. defineSymbol(math, main, textord, "A", "\u0391");
  4095. defineSymbol(math, main, textord, "B", "\u0392");
  4096. defineSymbol(math, main, textord, "E", "\u0395");
  4097. defineSymbol(math, main, textord, "Z", "\u0396");
  4098. defineSymbol(math, main, textord, "H", "\u0397");
  4099. defineSymbol(math, main, textord, "I", "\u0399");
  4100. defineSymbol(math, main, textord, "K", "\u039A");
  4101. defineSymbol(math, main, textord, "M", "\u039C");
  4102. defineSymbol(math, main, textord, "N", "\u039D");
  4103. defineSymbol(math, main, textord, "O", "\u039F");
  4104. defineSymbol(math, main, textord, "P", "\u03A1");
  4105. defineSymbol(math, main, textord, "T", "\u03A4");
  4106. defineSymbol(math, main, textord, "X", "\u03A7");
  4107. defineSymbol(math, main, textord, "\u00ac", "\\neg", true);
  4108. defineSymbol(math, main, textord, "\u00ac", "\\lnot");
  4109. defineSymbol(math, main, textord, "\u22a4", "\\top");
  4110. defineSymbol(math, main, textord, "\u22a5", "\\bot");
  4111. defineSymbol(math, main, textord, "\u2205", "\\emptyset");
  4112. defineSymbol(math, ams, textord, "\u2205", "\\varnothing");
  4113. defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true);
  4114. defineSymbol(math, main, mathord, "\u03b2", "\\beta", true);
  4115. defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true);
  4116. defineSymbol(math, main, mathord, "\u03b4", "\\delta", true);
  4117. defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true);
  4118. defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true);
  4119. defineSymbol(math, main, mathord, "\u03b7", "\\eta", true);
  4120. defineSymbol(math, main, mathord, "\u03b8", "\\theta", true);
  4121. defineSymbol(math, main, mathord, "\u03b9", "\\iota", true);
  4122. defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true);
  4123. defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true);
  4124. defineSymbol(math, main, mathord, "\u03bc", "\\mu", true);
  4125. defineSymbol(math, main, mathord, "\u03bd", "\\nu", true);
  4126. defineSymbol(math, main, mathord, "\u03be", "\\xi", true);
  4127. defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true);
  4128. defineSymbol(math, main, mathord, "\u03c0", "\\pi", true);
  4129. defineSymbol(math, main, mathord, "\u03c1", "\\rho", true);
  4130. defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true);
  4131. defineSymbol(math, main, mathord, "\u03c4", "\\tau", true);
  4132. defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true);
  4133. defineSymbol(math, main, mathord, "\u03d5", "\\phi", true);
  4134. defineSymbol(math, main, mathord, "\u03c7", "\\chi", true);
  4135. defineSymbol(math, main, mathord, "\u03c8", "\\psi", true);
  4136. defineSymbol(math, main, mathord, "\u03c9", "\\omega", true);
  4137. defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true);
  4138. defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true);
  4139. defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true);
  4140. defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true);
  4141. defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true);
  4142. defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true);
  4143. defineSymbol(math, main, bin, "\u2217", "*", true);
  4144. defineSymbol(math, main, bin, "+", "+");
  4145. defineSymbol(math, main, bin, "\u2212", "-", true);
  4146. defineSymbol(math, main, bin, "\u22c5", "\\cdot", true);
  4147. defineSymbol(math, main, bin, "\u2218", "\\circ", true);
  4148. defineSymbol(math, main, bin, "\u00f7", "\\div", true);
  4149. defineSymbol(math, main, bin, "\u00b1", "\\pm", true);
  4150. defineSymbol(math, main, bin, "\u00d7", "\\times", true);
  4151. defineSymbol(math, main, bin, "\u2229", "\\cap", true);
  4152. defineSymbol(math, main, bin, "\u222a", "\\cup", true);
  4153. defineSymbol(math, main, bin, "\u2216", "\\setminus", true);
  4154. defineSymbol(math, main, bin, "\u2227", "\\land");
  4155. defineSymbol(math, main, bin, "\u2228", "\\lor");
  4156. defineSymbol(math, main, bin, "\u2227", "\\wedge", true);
  4157. defineSymbol(math, main, bin, "\u2228", "\\vee", true);
  4158. defineSymbol(math, main, textord, "\u221a", "\\surd");
  4159. defineSymbol(math, main, open, "\u27e8", "\\langle", true);
  4160. defineSymbol(math, main, open, "\u2223", "\\lvert");
  4161. defineSymbol(math, main, open, "\u2225", "\\lVert");
  4162. defineSymbol(math, main, close, "?", "?");
  4163. defineSymbol(math, main, close, "!", "!");
  4164. defineSymbol(math, main, close, "\u27e9", "\\rangle", true);
  4165. defineSymbol(math, main, close, "\u2223", "\\rvert");
  4166. defineSymbol(math, main, close, "\u2225", "\\rVert");
  4167. defineSymbol(math, main, rel, "=", "=");
  4168. defineSymbol(math, main, rel, ":", ":");
  4169. defineSymbol(math, main, rel, "\u2248", "\\approx", true);
  4170. defineSymbol(math, main, rel, "\u2245", "\\cong", true);
  4171. defineSymbol(math, main, rel, "\u2265", "\\ge");
  4172. defineSymbol(math, main, rel, "\u2265", "\\geq", true);
  4173. defineSymbol(math, main, rel, "\u2190", "\\gets");
  4174. defineSymbol(math, main, rel, ">", "\\gt", true);
  4175. defineSymbol(math, main, rel, "\u2208", "\\in", true);
  4176. defineSymbol(math, main, rel, "\ue020", "\\@not");
  4177. defineSymbol(math, main, rel, "\u2282", "\\subset", true);
  4178. defineSymbol(math, main, rel, "\u2283", "\\supset", true);
  4179. defineSymbol(math, main, rel, "\u2286", "\\subseteq", true);
  4180. defineSymbol(math, main, rel, "\u2287", "\\supseteq", true);
  4181. defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true);
  4182. defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true);
  4183. defineSymbol(math, main, rel, "\u22a8", "\\models");
  4184. defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true);
  4185. defineSymbol(math, main, rel, "\u2264", "\\le");
  4186. defineSymbol(math, main, rel, "\u2264", "\\leq", true);
  4187. defineSymbol(math, main, rel, "<", "\\lt", true);
  4188. defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true);
  4189. defineSymbol(math, main, rel, "\u2192", "\\to");
  4190. defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true);
  4191. defineSymbol(math, ams, rel, "\u2270", "\\nleq", true);
  4192. defineSymbol(math, main, spacing, "\u00a0", "\\ ");
  4193. defineSymbol(math, main, spacing, "\u00a0", "\\space");
  4194. // Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{%
  4195. defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace");
  4196. defineSymbol(text, main, spacing, "\u00a0", "\\ ");
  4197. defineSymbol(text, main, spacing, "\u00a0", " ");
  4198. defineSymbol(text, main, spacing, "\u00a0", "\\space");
  4199. defineSymbol(text, main, spacing, "\u00a0", "\\nobreakspace");
  4200. defineSymbol(math, main, spacing, null, "\\nobreak");
  4201. defineSymbol(math, main, spacing, null, "\\allowbreak");
  4202. defineSymbol(math, main, punct, ",", ",");
  4203. defineSymbol(math, main, punct, ";", ";");
  4204. defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true);
  4205. defineSymbol(math, ams, bin, "\u22bb", "\\veebar", true);
  4206. defineSymbol(math, main, bin, "\u2299", "\\odot", true);
  4207. defineSymbol(math, main, bin, "\u2295", "\\oplus", true);
  4208. defineSymbol(math, main, bin, "\u2297", "\\otimes", true);
  4209. defineSymbol(math, main, textord, "\u2202", "\\partial", true);
  4210. defineSymbol(math, main, bin, "\u2298", "\\oslash", true);
  4211. defineSymbol(math, ams, bin, "\u229a", "\\circledcirc", true);
  4212. defineSymbol(math, ams, bin, "\u22a1", "\\boxdot", true);
  4213. defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup");
  4214. defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown");
  4215. defineSymbol(math, main, bin, "\u2020", "\\dagger");
  4216. defineSymbol(math, main, bin, "\u22c4", "\\diamond");
  4217. defineSymbol(math, main, bin, "\u22c6", "\\star");
  4218. defineSymbol(math, main, bin, "\u25c3", "\\triangleleft");
  4219. defineSymbol(math, main, bin, "\u25b9", "\\triangleright");
  4220. defineSymbol(math, main, open, "{", "\\{");
  4221. defineSymbol(text, main, textord, "{", "\\{");
  4222. defineSymbol(text, main, textord, "{", "\\textbraceleft");
  4223. defineSymbol(math, main, close, "}", "\\}");
  4224. defineSymbol(text, main, textord, "}", "\\}");
  4225. defineSymbol(text, main, textord, "}", "\\textbraceright");
  4226. defineSymbol(math, main, open, "{", "\\lbrace");
  4227. defineSymbol(math, main, close, "}", "\\rbrace");
  4228. defineSymbol(math, main, open, "[", "\\lbrack", true);
  4229. defineSymbol(text, main, textord, "[", "\\lbrack", true);
  4230. defineSymbol(math, main, close, "]", "\\rbrack", true);
  4231. defineSymbol(text, main, textord, "]", "\\rbrack", true);
  4232. defineSymbol(math, main, open, "(", "\\lparen", true);
  4233. defineSymbol(math, main, close, ")", "\\rparen", true);
  4234. defineSymbol(text, main, textord, "<", "\\textless", true); // in T1 fontenc
  4235. defineSymbol(text, main, textord, ">", "\\textgreater", true); // in T1 fontenc
  4236. defineSymbol(math, main, open, "\u230a", "\\lfloor", true);
  4237. defineSymbol(math, main, close, "\u230b", "\\rfloor", true);
  4238. defineSymbol(math, main, open, "\u2308", "\\lceil", true);
  4239. defineSymbol(math, main, close, "\u2309", "\\rceil", true);
  4240. defineSymbol(math, main, textord, "\\", "\\backslash");
  4241. defineSymbol(math, main, textord, "\u2223", "|");
  4242. defineSymbol(math, main, textord, "\u2223", "\\vert");
  4243. defineSymbol(text, main, textord, "|", "\\textbar", true); // in T1 fontenc
  4244. defineSymbol(math, main, textord, "\u2225", "\\|");
  4245. defineSymbol(math, main, textord, "\u2225", "\\Vert");
  4246. defineSymbol(text, main, textord, "\u2225", "\\textbardbl");
  4247. defineSymbol(text, main, textord, "~", "\\textasciitilde");
  4248. defineSymbol(text, main, textord, "\\", "\\textbackslash");
  4249. defineSymbol(text, main, textord, "^", "\\textasciicircum");
  4250. defineSymbol(math, main, rel, "\u2191", "\\uparrow", true);
  4251. defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true);
  4252. defineSymbol(math, main, rel, "\u2193", "\\downarrow", true);
  4253. defineSymbol(math, main, rel, "\u21d3", "\\Downarrow", true);
  4254. defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true);
  4255. defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow", true);
  4256. defineSymbol(math, main, op, "\u2210", "\\coprod");
  4257. defineSymbol(math, main, op, "\u22c1", "\\bigvee");
  4258. defineSymbol(math, main, op, "\u22c0", "\\bigwedge");
  4259. defineSymbol(math, main, op, "\u2a04", "\\biguplus");
  4260. defineSymbol(math, main, op, "\u22c2", "\\bigcap");
  4261. defineSymbol(math, main, op, "\u22c3", "\\bigcup");
  4262. defineSymbol(math, main, op, "\u222b", "\\int");
  4263. defineSymbol(math, main, op, "\u222b", "\\intop");
  4264. defineSymbol(math, main, op, "\u222c", "\\iint");
  4265. defineSymbol(math, main, op, "\u222d", "\\iiint");
  4266. defineSymbol(math, main, op, "\u220f", "\\prod");
  4267. defineSymbol(math, main, op, "\u2211", "\\sum");
  4268. defineSymbol(math, main, op, "\u2a02", "\\bigotimes");
  4269. defineSymbol(math, main, op, "\u2a01", "\\bigoplus");
  4270. defineSymbol(math, main, op, "\u2a00", "\\bigodot");
  4271. defineSymbol(math, main, op, "\u222e", "\\oint");
  4272. defineSymbol(math, main, op, "\u222f", "\\oiint");
  4273. defineSymbol(math, main, op, "\u2230", "\\oiiint");
  4274. defineSymbol(math, main, op, "\u2a06", "\\bigsqcup");
  4275. defineSymbol(math, main, op, "\u222b", "\\smallint");
  4276. defineSymbol(text, main, inner, "\u2026", "\\textellipsis");
  4277. defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
  4278. defineSymbol(text, main, inner, "\u2026", "\\ldots", true);
  4279. defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
  4280. defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true);
  4281. defineSymbol(math, main, inner, "\u22f1", "\\ddots", true);
  4282. // \vdots is a macro that uses one of these two symbols (with made-up names):
  4283. defineSymbol(math, main, textord, "\u22ee", "\\varvdots");
  4284. defineSymbol(text, main, textord, "\u22ee", "\\varvdots");
  4285. defineSymbol(math, main, accent, "\u02ca", "\\acute");
  4286. defineSymbol(math, main, accent, "\u02cb", "\\grave");
  4287. defineSymbol(math, main, accent, "\u00a8", "\\ddot");
  4288. defineSymbol(math, main, accent, "\u007e", "\\tilde");
  4289. defineSymbol(math, main, accent, "\u02c9", "\\bar");
  4290. defineSymbol(math, main, accent, "\u02d8", "\\breve");
  4291. defineSymbol(math, main, accent, "\u02c7", "\\check");
  4292. defineSymbol(math, main, accent, "\u005e", "\\hat");
  4293. defineSymbol(math, main, accent, "\u20d7", "\\vec");
  4294. defineSymbol(math, main, accent, "\u02d9", "\\dot");
  4295. defineSymbol(math, main, accent, "\u02da", "\\mathring");
  4296. // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA
  4297. defineSymbol(math, main, mathord, "\ue131", "\\@imath");
  4298. defineSymbol(math, main, mathord, "\ue237", "\\@jmath");
  4299. defineSymbol(math, main, textord, "\u0131", "\u0131");
  4300. defineSymbol(math, main, textord, "\u0237", "\u0237");
  4301. defineSymbol(text, main, textord, "\u0131", "\\i", true);
  4302. defineSymbol(text, main, textord, "\u0237", "\\j", true);
  4303. defineSymbol(text, main, textord, "\u00df", "\\ss", true);
  4304. defineSymbol(text, main, textord, "\u00e6", "\\ae", true);
  4305. defineSymbol(text, main, textord, "\u0153", "\\oe", true);
  4306. defineSymbol(text, main, textord, "\u00f8", "\\o", true);
  4307. defineSymbol(text, main, textord, "\u00c6", "\\AE", true);
  4308. defineSymbol(text, main, textord, "\u0152", "\\OE", true);
  4309. defineSymbol(text, main, textord, "\u00d8", "\\O", true);
  4310. defineSymbol(text, main, accent, "\u02ca", "\\'"); // acute
  4311. defineSymbol(text, main, accent, "\u02cb", "\\`"); // grave
  4312. defineSymbol(text, main, accent, "\u02c6", "\\^"); // circumflex
  4313. defineSymbol(text, main, accent, "\u02dc", "\\~"); // tilde
  4314. defineSymbol(text, main, accent, "\u02c9", "\\="); // macron
  4315. defineSymbol(text, main, accent, "\u02d8", "\\u"); // breve
  4316. defineSymbol(text, main, accent, "\u02d9", "\\."); // dot above
  4317. defineSymbol(text, main, accent, "\u00b8", "\\c"); // cedilla
  4318. defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above
  4319. defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron
  4320. defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaeresis
  4321. defineSymbol(text, main, accent, "\u02dd", "\\H"); // double acute
  4322. defineSymbol(text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph
  4323. // These ligatures are detected and created in Parser.js's `formLigatures`.
  4324. var ligatures = {
  4325. "--": true,
  4326. "---": true,
  4327. "``": true,
  4328. "''": true
  4329. };
  4330. defineSymbol(text, main, textord, "\u2013", "--", true);
  4331. defineSymbol(text, main, textord, "\u2013", "\\textendash");
  4332. defineSymbol(text, main, textord, "\u2014", "---", true);
  4333. defineSymbol(text, main, textord, "\u2014", "\\textemdash");
  4334. defineSymbol(text, main, textord, "\u2018", "`", true);
  4335. defineSymbol(text, main, textord, "\u2018", "\\textquoteleft");
  4336. defineSymbol(text, main, textord, "\u2019", "'", true);
  4337. defineSymbol(text, main, textord, "\u2019", "\\textquoteright");
  4338. defineSymbol(text, main, textord, "\u201c", "``", true);
  4339. defineSymbol(text, main, textord, "\u201c", "\\textquotedblleft");
  4340. defineSymbol(text, main, textord, "\u201d", "''", true);
  4341. defineSymbol(text, main, textord, "\u201d", "\\textquotedblright");
  4342. // \degree from gensymb package
  4343. defineSymbol(math, main, textord, "\u00b0", "\\degree", true);
  4344. defineSymbol(text, main, textord, "\u00b0", "\\degree");
  4345. // \textdegree from inputenc package
  4346. defineSymbol(text, main, textord, "\u00b0", "\\textdegree", true);
  4347. // TODO: In LaTeX, \pounds can generate a different character in text and math
  4348. // mode, but among our fonts, only Main-Regular defines this character "163".
  4349. defineSymbol(math, main, textord, "\u00a3", "\\pounds");
  4350. defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true);
  4351. defineSymbol(text, main, textord, "\u00a3", "\\pounds");
  4352. defineSymbol(text, main, textord, "\u00a3", "\\textsterling", true);
  4353. defineSymbol(math, ams, textord, "\u2720", "\\maltese");
  4354. defineSymbol(text, ams, textord, "\u2720", "\\maltese");
  4355. // There are lots of symbols which are the same, so we add them in afterwards.
  4356. // All of these are textords in math mode
  4357. var mathTextSymbols = "0123456789/@.\"";
  4358. for (var i = 0; i < mathTextSymbols.length; i++) {
  4359. var ch = mathTextSymbols.charAt(i);
  4360. defineSymbol(math, main, textord, ch, ch);
  4361. }
  4362. // All of these are textords in text mode
  4363. var textSymbols = "0123456789!@*()-=+\";:?/.,";
  4364. for (var _i = 0; _i < textSymbols.length; _i++) {
  4365. var _ch = textSymbols.charAt(_i);
  4366. defineSymbol(text, main, textord, _ch, _ch);
  4367. }
  4368. // All of these are textords in text mode, and mathords in math mode
  4369. var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  4370. for (var _i2 = 0; _i2 < letters.length; _i2++) {
  4371. var _ch2 = letters.charAt(_i2);
  4372. defineSymbol(math, main, mathord, _ch2, _ch2);
  4373. defineSymbol(text, main, textord, _ch2, _ch2);
  4374. }
  4375. // Blackboard bold and script letters in Unicode range
  4376. defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
  4377. defineSymbol(text, ams, textord, "C", "\u2102");
  4378. defineSymbol(math, ams, textord, "H", "\u210D");
  4379. defineSymbol(text, ams, textord, "H", "\u210D");
  4380. defineSymbol(math, ams, textord, "N", "\u2115");
  4381. defineSymbol(text, ams, textord, "N", "\u2115");
  4382. defineSymbol(math, ams, textord, "P", "\u2119");
  4383. defineSymbol(text, ams, textord, "P", "\u2119");
  4384. defineSymbol(math, ams, textord, "Q", "\u211A");
  4385. defineSymbol(text, ams, textord, "Q", "\u211A");
  4386. defineSymbol(math, ams, textord, "R", "\u211D");
  4387. defineSymbol(text, ams, textord, "R", "\u211D");
  4388. defineSymbol(math, ams, textord, "Z", "\u2124");
  4389. defineSymbol(text, ams, textord, "Z", "\u2124");
  4390. defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant
  4391. defineSymbol(text, main, mathord, "h", "\u210E");
  4392. // The next loop loads wide (surrogate pair) characters.
  4393. // We support some letters in the Unicode range U+1D400 to U+1D7FF,
  4394. // Mathematical Alphanumeric Symbols.
  4395. // Some editors do not deal well with wide characters. So don't write the
  4396. // string into this file. Instead, create the string from the surrogate pair.
  4397. var wideChar = "";
  4398. for (var _i3 = 0; _i3 < letters.length; _i3++) {
  4399. var _ch3 = letters.charAt(_i3);
  4400. // The hex numbers in the next line are a surrogate pair.
  4401. // 0xD835 is the high surrogate for all letters in the range we support.
  4402. // 0xDC00 is the low surrogate for bold A.
  4403. wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
  4404. defineSymbol(math, main, mathord, _ch3, wideChar);
  4405. defineSymbol(text, main, textord, _ch3, wideChar);
  4406. wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic
  4407. defineSymbol(math, main, mathord, _ch3, wideChar);
  4408. defineSymbol(text, main, textord, _ch3, wideChar);
  4409. wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic
  4410. defineSymbol(math, main, mathord, _ch3, wideChar);
  4411. defineSymbol(text, main, textord, _ch3, wideChar);
  4412. wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fraktur
  4413. defineSymbol(math, main, mathord, _ch3, wideChar);
  4414. defineSymbol(text, main, textord, _ch3, wideChar);
  4415. wideChar = String.fromCharCode(0xD835, 0xDD6C + _i3); // A-Z a-z bold Fraktur
  4416. defineSymbol(math, main, mathord, _ch3, wideChar);
  4417. defineSymbol(text, main, textord, _ch3, wideChar);
  4418. wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif
  4419. defineSymbol(math, main, mathord, _ch3, wideChar);
  4420. defineSymbol(text, main, textord, _ch3, wideChar);
  4421. wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold
  4422. defineSymbol(math, main, mathord, _ch3, wideChar);
  4423. defineSymbol(text, main, textord, _ch3, wideChar);
  4424. wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic
  4425. defineSymbol(math, main, mathord, _ch3, wideChar);
  4426. defineSymbol(text, main, textord, _ch3, wideChar);
  4427. wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace
  4428. defineSymbol(math, main, mathord, _ch3, wideChar);
  4429. defineSymbol(text, main, textord, _ch3, wideChar);
  4430. if (_i3 < 26) {
  4431. // KaTeX fonts have only capital letters for blackboard bold and script.
  4432. // See exception for k below.
  4433. wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck
  4434. defineSymbol(math, main, mathord, _ch3, wideChar);
  4435. defineSymbol(text, main, textord, _ch3, wideChar);
  4436. wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script
  4437. defineSymbol(math, main, mathord, _ch3, wideChar);
  4438. defineSymbol(text, main, textord, _ch3, wideChar);
  4439. }
  4440. // TODO: Add bold script when it is supported by a KaTeX font.
  4441. }
  4442. // "k" is the only double struck lower case letter in the KaTeX fonts.
  4443. wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
  4444. defineSymbol(math, main, mathord, "k", wideChar);
  4445. defineSymbol(text, main, textord, "k", wideChar);
  4446. // Next, some wide character numerals
  4447. for (var _i4 = 0; _i4 < 10; _i4++) {
  4448. var _ch4 = _i4.toString();
  4449. wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold
  4450. defineSymbol(math, main, mathord, _ch4, wideChar);
  4451. defineSymbol(text, main, textord, _ch4, wideChar);
  4452. wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif
  4453. defineSymbol(math, main, mathord, _ch4, wideChar);
  4454. defineSymbol(text, main, textord, _ch4, wideChar);
  4455. wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans
  4456. defineSymbol(math, main, mathord, _ch4, wideChar);
  4457. defineSymbol(text, main, textord, _ch4, wideChar);
  4458. wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace
  4459. defineSymbol(math, main, mathord, _ch4, wideChar);
  4460. defineSymbol(text, main, textord, _ch4, wideChar);
  4461. }
  4462. // We add these Latin-1 letters as symbols for backwards-compatibility,
  4463. // but they are not actually in the font, nor are they supported by the
  4464. // Unicode accent mechanism, so they fall back to Times font and look ugly.
  4465. // TODO(edemaine): Fix this.
  4466. var extraLatin = "\u00d0\u00de\u00fe";
  4467. for (var _i5 = 0; _i5 < extraLatin.length; _i5++) {
  4468. var _ch5 = extraLatin.charAt(_i5);
  4469. defineSymbol(math, main, mathord, _ch5, _ch5);
  4470. defineSymbol(text, main, textord, _ch5, _ch5);
  4471. }
  4472. /**
  4473. * This file provides support for Unicode range U+1D400 to U+1D7FF,
  4474. * Mathematical Alphanumeric Symbols.
  4475. *
  4476. * Function wideCharacterFont takes a wide character as input and returns
  4477. * the font information necessary to render it properly.
  4478. */
  4479. /**
  4480. * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf
  4481. * That document sorts characters into groups by font type, say bold or italic.
  4482. *
  4483. * In the arrays below, each subarray consists three elements:
  4484. * * The CSS class of that group when in math mode.
  4485. * * The CSS class of that group when in text mode.
  4486. * * The font name, so that KaTeX can get font metrics.
  4487. */
  4488. var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"],
  4489. // A-Z bold upright
  4490. ["mathbf", "textbf", "Main-Bold"],
  4491. // a-z bold upright
  4492. ["mathnormal", "textit", "Math-Italic"],
  4493. // A-Z italic
  4494. ["mathnormal", "textit", "Math-Italic"],
  4495. // a-z italic
  4496. ["boldsymbol", "boldsymbol", "Main-BoldItalic"],
  4497. // A-Z bold italic
  4498. ["boldsymbol", "boldsymbol", "Main-BoldItalic"],
  4499. // a-z bold italic
  4500. // Map fancy A-Z letters to script, not calligraphic.
  4501. // This aligns with unicode-math and math fonts (except Cambria Math).
  4502. ["mathscr", "textscr", "Script-Regular"],
  4503. // A-Z script
  4504. ["", "", ""],
  4505. // a-z script. No font
  4506. ["", "", ""],
  4507. // A-Z bold script. No font
  4508. ["", "", ""],
  4509. // a-z bold script. No font
  4510. ["mathfrak", "textfrak", "Fraktur-Regular"],
  4511. // A-Z Fraktur
  4512. ["mathfrak", "textfrak", "Fraktur-Regular"],
  4513. // a-z Fraktur
  4514. ["mathbb", "textbb", "AMS-Regular"],
  4515. // A-Z double-struck
  4516. ["mathbb", "textbb", "AMS-Regular"],
  4517. // k double-struck
  4518. // Note that we are using a bold font, but font metrics for regular Fraktur.
  4519. ["mathboldfrak", "textboldfrak", "Fraktur-Regular"],
  4520. // A-Z bold Fraktur
  4521. ["mathboldfrak", "textboldfrak", "Fraktur-Regular"],
  4522. // a-z bold Fraktur
  4523. ["mathsf", "textsf", "SansSerif-Regular"],
  4524. // A-Z sans-serif
  4525. ["mathsf", "textsf", "SansSerif-Regular"],
  4526. // a-z sans-serif
  4527. ["mathboldsf", "textboldsf", "SansSerif-Bold"],
  4528. // A-Z bold sans-serif
  4529. ["mathboldsf", "textboldsf", "SansSerif-Bold"],
  4530. // a-z bold sans-serif
  4531. ["mathitsf", "textitsf", "SansSerif-Italic"],
  4532. // A-Z italic sans-serif
  4533. ["mathitsf", "textitsf", "SansSerif-Italic"],
  4534. // a-z italic sans-serif
  4535. ["", "", ""],
  4536. // A-Z bold italic sans. No font
  4537. ["", "", ""],
  4538. // a-z bold italic sans. No font
  4539. ["mathtt", "texttt", "Typewriter-Regular"],
  4540. // A-Z monospace
  4541. ["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace
  4542. ];
  4543. var wideNumeralData = [["mathbf", "textbf", "Main-Bold"],
  4544. // 0-9 bold
  4545. ["", "", ""],
  4546. // 0-9 double-struck. No KaTeX font.
  4547. ["mathsf", "textsf", "SansSerif-Regular"],
  4548. // 0-9 sans-serif
  4549. ["mathboldsf", "textboldsf", "SansSerif-Bold"],
  4550. // 0-9 bold sans-serif
  4551. ["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace
  4552. ];
  4553. var wideCharacterFont = (wideChar, mode) => {
  4554. // IE doesn't support codePointAt(). So work with the surrogate pair.
  4555. var H = wideChar.charCodeAt(0); // high surrogate
  4556. var L = wideChar.charCodeAt(1); // low surrogate
  4557. var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000;
  4558. var j = mode === "math" ? 0 : 1; // column index for CSS class.
  4559. if (0x1D400 <= codePoint && codePoint < 0x1D6A4) {
  4560. // wideLatinLetterData contains exactly 26 chars on each row.
  4561. // So we can calculate the relevant row. No traverse necessary.
  4562. var i = Math.floor((codePoint - 0x1D400) / 26);
  4563. return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]];
  4564. } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) {
  4565. // Numerals, ten per row.
  4566. var _i = Math.floor((codePoint - 0x1D7CE) / 10);
  4567. return [wideNumeralData[_i][2], wideNumeralData[_i][j]];
  4568. } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) {
  4569. // dotless i or j
  4570. return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]];
  4571. } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) {
  4572. // Greek letters. Not supported, yet.
  4573. return ["", ""];
  4574. } else {
  4575. // We don't support any wide characters outside 1D400–1D7FF.
  4576. throw new ParseError("Unsupported character: " + wideChar);
  4577. }
  4578. };
  4579. /* eslint no-console:0 */
  4580. /**
  4581. * Looks up the given symbol in fontMetrics, after applying any symbol
  4582. * replacements defined in symbol.js
  4583. */
  4584. var lookupSymbol = function lookupSymbol(value,
  4585. // TODO(#963): Use a union type for this.
  4586. fontName, mode) {
  4587. // Replace the value with its replaced value from symbol.js
  4588. if (symbols[mode][value]) {
  4589. var replacement = symbols[mode][value].replace;
  4590. if (replacement) {
  4591. value = replacement;
  4592. }
  4593. }
  4594. return {
  4595. value,
  4596. metrics: getCharacterMetrics(value, fontName, mode)
  4597. };
  4598. };
  4599. /**
  4600. * Makes a symbolNode after translation via the list of symbols in symbols.js.
  4601. * Correctly pulls out metrics for the character, and optionally takes a list of
  4602. * classes to be attached to the node.
  4603. *
  4604. * TODO: make argument order closer to makeSpan
  4605. * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
  4606. * should if present come first in `classes`.
  4607. * TODO(#953): Make `options` mandatory and always pass it in.
  4608. */
  4609. var makeSymbol = function makeSymbol(value, fontName, mode, options, classes) {
  4610. var lookup = lookupSymbol(value, fontName, mode);
  4611. var metrics = lookup.metrics;
  4612. value = lookup.value;
  4613. var symbolNode;
  4614. if (metrics) {
  4615. var italic = metrics.italic;
  4616. if (mode === "text" || options && options.font === "mathit") {
  4617. italic = 0;
  4618. }
  4619. symbolNode = new SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes);
  4620. } else {
  4621. // TODO(emily): Figure out a good way to only print this in development
  4622. typeof console !== "undefined" && console.warn("No character metrics " + ("for '" + value + "' in style '" + fontName + "' and mode '" + mode + "'"));
  4623. symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes);
  4624. }
  4625. if (options) {
  4626. symbolNode.maxFontSize = options.sizeMultiplier;
  4627. if (options.style.isTight()) {
  4628. symbolNode.classes.push("mtight");
  4629. }
  4630. var color = options.getColor();
  4631. if (color) {
  4632. symbolNode.style.color = color;
  4633. }
  4634. }
  4635. return symbolNode;
  4636. };
  4637. /**
  4638. * Makes a symbol in Main-Regular or AMS-Regular.
  4639. * Used for rel, bin, open, close, inner, and punct.
  4640. */
  4641. var mathsym = function mathsym(value, mode, options, classes) {
  4642. if (classes === void 0) {
  4643. classes = [];
  4644. }
  4645. // Decide what font to render the symbol in by its entry in the symbols
  4646. // table.
  4647. // Have a special case for when the value = \ because the \ is used as a
  4648. // textord in unsupported command errors but cannot be parsed as a regular
  4649. // text ordinal and is therefore not present as a symbol in the symbols
  4650. // table for text, as well as a special case for boldsymbol because it
  4651. // can be used for bold + and -
  4652. if (options.font === "boldsymbol" && lookupSymbol(value, "Main-Bold", mode).metrics) {
  4653. return makeSymbol(value, "Main-Bold", mode, options, classes.concat(["mathbf"]));
  4654. } else if (value === "\\" || symbols[mode][value].font === "main") {
  4655. return makeSymbol(value, "Main-Regular", mode, options, classes);
  4656. } else {
  4657. return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"]));
  4658. }
  4659. };
  4660. /**
  4661. * Determines which of the two font names (Main-Bold and Math-BoldItalic) and
  4662. * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol",
  4663. * depending on the symbol. Use this function instead of fontMap for font
  4664. * "boldsymbol".
  4665. */
  4666. var boldsymbol = function boldsymbol(value, mode, options, classes, type) {
  4667. if (type !== "textord" && lookupSymbol(value, "Math-BoldItalic", mode).metrics) {
  4668. return {
  4669. fontName: "Math-BoldItalic",
  4670. fontClass: "boldsymbol"
  4671. };
  4672. } else {
  4673. // Some glyphs do not exist in Math-BoldItalic so we need to use
  4674. // Main-Bold instead.
  4675. return {
  4676. fontName: "Main-Bold",
  4677. fontClass: "mathbf"
  4678. };
  4679. }
  4680. };
  4681. /**
  4682. * Makes either a mathord or textord in the correct font and color.
  4683. */
  4684. var makeOrd = function makeOrd(group, options, type) {
  4685. var mode = group.mode;
  4686. var text = group.text;
  4687. var classes = ["mord"];
  4688. // Math mode or Old font (i.e. \rm)
  4689. var isFont = mode === "math" || mode === "text" && options.font;
  4690. var fontOrFamily = isFont ? options.font : options.fontFamily;
  4691. var wideFontName = "";
  4692. var wideFontClass = "";
  4693. if (text.charCodeAt(0) === 0xD835) {
  4694. [wideFontName, wideFontClass] = wideCharacterFont(text, mode);
  4695. }
  4696. if (wideFontName.length > 0) {
  4697. // surrogate pairs get special treatment
  4698. return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass));
  4699. } else if (fontOrFamily) {
  4700. var fontName;
  4701. var fontClasses;
  4702. if (fontOrFamily === "boldsymbol") {
  4703. var fontData = boldsymbol(text, mode, options, classes, type);
  4704. fontName = fontData.fontName;
  4705. fontClasses = [fontData.fontClass];
  4706. } else if (isFont) {
  4707. fontName = fontMap[fontOrFamily].fontName;
  4708. fontClasses = [fontOrFamily];
  4709. } else {
  4710. fontName = retrieveTextFontName(fontOrFamily, options.fontWeight, options.fontShape);
  4711. fontClasses = [fontOrFamily, options.fontWeight, options.fontShape];
  4712. }
  4713. if (lookupSymbol(text, fontName, mode).metrics) {
  4714. return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses));
  4715. } else if (ligatures.hasOwnProperty(text) && fontName.slice(0, 10) === "Typewriter") {
  4716. // Deconstruct ligatures in monospace fonts (\texttt, \tt).
  4717. var parts = [];
  4718. for (var i = 0; i < text.length; i++) {
  4719. parts.push(makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses)));
  4720. }
  4721. return makeFragment(parts);
  4722. }
  4723. }
  4724. // Makes a symbol in the default font for mathords and textords.
  4725. if (type === "mathord") {
  4726. return makeSymbol(text, "Math-Italic", mode, options, classes.concat(["mathnormal"]));
  4727. } else if (type === "textord") {
  4728. var font = symbols[mode][text] && symbols[mode][text].font;
  4729. if (font === "ams") {
  4730. var _fontName = retrieveTextFontName("amsrm", options.fontWeight, options.fontShape);
  4731. return makeSymbol(text, _fontName, mode, options, classes.concat("amsrm", options.fontWeight, options.fontShape));
  4732. } else if (font === "main" || !font) {
  4733. var _fontName2 = retrieveTextFontName("textrm", options.fontWeight, options.fontShape);
  4734. return makeSymbol(text, _fontName2, mode, options, classes.concat(options.fontWeight, options.fontShape));
  4735. } else {
  4736. // fonts added by plugins
  4737. var _fontName3 = retrieveTextFontName(font, options.fontWeight, options.fontShape);
  4738. // We add font name as a css class
  4739. return makeSymbol(text, _fontName3, mode, options, classes.concat(_fontName3, options.fontWeight, options.fontShape));
  4740. }
  4741. } else {
  4742. throw new Error("unexpected type: " + type + " in makeOrd");
  4743. }
  4744. };
  4745. /**
  4746. * Returns true if subsequent symbolNodes have the same classes, skew, maxFont,
  4747. * and styles. For mathnormal text, the left node must also have zero italic
  4748. * correction so we don't lose spacing between combined glyphs.
  4749. */
  4750. var canCombine = (prev, next) => {
  4751. if (createClass(prev.classes) !== createClass(next.classes) || prev.skew !== next.skew || prev.maxFontSize !== next.maxFontSize || prev.italic !== 0 && prev.hasClass("mathnormal")) {
  4752. return false;
  4753. }
  4754. // If prev and next both are just "mbin"s or "mord"s we don't combine them
  4755. // so that the proper spacing can be preserved.
  4756. if (prev.classes.length === 1) {
  4757. var cls = prev.classes[0];
  4758. if (cls === "mbin" || cls === "mord") {
  4759. return false;
  4760. }
  4761. }
  4762. for (var key of Object.keys(prev.style)) {
  4763. if (prev.style[key] !== next.style[key]) {
  4764. return false;
  4765. }
  4766. }
  4767. for (var _key of Object.keys(next.style)) {
  4768. if (prev.style[_key] !== next.style[_key]) {
  4769. return false;
  4770. }
  4771. }
  4772. return true;
  4773. };
  4774. /**
  4775. * Combine consecutive domTree.symbolNodes into a single symbolNode.
  4776. * Note: this function mutates the argument.
  4777. */
  4778. var tryCombineChars = chars => {
  4779. for (var i = 0; i < chars.length - 1; i++) {
  4780. var prev = chars[i];
  4781. var next = chars[i + 1];
  4782. if (prev instanceof SymbolNode && next instanceof SymbolNode && canCombine(prev, next)) {
  4783. prev.text += next.text;
  4784. prev.height = Math.max(prev.height, next.height);
  4785. prev.depth = Math.max(prev.depth, next.depth);
  4786. // Use the last character's italic correction since we use
  4787. // it to add padding to the right of the span created from
  4788. // the combined characters.
  4789. prev.italic = next.italic;
  4790. chars.splice(i + 1, 1);
  4791. i--;
  4792. }
  4793. }
  4794. return chars;
  4795. };
  4796. /**
  4797. * Calculate the height, depth, and maxFontSize of an element based on its
  4798. * children.
  4799. */
  4800. var sizeElementFromChildren = function sizeElementFromChildren(elem) {
  4801. var height = 0;
  4802. var depth = 0;
  4803. var maxFontSize = 0;
  4804. for (var i = 0; i < elem.children.length; i++) {
  4805. var child = elem.children[i];
  4806. if (child.height > height) {
  4807. height = child.height;
  4808. }
  4809. if (child.depth > depth) {
  4810. depth = child.depth;
  4811. }
  4812. if (child.maxFontSize > maxFontSize) {
  4813. maxFontSize = child.maxFontSize;
  4814. }
  4815. }
  4816. elem.height = height;
  4817. elem.depth = depth;
  4818. elem.maxFontSize = maxFontSize;
  4819. };
  4820. /**
  4821. * Makes a span with the given list of classes, list of children, and options.
  4822. *
  4823. * TODO(#953): Ensure that `options` is always provided (currently some call
  4824. * sites don't pass it) and make the type below mandatory.
  4825. * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
  4826. * should if present come first in `classes`.
  4827. */
  4828. var makeSpan = function makeSpan(classes, children, options, style) {
  4829. var span = new Span(classes, children, options, style);
  4830. sizeElementFromChildren(span);
  4831. return span;
  4832. };
  4833. // SVG one is simpler -- doesn't require height, depth, max-font setting.
  4834. // This is also a separate method for typesafety.
  4835. var makeSvgSpan = (classes, children, options, style) => new Span(classes, children, options, style);
  4836. var makeLineSpan = function makeLineSpan(className, options, thickness) {
  4837. var line = makeSpan([className], [], options);
  4838. line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness);
  4839. line.style.borderBottomWidth = makeEm(line.height);
  4840. line.maxFontSize = 1.0;
  4841. return line;
  4842. };
  4843. /**
  4844. * Makes an anchor with the given href, list of classes, list of children,
  4845. * and options.
  4846. */
  4847. var makeAnchor = function makeAnchor(href, classes, children, options) {
  4848. var anchor = new Anchor(href, classes, children, options);
  4849. sizeElementFromChildren(anchor);
  4850. return anchor;
  4851. };
  4852. /**
  4853. * Makes a document fragment with the given list of children.
  4854. */
  4855. var makeFragment = function makeFragment(children) {
  4856. var fragment = new DocumentFragment(children);
  4857. sizeElementFromChildren(fragment);
  4858. return fragment;
  4859. };
  4860. /**
  4861. * Wraps group in a span if it's a document fragment, allowing to apply classes
  4862. * and styles
  4863. */
  4864. var wrapFragment = function wrapFragment(group, options) {
  4865. if (group instanceof DocumentFragment) {
  4866. return makeSpan([], [group], options);
  4867. }
  4868. return group;
  4869. };
  4870. // Computes the updated `children` list and the overall depth.
  4871. //
  4872. // This helper function for makeVList makes it easier to enforce type safety by
  4873. // allowing early exits (returns) in the logic.
  4874. var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) {
  4875. if (params.positionType === "individualShift") {
  4876. var oldChildren = params.children;
  4877. var children = [oldChildren[0]];
  4878. // Add in kerns to the list of params.children to get each element to be
  4879. // shifted to the correct specified shift
  4880. var _depth = -oldChildren[0].shift - oldChildren[0].elem.depth;
  4881. var currPos = _depth;
  4882. for (var i = 1; i < oldChildren.length; i++) {
  4883. var diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth;
  4884. var size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth);
  4885. currPos = currPos + diff;
  4886. children.push({
  4887. type: "kern",
  4888. size
  4889. });
  4890. children.push(oldChildren[i]);
  4891. }
  4892. return {
  4893. children,
  4894. depth: _depth
  4895. };
  4896. }
  4897. var depth;
  4898. if (params.positionType === "top") {
  4899. // We always start at the bottom, so calculate the bottom by adding up
  4900. // all the sizes
  4901. var bottom = params.positionData;
  4902. for (var _i = 0; _i < params.children.length; _i++) {
  4903. var child = params.children[_i];
  4904. bottom -= child.type === "kern" ? child.size : child.elem.height + child.elem.depth;
  4905. }
  4906. depth = bottom;
  4907. } else if (params.positionType === "bottom") {
  4908. depth = -params.positionData;
  4909. } else {
  4910. var firstChild = params.children[0];
  4911. if (firstChild.type !== "elem") {
  4912. throw new Error('First child must have type "elem".');
  4913. }
  4914. if (params.positionType === "shift") {
  4915. depth = -firstChild.elem.depth - params.positionData;
  4916. } else if (params.positionType === "firstBaseline") {
  4917. depth = -firstChild.elem.depth;
  4918. } else {
  4919. throw new Error("Invalid positionType " + params.positionType + ".");
  4920. }
  4921. }
  4922. return {
  4923. children: params.children,
  4924. depth
  4925. };
  4926. };
  4927. /**
  4928. * Makes a vertical list by stacking elements and kerns on top of each other.
  4929. * Allows for many different ways of specifying the positioning method.
  4930. *
  4931. * See VListParam documentation above.
  4932. */
  4933. var makeVList = function makeVList(params, options) {
  4934. var {
  4935. children,
  4936. depth
  4937. } = getVListChildrenAndDepth(params);
  4938. // Create a strut that is taller than any list item. The strut is added to
  4939. // each item, where it will determine the item's baseline. Since it has
  4940. // `overflow:hidden`, the strut's top edge will sit on the item's line box's
  4941. // top edge and the strut's bottom edge will sit on the item's baseline,
  4942. // with no additional line-height spacing. This allows the item baseline to
  4943. // be positioned precisely without worrying about font ascent and
  4944. // line-height.
  4945. var pstrutSize = 0;
  4946. for (var i = 0; i < children.length; i++) {
  4947. var child = children[i];
  4948. if (child.type === "elem") {
  4949. var elem = child.elem;
  4950. pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height);
  4951. }
  4952. }
  4953. pstrutSize += 2;
  4954. var pstrut = makeSpan(["pstrut"], []);
  4955. pstrut.style.height = makeEm(pstrutSize);
  4956. // Create a new list of actual children at the correct offsets
  4957. var realChildren = [];
  4958. var minPos = depth;
  4959. var maxPos = depth;
  4960. var currPos = depth;
  4961. for (var _i2 = 0; _i2 < children.length; _i2++) {
  4962. var _child = children[_i2];
  4963. if (_child.type === "kern") {
  4964. currPos += _child.size;
  4965. } else {
  4966. var _elem = _child.elem;
  4967. var classes = _child.wrapperClasses || [];
  4968. var style = _child.wrapperStyle || {};
  4969. var childWrap = makeSpan(classes, [pstrut, _elem], undefined, style);
  4970. childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth);
  4971. if (_child.marginLeft) {
  4972. childWrap.style.marginLeft = _child.marginLeft;
  4973. }
  4974. if (_child.marginRight) {
  4975. childWrap.style.marginRight = _child.marginRight;
  4976. }
  4977. realChildren.push(childWrap);
  4978. currPos += _elem.height + _elem.depth;
  4979. }
  4980. minPos = Math.min(minPos, currPos);
  4981. maxPos = Math.max(maxPos, currPos);
  4982. }
  4983. // The vlist contents go in a table-cell with `vertical-align:bottom`.
  4984. // This cell's bottom edge will determine the containing table's baseline
  4985. // without overly expanding the containing line-box.
  4986. var vlist = makeSpan(["vlist"], realChildren);
  4987. vlist.style.height = makeEm(maxPos);
  4988. // A second row is used if necessary to represent the vlist's depth.
  4989. var rows;
  4990. if (minPos < 0) {
  4991. // We will define depth in an empty span with display: table-cell.
  4992. // It should render with the height that we define. But Chrome, in
  4993. // contenteditable mode only, treats that span as if it contains some
  4994. // text content. And that min-height over-rides our desired height.
  4995. // So we put another empty span inside the depth strut span.
  4996. var emptySpan = makeSpan([], []);
  4997. var depthStrut = makeSpan(["vlist"], [emptySpan]);
  4998. depthStrut.style.height = makeEm(-minPos);
  4999. // Safari wants the first row to have inline content; otherwise it
  5000. // puts the bottom of the *second* row on the baseline.
  5001. var topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200b")]);
  5002. rows = [makeSpan(["vlist-r"], [vlist, topStrut]), makeSpan(["vlist-r"], [depthStrut])];
  5003. } else {
  5004. rows = [makeSpan(["vlist-r"], [vlist])];
  5005. }
  5006. var vtable = makeSpan(["vlist-t"], rows);
  5007. if (rows.length === 2) {
  5008. vtable.classes.push("vlist-t2");
  5009. }
  5010. vtable.height = maxPos;
  5011. vtable.depth = -minPos;
  5012. return vtable;
  5013. };
  5014. // Glue is a concept from TeX which is a flexible space between elements in
  5015. // either a vertical or horizontal list. In KaTeX, at least for now, it's
  5016. // static space between elements in a horizontal layout.
  5017. var makeGlue = (measurement, options) => {
  5018. // Make an empty span for the space
  5019. var rule = makeSpan(["mspace"], [], options);
  5020. var size = calculateSize(measurement, options);
  5021. rule.style.marginRight = makeEm(size);
  5022. return rule;
  5023. };
  5024. // Takes font options, and returns the appropriate fontLookup name
  5025. var retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeight, fontShape) {
  5026. var baseFontName = "";
  5027. switch (fontFamily) {
  5028. case "amsrm":
  5029. baseFontName = "AMS";
  5030. break;
  5031. case "textrm":
  5032. baseFontName = "Main";
  5033. break;
  5034. case "textsf":
  5035. baseFontName = "SansSerif";
  5036. break;
  5037. case "texttt":
  5038. baseFontName = "Typewriter";
  5039. break;
  5040. default:
  5041. baseFontName = fontFamily;
  5042. // use fonts added by a plugin
  5043. }
  5044. var fontStylesName;
  5045. if (fontWeight === "textbf" && fontShape === "textit") {
  5046. fontStylesName = "BoldItalic";
  5047. } else if (fontWeight === "textbf") {
  5048. fontStylesName = "Bold";
  5049. } else if (fontWeight === "textit") {
  5050. fontStylesName = "Italic";
  5051. } else {
  5052. fontStylesName = "Regular";
  5053. }
  5054. return baseFontName + "-" + fontStylesName;
  5055. };
  5056. /**
  5057. * Maps TeX font commands to objects containing:
  5058. * - variant: string used for "mathvariant" attribute in buildMathML.js
  5059. * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics
  5060. */
  5061. // A map between tex font commands an MathML mathvariant attribute values
  5062. var fontMap = {
  5063. // styles
  5064. "mathbf": {
  5065. variant: "bold",
  5066. fontName: "Main-Bold"
  5067. },
  5068. "mathrm": {
  5069. variant: "normal",
  5070. fontName: "Main-Regular"
  5071. },
  5072. "textit": {
  5073. variant: "italic",
  5074. fontName: "Main-Italic"
  5075. },
  5076. "mathit": {
  5077. variant: "italic",
  5078. fontName: "Main-Italic"
  5079. },
  5080. "mathnormal": {
  5081. variant: "italic",
  5082. fontName: "Math-Italic"
  5083. },
  5084. "mathsfit": {
  5085. variant: "sans-serif-italic",
  5086. fontName: "SansSerif-Italic"
  5087. },
  5088. // "boldsymbol" is missing because they require the use of multiple fonts:
  5089. // Math-BoldItalic and Main-Bold. This is handled by a special case in
  5090. // makeOrd which ends up calling boldsymbol.
  5091. // families
  5092. "mathbb": {
  5093. variant: "double-struck",
  5094. fontName: "AMS-Regular"
  5095. },
  5096. "mathcal": {
  5097. variant: "script",
  5098. fontName: "Caligraphic-Regular"
  5099. },
  5100. "mathfrak": {
  5101. variant: "fraktur",
  5102. fontName: "Fraktur-Regular"
  5103. },
  5104. "mathscr": {
  5105. variant: "script",
  5106. fontName: "Script-Regular"
  5107. },
  5108. "mathsf": {
  5109. variant: "sans-serif",
  5110. fontName: "SansSerif-Regular"
  5111. },
  5112. "mathtt": {
  5113. variant: "monospace",
  5114. fontName: "Typewriter-Regular"
  5115. }
  5116. };
  5117. var svgData = {
  5118. // path, width, height
  5119. vec: ["vec", 0.471, 0.714],
  5120. // values from the font glyph
  5121. oiintSize1: ["oiintSize1", 0.957, 0.499],
  5122. // oval to overlay the integrand
  5123. oiintSize2: ["oiintSize2", 1.472, 0.659],
  5124. oiiintSize1: ["oiiintSize1", 1.304, 0.499],
  5125. oiiintSize2: ["oiiintSize2", 1.98, 0.659]
  5126. };
  5127. var staticSvg = function staticSvg(value, options) {
  5128. // Create a span with inline SVG for the element.
  5129. var [pathName, width, height] = svgData[value];
  5130. var path = new PathNode(pathName);
  5131. var svgNode = new SvgNode([path], {
  5132. "width": makeEm(width),
  5133. "height": makeEm(height),
  5134. // Override CSS rule `.katex svg { width: 100% }`
  5135. "style": "width:" + makeEm(width),
  5136. "viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
  5137. "preserveAspectRatio": "xMinYMin"
  5138. });
  5139. var span = makeSvgSpan(["overlay"], [svgNode], options);
  5140. span.height = height;
  5141. span.style.height = makeEm(height);
  5142. span.style.width = makeEm(width);
  5143. return span;
  5144. };
  5145. var thinspace = {
  5146. number: 3,
  5147. unit: "mu"
  5148. };
  5149. var mediumspace = {
  5150. number: 4,
  5151. unit: "mu"
  5152. };
  5153. var thickspace = {
  5154. number: 5,
  5155. unit: "mu"
  5156. };
  5157. // Spacing relationships for display and text styles
  5158. var spacings = {
  5159. mord: {
  5160. mop: thinspace,
  5161. mbin: mediumspace,
  5162. mrel: thickspace,
  5163. minner: thinspace
  5164. },
  5165. mop: {
  5166. mord: thinspace,
  5167. mop: thinspace,
  5168. mrel: thickspace,
  5169. minner: thinspace
  5170. },
  5171. mbin: {
  5172. mord: mediumspace,
  5173. mop: mediumspace,
  5174. mopen: mediumspace,
  5175. minner: mediumspace
  5176. },
  5177. mrel: {
  5178. mord: thickspace,
  5179. mop: thickspace,
  5180. mopen: thickspace,
  5181. minner: thickspace
  5182. },
  5183. mopen: {},
  5184. mclose: {
  5185. mop: thinspace,
  5186. mbin: mediumspace,
  5187. mrel: thickspace,
  5188. minner: thinspace
  5189. },
  5190. mpunct: {
  5191. mord: thinspace,
  5192. mop: thinspace,
  5193. mrel: thickspace,
  5194. mopen: thinspace,
  5195. mclose: thinspace,
  5196. mpunct: thinspace,
  5197. minner: thinspace
  5198. },
  5199. minner: {
  5200. mord: thinspace,
  5201. mop: thinspace,
  5202. mbin: mediumspace,
  5203. mrel: thickspace,
  5204. mopen: thinspace,
  5205. mpunct: thinspace,
  5206. minner: thinspace
  5207. }
  5208. };
  5209. // Spacing relationships for script and scriptscript styles
  5210. var tightSpacings = {
  5211. mord: {
  5212. mop: thinspace
  5213. },
  5214. mop: {
  5215. mord: thinspace,
  5216. mop: thinspace
  5217. },
  5218. mbin: {},
  5219. mrel: {},
  5220. mopen: {},
  5221. mclose: {
  5222. mop: thinspace
  5223. },
  5224. mpunct: {},
  5225. minner: {
  5226. mop: thinspace
  5227. }
  5228. };
  5229. /**
  5230. * All registered functions.
  5231. * `functions.js` just exports this same dictionary again and makes it public.
  5232. * `Parser.js` requires this dictionary.
  5233. */
  5234. var _functions = {};
  5235. /**
  5236. * All HTML builders. Should be only used in the `define*` and the `build*ML`
  5237. * functions.
  5238. */
  5239. var _htmlGroupBuilders = {};
  5240. /**
  5241. * All MathML builders. Should be only used in the `define*` and the `build*ML`
  5242. * functions.
  5243. */
  5244. var _mathmlGroupBuilders = {};
  5245. function defineFunction(_ref) {
  5246. var {
  5247. type,
  5248. names,
  5249. props,
  5250. handler,
  5251. htmlBuilder,
  5252. mathmlBuilder
  5253. } = _ref;
  5254. // Set default values of functions
  5255. var data = {
  5256. type,
  5257. numArgs: props.numArgs,
  5258. argTypes: props.argTypes,
  5259. allowedInArgument: !!props.allowedInArgument,
  5260. allowedInText: !!props.allowedInText,
  5261. allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath,
  5262. numOptionalArgs: props.numOptionalArgs || 0,
  5263. infix: !!props.infix,
  5264. primitive: !!props.primitive,
  5265. handler
  5266. };
  5267. for (var i = 0; i < names.length; ++i) {
  5268. _functions[names[i]] = data;
  5269. }
  5270. if (type) {
  5271. if (htmlBuilder) {
  5272. _htmlGroupBuilders[type] = htmlBuilder;
  5273. }
  5274. if (mathmlBuilder) {
  5275. _mathmlGroupBuilders[type] = mathmlBuilder;
  5276. }
  5277. }
  5278. }
  5279. /**
  5280. * Use this to register only the HTML and MathML builders for a function (e.g.
  5281. * if the function's ParseNode is generated in Parser.js rather than via a
  5282. * stand-alone handler provided to `defineFunction`).
  5283. */
  5284. function defineFunctionBuilders(_ref2) {
  5285. var {
  5286. type,
  5287. htmlBuilder,
  5288. mathmlBuilder
  5289. } = _ref2;
  5290. defineFunction({
  5291. type,
  5292. names: [],
  5293. props: {
  5294. numArgs: 0
  5295. },
  5296. handler() {
  5297. throw new Error('Should never be called.');
  5298. },
  5299. htmlBuilder,
  5300. mathmlBuilder
  5301. });
  5302. }
  5303. var normalizeArgument = function normalizeArgument(arg) {
  5304. return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg;
  5305. };
  5306. // Since the corresponding buildHTML/buildMathML function expects a
  5307. // list of elements, we normalize for different kinds of arguments
  5308. var ordargument = function ordargument(arg) {
  5309. return arg.type === "ordgroup" ? arg.body : [arg];
  5310. };
  5311. /**
  5312. * This file does the main work of building a domTree structure from a parse
  5313. * tree. The entry point is the `buildHTML` function, which takes a parse tree.
  5314. * Then, the buildExpression, buildGroup, and various groupBuilders functions
  5315. * are called, to produce a final HTML tree.
  5316. */
  5317. // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`)
  5318. // depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6,
  5319. // and the text before Rule 19.
  5320. var binLeftCanceller = new Set(["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"]);
  5321. var binRightCanceller = new Set(["rightmost", "mrel", "mclose", "mpunct"]);
  5322. var styleMap$1 = {
  5323. "display": Style$1.DISPLAY,
  5324. "text": Style$1.TEXT,
  5325. "script": Style$1.SCRIPT,
  5326. "scriptscript": Style$1.SCRIPTSCRIPT
  5327. };
  5328. var DomEnum = {
  5329. mord: "mord",
  5330. mop: "mop",
  5331. mbin: "mbin",
  5332. mrel: "mrel",
  5333. mopen: "mopen",
  5334. mclose: "mclose",
  5335. mpunct: "mpunct",
  5336. minner: "minner"
  5337. };
  5338. /**
  5339. * Take a list of nodes, build them in order, and return a list of the built
  5340. * nodes. documentFragments are flattened into their contents, so the
  5341. * returned list contains no fragments. `isRealGroup` is true if `expression`
  5342. * is a real group (no atoms will be added on either side), as opposed to
  5343. * a partial group (e.g. one created by \color). `surrounding` is an array
  5344. * consisting type of nodes that will be added to the left and right.
  5345. */
  5346. var buildExpression$1 = function buildExpression(expression, options, isRealGroup, surrounding) {
  5347. if (surrounding === void 0) {
  5348. surrounding = [null, null];
  5349. }
  5350. // Parse expressions into `groups`.
  5351. var groups = [];
  5352. for (var i = 0; i < expression.length; i++) {
  5353. var output = buildGroup$1(expression[i], options);
  5354. if (output instanceof DocumentFragment) {
  5355. var children = output.children;
  5356. groups.push(...children);
  5357. } else {
  5358. groups.push(output);
  5359. }
  5360. }
  5361. // Combine consecutive domTree.symbolNodes into a single symbolNode.
  5362. tryCombineChars(groups);
  5363. // If `expression` is a partial group, let the parent handle spacings
  5364. // to avoid processing groups multiple times.
  5365. if (!isRealGroup) {
  5366. return groups;
  5367. }
  5368. var glueOptions = options;
  5369. if (expression.length === 1) {
  5370. var node = expression[0];
  5371. if (node.type === "sizing") {
  5372. glueOptions = options.havingSize(node.size);
  5373. } else if (node.type === "styling") {
  5374. glueOptions = options.havingStyle(styleMap$1[node.style]);
  5375. }
  5376. }
  5377. // Dummy spans for determining spacings between surrounding atoms.
  5378. // If `expression` has no atoms on the left or right, class "leftmost"
  5379. // or "rightmost", respectively, is used to indicate it.
  5380. var dummyPrev = makeSpan([surrounding[0] || "leftmost"], [], options);
  5381. var dummyNext = makeSpan([surrounding[1] || "rightmost"], [], options);
  5382. // TODO: These code assumes that a node's math class is the first element
  5383. // of its `classes` array. A later cleanup should ensure this, for
  5384. // instance by changing the signature of `makeSpan`.
  5385. // Before determining what spaces to insert, perform bin cancellation.
  5386. // Binary operators change to ordinary symbols in some contexts.
  5387. var isRoot = isRealGroup === "root";
  5388. _traverseNonSpaceNodes(groups, (node, prev) => {
  5389. var prevType = prev.classes[0];
  5390. var type = node.classes[0];
  5391. if (prevType === "mbin" && binRightCanceller.has(type)) {
  5392. prev.classes[0] = "mord";
  5393. } else if (type === "mbin" && binLeftCanceller.has(prevType)) {
  5394. node.classes[0] = "mord";
  5395. }
  5396. }, {
  5397. node: dummyPrev
  5398. }, dummyNext, isRoot);
  5399. _traverseNonSpaceNodes(groups, (node, prev) => {
  5400. var _tightSpacings$prevTy, _spacings$prevType;
  5401. var prevType = getTypeOfDomTree(prev);
  5402. var type = getTypeOfDomTree(node);
  5403. // 'mtight' indicates that the node is script or scriptscript style.
  5404. var space = prevType && type ? node.hasClass("mtight") ? (_tightSpacings$prevTy = tightSpacings[prevType]) == null ? void 0 : _tightSpacings$prevTy[type] : (_spacings$prevType = spacings[prevType]) == null ? void 0 : _spacings$prevType[type] : null;
  5405. if (space) {
  5406. // Insert glue (spacing) after the `prev`.
  5407. return makeGlue(space, glueOptions);
  5408. }
  5409. }, {
  5410. node: dummyPrev
  5411. }, dummyNext, isRoot);
  5412. return groups;
  5413. };
  5414. // Depth-first traverse non-space `nodes`, calling `callback` with the current and
  5415. // previous node as arguments, optionally returning a node to insert after the
  5416. // previous node. `prev` is an object with the previous node and `insertAfter`
  5417. // function to insert after it. `next` is a node that will be added to the right.
  5418. // Used for bin cancellation and inserting spacings.
  5419. var _traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev, next, isRoot) {
  5420. if (next) {
  5421. // temporarily append the right node, if exists
  5422. nodes.push(next);
  5423. }
  5424. var i = 0;
  5425. for (; i < nodes.length; i++) {
  5426. var node = nodes[i];
  5427. var partialGroup = checkPartialGroup(node);
  5428. if (partialGroup) {
  5429. // Recursive DFS
  5430. // TODO(ts): make nodes a $ReadOnlyArray by returning a new array
  5431. _traverseNonSpaceNodes(partialGroup.children, callback, prev, null, isRoot);
  5432. continue;
  5433. }
  5434. // Ignore explicit spaces (e.g., \;, \,) when determining what implicit
  5435. // spacing should go between atoms of different classes
  5436. var nonspace = !node.hasClass("mspace");
  5437. if (nonspace) {
  5438. var result = callback(node, prev.node);
  5439. if (result) {
  5440. if (prev.insertAfter) {
  5441. prev.insertAfter(result);
  5442. } else {
  5443. // insert at front
  5444. nodes.unshift(result);
  5445. i++;
  5446. }
  5447. }
  5448. }
  5449. if (nonspace) {
  5450. prev.node = node;
  5451. } else if (isRoot && node.hasClass("newline")) {
  5452. prev.node = makeSpan(["leftmost"]); // treat like beginning of line
  5453. }
  5454. prev.insertAfter = (index => n => {
  5455. nodes.splice(index + 1, 0, n);
  5456. i++;
  5457. })(i);
  5458. }
  5459. if (next) {
  5460. nodes.pop();
  5461. }
  5462. };
  5463. // Check if given node is a partial group, i.e., does not affect spacing around.
  5464. var checkPartialGroup = function checkPartialGroup(node) {
  5465. if (node instanceof DocumentFragment || node instanceof Anchor || node instanceof Span && node.hasClass("enclosing")) {
  5466. return node;
  5467. }
  5468. return null;
  5469. };
  5470. // Return the outermost node of a domTree.
  5471. var _getOutermostNode = function getOutermostNode(node, side) {
  5472. var partialGroup = checkPartialGroup(node);
  5473. if (partialGroup) {
  5474. var children = partialGroup.children;
  5475. if (children.length) {
  5476. if (side === "right") {
  5477. return _getOutermostNode(children[children.length - 1], "right");
  5478. } else if (side === "left") {
  5479. return _getOutermostNode(children[0], "left");
  5480. }
  5481. }
  5482. }
  5483. return node;
  5484. };
  5485. // Return math atom class (mclass) of a domTree.
  5486. // If `side` is given, it will get the type of the outermost node at given side.
  5487. var getTypeOfDomTree = function getTypeOfDomTree(node, side) {
  5488. if (!node) {
  5489. return null;
  5490. }
  5491. if (side) {
  5492. node = _getOutermostNode(node, side);
  5493. }
  5494. // This makes a lot of assumptions as to where the type of atom
  5495. // appears. We should do a better job of enforcing this.
  5496. var className = node.classes[0];
  5497. return DomEnum[className] || null;
  5498. };
  5499. var makeNullDelimiter = function makeNullDelimiter(options, classes) {
  5500. var moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses());
  5501. return makeSpan(classes.concat(moreClasses));
  5502. };
  5503. /**
  5504. * buildGroup is the function that takes a group and calls the correct groupType
  5505. * function for it. It also handles the interaction of size and style changes
  5506. * between parents and children.
  5507. */
  5508. var buildGroup$1 = function buildGroup(group, options, baseOptions) {
  5509. if (!group) {
  5510. return makeSpan();
  5511. }
  5512. if (_htmlGroupBuilders[group.type]) {
  5513. // Call the groupBuilders function
  5514. // TODO(ts)
  5515. var groupNode = _htmlGroupBuilders[group.type](group, options);
  5516. // If the size changed between the parent and the current group, account
  5517. // for that size difference.
  5518. if (baseOptions && options.size !== baseOptions.size) {
  5519. groupNode = makeSpan(options.sizingClasses(baseOptions), [groupNode], options);
  5520. var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier;
  5521. groupNode.height *= multiplier;
  5522. groupNode.depth *= multiplier;
  5523. }
  5524. return groupNode;
  5525. } else {
  5526. throw new ParseError("Got group of unknown type: '" + group.type + "'");
  5527. }
  5528. };
  5529. /**
  5530. * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`)
  5531. * into an unbreakable HTML node of class .base, with proper struts to
  5532. * guarantee correct vertical extent. `buildHTML` calls this repeatedly to
  5533. * make up the entire expression as a sequence of unbreakable units.
  5534. */
  5535. function buildHTMLUnbreakable(children, options) {
  5536. // Compute height and depth of this chunk.
  5537. var body = makeSpan(["base"], children, options);
  5538. // Add strut, which ensures that the top of the HTML element falls at
  5539. // the height of the expression, and the bottom of the HTML element
  5540. // falls at the depth of the expression.
  5541. var strut = makeSpan(["strut"]);
  5542. strut.style.height = makeEm(body.height + body.depth);
  5543. if (body.depth) {
  5544. strut.style.verticalAlign = makeEm(-body.depth);
  5545. }
  5546. body.children.unshift(strut);
  5547. return body;
  5548. }
  5549. /**
  5550. * Take an entire parse tree, and build it into an appropriate set of HTML
  5551. * nodes.
  5552. */
  5553. function buildHTML(tree, options) {
  5554. // Strip off outer tag wrapper for processing below.
  5555. var tag = null;
  5556. if (tree.length === 1 && tree[0].type === "tag") {
  5557. tag = tree[0].tag;
  5558. tree = tree[0].body;
  5559. }
  5560. // Build the expression contained in the tree
  5561. var expression = buildExpression$1(tree, options, "root");
  5562. var eqnNum;
  5563. if (expression.length === 2 && expression[1].hasClass("tag")) {
  5564. // An environment with automatic equation numbers, e.g. {gather}.
  5565. eqnNum = expression.pop();
  5566. }
  5567. var children = [];
  5568. // Create one base node for each chunk between potential line breaks.
  5569. // The TeXBook [p.173] says "A formula will be broken only after a
  5570. // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary
  5571. // operation symbol like $+$ or $-$ or $\times$, where the relation or
  5572. // binary operation is on the ``outer level'' of the formula (i.e., not
  5573. // enclosed in {...} and not part of an \over construction)."
  5574. var parts = [];
  5575. for (var i = 0; i < expression.length; i++) {
  5576. parts.push(expression[i]);
  5577. if (expression[i].hasClass("mbin") || expression[i].hasClass("mrel") || expression[i].hasClass("allowbreak")) {
  5578. // Put any post-operator glue on same line as operator.
  5579. // Watch for \nobreak along the way, and stop at \newline.
  5580. var nobreak = false;
  5581. while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) {
  5582. i++;
  5583. parts.push(expression[i]);
  5584. if (expression[i].hasClass("nobreak")) {
  5585. nobreak = true;
  5586. }
  5587. }
  5588. // Don't allow break if \nobreak among the post-operator glue.
  5589. if (!nobreak) {
  5590. children.push(buildHTMLUnbreakable(parts, options));
  5591. parts = [];
  5592. }
  5593. } else if (expression[i].hasClass("newline")) {
  5594. // Write the line except the newline
  5595. parts.pop();
  5596. if (parts.length > 0) {
  5597. children.push(buildHTMLUnbreakable(parts, options));
  5598. parts = [];
  5599. }
  5600. // Put the newline at the top level
  5601. children.push(expression[i]);
  5602. }
  5603. }
  5604. if (parts.length > 0) {
  5605. children.push(buildHTMLUnbreakable(parts, options));
  5606. }
  5607. // Now, if there was a tag, build it too and append it as a final child.
  5608. var tagChild;
  5609. if (tag) {
  5610. tagChild = buildHTMLUnbreakable(buildExpression$1(tag, options, true), options);
  5611. tagChild.classes = ["tag"];
  5612. children.push(tagChild);
  5613. } else if (eqnNum) {
  5614. children.push(eqnNum);
  5615. }
  5616. var htmlNode = makeSpan(["katex-html"], children);
  5617. htmlNode.setAttribute("aria-hidden", "true");
  5618. // Adjust the strut of the tag to be the maximum height of all children
  5619. // (the height of the enclosing htmlNode) for proper vertical alignment.
  5620. if (tagChild) {
  5621. var strut = tagChild.children[0];
  5622. strut.style.height = makeEm(htmlNode.height + htmlNode.depth);
  5623. if (htmlNode.depth) {
  5624. strut.style.verticalAlign = makeEm(-htmlNode.depth);
  5625. }
  5626. }
  5627. return htmlNode;
  5628. }
  5629. /**
  5630. * These objects store data about MathML nodes. This is the MathML equivalent
  5631. * of the types in domTree.js. Since MathML handles its own rendering, and
  5632. * since we're mainly using MathML to improve accessibility, we don't manage
  5633. * any of the styling state that the plain DOM nodes do.
  5634. *
  5635. * The `toNode` and `toMarkup` functions work similarly to how they do in
  5636. * domTree.js, creating namespaced DOM nodes and HTML text markup respectively.
  5637. */
  5638. function newDocumentFragment(children) {
  5639. return new DocumentFragment(children);
  5640. }
  5641. /**
  5642. * This node represents a general purpose MathML node of any type. The
  5643. * constructor requires the type of node to create (for example, `"mo"` or
  5644. * `"mspace"`, corresponding to `<mo>` and `<mspace>` tags).
  5645. */
  5646. class MathNode {
  5647. constructor(type, children, classes) {
  5648. this.type = type;
  5649. this.attributes = {};
  5650. this.children = children || [];
  5651. this.classes = classes || [];
  5652. }
  5653. /**
  5654. * Sets an attribute on a MathML node. MathML depends on attributes to convey a
  5655. * semantic content, so this is used heavily.
  5656. */
  5657. setAttribute(name, value) {
  5658. this.attributes[name] = value;
  5659. }
  5660. /**
  5661. * Gets an attribute on a MathML node.
  5662. */
  5663. getAttribute(name) {
  5664. return this.attributes[name];
  5665. }
  5666. /**
  5667. * Converts the math node into a MathML-namespaced DOM element.
  5668. */
  5669. toNode() {
  5670. var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type);
  5671. for (var attr in this.attributes) {
  5672. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  5673. node.setAttribute(attr, this.attributes[attr]);
  5674. }
  5675. }
  5676. if (this.classes.length > 0) {
  5677. node.className = createClass(this.classes);
  5678. }
  5679. for (var i = 0; i < this.children.length; i++) {
  5680. // Combine multiple TextNodes into one TextNode, to prevent
  5681. // screen readers from reading each as a separate word [#3995]
  5682. if (this.children[i] instanceof TextNode && this.children[i + 1] instanceof TextNode) {
  5683. var text = this.children[i].toText() + this.children[++i].toText();
  5684. while (this.children[i + 1] instanceof TextNode) {
  5685. text += this.children[++i].toText();
  5686. }
  5687. node.appendChild(new TextNode(text).toNode());
  5688. } else {
  5689. node.appendChild(this.children[i].toNode());
  5690. }
  5691. }
  5692. return node;
  5693. }
  5694. /**
  5695. * Converts the math node into an HTML markup string.
  5696. */
  5697. toMarkup() {
  5698. var markup = "<" + this.type;
  5699. // Add the attributes
  5700. for (var attr in this.attributes) {
  5701. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  5702. markup += " " + attr + "=\"";
  5703. markup += escape(this.attributes[attr]);
  5704. markup += "\"";
  5705. }
  5706. }
  5707. if (this.classes.length > 0) {
  5708. markup += " class =\"" + escape(createClass(this.classes)) + "\"";
  5709. }
  5710. markup += ">";
  5711. for (var i = 0; i < this.children.length; i++) {
  5712. markup += this.children[i].toMarkup();
  5713. }
  5714. markup += "</" + this.type + ">";
  5715. return markup;
  5716. }
  5717. /**
  5718. * Converts the math node into a string, similar to innerText, but escaped.
  5719. */
  5720. toText() {
  5721. return this.children.map(child => child.toText()).join("");
  5722. }
  5723. }
  5724. /**
  5725. * This node represents a piece of text.
  5726. */
  5727. class TextNode {
  5728. constructor(text) {
  5729. this.text = text;
  5730. }
  5731. /**
  5732. * Converts the text node into a DOM text node.
  5733. */
  5734. toNode() {
  5735. return document.createTextNode(this.text);
  5736. }
  5737. /**
  5738. * Converts the text node into escaped HTML markup
  5739. * (representing the text itself).
  5740. */
  5741. toMarkup() {
  5742. return escape(this.toText());
  5743. }
  5744. /**
  5745. * Converts the text node into a string
  5746. * (representing the text itself).
  5747. */
  5748. toText() {
  5749. return this.text;
  5750. }
  5751. }
  5752. /**
  5753. * This node represents a space, but may render as <mspace.../> or as text,
  5754. * depending on the width.
  5755. */
  5756. class SpaceNode {
  5757. /**
  5758. * Create a Space node with width given in CSS ems.
  5759. */
  5760. constructor(width) {
  5761. this.width = width;
  5762. // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html
  5763. // for a table of space-like characters. We use Unicode
  5764. // representations instead of &LongNames; as it's not clear how to
  5765. // make the latter via document.createTextNode.
  5766. if (width >= 0.05555 && width <= 0.05556) {
  5767. this.character = "\u200a"; // &VeryThinSpace;
  5768. } else if (width >= 0.1666 && width <= 0.1667) {
  5769. this.character = "\u2009"; // &ThinSpace;
  5770. } else if (width >= 0.2222 && width <= 0.2223) {
  5771. this.character = "\u2005"; // &MediumSpace;
  5772. } else if (width >= 0.2777 && width <= 0.2778) {
  5773. this.character = "\u2005\u200a"; // &ThickSpace;
  5774. } else if (width >= -0.05556 && width <= -0.05555) {
  5775. this.character = "\u200a\u2063"; // &NegativeVeryThinSpace;
  5776. } else if (width >= -0.1667 && width <= -0.1666) {
  5777. this.character = "\u2009\u2063"; // &NegativeThinSpace;
  5778. } else if (width >= -0.2223 && width <= -0.2222) {
  5779. this.character = "\u205f\u2063"; // &NegativeMediumSpace;
  5780. } else if (width >= -0.2778 && width <= -0.2777) {
  5781. this.character = "\u2005\u2063"; // &NegativeThickSpace;
  5782. } else {
  5783. this.character = null;
  5784. }
  5785. }
  5786. /**
  5787. * Converts the math node into a MathML-namespaced DOM element.
  5788. */
  5789. toNode() {
  5790. if (this.character) {
  5791. return document.createTextNode(this.character);
  5792. } else {
  5793. var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace");
  5794. node.setAttribute("width", makeEm(this.width));
  5795. return node;
  5796. }
  5797. }
  5798. /**
  5799. * Converts the math node into an HTML markup string.
  5800. */
  5801. toMarkup() {
  5802. if (this.character) {
  5803. return "<mtext>" + this.character + "</mtext>";
  5804. } else {
  5805. return "<mspace width=\"" + makeEm(this.width) + "\"/>";
  5806. }
  5807. }
  5808. /**
  5809. * Converts the math node into a string, similar to innerText.
  5810. */
  5811. toText() {
  5812. if (this.character) {
  5813. return this.character;
  5814. } else {
  5815. return " ";
  5816. }
  5817. }
  5818. }
  5819. /**
  5820. * This file converts a parse tree into a corresponding MathML tree. The main
  5821. * entry point is the `buildMathML` function, which takes a parse tree from the
  5822. * parser.
  5823. */
  5824. var noVariantSymbols = new Set(["\\imath", "\\jmath"]);
  5825. var rowLikeTypes = new Set(["mrow", "mtable"]);
  5826. /**
  5827. * Takes a symbol and converts it into a MathML text node after performing
  5828. * optional replacement from symbols.js.
  5829. */
  5830. var makeText = function makeText(text, mode, options) {
  5831. if (symbols[mode][text] && 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"))) {
  5832. text = symbols[mode][text].replace;
  5833. }
  5834. return new TextNode(text);
  5835. };
  5836. /**
  5837. * Wrap the given array of nodes in an <mrow> node if needed, i.e.,
  5838. * unless the array has length 1. Always returns a single node.
  5839. */
  5840. var makeRow = function makeRow(body) {
  5841. if (body.length === 1) {
  5842. return body[0];
  5843. } else {
  5844. return new MathNode("mrow", body);
  5845. }
  5846. };
  5847. /**
  5848. * Returns the math variant as a string or null if none is required.
  5849. */
  5850. var getVariant = function getVariant(group, options) {
  5851. // Handle \text... font specifiers as best we can.
  5852. // MathML has a limited list of allowable mathvariant specifiers; see
  5853. // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt
  5854. if (options.fontFamily === "texttt") {
  5855. return "monospace";
  5856. } else if (options.fontFamily === "textsf") {
  5857. if (options.fontShape === "textit" && options.fontWeight === "textbf") {
  5858. return "sans-serif-bold-italic";
  5859. } else if (options.fontShape === "textit") {
  5860. return "sans-serif-italic";
  5861. } else if (options.fontWeight === "textbf") {
  5862. return "bold-sans-serif";
  5863. } else {
  5864. return "sans-serif";
  5865. }
  5866. } else if (options.fontShape === "textit" && options.fontWeight === "textbf") {
  5867. return "bold-italic";
  5868. } else if (options.fontShape === "textit") {
  5869. return "italic";
  5870. } else if (options.fontWeight === "textbf") {
  5871. return "bold";
  5872. }
  5873. var font = options.font;
  5874. if (!font || font === "mathnormal") {
  5875. return null;
  5876. }
  5877. var mode = group.mode;
  5878. if (font === "mathit") {
  5879. return "italic";
  5880. } else if (font === "boldsymbol") {
  5881. return group.type === "textord" ? "bold" : "bold-italic";
  5882. } else if (font === "mathbf") {
  5883. return "bold";
  5884. } else if (font === "mathbb") {
  5885. return "double-struck";
  5886. } else if (font === "mathsfit") {
  5887. return "sans-serif-italic";
  5888. } else if (font === "mathfrak") {
  5889. return "fraktur";
  5890. } else if (font === "mathscr" || font === "mathcal") {
  5891. // MathML makes no distinction between script and calligraphic
  5892. return "script";
  5893. } else if (font === "mathsf") {
  5894. return "sans-serif";
  5895. } else if (font === "mathtt") {
  5896. return "monospace";
  5897. }
  5898. var text = group.text;
  5899. if (noVariantSymbols.has(text)) {
  5900. return null;
  5901. }
  5902. if (symbols[mode][text]) {
  5903. var replacement = symbols[mode][text].replace;
  5904. if (replacement) {
  5905. text = replacement;
  5906. }
  5907. }
  5908. var fontName = fontMap[font].fontName;
  5909. if (getCharacterMetrics(text, fontName, mode)) {
  5910. return fontMap[font].variant;
  5911. }
  5912. return null;
  5913. };
  5914. /**
  5915. * Check for <mi>.</mi> which is how a dot renders in MathML,
  5916. * or <mo separator="true" lspace="0em" rspace="0em">,</mo>
  5917. * which is how a braced comma {,} renders in MathML
  5918. */
  5919. function isNumberPunctuation(group) {
  5920. if (!group) {
  5921. return false;
  5922. }
  5923. if (group.type === 'mi' && group.children.length === 1) {
  5924. var child = group.children[0];
  5925. return child instanceof TextNode && child.text === '.';
  5926. } else if (group.type === 'mo' && group.children.length === 1 && group.getAttribute('separator') === 'true' && group.getAttribute('lspace') === '0em' && group.getAttribute('rspace') === '0em') {
  5927. var _child = group.children[0];
  5928. return _child instanceof TextNode && _child.text === ',';
  5929. } else {
  5930. return false;
  5931. }
  5932. }
  5933. /**
  5934. * Takes a list of nodes, builds them, and returns a list of the generated
  5935. * MathML nodes. Also combine consecutive <mtext> outputs into a single
  5936. * <mtext> tag.
  5937. */
  5938. var buildExpression = function buildExpression(expression, options, isOrdgroup) {
  5939. if (expression.length === 1) {
  5940. var group = buildGroup(expression[0], options);
  5941. if (isOrdgroup && group instanceof MathNode && group.type === "mo") {
  5942. // When TeX writers want to suppress spacing on an operator,
  5943. // they often put the operator by itself inside braces.
  5944. group.setAttribute("lspace", "0em");
  5945. group.setAttribute("rspace", "0em");
  5946. }
  5947. return [group];
  5948. }
  5949. var groups = [];
  5950. var lastGroup;
  5951. for (var i = 0; i < expression.length; i++) {
  5952. var _group = buildGroup(expression[i], options);
  5953. if (_group instanceof MathNode && lastGroup instanceof MathNode) {
  5954. // Concatenate adjacent <mtext>s
  5955. if (_group.type === 'mtext' && lastGroup.type === 'mtext' && _group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) {
  5956. lastGroup.children.push(..._group.children);
  5957. continue;
  5958. // Concatenate adjacent <mn>s
  5959. } else if (_group.type === 'mn' && lastGroup.type === 'mn') {
  5960. lastGroup.children.push(..._group.children);
  5961. continue;
  5962. // Concatenate <mn>...</mn> followed by <mi>.</mi>
  5963. } else if (isNumberPunctuation(_group) && lastGroup.type === 'mn') {
  5964. lastGroup.children.push(..._group.children);
  5965. continue;
  5966. // Concatenate <mi>.</mi> followed by <mn>...</mn>
  5967. } else if (_group.type === 'mn' && isNumberPunctuation(lastGroup)) {
  5968. _group.children = [...lastGroup.children, ..._group.children];
  5969. groups.pop();
  5970. // Put preceding <mn>...</mn> or <mi>.</mi> inside base of
  5971. // <msup><mn>...base...</mn>...exponent...</msup> (or <msub>)
  5972. } else if ((_group.type === 'msup' || _group.type === 'msub') && _group.children.length >= 1 && (lastGroup.type === 'mn' || isNumberPunctuation(lastGroup))) {
  5973. var base = _group.children[0];
  5974. if (base instanceof MathNode && base.type === 'mn') {
  5975. base.children = [...lastGroup.children, ...base.children];
  5976. groups.pop();
  5977. }
  5978. // \not
  5979. } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) {
  5980. var lastChild = lastGroup.children[0];
  5981. if (lastChild instanceof TextNode && lastChild.text === '\u0338' && (_group.type === 'mo' || _group.type === 'mi' || _group.type === 'mn')) {
  5982. var child = _group.children[0];
  5983. if (child instanceof TextNode && child.text.length > 0) {
  5984. // Overlay with combining character long solidus
  5985. child.text = child.text.slice(0, 1) + "\u0338" + child.text.slice(1);
  5986. groups.pop();
  5987. }
  5988. }
  5989. }
  5990. }
  5991. groups.push(_group);
  5992. lastGroup = _group;
  5993. }
  5994. return groups;
  5995. };
  5996. /**
  5997. * Equivalent to buildExpression, but wraps the elements in an <mrow>
  5998. * if there's more than one. Returns a single node instead of an array.
  5999. */
  6000. var buildExpressionRow = function buildExpressionRow(expression, options, isOrdgroup) {
  6001. return makeRow(buildExpression(expression, options, isOrdgroup));
  6002. };
  6003. /**
  6004. * Takes a group from the parser and calls the appropriate groupBuilders function
  6005. * on it to produce a MathML node.
  6006. */
  6007. var buildGroup = function buildGroup(group, options) {
  6008. if (!group) {
  6009. return new MathNode("mrow");
  6010. }
  6011. if (_mathmlGroupBuilders[group.type]) {
  6012. // Call the groupBuilders function
  6013. // TODO(ts)
  6014. var result = _mathmlGroupBuilders[group.type](group, options);
  6015. // TODO(ts)
  6016. return result;
  6017. } else {
  6018. throw new ParseError("Got group of unknown type: '" + group.type + "'");
  6019. }
  6020. };
  6021. /**
  6022. * Takes a full parse tree and settings and builds a MathML representation of
  6023. * it. In particular, we put the elements from building the parse tree into a
  6024. * <semantics> tag so we can also include that TeX source as an annotation.
  6025. *
  6026. * Note that we actually return a domTree element with a `<math>` inside it so
  6027. * we can do appropriate styling.
  6028. */
  6029. function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) {
  6030. var expression = buildExpression(tree, options);
  6031. // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes
  6032. // and add spacing nodes. This is necessary only adjacent to math operators
  6033. // like \sin or \lim or to subsup elements that contain math operators.
  6034. // MathML takes care of the other spacing issues.
  6035. // Wrap up the expression in an mrow so it is presented in the semantics
  6036. // tag correctly, unless it's a single <mrow> or <mtable>.
  6037. var wrapper;
  6038. if (expression.length === 1 && expression[0] instanceof MathNode && rowLikeTypes.has(expression[0].type)) {
  6039. wrapper = expression[0];
  6040. } else {
  6041. wrapper = new MathNode("mrow", expression);
  6042. }
  6043. // Build a TeX annotation of the source
  6044. var annotation = new MathNode("annotation", [new TextNode(texExpression)]);
  6045. annotation.setAttribute("encoding", "application/x-tex");
  6046. var semantics = new MathNode("semantics", [wrapper, annotation]);
  6047. var math = new MathNode("math", [semantics]);
  6048. math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
  6049. if (isDisplayMode) {
  6050. math.setAttribute("display", "block");
  6051. }
  6052. // You can't style <math> nodes, so we wrap the node in a span.
  6053. // NOTE: The span class is not typed to have <math> nodes as children, and
  6054. // we don't want to make the children type more generic since the children
  6055. // of span are expected to have more fields in `buildHtml` contexts.
  6056. var wrapperClass = forMathmlOnly ? "katex" : "katex-mathml";
  6057. // TODO(ts)
  6058. return makeSpan([wrapperClass], [math]);
  6059. }
  6060. /**
  6061. * This file contains information about the options that the Parser carries
  6062. * around with it while parsing. Data is held in an `Options` object, and when
  6063. * recursing, a new `Options` object can be created with the `.with*` and
  6064. * `.reset` functions.
  6065. */
  6066. var sizeStyleMap = [
  6067. // Each element contains [textsize, scriptsize, scriptscriptsize].
  6068. // The size mappings are taken from TeX with \normalsize=10pt.
  6069. [1, 1, 1],
  6070. // size1: [5, 5, 5] \tiny
  6071. [2, 1, 1],
  6072. // size2: [6, 5, 5]
  6073. [3, 1, 1],
  6074. // size3: [7, 5, 5] \scriptsize
  6075. [4, 2, 1],
  6076. // size4: [8, 6, 5] \footnotesize
  6077. [5, 2, 1],
  6078. // size5: [9, 6, 5] \small
  6079. [6, 3, 1],
  6080. // size6: [10, 7, 5] \normalsize
  6081. [7, 4, 2],
  6082. // size7: [12, 8, 6] \large
  6083. [8, 6, 3],
  6084. // size8: [14.4, 10, 7] \Large
  6085. [9, 7, 6],
  6086. // size9: [17.28, 12, 10] \LARGE
  6087. [10, 8, 7],
  6088. // size10: [20.74, 14.4, 12] \huge
  6089. [11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE
  6090. ];
  6091. var sizeMultipliers = [
  6092. // fontMetrics.js:getGlobalMetrics also uses size indexes, so if
  6093. // you change size indexes, change that function.
  6094. 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
  6095. var sizeAtStyle = function sizeAtStyle(size, style) {
  6096. return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
  6097. };
  6098. /**
  6099. * This is the main options class. It contains the current style, size, color,
  6100. * and font.
  6101. *
  6102. * Options objects should not be modified. To create a new Options with
  6103. * different properties, call a `.having*` method.
  6104. */
  6105. class Options {
  6106. constructor(data) {
  6107. this.style = data.style;
  6108. this.color = data.color;
  6109. this.size = data.size || Options.BASESIZE;
  6110. this.textSize = data.textSize || this.size;
  6111. this.phantom = !!data.phantom;
  6112. this.font = data.font || "";
  6113. this.fontFamily = data.fontFamily || "";
  6114. this.fontWeight = data.fontWeight || '';
  6115. this.fontShape = data.fontShape || '';
  6116. this.sizeMultiplier = sizeMultipliers[this.size - 1];
  6117. this.maxSize = data.maxSize;
  6118. this.minRuleThickness = data.minRuleThickness;
  6119. this._fontMetrics = undefined;
  6120. }
  6121. /**
  6122. * Returns a new options object with the same properties as "this". Properties
  6123. * from "extension" will be copied to the new options object.
  6124. */
  6125. extend(extension) {
  6126. var data = {
  6127. style: this.style,
  6128. size: this.size,
  6129. textSize: this.textSize,
  6130. color: this.color,
  6131. phantom: this.phantom,
  6132. font: this.font,
  6133. fontFamily: this.fontFamily,
  6134. fontWeight: this.fontWeight,
  6135. fontShape: this.fontShape,
  6136. maxSize: this.maxSize,
  6137. minRuleThickness: this.minRuleThickness
  6138. };
  6139. Object.assign(data, extension);
  6140. return new Options(data);
  6141. }
  6142. /**
  6143. * Return an options object with the given style. If `this.style === style`,
  6144. * returns `this`.
  6145. */
  6146. havingStyle(style) {
  6147. if (this.style === style) {
  6148. return this;
  6149. } else {
  6150. return this.extend({
  6151. style: style,
  6152. size: sizeAtStyle(this.textSize, style)
  6153. });
  6154. }
  6155. }
  6156. /**
  6157. * Return an options object with a cramped version of the current style. If
  6158. * the current style is cramped, returns `this`.
  6159. */
  6160. havingCrampedStyle() {
  6161. return this.havingStyle(this.style.cramp());
  6162. }
  6163. /**
  6164. * Return an options object with the given size and in at least `\textstyle`.
  6165. * Returns `this` if appropriate.
  6166. */
  6167. havingSize(size) {
  6168. if (this.size === size && this.textSize === size) {
  6169. return this;
  6170. } else {
  6171. return this.extend({
  6172. style: this.style.text(),
  6173. size: size,
  6174. textSize: size,
  6175. sizeMultiplier: sizeMultipliers[size - 1]
  6176. });
  6177. }
  6178. }
  6179. /**
  6180. * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
  6181. * changes to at least `\textstyle`.
  6182. */
  6183. havingBaseStyle(style) {
  6184. style = style || this.style.text();
  6185. var wantSize = sizeAtStyle(Options.BASESIZE, style);
  6186. if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) {
  6187. return this;
  6188. } else {
  6189. return this.extend({
  6190. style: style,
  6191. size: wantSize
  6192. });
  6193. }
  6194. }
  6195. /**
  6196. * Remove the effect of sizing changes such as \Huge.
  6197. * Keep the effect of the current style, such as \scriptstyle.
  6198. */
  6199. havingBaseSizing() {
  6200. var size;
  6201. switch (this.style.id) {
  6202. case 4:
  6203. case 5:
  6204. size = 3; // normalsize in scriptstyle
  6205. break;
  6206. case 6:
  6207. case 7:
  6208. size = 1; // normalsize in scriptscriptstyle
  6209. break;
  6210. default:
  6211. size = 6;
  6212. // normalsize in textstyle or displaystyle
  6213. }
  6214. return this.extend({
  6215. style: this.style.text(),
  6216. size: size
  6217. });
  6218. }
  6219. /**
  6220. * Create a new options object with the given color.
  6221. */
  6222. withColor(color) {
  6223. return this.extend({
  6224. color: color
  6225. });
  6226. }
  6227. /**
  6228. * Create a new options object with "phantom" set to true.
  6229. */
  6230. withPhantom() {
  6231. return this.extend({
  6232. phantom: true
  6233. });
  6234. }
  6235. /**
  6236. * Creates a new options object with the given math font or old text font.
  6237. * @type {[type]}
  6238. */
  6239. withFont(font) {
  6240. return this.extend({
  6241. font
  6242. });
  6243. }
  6244. /**
  6245. * Create a new options objects with the given fontFamily.
  6246. */
  6247. withTextFontFamily(fontFamily) {
  6248. return this.extend({
  6249. fontFamily,
  6250. font: ""
  6251. });
  6252. }
  6253. /**
  6254. * Creates a new options object with the given font weight
  6255. */
  6256. withTextFontWeight(fontWeight) {
  6257. return this.extend({
  6258. fontWeight,
  6259. font: ""
  6260. });
  6261. }
  6262. /**
  6263. * Creates a new options object with the given font weight
  6264. */
  6265. withTextFontShape(fontShape) {
  6266. return this.extend({
  6267. fontShape,
  6268. font: ""
  6269. });
  6270. }
  6271. /**
  6272. * Return the CSS sizing classes required to switch from enclosing options
  6273. * `oldOptions` to `this`. Returns an array of classes.
  6274. */
  6275. sizingClasses(oldOptions) {
  6276. if (oldOptions.size !== this.size) {
  6277. return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
  6278. } else {
  6279. return [];
  6280. }
  6281. }
  6282. /**
  6283. * Return the CSS sizing classes required to switch to the base size. Like
  6284. * `this.havingSize(BASESIZE).sizingClasses(this)`.
  6285. */
  6286. baseSizingClasses() {
  6287. if (this.size !== Options.BASESIZE) {
  6288. return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
  6289. } else {
  6290. return [];
  6291. }
  6292. }
  6293. /**
  6294. * Return the font metrics for this size.
  6295. */
  6296. fontMetrics() {
  6297. if (!this._fontMetrics) {
  6298. this._fontMetrics = getGlobalMetrics(this.size);
  6299. }
  6300. return this._fontMetrics;
  6301. }
  6302. /**
  6303. * Gets the CSS color of the current options object
  6304. */
  6305. getColor() {
  6306. if (this.phantom) {
  6307. return "transparent";
  6308. } else {
  6309. return this.color;
  6310. }
  6311. }
  6312. }
  6313. // A font family applies to a group of fonts (i.e. SansSerif), while a font
  6314. // represents a specific font (i.e. SansSerif Bold).
  6315. // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm
  6316. /**
  6317. * The base size index.
  6318. */
  6319. Options.BASESIZE = 6;
  6320. var optionsFromSettings = function optionsFromSettings(settings) {
  6321. return new Options({
  6322. style: settings.displayMode ? Style$1.DISPLAY : Style$1.TEXT,
  6323. maxSize: settings.maxSize,
  6324. minRuleThickness: settings.minRuleThickness
  6325. });
  6326. };
  6327. var displayWrap = function displayWrap(node, settings) {
  6328. if (settings.displayMode) {
  6329. var classes = ["katex-display"];
  6330. if (settings.leqno) {
  6331. classes.push("leqno");
  6332. }
  6333. if (settings.fleqn) {
  6334. classes.push("fleqn");
  6335. }
  6336. node = makeSpan(classes, [node]);
  6337. }
  6338. return node;
  6339. };
  6340. var buildTree = function buildTree(tree, expression, settings) {
  6341. var options = optionsFromSettings(settings);
  6342. var katexNode;
  6343. if (settings.output === "mathml") {
  6344. return buildMathML(tree, expression, options, settings.displayMode, true);
  6345. } else if (settings.output === "html") {
  6346. var htmlNode = buildHTML(tree, options);
  6347. katexNode = makeSpan(["katex"], [htmlNode]);
  6348. } else {
  6349. var mathMLNode = buildMathML(tree, expression, options, settings.displayMode, false);
  6350. var _htmlNode = buildHTML(tree, options);
  6351. katexNode = makeSpan(["katex"], [mathMLNode, _htmlNode]);
  6352. }
  6353. return displayWrap(katexNode, settings);
  6354. };
  6355. var buildHTMLTree = function buildHTMLTree(tree, expression, settings) {
  6356. var options = optionsFromSettings(settings);
  6357. var htmlNode = buildHTML(tree, options);
  6358. var katexNode = makeSpan(["katex"], [htmlNode]);
  6359. return displayWrap(katexNode, settings);
  6360. };
  6361. /**
  6362. * This file provides support to buildMathML.js and buildHTML.js
  6363. * for stretchy wide elements rendered from SVG files
  6364. * and other CSS trickery.
  6365. */
  6366. var stretchyCodePoint = {
  6367. widehat: "^",
  6368. widecheck: "ˇ",
  6369. widetilde: "~",
  6370. utilde: "~",
  6371. overleftarrow: "\u2190",
  6372. underleftarrow: "\u2190",
  6373. xleftarrow: "\u2190",
  6374. overrightarrow: "\u2192",
  6375. underrightarrow: "\u2192",
  6376. xrightarrow: "\u2192",
  6377. underbrace: "\u23df",
  6378. overbrace: "\u23de",
  6379. underbracket: "\u23b5",
  6380. overbracket: "\u23b4",
  6381. overgroup: "\u23e0",
  6382. undergroup: "\u23e1",
  6383. overleftrightarrow: "\u2194",
  6384. underleftrightarrow: "\u2194",
  6385. xleftrightarrow: "\u2194",
  6386. Overrightarrow: "\u21d2",
  6387. xRightarrow: "\u21d2",
  6388. overleftharpoon: "\u21bc",
  6389. xleftharpoonup: "\u21bc",
  6390. overrightharpoon: "\u21c0",
  6391. xrightharpoonup: "\u21c0",
  6392. xLeftarrow: "\u21d0",
  6393. xLeftrightarrow: "\u21d4",
  6394. xhookleftarrow: "\u21a9",
  6395. xhookrightarrow: "\u21aa",
  6396. xmapsto: "\u21a6",
  6397. xrightharpoondown: "\u21c1",
  6398. xleftharpoondown: "\u21bd",
  6399. xrightleftharpoons: "\u21cc",
  6400. xleftrightharpoons: "\u21cb",
  6401. xtwoheadleftarrow: "\u219e",
  6402. xtwoheadrightarrow: "\u21a0",
  6403. xlongequal: "=",
  6404. xtofrom: "\u21c4",
  6405. xrightleftarrows: "\u21c4",
  6406. xrightequilibrium: "\u21cc",
  6407. // Not a perfect match.
  6408. xleftequilibrium: "\u21cb",
  6409. // None better available.
  6410. "\\cdrightarrow": "\u2192",
  6411. "\\cdleftarrow": "\u2190",
  6412. "\\cdlongequal": "="
  6413. };
  6414. var stretchyMathML = function stretchyMathML(label) {
  6415. var node = new MathNode("mo", [new TextNode(stretchyCodePoint[label.replace(/^\\/, '')])]);
  6416. node.setAttribute("stretchy", "true");
  6417. return node;
  6418. };
  6419. // Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts.
  6420. // Copyright (c) 2009-2010, Design Science, Inc. (<www.mathjax.org>)
  6421. // Copyright (c) 2014-2017 Khan Academy (<www.khanacademy.org>)
  6422. // Licensed under the SIL Open Font License, Version 1.1.
  6423. // See \nhttp://scripts.sil.org/OFL
  6424. // Very Long SVGs
  6425. // Many of the KaTeX stretchy wide elements use a long SVG image and an
  6426. // overflow: hidden tactic to achieve a stretchy image while avoiding
  6427. // distortion of arrowheads or brace corners.
  6428. // The SVG typically contains a very long (400 em) arrow.
  6429. // The SVG is in a container span that has overflow: hidden, so the span
  6430. // acts like a window that exposes only part of the SVG.
  6431. // The SVG always has a longer, thinner aspect ratio than the container span.
  6432. // After the SVG fills 100% of the height of the container span,
  6433. // there is a long arrow shaft left over. That left-over shaft is not shown.
  6434. // Instead, it is sliced off because the span's CSS has overflow: hidden.
  6435. // Thus, the reader sees an arrow that matches the subject matter width
  6436. // without distortion.
  6437. // Some functions, such as \cancel, need to vary their aspect ratio. These
  6438. // functions do not get the overflow SVG treatment.
  6439. // Second Brush Stroke
  6440. // Low resolution monitors struggle to display images in fine detail.
  6441. // So browsers apply anti-aliasing. A long straight arrow shaft therefore
  6442. // will sometimes appear as if it has a blurred edge.
  6443. // To mitigate this, these SVG files contain a second "brush-stroke" on the
  6444. // arrow shafts. That is, a second long thin rectangular SVG path has been
  6445. // written directly on top of each arrow shaft. This reinforcement causes
  6446. // some of the screen pixels to display as black instead of the anti-aliased
  6447. // gray pixel that a single path would generate. So we get arrow shafts
  6448. // whose edges appear to be sharper.
  6449. // In the katexImagesData object just below, the dimensions all
  6450. // correspond to path geometry inside the relevant SVG.
  6451. // For example, \overrightarrow uses the same arrowhead as glyph U+2192
  6452. // from the KaTeX Main font. The scaling factor is 1000.
  6453. // That is, inside the font, that arrowhead is 522 units tall, which
  6454. // corresponds to 0.522 em inside the document.
  6455. var katexImagesData = {
  6456. // path(s), minWidth, height, align
  6457. overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"],
  6458. overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"],
  6459. underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"],
  6460. underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"],
  6461. xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"],
  6462. "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"],
  6463. // CD minwwidth2.5pc
  6464. xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"],
  6465. "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"],
  6466. Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"],
  6467. xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"],
  6468. xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"],
  6469. overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"],
  6470. xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"],
  6471. xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"],
  6472. overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"],
  6473. xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"],
  6474. xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"],
  6475. xlongequal: [["longequal"], 0.888, 334, "xMinYMin"],
  6476. "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"],
  6477. xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"],
  6478. xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"],
  6479. overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522],
  6480. overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548],
  6481. underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], 1.6, 548],
  6482. underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522],
  6483. xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522],
  6484. xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560],
  6485. xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716],
  6486. xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], 1.75, 716],
  6487. xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522],
  6488. xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522],
  6489. overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522],
  6490. underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522],
  6491. overbracket: [["leftbracketover", "rightbracketover"], 1.6, 440],
  6492. underbracket: [["leftbracketunder", "rightbracketunder"], 1.6, 410],
  6493. overgroup: [["leftgroup", "rightgroup"], 0.888, 342],
  6494. undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342],
  6495. xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522],
  6496. xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528],
  6497. // The next three arrows are from the mhchem package.
  6498. // In mhchem.sty, min-length is 2.0em. But these arrows might appear in the
  6499. // document as \xrightarrow or \xrightleftharpoons. Those have
  6500. // min-length = 1.75em, so we set min-length on these next three to match.
  6501. xrightleftarrows: [["baraboveleftarrow", "rightarrowabovebar"], 1.75, 901],
  6502. xrightequilibrium: [["baraboveshortleftharpoon", "rightharpoonaboveshortbar"], 1.75, 716],
  6503. xleftequilibrium: [["shortbaraboveleftharpoon", "shortrightharpoonabovebar"], 1.75, 716]
  6504. };
  6505. var wideAccentLabels = new Set(["widehat", "widecheck", "widetilde", "utilde"]);
  6506. var stretchySvg = function stretchySvg(group, options) {
  6507. // Create a span with inline SVG for the element.
  6508. function buildSvgSpan_() {
  6509. var viewBoxWidth = 400000; // default
  6510. var label = group.label.slice(1);
  6511. if (wideAccentLabels.has(label)) {
  6512. // Each type in the `if` statement corresponds to one of the ParseNode
  6513. // types below. This narrowing is required to access `grp.base`.
  6514. // TODO(ts)
  6515. var grp = group;
  6516. // There are four SVG images available for each function.
  6517. // Choose a taller image when there are more characters.
  6518. var numChars = grp.base.type === "ordgroup" ? grp.base.body.length : 1;
  6519. var viewBoxHeight;
  6520. var pathName;
  6521. var _height;
  6522. if (numChars > 5) {
  6523. if (label === "widehat" || label === "widecheck") {
  6524. viewBoxHeight = 420;
  6525. viewBoxWidth = 2364;
  6526. _height = 0.42;
  6527. pathName = label + "4";
  6528. } else {
  6529. viewBoxHeight = 312;
  6530. viewBoxWidth = 2340;
  6531. _height = 0.34;
  6532. pathName = "tilde4";
  6533. }
  6534. } else {
  6535. var imgIndex = [1, 1, 2, 2, 3, 3][numChars];
  6536. if (label === "widehat" || label === "widecheck") {
  6537. viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex];
  6538. viewBoxHeight = [0, 239, 300, 360, 420][imgIndex];
  6539. _height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex];
  6540. pathName = label + imgIndex;
  6541. } else {
  6542. viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex];
  6543. viewBoxHeight = [0, 260, 286, 306, 312][imgIndex];
  6544. _height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex];
  6545. pathName = "tilde" + imgIndex;
  6546. }
  6547. }
  6548. var path = new PathNode(pathName);
  6549. var svgNode = new SvgNode([path], {
  6550. "width": "100%",
  6551. "height": makeEm(_height),
  6552. "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight,
  6553. "preserveAspectRatio": "none"
  6554. });
  6555. return {
  6556. span: makeSvgSpan([], [svgNode], options),
  6557. minWidth: 0,
  6558. height: _height
  6559. };
  6560. } else {
  6561. var spans = [];
  6562. var data = katexImagesData[label];
  6563. var [paths, _minWidth, _viewBoxHeight] = data;
  6564. var _height2 = _viewBoxHeight / 1000;
  6565. var numSvgChildren = paths.length;
  6566. var widthClasses;
  6567. var aligns;
  6568. if (numSvgChildren === 1) {
  6569. // TODO(ts): All these cases must be of the 4-tuple type.
  6570. var align1 = data[3];
  6571. widthClasses = ["hide-tail"];
  6572. aligns = [align1];
  6573. } else if (numSvgChildren === 2) {
  6574. widthClasses = ["halfarrow-left", "halfarrow-right"];
  6575. aligns = ["xMinYMin", "xMaxYMin"];
  6576. } else if (numSvgChildren === 3) {
  6577. widthClasses = ["brace-left", "brace-center", "brace-right"];
  6578. aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"];
  6579. } else {
  6580. throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children.");
  6581. }
  6582. for (var i = 0; i < numSvgChildren; i++) {
  6583. var _path = new PathNode(paths[i]);
  6584. var _svgNode = new SvgNode([_path], {
  6585. "width": "400em",
  6586. "height": makeEm(_height2),
  6587. "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight,
  6588. "preserveAspectRatio": aligns[i] + " slice"
  6589. });
  6590. var _span = makeSvgSpan([widthClasses[i]], [_svgNode], options);
  6591. if (numSvgChildren === 1) {
  6592. return {
  6593. span: _span,
  6594. minWidth: _minWidth,
  6595. height: _height2
  6596. };
  6597. } else {
  6598. _span.style.height = makeEm(_height2);
  6599. spans.push(_span);
  6600. }
  6601. }
  6602. return {
  6603. span: makeSpan(["stretchy"], spans, options),
  6604. minWidth: _minWidth,
  6605. height: _height2
  6606. };
  6607. }
  6608. } // buildSvgSpan_()
  6609. var {
  6610. span,
  6611. minWidth,
  6612. height
  6613. } = buildSvgSpan_();
  6614. // Note that we are returning span.depth = 0.
  6615. // Any adjustments relative to the baseline must be done in buildHTML.
  6616. span.height = height;
  6617. span.style.height = makeEm(height);
  6618. if (minWidth > 0) {
  6619. span.style.minWidth = makeEm(minWidth);
  6620. }
  6621. return span;
  6622. };
  6623. var stretchyEnclose = function stretchyEnclose(inner, label, topPad, bottomPad, options) {
  6624. // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl
  6625. var img;
  6626. var totalHeight = inner.height + inner.depth + topPad + bottomPad;
  6627. if (/fbox|color|angl/.test(label)) {
  6628. img = makeSpan(["stretchy", label], [], options);
  6629. if (label === "fbox") {
  6630. var color = options.color && options.getColor();
  6631. if (color) {
  6632. img.style.borderColor = color;
  6633. }
  6634. }
  6635. } else {
  6636. // \cancel, \bcancel, or \xcancel
  6637. // Since \cancel's SVG is inline and it omits the viewBox attribute,
  6638. // its stroke-width will not vary with span area.
  6639. var lines = [];
  6640. if (/^[bx]cancel$/.test(label)) {
  6641. lines.push(new LineNode({
  6642. "x1": "0",
  6643. "y1": "0",
  6644. "x2": "100%",
  6645. "y2": "100%",
  6646. "stroke-width": "0.046em"
  6647. }));
  6648. }
  6649. if (/^x?cancel$/.test(label)) {
  6650. lines.push(new LineNode({
  6651. "x1": "0",
  6652. "y1": "100%",
  6653. "x2": "100%",
  6654. "y2": "0",
  6655. "stroke-width": "0.046em"
  6656. }));
  6657. }
  6658. var svgNode = new SvgNode(lines, {
  6659. "width": "100%",
  6660. "height": makeEm(totalHeight)
  6661. });
  6662. img = makeSvgSpan([], [svgNode], options);
  6663. }
  6664. img.height = totalHeight;
  6665. img.style.height = makeEm(totalHeight);
  6666. return img;
  6667. };
  6668. /**
  6669. * Asserts that the node is of the given type and returns it with stricter
  6670. * typing. Throws if the node's type does not match.
  6671. */
  6672. function assertNodeType(node, type) {
  6673. if (!node || node.type !== type) {
  6674. throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node)));
  6675. }
  6676. return node;
  6677. }
  6678. /**
  6679. * Returns the node more strictly typed iff it is of the given type. Otherwise,
  6680. * returns null.
  6681. */
  6682. function assertSymbolNodeType(node) {
  6683. var typedNode = checkSymbolNodeType(node);
  6684. if (!typedNode) {
  6685. throw new Error("Expected node of symbol group type, but got " + (node ? "node of type " + node.type : String(node)));
  6686. }
  6687. return typedNode;
  6688. }
  6689. /**
  6690. * Returns the node more strictly typed iff it is of the given type. Otherwise,
  6691. * returns null.
  6692. */
  6693. function checkSymbolNodeType(node) {
  6694. if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) {
  6695. return node;
  6696. }
  6697. return null;
  6698. }
  6699. var getBaseSymbol = group => {
  6700. if (group instanceof SymbolNode) {
  6701. return group;
  6702. }
  6703. if (hasHtmlDomChildren(group) && group.children.length === 1) {
  6704. return getBaseSymbol(group.children[0]);
  6705. }
  6706. };
  6707. // NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but
  6708. // also "supsub" since an accent can affect super/subscripting.
  6709. var htmlBuilder$a = (grp, options) => {
  6710. // Accents are handled in the TeXbook pg. 443, rule 12.
  6711. var base;
  6712. var group;
  6713. var supSubGroup;
  6714. if (grp && grp.type === "supsub") {
  6715. // If our base is a character box, and we have superscripts and
  6716. // subscripts, the supsub will defer to us. In particular, we want
  6717. // to attach the superscripts and subscripts to the inner body (so
  6718. // that the position of the superscripts and subscripts won't be
  6719. // affected by the height of the accent). We accomplish this by
  6720. // sticking the base of the accent into the base of the supsub, and
  6721. // rendering that, while keeping track of where the accent is.
  6722. // The real accent group is the base of the supsub group
  6723. group = assertNodeType(grp.base, "accent");
  6724. // The character box is the base of the accent group
  6725. base = group.base;
  6726. // Stick the character box into the base of the supsub group
  6727. grp.base = base;
  6728. // Rerender the supsub group with its new base, and store that
  6729. // result.
  6730. supSubGroup = assertSpan(buildGroup$1(grp, options));
  6731. // reset original base
  6732. grp.base = group;
  6733. } else {
  6734. group = assertNodeType(grp, "accent");
  6735. base = group.base;
  6736. }
  6737. // Build the base group
  6738. var body = buildGroup$1(base, options.havingCrampedStyle());
  6739. // Does the accent need to shift for the skew of a character?
  6740. var mustShift = group.isShifty && isCharacterBox(base);
  6741. // Calculate the skew of the accent. This is based on the line "If the
  6742. // nucleus is not a single character, let s = 0; otherwise set s to the
  6743. // kern amount for the nucleus followed by the \skewchar of its font."
  6744. // Note that our skew metrics are just the kern between each character
  6745. // and the skewchar.
  6746. var skew = 0;
  6747. if (mustShift) {
  6748. var _getBaseSymbol$skew, _getBaseSymbol;
  6749. // Read the skew from the rendered base symbol.
  6750. // This preserves font metrics from font wrappers like \mathbb.
  6751. skew = (_getBaseSymbol$skew = (_getBaseSymbol = getBaseSymbol(body)) == null ? void 0 : _getBaseSymbol.skew) != null ? _getBaseSymbol$skew : 0;
  6752. }
  6753. var accentBelow = group.label === "\\c";
  6754. // calculate the amount of space between the body and the accent
  6755. var clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight);
  6756. // Build the accent
  6757. var accentBody;
  6758. if (!group.isStretchy) {
  6759. var accent;
  6760. var width;
  6761. if (group.label === "\\vec") {
  6762. // Before version 0.9, \vec used the combining font glyph U+20D7.
  6763. // But browsers, especially Safari, are not consistent in how they
  6764. // render combining characters when not preceded by a character.
  6765. // So now we use an SVG.
  6766. // If Safari reforms, we should consider reverting to the glyph.
  6767. accent = staticSvg("vec", options);
  6768. width = svgData.vec[1];
  6769. } else {
  6770. accent = makeOrd({
  6771. type: "textord",
  6772. mode: group.mode,
  6773. text: group.label
  6774. }, options, "textord");
  6775. accent = assertSymbolDomNode(accent);
  6776. // Remove the italic correction of the accent, because it only serves to
  6777. // shift the accent over to a place we don't want.
  6778. accent.italic = 0;
  6779. width = accent.width;
  6780. if (accentBelow) {
  6781. clearance += accent.depth;
  6782. }
  6783. }
  6784. accentBody = makeSpan(["accent-body"], [accent]);
  6785. // "Full" accents expand the width of the resulting symbol to be
  6786. // at least the width of the accent, and overlap directly onto the
  6787. // character without any vertical offset.
  6788. var accentFull = group.label === "\\textcircled";
  6789. if (accentFull) {
  6790. accentBody.classes.push('accent-full');
  6791. clearance = body.height;
  6792. }
  6793. // Shift the accent over by the skew.
  6794. var left = skew;
  6795. // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }`
  6796. // so that the accent doesn't contribute to the bounding box.
  6797. // We need to shift the character by its width (effectively half
  6798. // its width) to compensate.
  6799. if (!accentFull) {
  6800. left -= width / 2;
  6801. }
  6802. accentBody.style.left = makeEm(left);
  6803. // \textcircled uses the \bigcirc glyph, so it needs some
  6804. // vertical adjustment to match LaTeX.
  6805. if (group.label === "\\textcircled") {
  6806. accentBody.style.top = ".2em";
  6807. }
  6808. accentBody = makeVList({
  6809. positionType: "firstBaseline",
  6810. children: [{
  6811. type: "elem",
  6812. elem: body
  6813. }, {
  6814. type: "kern",
  6815. size: -clearance
  6816. }, {
  6817. type: "elem",
  6818. elem: accentBody
  6819. }]
  6820. });
  6821. } else {
  6822. accentBody = stretchySvg(group, options);
  6823. accentBody = makeVList({
  6824. positionType: "firstBaseline",
  6825. children: [{
  6826. type: "elem",
  6827. elem: body
  6828. }, {
  6829. type: "elem",
  6830. elem: accentBody,
  6831. wrapperClasses: ["svg-align"],
  6832. wrapperStyle: skew > 0 ? {
  6833. width: "calc(100% - " + makeEm(2 * skew) + ")",
  6834. marginLeft: makeEm(2 * skew)
  6835. } : undefined
  6836. }]
  6837. });
  6838. }
  6839. var accentWrap = makeSpan(["mord", "accent"], [accentBody], options);
  6840. if (supSubGroup) {
  6841. // Here, we replace the "base" child of the supsub with our newly
  6842. // generated accent.
  6843. supSubGroup.children[0] = accentWrap;
  6844. // Since we don't rerun the height calculation after replacing the
  6845. // accent, we manually recalculate height.
  6846. supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height);
  6847. // Accents should always be ords, even when their innards are not.
  6848. supSubGroup.classes[0] = "mord";
  6849. return supSubGroup;
  6850. } else {
  6851. return accentWrap;
  6852. }
  6853. };
  6854. var mathmlBuilder$9 = (group, options) => {
  6855. var accentNode = group.isStretchy ? stretchyMathML(group.label) : new MathNode("mo", [makeText(group.label, group.mode)]);
  6856. var node = new MathNode("mover", [buildGroup(group.base, options), accentNode]);
  6857. node.setAttribute("accent", "true");
  6858. return node;
  6859. };
  6860. var NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(accent => "\\" + accent).join("|"));
  6861. // Accents
  6862. defineFunction({
  6863. type: "accent",
  6864. names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"],
  6865. props: {
  6866. numArgs: 1
  6867. },
  6868. handler: (context, args) => {
  6869. var base = normalizeArgument(args[0]);
  6870. var isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName);
  6871. var isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck";
  6872. return {
  6873. type: "accent",
  6874. mode: context.parser.mode,
  6875. label: context.funcName,
  6876. isStretchy: isStretchy,
  6877. isShifty: isShifty,
  6878. base: base
  6879. };
  6880. },
  6881. htmlBuilder: htmlBuilder$a,
  6882. mathmlBuilder: mathmlBuilder$9
  6883. });
  6884. // Text-mode accents
  6885. defineFunction({
  6886. type: "accent",
  6887. names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"],
  6888. props: {
  6889. numArgs: 1,
  6890. allowedInText: true,
  6891. allowedInMath: true,
  6892. // unless in strict mode
  6893. argTypes: ["primitive"]
  6894. },
  6895. handler: (context, args) => {
  6896. var base = args[0];
  6897. var mode = context.parser.mode;
  6898. if (mode === "math") {
  6899. context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode");
  6900. mode = "text";
  6901. }
  6902. return {
  6903. type: "accent",
  6904. mode: mode,
  6905. label: context.funcName,
  6906. isStretchy: false,
  6907. isShifty: true,
  6908. base: base
  6909. };
  6910. },
  6911. htmlBuilder: htmlBuilder$a,
  6912. mathmlBuilder: mathmlBuilder$9
  6913. });
  6914. // Horizontal overlap functions
  6915. defineFunction({
  6916. type: "accentUnder",
  6917. names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"],
  6918. props: {
  6919. numArgs: 1
  6920. },
  6921. handler: (_ref, args) => {
  6922. var {
  6923. parser,
  6924. funcName
  6925. } = _ref;
  6926. var base = args[0];
  6927. return {
  6928. type: "accentUnder",
  6929. mode: parser.mode,
  6930. label: funcName,
  6931. base: base
  6932. };
  6933. },
  6934. htmlBuilder: (group, options) => {
  6935. // Treat under accents much like underlines.
  6936. var innerGroup = buildGroup$1(group.base, options);
  6937. var accentBody = stretchySvg(group, options);
  6938. var kern = group.label === "\\utilde" ? 0.12 : 0;
  6939. // Generate the vlist, with the appropriate kerns
  6940. var vlist = makeVList({
  6941. positionType: "top",
  6942. positionData: innerGroup.height,
  6943. children: [{
  6944. type: "elem",
  6945. elem: accentBody,
  6946. wrapperClasses: ["svg-align"]
  6947. }, {
  6948. type: "kern",
  6949. size: kern
  6950. }, {
  6951. type: "elem",
  6952. elem: innerGroup
  6953. }]
  6954. });
  6955. return makeSpan(["mord", "accentunder"], [vlist], options);
  6956. },
  6957. mathmlBuilder: (group, options) => {
  6958. var accentNode = stretchyMathML(group.label);
  6959. var node = new MathNode("munder", [buildGroup(group.base, options), accentNode]);
  6960. node.setAttribute("accentunder", "true");
  6961. return node;
  6962. }
  6963. });
  6964. // Helper function
  6965. var paddedNode = group => {
  6966. var node = new MathNode("mpadded", group ? [group] : []);
  6967. node.setAttribute("width", "+0.6em");
  6968. node.setAttribute("lspace", "0.3em");
  6969. return node;
  6970. };
  6971. // Stretchy arrows with an optional argument
  6972. defineFunction({
  6973. type: "xArrow",
  6974. names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom",
  6975. // The next 3 functions are here to support the mhchem extension.
  6976. // Direct use of these functions is discouraged and may break someday.
  6977. "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium",
  6978. // The next 3 functions are here only to support the {CD} environment.
  6979. "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"],
  6980. props: {
  6981. numArgs: 1,
  6982. numOptionalArgs: 1
  6983. },
  6984. handler(_ref, args, optArgs) {
  6985. var {
  6986. parser,
  6987. funcName
  6988. } = _ref;
  6989. return {
  6990. type: "xArrow",
  6991. mode: parser.mode,
  6992. label: funcName,
  6993. body: args[0],
  6994. below: optArgs[0]
  6995. };
  6996. },
  6997. htmlBuilder(group, options) {
  6998. var style = options.style;
  6999. // Build the argument groups in the appropriate style.
  7000. // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}%
  7001. // Some groups can return document fragments. Handle those by wrapping
  7002. // them in a span.
  7003. var newOptions = options.havingStyle(style.sup());
  7004. var upperGroup = wrapFragment(buildGroup$1(group.body, newOptions, options), options);
  7005. var arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd";
  7006. upperGroup.classes.push(arrowPrefix + "-arrow-pad");
  7007. var lowerGroup;
  7008. if (group.below) {
  7009. // Build the lower group
  7010. newOptions = options.havingStyle(style.sub());
  7011. lowerGroup = wrapFragment(buildGroup$1(group.below, newOptions, options), options);
  7012. lowerGroup.classes.push(arrowPrefix + "-arrow-pad");
  7013. }
  7014. var arrowBody = stretchySvg(group, options);
  7015. // Re shift: Note that stretchySvg returned arrowBody.depth = 0.
  7016. // The point we want on the math axis is at 0.5 * arrowBody.height.
  7017. var arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height;
  7018. // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi
  7019. var upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu
  7020. if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") {
  7021. upperShift -= upperGroup.depth; // shift up if depth encroaches
  7022. }
  7023. // Generate the vlist
  7024. var vlist;
  7025. if (lowerGroup) {
  7026. var lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111;
  7027. vlist = makeVList({
  7028. positionType: "individualShift",
  7029. children: [{
  7030. type: "elem",
  7031. elem: upperGroup,
  7032. shift: upperShift
  7033. }, {
  7034. type: "elem",
  7035. elem: arrowBody,
  7036. shift: arrowShift
  7037. }, {
  7038. type: "elem",
  7039. elem: lowerGroup,
  7040. shift: lowerShift
  7041. }]
  7042. });
  7043. } else {
  7044. vlist = makeVList({
  7045. positionType: "individualShift",
  7046. children: [{
  7047. type: "elem",
  7048. elem: upperGroup,
  7049. shift: upperShift
  7050. }, {
  7051. type: "elem",
  7052. elem: arrowBody,
  7053. shift: arrowShift
  7054. }]
  7055. });
  7056. }
  7057. // TODO(ts): Replace this with passing "svg-align" into makeVList.
  7058. vlist.children[0].children[0].children[1].classes.push("svg-align");
  7059. return makeSpan(["mrel", "x-arrow"], [vlist], options);
  7060. },
  7061. mathmlBuilder(group, options) {
  7062. var arrowNode = stretchyMathML(group.label);
  7063. arrowNode.setAttribute("minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em");
  7064. var node;
  7065. if (group.body) {
  7066. var upperNode = paddedNode(buildGroup(group.body, options));
  7067. if (group.below) {
  7068. var lowerNode = paddedNode(buildGroup(group.below, options));
  7069. node = new MathNode("munderover", [arrowNode, lowerNode, upperNode]);
  7070. } else {
  7071. node = new MathNode("mover", [arrowNode, upperNode]);
  7072. }
  7073. } else if (group.below) {
  7074. var _lowerNode = paddedNode(buildGroup(group.below, options));
  7075. node = new MathNode("munder", [arrowNode, _lowerNode]);
  7076. } else {
  7077. // This should never happen.
  7078. // Parser.js throws an error if there is no argument.
  7079. node = paddedNode();
  7080. node = new MathNode("mover", [arrowNode, node]);
  7081. }
  7082. return node;
  7083. }
  7084. });
  7085. function htmlBuilder$9(group, options) {
  7086. var elements = buildExpression$1(group.body, options, true);
  7087. return makeSpan([group.mclass], elements, options);
  7088. }
  7089. function mathmlBuilder$8(group, options) {
  7090. var node;
  7091. var inner = buildExpression(group.body, options);
  7092. if (group.mclass === "minner") {
  7093. node = new MathNode("mpadded", inner);
  7094. } else if (group.mclass === "mord") {
  7095. if (group.isCharacterBox) {
  7096. node = inner[0];
  7097. node.type = "mi";
  7098. } else {
  7099. node = new MathNode("mi", inner);
  7100. }
  7101. } else {
  7102. if (group.isCharacterBox) {
  7103. node = inner[0];
  7104. node.type = "mo";
  7105. } else {
  7106. node = new MathNode("mo", inner);
  7107. }
  7108. // Set spacing based on what is the most likely adjacent atom type.
  7109. // See TeXbook p170.
  7110. if (group.mclass === "mbin") {
  7111. node.attributes.lspace = "0.22em"; // medium space
  7112. node.attributes.rspace = "0.22em";
  7113. } else if (group.mclass === "mpunct") {
  7114. node.attributes.lspace = "0em";
  7115. node.attributes.rspace = "0.17em"; // thinspace
  7116. } else if (group.mclass === "mopen" || group.mclass === "mclose") {
  7117. node.attributes.lspace = "0em";
  7118. node.attributes.rspace = "0em";
  7119. } else if (group.mclass === "minner") {
  7120. node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option
  7121. node.attributes.width = "+0.1111em";
  7122. }
  7123. // MathML <mo> default space is 5/18 em, so <mrel> needs no action.
  7124. // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
  7125. }
  7126. return node;
  7127. }
  7128. // Math class commands except \mathop
  7129. defineFunction({
  7130. type: "mclass",
  7131. names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"],
  7132. props: {
  7133. numArgs: 1,
  7134. primitive: true
  7135. },
  7136. handler(_ref, args) {
  7137. var {
  7138. parser,
  7139. funcName
  7140. } = _ref;
  7141. var body = args[0];
  7142. return {
  7143. type: "mclass",
  7144. mode: parser.mode,
  7145. mclass: "m" + funcName.slice(5),
  7146. // TODO(kevinb): don't prefix with 'm'
  7147. body: ordargument(body),
  7148. isCharacterBox: isCharacterBox(body)
  7149. };
  7150. },
  7151. htmlBuilder: htmlBuilder$9,
  7152. mathmlBuilder: mathmlBuilder$8
  7153. });
  7154. var binrelClass = arg => {
  7155. // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument.
  7156. // (by rendering separately and with {}s before and after, and measuring
  7157. // the change in spacing). We'll do roughly the same by detecting the
  7158. // atom type directly.
  7159. var atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg;
  7160. if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) {
  7161. return "m" + atom.family;
  7162. } else {
  7163. return "mord";
  7164. }
  7165. };
  7166. // \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord.
  7167. // This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX.
  7168. defineFunction({
  7169. type: "mclass",
  7170. names: ["\\@binrel"],
  7171. props: {
  7172. numArgs: 2
  7173. },
  7174. handler(_ref2, args) {
  7175. var {
  7176. parser
  7177. } = _ref2;
  7178. return {
  7179. type: "mclass",
  7180. mode: parser.mode,
  7181. mclass: binrelClass(args[0]),
  7182. body: ordargument(args[1]),
  7183. isCharacterBox: isCharacterBox(args[1])
  7184. };
  7185. }
  7186. });
  7187. // Build a relation or stacked op by placing one symbol on top of another
  7188. defineFunction({
  7189. type: "mclass",
  7190. names: ["\\stackrel", "\\overset", "\\underset"],
  7191. props: {
  7192. numArgs: 2
  7193. },
  7194. handler(_ref3, args) {
  7195. var {
  7196. parser,
  7197. funcName
  7198. } = _ref3;
  7199. var baseArg = args[1];
  7200. var shiftedArg = args[0];
  7201. var mclass;
  7202. if (funcName !== "\\stackrel") {
  7203. // LaTeX applies \binrel spacing to \overset and \underset.
  7204. mclass = binrelClass(baseArg);
  7205. } else {
  7206. mclass = "mrel"; // for \stackrel
  7207. }
  7208. var baseOp = {
  7209. type: "op",
  7210. mode: baseArg.mode,
  7211. limits: true,
  7212. alwaysHandleSupSub: true,
  7213. parentIsSupSub: false,
  7214. symbol: false,
  7215. suppressBaseShift: funcName !== "\\stackrel",
  7216. body: ordargument(baseArg)
  7217. };
  7218. var supsub = {
  7219. type: "supsub",
  7220. mode: shiftedArg.mode,
  7221. base: baseOp,
  7222. sup: funcName === "\\underset" ? null : shiftedArg,
  7223. sub: funcName === "\\underset" ? shiftedArg : null
  7224. };
  7225. return {
  7226. type: "mclass",
  7227. mode: parser.mode,
  7228. mclass,
  7229. body: [supsub],
  7230. isCharacterBox: isCharacterBox(supsub)
  7231. };
  7232. },
  7233. htmlBuilder: htmlBuilder$9,
  7234. mathmlBuilder: mathmlBuilder$8
  7235. });
  7236. // \pmb is a simulation of bold font.
  7237. // The version of \pmb in ambsy.sty works by typesetting three copies
  7238. // with small offsets. We use CSS text-shadow.
  7239. // It's a hack. Not as good as a real bold font. Better than nothing.
  7240. defineFunction({
  7241. type: "pmb",
  7242. names: ["\\pmb"],
  7243. props: {
  7244. numArgs: 1,
  7245. allowedInText: true
  7246. },
  7247. handler(_ref, args) {
  7248. var {
  7249. parser
  7250. } = _ref;
  7251. return {
  7252. type: "pmb",
  7253. mode: parser.mode,
  7254. mclass: binrelClass(args[0]),
  7255. body: ordargument(args[0])
  7256. };
  7257. },
  7258. htmlBuilder(group, options) {
  7259. var elements = buildExpression$1(group.body, options, true);
  7260. var node = makeSpan([group.mclass], elements, options);
  7261. node.style.textShadow = "0.02em 0.01em 0.04px";
  7262. return node;
  7263. },
  7264. mathmlBuilder(group, style) {
  7265. var inner = buildExpression(group.body, style);
  7266. // Wrap with an <mstyle> element.
  7267. var node = new MathNode("mstyle", inner);
  7268. node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px");
  7269. return node;
  7270. }
  7271. });
  7272. var cdArrowFunctionName = {
  7273. ">": "\\\\cdrightarrow",
  7274. "<": "\\\\cdleftarrow",
  7275. "=": "\\\\cdlongequal",
  7276. "A": "\\uparrow",
  7277. "V": "\\downarrow",
  7278. "|": "\\Vert",
  7279. ".": "no arrow"
  7280. };
  7281. var newCell = () => {
  7282. // Create an empty cell, to be filled below with parse nodes.
  7283. // The parseTree from this module must be constructed like the
  7284. // one created by parseArray(), so an empty CD cell must
  7285. // be a ParseNode<"styling">. And CD is always displaystyle.
  7286. return {
  7287. type: "styling",
  7288. body: [],
  7289. mode: "math",
  7290. style: "display"
  7291. };
  7292. };
  7293. var isStartOfArrow = node => {
  7294. return node.type === "textord" && node.text === "@";
  7295. };
  7296. var isLabelEnd = (node, endChar) => {
  7297. return (node.type === "mathord" || node.type === "atom") && node.text === endChar;
  7298. };
  7299. function cdArrow(arrowChar, labels, parser) {
  7300. // Return a parse tree of an arrow and its labels.
  7301. // This acts in a way similar to a macro expansion.
  7302. var funcName = cdArrowFunctionName[arrowChar];
  7303. switch (funcName) {
  7304. case "\\\\cdrightarrow":
  7305. case "\\\\cdleftarrow":
  7306. return parser.callFunction(funcName, [labels[0]], [labels[1]]);
  7307. case "\\uparrow":
  7308. case "\\downarrow":
  7309. {
  7310. var leftLabel = parser.callFunction("\\\\cdleft", [labels[0]], []);
  7311. var bareArrow = {
  7312. type: "atom",
  7313. text: funcName,
  7314. mode: "math",
  7315. family: "rel"
  7316. };
  7317. var sizedArrow = parser.callFunction("\\Big", [bareArrow], []);
  7318. var rightLabel = parser.callFunction("\\\\cdright", [labels[1]], []);
  7319. var arrowGroup = {
  7320. type: "ordgroup",
  7321. mode: "math",
  7322. body: [leftLabel, sizedArrow, rightLabel]
  7323. };
  7324. return parser.callFunction("\\\\cdparent", [arrowGroup], []);
  7325. }
  7326. case "\\\\cdlongequal":
  7327. return parser.callFunction("\\\\cdlongequal", [], []);
  7328. case "\\Vert":
  7329. {
  7330. var arrow = {
  7331. type: "textord",
  7332. text: "\\Vert",
  7333. mode: "math"
  7334. };
  7335. return parser.callFunction("\\Big", [arrow], []);
  7336. }
  7337. default:
  7338. return {
  7339. type: "textord",
  7340. text: " ",
  7341. mode: "math"
  7342. };
  7343. }
  7344. }
  7345. function parseCD(parser) {
  7346. // Get the array's parse nodes with \\ temporarily mapped to \cr.
  7347. var parsedRows = [];
  7348. parser.gullet.beginGroup();
  7349. parser.gullet.macros.set("\\cr", "\\\\\\relax");
  7350. parser.gullet.beginGroup();
  7351. while (true) {
  7352. // eslint-disable-line no-constant-condition
  7353. // Get the parse nodes for the next row.
  7354. parsedRows.push(parser.parseExpression(false, "\\\\"));
  7355. parser.gullet.endGroup();
  7356. parser.gullet.beginGroup();
  7357. var next = parser.fetch().text;
  7358. if (next === "&" || next === "\\\\") {
  7359. parser.consume();
  7360. } else if (next === "\\end") {
  7361. if (parsedRows[parsedRows.length - 1].length === 0) {
  7362. parsedRows.pop(); // final row ended in \\
  7363. }
  7364. break;
  7365. } else {
  7366. throw new ParseError("Expected \\\\ or \\cr or \\end", parser.nextToken);
  7367. }
  7368. }
  7369. var row = [];
  7370. var body = [row];
  7371. // Loop thru the parse nodes. Collect them into cells and arrows.
  7372. for (var i = 0; i < parsedRows.length; i++) {
  7373. // Start a new row.
  7374. var rowNodes = parsedRows[i];
  7375. // Create the first cell.
  7376. var cell = newCell();
  7377. for (var j = 0; j < rowNodes.length; j++) {
  7378. if (!isStartOfArrow(rowNodes[j])) {
  7379. // If a parseNode is not an arrow, it goes into a cell.
  7380. cell.body.push(rowNodes[j]);
  7381. } else {
  7382. // Parse node j is an "@", the start of an arrow.
  7383. // Before starting on the arrow, push the cell into `row`.
  7384. row.push(cell);
  7385. // Now collect parseNodes into an arrow.
  7386. // The character after "@" defines the arrow type.
  7387. j += 1;
  7388. var arrowChar = assertSymbolNodeType(rowNodes[j]).text;
  7389. // Create two empty label nodes. We may or may not use them.
  7390. var labels = new Array(2);
  7391. labels[0] = {
  7392. type: "ordgroup",
  7393. mode: "math",
  7394. body: []
  7395. };
  7396. labels[1] = {
  7397. type: "ordgroup",
  7398. mode: "math",
  7399. body: []
  7400. };
  7401. // Process the arrow.
  7402. if ("=|.".includes(arrowChar)) ; else if ("<>AV".includes(arrowChar)) {
  7403. // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take
  7404. // two optional labels. E.g. the right-point arrow syntax is
  7405. // really: @>{optional label}>{optional label}>
  7406. // Collect parseNodes into labels.
  7407. for (var labelNum = 0; labelNum < 2; labelNum++) {
  7408. var inLabel = true;
  7409. for (var k = j + 1; k < rowNodes.length; k++) {
  7410. if (isLabelEnd(rowNodes[k], arrowChar)) {
  7411. inLabel = false;
  7412. j = k;
  7413. break;
  7414. }
  7415. if (isStartOfArrow(rowNodes[k])) {
  7416. throw new ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[k]);
  7417. }
  7418. labels[labelNum].body.push(rowNodes[k]);
  7419. }
  7420. if (inLabel) {
  7421. // isLabelEnd never returned a true.
  7422. throw new ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[j]);
  7423. }
  7424. }
  7425. } else {
  7426. throw new ParseError("Expected one of \"<>AV=|.\" after @", rowNodes[j]);
  7427. }
  7428. // Now join the arrow to its labels.
  7429. var arrow = cdArrow(arrowChar, labels, parser);
  7430. // Wrap the arrow in ParseNode<"styling">.
  7431. // This is done to match parseArray() behavior.
  7432. var wrappedArrow = {
  7433. type: "styling",
  7434. body: [arrow],
  7435. mode: "math",
  7436. style: "display" // CD is always displaystyle.
  7437. };
  7438. row.push(wrappedArrow);
  7439. // In CD's syntax, cells are implicit. That is, everything that
  7440. // is not an arrow gets collected into a cell. So create an empty
  7441. // cell now. It will collect upcoming parseNodes.
  7442. cell = newCell();
  7443. }
  7444. }
  7445. if (i % 2 === 0) {
  7446. // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell
  7447. // The last cell is not yet pushed into `row`, so:
  7448. row.push(cell);
  7449. } else {
  7450. // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow
  7451. // Remove the empty cell that was placed at the beginning of `row`.
  7452. row.shift();
  7453. }
  7454. row = [];
  7455. body.push(row);
  7456. }
  7457. // End row group
  7458. parser.gullet.endGroup();
  7459. // End array group defining \\
  7460. parser.gullet.endGroup();
  7461. // define column separation.
  7462. var cols = new Array(body[0].length).fill({
  7463. type: "align",
  7464. align: "c",
  7465. pregap: 0.25,
  7466. // CD package sets \enskip between columns.
  7467. postgap: 0.25 // So pre and post each get half an \enskip, i.e. 0.25em.
  7468. });
  7469. return {
  7470. type: "array",
  7471. mode: "math",
  7472. body,
  7473. arraystretch: 1,
  7474. addJot: true,
  7475. rowGaps: [null],
  7476. cols,
  7477. colSeparationType: "CD",
  7478. hLinesBeforeRow: new Array(body.length + 1).fill([])
  7479. };
  7480. }
  7481. // The functions below are not available for general use.
  7482. // They are here only for internal use by the {CD} environment in placing labels
  7483. // next to vertical arrows.
  7484. // We don't need any such functions for horizontal arrows because we can reuse
  7485. // the functionality that already exists for extensible arrows.
  7486. defineFunction({
  7487. type: "cdlabel",
  7488. names: ["\\\\cdleft", "\\\\cdright"],
  7489. props: {
  7490. numArgs: 1
  7491. },
  7492. handler(_ref, args) {
  7493. var {
  7494. parser,
  7495. funcName
  7496. } = _ref;
  7497. return {
  7498. type: "cdlabel",
  7499. mode: parser.mode,
  7500. side: funcName.slice(4),
  7501. label: args[0]
  7502. };
  7503. },
  7504. htmlBuilder(group, options) {
  7505. var newOptions = options.havingStyle(options.style.sup());
  7506. var label = wrapFragment(buildGroup$1(group.label, newOptions, options), options);
  7507. label.classes.push("cd-label-" + group.side);
  7508. label.style.bottom = makeEm(0.8 - label.depth);
  7509. // Zero out label height & depth, so vertical align of arrow is set
  7510. // by the arrow height, not by the label.
  7511. label.height = 0;
  7512. label.depth = 0;
  7513. return label;
  7514. },
  7515. mathmlBuilder(group, options) {
  7516. var label = new MathNode("mrow", [buildGroup(group.label, options)]);
  7517. label = new MathNode("mpadded", [label]);
  7518. label.setAttribute("width", "0");
  7519. if (group.side === "left") {
  7520. label.setAttribute("lspace", "-1width");
  7521. }
  7522. // We have to guess at vertical alignment. We know the arrow is 1.8em tall,
  7523. // But we don't know the height or depth of the label.
  7524. label.setAttribute("voffset", "0.7em");
  7525. label = new MathNode("mstyle", [label]);
  7526. label.setAttribute("displaystyle", "false");
  7527. label.setAttribute("scriptlevel", "1");
  7528. return label;
  7529. }
  7530. });
  7531. defineFunction({
  7532. type: "cdlabelparent",
  7533. names: ["\\\\cdparent"],
  7534. props: {
  7535. numArgs: 1
  7536. },
  7537. handler(_ref2, args) {
  7538. var {
  7539. parser
  7540. } = _ref2;
  7541. return {
  7542. type: "cdlabelparent",
  7543. mode: parser.mode,
  7544. fragment: args[0]
  7545. };
  7546. },
  7547. htmlBuilder(group, options) {
  7548. // Wrap the vertical arrow and its labels.
  7549. // The parent gets position: relative. The child gets position: absolute.
  7550. // So CSS can locate the label correctly.
  7551. var parent = wrapFragment(buildGroup$1(group.fragment, options), options);
  7552. parent.classes.push("cd-vert-arrow");
  7553. return parent;
  7554. },
  7555. mathmlBuilder(group, options) {
  7556. return new MathNode("mrow", [buildGroup(group.fragment, options)]);
  7557. }
  7558. });
  7559. // \@char is an internal function that takes a grouped decimal argument like
  7560. // {123} and converts into symbol with code 123. It is used by the *macro*
  7561. // \char defined in macros.js.
  7562. defineFunction({
  7563. type: "textord",
  7564. names: ["\\@char"],
  7565. props: {
  7566. numArgs: 1,
  7567. allowedInText: true
  7568. },
  7569. handler(_ref, args) {
  7570. var {
  7571. parser
  7572. } = _ref;
  7573. var arg = assertNodeType(args[0], "ordgroup");
  7574. var group = arg.body;
  7575. var number = "";
  7576. for (var i = 0; i < group.length; i++) {
  7577. var node = assertNodeType(group[i], "textord");
  7578. number += node.text;
  7579. }
  7580. var code = parseInt(number);
  7581. var text;
  7582. if (isNaN(code)) {
  7583. throw new ParseError("\\@char has non-numeric argument " + number);
  7584. // If we drop IE support, the following code could be replaced with
  7585. // text = String.fromCodePoint(code)
  7586. } else if (code < 0 || code >= 0x10ffff) {
  7587. throw new ParseError("\\@char with invalid code point " + number);
  7588. } else if (code <= 0xffff) {
  7589. text = String.fromCharCode(code);
  7590. } else {
  7591. // Astral code point; split into surrogate halves
  7592. code -= 0x10000;
  7593. text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00);
  7594. }
  7595. return {
  7596. type: "textord",
  7597. mode: parser.mode,
  7598. text: text
  7599. };
  7600. }
  7601. });
  7602. var htmlBuilder$8 = (group, options) => {
  7603. var elements = buildExpression$1(group.body, options.withColor(group.color), false);
  7604. // \color isn't supposed to affect the type of the elements it contains.
  7605. // To accomplish this, we wrap the results in a fragment, so the inner
  7606. // elements will be able to directly interact with their neighbors. For
  7607. // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3`
  7608. return makeFragment(elements);
  7609. };
  7610. var mathmlBuilder$7 = (group, options) => {
  7611. var inner = buildExpression(group.body, options.withColor(group.color));
  7612. var node = new MathNode("mstyle", inner);
  7613. node.setAttribute("mathcolor", group.color);
  7614. return node;
  7615. };
  7616. defineFunction({
  7617. type: "color",
  7618. names: ["\\textcolor"],
  7619. props: {
  7620. numArgs: 2,
  7621. allowedInText: true,
  7622. argTypes: ["color", "original"]
  7623. },
  7624. handler(_ref, args) {
  7625. var {
  7626. parser
  7627. } = _ref;
  7628. var color = assertNodeType(args[0], "color-token").color;
  7629. var body = args[1];
  7630. return {
  7631. type: "color",
  7632. mode: parser.mode,
  7633. color,
  7634. body: ordargument(body)
  7635. };
  7636. },
  7637. htmlBuilder: htmlBuilder$8,
  7638. mathmlBuilder: mathmlBuilder$7
  7639. });
  7640. defineFunction({
  7641. type: "color",
  7642. names: ["\\color"],
  7643. props: {
  7644. numArgs: 1,
  7645. allowedInText: true,
  7646. argTypes: ["color"]
  7647. },
  7648. handler(_ref2, args) {
  7649. var {
  7650. parser,
  7651. breakOnTokenText
  7652. } = _ref2;
  7653. var color = assertNodeType(args[0], "color-token").color;
  7654. // Set macro \current@color in current namespace to store the current
  7655. // color, mimicking the behavior of color.sty.
  7656. // This is currently used just to correctly color a \right
  7657. // that follows a \color command.
  7658. parser.gullet.macros.set("\\current@color", color);
  7659. // Parse out the implicit body that should be colored.
  7660. var body = parser.parseExpression(true, breakOnTokenText);
  7661. return {
  7662. type: "color",
  7663. mode: parser.mode,
  7664. color,
  7665. body
  7666. };
  7667. },
  7668. htmlBuilder: htmlBuilder$8,
  7669. mathmlBuilder: mathmlBuilder$7
  7670. });
  7671. // Row breaks within tabular environments, and line breaks at top level
  7672. // \DeclareRobustCommand\\{...\@xnewline}
  7673. defineFunction({
  7674. type: "cr",
  7675. names: ["\\\\"],
  7676. props: {
  7677. numArgs: 0,
  7678. numOptionalArgs: 0,
  7679. allowedInText: true
  7680. },
  7681. handler(_ref, args, optArgs) {
  7682. var {
  7683. parser
  7684. } = _ref;
  7685. var size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null;
  7686. var newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode");
  7687. return {
  7688. type: "cr",
  7689. mode: parser.mode,
  7690. newLine,
  7691. size: size && assertNodeType(size, "size").value
  7692. };
  7693. },
  7694. // The following builders are called only at the top level,
  7695. // not within tabular/array environments.
  7696. htmlBuilder(group, options) {
  7697. var span = makeSpan(["mspace"], [], options);
  7698. if (group.newLine) {
  7699. span.classes.push("newline");
  7700. if (group.size) {
  7701. span.style.marginTop = makeEm(calculateSize(group.size, options));
  7702. }
  7703. }
  7704. return span;
  7705. },
  7706. mathmlBuilder(group, options) {
  7707. var node = new MathNode("mspace");
  7708. if (group.newLine) {
  7709. node.setAttribute("linebreak", "newline");
  7710. if (group.size) {
  7711. node.setAttribute("height", makeEm(calculateSize(group.size, options)));
  7712. }
  7713. }
  7714. return node;
  7715. }
  7716. });
  7717. var globalMap = {
  7718. "\\global": "\\global",
  7719. "\\long": "\\\\globallong",
  7720. "\\\\globallong": "\\\\globallong",
  7721. "\\def": "\\gdef",
  7722. "\\gdef": "\\gdef",
  7723. "\\edef": "\\xdef",
  7724. "\\xdef": "\\xdef",
  7725. "\\let": "\\\\globallet",
  7726. "\\futurelet": "\\\\globalfuture"
  7727. };
  7728. var checkControlSequence = tok => {
  7729. var name = tok.text;
  7730. if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) {
  7731. throw new ParseError("Expected a control sequence", tok);
  7732. }
  7733. return name;
  7734. };
  7735. var getRHS = parser => {
  7736. var tok = parser.gullet.popToken();
  7737. if (tok.text === "=") {
  7738. // consume optional equals
  7739. tok = parser.gullet.popToken();
  7740. if (tok.text === " ") {
  7741. // consume one optional space
  7742. tok = parser.gullet.popToken();
  7743. }
  7744. }
  7745. return tok;
  7746. };
  7747. var letCommand = (parser, name, tok, global) => {
  7748. var macro = parser.gullet.macros.get(tok.text);
  7749. if (macro == null) {
  7750. // don't expand it later even if a macro with the same name is defined
  7751. // e.g., \let\foo=\frac \def\frac{\relax} \frac12
  7752. tok.noexpand = true;
  7753. macro = {
  7754. tokens: [tok],
  7755. numArgs: 0,
  7756. // reproduce the same behavior in expansion
  7757. unexpandable: !parser.gullet.isExpandable(tok.text)
  7758. };
  7759. }
  7760. parser.gullet.macros.set(name, macro, global);
  7761. };
  7762. // <assignment> -> <non-macro assignment>|<macro assignment>
  7763. // <non-macro assignment> -> <simple assignment>|\global<non-macro assignment>
  7764. // <macro assignment> -> <definition>|<prefix><macro assignment>
  7765. // <prefix> -> \global|\long|\outer
  7766. defineFunction({
  7767. type: "internal",
  7768. names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly
  7769. ],
  7770. props: {
  7771. numArgs: 0,
  7772. allowedInText: true
  7773. },
  7774. handler(_ref) {
  7775. var {
  7776. parser,
  7777. funcName
  7778. } = _ref;
  7779. parser.consumeSpaces();
  7780. var token = parser.fetch();
  7781. if (globalMap[token.text]) {
  7782. // KaTeX doesn't have \par, so ignore \long
  7783. if (funcName === "\\global" || funcName === "\\\\globallong") {
  7784. token.text = globalMap[token.text];
  7785. }
  7786. return assertNodeType(parser.parseFunction(), "internal");
  7787. }
  7788. throw new ParseError("Invalid token after macro prefix", token);
  7789. }
  7790. });
  7791. // Basic support for macro definitions: \def, \gdef, \edef, \xdef
  7792. // <definition> -> <def><control sequence><definition text>
  7793. // <def> -> \def|\gdef|\edef|\xdef
  7794. // <definition text> -> <parameter text><left brace><balanced text><right brace>
  7795. defineFunction({
  7796. type: "internal",
  7797. names: ["\\def", "\\gdef", "\\edef", "\\xdef"],
  7798. props: {
  7799. numArgs: 0,
  7800. allowedInText: true,
  7801. primitive: true
  7802. },
  7803. handler(_ref2) {
  7804. var {
  7805. parser,
  7806. funcName
  7807. } = _ref2;
  7808. var tok = parser.gullet.popToken();
  7809. var name = tok.text;
  7810. if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) {
  7811. throw new ParseError("Expected a control sequence", tok);
  7812. }
  7813. var numArgs = 0;
  7814. var insert;
  7815. var delimiters = [[]];
  7816. // <parameter text> contains no braces
  7817. while (parser.gullet.future().text !== "{") {
  7818. tok = parser.gullet.popToken();
  7819. if (tok.text === "#") {
  7820. // If the very last character of the <parameter text> is #, so that
  7821. // this # is immediately followed by {, TeX will behave as if the {
  7822. // had been inserted at the right end of both the parameter text
  7823. // and the replacement text.
  7824. if (parser.gullet.future().text === "{") {
  7825. insert = parser.gullet.future();
  7826. delimiters[numArgs].push("{");
  7827. break;
  7828. }
  7829. // A parameter, the first appearance of # must be followed by 1,
  7830. // the next by 2, and so on; up to nine #’s are allowed
  7831. tok = parser.gullet.popToken();
  7832. if (!/^[1-9]$/.test(tok.text)) {
  7833. throw new ParseError("Invalid argument number \"" + tok.text + "\"");
  7834. }
  7835. if (parseInt(tok.text) !== numArgs + 1) {
  7836. throw new ParseError("Argument number \"" + tok.text + "\" out of order");
  7837. }
  7838. numArgs++;
  7839. delimiters.push([]);
  7840. } else if (tok.text === "EOF") {
  7841. throw new ParseError("Expected a macro definition");
  7842. } else {
  7843. delimiters[numArgs].push(tok.text);
  7844. }
  7845. }
  7846. // replacement text, enclosed in '{' and '}' and properly nested
  7847. var {
  7848. tokens
  7849. } = parser.gullet.consumeArg();
  7850. if (insert) {
  7851. tokens.unshift(insert);
  7852. }
  7853. if (funcName === "\\edef" || funcName === "\\xdef") {
  7854. tokens = parser.gullet.expandTokens(tokens);
  7855. tokens.reverse(); // to fit in with stack order
  7856. }
  7857. // Final arg is the expansion of the macro
  7858. parser.gullet.macros.set(name, {
  7859. tokens,
  7860. numArgs,
  7861. delimiters
  7862. }, funcName === globalMap[funcName]);
  7863. return {
  7864. type: "internal",
  7865. mode: parser.mode
  7866. };
  7867. }
  7868. });
  7869. // <simple assignment> -> <let assignment>
  7870. // <let assignment> -> \futurelet<control sequence><token><token>
  7871. // | \let<control sequence><equals><one optional space><token>
  7872. // <equals> -> <optional spaces>|<optional spaces>=
  7873. defineFunction({
  7874. type: "internal",
  7875. names: ["\\let", "\\\\globallet" // can’t be entered directly
  7876. ],
  7877. props: {
  7878. numArgs: 0,
  7879. allowedInText: true,
  7880. primitive: true
  7881. },
  7882. handler(_ref3) {
  7883. var {
  7884. parser,
  7885. funcName
  7886. } = _ref3;
  7887. var name = checkControlSequence(parser.gullet.popToken());
  7888. parser.gullet.consumeSpaces();
  7889. var tok = getRHS(parser);
  7890. letCommand(parser, name, tok, funcName === "\\\\globallet");
  7891. return {
  7892. type: "internal",
  7893. mode: parser.mode
  7894. };
  7895. }
  7896. });
  7897. // ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf
  7898. defineFunction({
  7899. type: "internal",
  7900. names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly
  7901. ],
  7902. props: {
  7903. numArgs: 0,
  7904. allowedInText: true,
  7905. primitive: true
  7906. },
  7907. handler(_ref4) {
  7908. var {
  7909. parser,
  7910. funcName
  7911. } = _ref4;
  7912. var name = checkControlSequence(parser.gullet.popToken());
  7913. var middle = parser.gullet.popToken();
  7914. var tok = parser.gullet.popToken();
  7915. letCommand(parser, name, tok, funcName === "\\\\globalfuture");
  7916. parser.gullet.pushToken(tok);
  7917. parser.gullet.pushToken(middle);
  7918. return {
  7919. type: "internal",
  7920. mode: parser.mode
  7921. };
  7922. }
  7923. });
  7924. /**
  7925. * This file deals with creating delimiters of various sizes. The TeXbook
  7926. * discusses these routines on page 441-442, in the "Another subroutine sets box
  7927. * x to a specified variable delimiter" paragraph.
  7928. *
  7929. * There are three main routines here. `makeSmallDelim` makes a delimiter in the
  7930. * normal font, but in either text, script, or scriptscript style.
  7931. * `makeLargeDelim` makes a delimiter in textstyle, but in one of the Size1,
  7932. * Size2, Size3, or Size4 fonts. `makeStackedDelim` makes a delimiter out of
  7933. * smaller pieces that are stacked on top of one another.
  7934. *
  7935. * The functions take a parameter `center`, which determines if the delimiter
  7936. * should be centered around the axis.
  7937. *
  7938. * Then, there are three exposed functions. `sizedDelim` makes a delimiter in
  7939. * one of the given sizes. This is used for things like `\bigl`.
  7940. * `customSizedDelim` makes a delimiter with a given total height+depth. It is
  7941. * called in places like `\sqrt`. `leftRightDelim` makes an appropriate
  7942. * delimiter which surrounds an expression of a given height an depth. It is
  7943. * used in `\left` and `\right`.
  7944. */
  7945. /**
  7946. * Get the metrics for a given symbol and font, after transformation (i.e.
  7947. * after following replacement from symbols.js)
  7948. */
  7949. var getMetrics = function getMetrics(symbol, font, mode) {
  7950. var replace = symbols.math[symbol] && symbols.math[symbol].replace;
  7951. var metrics = getCharacterMetrics(replace || symbol, font, mode);
  7952. if (!metrics) {
  7953. throw new Error("Unsupported symbol " + symbol + " and font size " + font + ".");
  7954. }
  7955. return metrics;
  7956. };
  7957. /**
  7958. * Puts a delimiter span in a given style, and adds appropriate height, depth,
  7959. * and maxFontSizes.
  7960. */
  7961. var styleWrap = function styleWrap(delim, toStyle, options, classes) {
  7962. var newOptions = options.havingBaseStyle(toStyle);
  7963. var span = makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options);
  7964. var delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier;
  7965. span.height *= delimSizeMultiplier;
  7966. span.depth *= delimSizeMultiplier;
  7967. span.maxFontSize = newOptions.sizeMultiplier;
  7968. return span;
  7969. };
  7970. var centerSpan = function centerSpan(span, options, style) {
  7971. var newOptions = options.havingBaseStyle(style);
  7972. var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight;
  7973. span.classes.push("delimcenter");
  7974. span.style.top = makeEm(shift);
  7975. span.height -= shift;
  7976. span.depth += shift;
  7977. };
  7978. /**
  7979. * Makes a small delimiter. This is a delimiter that comes in the Main-Regular
  7980. * font, but is restyled to either be in textstyle, scriptstyle, or
  7981. * scriptscriptstyle.
  7982. */
  7983. var makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) {
  7984. var text = makeSymbol(delim, "Main-Regular", mode, options);
  7985. var span = styleWrap(text, style, options, classes);
  7986. if (center) {
  7987. centerSpan(span, options, style);
  7988. }
  7989. return span;
  7990. };
  7991. /**
  7992. * Builds a symbol in the given font size (note size is an integer)
  7993. */
  7994. var mathrmSize = function mathrmSize(value, size, mode, options) {
  7995. return makeSymbol(value, "Size" + size + "-Regular", mode, options);
  7996. };
  7997. /**
  7998. * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2,
  7999. * Size3, or Size4 fonts. It is always rendered in textstyle.
  8000. */
  8001. var makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) {
  8002. var inner = mathrmSize(delim, size, mode, options);
  8003. var span = styleWrap(makeSpan(["delimsizing", "size" + size], [inner], options), Style$1.TEXT, options, classes);
  8004. if (center) {
  8005. centerSpan(span, options, Style$1.TEXT);
  8006. }
  8007. return span;
  8008. };
  8009. /**
  8010. * Make a span from a font glyph with the given offset and in the given font.
  8011. * This is used in makeStackedDelim to make the stacking pieces for the delimiter.
  8012. */
  8013. var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) {
  8014. var sizeClass;
  8015. // Apply the correct CSS class to choose the right font.
  8016. if (font === "Size1-Regular") {
  8017. sizeClass = "delim-size1";
  8018. } else /* if (font === "Size4-Regular") */{
  8019. sizeClass = "delim-size4";
  8020. }
  8021. var corner = makeSpan(["delimsizinginner", sizeClass], [makeSpan([], [makeSymbol(symbol, font, mode)])]);
  8022. // Since this will be passed into `makeVList` in the end, wrap the element
  8023. // in the appropriate tag that VList uses.
  8024. return {
  8025. type: "elem",
  8026. elem: corner
  8027. };
  8028. };
  8029. var makeInner = function makeInner(ch, height, options) {
  8030. // Create a span with inline SVG for the inner part of a tall stacked delimiter.
  8031. var width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)] ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4] : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4];
  8032. var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height)));
  8033. var svgNode = new SvgNode([path], {
  8034. "width": makeEm(width),
  8035. "height": makeEm(height),
  8036. // Override CSS rule `.katex svg { width: 100% }`
  8037. "style": "width:" + makeEm(width),
  8038. "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height),
  8039. "preserveAspectRatio": "xMinYMin"
  8040. });
  8041. var span = makeSvgSpan([], [svgNode], options);
  8042. span.height = height;
  8043. span.style.height = makeEm(height);
  8044. span.style.width = makeEm(width);
  8045. return {
  8046. type: "elem",
  8047. elem: span
  8048. };
  8049. };
  8050. // Helpers for makeStackedDelim
  8051. var lapInEms = 0.008;
  8052. var lap = {
  8053. type: "kern",
  8054. size: -1 * lapInEms
  8055. };
  8056. var verts = new Set(["|", "\\lvert", "\\rvert", "\\vert"]);
  8057. var doubleVerts = new Set(["\\|", "\\lVert", "\\rVert", "\\Vert"]);
  8058. /**
  8059. * Make a stacked delimiter out of a given delimiter, with the total height at
  8060. * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook.
  8061. */
  8062. var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) {
  8063. // There are four parts, the top, an optional middle, a repeated part, and a
  8064. // bottom.
  8065. var top;
  8066. var middle;
  8067. var repeat;
  8068. var bottom;
  8069. var svgLabel = "";
  8070. var viewBoxWidth = 0;
  8071. top = repeat = bottom = delim;
  8072. middle = null;
  8073. // Also keep track of what font the delimiters are in
  8074. var font = "Size1-Regular";
  8075. // We set the parts and font based on the symbol. Note that we use
  8076. // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the
  8077. // repeats of the arrows
  8078. if (delim === "\\uparrow") {
  8079. repeat = bottom = "\u23d0";
  8080. } else if (delim === "\\Uparrow") {
  8081. repeat = bottom = "\u2016";
  8082. } else if (delim === "\\downarrow") {
  8083. top = repeat = "\u23d0";
  8084. } else if (delim === "\\Downarrow") {
  8085. top = repeat = "\u2016";
  8086. } else if (delim === "\\updownarrow") {
  8087. top = "\\uparrow";
  8088. repeat = "\u23d0";
  8089. bottom = "\\downarrow";
  8090. } else if (delim === "\\Updownarrow") {
  8091. top = "\\Uparrow";
  8092. repeat = "\u2016";
  8093. bottom = "\\Downarrow";
  8094. } else if (verts.has(delim)) {
  8095. repeat = "\u2223";
  8096. svgLabel = "vert";
  8097. viewBoxWidth = 333;
  8098. } else if (doubleVerts.has(delim)) {
  8099. repeat = "\u2225";
  8100. svgLabel = "doublevert";
  8101. viewBoxWidth = 556;
  8102. } else if (delim === "[" || delim === "\\lbrack") {
  8103. top = "\u23a1";
  8104. repeat = "\u23a2";
  8105. bottom = "\u23a3";
  8106. font = "Size4-Regular";
  8107. svgLabel = "lbrack";
  8108. viewBoxWidth = 667;
  8109. } else if (delim === "]" || delim === "\\rbrack") {
  8110. top = "\u23a4";
  8111. repeat = "\u23a5";
  8112. bottom = "\u23a6";
  8113. font = "Size4-Regular";
  8114. svgLabel = "rbrack";
  8115. viewBoxWidth = 667;
  8116. } else if (delim === "\\lfloor" || delim === "\u230a") {
  8117. repeat = top = "\u23a2";
  8118. bottom = "\u23a3";
  8119. font = "Size4-Regular";
  8120. svgLabel = "lfloor";
  8121. viewBoxWidth = 667;
  8122. } else if (delim === "\\lceil" || delim === "\u2308") {
  8123. top = "\u23a1";
  8124. repeat = bottom = "\u23a2";
  8125. font = "Size4-Regular";
  8126. svgLabel = "lceil";
  8127. viewBoxWidth = 667;
  8128. } else if (delim === "\\rfloor" || delim === "\u230b") {
  8129. repeat = top = "\u23a5";
  8130. bottom = "\u23a6";
  8131. font = "Size4-Regular";
  8132. svgLabel = "rfloor";
  8133. viewBoxWidth = 667;
  8134. } else if (delim === "\\rceil" || delim === "\u2309") {
  8135. top = "\u23a4";
  8136. repeat = bottom = "\u23a5";
  8137. font = "Size4-Regular";
  8138. svgLabel = "rceil";
  8139. viewBoxWidth = 667;
  8140. } else if (delim === "(" || delim === "\\lparen") {
  8141. top = "\u239b";
  8142. repeat = "\u239c";
  8143. bottom = "\u239d";
  8144. font = "Size4-Regular";
  8145. svgLabel = "lparen";
  8146. viewBoxWidth = 875;
  8147. } else if (delim === ")" || delim === "\\rparen") {
  8148. top = "\u239e";
  8149. repeat = "\u239f";
  8150. bottom = "\u23a0";
  8151. font = "Size4-Regular";
  8152. svgLabel = "rparen";
  8153. viewBoxWidth = 875;
  8154. } else if (delim === "\\{" || delim === "\\lbrace") {
  8155. top = "\u23a7";
  8156. middle = "\u23a8";
  8157. bottom = "\u23a9";
  8158. repeat = "\u23aa";
  8159. font = "Size4-Regular";
  8160. } else if (delim === "\\}" || delim === "\\rbrace") {
  8161. top = "\u23ab";
  8162. middle = "\u23ac";
  8163. bottom = "\u23ad";
  8164. repeat = "\u23aa";
  8165. font = "Size4-Regular";
  8166. } else if (delim === "\\lgroup" || delim === "\u27ee") {
  8167. top = "\u23a7";
  8168. bottom = "\u23a9";
  8169. repeat = "\u23aa";
  8170. font = "Size4-Regular";
  8171. } else if (delim === "\\rgroup" || delim === "\u27ef") {
  8172. top = "\u23ab";
  8173. bottom = "\u23ad";
  8174. repeat = "\u23aa";
  8175. font = "Size4-Regular";
  8176. } else if (delim === "\\lmoustache" || delim === "\u23b0") {
  8177. top = "\u23a7";
  8178. bottom = "\u23ad";
  8179. repeat = "\u23aa";
  8180. font = "Size4-Regular";
  8181. } else if (delim === "\\rmoustache" || delim === "\u23b1") {
  8182. top = "\u23ab";
  8183. bottom = "\u23a9";
  8184. repeat = "\u23aa";
  8185. font = "Size4-Regular";
  8186. }
  8187. // Get the metrics of the four sections
  8188. var topMetrics = getMetrics(top, font, mode);
  8189. var topHeightTotal = topMetrics.height + topMetrics.depth;
  8190. var repeatMetrics = getMetrics(repeat, font, mode);
  8191. var repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth;
  8192. var bottomMetrics = getMetrics(bottom, font, mode);
  8193. var bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth;
  8194. var middleHeightTotal = 0;
  8195. var middleFactor = 1;
  8196. if (middle !== null) {
  8197. var middleMetrics = getMetrics(middle, font, mode);
  8198. middleHeightTotal = middleMetrics.height + middleMetrics.depth;
  8199. middleFactor = 2; // repeat symmetrically above and below middle
  8200. }
  8201. // Calculate the minimal height that the delimiter can have.
  8202. // It is at least the size of the top, bottom, and optional middle combined.
  8203. var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal;
  8204. // Compute the number of copies of the repeat symbol we will need
  8205. var repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal)));
  8206. // Compute the total height of the delimiter including all the symbols
  8207. var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal;
  8208. // The center of the delimiter is placed at the center of the axis. Note
  8209. // that in this context, "center" means that the delimiter should be
  8210. // centered around the axis in the current style, while normally it is
  8211. // centered around the axis in textstyle.
  8212. var axisHeight = options.fontMetrics().axisHeight;
  8213. if (center) {
  8214. axisHeight *= options.sizeMultiplier;
  8215. }
  8216. // Calculate the depth
  8217. var depth = realHeightTotal / 2 - axisHeight;
  8218. // Now, we start building the pieces that will go into the vlist
  8219. // Keep a list of the pieces of the stacked delimiter
  8220. var stack = [];
  8221. if (svgLabel.length > 0) {
  8222. // Instead of stacking glyphs, create a single SVG.
  8223. // This evades browser problems with imprecise positioning of spans.
  8224. var midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal;
  8225. var viewBoxHeight = Math.round(realHeightTotal * 1000);
  8226. var pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000));
  8227. var path = new PathNode(svgLabel, pathStr);
  8228. var width = makeEm(viewBoxWidth / 1000);
  8229. var height = makeEm(viewBoxHeight / 1000);
  8230. var svg = new SvgNode([path], {
  8231. "width": width,
  8232. "height": height,
  8233. "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight
  8234. });
  8235. var wrapper = makeSvgSpan([], [svg], options);
  8236. wrapper.height = viewBoxHeight / 1000;
  8237. wrapper.style.width = width;
  8238. wrapper.style.height = height;
  8239. stack.push({
  8240. type: "elem",
  8241. elem: wrapper
  8242. });
  8243. } else {
  8244. // Stack glyphs
  8245. // Start by adding the bottom symbol
  8246. stack.push(makeGlyphSpan(bottom, font, mode));
  8247. stack.push(lap); // overlap
  8248. if (middle === null) {
  8249. // The middle section will be an SVG. Make it an extra 0.016em tall.
  8250. // We'll overlap by 0.008em at top and bottom.
  8251. var innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms;
  8252. stack.push(makeInner(repeat, innerHeight, options));
  8253. } else {
  8254. // When there is a middle bit, we need the middle part and two repeated
  8255. // sections
  8256. var _innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms;
  8257. stack.push(makeInner(repeat, _innerHeight, options));
  8258. // Now insert the middle of the brace.
  8259. stack.push(lap);
  8260. stack.push(makeGlyphSpan(middle, font, mode));
  8261. stack.push(lap);
  8262. stack.push(makeInner(repeat, _innerHeight, options));
  8263. }
  8264. // Add the top symbol
  8265. stack.push(lap);
  8266. stack.push(makeGlyphSpan(top, font, mode));
  8267. }
  8268. // Finally, build the vlist
  8269. var newOptions = options.havingBaseStyle(Style$1.TEXT);
  8270. var inner = makeVList({
  8271. positionType: "bottom",
  8272. positionData: depth,
  8273. children: stack
  8274. });
  8275. return styleWrap(makeSpan(["delimsizing", "mult"], [inner], newOptions), Style$1.TEXT, options, classes);
  8276. };
  8277. // All surds have 0.08em padding above the vinculum inside the SVG.
  8278. // That keeps browser span height rounding error from pinching the line.
  8279. var vbPad = 80; // padding above the surd, measured inside the viewBox.
  8280. var emPad = 0.08; // padding, in ems, measured in the document.
  8281. var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraVinculum, options) {
  8282. var path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight);
  8283. var pathNode = new PathNode(sqrtName, path);
  8284. var svg = new SvgNode([pathNode], {
  8285. // Note: 1000:1 ratio of viewBox to document em width.
  8286. "width": "400em",
  8287. "height": makeEm(height),
  8288. "viewBox": "0 0 400000 " + viewBoxHeight,
  8289. "preserveAspectRatio": "xMinYMin slice"
  8290. });
  8291. return makeSvgSpan(["hide-tail"], [svg], options);
  8292. };
  8293. /**
  8294. * Make a sqrt image of the given height,
  8295. */
  8296. var makeSqrtImage = function makeSqrtImage(height, options) {
  8297. // Define a newOptions that removes the effect of size changes such as \Huge.
  8298. // We don't pick different a height surd for \Huge. For it, we scale up.
  8299. var newOptions = options.havingBaseSizing();
  8300. // Pick the desired surd glyph from a sequence of surds.
  8301. var delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions);
  8302. var sizeMultiplier = newOptions.sizeMultiplier; // default
  8303. // The standard sqrt SVGs each have a 0.04em thick vinculum.
  8304. // If Settings.minRuleThickness is larger than that, we add extraVinculum.
  8305. var extraVinculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness);
  8306. // Create a span containing an SVG image of a sqrt symbol.
  8307. var span;
  8308. var spanHeight = 0;
  8309. var texHeight = 0;
  8310. var viewBoxHeight = 0;
  8311. var advanceWidth;
  8312. // 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 vinculum. 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 * extraVinculum + 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 + extraVinculum + emPad) / sizeMultiplier;
  8327. texHeight = (1.00 + extraVinculum) / sizeMultiplier;
  8328. span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum, 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] + extraVinculum) / sizeMultiplier;
  8335. spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad) / sizeMultiplier;
  8336. span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraVinculum, 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 + extraVinculum + emPad;
  8343. texHeight = height + extraVinculum;
  8344. viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad;
  8345. span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum, 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,
  8353. 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 + extraVinculum) * sizeMultiplier
  8359. };
  8360. };
  8361. // There are three kinds of delimiters, delimiters that stack when they become
  8362. // too large
  8363. var stackLargeDelimiters = new Set(["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]);
  8364. // delimiters that always stack
  8365. var stackAlwaysDelimiters = new Set(["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1"]);
  8366. // and delimiters that never stack
  8367. var stackNeverDelimiters = new Set(["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]);
  8368. // Metrics of the different sizes. Found by looking at TeX's output of
  8369. // $\bigl| // \Bigl| \biggl| \Biggl| \showlists$
  8370. // Used to create stacked delimiters of appropriate sizes in makeSizedDelim.
  8371. var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0];
  8372. /**
  8373. * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4.
  8374. */
  8375. var makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) {
  8376. // < and > turn into \langle and \rangle in delimiters
  8377. if (delim === "<" || delim === "\\lt" || delim === "\u27e8") {
  8378. delim = "\\langle";
  8379. } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") {
  8380. delim = "\\rangle";
  8381. }
  8382. // Sized delimiters are never centered.
  8383. if (stackLargeDelimiters.has(delim) || stackNeverDelimiters.has(delim)) {
  8384. return makeLargeDelim(delim, size, false, options, mode, classes);
  8385. } else if (stackAlwaysDelimiters.has(delim)) {
  8386. return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes);
  8387. } else {
  8388. throw new ParseError("Illegal delimiter: '" + delim + "'");
  8389. }
  8390. };
  8391. // Delimiters that never stack try small delimiters and large delimiters only
  8392. var stackNeverDelimiterSequence = [{
  8393. type: "small",
  8394. style: Style$1.SCRIPTSCRIPT
  8395. }, {
  8396. type: "small",
  8397. style: Style$1.SCRIPT
  8398. }, {
  8399. type: "small",
  8400. style: Style$1.TEXT
  8401. }, {
  8402. type: "large",
  8403. size: 1
  8404. }, {
  8405. type: "large",
  8406. size: 2
  8407. }, {
  8408. type: "large",
  8409. size: 3
  8410. }, {
  8411. type: "large",
  8412. size: 4
  8413. }];
  8414. // Delimiters that always stack try the small delimiters first, then stack
  8415. var stackAlwaysDelimiterSequence = [{
  8416. type: "small",
  8417. style: Style$1.SCRIPTSCRIPT
  8418. }, {
  8419. type: "small",
  8420. style: Style$1.SCRIPT
  8421. }, {
  8422. type: "small",
  8423. style: Style$1.TEXT
  8424. }, {
  8425. type: "stack"
  8426. }];
  8427. // Delimiters that stack when large try the small and then large delimiters, and
  8428. // stack afterwards
  8429. var stackLargeDelimiterSequence = [{
  8430. type: "small",
  8431. style: Style$1.SCRIPTSCRIPT
  8432. }, {
  8433. type: "small",
  8434. style: Style$1.SCRIPT
  8435. }, {
  8436. type: "small",
  8437. style: Style$1.TEXT
  8438. }, {
  8439. type: "large",
  8440. size: 1
  8441. }, {
  8442. type: "large",
  8443. size: 2
  8444. }, {
  8445. type: "large",
  8446. size: 3
  8447. }, {
  8448. type: "large",
  8449. size: 4
  8450. }, {
  8451. type: "stack"
  8452. }];
  8453. /**
  8454. * Get the font used in a delimiter based on what kind of delimiter it is.
  8455. * TODO(#963) Use more specific font family return type once that is introduced.
  8456. */
  8457. var delimTypeToFont = function delimTypeToFont(type) {
  8458. if (type.type === "small") {
  8459. return "Main-Regular";
  8460. } else if (type.type === "large") {
  8461. return "Size" + type.size + "-Regular";
  8462. } else if (type.type === "stack") {
  8463. return "Size4-Regular";
  8464. } else {
  8465. var delimKind = type.type;
  8466. throw new Error("Add support for delim type '" + delimKind + "' here.");
  8467. }
  8468. };
  8469. /**
  8470. * Traverse a sequence of types of delimiters to decide what kind of delimiter
  8471. * should be used to create a delimiter of the given height+depth.
  8472. */
  8473. var traverseSequence = function traverseSequence(delim, height, sequence, options) {
  8474. // Here, we choose the index we should start at in the sequences. In smaller
  8475. // sizes (which correspond to larger numbers in style.size) we start earlier
  8476. // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts
  8477. // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2
  8478. var start = Math.min(2, 3 - options.style.size);
  8479. for (var i = start; i < sequence.length; i++) {
  8480. var delimType = sequence[i];
  8481. if (delimType.type === "stack") {
  8482. // This is always the last delimiter, so we just break the loop now.
  8483. break;
  8484. }
  8485. var metrics = getMetrics(delim, delimTypeToFont(delimType), "math");
  8486. var heightDepth = metrics.height + metrics.depth;
  8487. // Small delimiters are scaled down versions of the same font, so we
  8488. // account for the style change size.
  8489. if (delimType.type === "small") {
  8490. var newOptions = options.havingBaseStyle(delimType.style);
  8491. heightDepth *= newOptions.sizeMultiplier;
  8492. }
  8493. // Check if the delimiter at this size works for the given height.
  8494. if (heightDepth > height) {
  8495. return delimType;
  8496. }
  8497. }
  8498. // If we reached the end of the sequence, return the last sequence element.
  8499. return sequence[sequence.length - 1];
  8500. };
  8501. /**
  8502. * Make a delimiter of a given height+depth, with optional centering. Here, we
  8503. * traverse the sequences, and create a delimiter that the sequence tells us to.
  8504. */
  8505. var makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) {
  8506. if (delim === "<" || delim === "\\lt" || delim === "\u27e8") {
  8507. delim = "\\langle";
  8508. } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") {
  8509. delim = "\\rangle";
  8510. }
  8511. // Decide what sequence to use
  8512. var sequence;
  8513. if (stackNeverDelimiters.has(delim)) {
  8514. sequence = stackNeverDelimiterSequence;
  8515. } else if (stackLargeDelimiters.has(delim)) {
  8516. sequence = stackLargeDelimiterSequence;
  8517. } else {
  8518. sequence = stackAlwaysDelimiterSequence;
  8519. }
  8520. // Look through the sequence
  8521. var delimType = traverseSequence(delim, height, sequence, options);
  8522. // Get the delimiter from font glyphs.
  8523. // Depending on the sequence element we decided on, call the
  8524. // appropriate function.
  8525. if (delimType.type === "small") {
  8526. return makeSmallDelim(delim, delimType.style, center, options, mode, classes);
  8527. } else if (delimType.type === "large") {
  8528. return makeLargeDelim(delim, delimType.size, center, options, mode, classes);
  8529. } else /* if (delimType.type === "stack") */{
  8530. return makeStackedDelim(delim, height, center, options, mode, classes);
  8531. }
  8532. };
  8533. /**
  8534. * Make a delimiter for use with `\left` and `\right`, given a height and depth
  8535. * of an expression that the delimiters surround.
  8536. */
  8537. var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) {
  8538. // We always center \left/\right delimiters, so the axis is always shifted
  8539. var axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier;
  8540. // Taken from TeX source, tex.web, function make_left_right
  8541. var delimiterFactor = 901;
  8542. var delimiterExtend = 5.0 / options.fontMetrics().ptPerEm;
  8543. var maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight);
  8544. var totalHeight = Math.max(
  8545. // In real TeX, calculations are done using integral values which are
  8546. // 65536 per pt, or 655360 per em. So, the division here truncates in
  8547. // TeX but doesn't here, producing different results. If we wanted to
  8548. // exactly match TeX's calculation, we could do
  8549. // Math.floor(655360 * maxDistFromAxis / 500) *
  8550. // delimiterFactor / 655360
  8551. // (To see the difference, compare
  8552. // x^{x^{\left(\rule{0.1em}{0.68em}\right)}}
  8553. // in TeX and KaTeX)
  8554. maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend);
  8555. // Finally, we defer to `makeCustomSizedDelim` with our calculated total
  8556. // height
  8557. return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes);
  8558. };
  8559. // Extra data needed for the delimiter handler down below
  8560. var delimiterSizes = {
  8561. "\\bigl": {
  8562. mclass: "mopen",
  8563. size: 1
  8564. },
  8565. "\\Bigl": {
  8566. mclass: "mopen",
  8567. size: 2
  8568. },
  8569. "\\biggl": {
  8570. mclass: "mopen",
  8571. size: 3
  8572. },
  8573. "\\Biggl": {
  8574. mclass: "mopen",
  8575. size: 4
  8576. },
  8577. "\\bigr": {
  8578. mclass: "mclose",
  8579. size: 1
  8580. },
  8581. "\\Bigr": {
  8582. mclass: "mclose",
  8583. size: 2
  8584. },
  8585. "\\biggr": {
  8586. mclass: "mclose",
  8587. size: 3
  8588. },
  8589. "\\Biggr": {
  8590. mclass: "mclose",
  8591. size: 4
  8592. },
  8593. "\\bigm": {
  8594. mclass: "mrel",
  8595. size: 1
  8596. },
  8597. "\\Bigm": {
  8598. mclass: "mrel",
  8599. size: 2
  8600. },
  8601. "\\biggm": {
  8602. mclass: "mrel",
  8603. size: 3
  8604. },
  8605. "\\Biggm": {
  8606. mclass: "mrel",
  8607. size: 4
  8608. },
  8609. "\\big": {
  8610. mclass: "mord",
  8611. size: 1
  8612. },
  8613. "\\Big": {
  8614. mclass: "mord",
  8615. size: 2
  8616. },
  8617. "\\bigg": {
  8618. mclass: "mord",
  8619. size: 3
  8620. },
  8621. "\\Bigg": {
  8622. mclass: "mord",
  8623. size: 4
  8624. }
  8625. };
  8626. var delimiters = new Set(["(", "\\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", "."]);
  8627. // Delimiter functions
  8628. function checkDelimiter(delim, context) {
  8629. var symDelim = checkSymbolNodeType(delim);
  8630. if (symDelim && delimiters.has(symDelim.text)) {
  8631. return symDelim;
  8632. } else if (symDelim) {
  8633. throw new ParseError("Invalid delimiter '" + symDelim.text + "' after '" + context.funcName + "'", delim);
  8634. } else {
  8635. throw new ParseError("Invalid delimiter type '" + delim.type + "'", delim);
  8636. }
  8637. }
  8638. defineFunction({
  8639. type: "delimsizing",
  8640. names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"],
  8641. props: {
  8642. numArgs: 1,
  8643. argTypes: ["primitive"]
  8644. },
  8645. handler: (context, args) => {
  8646. var delim = checkDelimiter(args[0], context);
  8647. return {
  8648. type: "delimsizing",
  8649. mode: context.parser.mode,
  8650. size: delimiterSizes[context.funcName].size,
  8651. mclass: delimiterSizes[context.funcName].mclass,
  8652. delim: delim.text
  8653. };
  8654. },
  8655. htmlBuilder: (group, options) => {
  8656. if (group.delim === ".") {
  8657. // Empty delimiters still count as elements, even though they don't
  8658. // show anything.
  8659. return makeSpan([group.mclass]);
  8660. }
  8661. return makeSizedDelim(group.delim, group.size, options, group.mode, [group.mclass]);
  8662. },
  8663. mathmlBuilder: group => {
  8664. var children = [];
  8665. if (group.delim !== ".") {
  8666. children.push(makeText(group.delim, group.mode));
  8667. }
  8668. var node = new MathNode("mo", children);
  8669. if (group.mclass === "mopen" || group.mclass === "mclose") {
  8670. // Only some of the delimsizing functions act as fences, and they
  8671. // return "mopen" or "mclose" mclass.
  8672. node.setAttribute("fence", "true");
  8673. } else {
  8674. // Explicitly disable fencing if it's not a fence, to override the
  8675. // defaults.
  8676. node.setAttribute("fence", "false");
  8677. }
  8678. node.setAttribute("stretchy", "true");
  8679. var size = makeEm(sizeToMaxHeight[group.size]);
  8680. node.setAttribute("minsize", size);
  8681. node.setAttribute("maxsize", size);
  8682. return node;
  8683. }
  8684. });
  8685. function assertParsed(group) {
  8686. if (!group.body) {
  8687. throw new Error("Bug: The leftright ParseNode wasn't fully parsed.");
  8688. }
  8689. }
  8690. defineFunction({
  8691. type: "leftright-right",
  8692. names: ["\\right"],
  8693. props: {
  8694. numArgs: 1,
  8695. primitive: true
  8696. },
  8697. handler: (context, args) => {
  8698. // \left case below triggers parsing of \right in
  8699. // `const right = parser.parseFunction();`
  8700. // uses this return value.
  8701. var color = context.parser.gullet.macros.get("\\current@color");
  8702. if (color && typeof color !== "string") {
  8703. throw new ParseError("\\current@color set to non-string in \\right");
  8704. }
  8705. return {
  8706. type: "leftright-right",
  8707. mode: context.parser.mode,
  8708. delim: checkDelimiter(args[0], context).text,
  8709. color: color // undefined if not set via \color
  8710. };
  8711. }
  8712. });
  8713. defineFunction({
  8714. type: "leftright",
  8715. names: ["\\left"],
  8716. props: {
  8717. numArgs: 1,
  8718. primitive: true
  8719. },
  8720. handler: (context, args) => {
  8721. var delim = checkDelimiter(args[0], context);
  8722. var parser = context.parser;
  8723. // Parse out the implicit body
  8724. ++parser.leftrightDepth;
  8725. // parseExpression stops before '\\right'
  8726. var body = parser.parseExpression(false);
  8727. --parser.leftrightDepth;
  8728. // 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,
  8735. left: delim.text,
  8736. right: right.delim,
  8737. rightColor: right.color
  8738. };
  8739. },
  8740. htmlBuilder: (group, options) => {
  8741. assertParsed(group);
  8742. // Build the inner expression
  8743. var inner = buildExpression$1(group.body, options, true, ["mopen", "mclose"]);
  8744. var innerHeight = 0;
  8745. var innerDepth = 0;
  8746. var hadMiddle = false;
  8747. // Calculate its height and depth
  8748. for (var i = 0; i < inner.length; i++) {
  8749. // Property `isMiddle` not defined on `span`. See comment in
  8750. // "middle"'s htmlBuilder.
  8751. // TODO(ts)
  8752. if (inner[i].isMiddle) {
  8753. hadMiddle = true;
  8754. } else {
  8755. innerHeight = Math.max(inner[i].height, innerHeight);
  8756. innerDepth = Math.max(inner[i].depth, innerDepth);
  8757. }
  8758. }
  8759. // The size of delimiters is the same, regardless of what style we are
  8760. // in. Thus, to correctly calculate the size of delimiter we need around
  8761. // a group, we scale down the inner size based on the size.
  8762. innerHeight *= options.sizeMultiplier;
  8763. innerDepth *= options.sizeMultiplier;
  8764. var leftDelim;
  8765. if (group.left === ".") {
  8766. // Empty delimiters in \left and \right make null delimiter spaces.
  8767. leftDelim = makeNullDelimiter(options, ["mopen"]);
  8768. } else {
  8769. // Otherwise, use leftRightDelim to generate the correct sized
  8770. // delimiter.
  8771. leftDelim = makeLeftRightDelim(group.left, innerHeight, innerDepth, options, group.mode, ["mopen"]);
  8772. }
  8773. // Add it to the beginning of the expression
  8774. inner.unshift(leftDelim);
  8775. // Handle middle delimiters
  8776. if (hadMiddle) {
  8777. for (var _i = 1; _i < inner.length; _i++) {
  8778. var middleDelim = inner[_i];
  8779. // Property `isMiddle` not defined on `span`. See comment in
  8780. // "middle"'s htmlBuilder.
  8781. // TODO(ts)
  8782. var isMiddle = middleDelim.isMiddle;
  8783. if (isMiddle) {
  8784. // Apply the options that were active when \middle was called
  8785. inner[_i] = makeLeftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []);
  8786. }
  8787. }
  8788. }
  8789. var rightDelim;
  8790. // Same for the right delimiter, but using color specified by \color
  8791. if (group.right === ".") {
  8792. rightDelim = makeNullDelimiter(options, ["mclose"]);
  8793. } else {
  8794. var colorOptions = group.rightColor ? options.withColor(group.rightColor) : options;
  8795. rightDelim = makeLeftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]);
  8796. }
  8797. // Add it to the end of the expression.
  8798. inner.push(rightDelim);
  8799. return makeSpan(["minner"], inner, options);
  8800. },
  8801. mathmlBuilder: (group, options) => {
  8802. assertParsed(group);
  8803. var inner = buildExpression(group.body, options);
  8804. if (group.left !== ".") {
  8805. var leftNode = new MathNode("mo", [makeText(group.left, group.mode)]);
  8806. leftNode.setAttribute("fence", "true");
  8807. inner.unshift(leftNode);
  8808. }
  8809. if (group.right !== ".") {
  8810. var rightNode = new MathNode("mo", [makeText(group.right, group.mode)]);
  8811. rightNode.setAttribute("fence", "true");
  8812. if (group.rightColor) {
  8813. rightNode.setAttribute("mathcolor", group.rightColor);
  8814. }
  8815. inner.push(rightNode);
  8816. }
  8817. return makeRow(inner);
  8818. }
  8819. });
  8820. defineFunction({
  8821. type: "middle",
  8822. names: ["\\middle"],
  8823. props: {
  8824. numArgs: 1,
  8825. primitive: true
  8826. },
  8827. handler: (context, args) => {
  8828. var delim = checkDelimiter(args[0], context);
  8829. if (!context.parser.leftrightDepth) {
  8830. throw new ParseError("\\middle without preceding \\left", delim);
  8831. }
  8832. return {
  8833. type: "middle",
  8834. mode: context.parser.mode,
  8835. delim: delim.text
  8836. };
  8837. },
  8838. htmlBuilder: (group, options) => {
  8839. var middleDelim;
  8840. if (group.delim === ".") {
  8841. middleDelim = makeNullDelimiter(options, []);
  8842. } else {
  8843. middleDelim = makeSizedDelim(group.delim, 1, options, group.mode, []);
  8844. var isMiddle = {
  8845. delim: group.delim,
  8846. options
  8847. };
  8848. // Property `isMiddle` not defined on `span`. It is only used in
  8849. // this file above.
  8850. // TODO: Fix this violation of the `span` type and possibly rename
  8851. // things since `isMiddle` sounds like a boolean, but is a struct.
  8852. // TODO(ts)
  8853. middleDelim.isMiddle = isMiddle;
  8854. }
  8855. return middleDelim;
  8856. },
  8857. mathmlBuilder: (group, options) => {
  8858. // A Firefox \middle will stretch a character vertically only if it
  8859. // is in the fence part of the operator dictionary at:
  8860. // https://www.w3.org/TR/MathML3/appendixc.html.
  8861. // So we need to avoid U+2223 and use plain "|" instead.
  8862. var textNode = group.delim === "\\vert" || group.delim === "|" ? makeText("|", "text") : makeText(group.delim, group.mode);
  8863. var middleNode = new MathNode("mo", [textNode]);
  8864. middleNode.setAttribute("fence", "true");
  8865. // MathML gives 5/18em spacing to each <mo> element.
  8866. // \middle should get delimiter spacing instead.
  8867. middleNode.setAttribute("lspace", "0.05em");
  8868. middleNode.setAttribute("rspace", "0.05em");
  8869. return middleNode;
  8870. }
  8871. });
  8872. var htmlBuilder$7 = (group, options) => {
  8873. // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase
  8874. // Some groups can return document fragments. Handle those by wrapping
  8875. // them in a span.
  8876. var inner = wrapFragment(buildGroup$1(group.body, options), options);
  8877. var label = group.label.slice(1);
  8878. var scale = options.sizeMultiplier;
  8879. var img;
  8880. var imgShift = 0;
  8881. // In the LaTeX cancel package, line geometry is slightly different
  8882. // depending on whether the subject is wider than it is tall, or vice versa.
  8883. // We don't know the width of a group, so as a proxy, we test if
  8884. // the subject is a single character. This captures most of the
  8885. // subjects that should get the "tall" treatment.
  8886. var isSingleChar = isCharacterBox(group.body);
  8887. if (label === "sout") {
  8888. img = makeSpan(["stretchy", "sout"]);
  8889. img.height = options.fontMetrics().defaultRuleThickness / scale;
  8890. imgShift = -0.5 * options.fontMetrics().xHeight;
  8891. } else if (label === "phase") {
  8892. // Set a couple of dimensions from the steinmetz package.
  8893. var lineWeight = calculateSize({
  8894. number: 0.6,
  8895. unit: "pt"
  8896. }, options);
  8897. var clearance = calculateSize({
  8898. number: 0.35,
  8899. unit: "ex"
  8900. }, options);
  8901. // Prevent size changes like \Huge from affecting line thickness
  8902. var newOptions = options.havingBaseSizing();
  8903. scale = scale / newOptions.sizeMultiplier;
  8904. var angleHeight = inner.height + inner.depth + lineWeight + clearance;
  8905. // Reserve a left pad for the angle.
  8906. inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight);
  8907. // Create an SVG
  8908. var viewBoxHeight = Math.floor(1000 * angleHeight * scale);
  8909. var path = phasePath(viewBoxHeight);
  8910. var svgNode = new SvgNode([new PathNode("phase", path)], {
  8911. "width": "400em",
  8912. "height": makeEm(viewBoxHeight / 1000),
  8913. "viewBox": "0 0 400000 " + viewBoxHeight,
  8914. "preserveAspectRatio": "xMinYMin slice"
  8915. });
  8916. // Wrap it in a span with overflow: hidden.
  8917. img = makeSvgSpan(["hide-tail"], [svgNode], options);
  8918. img.style.height = makeEm(angleHeight);
  8919. imgShift = inner.depth + lineWeight + clearance;
  8920. } else {
  8921. // Add horizontal padding
  8922. if (/cancel/.test(label)) {
  8923. if (!isSingleChar) {
  8924. inner.classes.push("cancel-pad");
  8925. }
  8926. } else if (label === "angl") {
  8927. inner.classes.push("anglpad");
  8928. } else {
  8929. inner.classes.push("boxpad");
  8930. }
  8931. // Add vertical padding
  8932. var topPad = 0;
  8933. var bottomPad = 0;
  8934. var ruleThickness = 0;
  8935. // ref: cancel package: \advance\totalheight2\p@ % "+2"
  8936. if (/box/.test(label)) {
  8937. ruleThickness = Math.max(options.fontMetrics().fboxrule,
  8938. // default
  8939. options.minRuleThickness);
  8940. topPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness);
  8941. bottomPad = topPad;
  8942. } else if (label === "angl") {
  8943. ruleThickness = Math.max(options.fontMetrics().defaultRuleThickness, options.minRuleThickness);
  8944. topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself.
  8945. bottomPad = Math.max(0, 0.25 - inner.depth);
  8946. } else {
  8947. topPad = isSingleChar ? 0.2 : 0;
  8948. bottomPad = topPad;
  8949. }
  8950. img = stretchyEnclose(inner, label, topPad, bottomPad, options);
  8951. if (/fbox|boxed|fcolorbox/.test(label)) {
  8952. img.style.borderStyle = "solid";
  8953. img.style.borderWidth = makeEm(ruleThickness);
  8954. } else if (label === "angl" && ruleThickness !== 0.049) {
  8955. img.style.borderTopWidth = makeEm(ruleThickness);
  8956. img.style.borderRightWidth = makeEm(ruleThickness);
  8957. }
  8958. imgShift = inner.depth + bottomPad;
  8959. if (group.backgroundColor) {
  8960. img.style.backgroundColor = group.backgroundColor;
  8961. if (group.borderColor) {
  8962. img.style.borderColor = group.borderColor;
  8963. }
  8964. }
  8965. }
  8966. var vlist;
  8967. if (group.backgroundColor) {
  8968. vlist = makeVList({
  8969. positionType: "individualShift",
  8970. children: [
  8971. // Put the color background behind inner;
  8972. {
  8973. type: "elem",
  8974. elem: img,
  8975. shift: imgShift
  8976. }, {
  8977. type: "elem",
  8978. elem: inner,
  8979. shift: 0
  8980. }]
  8981. });
  8982. } else {
  8983. var classes = /cancel|phase/.test(label) ? ["svg-align"] : [];
  8984. vlist = makeVList({
  8985. positionType: "individualShift",
  8986. children: [
  8987. // Write the \cancel stroke on top of inner.
  8988. {
  8989. type: "elem",
  8990. elem: inner,
  8991. shift: 0
  8992. }, {
  8993. type: "elem",
  8994. elem: img,
  8995. shift: imgShift,
  8996. wrapperClasses: classes
  8997. }]
  8998. });
  8999. }
  9000. if (/cancel/.test(label)) {
  9001. // The cancel package documentation says that cancel lines add their height
  9002. // to the expression, but tests show that isn't how it actually works.
  9003. vlist.height = inner.height;
  9004. vlist.depth = inner.depth;
  9005. }
  9006. if (/cancel/.test(label) && !isSingleChar) {
  9007. // cancel does not create horiz space for its line extension.
  9008. return makeSpan(["mord", "cancel-lap"], [vlist], options);
  9009. } else {
  9010. return makeSpan(["mord"], [vlist], options);
  9011. }
  9012. };
  9013. var mathmlBuilder$6 = (group, options) => {
  9014. var fboxsep = 0;
  9015. var node = new MathNode(group.label.includes("colorbox") ? "mpadded" : "menclose", [buildGroup(group.body, options)]);
  9016. switch (group.label) {
  9017. case "\\cancel":
  9018. node.setAttribute("notation", "updiagonalstrike");
  9019. break;
  9020. case "\\bcancel":
  9021. node.setAttribute("notation", "downdiagonalstrike");
  9022. break;
  9023. case "\\phase":
  9024. node.setAttribute("notation", "phasorangle");
  9025. break;
  9026. case "\\sout":
  9027. node.setAttribute("notation", "horizontalstrike");
  9028. break;
  9029. case "\\fbox":
  9030. node.setAttribute("notation", "box");
  9031. break;
  9032. case "\\angl":
  9033. node.setAttribute("notation", "actuarial");
  9034. break;
  9035. case "\\fcolorbox":
  9036. case "\\colorbox":
  9037. // <menclose> doesn't have a good notation option. So use <mpadded>
  9038. // instead. Set some attributes that come included with <menclose>.
  9039. fboxsep = options.fontMetrics().fboxsep * options.fontMetrics().ptPerEm;
  9040. node.setAttribute("width", "+" + 2 * fboxsep + "pt");
  9041. node.setAttribute("height", "+" + 2 * fboxsep + "pt");
  9042. node.setAttribute("lspace", fboxsep + "pt"); //
  9043. node.setAttribute("voffset", fboxsep + "pt");
  9044. if (group.label === "\\fcolorbox") {
  9045. var thk = Math.max(options.fontMetrics().fboxrule,
  9046. // default
  9047. options.minRuleThickness);
  9048. node.setAttribute("style", "border: " + makeEm(thk) + " solid " + group.borderColor);
  9049. }
  9050. break;
  9051. case "\\xcancel":
  9052. node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
  9053. break;
  9054. }
  9055. if (group.backgroundColor) {
  9056. node.setAttribute("mathbackground", group.backgroundColor);
  9057. }
  9058. return node;
  9059. };
  9060. defineFunction({
  9061. type: "enclose",
  9062. names: ["\\colorbox"],
  9063. props: {
  9064. numArgs: 2,
  9065. allowedInText: true,
  9066. argTypes: ["color", "text"]
  9067. },
  9068. handler(_ref, args, optArgs) {
  9069. var {
  9070. parser,
  9071. funcName
  9072. } = _ref;
  9073. var color = assertNodeType(args[0], "color-token").color;
  9074. var body = args[1];
  9075. return {
  9076. type: "enclose",
  9077. mode: parser.mode,
  9078. label: funcName,
  9079. backgroundColor: color,
  9080. body
  9081. };
  9082. },
  9083. htmlBuilder: htmlBuilder$7,
  9084. mathmlBuilder: mathmlBuilder$6
  9085. });
  9086. defineFunction({
  9087. type: "enclose",
  9088. names: ["\\fcolorbox"],
  9089. props: {
  9090. numArgs: 3,
  9091. allowedInText: true,
  9092. argTypes: ["color", "color", "text"]
  9093. },
  9094. handler(_ref2, args, optArgs) {
  9095. var {
  9096. parser,
  9097. funcName
  9098. } = _ref2;
  9099. var borderColor = assertNodeType(args[0], "color-token").color;
  9100. var backgroundColor = assertNodeType(args[1], "color-token").color;
  9101. var body = args[2];
  9102. return {
  9103. type: "enclose",
  9104. mode: parser.mode,
  9105. label: funcName,
  9106. backgroundColor,
  9107. borderColor,
  9108. body
  9109. };
  9110. },
  9111. htmlBuilder: htmlBuilder$7,
  9112. mathmlBuilder: mathmlBuilder$6
  9113. });
  9114. defineFunction({
  9115. type: "enclose",
  9116. names: ["\\fbox"],
  9117. props: {
  9118. numArgs: 1,
  9119. argTypes: ["hbox"],
  9120. allowedInText: true
  9121. },
  9122. handler(_ref3, args) {
  9123. var {
  9124. parser
  9125. } = _ref3;
  9126. return {
  9127. type: "enclose",
  9128. mode: parser.mode,
  9129. label: "\\fbox",
  9130. body: args[0]
  9131. };
  9132. }
  9133. });
  9134. defineFunction({
  9135. type: "enclose",
  9136. names: ["\\cancel", "\\bcancel", "\\xcancel", "\\phase"],
  9137. props: {
  9138. numArgs: 1
  9139. },
  9140. handler(_ref4, args) {
  9141. var {
  9142. parser,
  9143. funcName
  9144. } = _ref4;
  9145. var body = args[0];
  9146. return {
  9147. type: "enclose",
  9148. mode: parser.mode,
  9149. label: funcName,
  9150. body
  9151. };
  9152. },
  9153. htmlBuilder: htmlBuilder$7,
  9154. mathmlBuilder: mathmlBuilder$6
  9155. });
  9156. defineFunction({
  9157. type: "enclose",
  9158. names: ["\\sout"],
  9159. props: {
  9160. numArgs: 1,
  9161. allowedInText: true
  9162. },
  9163. handler(_ref5, args) {
  9164. var {
  9165. parser,
  9166. funcName
  9167. } = _ref5;
  9168. if (parser.mode === "math") {
  9169. parser.settings.reportNonstrict("mathVsSout", "LaTeX's \\sout works only in text mode");
  9170. }
  9171. var body = args[0];
  9172. return {
  9173. type: "enclose",
  9174. mode: parser.mode,
  9175. label: funcName,
  9176. body
  9177. };
  9178. },
  9179. htmlBuilder: htmlBuilder$7,
  9180. mathmlBuilder: mathmlBuilder$6
  9181. });
  9182. defineFunction({
  9183. type: "enclose",
  9184. names: ["\\angl"],
  9185. props: {
  9186. numArgs: 1,
  9187. argTypes: ["hbox"],
  9188. allowedInText: false
  9189. },
  9190. handler(_ref6, args) {
  9191. var {
  9192. parser
  9193. } = _ref6;
  9194. return {
  9195. type: "enclose",
  9196. mode: parser.mode,
  9197. label: "\\angl",
  9198. body: args[0]
  9199. };
  9200. }
  9201. });
  9202. /**
  9203. * All registered environments.
  9204. * `environments.js` exports this same dictionary again and makes it public.
  9205. * `Parser.js` requires this dictionary via `environments.js`.
  9206. */
  9207. var _environments = {};
  9208. function defineEnvironment(_ref) {
  9209. var {
  9210. type,
  9211. names,
  9212. props,
  9213. handler,
  9214. htmlBuilder,
  9215. mathmlBuilder
  9216. } = _ref;
  9217. // Set default values of environments.
  9218. var data = {
  9219. type,
  9220. numArgs: props.numArgs || 0,
  9221. allowedInText: false,
  9222. numOptionalArgs: 0,
  9223. handler
  9224. };
  9225. for (var i = 0; i < names.length; ++i) {
  9226. // TODO: The value type of _environments should be a type union of all
  9227. // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is
  9228. // an existential type.
  9229. _environments[names[i]] = data;
  9230. }
  9231. if (htmlBuilder) {
  9232. _htmlGroupBuilders[type] = htmlBuilder;
  9233. }
  9234. if (mathmlBuilder) {
  9235. _mathmlGroupBuilders[type] = mathmlBuilder;
  9236. }
  9237. }
  9238. /**
  9239. * All registered global/built-in macros.
  9240. * `macros.js` exports this same dictionary again and makes it public.
  9241. * `Parser.js` requires this dictionary via `macros.js`.
  9242. */
  9243. var _macros = {};
  9244. // This function might one day accept an additional argument and do more things.
  9245. function defineMacro(name, body) {
  9246. _macros[name] = body;
  9247. }
  9248. /**
  9249. * Lexing or parsing positional information for error reporting.
  9250. * This object is immutable.
  9251. */
  9252. class SourceLocation {
  9253. // The + prefix indicates that these fields aren't writeable
  9254. // Lexer holding the input string.
  9255. // Start offset, zero-based inclusive.
  9256. // End offset, zero-based exclusive.
  9257. constructor(lexer, start, end) {
  9258. this.lexer = lexer;
  9259. this.start = start;
  9260. this.end = end;
  9261. }
  9262. /**
  9263. * Merges two `SourceLocation`s from location providers, given they are
  9264. * provided in order of appearance.
  9265. * - Returns the first one's location if only the first is provided.
  9266. * - Returns a merged range of the first and the last if both are provided
  9267. * and their lexers match.
  9268. * - Otherwise, returns null.
  9269. */
  9270. static range(first, second) {
  9271. if (!second) {
  9272. return first && first.loc;
  9273. } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) {
  9274. return null;
  9275. } else {
  9276. return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end);
  9277. }
  9278. }
  9279. }
  9280. /**
  9281. * The resulting token returned from `lex`.
  9282. *
  9283. * It consists of the token text plus some position information.
  9284. * The position information is essentially a range in an input string,
  9285. * but instead of referencing the bare input string, we refer to the lexer.
  9286. * That way it is possible to attach extra metadata to the input string,
  9287. * like for example a file name or similar.
  9288. *
  9289. * The position information is optional, so it is OK to construct synthetic
  9290. * tokens if appropriate. Not providing available position information may
  9291. * lead to degraded error reporting, though.
  9292. */
  9293. class Token {
  9294. // don't expand the token
  9295. // used in \noexpand
  9296. constructor(text,
  9297. // the text of this token
  9298. loc) {
  9299. this.text = text;
  9300. this.loc = loc;
  9301. }
  9302. /**
  9303. * Given a pair of tokens (this and endToken), compute a `Token` encompassing
  9304. * the whole input range enclosed by these two.
  9305. */
  9306. range(endToken,
  9307. // last token of the range, inclusive
  9308. text) {
  9309. return new Token(text, SourceLocation.range(this, endToken));
  9310. }
  9311. }
  9312. // Helper functions
  9313. function getHLines(parser) {
  9314. // Return an array. The array length = number of hlines.
  9315. // Each element in the array tells if the line is dashed.
  9316. var hlineInfo = [];
  9317. parser.consumeSpaces();
  9318. var nxt = parser.fetch().text;
  9319. if (nxt === "\\relax") {
  9320. // \relax is an artifact of the \cr macro below
  9321. parser.consume();
  9322. parser.consumeSpaces();
  9323. nxt = parser.fetch().text;
  9324. }
  9325. while (nxt === "\\hline" || nxt === "\\hdashline") {
  9326. parser.consume();
  9327. hlineInfo.push(nxt === "\\hdashline");
  9328. parser.consumeSpaces();
  9329. nxt = parser.fetch().text;
  9330. }
  9331. return hlineInfo;
  9332. }
  9333. var validateAmsEnvironmentContext = context => {
  9334. var settings = context.parser.settings;
  9335. if (!settings.displayMode) {
  9336. throw new ParseError("{" + context.envName + "} can be used only in" + " display mode.");
  9337. }
  9338. };
  9339. var gatherEnvironments = new Set(["gather", "gather*"]);
  9340. // autoTag (an argument to parseArray) can be one of three values:
  9341. // * undefined: Regular (not-top-level) array; no tags on each row
  9342. // * true: Automatic equation numbering, overridable by \tag
  9343. // * false: Tags allowed on each row, but no automatic numbering
  9344. // This function *doesn't* work with the "split" environment name.
  9345. function getAutoTag(name) {
  9346. if (!name.includes("ed")) {
  9347. return !name.includes("*");
  9348. }
  9349. // return undefined;
  9350. }
  9351. /**
  9352. * Parse the body of the environment, with rows delimited by \\ and
  9353. * columns delimited by &, and create a nested list in row-major order
  9354. * with one group per cell. If given an optional argument style
  9355. * ("text", "display", etc.), then each cell is cast into that style.
  9356. */
  9357. function parseArray(parser, _ref, style) {
  9358. var {
  9359. hskipBeforeAndAfter,
  9360. addJot,
  9361. cols,
  9362. arraystretch,
  9363. colSeparationType,
  9364. autoTag,
  9365. singleRow,
  9366. emptySingleRow,
  9367. maxNumCols,
  9368. leqno
  9369. } = _ref;
  9370. parser.gullet.beginGroup();
  9371. if (!singleRow) {
  9372. // \cr is equivalent to \\ without the optional size argument (see below)
  9373. // TODO: provide helpful error when \cr is used outside array environment
  9374. parser.gullet.macros.set("\\cr", "\\\\\\relax");
  9375. }
  9376. // Get current arraystretch if it's not set by the environment
  9377. if (!arraystretch) {
  9378. var stretch = parser.gullet.expandMacroAsText("\\arraystretch");
  9379. if (stretch == null) {
  9380. // Default \arraystretch from lttab.dtx
  9381. arraystretch = 1;
  9382. } else {
  9383. arraystretch = parseFloat(stretch);
  9384. if (!arraystretch || arraystretch < 0) {
  9385. throw new ParseError("Invalid \\arraystretch: " + stretch);
  9386. }
  9387. }
  9388. }
  9389. // Start group for first cell
  9390. parser.gullet.beginGroup();
  9391. var row = [];
  9392. var body = [row];
  9393. var rowGaps = [];
  9394. var hLinesBeforeRow = [];
  9395. var tags = autoTag != null ? [] : undefined;
  9396. // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent
  9397. // whether this row should have an equation number. Simulate this with
  9398. // a \@eqnsw macro set to 1 or 0.
  9399. function beginRow() {
  9400. if (autoTag) {
  9401. parser.gullet.macros.set("\\@eqnsw", "1", true);
  9402. }
  9403. }
  9404. function endRow() {
  9405. if (tags) {
  9406. if (parser.gullet.macros.get("\\df@tag")) {
  9407. tags.push(parser.subparse([new Token("\\df@tag")]));
  9408. parser.gullet.macros.set("\\df@tag", undefined, true);
  9409. } else {
  9410. tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1");
  9411. }
  9412. }
  9413. }
  9414. beginRow();
  9415. // Test for \hline at the top of the array.
  9416. hLinesBeforeRow.push(getHLines(parser));
  9417. while (true) {
  9418. // eslint-disable-line no-constant-condition
  9419. // Parse each cell in its own group (namespace)
  9420. var cellBody = parser.parseExpression(false, singleRow ? "\\end" : "\\\\");
  9421. parser.gullet.endGroup();
  9422. parser.gullet.beginGroup();
  9423. var cell = {
  9424. type: "ordgroup",
  9425. mode: parser.mode,
  9426. body: cellBody
  9427. };
  9428. if (style) {
  9429. cell = {
  9430. type: "styling",
  9431. mode: parser.mode,
  9432. style,
  9433. body: [cell]
  9434. };
  9435. }
  9436. row.push(cell);
  9437. var next = parser.fetch().text;
  9438. if (next === "&") {
  9439. if (maxNumCols && row.length === maxNumCols) {
  9440. if (singleRow || colSeparationType) {
  9441. // {equation} or {split}
  9442. throw new ParseError("Too many tab characters: &", parser.nextToken);
  9443. } else {
  9444. // {array} environment
  9445. parser.settings.reportNonstrict("textEnv", "Too few columns " + "specified in the {array} column argument.");
  9446. }
  9447. }
  9448. parser.consume();
  9449. } else if (next === "\\end") {
  9450. endRow();
  9451. // Arrays terminate newlines with `\crcr` which consumes a `\cr` if
  9452. // the last line is empty. However, AMS environments keep the
  9453. // empty row if it's the only one.
  9454. // NOTE: Currently, `cell` is the last item added into `row`.
  9455. if (row.length === 1 && cell.type === "styling" && cell.body.length === 1 && cell.body[0].type === "ordgroup" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) {
  9456. body.pop();
  9457. }
  9458. if (hLinesBeforeRow.length < body.length + 1) {
  9459. hLinesBeforeRow.push([]);
  9460. }
  9461. break;
  9462. } else if (next === "\\\\") {
  9463. parser.consume();
  9464. var size = void 0;
  9465. // \def\Let@{\let\\\math@cr}
  9466. // \def\math@cr{...\math@cr@}
  9467. // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}}
  9468. // \def\math@cr@@[#1]{...\math@cr@@@...}
  9469. // \def\math@cr@@@{\cr}
  9470. if (parser.gullet.future().text !== " ") {
  9471. size = parser.parseSizeGroup(true);
  9472. }
  9473. rowGaps.push(size ? size.value : null);
  9474. endRow();
  9475. // check for \hline(s) following the row separator
  9476. hLinesBeforeRow.push(getHLines(parser));
  9477. row = [];
  9478. body.push(row);
  9479. beginRow();
  9480. } else {
  9481. throw new ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken);
  9482. }
  9483. }
  9484. // End cell group
  9485. parser.gullet.endGroup();
  9486. // End array group defining \cr
  9487. parser.gullet.endGroup();
  9488. return {
  9489. type: "array",
  9490. mode: parser.mode,
  9491. addJot,
  9492. arraystretch,
  9493. body,
  9494. cols,
  9495. rowGaps,
  9496. hskipBeforeAndAfter,
  9497. hLinesBeforeRow,
  9498. colSeparationType,
  9499. tags,
  9500. leqno
  9501. };
  9502. }
  9503. // Decides on a style for cells in an array according to whether the given
  9504. // environment name starts with the letter 'd'.
  9505. function dCellStyle(envName) {
  9506. if (envName.slice(0, 1) === "d") {
  9507. return "display";
  9508. } else {
  9509. return "text";
  9510. }
  9511. }
  9512. var htmlBuilder$6 = function htmlBuilder(group, options) {
  9513. var r;
  9514. var c;
  9515. var nr = group.body.length;
  9516. var hLinesBeforeRow = group.hLinesBeforeRow;
  9517. var nc = 0;
  9518. var body = new Array(nr);
  9519. var hlines = [];
  9520. var ruleThickness = Math.max(
  9521. // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em.
  9522. options.fontMetrics().arrayRuleWidth, options.minRuleThickness);
  9523. // Horizontal spacing
  9524. var pt = 1 / options.fontMetrics().ptPerEm;
  9525. var arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls
  9526. if (group.colSeparationType && group.colSeparationType === "small") {
  9527. // We're in a {smallmatrix}. Default column space is \thickspace,
  9528. // i.e. 5/18em = 0.2778em, per amsmath.dtx for {smallmatrix}.
  9529. // But that needs adjustment because LaTeX applies \scriptstyle to the
  9530. // entire array, including the colspace, but this function applies
  9531. // \scriptstyle only inside each element.
  9532. var localMultiplier = options.havingStyle(Style$1.SCRIPT).sizeMultiplier;
  9533. arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier);
  9534. }
  9535. // Vertical spacing
  9536. var baselineskip = group.colSeparationType === "CD" ? calculateSize({
  9537. number: 3,
  9538. unit: "ex"
  9539. }, options) : 12 * pt; // see size10.clo
  9540. // Default \jot from ltmath.dtx
  9541. // TODO(edemaine): allow overriding \jot via \setlength (#687)
  9542. var jot = 3 * pt;
  9543. var arrayskip = group.arraystretch * baselineskip;
  9544. var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and
  9545. var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx
  9546. var totalHeight = 0;
  9547. // Set a position for \hline(s) at the top of the array, if any.
  9548. function setHLinePos(hlinesInGap) {
  9549. for (var i = 0; i < hlinesInGap.length; ++i) {
  9550. if (i > 0) {
  9551. totalHeight += 0.25;
  9552. }
  9553. hlines.push({
  9554. pos: totalHeight,
  9555. isDashed: hlinesInGap[i]
  9556. });
  9557. }
  9558. }
  9559. setHLinePos(hLinesBeforeRow[0]);
  9560. for (r = 0; r < group.body.length; ++r) {
  9561. var inrow = group.body[r];
  9562. var height = arstrutHeight; // \@array adds an \@arstrut
  9563. var depth = arstrutDepth; // to each tow (via the template)
  9564. if (nc < inrow.length) {
  9565. nc = inrow.length;
  9566. }
  9567. var outrow = new Array(inrow.length);
  9568. for (c = 0; c < inrow.length; ++c) {
  9569. var elt = buildGroup$1(inrow[c], options);
  9570. if (depth < elt.depth) {
  9571. depth = elt.depth;
  9572. }
  9573. if (height < elt.height) {
  9574. height = elt.height;
  9575. }
  9576. outrow[c] = elt;
  9577. }
  9578. var rowGap = group.rowGaps[r];
  9579. var gap = 0;
  9580. if (rowGap) {
  9581. gap = calculateSize(rowGap, options);
  9582. if (gap > 0) {
  9583. // \@argarraycr
  9584. gap += arstrutDepth;
  9585. if (depth < gap) {
  9586. depth = gap; // \@xargarraycr
  9587. }
  9588. gap = 0;
  9589. }
  9590. }
  9591. // In AMS multiline environments such as aligned and gathered, rows
  9592. // correspond to lines that have additional \jot added between lines
  9593. // via \openup.
  9594. // We simulate this by adding \jot depth to each row except the last.
  9595. if (group.addJot && r < group.body.length - 1) {
  9596. depth += jot;
  9597. }
  9598. outrow.height = height;
  9599. outrow.depth = depth;
  9600. totalHeight += height;
  9601. outrow.pos = totalHeight;
  9602. totalHeight += depth + gap; // \@yargarraycr
  9603. body[r] = outrow;
  9604. // Set a position for \hline(s), if any.
  9605. setHLinePos(hLinesBeforeRow[r + 1]);
  9606. }
  9607. var offset = totalHeight / 2 + options.fontMetrics().axisHeight;
  9608. var colDescriptions = group.cols || [];
  9609. var cols = [];
  9610. var colSep;
  9611. var colDescrNum;
  9612. var tagSpans = [];
  9613. if (group.tags && group.tags.some(tag => tag)) {
  9614. // An environment with manual tags and/or automatic equation numbers.
  9615. // Create node(s), the latter of which trigger CSS counter increment.
  9616. for (r = 0; r < nr; ++r) {
  9617. var rw = body[r];
  9618. var shift = rw.pos - offset;
  9619. var tag = group.tags[r];
  9620. var tagSpan = void 0;
  9621. if (tag === true) {
  9622. // automatic numbering
  9623. tagSpan = makeSpan(["eqn-num"], [], options);
  9624. } else if (tag === false) {
  9625. // \nonumber/\notag or starred environment
  9626. tagSpan = makeSpan([], [], options);
  9627. } else {
  9628. // manual \tag
  9629. tagSpan = makeSpan([], buildExpression$1(tag, options, true), options);
  9630. }
  9631. tagSpan.depth = rw.depth;
  9632. tagSpan.height = rw.height;
  9633. tagSpans.push({
  9634. type: "elem",
  9635. elem: tagSpan,
  9636. shift
  9637. });
  9638. }
  9639. }
  9640. for (c = 0, colDescrNum = 0;
  9641. // Continue while either there are more columns or more column
  9642. // descriptions, so trailing separators don't get lost.
  9643. c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) {
  9644. var _colDescr3;
  9645. var colDescr = colDescriptions[colDescrNum];
  9646. var firstSeparator = true;
  9647. while (((_colDescr = colDescr) == null ? void 0 : _colDescr.type) === "separator") {
  9648. var _colDescr;
  9649. // If there is more than one separator in a row, add a space
  9650. // between them.
  9651. if (!firstSeparator) {
  9652. colSep = makeSpan(["arraycolsep"], []);
  9653. colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep);
  9654. cols.push(colSep);
  9655. }
  9656. if (colDescr.separator === "|" || colDescr.separator === ":") {
  9657. var lineType = colDescr.separator === "|" ? "solid" : "dashed";
  9658. var separator = makeSpan(["vertical-separator"], [], options);
  9659. separator.style.height = makeEm(totalHeight);
  9660. separator.style.borderRightWidth = makeEm(ruleThickness);
  9661. separator.style.borderRightStyle = lineType;
  9662. separator.style.margin = "0 " + makeEm(-ruleThickness / 2);
  9663. var _shift = totalHeight - offset;
  9664. if (_shift) {
  9665. separator.style.verticalAlign = makeEm(-_shift);
  9666. }
  9667. cols.push(separator);
  9668. } else {
  9669. throw new ParseError("Invalid separator type: " + colDescr.separator);
  9670. }
  9671. colDescrNum++;
  9672. colDescr = colDescriptions[colDescrNum];
  9673. firstSeparator = false;
  9674. }
  9675. if (c >= nc) {
  9676. continue;
  9677. }
  9678. var sepwidth = void 0;
  9679. if (c > 0 || group.hskipBeforeAndAfter) {
  9680. var _colDescr$pregap, _colDescr2;
  9681. sepwidth = (_colDescr$pregap = (_colDescr2 = colDescr) == null ? void 0 : _colDescr2.pregap) != null ? _colDescr$pregap : arraycolsep;
  9682. if (sepwidth !== 0) {
  9683. colSep = makeSpan(["arraycolsep"], []);
  9684. colSep.style.width = makeEm(sepwidth);
  9685. cols.push(colSep);
  9686. }
  9687. }
  9688. var colElems = [];
  9689. for (r = 0; r < nr; ++r) {
  9690. var row = body[r];
  9691. var elem = row[c];
  9692. if (!elem) {
  9693. continue;
  9694. }
  9695. var _shift2 = row.pos - offset;
  9696. elem.depth = row.depth;
  9697. elem.height = row.height;
  9698. colElems.push({
  9699. type: "elem",
  9700. elem: elem,
  9701. shift: _shift2
  9702. });
  9703. }
  9704. var colVList = makeVList({
  9705. positionType: "individualShift",
  9706. children: colElems
  9707. });
  9708. var colSpan = makeSpan(["col-align-" + (((_colDescr3 = colDescr) == null ? void 0 : _colDescr3.align) || "c")], [colVList]);
  9709. cols.push(colSpan);
  9710. if (c < nc - 1 || group.hskipBeforeAndAfter) {
  9711. var _colDescr$postgap, _colDescr4;
  9712. sepwidth = (_colDescr$postgap = (_colDescr4 = colDescr) == null ? void 0 : _colDescr4.postgap) != null ? _colDescr$postgap : arraycolsep;
  9713. if (sepwidth !== 0) {
  9714. colSep = makeSpan(["arraycolsep"], []);
  9715. colSep.style.width = makeEm(sepwidth);
  9716. cols.push(colSep);
  9717. }
  9718. }
  9719. }
  9720. var tableBody = makeSpan(["mtable"], cols);
  9721. // Add \hline(s), if any.
  9722. if (hlines.length > 0) {
  9723. var line = makeLineSpan("hline", options, ruleThickness);
  9724. var dashes = makeLineSpan("hdashline", options, ruleThickness);
  9725. var vListElems = [{
  9726. type: "elem",
  9727. elem: tableBody,
  9728. shift: 0
  9729. }];
  9730. while (hlines.length > 0) {
  9731. var hline = hlines.pop();
  9732. var lineShift = hline.pos - offset;
  9733. if (hline.isDashed) {
  9734. vListElems.push({
  9735. type: "elem",
  9736. elem: dashes,
  9737. shift: lineShift
  9738. });
  9739. } else {
  9740. vListElems.push({
  9741. type: "elem",
  9742. elem: line,
  9743. shift: lineShift
  9744. });
  9745. }
  9746. }
  9747. tableBody = makeVList({
  9748. positionType: "individualShift",
  9749. children: vListElems
  9750. });
  9751. }
  9752. if (tagSpans.length === 0) {
  9753. return makeSpan(["mord"], [tableBody], options);
  9754. } else {
  9755. var eqnNumCol = makeVList({
  9756. positionType: "individualShift",
  9757. children: tagSpans
  9758. });
  9759. var tagCol = makeSpan(["tag"], [eqnNumCol], options);
  9760. return makeFragment([tableBody, tagCol]);
  9761. }
  9762. };
  9763. var alignMap = {
  9764. c: "center ",
  9765. l: "left ",
  9766. r: "right "
  9767. };
  9768. var mathmlBuilder$5 = function mathmlBuilder(group, options) {
  9769. var tbl = [];
  9770. var glue = new MathNode("mtd", [], ["mtr-glue"]);
  9771. var tag = new MathNode("mtd", [], ["mml-eqn-num"]);
  9772. for (var i = 0; i < group.body.length; i++) {
  9773. var rw = group.body[i];
  9774. var row = [];
  9775. for (var j = 0; j < rw.length; j++) {
  9776. row.push(new MathNode("mtd", [buildGroup(rw[j], options)]));
  9777. }
  9778. if (group.tags && group.tags[i]) {
  9779. row.unshift(glue);
  9780. row.push(glue);
  9781. if (group.leqno) {
  9782. row.unshift(tag);
  9783. } else {
  9784. row.push(tag);
  9785. }
  9786. }
  9787. tbl.push(new MathNode("mtr", row));
  9788. }
  9789. var table = new MathNode("mtable", tbl);
  9790. // Set column alignment, row spacing, column spacing, and
  9791. // array lines by setting attributes on the table element.
  9792. // Set the row spacing. In MathML, we specify a gap distance.
  9793. // We do not use rowGap[] because MathML automatically increases
  9794. // cell height with the height/depth of the element content.
  9795. // LaTeX \arraystretch multiplies the row baseline-to-baseline distance.
  9796. // We simulate this by adding (arraystretch - 1)em to the gap. This
  9797. // does a reasonable job of adjusting arrays containing 1 em tall content.
  9798. // The 0.16 and 0.09 values are found empirically. They produce an array
  9799. // similar to LaTeX and in which content does not interfere with \hlines.
  9800. var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray}
  9801. : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
  9802. table.setAttribute("rowspacing", makeEm(gap));
  9803. // MathML table lines go only between cells.
  9804. // To place a line on an edge we'll use <menclose>, if necessary.
  9805. var menclose = "";
  9806. var align = "";
  9807. if (group.cols && group.cols.length > 0) {
  9808. // Find column alignment, column spacing, and vertical lines.
  9809. var cols = group.cols;
  9810. var columnLines = "";
  9811. var prevTypeWasAlign = false;
  9812. var iStart = 0;
  9813. var iEnd = cols.length;
  9814. if (cols[0].type === "separator") {
  9815. menclose += "top ";
  9816. iStart = 1;
  9817. }
  9818. if (cols[cols.length - 1].type === "separator") {
  9819. menclose += "bottom ";
  9820. iEnd -= 1;
  9821. }
  9822. for (var _i = iStart; _i < iEnd; _i++) {
  9823. var col = cols[_i];
  9824. if (col.type === "align") {
  9825. align += alignMap[col.align];
  9826. if (prevTypeWasAlign) {
  9827. columnLines += "none ";
  9828. }
  9829. prevTypeWasAlign = true;
  9830. } else if (col.type === "separator") {
  9831. // MathML accepts only single lines between cells.
  9832. // So we read only the first of consecutive separators.
  9833. if (prevTypeWasAlign) {
  9834. columnLines += col.separator === "|" ? "solid " : "dashed ";
  9835. prevTypeWasAlign = false;
  9836. }
  9837. }
  9838. }
  9839. table.setAttribute("columnalign", align.trim());
  9840. if (/[sd]/.test(columnLines)) {
  9841. table.setAttribute("columnlines", columnLines.trim());
  9842. }
  9843. }
  9844. // Set column spacing.
  9845. if (group.colSeparationType === "align") {
  9846. var _cols = group.cols || [];
  9847. var spacing = "";
  9848. for (var _i2 = 1; _i2 < _cols.length; _i2++) {
  9849. spacing += _i2 % 2 ? "0em " : "1em ";
  9850. }
  9851. table.setAttribute("columnspacing", spacing.trim());
  9852. } else if (group.colSeparationType === "alignat" || group.colSeparationType === "gather") {
  9853. table.setAttribute("columnspacing", "0em");
  9854. } else if (group.colSeparationType === "small") {
  9855. table.setAttribute("columnspacing", "0.2778em");
  9856. } else if (group.colSeparationType === "CD") {
  9857. table.setAttribute("columnspacing", "0.5em");
  9858. } else {
  9859. table.setAttribute("columnspacing", "1em");
  9860. }
  9861. // Address \hline and \hdashline
  9862. var rowLines = "";
  9863. var hlines = group.hLinesBeforeRow;
  9864. menclose += hlines[0].length > 0 ? "left " : "";
  9865. menclose += hlines[hlines.length - 1].length > 0 ? "right " : "";
  9866. for (var _i3 = 1; _i3 < hlines.length - 1; _i3++) {
  9867. rowLines += hlines[_i3].length === 0 ? "none "
  9868. // MathML accepts only a single line between rows. Read one element.
  9869. : hlines[_i3][0] ? "dashed " : "solid ";
  9870. }
  9871. if (/[sd]/.test(rowLines)) {
  9872. table.setAttribute("rowlines", rowLines.trim());
  9873. }
  9874. if (menclose !== "") {
  9875. table = new MathNode("menclose", [table]);
  9876. table.setAttribute("notation", menclose.trim());
  9877. }
  9878. if (group.arraystretch && group.arraystretch < 1) {
  9879. // A small array. Wrap in scriptstyle so row gap is not too large.
  9880. table = new MathNode("mstyle", [table]);
  9881. table.setAttribute("scriptlevel", "1");
  9882. }
  9883. return table;
  9884. };
  9885. // Convenience function for align, align*, aligned, alignat, alignat*, alignedat.
  9886. var alignedHandler = function alignedHandler(context, args) {
  9887. if (!context.envName.includes("ed")) {
  9888. validateAmsEnvironmentContext(context);
  9889. }
  9890. var cols = [];
  9891. var separationType = context.envName.includes("at") ? "alignat" : "align";
  9892. var isSplit = context.envName === "split";
  9893. var res = parseArray(context.parser, {
  9894. cols,
  9895. addJot: true,
  9896. autoTag: isSplit ? undefined : getAutoTag(context.envName),
  9897. emptySingleRow: true,
  9898. colSeparationType: separationType,
  9899. maxNumCols: isSplit ? 2 : undefined,
  9900. leqno: context.parser.settings.leqno
  9901. }, "display");
  9902. // Determining number of columns.
  9903. // 1. If the first argument is given, we use it as a number of columns,
  9904. // and makes sure that each row doesn't exceed that number.
  9905. // 2. Otherwise, just count number of columns = maximum number
  9906. // of cells in each row ("aligned" mode -- isAligned will be true).
  9907. //
  9908. // At the same time, prepend empty group {} at beginning of every second
  9909. // cell in each row (starting with second cell) so that operators become
  9910. // binary. This behavior is implemented in amsmath's \start@aligned.
  9911. var numMaths = 0;
  9912. var numCols = 0;
  9913. var emptyGroup = {
  9914. type: "ordgroup",
  9915. mode: context.mode,
  9916. body: []
  9917. };
  9918. if (args[0] && args[0].type === "ordgroup") {
  9919. var arg0 = "";
  9920. for (var i = 0; i < args[0].body.length; i++) {
  9921. var textord = assertNodeType(args[0].body[i], "textord");
  9922. arg0 += textord.text;
  9923. }
  9924. numMaths = Number(arg0);
  9925. numCols = numMaths * 2;
  9926. }
  9927. var isAligned = !numCols;
  9928. res.body.forEach(function (row) {
  9929. for (var _i4 = 1; _i4 < row.length; _i4 += 2) {
  9930. // Modify ordgroup node within styling node
  9931. var styling = assertNodeType(row[_i4], "styling");
  9932. var ordgroup = assertNodeType(styling.body[0], "ordgroup");
  9933. ordgroup.body.unshift(emptyGroup);
  9934. }
  9935. if (!isAligned) {
  9936. // Case 1
  9937. var curMaths = row.length / 2;
  9938. if (numMaths < curMaths) {
  9939. throw new ParseError("Too many math in a row: " + ("expected " + numMaths + ", but got " + curMaths), row[0]);
  9940. }
  9941. } else if (numCols < row.length) {
  9942. // Case 2
  9943. numCols = row.length;
  9944. }
  9945. });
  9946. // Adjusting alignment.
  9947. // In aligned mode, we add one \qquad between columns;
  9948. // otherwise we add nothing.
  9949. for (var _i5 = 0; _i5 < numCols; ++_i5) {
  9950. var align = "r";
  9951. var pregap = 0;
  9952. if (_i5 % 2 === 1) {
  9953. align = "l";
  9954. } else if (_i5 > 0 && isAligned) {
  9955. // "aligned" mode.
  9956. pregap = 1; // add one \quad
  9957. }
  9958. cols[_i5] = {
  9959. type: "align",
  9960. align: align,
  9961. pregap: pregap,
  9962. postgap: 0
  9963. };
  9964. }
  9965. res.colSeparationType = isAligned ? "align" : "alignat";
  9966. return res;
  9967. };
  9968. // Arrays are part of LaTeX, defined in lttab.dtx so its documentation
  9969. // is part of the source2e.pdf file of LaTeX2e source documentation.
  9970. // {darray} is an {array} environment where cells are set in \displaystyle,
  9971. // as defined in nccmath.sty.
  9972. defineEnvironment({
  9973. type: "array",
  9974. names: ["array", "darray"],
  9975. props: {
  9976. numArgs: 1
  9977. },
  9978. handler(context, args) {
  9979. // Since no types are specified above, the two possibilities are
  9980. // - The argument is wrapped in {} or [], in which case Parser's
  9981. // parseGroup() returns an "ordgroup" wrapping some symbol node.
  9982. // - The argument is a bare symbol node.
  9983. var symNode = checkSymbolNodeType(args[0]);
  9984. var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body;
  9985. var cols = colalign.map(function (nde) {
  9986. var node = assertSymbolNodeType(nde);
  9987. var ca = node.text;
  9988. if ("lcr".includes(ca)) {
  9989. return {
  9990. type: "align",
  9991. align: ca
  9992. };
  9993. } else if (ca === "|") {
  9994. return {
  9995. type: "separator",
  9996. separator: "|"
  9997. };
  9998. } else if (ca === ":") {
  9999. return {
  10000. type: "separator",
  10001. separator: ":"
  10002. };
  10003. }
  10004. throw new ParseError("Unknown column alignment: " + ca, nde);
  10005. });
  10006. var res = {
  10007. cols,
  10008. hskipBeforeAndAfter: true,
  10009. // \@preamble in lttab.dtx
  10010. maxNumCols: cols.length
  10011. };
  10012. return parseArray(context.parser, res, dCellStyle(context.envName));
  10013. },
  10014. htmlBuilder: htmlBuilder$6,
  10015. mathmlBuilder: mathmlBuilder$5
  10016. });
  10017. // The matrix environments of amsmath builds on the array environment
  10018. // of LaTeX, which is discussed above.
  10019. // The mathtools package adds starred versions of the same environments.
  10020. // These have an optional argument to choose left|center|right justification.
  10021. defineEnvironment({
  10022. type: "array",
  10023. names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix", "matrix*", "pmatrix*", "bmatrix*", "Bmatrix*", "vmatrix*", "Vmatrix*"],
  10024. props: {
  10025. numArgs: 0
  10026. },
  10027. handler(context) {
  10028. var delimiters = {
  10029. "matrix": null,
  10030. "pmatrix": ["(", ")"],
  10031. "bmatrix": ["[", "]"],
  10032. "Bmatrix": ["\\{", "\\}"],
  10033. "vmatrix": ["|", "|"],
  10034. "Vmatrix": ["\\Vert", "\\Vert"]
  10035. }[context.envName.replace("*", "")];
  10036. // \hskip -\arraycolsep in amsmath
  10037. var colAlign = "c";
  10038. var payload = {
  10039. hskipBeforeAndAfter: false,
  10040. cols: [{
  10041. type: "align",
  10042. align: colAlign
  10043. }]
  10044. };
  10045. if (context.envName.charAt(context.envName.length - 1) === "*") {
  10046. // It's one of the mathtools starred functions.
  10047. // Parse the optional alignment argument.
  10048. var parser = context.parser;
  10049. parser.consumeSpaces();
  10050. if (parser.fetch().text === "[") {
  10051. parser.consume();
  10052. parser.consumeSpaces();
  10053. colAlign = parser.fetch().text;
  10054. if (!"lcr".includes(colAlign)) {
  10055. throw new ParseError("Expected l or c or r", parser.nextToken);
  10056. }
  10057. parser.consume();
  10058. parser.consumeSpaces();
  10059. parser.expect("]");
  10060. parser.consume();
  10061. payload.cols = [{
  10062. type: "align",
  10063. align: colAlign
  10064. }];
  10065. }
  10066. }
  10067. var res = parseArray(context.parser, payload, dCellStyle(context.envName));
  10068. // Populate cols with the correct number of column alignment specs.
  10069. var numCols = Math.max(0, ...res.body.map(row => row.length));
  10070. res.cols = new Array(numCols).fill({
  10071. type: "align",
  10072. align: colAlign
  10073. });
  10074. return delimiters ? {
  10075. type: "leftright",
  10076. mode: context.mode,
  10077. body: [res],
  10078. left: delimiters[0],
  10079. right: delimiters[1],
  10080. rightColor: undefined // \right uninfluenced by \color in array
  10081. } : res;
  10082. },
  10083. htmlBuilder: htmlBuilder$6,
  10084. mathmlBuilder: mathmlBuilder$5
  10085. });
  10086. defineEnvironment({
  10087. type: "array",
  10088. names: ["smallmatrix"],
  10089. props: {
  10090. numArgs: 0
  10091. },
  10092. handler(context) {
  10093. var payload = {
  10094. arraystretch: 0.5
  10095. };
  10096. var res = parseArray(context.parser, payload, "script");
  10097. res.colSeparationType = "small";
  10098. return res;
  10099. },
  10100. htmlBuilder: htmlBuilder$6,
  10101. mathmlBuilder: mathmlBuilder$5
  10102. });
  10103. defineEnvironment({
  10104. type: "array",
  10105. names: ["subarray"],
  10106. props: {
  10107. numArgs: 1
  10108. },
  10109. handler(context, args) {
  10110. // Parsing of {subarray} is similar to {array}
  10111. var symNode = checkSymbolNodeType(args[0]);
  10112. var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body;
  10113. var cols = colalign.map(function (nde) {
  10114. var node = assertSymbolNodeType(nde);
  10115. var ca = node.text;
  10116. // {subarray} only recognizes "l" & "c"
  10117. if ("lc".includes(ca)) {
  10118. return {
  10119. type: "align",
  10120. align: ca
  10121. };
  10122. }
  10123. throw new ParseError("Unknown column alignment: " + ca, nde);
  10124. });
  10125. if (cols.length > 1) {
  10126. throw new ParseError("{subarray} can contain only one column");
  10127. }
  10128. var payload = {
  10129. cols,
  10130. hskipBeforeAndAfter: false,
  10131. arraystretch: 0.5
  10132. };
  10133. var res = parseArray(context.parser, payload, "script");
  10134. if (res.body.length > 0 && res.body[0].length > 1) {
  10135. throw new ParseError("{subarray} can contain only one column");
  10136. }
  10137. return res;
  10138. },
  10139. htmlBuilder: htmlBuilder$6,
  10140. mathmlBuilder: mathmlBuilder$5
  10141. });
  10142. // A cases environment (in amsmath.sty) is almost equivalent to
  10143. // \def\arraystretch{1.2}%
  10144. // \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right.
  10145. // {dcases} is a {cases} environment where cells are set in \displaystyle,
  10146. // as defined in mathtools.sty.
  10147. // {rcases} is another mathtools environment. It's brace is on the right side.
  10148. defineEnvironment({
  10149. type: "array",
  10150. names: ["cases", "dcases", "rcases", "drcases"],
  10151. props: {
  10152. numArgs: 0
  10153. },
  10154. handler(context) {
  10155. var payload = {
  10156. arraystretch: 1.2,
  10157. cols: [{
  10158. type: "align",
  10159. align: "l",
  10160. pregap: 0,
  10161. // TODO(kevinb) get the current style.
  10162. // For now we use the metrics for TEXT style which is what we were
  10163. // doing before. Before attempting to get the current style we
  10164. // should look at TeX's behavior especially for \over and matrices.
  10165. postgap: 1.0 /* 1em quad */
  10166. }, {
  10167. type: "align",
  10168. align: "l",
  10169. pregap: 0,
  10170. postgap: 0
  10171. }]
  10172. };
  10173. var res = parseArray(context.parser, payload, dCellStyle(context.envName));
  10174. return {
  10175. type: "leftright",
  10176. mode: context.mode,
  10177. body: [res],
  10178. left: context.envName.includes("r") ? "." : "\\{",
  10179. right: context.envName.includes("r") ? "\\}" : ".",
  10180. rightColor: undefined
  10181. };
  10182. },
  10183. htmlBuilder: htmlBuilder$6,
  10184. mathmlBuilder: mathmlBuilder$5
  10185. });
  10186. // In the align environment, one uses ampersands, &, to specify number of
  10187. // columns in each row, and to locate spacing between each column.
  10188. // align gets automatic numbering. align* and aligned do not.
  10189. // The alignedat environment can be used in math mode.
  10190. // Note that we assume \nomallineskiplimit to be zero,
  10191. // so that \strut@ is the same as \strut.
  10192. defineEnvironment({
  10193. type: "array",
  10194. names: ["align", "align*", "aligned", "split"],
  10195. props: {
  10196. numArgs: 0
  10197. },
  10198. handler: alignedHandler,
  10199. htmlBuilder: htmlBuilder$6,
  10200. mathmlBuilder: mathmlBuilder$5
  10201. });
  10202. // A gathered environment is like an array environment with one centered
  10203. // column, but where rows are considered lines so get \jot line spacing
  10204. // and contents are set in \displaystyle.
  10205. defineEnvironment({
  10206. type: "array",
  10207. names: ["gathered", "gather", "gather*"],
  10208. props: {
  10209. numArgs: 0
  10210. },
  10211. handler(context) {
  10212. if (gatherEnvironments.has(context.envName)) {
  10213. validateAmsEnvironmentContext(context);
  10214. }
  10215. var res = {
  10216. cols: [{
  10217. type: "align",
  10218. align: "c"
  10219. }],
  10220. addJot: true,
  10221. colSeparationType: "gather",
  10222. autoTag: getAutoTag(context.envName),
  10223. emptySingleRow: true,
  10224. leqno: context.parser.settings.leqno
  10225. };
  10226. return parseArray(context.parser, res, "display");
  10227. },
  10228. htmlBuilder: htmlBuilder$6,
  10229. mathmlBuilder: mathmlBuilder$5
  10230. });
  10231. // alignat environment is like an align environment, but one must explicitly
  10232. // specify maximum number of columns in each row, and can adjust spacing between
  10233. // each columns.
  10234. defineEnvironment({
  10235. type: "array",
  10236. names: ["alignat", "alignat*", "alignedat"],
  10237. props: {
  10238. numArgs: 1
  10239. },
  10240. handler: alignedHandler,
  10241. htmlBuilder: htmlBuilder$6,
  10242. mathmlBuilder: mathmlBuilder$5
  10243. });
  10244. defineEnvironment({
  10245. type: "array",
  10246. names: ["equation", "equation*"],
  10247. props: {
  10248. numArgs: 0
  10249. },
  10250. handler(context) {
  10251. validateAmsEnvironmentContext(context);
  10252. var res = {
  10253. autoTag: getAutoTag(context.envName),
  10254. emptySingleRow: true,
  10255. singleRow: true,
  10256. maxNumCols: 1,
  10257. leqno: context.parser.settings.leqno
  10258. };
  10259. return parseArray(context.parser, res, "display");
  10260. },
  10261. htmlBuilder: htmlBuilder$6,
  10262. mathmlBuilder: mathmlBuilder$5
  10263. });
  10264. defineEnvironment({
  10265. type: "array",
  10266. names: ["CD"],
  10267. props: {
  10268. numArgs: 0
  10269. },
  10270. handler(context) {
  10271. validateAmsEnvironmentContext(context);
  10272. return parseCD(context.parser);
  10273. },
  10274. htmlBuilder: htmlBuilder$6,
  10275. mathmlBuilder: mathmlBuilder$5
  10276. });
  10277. defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}");
  10278. defineMacro("\\notag", "\\nonumber");
  10279. // Catch \hline outside array environment
  10280. defineFunction({
  10281. type: "text",
  10282. // Doesn't matter what this is.
  10283. names: ["\\hline", "\\hdashline"],
  10284. props: {
  10285. numArgs: 0,
  10286. allowedInText: true,
  10287. allowedInMath: true
  10288. },
  10289. handler(context, args) {
  10290. throw new ParseError(context.funcName + " valid only within array environment");
  10291. }
  10292. });
  10293. var environments = _environments;
  10294. // Environment delimiters. HTML/MathML rendering is defined in the corresponding
  10295. // defineEnvironment definitions.
  10296. defineFunction({
  10297. type: "environment",
  10298. names: ["\\begin", "\\end"],
  10299. props: {
  10300. numArgs: 1,
  10301. argTypes: ["text"]
  10302. },
  10303. handler(_ref, args) {
  10304. var {
  10305. parser,
  10306. funcName
  10307. } = _ref;
  10308. var nameGroup = args[0];
  10309. if (nameGroup.type !== "ordgroup") {
  10310. throw new ParseError("Invalid environment name", nameGroup);
  10311. }
  10312. var envName = "";
  10313. for (var i = 0; i < nameGroup.body.length; ++i) {
  10314. envName += assertNodeType(nameGroup.body[i], "textord").text;
  10315. }
  10316. if (funcName === "\\begin") {
  10317. // begin...end is similar to left...right
  10318. if (!environments.hasOwnProperty(envName)) {
  10319. throw new ParseError("No such environment: " + envName, nameGroup);
  10320. }
  10321. // Build the environment object. Arguments and other information will
  10322. // be made available to the begin and end methods using properties.
  10323. var env = environments[envName];
  10324. var {
  10325. args: _args,
  10326. optArgs
  10327. } = parser.parseArguments("\\begin{" + envName + "}", env);
  10328. var context = {
  10329. mode: parser.mode,
  10330. envName,
  10331. parser
  10332. };
  10333. var result = env.handler(context, _args, optArgs);
  10334. parser.expect("\\end", false);
  10335. var endNameToken = parser.nextToken;
  10336. var end = assertNodeType(parser.parseFunction(), "environment");
  10337. if (end.name !== envName) {
  10338. throw new ParseError("Mismatch: \\begin{" + envName + "} matched by \\end{" + end.name + "}", endNameToken);
  10339. }
  10340. // TODO(ts), "environment" handler returns an environment ParseNode
  10341. return result;
  10342. }
  10343. return {
  10344. type: "environment",
  10345. mode: parser.mode,
  10346. name: envName,
  10347. nameGroup
  10348. };
  10349. }
  10350. });
  10351. // TODO(kevinb): implement \\sl and \\sc
  10352. var htmlBuilder$5 = (group, options) => {
  10353. var font = group.font;
  10354. var newOptions = options.withFont(font);
  10355. return buildGroup$1(group.body, newOptions);
  10356. };
  10357. var mathmlBuilder$4 = (group, options) => {
  10358. var font = group.font;
  10359. var newOptions = options.withFont(font);
  10360. return buildGroup(group.body, newOptions);
  10361. };
  10362. var fontAliases = {
  10363. "\\Bbb": "\\mathbb",
  10364. "\\bold": "\\mathbf",
  10365. "\\frak": "\\mathfrak",
  10366. "\\bm": "\\boldsymbol"
  10367. };
  10368. defineFunction({
  10369. type: "font",
  10370. names: [
  10371. // styles, except \boldsymbol defined below
  10372. "\\mathrm", "\\mathit", "\\mathbf", "\\mathnormal", "\\mathsfit",
  10373. // families
  10374. "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt",
  10375. // aliases, except \bm defined below
  10376. "\\Bbb", "\\bold", "\\frak"],
  10377. props: {
  10378. numArgs: 1,
  10379. allowedInArgument: true
  10380. },
  10381. handler: (_ref, args) => {
  10382. var {
  10383. parser,
  10384. funcName
  10385. } = _ref;
  10386. var body = normalizeArgument(args[0]);
  10387. var func = funcName;
  10388. if (func in fontAliases) {
  10389. func = fontAliases[func];
  10390. }
  10391. return {
  10392. type: "font",
  10393. mode: parser.mode,
  10394. font: func.slice(1),
  10395. body
  10396. };
  10397. },
  10398. htmlBuilder: htmlBuilder$5,
  10399. mathmlBuilder: mathmlBuilder$4
  10400. });
  10401. defineFunction({
  10402. type: "mclass",
  10403. names: ["\\boldsymbol", "\\bm"],
  10404. props: {
  10405. numArgs: 1
  10406. },
  10407. handler: (_ref2, args) => {
  10408. var {
  10409. parser
  10410. } = _ref2;
  10411. var body = args[0];
  10412. // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the
  10413. // argument's bin|rel|ord status
  10414. return {
  10415. type: "mclass",
  10416. mode: parser.mode,
  10417. mclass: binrelClass(body),
  10418. body: [{
  10419. type: "font",
  10420. mode: parser.mode,
  10421. font: "boldsymbol",
  10422. body
  10423. }],
  10424. isCharacterBox: isCharacterBox(body)
  10425. };
  10426. }
  10427. });
  10428. // Old font changing functions
  10429. defineFunction({
  10430. type: "font",
  10431. names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"],
  10432. props: {
  10433. numArgs: 0,
  10434. allowedInText: true
  10435. },
  10436. handler: (_ref3, args) => {
  10437. var {
  10438. parser,
  10439. funcName,
  10440. breakOnTokenText
  10441. } = _ref3;
  10442. var {
  10443. mode
  10444. } = parser;
  10445. var body = parser.parseExpression(true, breakOnTokenText);
  10446. var style = "math" + funcName.slice(1);
  10447. return {
  10448. type: "font",
  10449. mode: mode,
  10450. font: style,
  10451. body: {
  10452. type: "ordgroup",
  10453. mode: parser.mode,
  10454. body
  10455. }
  10456. };
  10457. },
  10458. htmlBuilder: htmlBuilder$5,
  10459. mathmlBuilder: mathmlBuilder$4
  10460. });
  10461. var htmlBuilder$4 = (group, options) => {
  10462. // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e).
  10463. var style = options.style;
  10464. var nstyle = style.fracNum();
  10465. var dstyle = style.fracDen();
  10466. var newOptions;
  10467. newOptions = options.havingStyle(nstyle);
  10468. var numerm = buildGroup$1(group.numer, newOptions, options);
  10469. if (group.continued) {
  10470. // \cfrac inserts a \strut into the numerator.
  10471. // Get \strut dimensions from TeXbook page 353.
  10472. var hStrut = 8.5 / options.fontMetrics().ptPerEm;
  10473. var dStrut = 3.5 / options.fontMetrics().ptPerEm;
  10474. numerm.height = numerm.height < hStrut ? hStrut : numerm.height;
  10475. numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth;
  10476. }
  10477. newOptions = options.havingStyle(dstyle);
  10478. var denomm = buildGroup$1(group.denom, newOptions, options);
  10479. var rule;
  10480. var ruleWidth;
  10481. var ruleSpacing;
  10482. if (group.hasBarLine) {
  10483. if (group.barSize) {
  10484. ruleWidth = calculateSize(group.barSize, options);
  10485. rule = makeLineSpan("frac-line", options, ruleWidth);
  10486. } else {
  10487. rule = makeLineSpan("frac-line", options);
  10488. }
  10489. ruleWidth = rule.height;
  10490. ruleSpacing = rule.height;
  10491. } else {
  10492. rule = null;
  10493. ruleWidth = 0;
  10494. ruleSpacing = options.fontMetrics().defaultRuleThickness;
  10495. }
  10496. // Rule 15b
  10497. var numShift;
  10498. var clearance;
  10499. var denomShift;
  10500. if (style.size === Style$1.DISPLAY.size) {
  10501. numShift = options.fontMetrics().num1;
  10502. if (ruleWidth > 0) {
  10503. clearance = 3 * ruleSpacing;
  10504. } else {
  10505. clearance = 7 * ruleSpacing;
  10506. }
  10507. denomShift = options.fontMetrics().denom1;
  10508. } else {
  10509. if (ruleWidth > 0) {
  10510. numShift = options.fontMetrics().num2;
  10511. clearance = ruleSpacing;
  10512. } else {
  10513. numShift = options.fontMetrics().num3;
  10514. clearance = 3 * ruleSpacing;
  10515. }
  10516. denomShift = options.fontMetrics().denom2;
  10517. }
  10518. var frac;
  10519. if (!rule) {
  10520. // Rule 15c
  10521. var candidateClearance = numShift - numerm.depth - (denomm.height - denomShift);
  10522. if (candidateClearance < clearance) {
  10523. numShift += 0.5 * (clearance - candidateClearance);
  10524. denomShift += 0.5 * (clearance - candidateClearance);
  10525. }
  10526. frac = makeVList({
  10527. positionType: "individualShift",
  10528. children: [{
  10529. type: "elem",
  10530. elem: denomm,
  10531. shift: denomShift
  10532. }, {
  10533. type: "elem",
  10534. elem: numerm,
  10535. shift: -numShift
  10536. }]
  10537. });
  10538. } else {
  10539. // Rule 15d
  10540. var axisHeight = options.fontMetrics().axisHeight;
  10541. if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) {
  10542. numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth));
  10543. }
  10544. if (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift) < clearance) {
  10545. denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift));
  10546. }
  10547. var midShift = -(axisHeight - 0.5 * ruleWidth);
  10548. frac = makeVList({
  10549. positionType: "individualShift",
  10550. children: [{
  10551. type: "elem",
  10552. elem: denomm,
  10553. shift: denomShift
  10554. }, {
  10555. type: "elem",
  10556. elem: rule,
  10557. shift: midShift
  10558. }, {
  10559. type: "elem",
  10560. elem: numerm,
  10561. shift: -numShift
  10562. }]
  10563. });
  10564. }
  10565. // Since we manually change the style sometimes (with \dfrac or \tfrac),
  10566. // account for the possible size change here.
  10567. newOptions = options.havingStyle(style);
  10568. frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier;
  10569. frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier;
  10570. // Rule 15e
  10571. var delimSize;
  10572. if (style.size === Style$1.DISPLAY.size) {
  10573. delimSize = options.fontMetrics().delim1;
  10574. } else if (style.size === Style$1.SCRIPTSCRIPT.size) {
  10575. delimSize = options.havingStyle(Style$1.SCRIPT).fontMetrics().delim2;
  10576. } else {
  10577. delimSize = options.fontMetrics().delim2;
  10578. }
  10579. var leftDelim;
  10580. var rightDelim;
  10581. if (group.leftDelim == null) {
  10582. leftDelim = makeNullDelimiter(options, ["mopen"]);
  10583. } else {
  10584. leftDelim = makeCustomSizedDelim(group.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]);
  10585. }
  10586. if (group.continued) {
  10587. rightDelim = makeSpan([]); // zero width for \cfrac
  10588. } else if (group.rightDelim == null) {
  10589. rightDelim = makeNullDelimiter(options, ["mclose"]);
  10590. } else {
  10591. rightDelim = makeCustomSizedDelim(group.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]);
  10592. }
  10593. return makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, makeSpan(["mfrac"], [frac]), rightDelim], options);
  10594. };
  10595. var mathmlBuilder$3 = (group, options) => {
  10596. var node = new MathNode("mfrac", [buildGroup(group.numer, options), buildGroup(group.denom, options)]);
  10597. if (!group.hasBarLine) {
  10598. node.setAttribute("linethickness", "0px");
  10599. } else if (group.barSize) {
  10600. var ruleWidth = calculateSize(group.barSize, options);
  10601. node.setAttribute("linethickness", makeEm(ruleWidth));
  10602. }
  10603. if (group.leftDelim != null || group.rightDelim != null) {
  10604. var withDelims = [];
  10605. if (group.leftDelim != null) {
  10606. var leftOp = new MathNode("mo", [new TextNode(group.leftDelim.replace("\\", ""))]);
  10607. leftOp.setAttribute("fence", "true");
  10608. withDelims.push(leftOp);
  10609. }
  10610. withDelims.push(node);
  10611. if (group.rightDelim != null) {
  10612. var rightOp = new MathNode("mo", [new TextNode(group.rightDelim.replace("\\", ""))]);
  10613. rightOp.setAttribute("fence", "true");
  10614. withDelims.push(rightOp);
  10615. }
  10616. return makeRow(withDelims);
  10617. }
  10618. return node;
  10619. };
  10620. var wrapWithStyle = (frac, style) => {
  10621. if (!style) {
  10622. return frac;
  10623. }
  10624. var wrapper = {
  10625. type: "styling",
  10626. mode: frac.mode,
  10627. style,
  10628. body: [frac]
  10629. };
  10630. // @ts-ignore defineFunction handler needs to return ParseNode<"genfrac">
  10631. return wrapper;
  10632. };
  10633. defineFunction({
  10634. type: "genfrac",
  10635. names: ["\\cfrac", "\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac",
  10636. // can’t be entered directly
  10637. "\\\\bracefrac", "\\\\brackfrac" // ditto
  10638. ],
  10639. props: {
  10640. numArgs: 2,
  10641. allowedInArgument: true
  10642. },
  10643. handler: (_ref, args) => {
  10644. var {
  10645. parser,
  10646. funcName
  10647. } = _ref;
  10648. var numer = args[0];
  10649. var denom = args[1];
  10650. var hasBarLine;
  10651. var leftDelim = null;
  10652. var rightDelim = null;
  10653. switch (funcName) {
  10654. case "\\cfrac":
  10655. case "\\dfrac":
  10656. case "\\frac":
  10657. case "\\tfrac":
  10658. hasBarLine = true;
  10659. break;
  10660. case "\\\\atopfrac":
  10661. hasBarLine = false;
  10662. break;
  10663. case "\\dbinom":
  10664. case "\\binom":
  10665. case "\\tbinom":
  10666. hasBarLine = false;
  10667. leftDelim = "(";
  10668. rightDelim = ")";
  10669. break;
  10670. case "\\\\bracefrac":
  10671. hasBarLine = false;
  10672. leftDelim = "\\{";
  10673. rightDelim = "\\}";
  10674. break;
  10675. case "\\\\brackfrac":
  10676. hasBarLine = false;
  10677. leftDelim = "[";
  10678. rightDelim = "]";
  10679. break;
  10680. default:
  10681. throw new Error("Unrecognized genfrac command");
  10682. }
  10683. var continued = funcName === "\\cfrac";
  10684. var style = null;
  10685. if (continued || funcName.startsWith("\\d")) {
  10686. style = "display";
  10687. } else if (funcName.startsWith("\\t")) {
  10688. style = "text";
  10689. }
  10690. return wrapWithStyle({
  10691. type: "genfrac",
  10692. mode: parser.mode,
  10693. numer,
  10694. denom,
  10695. continued,
  10696. hasBarLine,
  10697. leftDelim,
  10698. rightDelim,
  10699. barSize: null
  10700. }, style);
  10701. },
  10702. htmlBuilder: htmlBuilder$4,
  10703. mathmlBuilder: mathmlBuilder$3
  10704. });
  10705. // Infix generalized fractions -- these are not rendered directly, but replaced
  10706. // immediately by one of the variants above.
  10707. defineFunction({
  10708. type: "infix",
  10709. names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"],
  10710. props: {
  10711. numArgs: 0,
  10712. infix: true
  10713. },
  10714. handler(_ref2) {
  10715. var {
  10716. parser,
  10717. funcName,
  10718. token
  10719. } = _ref2;
  10720. var replaceWith;
  10721. switch (funcName) {
  10722. case "\\over":
  10723. replaceWith = "\\frac";
  10724. break;
  10725. case "\\choose":
  10726. replaceWith = "\\binom";
  10727. break;
  10728. case "\\atop":
  10729. replaceWith = "\\\\atopfrac";
  10730. break;
  10731. case "\\brace":
  10732. replaceWith = "\\\\bracefrac";
  10733. break;
  10734. case "\\brack":
  10735. replaceWith = "\\\\brackfrac";
  10736. break;
  10737. default:
  10738. throw new Error("Unrecognized infix genfrac command");
  10739. }
  10740. return {
  10741. type: "infix",
  10742. mode: parser.mode,
  10743. replaceWith,
  10744. token
  10745. };
  10746. }
  10747. });
  10748. var stylArray = ["display", "text", "script", "scriptscript"];
  10749. var delimFromValue = function delimFromValue(delimString) {
  10750. var delim = null;
  10751. if (delimString.length > 0) {
  10752. delim = delimString;
  10753. delim = delim === "." ? null : delim;
  10754. }
  10755. return delim;
  10756. };
  10757. defineFunction({
  10758. type: "genfrac",
  10759. names: ["\\genfrac"],
  10760. props: {
  10761. numArgs: 6,
  10762. allowedInArgument: true,
  10763. argTypes: ["math", "math", "size", "text", "math", "math"]
  10764. },
  10765. handler(_ref3, args) {
  10766. var {
  10767. parser
  10768. } = _ref3;
  10769. var numer = args[4];
  10770. var denom = args[5];
  10771. // Look into the parse nodes to get the desired delimiters.
  10772. var leftNode = normalizeArgument(args[0]);
  10773. var leftDelim = leftNode.type === "atom" && leftNode.family === "open" ? delimFromValue(leftNode.text) : null;
  10774. var rightNode = normalizeArgument(args[1]);
  10775. var rightDelim = rightNode.type === "atom" && rightNode.family === "close" ? delimFromValue(rightNode.text) : null;
  10776. var barNode = assertNodeType(args[2], "size");
  10777. var hasBarLine;
  10778. var barSize = null;
  10779. if (barNode.isBlank) {
  10780. // \genfrac acts differently than \above.
  10781. // \genfrac treats an empty size group as a signal to use a
  10782. // standard bar size. \above would see size = 0 and omit the bar.
  10783. hasBarLine = true;
  10784. } else {
  10785. barSize = barNode.value;
  10786. hasBarLine = barSize.number > 0;
  10787. }
  10788. // Find out if we want displaystyle, textstyle, etc.
  10789. var size = null;
  10790. var styl = args[3];
  10791. if (styl.type === "ordgroup") {
  10792. if (styl.body.length > 0) {
  10793. var textOrd = assertNodeType(styl.body[0], "textord");
  10794. size = stylArray[Number(textOrd.text)];
  10795. }
  10796. } else {
  10797. styl = assertNodeType(styl, "textord");
  10798. size = stylArray[Number(styl.text)];
  10799. }
  10800. return wrapWithStyle({
  10801. type: "genfrac",
  10802. mode: parser.mode,
  10803. numer,
  10804. denom,
  10805. continued: false,
  10806. hasBarLine,
  10807. barSize,
  10808. leftDelim,
  10809. rightDelim
  10810. }, size);
  10811. }
  10812. });
  10813. // \above is an infix fraction that also defines a fraction bar size.
  10814. defineFunction({
  10815. type: "infix",
  10816. names: ["\\above"],
  10817. props: {
  10818. numArgs: 1,
  10819. argTypes: ["size"],
  10820. infix: true
  10821. },
  10822. handler(_ref4, args) {
  10823. var {
  10824. parser,
  10825. funcName,
  10826. token
  10827. } = _ref4;
  10828. return {
  10829. type: "infix",
  10830. mode: parser.mode,
  10831. replaceWith: "\\\\abovefrac",
  10832. size: assertNodeType(args[0], "size").value,
  10833. token
  10834. };
  10835. }
  10836. });
  10837. defineFunction({
  10838. type: "genfrac",
  10839. names: ["\\\\abovefrac"],
  10840. props: {
  10841. numArgs: 3,
  10842. argTypes: ["math", "size", "math"]
  10843. },
  10844. handler: (_ref5, args) => {
  10845. var {
  10846. parser,
  10847. funcName
  10848. } = _ref5;
  10849. var numer = args[0];
  10850. var barSize = assertNodeType(args[1], "infix").size;
  10851. if (!barSize) {
  10852. throw new Error("\\\\abovefrac expected size, but got " + String(barSize));
  10853. }
  10854. var denom = args[2];
  10855. var hasBarLine = barSize.number > 0;
  10856. return {
  10857. type: "genfrac",
  10858. mode: parser.mode,
  10859. numer,
  10860. denom,
  10861. continued: false,
  10862. hasBarLine,
  10863. barSize,
  10864. leftDelim: null,
  10865. rightDelim: null
  10866. };
  10867. }
  10868. });
  10869. // NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but
  10870. // also "supsub" since an over/underbrace can affect super/subscripting.
  10871. var htmlBuilder$3 = (grp, options) => {
  10872. var style = options.style;
  10873. // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node.
  10874. var supSubGroup;
  10875. var group;
  10876. if (grp.type === "supsub") {
  10877. // Ref: LaTeX source2e: }}}}\limits}
  10878. // i.e. LaTeX treats the brace similar to an op and passes it
  10879. // with \limits, so we need to assign supsub style.
  10880. supSubGroup = grp.sup ? buildGroup$1(grp.sup, options.havingStyle(style.sup()), options) : buildGroup$1(grp.sub, options.havingStyle(style.sub()), options);
  10881. group = assertNodeType(grp.base, "horizBrace");
  10882. } else {
  10883. group = assertNodeType(grp, "horizBrace");
  10884. }
  10885. // Build the base group
  10886. var body = buildGroup$1(group.base, options.havingBaseStyle(Style$1.DISPLAY));
  10887. // Create the stretchy element
  10888. var braceBody = stretchySvg(group, options);
  10889. // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓
  10890. // This first vlist contains the content and the brace: equation
  10891. var vlist;
  10892. if (group.isOver) {
  10893. vlist = makeVList({
  10894. positionType: "firstBaseline",
  10895. children: [{
  10896. type: "elem",
  10897. elem: body
  10898. }, {
  10899. type: "kern",
  10900. size: 0.1
  10901. }, {
  10902. type: "elem",
  10903. elem: braceBody
  10904. }]
  10905. });
  10906. // TODO(ts): Replace this with passing "svg-align" into makeVList.
  10907. vlist.children[0].children[0].children[1].classes.push("svg-align");
  10908. } else {
  10909. vlist = makeVList({
  10910. positionType: "bottom",
  10911. positionData: body.depth + 0.1 + braceBody.height,
  10912. children: [{
  10913. type: "elem",
  10914. elem: braceBody
  10915. }, {
  10916. type: "kern",
  10917. size: 0.1
  10918. }, {
  10919. type: "elem",
  10920. elem: body
  10921. }]
  10922. });
  10923. // TODO(ts): Replace this with passing "svg-align" into makeVList.
  10924. vlist.children[0].children[0].children[0].classes.push("svg-align");
  10925. }
  10926. if (supSubGroup) {
  10927. // To write the supsub, wrap the first vlist in another vlist:
  10928. // They can't all go in the same vlist, because the note might be
  10929. // wider than the equation. We want the equation to control the
  10930. // brace width.
  10931. // note long note long note
  10932. // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓
  10933. // equation eqn eqn
  10934. var vSpan = makeSpan(["minner", group.isOver ? "mover" : "munder"], [vlist], options);
  10935. if (group.isOver) {
  10936. vlist = makeVList({
  10937. positionType: "firstBaseline",
  10938. children: [{
  10939. type: "elem",
  10940. elem: vSpan
  10941. }, {
  10942. type: "kern",
  10943. size: 0.2
  10944. }, {
  10945. type: "elem",
  10946. elem: supSubGroup
  10947. }]
  10948. });
  10949. } else {
  10950. vlist = makeVList({
  10951. positionType: "bottom",
  10952. positionData: vSpan.depth + 0.2 + supSubGroup.height + supSubGroup.depth,
  10953. children: [{
  10954. type: "elem",
  10955. elem: supSubGroup
  10956. }, {
  10957. type: "kern",
  10958. size: 0.2
  10959. }, {
  10960. type: "elem",
  10961. elem: vSpan
  10962. }]
  10963. });
  10964. }
  10965. }
  10966. return makeSpan(["minner", group.isOver ? "mover" : "munder"], [vlist], options);
  10967. };
  10968. var mathmlBuilder$2 = (group, options) => {
  10969. var accentNode = stretchyMathML(group.label);
  10970. return new MathNode(group.isOver ? "mover" : "munder", [buildGroup(group.base, options), accentNode]);
  10971. };
  10972. // Horizontal stretchy braces
  10973. defineFunction({
  10974. type: "horizBrace",
  10975. names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"],
  10976. props: {
  10977. numArgs: 1
  10978. },
  10979. handler(_ref, args) {
  10980. var {
  10981. parser,
  10982. funcName
  10983. } = _ref;
  10984. return {
  10985. type: "horizBrace",
  10986. mode: parser.mode,
  10987. label: funcName,
  10988. isOver: funcName.includes("\\over"),
  10989. base: args[0]
  10990. };
  10991. },
  10992. htmlBuilder: htmlBuilder$3,
  10993. mathmlBuilder: mathmlBuilder$2
  10994. });
  10995. defineFunction({
  10996. type: "href",
  10997. names: ["\\href"],
  10998. props: {
  10999. numArgs: 2,
  11000. argTypes: ["url", "original"],
  11001. allowedInText: true
  11002. },
  11003. handler: (_ref, args) => {
  11004. var {
  11005. parser
  11006. } = _ref;
  11007. var body = args[1];
  11008. var href = assertNodeType(args[0], "url").url;
  11009. if (!parser.settings.isTrusted({
  11010. command: "\\href",
  11011. url: href
  11012. })) {
  11013. return parser.formatUnsupportedCmd("\\href");
  11014. }
  11015. return {
  11016. type: "href",
  11017. mode: parser.mode,
  11018. href,
  11019. body: ordargument(body)
  11020. };
  11021. },
  11022. htmlBuilder: (group, options) => {
  11023. var elements = buildExpression$1(group.body, options, false);
  11024. return makeAnchor(group.href, [], elements, options);
  11025. },
  11026. mathmlBuilder: (group, options) => {
  11027. var math = buildExpressionRow(group.body, options);
  11028. if (!(math instanceof MathNode)) {
  11029. math = new MathNode("mrow", [math]);
  11030. }
  11031. math.setAttribute("href", group.href);
  11032. return math;
  11033. }
  11034. });
  11035. defineFunction({
  11036. type: "href",
  11037. names: ["\\url"],
  11038. props: {
  11039. numArgs: 1,
  11040. argTypes: ["url"],
  11041. allowedInText: true
  11042. },
  11043. handler: (_ref2, args) => {
  11044. var {
  11045. parser
  11046. } = _ref2;
  11047. var href = assertNodeType(args[0], "url").url;
  11048. if (!parser.settings.isTrusted({
  11049. command: "\\url",
  11050. url: href
  11051. })) {
  11052. return parser.formatUnsupportedCmd("\\url");
  11053. }
  11054. var chars = [];
  11055. for (var i = 0; i < href.length; i++) {
  11056. var c = href[i];
  11057. if (c === "~") {
  11058. c = "\\textasciitilde";
  11059. }
  11060. chars.push({
  11061. type: "textord",
  11062. mode: "text",
  11063. text: c
  11064. });
  11065. }
  11066. var body = {
  11067. type: "text",
  11068. mode: parser.mode,
  11069. font: "\\texttt",
  11070. body: chars
  11071. };
  11072. return {
  11073. type: "href",
  11074. mode: parser.mode,
  11075. href,
  11076. body: ordargument(body)
  11077. };
  11078. }
  11079. });
  11080. // \hbox is provided for compatibility with LaTeX \vcenter.
  11081. // In LaTeX, \vcenter can act only on a box, as in
  11082. // \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}}
  11083. // This function by itself doesn't do anything but prevent a soft line break.
  11084. defineFunction({
  11085. type: "hbox",
  11086. names: ["\\hbox"],
  11087. props: {
  11088. numArgs: 1,
  11089. argTypes: ["text"],
  11090. allowedInText: true,
  11091. primitive: true
  11092. },
  11093. handler(_ref, args) {
  11094. var {
  11095. parser
  11096. } = _ref;
  11097. return {
  11098. type: "hbox",
  11099. mode: parser.mode,
  11100. body: ordargument(args[0])
  11101. };
  11102. },
  11103. htmlBuilder(group, options) {
  11104. var elements = buildExpression$1(group.body, options, false);
  11105. return makeFragment(elements);
  11106. },
  11107. mathmlBuilder(group, options) {
  11108. return new MathNode("mrow", buildExpression(group.body, options));
  11109. }
  11110. });
  11111. defineFunction({
  11112. type: "html",
  11113. names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"],
  11114. props: {
  11115. numArgs: 2,
  11116. argTypes: ["raw", "original"],
  11117. allowedInText: true
  11118. },
  11119. handler: (_ref, args) => {
  11120. var {
  11121. parser,
  11122. funcName,
  11123. token
  11124. } = _ref;
  11125. var value = assertNodeType(args[0], "raw").string;
  11126. var body = args[1];
  11127. if (parser.settings.strict) {
  11128. parser.settings.reportNonstrict("htmlExtension", "HTML extension is disabled on strict mode");
  11129. }
  11130. var trustContext;
  11131. var attributes = {};
  11132. switch (funcName) {
  11133. case "\\htmlClass":
  11134. attributes.class = value;
  11135. trustContext = {
  11136. command: "\\htmlClass",
  11137. class: value
  11138. };
  11139. break;
  11140. case "\\htmlId":
  11141. attributes.id = value;
  11142. trustContext = {
  11143. command: "\\htmlId",
  11144. id: value
  11145. };
  11146. break;
  11147. case "\\htmlStyle":
  11148. attributes.style = value;
  11149. trustContext = {
  11150. command: "\\htmlStyle",
  11151. style: value
  11152. };
  11153. break;
  11154. case "\\htmlData":
  11155. {
  11156. var data = value.split(",");
  11157. for (var i = 0; i < data.length; i++) {
  11158. var item = data[i];
  11159. var firstEquals = item.indexOf("=");
  11160. if (firstEquals < 0) {
  11161. throw new ParseError("\\htmlData key/value '" + item + "'" + " missing equals sign");
  11162. }
  11163. var key = item.slice(0, firstEquals);
  11164. var _value = item.slice(firstEquals + 1);
  11165. attributes["data-" + key.trim()] = _value;
  11166. }
  11167. trustContext = {
  11168. command: "\\htmlData",
  11169. attributes
  11170. };
  11171. break;
  11172. }
  11173. default:
  11174. throw new Error("Unrecognized html command");
  11175. }
  11176. if (!parser.settings.isTrusted(trustContext)) {
  11177. return parser.formatUnsupportedCmd(funcName);
  11178. }
  11179. return {
  11180. type: "html",
  11181. mode: parser.mode,
  11182. attributes,
  11183. body: ordargument(body)
  11184. };
  11185. },
  11186. htmlBuilder: (group, options) => {
  11187. var elements = buildExpression$1(group.body, options, false);
  11188. var classes = ["enclosing"];
  11189. if (group.attributes.class) {
  11190. classes.push(...group.attributes.class.trim().split(/\s+/));
  11191. }
  11192. var span = makeSpan(classes, elements, options);
  11193. for (var attr in group.attributes) {
  11194. if (attr !== "class" && group.attributes.hasOwnProperty(attr)) {
  11195. span.setAttribute(attr, group.attributes[attr]);
  11196. }
  11197. }
  11198. return span;
  11199. },
  11200. mathmlBuilder: (group, options) => {
  11201. return buildExpressionRow(group.body, options);
  11202. }
  11203. });
  11204. defineFunction({
  11205. type: "htmlmathml",
  11206. names: ["\\html@mathml"],
  11207. props: {
  11208. numArgs: 2,
  11209. allowedInArgument: true,
  11210. allowedInText: true
  11211. },
  11212. handler: (_ref, args) => {
  11213. var {
  11214. parser
  11215. } = _ref;
  11216. return {
  11217. type: "htmlmathml",
  11218. mode: parser.mode,
  11219. html: ordargument(args[0]),
  11220. mathml: ordargument(args[1])
  11221. };
  11222. },
  11223. htmlBuilder: (group, options) => {
  11224. var elements = buildExpression$1(group.html, options, false);
  11225. return makeFragment(elements);
  11226. },
  11227. mathmlBuilder: (group, options) => {
  11228. return buildExpressionRow(group.mathml, options);
  11229. }
  11230. });
  11231. var sizeData = function sizeData(str) {
  11232. if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) {
  11233. // str is a number with no unit specified.
  11234. // default unit is bp, per graphix package.
  11235. return {
  11236. number: +str,
  11237. unit: "bp"
  11238. };
  11239. } else {
  11240. var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str);
  11241. if (!match) {
  11242. throw new ParseError("Invalid size: '" + str + "' in \\includegraphics");
  11243. }
  11244. var data = {
  11245. number: +(match[1] + match[2]),
  11246. // sign + magnitude, cast to number
  11247. unit: match[3]
  11248. };
  11249. if (!validUnit(data)) {
  11250. throw new ParseError("Invalid unit: '" + data.unit + "' in \\includegraphics.");
  11251. }
  11252. return data;
  11253. }
  11254. };
  11255. defineFunction({
  11256. type: "includegraphics",
  11257. names: ["\\includegraphics"],
  11258. props: {
  11259. numArgs: 1,
  11260. numOptionalArgs: 1,
  11261. argTypes: ["raw", "url"],
  11262. allowedInText: false
  11263. },
  11264. handler: (_ref, args, optArgs) => {
  11265. var {
  11266. parser
  11267. } = _ref;
  11268. var width = {
  11269. number: 0,
  11270. unit: "em"
  11271. };
  11272. var height = {
  11273. number: 0.9,
  11274. unit: "em"
  11275. }; // sorta character sized.
  11276. var totalheight = {
  11277. number: 0,
  11278. unit: "em"
  11279. };
  11280. var alt = "";
  11281. if (optArgs[0]) {
  11282. var attributeStr = assertNodeType(optArgs[0], "raw").string;
  11283. // Parser.js does not parse key/value pairs. We get a string.
  11284. var attributes = attributeStr.split(",");
  11285. for (var i = 0; i < attributes.length; i++) {
  11286. var keyVal = attributes[i].split("=");
  11287. if (keyVal.length === 2) {
  11288. var str = keyVal[1].trim();
  11289. switch (keyVal[0].trim()) {
  11290. case "alt":
  11291. alt = str;
  11292. break;
  11293. case "width":
  11294. width = sizeData(str);
  11295. break;
  11296. case "height":
  11297. height = sizeData(str);
  11298. break;
  11299. case "totalheight":
  11300. totalheight = sizeData(str);
  11301. break;
  11302. default:
  11303. throw new ParseError("Invalid key: '" + keyVal[0] + "' in \\includegraphics.");
  11304. }
  11305. }
  11306. }
  11307. }
  11308. var src = assertNodeType(args[0], "url").url;
  11309. if (alt === "") {
  11310. // No alt given. Use the file name. Strip away the path.
  11311. alt = src;
  11312. alt = alt.replace(/^.*[\\/]/, '');
  11313. alt = alt.substring(0, alt.lastIndexOf('.'));
  11314. }
  11315. if (!parser.settings.isTrusted({
  11316. command: "\\includegraphics",
  11317. url: src
  11318. })) {
  11319. return parser.formatUnsupportedCmd("\\includegraphics");
  11320. }
  11321. return {
  11322. type: "includegraphics",
  11323. mode: parser.mode,
  11324. alt: alt,
  11325. width: width,
  11326. height: height,
  11327. totalheight: totalheight,
  11328. src: src
  11329. };
  11330. },
  11331. htmlBuilder: (group, options) => {
  11332. var height = calculateSize(group.height, options);
  11333. var depth = 0;
  11334. if (group.totalheight.number > 0) {
  11335. depth = calculateSize(group.totalheight, options) - height;
  11336. }
  11337. var width = 0;
  11338. if (group.width.number > 0) {
  11339. width = calculateSize(group.width, options);
  11340. }
  11341. var style = {
  11342. height: makeEm(height + depth)
  11343. };
  11344. if (width > 0) {
  11345. style.width = makeEm(width);
  11346. }
  11347. if (depth > 0) {
  11348. style.verticalAlign = makeEm(-depth);
  11349. }
  11350. var node = new Img(group.src, group.alt, style);
  11351. node.height = height;
  11352. node.depth = depth;
  11353. return node;
  11354. },
  11355. mathmlBuilder: (group, options) => {
  11356. var node = new MathNode("mglyph", []);
  11357. node.setAttribute("alt", group.alt);
  11358. var height = calculateSize(group.height, options);
  11359. var depth = 0;
  11360. if (group.totalheight.number > 0) {
  11361. depth = calculateSize(group.totalheight, options) - height;
  11362. node.setAttribute("valign", makeEm(-depth));
  11363. }
  11364. node.setAttribute("height", makeEm(height + depth));
  11365. if (group.width.number > 0) {
  11366. var width = calculateSize(group.width, options);
  11367. node.setAttribute("width", makeEm(width));
  11368. }
  11369. node.setAttribute("src", group.src);
  11370. return node;
  11371. }
  11372. });
  11373. // Horizontal spacing commands
  11374. // TODO: \hskip and \mskip should support plus and minus in lengths
  11375. defineFunction({
  11376. type: "kern",
  11377. names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"],
  11378. props: {
  11379. numArgs: 1,
  11380. argTypes: ["size"],
  11381. primitive: true,
  11382. allowedInText: true
  11383. },
  11384. handler(_ref, args) {
  11385. var {
  11386. parser,
  11387. funcName
  11388. } = _ref;
  11389. var size = assertNodeType(args[0], "size");
  11390. if (parser.settings.strict) {
  11391. var mathFunction = funcName[1] === 'm'; // \mkern, \mskip
  11392. var muUnit = size.value.unit === 'mu';
  11393. if (mathFunction) {
  11394. if (!muUnit) {
  11395. parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " supports only mu units, " + ("not " + size.value.unit + " units"));
  11396. }
  11397. if (parser.mode !== "math") {
  11398. parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " works only in math mode");
  11399. }
  11400. } else {
  11401. // !mathFunction
  11402. if (muUnit) {
  11403. parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " doesn't support mu units");
  11404. }
  11405. }
  11406. }
  11407. return {
  11408. type: "kern",
  11409. mode: parser.mode,
  11410. dimension: size.value
  11411. };
  11412. },
  11413. htmlBuilder(group, options) {
  11414. return makeGlue(group.dimension, options);
  11415. },
  11416. mathmlBuilder(group, options) {
  11417. var dimension = calculateSize(group.dimension, options);
  11418. return new SpaceNode(dimension);
  11419. }
  11420. });
  11421. // Horizontal overlap functions
  11422. defineFunction({
  11423. type: "lap",
  11424. names: ["\\mathllap", "\\mathrlap", "\\mathclap"],
  11425. props: {
  11426. numArgs: 1,
  11427. allowedInText: true
  11428. },
  11429. handler: (_ref, args) => {
  11430. var {
  11431. parser,
  11432. funcName
  11433. } = _ref;
  11434. var body = args[0];
  11435. return {
  11436. type: "lap",
  11437. mode: parser.mode,
  11438. alignment: funcName.slice(5),
  11439. body
  11440. };
  11441. },
  11442. htmlBuilder: (group, options) => {
  11443. // mathllap, mathrlap, mathclap
  11444. var inner;
  11445. if (group.alignment === "clap") {
  11446. // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/
  11447. inner = makeSpan([], [buildGroup$1(group.body, options)]);
  11448. // wrap, since CSS will center a .clap > .inner > span
  11449. inner = makeSpan(["inner"], [inner], options);
  11450. } else {
  11451. inner = makeSpan(["inner"], [buildGroup$1(group.body, options)]);
  11452. }
  11453. var fix = makeSpan(["fix"], []);
  11454. var node = makeSpan([group.alignment], [inner, fix], options);
  11455. // At this point, we have correctly set horizontal alignment of the
  11456. // two items involved in the lap.
  11457. // Next, use a strut to set the height of the HTML bounding box.
  11458. // Otherwise, a tall argument may be misplaced.
  11459. // This code resolved issue #1153
  11460. var strut = makeSpan(["strut"]);
  11461. strut.style.height = makeEm(node.height + node.depth);
  11462. if (node.depth) {
  11463. strut.style.verticalAlign = makeEm(-node.depth);
  11464. }
  11465. node.children.unshift(strut);
  11466. // Next, prevent vertical misplacement when next to something tall.
  11467. // This code resolves issue #1234
  11468. node = makeSpan(["thinbox"], [node], options);
  11469. return makeSpan(["mord", "vbox"], [node], options);
  11470. },
  11471. mathmlBuilder: (group, options) => {
  11472. // mathllap, mathrlap, mathclap
  11473. var node = new MathNode("mpadded", [buildGroup(group.body, options)]);
  11474. if (group.alignment !== "rlap") {
  11475. var offset = group.alignment === "llap" ? "-1" : "-0.5";
  11476. node.setAttribute("lspace", offset + "width");
  11477. }
  11478. node.setAttribute("width", "0px");
  11479. return node;
  11480. }
  11481. });
  11482. // Switching from text mode back to math mode
  11483. defineFunction({
  11484. type: "styling",
  11485. names: ["\\(", "$"],
  11486. props: {
  11487. numArgs: 0,
  11488. allowedInText: true,
  11489. allowedInMath: false
  11490. },
  11491. handler(_ref, args) {
  11492. var {
  11493. funcName,
  11494. parser
  11495. } = _ref;
  11496. var outerMode = parser.mode;
  11497. parser.switchMode("math");
  11498. var close = funcName === "\\(" ? "\\)" : "$";
  11499. var body = parser.parseExpression(false, close);
  11500. parser.expect(close);
  11501. parser.switchMode(outerMode);
  11502. return {
  11503. type: "styling",
  11504. mode: parser.mode,
  11505. style: "text",
  11506. body
  11507. };
  11508. }
  11509. });
  11510. // Check for extra closing math delimiters
  11511. defineFunction({
  11512. type: "text",
  11513. // Doesn't matter what this is.
  11514. names: ["\\)", "\\]"],
  11515. props: {
  11516. numArgs: 0,
  11517. allowedInText: true,
  11518. allowedInMath: false
  11519. },
  11520. handler(context, args) {
  11521. throw new ParseError("Mismatched " + context.funcName);
  11522. }
  11523. });
  11524. var chooseMathStyle = (group, options) => {
  11525. switch (options.style.size) {
  11526. case Style$1.DISPLAY.size:
  11527. return group.display;
  11528. case Style$1.TEXT.size:
  11529. return group.text;
  11530. case Style$1.SCRIPT.size:
  11531. return group.script;
  11532. case Style$1.SCRIPTSCRIPT.size:
  11533. return group.scriptscript;
  11534. default:
  11535. return group.text;
  11536. }
  11537. };
  11538. defineFunction({
  11539. type: "mathchoice",
  11540. names: ["\\mathchoice"],
  11541. props: {
  11542. numArgs: 4,
  11543. primitive: true
  11544. },
  11545. handler: (_ref, args) => {
  11546. var {
  11547. parser
  11548. } = _ref;
  11549. return {
  11550. type: "mathchoice",
  11551. mode: parser.mode,
  11552. display: ordargument(args[0]),
  11553. text: ordargument(args[1]),
  11554. script: ordargument(args[2]),
  11555. scriptscript: ordargument(args[3])
  11556. };
  11557. },
  11558. htmlBuilder: (group, options) => {
  11559. var body = chooseMathStyle(group, options);
  11560. var elements = buildExpression$1(body, options, false);
  11561. return makeFragment(elements);
  11562. },
  11563. mathmlBuilder: (group, options) => {
  11564. var body = chooseMathStyle(group, options);
  11565. return buildExpressionRow(body, options);
  11566. }
  11567. });
  11568. // For an operator with limits, assemble the base, sup, and sub into a span.
  11569. var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => {
  11570. base = makeSpan([], [base]);
  11571. var subIsSingleCharacter = subGroup && isCharacterBox(subGroup);
  11572. var sub;
  11573. var sup;
  11574. // We manually have to handle the superscripts and subscripts. This,
  11575. // aside from the kern calculations, is copied from supsub.
  11576. if (supGroup) {
  11577. var elem = buildGroup$1(supGroup, options.havingStyle(style.sup()), options);
  11578. sup = {
  11579. elem,
  11580. kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth)
  11581. };
  11582. }
  11583. if (subGroup) {
  11584. var _elem = buildGroup$1(subGroup, options.havingStyle(style.sub()), options);
  11585. sub = {
  11586. elem: _elem,
  11587. kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - _elem.height)
  11588. };
  11589. }
  11590. // Build the final group as a vlist of the possible subscript, base,
  11591. // and possible superscript.
  11592. var finalGroup;
  11593. if (sup && sub) {
  11594. var bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift;
  11595. finalGroup = makeVList({
  11596. positionType: "bottom",
  11597. positionData: bottom,
  11598. children: [{
  11599. type: "kern",
  11600. size: options.fontMetrics().bigOpSpacing5
  11601. }, {
  11602. type: "elem",
  11603. elem: sub.elem,
  11604. marginLeft: makeEm(-slant)
  11605. }, {
  11606. type: "kern",
  11607. size: sub.kern
  11608. }, {
  11609. type: "elem",
  11610. elem: base
  11611. }, {
  11612. type: "kern",
  11613. size: sup.kern
  11614. }, {
  11615. type: "elem",
  11616. elem: sup.elem,
  11617. marginLeft: makeEm(slant)
  11618. }, {
  11619. type: "kern",
  11620. size: options.fontMetrics().bigOpSpacing5
  11621. }]
  11622. });
  11623. } else if (sub) {
  11624. var top = base.height - baseShift;
  11625. // Shift the limits by the slant of the symbol. Note
  11626. // that we are supposed to shift the limits by 1/2 of the slant,
  11627. // but since we are centering the limits adding a full slant of
  11628. // margin will shift by 1/2 that.
  11629. finalGroup = makeVList({
  11630. positionType: "top",
  11631. positionData: top,
  11632. children: [{
  11633. type: "kern",
  11634. size: options.fontMetrics().bigOpSpacing5
  11635. }, {
  11636. type: "elem",
  11637. elem: sub.elem,
  11638. marginLeft: makeEm(-slant)
  11639. }, {
  11640. type: "kern",
  11641. size: sub.kern
  11642. }, {
  11643. type: "elem",
  11644. elem: base
  11645. }]
  11646. });
  11647. } else if (sup) {
  11648. var _bottom = base.depth + baseShift;
  11649. finalGroup = makeVList({
  11650. positionType: "bottom",
  11651. positionData: _bottom,
  11652. children: [{
  11653. type: "elem",
  11654. elem: base
  11655. }, {
  11656. type: "kern",
  11657. size: sup.kern
  11658. }, {
  11659. type: "elem",
  11660. elem: sup.elem,
  11661. marginLeft: makeEm(slant)
  11662. }, {
  11663. type: "kern",
  11664. size: options.fontMetrics().bigOpSpacing5
  11665. }]
  11666. });
  11667. } else {
  11668. // This case probably shouldn't occur (this would mean the
  11669. // supsub was sending us a group with no superscript or
  11670. // subscript) but be safe.
  11671. return base;
  11672. }
  11673. var parts = [finalGroup];
  11674. if (sub && slant !== 0 && !subIsSingleCharacter) {
  11675. // A negative margin-left was applied to the lower limit.
  11676. // Avoid an overlap by placing a spacer on the left on the group.
  11677. var spacer = makeSpan(["mspace"], [], options);
  11678. spacer.style.marginRight = makeEm(slant);
  11679. parts.unshift(spacer);
  11680. }
  11681. return makeSpan(["mop", "op-limits"], parts, options);
  11682. };
  11683. // Limits, symbols
  11684. // Most operators have a large successor symbol, but these don't.
  11685. var noSuccessor = new Set(["\\smallint"]);
  11686. // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also
  11687. // "supsub" since some of them (like \int) can affect super/subscripting.
  11688. var htmlBuilder$2 = (grp, options) => {
  11689. // Operators are handled in the TeXbook pg. 443-444, rule 13(a).
  11690. var supGroup;
  11691. var subGroup;
  11692. var hasLimits = false;
  11693. var group;
  11694. if (grp.type === "supsub") {
  11695. // If we have limits, supsub will pass us its group to handle. Pull
  11696. // out the superscript and subscript and set the group to the op in
  11697. // its base.
  11698. supGroup = grp.sup;
  11699. subGroup = grp.sub;
  11700. group = assertNodeType(grp.base, "op");
  11701. hasLimits = true;
  11702. } else {
  11703. group = assertNodeType(grp, "op");
  11704. }
  11705. var style = options.style;
  11706. var large = false;
  11707. if (style.size === Style$1.DISPLAY.size && group.symbol && !noSuccessor.has(group.name)) {
  11708. // Most symbol operators get larger in displaystyle (rule 13)
  11709. large = true;
  11710. }
  11711. var base;
  11712. if (group.symbol) {
  11713. // If this is a symbol, create the symbol.
  11714. var fontName = large ? "Size2-Regular" : "Size1-Regular";
  11715. var stash = "";
  11716. if (group.name === "\\oiint" || group.name === "\\oiiint") {
  11717. // No font glyphs yet, so use a glyph w/o the oval.
  11718. // TODO: When font glyphs are available, delete this code.
  11719. stash = group.name.slice(1);
  11720. group.name = stash === "oiint" ? "\\iint" : "\\iiint";
  11721. }
  11722. base = makeSymbol(group.name, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]);
  11723. if (stash.length > 0) {
  11724. // We're in \oiint or \oiiint. Overlay the oval.
  11725. // TODO: When font glyphs are available, delete this code.
  11726. var italic = base.italic;
  11727. var oval = staticSvg(stash + "Size" + (large ? "2" : "1"), options);
  11728. base = makeVList({
  11729. positionType: "individualShift",
  11730. children: [{
  11731. type: "elem",
  11732. elem: base,
  11733. shift: 0
  11734. }, {
  11735. type: "elem",
  11736. elem: oval,
  11737. shift: large ? 0.08 : 0
  11738. }]
  11739. });
  11740. group.name = "\\" + stash;
  11741. base.classes.unshift("mop");
  11742. // TODO(ts)
  11743. base.italic = italic;
  11744. }
  11745. } else if (group.body) {
  11746. // If this is a list, compose that list.
  11747. var inner = buildExpression$1(group.body, options, true);
  11748. if (inner.length === 1 && inner[0] instanceof SymbolNode) {
  11749. base = inner[0];
  11750. base.classes[0] = "mop"; // replace old mclass
  11751. } else {
  11752. base = makeSpan(["mop"], inner, options);
  11753. }
  11754. } else {
  11755. // Otherwise, this is a text operator. Build the text from the
  11756. // operator's name.
  11757. var output = [];
  11758. for (var i = 1; i < group.name.length; i++) {
  11759. output.push(mathsym(group.name[i], group.mode, options));
  11760. }
  11761. base = makeSpan(["mop"], output, options);
  11762. }
  11763. // If content of op is a single symbol, shift it vertically.
  11764. var baseShift = 0;
  11765. var slant = 0;
  11766. if ((base instanceof SymbolNode || group.name === "\\oiint" || group.name === "\\oiiint") && !group.suppressBaseShift) {
  11767. // We suppress the shift of the base of \overset and \underset. Otherwise,
  11768. // shift the symbol so its center lies on the axis (rule 13). It
  11769. // appears that our fonts have the centers of the symbols already
  11770. // almost on the axis, so these numbers are very small. Note we
  11771. // don't actually apply this here, but instead it is used either in
  11772. // the vlist creation or separately when there are no limits.
  11773. baseShift = (base.height - base.depth) / 2 - options.fontMetrics().axisHeight;
  11774. // The slant of the symbol is just its italic correction.
  11775. // TODO(ts)
  11776. slant = base.italic || 0;
  11777. }
  11778. if (hasLimits) {
  11779. return assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift);
  11780. } else {
  11781. if (baseShift) {
  11782. base.style.position = "relative";
  11783. base.style.top = makeEm(baseShift);
  11784. }
  11785. return base;
  11786. }
  11787. };
  11788. var mathmlBuilder$1 = (group, options) => {
  11789. var node;
  11790. if (group.symbol) {
  11791. // This is a symbol. Just add the symbol.
  11792. node = new MathNode("mo", [makeText(group.name, group.mode)]);
  11793. if (noSuccessor.has(group.name)) {
  11794. node.setAttribute("largeop", "false");
  11795. }
  11796. } else if (group.body) {
  11797. // This is an operator with children. Add them.
  11798. node = new MathNode("mo", buildExpression(group.body, options));
  11799. } else {
  11800. // This is a text operator. Add all the characters from the
  11801. // operator's name.
  11802. node = new MathNode("mi", [new TextNode(group.name.slice(1))]);
  11803. // Append an <mo>&ApplyFunction;</mo>.
  11804. // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
  11805. var operator = new MathNode("mo", [makeText("\u2061", "text")]);
  11806. if (group.parentIsSupSub) {
  11807. node = new MathNode("mrow", [node, operator]);
  11808. } else {
  11809. node = newDocumentFragment([node, operator]);
  11810. }
  11811. }
  11812. return node;
  11813. };
  11814. var singleCharBigOps = {
  11815. "\u220F": "\\prod",
  11816. "\u2210": "\\coprod",
  11817. "\u2211": "\\sum",
  11818. "\u22c0": "\\bigwedge",
  11819. "\u22c1": "\\bigvee",
  11820. "\u22c2": "\\bigcap",
  11821. "\u22c3": "\\bigcup",
  11822. "\u2a00": "\\bigodot",
  11823. "\u2a01": "\\bigoplus",
  11824. "\u2a02": "\\bigotimes",
  11825. "\u2a04": "\\biguplus",
  11826. "\u2a06": "\\bigsqcup"
  11827. };
  11828. defineFunction({
  11829. type: "op",
  11830. 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"],
  11831. props: {
  11832. numArgs: 0
  11833. },
  11834. handler: (_ref, args) => {
  11835. var {
  11836. parser,
  11837. funcName
  11838. } = _ref;
  11839. var fName = funcName;
  11840. if (fName.length === 1) {
  11841. fName = singleCharBigOps[fName];
  11842. }
  11843. return {
  11844. type: "op",
  11845. mode: parser.mode,
  11846. limits: true,
  11847. parentIsSupSub: false,
  11848. symbol: true,
  11849. name: fName
  11850. };
  11851. },
  11852. htmlBuilder: htmlBuilder$2,
  11853. mathmlBuilder: mathmlBuilder$1
  11854. });
  11855. // Note: calling defineFunction with a type that's already been defined only
  11856. // works because the same htmlBuilder and mathmlBuilder are being used.
  11857. defineFunction({
  11858. type: "op",
  11859. names: ["\\mathop"],
  11860. props: {
  11861. numArgs: 1,
  11862. primitive: true
  11863. },
  11864. handler: (_ref2, args) => {
  11865. var {
  11866. parser
  11867. } = _ref2;
  11868. var body = args[0];
  11869. return {
  11870. type: "op",
  11871. mode: parser.mode,
  11872. limits: false,
  11873. parentIsSupSub: false,
  11874. symbol: false,
  11875. body: ordargument(body)
  11876. };
  11877. },
  11878. htmlBuilder: htmlBuilder$2,
  11879. mathmlBuilder: mathmlBuilder$1
  11880. });
  11881. // There are 2 flags for operators; whether they produce limits in
  11882. // displaystyle, and whether they are symbols and should grow in
  11883. // displaystyle. These four groups cover the four possible choices.
  11884. var singleCharIntegrals = {
  11885. "\u222b": "\\int",
  11886. "\u222c": "\\iint",
  11887. "\u222d": "\\iiint",
  11888. "\u222e": "\\oint",
  11889. "\u222f": "\\oiint",
  11890. "\u2230": "\\oiiint"
  11891. };
  11892. // No limits, not symbols
  11893. defineFunction({
  11894. type: "op",
  11895. 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"],
  11896. props: {
  11897. numArgs: 0
  11898. },
  11899. handler(_ref3) {
  11900. var {
  11901. parser,
  11902. funcName
  11903. } = _ref3;
  11904. return {
  11905. type: "op",
  11906. mode: parser.mode,
  11907. limits: false,
  11908. parentIsSupSub: false,
  11909. symbol: false,
  11910. name: funcName
  11911. };
  11912. },
  11913. htmlBuilder: htmlBuilder$2,
  11914. mathmlBuilder: mathmlBuilder$1
  11915. });
  11916. // Limits, not symbols
  11917. defineFunction({
  11918. type: "op",
  11919. names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"],
  11920. props: {
  11921. numArgs: 0
  11922. },
  11923. handler(_ref4) {
  11924. var {
  11925. parser,
  11926. funcName
  11927. } = _ref4;
  11928. return {
  11929. type: "op",
  11930. mode: parser.mode,
  11931. limits: true,
  11932. parentIsSupSub: false,
  11933. symbol: false,
  11934. name: funcName
  11935. };
  11936. },
  11937. htmlBuilder: htmlBuilder$2,
  11938. mathmlBuilder: mathmlBuilder$1
  11939. });
  11940. // No limits, symbols
  11941. defineFunction({
  11942. type: "op",
  11943. names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230"],
  11944. props: {
  11945. numArgs: 0,
  11946. allowedInArgument: true
  11947. },
  11948. handler(_ref5) {
  11949. var {
  11950. parser,
  11951. funcName
  11952. } = _ref5;
  11953. var fName = funcName;
  11954. if (fName.length === 1) {
  11955. fName = singleCharIntegrals[fName];
  11956. }
  11957. return {
  11958. type: "op",
  11959. mode: parser.mode,
  11960. limits: false,
  11961. parentIsSupSub: false,
  11962. symbol: true,
  11963. name: fName
  11964. };
  11965. },
  11966. htmlBuilder: htmlBuilder$2,
  11967. mathmlBuilder: mathmlBuilder$1
  11968. });
  11969. // NOTE: Unlike most `htmlBuilder`s, this one handles not only
  11970. // "operatorname", but also "supsub" since \operatorname* can
  11971. // affect super/subscripting.
  11972. var htmlBuilder$1 = (grp, options) => {
  11973. // Operators are handled in the TeXbook pg. 443-444, rule 13(a).
  11974. var supGroup;
  11975. var subGroup;
  11976. var hasLimits = false;
  11977. var group;
  11978. if (grp.type === "supsub") {
  11979. // If we have limits, supsub will pass us its group to handle. Pull
  11980. // out the superscript and subscript and set the group to the op in
  11981. // its base.
  11982. supGroup = grp.sup;
  11983. subGroup = grp.sub;
  11984. group = assertNodeType(grp.base, "operatorname");
  11985. hasLimits = true;
  11986. } else {
  11987. group = assertNodeType(grp, "operatorname");
  11988. }
  11989. var base;
  11990. if (group.body.length > 0) {
  11991. var body = group.body.map(child => {
  11992. var childText = "text" in child ? child.text : undefined;
  11993. if (typeof childText === "string") {
  11994. return {
  11995. type: "textord",
  11996. mode: child.mode,
  11997. text: childText
  11998. };
  11999. } else {
  12000. return child;
  12001. }
  12002. });
  12003. // Consolidate function names into symbol characters.
  12004. var expression = buildExpression$1(body, options.withFont("mathrm"), true);
  12005. for (var i = 0; i < expression.length; i++) {
  12006. var child = expression[i];
  12007. if (child instanceof SymbolNode) {
  12008. // Per amsopn package,
  12009. // change minus to hyphen and \ast to asterisk
  12010. child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
  12011. }
  12012. }
  12013. base = makeSpan(["mop"], expression, options);
  12014. } else {
  12015. base = makeSpan(["mop"], [], options);
  12016. }
  12017. if (hasLimits) {
  12018. return assembleSupSub(base, supGroup, subGroup, options, options.style, 0, 0);
  12019. } else {
  12020. return base;
  12021. }
  12022. };
  12023. var mathmlBuilder = (group, options) => {
  12024. // The steps taken here are similar to the html version.
  12025. var expression = buildExpression(group.body, options.withFont("mathrm"));
  12026. // Is expression a string or has it something like a fraction?
  12027. var isAllString = true; // default
  12028. for (var i = 0; i < expression.length; i++) {
  12029. var node = expression[i];
  12030. if (node instanceof SpaceNode) ; else if (node instanceof MathNode) {
  12031. switch (node.type) {
  12032. case "mi":
  12033. case "mn":
  12034. case "mspace":
  12035. case "mtext":
  12036. break;
  12037. // Do nothing yet.
  12038. case "mo":
  12039. {
  12040. var child = node.children[0];
  12041. if (node.children.length === 1 && child instanceof TextNode) {
  12042. child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
  12043. } else {
  12044. isAllString = false;
  12045. }
  12046. break;
  12047. }
  12048. default:
  12049. isAllString = false;
  12050. }
  12051. } else {
  12052. isAllString = false;
  12053. }
  12054. }
  12055. if (isAllString) {
  12056. // Write a single TextNode instead of multiple nested tags.
  12057. var word = expression.map(node => node.toText()).join("");
  12058. expression = [new TextNode(word)];
  12059. }
  12060. var identifier = new MathNode("mi", expression);
  12061. identifier.setAttribute("mathvariant", "normal");
  12062. // \u2061 is the same as &ApplyFunction;
  12063. // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp
  12064. var operator = new MathNode("mo", [makeText("\u2061", "text")]);
  12065. if (group.parentIsSupSub) {
  12066. return new MathNode("mrow", [identifier, operator]);
  12067. } else {
  12068. return newDocumentFragment([identifier, operator]);
  12069. }
  12070. };
  12071. // \operatorname
  12072. // amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@
  12073. defineFunction({
  12074. type: "operatorname",
  12075. names: ["\\operatorname@", "\\operatornamewithlimits"],
  12076. props: {
  12077. numArgs: 1
  12078. },
  12079. handler: (_ref, args) => {
  12080. var {
  12081. parser,
  12082. funcName
  12083. } = _ref;
  12084. var body = args[0];
  12085. return {
  12086. type: "operatorname",
  12087. mode: parser.mode,
  12088. body: ordargument(body),
  12089. alwaysHandleSupSub: funcName === "\\operatornamewithlimits",
  12090. limits: false,
  12091. parentIsSupSub: false
  12092. };
  12093. },
  12094. htmlBuilder: htmlBuilder$1,
  12095. mathmlBuilder
  12096. });
  12097. defineMacro("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@");
  12098. defineFunctionBuilders({
  12099. type: "ordgroup",
  12100. htmlBuilder(group, options) {
  12101. if (group.semisimple) {
  12102. return makeFragment(buildExpression$1(group.body, options, false));
  12103. }
  12104. return makeSpan(["mord"], buildExpression$1(group.body, options, true), options);
  12105. },
  12106. mathmlBuilder(group, options) {
  12107. return buildExpressionRow(group.body, options, true);
  12108. }
  12109. });
  12110. defineFunction({
  12111. type: "overline",
  12112. names: ["\\overline"],
  12113. props: {
  12114. numArgs: 1
  12115. },
  12116. handler(_ref, args) {
  12117. var {
  12118. parser
  12119. } = _ref;
  12120. var body = args[0];
  12121. return {
  12122. type: "overline",
  12123. mode: parser.mode,
  12124. body
  12125. };
  12126. },
  12127. htmlBuilder(group, options) {
  12128. // Overlines are handled in the TeXbook pg 443, Rule 9.
  12129. // Build the inner group in the cramped style.
  12130. var innerGroup = buildGroup$1(group.body, options.havingCrampedStyle());
  12131. // Create the line above the body
  12132. var line = makeLineSpan("overline-line", options);
  12133. // Generate the vlist, with the appropriate kerns
  12134. var defaultRuleThickness = options.fontMetrics().defaultRuleThickness;
  12135. var vlist = makeVList({
  12136. positionType: "firstBaseline",
  12137. children: [{
  12138. type: "elem",
  12139. elem: innerGroup
  12140. }, {
  12141. type: "kern",
  12142. size: 3 * defaultRuleThickness
  12143. }, {
  12144. type: "elem",
  12145. elem: line
  12146. }, {
  12147. type: "kern",
  12148. size: defaultRuleThickness
  12149. }]
  12150. });
  12151. return makeSpan(["mord", "overline"], [vlist], options);
  12152. },
  12153. mathmlBuilder(group, options) {
  12154. var operator = new MathNode("mo", [new TextNode("\u203e")]);
  12155. operator.setAttribute("stretchy", "true");
  12156. var node = new MathNode("mover", [buildGroup(group.body, options), operator]);
  12157. node.setAttribute("accent", "true");
  12158. return node;
  12159. }
  12160. });
  12161. defineFunction({
  12162. type: "phantom",
  12163. names: ["\\phantom"],
  12164. props: {
  12165. numArgs: 1,
  12166. allowedInText: true
  12167. },
  12168. handler: (_ref, args) => {
  12169. var {
  12170. parser
  12171. } = _ref;
  12172. var body = args[0];
  12173. return {
  12174. type: "phantom",
  12175. mode: parser.mode,
  12176. body: ordargument(body)
  12177. };
  12178. },
  12179. htmlBuilder: (group, options) => {
  12180. var elements = buildExpression$1(group.body, options.withPhantom(), false);
  12181. // \phantom isn't supposed to affect the elements it contains.
  12182. // See "color" for more details.
  12183. return makeFragment(elements);
  12184. },
  12185. mathmlBuilder: (group, options) => {
  12186. var inner = buildExpression(group.body, options);
  12187. return new MathNode("mphantom", inner);
  12188. }
  12189. });
  12190. defineMacro("\\hphantom", "\\smash{\\phantom{#1}}");
  12191. defineFunction({
  12192. type: "vphantom",
  12193. names: ["\\vphantom"],
  12194. props: {
  12195. numArgs: 1,
  12196. allowedInText: true
  12197. },
  12198. handler: (_ref2, args) => {
  12199. var {
  12200. parser
  12201. } = _ref2;
  12202. var body = args[0];
  12203. return {
  12204. type: "vphantom",
  12205. mode: parser.mode,
  12206. body
  12207. };
  12208. },
  12209. htmlBuilder: (group, options) => {
  12210. var inner = makeSpan(["inner"], [buildGroup$1(group.body, options.withPhantom())]);
  12211. var fix = makeSpan(["fix"], []);
  12212. return makeSpan(["mord", "rlap"], [inner, fix], options);
  12213. },
  12214. mathmlBuilder: (group, options) => {
  12215. var inner = buildExpression(ordargument(group.body), options);
  12216. var phantom = new MathNode("mphantom", inner);
  12217. var node = new MathNode("mpadded", [phantom]);
  12218. node.setAttribute("width", "0px");
  12219. return node;
  12220. }
  12221. });
  12222. // Box manipulation
  12223. defineFunction({
  12224. type: "raisebox",
  12225. names: ["\\raisebox"],
  12226. props: {
  12227. numArgs: 2,
  12228. argTypes: ["size", "hbox"],
  12229. allowedInText: true
  12230. },
  12231. handler(_ref, args) {
  12232. var {
  12233. parser
  12234. } = _ref;
  12235. var amount = assertNodeType(args[0], "size").value;
  12236. var body = args[1];
  12237. return {
  12238. type: "raisebox",
  12239. mode: parser.mode,
  12240. dy: amount,
  12241. body
  12242. };
  12243. },
  12244. htmlBuilder(group, options) {
  12245. var body = buildGroup$1(group.body, options);
  12246. var dy = calculateSize(group.dy, options);
  12247. return makeVList({
  12248. positionType: "shift",
  12249. positionData: -dy,
  12250. children: [{
  12251. type: "elem",
  12252. elem: body
  12253. }]
  12254. });
  12255. },
  12256. mathmlBuilder(group, options) {
  12257. var node = new MathNode("mpadded", [buildGroup(group.body, options)]);
  12258. var dy = group.dy.number + group.dy.unit;
  12259. node.setAttribute("voffset", dy);
  12260. return node;
  12261. }
  12262. });
  12263. defineFunction({
  12264. type: "internal",
  12265. names: ["\\relax"],
  12266. props: {
  12267. numArgs: 0,
  12268. allowedInText: true,
  12269. allowedInArgument: true
  12270. },
  12271. handler(_ref) {
  12272. var {
  12273. parser
  12274. } = _ref;
  12275. return {
  12276. type: "internal",
  12277. mode: parser.mode
  12278. };
  12279. }
  12280. });
  12281. defineFunction({
  12282. type: "rule",
  12283. names: ["\\rule"],
  12284. props: {
  12285. numArgs: 2,
  12286. numOptionalArgs: 1,
  12287. allowedInText: true,
  12288. allowedInMath: true,
  12289. argTypes: ["size", "size", "size"]
  12290. },
  12291. handler(_ref, args, optArgs) {
  12292. var {
  12293. parser
  12294. } = _ref;
  12295. var shift = optArgs[0];
  12296. var width = assertNodeType(args[0], "size");
  12297. var height = assertNodeType(args[1], "size");
  12298. return {
  12299. type: "rule",
  12300. mode: parser.mode,
  12301. shift: shift && assertNodeType(shift, "size").value,
  12302. width: width.value,
  12303. height: height.value
  12304. };
  12305. },
  12306. htmlBuilder(group, options) {
  12307. // Make an empty span for the rule
  12308. var rule = makeSpan(["mord", "rule"], [], options);
  12309. // Calculate the shift, width, and height of the rule, and account for units
  12310. var width = calculateSize(group.width, options);
  12311. var height = calculateSize(group.height, options);
  12312. var shift = group.shift ? calculateSize(group.shift, options) : 0;
  12313. // Style the rule to the right size
  12314. rule.style.borderRightWidth = makeEm(width);
  12315. rule.style.borderTopWidth = makeEm(height);
  12316. rule.style.bottom = makeEm(shift);
  12317. // Record the height and width
  12318. rule.width = width;
  12319. rule.height = height + shift;
  12320. rule.depth = -shift;
  12321. // Font size is the number large enough that the browser will
  12322. // reserve at least `absHeight` space above the baseline.
  12323. // The 1.125 factor was empirically determined
  12324. rule.maxFontSize = height * 1.125 * options.sizeMultiplier;
  12325. return rule;
  12326. },
  12327. mathmlBuilder(group, options) {
  12328. var width = calculateSize(group.width, options);
  12329. var height = calculateSize(group.height, options);
  12330. var shift = group.shift ? calculateSize(group.shift, options) : 0;
  12331. var color = options.color && options.getColor() || "black";
  12332. var rule = new MathNode("mspace");
  12333. rule.setAttribute("mathbackground", color);
  12334. rule.setAttribute("width", makeEm(width));
  12335. rule.setAttribute("height", makeEm(height));
  12336. var wrapper = new MathNode("mpadded", [rule]);
  12337. if (shift >= 0) {
  12338. wrapper.setAttribute("height", makeEm(shift));
  12339. } else {
  12340. wrapper.setAttribute("height", makeEm(shift));
  12341. wrapper.setAttribute("depth", makeEm(-shift));
  12342. }
  12343. wrapper.setAttribute("voffset", makeEm(shift));
  12344. return wrapper;
  12345. }
  12346. });
  12347. function sizingGroup(value, options, baseOptions) {
  12348. var inner = buildExpression$1(value, options, false);
  12349. var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier;
  12350. // Add size-resetting classes to the inner list and set maxFontSize
  12351. // manually. Handle nested size changes.
  12352. for (var i = 0; i < inner.length; i++) {
  12353. var pos = inner[i].classes.indexOf("sizing");
  12354. if (pos < 0) {
  12355. Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions));
  12356. } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) {
  12357. // This is a nested size change: e.g., inner[i] is the "b" in
  12358. // `\Huge a \small b`. Override the old size (the `reset-` class)
  12359. // but not the new size.
  12360. inner[i].classes[pos + 1] = "reset-size" + baseOptions.size;
  12361. }
  12362. inner[i].height *= multiplier;
  12363. inner[i].depth *= multiplier;
  12364. }
  12365. return makeFragment(inner);
  12366. }
  12367. var sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"];
  12368. var htmlBuilder = (group, options) => {
  12369. // Handle sizing operators like \Huge. Real TeX doesn't actually allow
  12370. // these functions inside of math expressions, so we do some special
  12371. // handling.
  12372. var newOptions = options.havingSize(group.size);
  12373. return sizingGroup(group.body, newOptions, options);
  12374. };
  12375. defineFunction({
  12376. type: "sizing",
  12377. names: sizeFuncs,
  12378. props: {
  12379. numArgs: 0,
  12380. allowedInText: true
  12381. },
  12382. handler: (_ref, args) => {
  12383. var {
  12384. breakOnTokenText,
  12385. funcName,
  12386. parser
  12387. } = _ref;
  12388. var body = parser.parseExpression(false, breakOnTokenText);
  12389. return {
  12390. type: "sizing",
  12391. mode: parser.mode,
  12392. // Figure out what size to use based on the list of functions above
  12393. size: sizeFuncs.indexOf(funcName) + 1,
  12394. body
  12395. };
  12396. },
  12397. htmlBuilder,
  12398. mathmlBuilder: (group, options) => {
  12399. var newOptions = options.havingSize(group.size);
  12400. var inner = buildExpression(group.body, newOptions);
  12401. var node = new MathNode("mstyle", inner);
  12402. // TODO(emily): This doesn't produce the correct size for nested size
  12403. // changes, because we don't keep state of what style we're currently
  12404. // in, so we can't reset the size to normal before changing it. Now
  12405. // that we're passing an options parameter we should be able to fix
  12406. // this.
  12407. node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier));
  12408. return node;
  12409. }
  12410. });
  12411. // smash, with optional [tb], as in AMS
  12412. defineFunction({
  12413. type: "smash",
  12414. names: ["\\smash"],
  12415. props: {
  12416. numArgs: 1,
  12417. numOptionalArgs: 1,
  12418. allowedInText: true
  12419. },
  12420. handler: (_ref, args, optArgs) => {
  12421. var {
  12422. parser
  12423. } = _ref;
  12424. var smashHeight = false;
  12425. var smashDepth = false;
  12426. var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup");
  12427. if (tbArg) {
  12428. // Optional [tb] argument is engaged.
  12429. // ref: amsmath: \renewcommand{\smash}[1][tb]{%
  12430. // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}%
  12431. var letter = "";
  12432. for (var i = 0; i < tbArg.body.length; ++i) {
  12433. var node = tbArg.body[i];
  12434. letter = assertSymbolNodeType(node).text;
  12435. if (letter === "t") {
  12436. smashHeight = true;
  12437. } else if (letter === "b") {
  12438. smashDepth = true;
  12439. } else {
  12440. smashHeight = false;
  12441. smashDepth = false;
  12442. break;
  12443. }
  12444. }
  12445. } else {
  12446. smashHeight = true;
  12447. smashDepth = true;
  12448. }
  12449. var body = args[0];
  12450. return {
  12451. type: "smash",
  12452. mode: parser.mode,
  12453. body,
  12454. smashHeight,
  12455. smashDepth
  12456. };
  12457. },
  12458. htmlBuilder: (group, options) => {
  12459. var node = makeSpan([], [buildGroup$1(group.body, options)]);
  12460. if (!group.smashHeight && !group.smashDepth) {
  12461. return node;
  12462. }
  12463. if (group.smashHeight) {
  12464. node.height = 0;
  12465. }
  12466. if (group.smashDepth) {
  12467. node.depth = 0;
  12468. }
  12469. if (group.smashHeight && group.smashDepth) {
  12470. // Symmetric \smash can stay in inline layout.
  12471. return makeSpan(["mord", "smash"], [node], options);
  12472. }
  12473. // In order to influence makeVList for asymmetric smashing, we have to
  12474. // reset the children.
  12475. if (node.children) {
  12476. for (var i = 0; i < node.children.length; i++) {
  12477. if (group.smashHeight) {
  12478. node.children[i].height = 0;
  12479. }
  12480. if (group.smashDepth) {
  12481. node.children[i].depth = 0;
  12482. }
  12483. }
  12484. }
  12485. // At this point, we've reset the TeX-like height and depth values.
  12486. // But the span still has an HTML line height.
  12487. // makeVList applies "display: table-cell", which prevents the browser
  12488. // from acting on that line height. So we'll call makeVList now.
  12489. var smashedNode = makeVList({
  12490. positionType: "firstBaseline",
  12491. children: [{
  12492. type: "elem",
  12493. elem: node
  12494. }]
  12495. });
  12496. // For spacing, TeX treats \smash as a math group (same spacing as ord).
  12497. return makeSpan(["mord"], [smashedNode], options);
  12498. },
  12499. mathmlBuilder: (group, options) => {
  12500. var node = new MathNode("mpadded", [buildGroup(group.body, options)]);
  12501. if (group.smashHeight) {
  12502. node.setAttribute("height", "0px");
  12503. }
  12504. if (group.smashDepth) {
  12505. node.setAttribute("depth", "0px");
  12506. }
  12507. return node;
  12508. }
  12509. });
  12510. defineFunction({
  12511. type: "sqrt",
  12512. names: ["\\sqrt"],
  12513. props: {
  12514. numArgs: 1,
  12515. numOptionalArgs: 1
  12516. },
  12517. handler(_ref, args, optArgs) {
  12518. var {
  12519. parser
  12520. } = _ref;
  12521. var index = optArgs[0];
  12522. var body = args[0];
  12523. return {
  12524. type: "sqrt",
  12525. mode: parser.mode,
  12526. body,
  12527. index
  12528. };
  12529. },
  12530. htmlBuilder(group, options) {
  12531. // Square roots are handled in the TeXbook pg. 443, Rule 11.
  12532. // First, we do the same steps as in overline to build the inner group
  12533. // and line
  12534. var inner = buildGroup$1(group.body, options.havingCrampedStyle());
  12535. if (inner.height === 0) {
  12536. // Render a small surd.
  12537. inner.height = options.fontMetrics().xHeight;
  12538. }
  12539. // Some groups can return document fragments. Handle those by wrapping
  12540. // them in a span.
  12541. inner = wrapFragment(inner, options);
  12542. // Calculate the minimum size for the \surd delimiter
  12543. var metrics = options.fontMetrics();
  12544. var theta = metrics.defaultRuleThickness;
  12545. var phi = theta;
  12546. if (options.style.id < Style$1.TEXT.id) {
  12547. phi = options.fontMetrics().xHeight;
  12548. }
  12549. // Calculate the clearance between the body and line
  12550. var lineClearance = theta + phi / 4;
  12551. var minDelimiterHeight = inner.height + inner.depth + lineClearance + theta;
  12552. // Create a sqrt SVG of the required minimum size
  12553. var {
  12554. span: img,
  12555. ruleWidth,
  12556. advanceWidth
  12557. } = makeSqrtImage(minDelimiterHeight, options);
  12558. var delimDepth = img.height - ruleWidth;
  12559. // Adjust the clearance based on the delimiter size
  12560. if (delimDepth > inner.height + inner.depth + lineClearance) {
  12561. lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2;
  12562. }
  12563. // Shift the sqrt image
  12564. var imgShift = img.height - inner.height - lineClearance - ruleWidth;
  12565. inner.style.paddingLeft = makeEm(advanceWidth);
  12566. // Overlay the image and the argument.
  12567. var body = makeVList({
  12568. positionType: "firstBaseline",
  12569. children: [{
  12570. type: "elem",
  12571. elem: inner,
  12572. wrapperClasses: ["svg-align"]
  12573. }, {
  12574. type: "kern",
  12575. size: -(inner.height + imgShift)
  12576. }, {
  12577. type: "elem",
  12578. elem: img
  12579. }, {
  12580. type: "kern",
  12581. size: ruleWidth
  12582. }]
  12583. });
  12584. if (!group.index) {
  12585. return makeSpan(["mord", "sqrt"], [body], options);
  12586. } else {
  12587. // Handle the optional root index
  12588. // The index is always in scriptscript style
  12589. var newOptions = options.havingStyle(Style$1.SCRIPTSCRIPT);
  12590. var rootm = buildGroup$1(group.index, newOptions, options);
  12591. // The amount the index is shifted by. This is taken from the TeX
  12592. // source, in the definition of `\r@@t`.
  12593. var toShift = 0.6 * (body.height - body.depth);
  12594. // Build a VList with the superscript shifted up correctly
  12595. var rootVList = makeVList({
  12596. positionType: "shift",
  12597. positionData: -toShift,
  12598. children: [{
  12599. type: "elem",
  12600. elem: rootm
  12601. }]
  12602. });
  12603. // Add a class surrounding it so we can add on the appropriate
  12604. // kerning
  12605. var rootVListWrap = makeSpan(["root"], [rootVList]);
  12606. return makeSpan(["mord", "sqrt"], [rootVListWrap, body], options);
  12607. }
  12608. },
  12609. mathmlBuilder(group, options) {
  12610. var {
  12611. body,
  12612. index
  12613. } = group;
  12614. return index ? new MathNode("mroot", [buildGroup(body, options), buildGroup(index, options)]) : new MathNode("msqrt", [buildGroup(body, options)]);
  12615. }
  12616. });
  12617. var styleMap = {
  12618. "display": Style$1.DISPLAY,
  12619. "text": Style$1.TEXT,
  12620. "script": Style$1.SCRIPT,
  12621. "scriptscript": Style$1.SCRIPTSCRIPT
  12622. };
  12623. defineFunction({
  12624. type: "styling",
  12625. names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"],
  12626. props: {
  12627. numArgs: 0,
  12628. allowedInText: true,
  12629. primitive: true
  12630. },
  12631. handler(_ref, args) {
  12632. var {
  12633. breakOnTokenText,
  12634. funcName,
  12635. parser
  12636. } = _ref;
  12637. // parse out the implicit body
  12638. var body = parser.parseExpression(true, breakOnTokenText);
  12639. // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g.
  12640. // here and in buildHTML and de-dupe the enumeration of all the styles).
  12641. // TODO(ts): The names above exactly match the styles.
  12642. var style = funcName.slice(1, funcName.length - 5);
  12643. return {
  12644. type: "styling",
  12645. mode: parser.mode,
  12646. // Figure out what style to use by pulling out the style from
  12647. // the function name
  12648. style,
  12649. body
  12650. };
  12651. },
  12652. htmlBuilder(group, options) {
  12653. // Style changes are handled in the TeXbook on pg. 442, Rule 3.
  12654. var newStyle = styleMap[group.style];
  12655. var newOptions = options.havingStyle(newStyle).withFont('');
  12656. return sizingGroup(group.body, newOptions, options);
  12657. },
  12658. mathmlBuilder(group, options) {
  12659. // Figure out what style we're changing to.
  12660. var newStyle = styleMap[group.style];
  12661. var newOptions = options.havingStyle(newStyle);
  12662. var inner = buildExpression(group.body, newOptions);
  12663. var node = new MathNode("mstyle", inner);
  12664. var styleAttributes = {
  12665. "display": ["0", "true"],
  12666. "text": ["0", "false"],
  12667. "script": ["1", "false"],
  12668. "scriptscript": ["2", "false"]
  12669. };
  12670. var attr = styleAttributes[group.style];
  12671. node.setAttribute("scriptlevel", attr[0]);
  12672. node.setAttribute("displaystyle", attr[1]);
  12673. return node;
  12674. }
  12675. });
  12676. /**
  12677. * Sometimes, groups perform special rules when they have superscripts or
  12678. * subscripts attached to them. This function lets the `supsub` group know that
  12679. * Sometimes, groups perform special rules when they have superscripts or
  12680. * its inner element should handle the superscripts and subscripts instead of
  12681. * handling them itself.
  12682. */
  12683. var htmlBuilderDelegate = function htmlBuilderDelegate(group, options) {
  12684. var base = group.base;
  12685. if (!base) {
  12686. return null;
  12687. } else if (base.type === "op") {
  12688. // Operators handle supsubs differently when they have limits
  12689. // (e.g. `\displaystyle\sum_2^3`)
  12690. var delegate = base.limits && (options.style.size === Style$1.DISPLAY.size || base.alwaysHandleSupSub);
  12691. return delegate ? htmlBuilder$2 : null;
  12692. } else if (base.type === "operatorname") {
  12693. var _delegate = base.alwaysHandleSupSub && (options.style.size === Style$1.DISPLAY.size || base.limits);
  12694. return _delegate ? htmlBuilder$1 : null;
  12695. } else if (base.type === "accent") {
  12696. return isCharacterBox(base.base) ? htmlBuilder$a : null;
  12697. } else if (base.type === "horizBrace") {
  12698. var isSup = !group.sub;
  12699. return isSup === base.isOver ? htmlBuilder$3 : null;
  12700. } else {
  12701. return null;
  12702. }
  12703. };
  12704. // Super scripts and subscripts, whose precise placement can depend on other
  12705. // functions that precede them.
  12706. defineFunctionBuilders({
  12707. type: "supsub",
  12708. htmlBuilder(group, options) {
  12709. // Superscript and subscripts are handled in the TeXbook on page
  12710. // 445-446, rules 18(a-f).
  12711. // Here is where we defer to the inner group if it should handle
  12712. // superscripts and subscripts itself.
  12713. var builderDelegate = htmlBuilderDelegate(group, options);
  12714. if (builderDelegate) {
  12715. return builderDelegate(group, options);
  12716. }
  12717. var {
  12718. base: valueBase,
  12719. sup: valueSup,
  12720. sub: valueSub
  12721. } = group;
  12722. var base = buildGroup$1(valueBase, options);
  12723. var supm;
  12724. var subm;
  12725. var metrics = options.fontMetrics();
  12726. // Rule 18a
  12727. var supShift = 0;
  12728. var subShift = 0;
  12729. var isCharBox = valueBase && isCharacterBox(valueBase);
  12730. if (valueSup) {
  12731. var newOptions = options.havingStyle(options.style.sup());
  12732. supm = buildGroup$1(valueSup, newOptions, options);
  12733. if (!isCharBox) {
  12734. supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier;
  12735. }
  12736. }
  12737. if (valueSub) {
  12738. var _newOptions = options.havingStyle(options.style.sub());
  12739. subm = buildGroup$1(valueSub, _newOptions, options);
  12740. if (!isCharBox) {
  12741. subShift = base.depth + _newOptions.fontMetrics().subDrop * _newOptions.sizeMultiplier / options.sizeMultiplier;
  12742. }
  12743. }
  12744. // Rule 18c
  12745. var minSupShift;
  12746. if (options.style === Style$1.DISPLAY) {
  12747. minSupShift = metrics.sup1;
  12748. } else if (options.style.cramped) {
  12749. minSupShift = metrics.sup3;
  12750. } else {
  12751. minSupShift = metrics.sup2;
  12752. }
  12753. // scriptspace is a font-size-independent size, so scale it
  12754. // appropriately for use as the marginRight.
  12755. var multiplier = options.sizeMultiplier;
  12756. var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier);
  12757. var marginLeft = null;
  12758. if (subm) {
  12759. // Subscripts shouldn't be shifted by the base's italic correction.
  12760. // Account for that by shifting the subscript back the appropriate
  12761. // amount. Note we only do this when the base is a single symbol.
  12762. var isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint");
  12763. if (base instanceof SymbolNode || isOiint) {
  12764. // @ts-ignore
  12765. marginLeft = makeEm(-base.italic);
  12766. }
  12767. }
  12768. var supsub;
  12769. if (supm && subm) {
  12770. supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight);
  12771. subShift = Math.max(subShift, metrics.sub2);
  12772. var ruleWidth = metrics.defaultRuleThickness;
  12773. // Rule 18e
  12774. var maxWidth = 4 * ruleWidth;
  12775. if (supShift - supm.depth - (subm.height - subShift) < maxWidth) {
  12776. subShift = maxWidth - (supShift - supm.depth) + subm.height;
  12777. var psi = 0.8 * metrics.xHeight - (supShift - supm.depth);
  12778. if (psi > 0) {
  12779. supShift += psi;
  12780. subShift -= psi;
  12781. }
  12782. }
  12783. var vlistElem = [{
  12784. type: "elem",
  12785. elem: subm,
  12786. shift: subShift,
  12787. marginRight,
  12788. marginLeft
  12789. }, {
  12790. type: "elem",
  12791. elem: supm,
  12792. shift: -supShift,
  12793. marginRight
  12794. }];
  12795. supsub = makeVList({
  12796. positionType: "individualShift",
  12797. children: vlistElem
  12798. });
  12799. } else if (subm) {
  12800. // Rule 18b
  12801. subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight);
  12802. var _vlistElem = [{
  12803. type: "elem",
  12804. elem: subm,
  12805. marginLeft,
  12806. marginRight
  12807. }];
  12808. supsub = makeVList({
  12809. positionType: "shift",
  12810. positionData: subShift,
  12811. children: _vlistElem
  12812. });
  12813. } else if (supm) {
  12814. // Rule 18c, d
  12815. supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight);
  12816. supsub = makeVList({
  12817. positionType: "shift",
  12818. positionData: -supShift,
  12819. children: [{
  12820. type: "elem",
  12821. elem: supm,
  12822. marginRight
  12823. }]
  12824. });
  12825. } else {
  12826. throw new Error("supsub must have either sup or sub.");
  12827. }
  12828. // Wrap the supsub vlist in a span.msupsub to reset text-align.
  12829. var mclass = getTypeOfDomTree(base, "right") || "mord";
  12830. return makeSpan([mclass], [base, makeSpan(["msupsub"], [supsub])], options);
  12831. },
  12832. mathmlBuilder(group, options) {
  12833. // Is the inner group a relevant horizontal brace?
  12834. var isBrace = false;
  12835. var isOver;
  12836. var isSup;
  12837. if (group.base && group.base.type === "horizBrace") {
  12838. isSup = !!group.sup;
  12839. if (isSup === group.base.isOver) {
  12840. isBrace = true;
  12841. isOver = group.base.isOver;
  12842. }
  12843. }
  12844. if (group.base && (group.base.type === "op" || group.base.type === "operatorname")) {
  12845. group.base.parentIsSupSub = true;
  12846. }
  12847. var children = [buildGroup(group.base, options)];
  12848. if (group.sub) {
  12849. children.push(buildGroup(group.sub, options));
  12850. }
  12851. if (group.sup) {
  12852. children.push(buildGroup(group.sup, options));
  12853. }
  12854. var nodeType;
  12855. if (isBrace) {
  12856. nodeType = isOver ? "mover" : "munder";
  12857. } else if (!group.sub) {
  12858. var base = group.base;
  12859. if (base && base.type === "op" && base.limits && (options.style === Style$1.DISPLAY || base.alwaysHandleSupSub)) {
  12860. nodeType = "mover";
  12861. } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === Style$1.DISPLAY)) {
  12862. nodeType = "mover";
  12863. } else {
  12864. nodeType = "msup";
  12865. }
  12866. } else if (!group.sup) {
  12867. var _base = group.base;
  12868. if (_base && _base.type === "op" && _base.limits && (options.style === Style$1.DISPLAY || _base.alwaysHandleSupSub)) {
  12869. nodeType = "munder";
  12870. } else if (_base && _base.type === "operatorname" && _base.alwaysHandleSupSub && (_base.limits || options.style === Style$1.DISPLAY)) {
  12871. nodeType = "munder";
  12872. } else {
  12873. nodeType = "msub";
  12874. }
  12875. } else {
  12876. var _base2 = group.base;
  12877. if (_base2 && _base2.type === "op" && _base2.limits && options.style === Style$1.DISPLAY) {
  12878. nodeType = "munderover";
  12879. } else if (_base2 && _base2.type === "operatorname" && _base2.alwaysHandleSupSub && (options.style === Style$1.DISPLAY || _base2.limits)) {
  12880. nodeType = "munderover";
  12881. } else {
  12882. nodeType = "msubsup";
  12883. }
  12884. }
  12885. return new MathNode(nodeType, children);
  12886. }
  12887. });
  12888. // Operator ParseNodes created in Parser.js from symbol Groups in src/symbols.js.
  12889. defineFunctionBuilders({
  12890. type: "atom",
  12891. htmlBuilder(group, options) {
  12892. return mathsym(group.text, group.mode, options, ["m" + group.family]);
  12893. },
  12894. mathmlBuilder(group, options) {
  12895. var node = new MathNode("mo", [makeText(group.text, group.mode)]);
  12896. if (group.family === "bin") {
  12897. var variant = getVariant(group, options);
  12898. if (variant === "bold-italic") {
  12899. node.setAttribute("mathvariant", variant);
  12900. }
  12901. } else if (group.family === "punct") {
  12902. node.setAttribute("separator", "true");
  12903. } else if (group.family === "open" || group.family === "close") {
  12904. // Delims built here should not stretch vertically.
  12905. // See delimsizing.js for stretchy delims.
  12906. node.setAttribute("stretchy", "false");
  12907. }
  12908. return node;
  12909. }
  12910. });
  12911. // "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in
  12912. // src/symbols.js.
  12913. var defaultVariant = {
  12914. "mi": "italic",
  12915. "mn": "normal",
  12916. "mtext": "normal"
  12917. };
  12918. defineFunctionBuilders({
  12919. type: "mathord",
  12920. htmlBuilder(group, options) {
  12921. return makeOrd(group, options, "mathord");
  12922. },
  12923. mathmlBuilder(group, options) {
  12924. var node = new MathNode("mi", [makeText(group.text, group.mode, options)]);
  12925. var variant = getVariant(group, options) || "italic";
  12926. if (variant !== defaultVariant[node.type]) {
  12927. node.setAttribute("mathvariant", variant);
  12928. }
  12929. return node;
  12930. }
  12931. });
  12932. defineFunctionBuilders({
  12933. type: "textord",
  12934. htmlBuilder(group, options) {
  12935. return makeOrd(group, options, "textord");
  12936. },
  12937. mathmlBuilder(group, options) {
  12938. var text = makeText(group.text, group.mode, options);
  12939. var variant = getVariant(group, options) || "normal";
  12940. var node;
  12941. if (group.mode === 'text') {
  12942. node = new MathNode("mtext", [text]);
  12943. } else if (/[0-9]/.test(group.text)) {
  12944. node = new MathNode("mn", [text]);
  12945. } else if (group.text === "\\prime") {
  12946. node = new MathNode("mo", [text]);
  12947. } else {
  12948. node = new MathNode("mi", [text]);
  12949. }
  12950. if (variant !== defaultVariant[node.type]) {
  12951. node.setAttribute("mathvariant", variant);
  12952. }
  12953. return node;
  12954. }
  12955. });
  12956. // A map of CSS-based spacing functions to their CSS class.
  12957. var cssSpace = {
  12958. "\\nobreak": "nobreak",
  12959. "\\allowbreak": "allowbreak"
  12960. };
  12961. // A lookup table to determine whether a spacing function/symbol should be
  12962. // treated like a regular space character. If a symbol or command is a key
  12963. // in this table, then it should be a regular space character. Furthermore,
  12964. // the associated value may have a `className` specifying an extra CSS class
  12965. // to add to the created `span`.
  12966. var regularSpace = {
  12967. " ": {},
  12968. "\\ ": {},
  12969. "~": {
  12970. className: "nobreak"
  12971. },
  12972. "\\space": {},
  12973. "\\nobreakspace": {
  12974. className: "nobreak"
  12975. }
  12976. };
  12977. // ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in
  12978. // src/symbols.js.
  12979. defineFunctionBuilders({
  12980. type: "spacing",
  12981. htmlBuilder(group, options) {
  12982. if (regularSpace.hasOwnProperty(group.text)) {
  12983. var className = regularSpace[group.text].className || "";
  12984. // Spaces are generated by adding an actual space. Each of these
  12985. // things has an entry in the symbols table, so these will be turned
  12986. // into appropriate outputs.
  12987. if (group.mode === "text") {
  12988. var ord = makeOrd(group, options, "textord");
  12989. ord.classes.push(className);
  12990. return ord;
  12991. } else {
  12992. return makeSpan(["mspace", className], [mathsym(group.text, group.mode, options)], options);
  12993. }
  12994. } else if (cssSpace.hasOwnProperty(group.text)) {
  12995. // Spaces based on just a CSS class.
  12996. return makeSpan(["mspace", cssSpace[group.text]], [], options);
  12997. } else {
  12998. throw new ParseError("Unknown type of space \"" + group.text + "\"");
  12999. }
  13000. },
  13001. mathmlBuilder(group, options) {
  13002. var node;
  13003. if (regularSpace.hasOwnProperty(group.text)) {
  13004. node = new MathNode("mtext", [new TextNode("\u00a0")]);
  13005. } else if (cssSpace.hasOwnProperty(group.text)) {
  13006. // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored
  13007. return new MathNode("mspace");
  13008. } else {
  13009. throw new ParseError("Unknown type of space \"" + group.text + "\"");
  13010. }
  13011. return node;
  13012. }
  13013. });
  13014. var pad = () => {
  13015. var padNode = new MathNode("mtd", []);
  13016. padNode.setAttribute("width", "50%");
  13017. return padNode;
  13018. };
  13019. defineFunctionBuilders({
  13020. type: "tag",
  13021. mathmlBuilder(group, options) {
  13022. var table = new MathNode("mtable", [new MathNode("mtr", [pad(), new MathNode("mtd", [buildExpressionRow(group.body, options)]), pad(), new MathNode("mtd", [buildExpressionRow(group.tag, options)])])]);
  13023. table.setAttribute("width", "100%");
  13024. return table;
  13025. // TODO: Left-aligned tags.
  13026. // Currently, the group and options passed here do not contain
  13027. // enough info to set tag alignment. `leqno` is in Settings but it is
  13028. // not passed to Options. On the HTML side, leqno is
  13029. // set by a CSS class applied in buildTree.js. That would have worked
  13030. // in MathML if browsers supported <mlabeledtr>. Since they don't, we
  13031. // need to rewrite the way this function is called.
  13032. }
  13033. });
  13034. // Non-mathy text, possibly in a font
  13035. var textFontFamilies = {
  13036. "\\text": undefined,
  13037. "\\textrm": "textrm",
  13038. "\\textsf": "textsf",
  13039. "\\texttt": "texttt",
  13040. "\\textnormal": "textrm"
  13041. };
  13042. var textFontWeights = {
  13043. "\\textbf": "textbf",
  13044. "\\textmd": "textmd"
  13045. };
  13046. var textFontShapes = {
  13047. "\\textit": "textit",
  13048. "\\textup": "textup"
  13049. };
  13050. var optionsWithFont = (group, options) => {
  13051. var font = group.font;
  13052. // Checks if the argument is a font family or a font style.
  13053. if (!font) {
  13054. return options;
  13055. } else if (textFontFamilies[font]) {
  13056. return options.withTextFontFamily(textFontFamilies[font]);
  13057. } else if (textFontWeights[font]) {
  13058. return options.withTextFontWeight(textFontWeights[font]);
  13059. } else if (font === "\\emph") {
  13060. return options.fontShape === "textit" ? options.withTextFontShape("textup") : options.withTextFontShape("textit");
  13061. }
  13062. return options.withTextFontShape(textFontShapes[font]);
  13063. };
  13064. defineFunction({
  13065. type: "text",
  13066. names: [
  13067. // Font families
  13068. "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal",
  13069. // Font weights
  13070. "\\textbf", "\\textmd",
  13071. // Font Shapes
  13072. "\\textit", "\\textup", "\\emph"],
  13073. props: {
  13074. numArgs: 1,
  13075. argTypes: ["text"],
  13076. allowedInArgument: true,
  13077. allowedInText: true
  13078. },
  13079. handler(_ref, args) {
  13080. var {
  13081. parser,
  13082. funcName
  13083. } = _ref;
  13084. var body = args[0];
  13085. return {
  13086. type: "text",
  13087. mode: parser.mode,
  13088. body: ordargument(body),
  13089. font: funcName
  13090. };
  13091. },
  13092. htmlBuilder(group, options) {
  13093. var newOptions = optionsWithFont(group, options);
  13094. var inner = buildExpression$1(group.body, newOptions, true);
  13095. return makeSpan(["mord", "text"], inner, newOptions);
  13096. },
  13097. mathmlBuilder(group, options) {
  13098. var newOptions = optionsWithFont(group, options);
  13099. return buildExpressionRow(group.body, newOptions);
  13100. }
  13101. });
  13102. defineFunction({
  13103. type: "underline",
  13104. names: ["\\underline"],
  13105. props: {
  13106. numArgs: 1,
  13107. allowedInText: true
  13108. },
  13109. handler(_ref, args) {
  13110. var {
  13111. parser
  13112. } = _ref;
  13113. return {
  13114. type: "underline",
  13115. mode: parser.mode,
  13116. body: args[0]
  13117. };
  13118. },
  13119. htmlBuilder(group, options) {
  13120. // Underlines are handled in the TeXbook pg 443, Rule 10.
  13121. // Build the inner group.
  13122. var innerGroup = buildGroup$1(group.body, options);
  13123. // Create the line to go below the body
  13124. var line = makeLineSpan("underline-line", options);
  13125. // Generate the vlist, with the appropriate kerns
  13126. var defaultRuleThickness = options.fontMetrics().defaultRuleThickness;
  13127. var vlist = makeVList({
  13128. positionType: "top",
  13129. positionData: innerGroup.height,
  13130. children: [{
  13131. type: "kern",
  13132. size: defaultRuleThickness
  13133. }, {
  13134. type: "elem",
  13135. elem: line
  13136. }, {
  13137. type: "kern",
  13138. size: 3 * defaultRuleThickness
  13139. }, {
  13140. type: "elem",
  13141. elem: innerGroup
  13142. }]
  13143. });
  13144. return makeSpan(["mord", "underline"], [vlist], options);
  13145. },
  13146. mathmlBuilder(group, options) {
  13147. var operator = new MathNode("mo", [new TextNode("\u203e")]);
  13148. operator.setAttribute("stretchy", "true");
  13149. var node = new MathNode("munder", [buildGroup(group.body, options), operator]);
  13150. node.setAttribute("accentunder", "true");
  13151. return node;
  13152. }
  13153. });
  13154. // \vcenter: Vertically center the argument group on the math axis.
  13155. defineFunction({
  13156. type: "vcenter",
  13157. names: ["\\vcenter"],
  13158. props: {
  13159. numArgs: 1,
  13160. argTypes: ["original"],
  13161. // In LaTeX, \vcenter can act only on a box.
  13162. allowedInText: false
  13163. },
  13164. handler(_ref, args) {
  13165. var {
  13166. parser
  13167. } = _ref;
  13168. return {
  13169. type: "vcenter",
  13170. mode: parser.mode,
  13171. body: args[0]
  13172. };
  13173. },
  13174. htmlBuilder(group, options) {
  13175. var body = buildGroup$1(group.body, options);
  13176. var axisHeight = options.fontMetrics().axisHeight;
  13177. var dy = 0.5 * (body.height - axisHeight - (body.depth + axisHeight));
  13178. return makeVList({
  13179. positionType: "shift",
  13180. positionData: dy,
  13181. children: [{
  13182. type: "elem",
  13183. elem: body
  13184. }]
  13185. });
  13186. },
  13187. mathmlBuilder(group, options) {
  13188. // There is no way to do this in MathML.
  13189. // Write a class as a breadcrumb in case some post-processor wants
  13190. // to perform a vcenter adjustment.
  13191. return new MathNode("mpadded", [buildGroup(group.body, options)], ["vcenter"]);
  13192. }
  13193. });
  13194. defineFunction({
  13195. type: "verb",
  13196. names: ["\\verb"],
  13197. props: {
  13198. numArgs: 0,
  13199. allowedInText: true
  13200. },
  13201. handler(context, args, optArgs) {
  13202. // \verb and \verb* are dealt with directly in Parser.js.
  13203. // If we end up here, it's because of a failure to match the two delimiters
  13204. // in the regex in Lexer.js. LaTeX raises the following error when \verb is
  13205. // terminated by end of line (or file).
  13206. throw new ParseError("\\verb ended by end of line instead of matching delimiter");
  13207. },
  13208. htmlBuilder(group, options) {
  13209. var text = makeVerb(group);
  13210. var body = [];
  13211. // \verb enters text mode and therefore is sized like \textstyle
  13212. var newOptions = options.havingStyle(options.style.text());
  13213. for (var i = 0; i < text.length; i++) {
  13214. var c = text[i];
  13215. if (c === '~') {
  13216. c = '\\textasciitilde';
  13217. }
  13218. body.push(makeSymbol(c, "Typewriter-Regular", group.mode, newOptions, ["mord", "texttt"]));
  13219. }
  13220. return makeSpan(["mord", "text"].concat(newOptions.sizingClasses(options)), tryCombineChars(body), newOptions);
  13221. },
  13222. mathmlBuilder(group, options) {
  13223. var text = new TextNode(makeVerb(group));
  13224. var node = new MathNode("mtext", [text]);
  13225. node.setAttribute("mathvariant", "monospace");
  13226. return node;
  13227. }
  13228. });
  13229. /**
  13230. * Converts verb group into body string.
  13231. *
  13232. * \verb* replaces each space with an open box \u2423
  13233. * \verb replaces each space with a no-break space \xA0
  13234. */
  13235. var makeVerb = group => group.body.replace(/ /g, group.star ? '\u2423' : '\xA0');
  13236. /** Include this to ensure that all functions are defined. */
  13237. var functions = _functions;
  13238. /**
  13239. * The Lexer class handles tokenizing the input in various ways. Since our
  13240. * parser expects us to be able to backtrack, the lexer allows lexing from any
  13241. * given starting point.
  13242. *
  13243. * Its main exposed function is the `lex` function, which takes a position to
  13244. * lex from and a type of token to lex. It defers to the appropriate `_innerLex`
  13245. * function.
  13246. *
  13247. * The various `_innerLex` functions perform the actual lexing of different
  13248. * kinds.
  13249. */
  13250. /* The following tokenRegex
  13251. * - matches typical whitespace (but not NBSP etc.) using its first group
  13252. * - does not match any control character \x00-\x1f except whitespace
  13253. * - does not match a bare backslash
  13254. * - matches any ASCII character except those just mentioned
  13255. * - does not match the BMP private use area \uE000-\uF8FF
  13256. * - does not match bare surrogate code units
  13257. * - matches any BMP character except for those just described
  13258. * - matches any valid Unicode surrogate pair
  13259. * - matches a backslash followed by one or more whitespace characters
  13260. * - matches a backslash followed by one or more letters then whitespace
  13261. * - matches a backslash followed by any BMP character
  13262. * Capturing groups:
  13263. * [1] regular whitespace
  13264. * [2] backslash followed by whitespace
  13265. * [3] anything else, which may include:
  13266. * [4] left character of \verb*
  13267. * [5] left character of \verb
  13268. * [6] backslash followed by word, excluding any trailing whitespace
  13269. * Just because the Lexer matches something doesn't mean it's valid input:
  13270. * If there is no matching function or symbol definition, the Parser will
  13271. * still reject the input.
  13272. */
  13273. var spaceRegexString = "[ \r\n\t]";
  13274. var controlWordRegexString = "\\\\[a-zA-Z@]+";
  13275. var controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]";
  13276. var controlWordWhitespaceRegexString = "(" + controlWordRegexString + ")" + spaceRegexString + "*";
  13277. var controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*";
  13278. var combiningDiacriticalMarkString = "[\u0300-\u036f]";
  13279. var combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$");
  13280. var tokenRegexString = "(" + spaceRegexString + "+)|" + (// whitespace
  13281. controlSpaceRegexString + "|") +
  13282. // \whitespace
  13283. "([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + (// single codepoint
  13284. combiningDiacriticalMarkString + "*") +
  13285. // ...plus accents
  13286. "|[\uD800-\uDBFF][\uDC00-\uDFFF]" + (// surrogate pair
  13287. combiningDiacriticalMarkString + "*") +
  13288. // ...plus accents
  13289. "|\\\\verb\\*([^]).*?\\4" +
  13290. // \verb*
  13291. "|\\\\verb([^*a-zA-Z]).*?\\5" + (// \verb unstarred
  13292. "|" + controlWordWhitespaceRegexString) + (// \macroName + spaces
  13293. "|" + controlSymbolRegexString + ")"); // \\, \', etc.
  13294. /** Main Lexer class */
  13295. class Lexer {
  13296. // Category codes. The lexer only supports comment characters (14) for now.
  13297. // MacroExpander additionally distinguishes active (13).
  13298. constructor(input, settings) {
  13299. // Separate accents from characters
  13300. this.input = input;
  13301. this.settings = settings;
  13302. this.tokenRegex = new RegExp(tokenRegexString, 'g');
  13303. this.catcodes = {
  13304. "%": 14,
  13305. // comment character
  13306. "~": 13 // active character
  13307. };
  13308. }
  13309. setCatcode(char, code) {
  13310. this.catcodes[char] = code;
  13311. }
  13312. /**
  13313. * This function lexes a single token.
  13314. */
  13315. lex() {
  13316. var input = this.input;
  13317. var pos = this.tokenRegex.lastIndex;
  13318. if (pos === input.length) {
  13319. return new Token("EOF", new SourceLocation(this, pos, pos));
  13320. }
  13321. var match = this.tokenRegex.exec(input);
  13322. if (match === null || match.index !== pos) {
  13323. throw new ParseError("Unexpected character: '" + input[pos] + "'", new Token(input[pos], new SourceLocation(this, pos, pos + 1)));
  13324. }
  13325. var text = match[6] || match[3] || (match[2] ? "\\ " : " ");
  13326. if (this.catcodes[text] === 14) {
  13327. // comment character
  13328. var nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex);
  13329. if (nlIndex === -1) {
  13330. this.tokenRegex.lastIndex = input.length; // EOF
  13331. this.settings.reportNonstrict("commentAtEnd", "% comment has no terminating newline; LaTeX would " + "fail because of commenting the end of math mode (e.g. $)");
  13332. } else {
  13333. this.tokenRegex.lastIndex = nlIndex + 1;
  13334. }
  13335. return this.lex();
  13336. }
  13337. return new Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex));
  13338. }
  13339. }
  13340. /**
  13341. * A `Namespace` refers to a space of nameable things like macros or lengths,
  13342. * which can be `set` either globally or local to a nested group, using an
  13343. * undo stack similar to how TeX implements this functionality.
  13344. * Performance-wise, `get` and local `set` take constant time, while global
  13345. * `set` takes time proportional to the depth of group nesting.
  13346. */
  13347. class Namespace {
  13348. /**
  13349. * Both arguments are optional. The first argument is an object of
  13350. * built-in mappings which never change. The second argument is an object
  13351. * of initial (global-level) mappings, which will constantly change
  13352. * according to any global/top-level `set`s done.
  13353. */
  13354. constructor(builtins, globalMacros) {
  13355. if (builtins === void 0) {
  13356. builtins = {};
  13357. }
  13358. if (globalMacros === void 0) {
  13359. globalMacros = {};
  13360. }
  13361. this.current = globalMacros;
  13362. this.builtins = builtins;
  13363. this.undefStack = [];
  13364. }
  13365. /**
  13366. * Start a new nested group, affecting future local `set`s.
  13367. */
  13368. beginGroup() {
  13369. this.undefStack.push({});
  13370. }
  13371. /**
  13372. * End current nested group, restoring values before the group began.
  13373. */
  13374. endGroup() {
  13375. if (this.undefStack.length === 0) {
  13376. throw new ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug");
  13377. }
  13378. var undefs = this.undefStack.pop();
  13379. for (var undef in undefs) {
  13380. if (undefs.hasOwnProperty(undef)) {
  13381. if (undefs[undef] == null) {
  13382. delete this.current[undef];
  13383. } else {
  13384. this.current[undef] = undefs[undef];
  13385. }
  13386. }
  13387. }
  13388. }
  13389. /**
  13390. * Ends all currently nested groups (if any), restoring values before the
  13391. * groups began. Useful in case of an error in the middle of parsing.
  13392. */
  13393. endGroups() {
  13394. while (this.undefStack.length > 0) {
  13395. this.endGroup();
  13396. }
  13397. }
  13398. /**
  13399. * Detect whether `name` has a definition. Equivalent to
  13400. * `get(name) != null`.
  13401. */
  13402. has(name) {
  13403. return this.current.hasOwnProperty(name) || this.builtins.hasOwnProperty(name);
  13404. }
  13405. /**
  13406. * Get the current value of a name, or `undefined` if there is no value.
  13407. *
  13408. * Note: Do not use `if (namespace.get(...))` to detect whether a macro
  13409. * is defined, as the definition may be the empty string which evaluates
  13410. * to `false` in JavaScript. Use `if (namespace.get(...) != null)` or
  13411. * `if (namespace.has(...))`.
  13412. */
  13413. get(name) {
  13414. if (this.current.hasOwnProperty(name)) {
  13415. return this.current[name];
  13416. } else {
  13417. return this.builtins[name];
  13418. }
  13419. }
  13420. /**
  13421. * Set the current value of a name, and optionally set it globally too.
  13422. * Local set() sets the current value and (when appropriate) adds an undo
  13423. * operation to the undo stack. Global set() may change the undo
  13424. * operation at every level, so takes time linear in their number.
  13425. * A value of undefined means to delete existing definitions.
  13426. */
  13427. set(name, value, global) {
  13428. if (global === void 0) {
  13429. global = false;
  13430. }
  13431. if (global) {
  13432. // Global set is equivalent to setting in all groups. Simulate this
  13433. // by destroying any undos currently scheduled for this name,
  13434. // and adding an undo with the *new* value (in case it later gets
  13435. // locally reset within this environment).
  13436. for (var i = 0; i < this.undefStack.length; i++) {
  13437. delete this.undefStack[i][name];
  13438. }
  13439. if (this.undefStack.length > 0) {
  13440. this.undefStack[this.undefStack.length - 1][name] = value;
  13441. }
  13442. } else {
  13443. // Undo this set at end of this group (possibly to `undefined`),
  13444. // unless an undo is already in place, in which case that older
  13445. // value is the correct one.
  13446. var top = this.undefStack[this.undefStack.length - 1];
  13447. if (top && !top.hasOwnProperty(name)) {
  13448. top[name] = this.current[name];
  13449. }
  13450. }
  13451. if (value == null) {
  13452. delete this.current[name];
  13453. } else {
  13454. this.current[name] = value;
  13455. }
  13456. }
  13457. }
  13458. /**
  13459. * Predefined macros for KaTeX.
  13460. * This can be used to define some commands in terms of others.
  13461. */
  13462. var macros = _macros;
  13463. //////////////////////////////////////////////////////////////////////
  13464. // macro tools
  13465. defineMacro("\\noexpand", function (context) {
  13466. // The expansion is the token itself; but that token is interpreted
  13467. // as if its meaning were ‘\relax’ if it is a control sequence that
  13468. // would ordinarily be expanded by TeX’s expansion rules.
  13469. var t = context.popToken();
  13470. if (context.isExpandable(t.text)) {
  13471. t.noexpand = true;
  13472. t.treatAsRelax = true;
  13473. }
  13474. return {
  13475. tokens: [t],
  13476. numArgs: 0
  13477. };
  13478. });
  13479. defineMacro("\\expandafter", function (context) {
  13480. // TeX first reads the token that comes immediately after \expandafter,
  13481. // without expanding it; let’s call this token t. Then TeX reads the
  13482. // token that comes after t (and possibly more tokens, if that token
  13483. // has an argument), replacing it by its expansion. Finally TeX puts
  13484. // t back in front of that expansion.
  13485. var t = context.popToken();
  13486. context.expandOnce(true); // expand only an expandable token
  13487. return {
  13488. tokens: [t],
  13489. numArgs: 0
  13490. };
  13491. });
  13492. // LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2
  13493. // TeX source: \long\def\@firstoftwo#1#2{#1}
  13494. defineMacro("\\@firstoftwo", function (context) {
  13495. var args = context.consumeArgs(2);
  13496. return {
  13497. tokens: args[0],
  13498. numArgs: 0
  13499. };
  13500. });
  13501. // LaTeX's \@secondoftwo{#1}{#2} expands to #2, skipping #1
  13502. // TeX source: \long\def\@secondoftwo#1#2{#2}
  13503. defineMacro("\\@secondoftwo", function (context) {
  13504. var args = context.consumeArgs(2);
  13505. return {
  13506. tokens: args[1],
  13507. numArgs: 0
  13508. };
  13509. });
  13510. // LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded)
  13511. // symbol that isn't a space, consuming any spaces but not consuming the
  13512. // first nonspace character. If that nonspace character matches #1, then
  13513. // the macro expands to #2; otherwise, it expands to #3.
  13514. defineMacro("\\@ifnextchar", function (context) {
  13515. var args = context.consumeArgs(3); // symbol, if, else
  13516. context.consumeSpaces();
  13517. var nextToken = context.future();
  13518. if (args[0].length === 1 && args[0][0].text === nextToken.text) {
  13519. return {
  13520. tokens: args[1],
  13521. numArgs: 0
  13522. };
  13523. } else {
  13524. return {
  13525. tokens: args[2],
  13526. numArgs: 0
  13527. };
  13528. }
  13529. });
  13530. // LaTeX's \@ifstar{#1}{#2} looks ahead to the next (unexpanded) symbol.
  13531. // If it is `*`, then it consumes the symbol, and the macro expands to #1;
  13532. // otherwise, the macro expands to #2 (without consuming the symbol).
  13533. // TeX source: \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}}
  13534. defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}");
  13535. // LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode
  13536. defineMacro("\\TextOrMath", function (context) {
  13537. var args = context.consumeArgs(2);
  13538. if (context.mode === 'text') {
  13539. return {
  13540. tokens: args[0],
  13541. numArgs: 0
  13542. };
  13543. } else {
  13544. return {
  13545. tokens: args[1],
  13546. numArgs: 0
  13547. };
  13548. }
  13549. });
  13550. // Lookup table for parsing numbers in base 8 through 16
  13551. var digitToNumber = {
  13552. "0": 0,
  13553. "1": 1,
  13554. "2": 2,
  13555. "3": 3,
  13556. "4": 4,
  13557. "5": 5,
  13558. "6": 6,
  13559. "7": 7,
  13560. "8": 8,
  13561. "9": 9,
  13562. "a": 10,
  13563. "A": 10,
  13564. "b": 11,
  13565. "B": 11,
  13566. "c": 12,
  13567. "C": 12,
  13568. "d": 13,
  13569. "D": 13,
  13570. "e": 14,
  13571. "E": 14,
  13572. "f": 15,
  13573. "F": 15
  13574. };
  13575. // TeX \char makes a literal character (catcode 12) using the following forms:
  13576. // (see The TeXBook, p. 43)
  13577. // \char123 -- decimal
  13578. // \char'123 -- octal
  13579. // \char"123 -- hex
  13580. // \char`x -- character that can be written (i.e. isn't active)
  13581. // \char`\x -- character that cannot be written (e.g. %)
  13582. // These all refer to characters from the font, so we turn them into special
  13583. // calls to a function \@char dealt with in the Parser.
  13584. defineMacro("\\char", function (context) {
  13585. var token = context.popToken();
  13586. var base;
  13587. var number = 0;
  13588. if (token.text === "'") {
  13589. base = 8;
  13590. token = context.popToken();
  13591. } else if (token.text === '"') {
  13592. base = 16;
  13593. token = context.popToken();
  13594. } else if (token.text === "`") {
  13595. token = context.popToken();
  13596. if (token.text[0] === "\\") {
  13597. number = token.text.charCodeAt(1);
  13598. } else if (token.text === "EOF") {
  13599. throw new ParseError("\\char` missing argument");
  13600. } else {
  13601. number = token.text.charCodeAt(0);
  13602. }
  13603. } else {
  13604. base = 10;
  13605. }
  13606. if (base) {
  13607. // Parse a number in the given base, starting with first `token`.
  13608. number = digitToNumber[token.text];
  13609. if (number == null || number >= base) {
  13610. throw new ParseError("Invalid base-" + base + " digit " + token.text);
  13611. }
  13612. var digit;
  13613. while ((digit = digitToNumber[context.future().text]) != null && digit < base) {
  13614. number *= base;
  13615. number += digit;
  13616. context.popToken();
  13617. }
  13618. }
  13619. return "\\@char{" + number + "}";
  13620. });
  13621. // \newcommand{\macro}[args]{definition}
  13622. // \renewcommand{\macro}[args]{definition}
  13623. // TODO: Optional arguments: \newcommand{\macro}[args][default]{definition}
  13624. var newcommand = (context, existsOK, nonexistsOK, skipIfExists) => {
  13625. var arg = context.consumeArg().tokens;
  13626. if (arg.length !== 1) {
  13627. throw new ParseError("\\newcommand's first argument must be a macro name");
  13628. }
  13629. var name = arg[0].text;
  13630. var exists = context.isDefined(name);
  13631. if (exists && !existsOK) {
  13632. throw new ParseError("\\newcommand{" + name + "} attempting to redefine " + (name + "; use \\renewcommand"));
  13633. }
  13634. if (!exists && !nonexistsOK) {
  13635. throw new ParseError("\\renewcommand{" + name + "} when command " + name + " " + "does not yet exist; use \\newcommand");
  13636. }
  13637. var numArgs = 0;
  13638. arg = context.consumeArg().tokens;
  13639. if (arg.length === 1 && arg[0].text === "[") {
  13640. var argText = '';
  13641. var token = context.expandNextToken();
  13642. while (token.text !== "]" && token.text !== "EOF") {
  13643. // TODO: Should properly expand arg, e.g., ignore {}s
  13644. argText += token.text;
  13645. token = context.expandNextToken();
  13646. }
  13647. if (!argText.match(/^\s*[0-9]+\s*$/)) {
  13648. throw new ParseError("Invalid number of arguments: " + argText);
  13649. }
  13650. numArgs = parseInt(argText);
  13651. arg = context.consumeArg().tokens;
  13652. }
  13653. if (!(exists && skipIfExists)) {
  13654. // Final arg is the expansion of the macro
  13655. context.macros.set(name, {
  13656. tokens: arg,
  13657. numArgs
  13658. });
  13659. }
  13660. return '';
  13661. };
  13662. defineMacro("\\newcommand", context => newcommand(context, false, true, false));
  13663. defineMacro("\\renewcommand", context => newcommand(context, true, false, false));
  13664. defineMacro("\\providecommand", context => newcommand(context, true, true, true));
  13665. // terminal (console) tools
  13666. defineMacro("\\message", context => {
  13667. var arg = context.consumeArgs(1)[0];
  13668. // eslint-disable-next-line no-console
  13669. console.log(arg.reverse().map(token => token.text).join(""));
  13670. return '';
  13671. });
  13672. defineMacro("\\errmessage", context => {
  13673. var arg = context.consumeArgs(1)[0];
  13674. // eslint-disable-next-line no-console
  13675. console.error(arg.reverse().map(token => token.text).join(""));
  13676. return '';
  13677. });
  13678. defineMacro("\\show", context => {
  13679. var tok = context.popToken();
  13680. var name = tok.text;
  13681. // eslint-disable-next-line no-console
  13682. console.log(tok, context.macros.get(name), functions[name], symbols.math[name], symbols.text[name]);
  13683. return '';
  13684. });
  13685. //////////////////////////////////////////////////////////////////////
  13686. // Grouping
  13687. // \let\bgroup={ \let\egroup=}
  13688. defineMacro("\\bgroup", "{");
  13689. defineMacro("\\egroup", "}");
  13690. // Symbols from latex.ltx:
  13691. // \def~{\nobreakspace{}}
  13692. // \def\lq{`}
  13693. // \def\rq{'}
  13694. // \def \aa {\r a}
  13695. // \def \AA {\r A}
  13696. defineMacro("~", "\\nobreakspace");
  13697. defineMacro("\\lq", "`");
  13698. defineMacro("\\rq", "'");
  13699. defineMacro("\\aa", "\\r a");
  13700. defineMacro("\\AA", "\\r A");
  13701. // Copyright (C) and registered (R) symbols. Use raw symbol in MathML.
  13702. // \DeclareTextCommandDefault{\textcopyright}{\textcircled{c}}
  13703. // \DeclareTextCommandDefault{\textregistered}{\textcircled{%
  13704. // \check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}}
  13705. // \DeclareRobustCommand{\copyright}{%
  13706. // \ifmmode{\nfss@text{\textcopyright}}\else\textcopyright\fi}
  13707. defineMacro("\\textcopyright", "\\html@mathml{\\textcircled{c}}{\\char`©}");
  13708. defineMacro("\\copyright", "\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}");
  13709. defineMacro("\\textregistered", "\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}");
  13710. // Characters omitted from Unicode range 1D400–1D7FF
  13711. defineMacro("\u212C", "\\mathscr{B}"); // script
  13712. defineMacro("\u2130", "\\mathscr{E}");
  13713. defineMacro("\u2131", "\\mathscr{F}");
  13714. defineMacro("\u210B", "\\mathscr{H}");
  13715. defineMacro("\u2110", "\\mathscr{I}");
  13716. defineMacro("\u2112", "\\mathscr{L}");
  13717. defineMacro("\u2133", "\\mathscr{M}");
  13718. defineMacro("\u211B", "\\mathscr{R}");
  13719. defineMacro("\u212D", "\\mathfrak{C}"); // Fraktur
  13720. defineMacro("\u210C", "\\mathfrak{H}");
  13721. defineMacro("\u2128", "\\mathfrak{Z}");
  13722. // Define \Bbbk with a macro that works in both HTML and MathML.
  13723. defineMacro("\\Bbbk", "\\Bbb{k}");
  13724. // \llap and \rlap render their contents in text mode
  13725. defineMacro("\\llap", "\\mathllap{\\textrm{#1}}");
  13726. defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}");
  13727. defineMacro("\\clap", "\\mathclap{\\textrm{#1}}");
  13728. // \mathstrut from the TeXbook, p 360
  13729. defineMacro("\\mathstrut", "\\vphantom{(}");
  13730. // \underbar from TeXbook p 353
  13731. defineMacro("\\underbar", "\\underline{\\text{#1}}");
  13732. // \not is defined by base/fontmath.ltx via
  13733. // \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36}
  13734. // It's thus treated like a \mathrel, but defined by a symbol that has zero
  13735. // width but extends to the right. We use \rlap to get that spacing.
  13736. // For MathML we write U+0338 here. buildMathML.js will then do the overlay.
  13737. defineMacro("\\not", "\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}" + "{\\char\"338}");
  13738. // Negated symbols from base/fontmath.ltx:
  13739. // \def\neq{\not=} \let\ne=\neq
  13740. // \DeclareRobustCommand
  13741. // \notin{\mathrel{\m@th\mathpalette\c@ncel\in}}
  13742. // \def\c@ncel#1#2{\m@th\ooalign{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}}
  13743. defineMacro("\\neq", "\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}");
  13744. defineMacro("\\ne", "\\neq");
  13745. defineMacro("\u2260", "\\neq");
  13746. defineMacro("\\notin", "\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}" + "{\\mathrel{\\char`∉}}");
  13747. defineMacro("\u2209", "\\notin");
  13748. // Unicode stacked relations
  13749. defineMacro("\u2258", "\\html@mathml{" + "\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}" + "}{\\mathrel{\\char`\u2258}}");
  13750. defineMacro("\u2259", "\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}");
  13751. defineMacro("\u225A", "\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}");
  13752. defineMacro("\u225B", "\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}" + "{\\mathrel{\\char`\u225B}}");
  13753. defineMacro("\u225D", "\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}" + "{\\mathrel{\\char`\u225D}}");
  13754. defineMacro("\u225E", "\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}" + "{\\mathrel{\\char`\u225E}}");
  13755. defineMacro("\u225F", "\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}");
  13756. // Misc Unicode
  13757. defineMacro("\u27C2", "\\perp");
  13758. defineMacro("\u203C", "\\mathclose{!\\mkern-0.8mu!}");
  13759. defineMacro("\u220C", "\\notni");
  13760. defineMacro("\u231C", "\\ulcorner");
  13761. defineMacro("\u231D", "\\urcorner");
  13762. defineMacro("\u231E", "\\llcorner");
  13763. defineMacro("\u231F", "\\lrcorner");
  13764. defineMacro("\u00A9", "\\copyright");
  13765. defineMacro("\u00AE", "\\textregistered");
  13766. // The KaTeX fonts have corners at codepoints that don't match Unicode.
  13767. // For MathML purposes, use the Unicode code point.
  13768. defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}");
  13769. defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}");
  13770. defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}");
  13771. defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}");
  13772. //////////////////////////////////////////////////////////////////////
  13773. // LaTeX_2ε
  13774. // \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@
  13775. // \kern6\p@\hbox{.}\hbox{.}\hbox{.}}}
  13776. // We'll call \varvdots, which gets a glyph from symbols.js.
  13777. // The zero-width rule gets us an equivalent to the vertical 6pt kern.
  13778. defineMacro("\\vdots", "{\\varvdots\\rule{0pt}{15pt}}");
  13779. defineMacro("\u22ee", "\\vdots");
  13780. //////////////////////////////////////////////////////////////////////
  13781. // amsmath.sty
  13782. // http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf
  13783. // Italic Greek capital letters. AMS defines these with \DeclareMathSymbol,
  13784. // but they are equivalent to \mathit{\Letter}.
  13785. defineMacro("\\varGamma", "\\mathit{\\Gamma}");
  13786. defineMacro("\\varDelta", "\\mathit{\\Delta}");
  13787. defineMacro("\\varTheta", "\\mathit{\\Theta}");
  13788. defineMacro("\\varLambda", "\\mathit{\\Lambda}");
  13789. defineMacro("\\varXi", "\\mathit{\\Xi}");
  13790. defineMacro("\\varPi", "\\mathit{\\Pi}");
  13791. defineMacro("\\varSigma", "\\mathit{\\Sigma}");
  13792. defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}");
  13793. defineMacro("\\varPhi", "\\mathit{\\Phi}");
  13794. defineMacro("\\varPsi", "\\mathit{\\Psi}");
  13795. defineMacro("\\varOmega", "\\mathit{\\Omega}");
  13796. //\newcommand{\substack}[1]{\subarray{c}#1\endsubarray}
  13797. defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}");
  13798. // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
  13799. // \mkern-\thinmuskip{:}\mskip6muplus1mu\relax}
  13800. defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax");
  13801. // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
  13802. defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}");
  13803. // \def\iff{\DOTSB\;\Longleftrightarrow\;}
  13804. // \def\implies{\DOTSB\;\Longrightarrow\;}
  13805. // \def\impliedby{\DOTSB\;\Longleftarrow\;}
  13806. defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;");
  13807. defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;");
  13808. defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;");
  13809. // \def\dddot#1{{\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@
  13810. // \hbox{\normalfont ...}\vss}}}}
  13811. // We use \overset which avoids the vertical shift of \mathop.
  13812. defineMacro("\\dddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}");
  13813. defineMacro("\\ddddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");
  13814. // AMSMath's automatic \dots, based on \mdots@@ macro.
  13815. var dotsByToken = {
  13816. ',': '\\dotsc',
  13817. '\\not': '\\dotsb',
  13818. // \keybin@ checks for the following:
  13819. '+': '\\dotsb',
  13820. '=': '\\dotsb',
  13821. '<': '\\dotsb',
  13822. '>': '\\dotsb',
  13823. '-': '\\dotsb',
  13824. '*': '\\dotsb',
  13825. ':': '\\dotsb',
  13826. // Symbols whose definition starts with \DOTSB:
  13827. '\\DOTSB': '\\dotsb',
  13828. '\\coprod': '\\dotsb',
  13829. '\\bigvee': '\\dotsb',
  13830. '\\bigwedge': '\\dotsb',
  13831. '\\biguplus': '\\dotsb',
  13832. '\\bigcap': '\\dotsb',
  13833. '\\bigcup': '\\dotsb',
  13834. '\\prod': '\\dotsb',
  13835. '\\sum': '\\dotsb',
  13836. '\\bigotimes': '\\dotsb',
  13837. '\\bigoplus': '\\dotsb',
  13838. '\\bigodot': '\\dotsb',
  13839. '\\bigsqcup': '\\dotsb',
  13840. '\\And': '\\dotsb',
  13841. '\\longrightarrow': '\\dotsb',
  13842. '\\Longrightarrow': '\\dotsb',
  13843. '\\longleftarrow': '\\dotsb',
  13844. '\\Longleftarrow': '\\dotsb',
  13845. '\\longleftrightarrow': '\\dotsb',
  13846. '\\Longleftrightarrow': '\\dotsb',
  13847. '\\mapsto': '\\dotsb',
  13848. '\\longmapsto': '\\dotsb',
  13849. '\\hookrightarrow': '\\dotsb',
  13850. '\\doteq': '\\dotsb',
  13851. // Symbols whose definition starts with \mathbin:
  13852. '\\mathbin': '\\dotsb',
  13853. // Symbols whose definition starts with \mathrel:
  13854. '\\mathrel': '\\dotsb',
  13855. '\\relbar': '\\dotsb',
  13856. '\\Relbar': '\\dotsb',
  13857. '\\xrightarrow': '\\dotsb',
  13858. '\\xleftarrow': '\\dotsb',
  13859. // Symbols whose definition starts with \DOTSI:
  13860. '\\DOTSI': '\\dotsi',
  13861. '\\int': '\\dotsi',
  13862. '\\oint': '\\dotsi',
  13863. '\\iint': '\\dotsi',
  13864. '\\iiint': '\\dotsi',
  13865. '\\iiiint': '\\dotsi',
  13866. '\\idotsint': '\\dotsi',
  13867. // Symbols whose definition starts with \DOTSX:
  13868. '\\DOTSX': '\\dotsx'
  13869. };
  13870. var dotsbGroups = new Set(['bin', 'rel']);
  13871. defineMacro("\\dots", function (context) {
  13872. // TODO: If used in text mode, should expand to \textellipsis.
  13873. // However, in KaTeX, \textellipsis and \ldots behave the same
  13874. // (in text mode), and it's unlikely we'd see any of the math commands
  13875. // that affect the behavior of \dots when in text mode. So fine for now
  13876. // (until we support \ifmmode ... \else ... \fi).
  13877. var thedots = '\\dotso';
  13878. var next = context.expandAfterFuture().text;
  13879. if (next in dotsByToken) {
  13880. thedots = dotsByToken[next];
  13881. } else if (next.slice(0, 4) === '\\not') {
  13882. thedots = '\\dotsb';
  13883. } else if (next in symbols.math) {
  13884. if (dotsbGroups.has(symbols.math[next].group)) {
  13885. thedots = '\\dotsb';
  13886. }
  13887. }
  13888. return thedots;
  13889. });
  13890. var spaceAfterDots = {
  13891. // \rightdelim@ checks for the following:
  13892. ')': true,
  13893. ']': true,
  13894. '\\rbrack': true,
  13895. '\\}': true,
  13896. '\\rbrace': true,
  13897. '\\rangle': true,
  13898. '\\rceil': true,
  13899. '\\rfloor': true,
  13900. '\\rgroup': true,
  13901. '\\rmoustache': true,
  13902. '\\right': true,
  13903. '\\bigr': true,
  13904. '\\biggr': true,
  13905. '\\Bigr': true,
  13906. '\\Biggr': true,
  13907. // \extra@ also tests for the following:
  13908. '$': true,
  13909. // \extrap@ checks for the following:
  13910. ';': true,
  13911. '.': true,
  13912. ',': true
  13913. };
  13914. defineMacro("\\dotso", function (context) {
  13915. var next = context.future().text;
  13916. if (next in spaceAfterDots) {
  13917. return "\\ldots\\,";
  13918. } else {
  13919. return "\\ldots";
  13920. }
  13921. });
  13922. defineMacro("\\dotsc", function (context) {
  13923. var next = context.future().text;
  13924. // \dotsc uses \extra@ but not \extrap@, instead specially checking for
  13925. // ';' and '.', but doesn't check for ','.
  13926. if (next in spaceAfterDots && next !== ',') {
  13927. return "\\ldots\\,";
  13928. } else {
  13929. return "\\ldots";
  13930. }
  13931. });
  13932. defineMacro("\\cdots", function (context) {
  13933. var next = context.future().text;
  13934. if (next in spaceAfterDots) {
  13935. return "\\@cdots\\,";
  13936. } else {
  13937. return "\\@cdots";
  13938. }
  13939. });
  13940. defineMacro("\\dotsb", "\\cdots");
  13941. defineMacro("\\dotsm", "\\cdots");
  13942. defineMacro("\\dotsi", "\\!\\cdots");
  13943. // amsmath doesn't actually define \dotsx, but \dots followed by a macro
  13944. // starting with \DOTSX implies \dotso, and then \extra@ detects this case
  13945. // and forces the added `\,`.
  13946. defineMacro("\\dotsx", "\\ldots\\,");
  13947. // \let\DOTSI\relax
  13948. // \let\DOTSB\relax
  13949. // \let\DOTSX\relax
  13950. defineMacro("\\DOTSI", "\\relax");
  13951. defineMacro("\\DOTSB", "\\relax");
  13952. defineMacro("\\DOTSX", "\\relax");
  13953. // Spacing, based on amsmath.sty's override of LaTeX defaults
  13954. // \DeclareRobustCommand{\tmspace}[3]{%
  13955. // \ifmmode\mskip#1#2\else\kern#1#3\fi\relax}
  13956. defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax");
  13957. // \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}}
  13958. // TODO: math mode should use \thinmuskip
  13959. defineMacro("\\,", "\\tmspace+{3mu}{.1667em}");
  13960. // \let\thinspace\,
  13961. defineMacro("\\thinspace", "\\,");
  13962. // \def\>{\mskip\medmuskip}
  13963. // \renewcommand{\:}{\tmspace+\medmuskip{.2222em}}
  13964. // TODO: \> and math mode of \: should use \medmuskip = 4mu plus 2mu minus 4mu
  13965. defineMacro("\\>", "\\mskip{4mu}");
  13966. defineMacro("\\:", "\\tmspace+{4mu}{.2222em}");
  13967. // \let\medspace\:
  13968. defineMacro("\\medspace", "\\:");
  13969. // \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}}
  13970. // TODO: math mode should use \thickmuskip = 5mu plus 5mu
  13971. defineMacro("\\;", "\\tmspace+{5mu}{.2777em}");
  13972. // \let\thickspace\;
  13973. defineMacro("\\thickspace", "\\;");
  13974. // \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}}
  13975. // TODO: math mode should use \thinmuskip
  13976. defineMacro("\\!", "\\tmspace-{3mu}{.1667em}");
  13977. // \let\negthinspace\!
  13978. defineMacro("\\negthinspace", "\\!");
  13979. // \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}}
  13980. // TODO: math mode should use \medmuskip
  13981. defineMacro("\\negmedspace", "\\tmspace-{4mu}{.2222em}");
  13982. // \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}}
  13983. // TODO: math mode should use \thickmuskip
  13984. defineMacro("\\negthickspace", "\\tmspace-{5mu}{.277em}");
  13985. // \def\enspace{\kern.5em }
  13986. defineMacro("\\enspace", "\\kern.5em ");
  13987. // \def\enskip{\hskip.5em\relax}
  13988. defineMacro("\\enskip", "\\hskip.5em\\relax");
  13989. // \def\quad{\hskip1em\relax}
  13990. defineMacro("\\quad", "\\hskip1em\\relax");
  13991. // \def\qquad{\hskip2em\relax}
  13992. defineMacro("\\qquad", "\\hskip2em\\relax");
  13993. // \tag@in@display form of \tag
  13994. defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren");
  13995. defineMacro("\\tag@paren", "\\tag@literal{({#1})}");
  13996. defineMacro("\\tag@literal", context => {
  13997. if (context.macros.get("\\df@tag")) {
  13998. throw new ParseError("Multiple \\tag");
  13999. }
  14000. return "\\gdef\\df@tag{\\text{#1}}";
  14001. });
  14002. // \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin
  14003. // {\operator@font mod}\penalty900
  14004. // \mkern5mu\nonscript\mskip-\medmuskip}
  14005. // \newcommand{\pod}[1]{\allowbreak
  14006. // \if@display\mkern18mu\else\mkern8mu\fi(#1)}
  14007. // \renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}}
  14008. // \newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu
  14009. // \else\mkern12mu\fi{\operator@font mod}\,\,#1}
  14010. // TODO: math mode should use \medmuskip = 4mu plus 2mu minus 4mu
  14011. defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + "\\mathbin{\\rm mod}" + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}");
  14012. defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");
  14013. defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}");
  14014. defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1");
  14015. //////////////////////////////////////////////////////////////////////
  14016. // LaTeX source2e
  14017. // \expandafter\let\expandafter\@normalcr
  14018. // \csname\expandafter\@gobble\string\\ \endcsname
  14019. // \DeclareRobustCommand\newline{\@normalcr\relax}
  14020. defineMacro("\\newline", "\\\\\\relax");
  14021. // \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@}
  14022. // TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't
  14023. // support \@ yet, so that's omitted, and we add \text so that the result
  14024. // doesn't look funny in math mode.
  14025. defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX" + "}{TeX}}");
  14026. // \DeclareRobustCommand{\LaTeX}{L\kern-.36em%
  14027. // {\sbox\z@ T%
  14028. // \vbox to\ht\z@{\hbox{\check@mathfonts
  14029. // \fontsize\sf@size\z@
  14030. // \math@fontsfalse\selectfont
  14031. // A}%
  14032. // \vss}%
  14033. // }%
  14034. // \kern-.15em%
  14035. // \TeX}
  14036. // This code aligns the top of the A with the T (from the perspective of TeX's
  14037. // boxes, though visually the A appears to extend above slightly).
  14038. // We compute the corresponding \raisebox when A is rendered in \normalsize
  14039. // \scriptstyle, which has a scale factor of 0.7 (see Options.js).
  14040. var latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]);
  14041. defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}");
  14042. // New KaTeX logo based on tweaking LaTeX logo
  14043. defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}");
  14044. // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
  14045. // \def\@hspace#1{\hskip #1\relax}
  14046. // \def\@hspacer#1{\vrule \@width\z@\nobreak
  14047. // \hskip #1\hskip \z@skip}
  14048. defineMacro("\\hspace", "\\@ifstar\\@hspacer\\@hspace");
  14049. defineMacro("\\@hspace", "\\hskip #1\\relax");
  14050. defineMacro("\\@hspacer", "\\rule{0pt}{0pt}\\hskip #1\\relax");
  14051. //////////////////////////////////////////////////////////////////////
  14052. // mathtools.sty
  14053. //\providecommand\ordinarycolon{:}
  14054. defineMacro("\\ordinarycolon", ":");
  14055. //\def\vcentcolon{\mathrel{\mathop\ordinarycolon}}
  14056. //TODO(edemaine): Not yet centered. Fix via \raisebox or #726
  14057. defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}");
  14058. // \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon}
  14059. defineMacro("\\dblcolon", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" + "{\\mathop{\\char\"2237}}");
  14060. // \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=}
  14061. defineMacro("\\coloneqq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2254}}"); // ≔
  14062. // \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=}
  14063. defineMacro("\\Coloneqq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2237\\char\"3d}}");
  14064. // \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
  14065. defineMacro("\\coloneq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"3a\\char\"2212}}");
  14066. // \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
  14067. defineMacro("\\Coloneq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"2237\\char\"2212}}");
  14068. // \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon}
  14069. defineMacro("\\eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2255}}"); // ≕
  14070. // \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon}
  14071. defineMacro("\\Eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"3d\\char\"2237}}");
  14072. // \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon}
  14073. defineMacro("\\eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2239}}");
  14074. // \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon}
  14075. defineMacro("\\Eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"2212\\char\"2237}}");
  14076. // \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx}
  14077. defineMacro("\\colonapprox", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"3a\\char\"2248}}");
  14078. // \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx}
  14079. defineMacro("\\Colonapprox", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"2237\\char\"2248}}");
  14080. // \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim}
  14081. defineMacro("\\colonsim", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"3a\\char\"223c}}");
  14082. // \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim}
  14083. defineMacro("\\Colonsim", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"2237\\char\"223c}}");
  14084. // Some Unicode characters are implemented with macros to mathtools functions.
  14085. defineMacro("\u2237", "\\dblcolon"); // ::
  14086. defineMacro("\u2239", "\\eqcolon"); // -:
  14087. defineMacro("\u2254", "\\coloneqq"); // :=
  14088. defineMacro("\u2255", "\\eqqcolon"); // =:
  14089. defineMacro("\u2A74", "\\Coloneqq"); // ::=
  14090. //////////////////////////////////////////////////////////////////////
  14091. // colonequals.sty
  14092. // Alternate names for mathtools's macros:
  14093. defineMacro("\\ratio", "\\vcentcolon");
  14094. defineMacro("\\coloncolon", "\\dblcolon");
  14095. defineMacro("\\colonequals", "\\coloneqq");
  14096. defineMacro("\\coloncolonequals", "\\Coloneqq");
  14097. defineMacro("\\equalscolon", "\\eqqcolon");
  14098. defineMacro("\\equalscoloncolon", "\\Eqqcolon");
  14099. defineMacro("\\colonminus", "\\coloneq");
  14100. defineMacro("\\coloncolonminus", "\\Coloneq");
  14101. defineMacro("\\minuscolon", "\\eqcolon");
  14102. defineMacro("\\minuscoloncolon", "\\Eqcolon");
  14103. // \colonapprox name is same in mathtools and colonequals.
  14104. defineMacro("\\coloncolonapprox", "\\Colonapprox");
  14105. // \colonsim name is same in mathtools and colonequals.
  14106. defineMacro("\\coloncolonsim", "\\Colonsim");
  14107. // Additional macros, implemented by analogy with mathtools definitions:
  14108. defineMacro("\\simcolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}");
  14109. defineMacro("\\simcoloncolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}");
  14110. defineMacro("\\approxcolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}");
  14111. defineMacro("\\approxcoloncolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}");
  14112. // Present in newtxmath, pxfonts and txfonts
  14113. defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}");
  14114. defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}");
  14115. defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}");
  14116. //////////////////////////////////////////////////////////////////////
  14117. // From amsopn.sty
  14118. defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}");
  14119. defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}");
  14120. defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}");
  14121. defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}");
  14122. defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}");
  14123. defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}");
  14124. //////////////////////////////////////////////////////////////////////
  14125. // MathML alternates for KaTeX glyphs in the Unicode private area
  14126. defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}");
  14127. defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}");
  14128. defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}");
  14129. defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}");
  14130. defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}");
  14131. defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}");
  14132. defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}");
  14133. defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}");
  14134. defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}");
  14135. defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}");
  14136. defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}");
  14137. defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}");
  14138. defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}");
  14139. defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}");
  14140. defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}");
  14141. defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}");
  14142. //////////////////////////////////////////////////////////////////////
  14143. // stmaryrd and semantic
  14144. // The stmaryrd and semantic packages render the next four items by calling a
  14145. // glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros.
  14146. defineMacro("\\llbracket", "\\html@mathml{" + "\\mathopen{[\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u27e6}}");
  14147. defineMacro("\\rrbracket", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu]}}" + "{\\mathclose{\\char`\u27e7}}");
  14148. defineMacro("\u27e6", "\\llbracket"); // blackboard bold [
  14149. defineMacro("\u27e7", "\\rrbracket"); // blackboard bold ]
  14150. defineMacro("\\lBrace", "\\html@mathml{" + "\\mathopen{\\{\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u2983}}");
  14151. defineMacro("\\rBrace", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu\\}}}" + "{\\mathclose{\\char`\u2984}}");
  14152. defineMacro("\u2983", "\\lBrace"); // blackboard bold {
  14153. defineMacro("\u2984", "\\rBrace"); // blackboard bold }
  14154. // TODO: Create variable sized versions of the last two items. I believe that
  14155. // will require new font glyphs.
  14156. // The stmaryrd function `\minuso` provides a "Plimsoll" symbol that
  14157. // superimposes the characters \circ and \mathminus. Used in chemistry.
  14158. defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + "{\\char`⦵}}");
  14159. defineMacro("⦵", "\\minuso");
  14160. //////////////////////////////////////////////////////////////////////
  14161. // texvc.sty
  14162. // The texvc package contains macros available in mediawiki pages.
  14163. // We omit the functions deprecated at
  14164. // https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax
  14165. // We also omit texvc's \O, which conflicts with \text{\O}
  14166. defineMacro("\\darr", "\\downarrow");
  14167. defineMacro("\\dArr", "\\Downarrow");
  14168. defineMacro("\\Darr", "\\Downarrow");
  14169. defineMacro("\\lang", "\\langle");
  14170. defineMacro("\\rang", "\\rangle");
  14171. defineMacro("\\uarr", "\\uparrow");
  14172. defineMacro("\\uArr", "\\Uparrow");
  14173. defineMacro("\\Uarr", "\\Uparrow");
  14174. defineMacro("\\N", "\\mathbb{N}");
  14175. defineMacro("\\R", "\\mathbb{R}");
  14176. defineMacro("\\Z", "\\mathbb{Z}");
  14177. defineMacro("\\alef", "\\aleph");
  14178. defineMacro("\\alefsym", "\\aleph");
  14179. defineMacro("\\Alpha", "\\mathrm{A}");
  14180. defineMacro("\\Beta", "\\mathrm{B}");
  14181. defineMacro("\\bull", "\\bullet");
  14182. defineMacro("\\Chi", "\\mathrm{X}");
  14183. defineMacro("\\clubs", "\\clubsuit");
  14184. defineMacro("\\cnums", "\\mathbb{C}");
  14185. defineMacro("\\Complex", "\\mathbb{C}");
  14186. defineMacro("\\Dagger", "\\ddagger");
  14187. defineMacro("\\diamonds", "\\diamondsuit");
  14188. defineMacro("\\empty", "\\emptyset");
  14189. defineMacro("\\Epsilon", "\\mathrm{E}");
  14190. defineMacro("\\Eta", "\\mathrm{H}");
  14191. defineMacro("\\exist", "\\exists");
  14192. defineMacro("\\harr", "\\leftrightarrow");
  14193. defineMacro("\\hArr", "\\Leftrightarrow");
  14194. defineMacro("\\Harr", "\\Leftrightarrow");
  14195. defineMacro("\\hearts", "\\heartsuit");
  14196. defineMacro("\\image", "\\Im");
  14197. defineMacro("\\infin", "\\infty");
  14198. defineMacro("\\Iota", "\\mathrm{I}");
  14199. defineMacro("\\isin", "\\in");
  14200. defineMacro("\\Kappa", "\\mathrm{K}");
  14201. defineMacro("\\larr", "\\leftarrow");
  14202. defineMacro("\\lArr", "\\Leftarrow");
  14203. defineMacro("\\Larr", "\\Leftarrow");
  14204. defineMacro("\\lrarr", "\\leftrightarrow");
  14205. defineMacro("\\lrArr", "\\Leftrightarrow");
  14206. defineMacro("\\Lrarr", "\\Leftrightarrow");
  14207. defineMacro("\\Mu", "\\mathrm{M}");
  14208. defineMacro("\\natnums", "\\mathbb{N}");
  14209. defineMacro("\\Nu", "\\mathrm{N}");
  14210. defineMacro("\\Omicron", "\\mathrm{O}");
  14211. defineMacro("\\plusmn", "\\pm");
  14212. defineMacro("\\rarr", "\\rightarrow");
  14213. defineMacro("\\rArr", "\\Rightarrow");
  14214. defineMacro("\\Rarr", "\\Rightarrow");
  14215. defineMacro("\\real", "\\Re");
  14216. defineMacro("\\reals", "\\mathbb{R}");
  14217. defineMacro("\\Reals", "\\mathbb{R}");
  14218. defineMacro("\\Rho", "\\mathrm{P}");
  14219. defineMacro("\\sdot", "\\cdot");
  14220. defineMacro("\\sect", "\\S");
  14221. defineMacro("\\spades", "\\spadesuit");
  14222. defineMacro("\\sub", "\\subset");
  14223. defineMacro("\\sube", "\\subseteq");
  14224. defineMacro("\\supe", "\\supseteq");
  14225. defineMacro("\\Tau", "\\mathrm{T}");
  14226. defineMacro("\\thetasym", "\\vartheta");
  14227. // TODO: defineMacro("\\varcoppa", "\\\mbox{\\coppa}");
  14228. defineMacro("\\weierp", "\\wp");
  14229. defineMacro("\\Zeta", "\\mathrm{Z}");
  14230. //////////////////////////////////////////////////////////////////////
  14231. // statmath.sty
  14232. // https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf
  14233. defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}");
  14234. defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}");
  14235. defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits");
  14236. //////////////////////////////////////////////////////////////////////
  14237. // braket.sty
  14238. // http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf
  14239. defineMacro("\\bra", "\\mathinner{\\langle{#1}|}");
  14240. defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}");
  14241. defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}");
  14242. defineMacro("\\Bra", "\\left\\langle#1\\right|");
  14243. defineMacro("\\Ket", "\\left|#1\\right\\rangle");
  14244. var braketHelper = one => context => {
  14245. var left = context.consumeArg().tokens;
  14246. var middle = context.consumeArg().tokens;
  14247. var middleDouble = context.consumeArg().tokens;
  14248. var right = context.consumeArg().tokens;
  14249. var oldMiddle = context.macros.get("|");
  14250. var oldMiddleDouble = context.macros.get("\\|");
  14251. context.macros.beginGroup();
  14252. var midMacro = double => context => {
  14253. if (one) {
  14254. // Only modify the first instance of | or \|
  14255. context.macros.set("|", oldMiddle);
  14256. if (middleDouble.length) {
  14257. context.macros.set("\\|", oldMiddleDouble);
  14258. }
  14259. }
  14260. var doubled = double;
  14261. if (!double && middleDouble.length) {
  14262. // Mimic \@ifnextchar
  14263. var nextToken = context.future();
  14264. if (nextToken.text === "|") {
  14265. context.popToken();
  14266. doubled = true;
  14267. }
  14268. }
  14269. return {
  14270. tokens: doubled ? middleDouble : middle,
  14271. numArgs: 0
  14272. };
  14273. };
  14274. context.macros.set("|", midMacro(false));
  14275. if (middleDouble.length) {
  14276. context.macros.set("\\|", midMacro(true));
  14277. }
  14278. var arg = context.consumeArg().tokens;
  14279. var expanded = context.expandTokens([...right, ...arg, ...left // reversed
  14280. ]);
  14281. context.macros.endGroup();
  14282. return {
  14283. tokens: expanded.reverse(),
  14284. numArgs: 0
  14285. };
  14286. };
  14287. defineMacro("\\bra@ket", braketHelper(false));
  14288. defineMacro("\\bra@set", braketHelper(true));
  14289. defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}");
  14290. defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}");
  14291. defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}");
  14292. // has no support for special || or \|
  14293. //////////////////////////////////////////////////////////////////////
  14294. // actuarialangle.dtx
  14295. defineMacro("\\angln", "{\\angl n}");
  14296. // Custom Khan Academy colors, should be moved to an optional package
  14297. defineMacro("\\blue", "\\textcolor{##6495ed}{#1}");
  14298. defineMacro("\\orange", "\\textcolor{##ffa500}{#1}");
  14299. defineMacro("\\pink", "\\textcolor{##ff00af}{#1}");
  14300. defineMacro("\\red", "\\textcolor{##df0030}{#1}");
  14301. defineMacro("\\green", "\\textcolor{##28ae7b}{#1}");
  14302. defineMacro("\\gray", "\\textcolor{gray}{#1}");
  14303. defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}");
  14304. defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}");
  14305. defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}");
  14306. defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}");
  14307. defineMacro("\\blueD", "\\textcolor{##11accd}{#1}");
  14308. defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}");
  14309. defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}");
  14310. defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}");
  14311. defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}");
  14312. defineMacro("\\tealD", "\\textcolor{##01a995}{#1}");
  14313. defineMacro("\\tealE", "\\textcolor{##208170}{#1}");
  14314. defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}");
  14315. defineMacro("\\greenB", "\\textcolor{##8af281}{#1}");
  14316. defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}");
  14317. defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}");
  14318. defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}");
  14319. defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}");
  14320. defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}");
  14321. defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}");
  14322. defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}");
  14323. defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}");
  14324. defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}");
  14325. defineMacro("\\redB", "\\textcolor{##ff8482}{#1}");
  14326. defineMacro("\\redC", "\\textcolor{##f9685d}{#1}");
  14327. defineMacro("\\redD", "\\textcolor{##e84d39}{#1}");
  14328. defineMacro("\\redE", "\\textcolor{##bc2612}{#1}");
  14329. defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}");
  14330. defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}");
  14331. defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}");
  14332. defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}");
  14333. defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}");
  14334. defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}");
  14335. defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}");
  14336. defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}");
  14337. defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}");
  14338. defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}");
  14339. defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}");
  14340. defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}");
  14341. defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}");
  14342. defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}");
  14343. defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}");
  14344. defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}");
  14345. defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}");
  14346. defineMacro("\\grayE", "\\textcolor{##babec2}{#1}");
  14347. defineMacro("\\grayF", "\\textcolor{##888d93}{#1}");
  14348. defineMacro("\\grayG", "\\textcolor{##626569}{#1}");
  14349. defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}");
  14350. defineMacro("\\grayI", "\\textcolor{##21242c}{#1}");
  14351. defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}");
  14352. defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}");
  14353. /**
  14354. * This file contains the “gullet” where macros are expanded
  14355. * until only non-macro tokens remain.
  14356. */
  14357. // List of commands that act like macros but aren't defined as a macro,
  14358. // function, or symbol. Used in `isDefined`.
  14359. var implicitCommands = {
  14360. "^": true,
  14361. // Parser.js
  14362. "_": true,
  14363. // Parser.js
  14364. "\\limits": true,
  14365. // Parser.js
  14366. "\\nolimits": true // Parser.js
  14367. };
  14368. class MacroExpander {
  14369. constructor(input, settings, mode) {
  14370. this.settings = settings;
  14371. this.expansionCount = 0;
  14372. this.feed(input);
  14373. // Make new global namespace
  14374. this.macros = new Namespace(macros, settings.macros);
  14375. this.mode = mode;
  14376. this.stack = []; // contains tokens in REVERSE order
  14377. }
  14378. /**
  14379. * Feed a new input string to the same MacroExpander
  14380. * (with existing macros etc.).
  14381. */
  14382. feed(input) {
  14383. this.lexer = new Lexer(input, this.settings);
  14384. }
  14385. /**
  14386. * Switches between "text" and "math" modes.
  14387. */
  14388. switchMode(newMode) {
  14389. this.mode = newMode;
  14390. }
  14391. /**
  14392. * Start a new group nesting within all namespaces.
  14393. */
  14394. beginGroup() {
  14395. this.macros.beginGroup();
  14396. }
  14397. /**
  14398. * End current group nesting within all namespaces.
  14399. */
  14400. endGroup() {
  14401. this.macros.endGroup();
  14402. }
  14403. /**
  14404. * Ends all currently nested groups (if any), restoring values before the
  14405. * groups began. Useful in case of an error in the middle of parsing.
  14406. */
  14407. endGroups() {
  14408. this.macros.endGroups();
  14409. }
  14410. /**
  14411. * Returns the topmost token on the stack, without expanding it.
  14412. * Similar in behavior to TeX's `\futurelet`.
  14413. */
  14414. future() {
  14415. if (this.stack.length === 0) {
  14416. this.pushToken(this.lexer.lex());
  14417. }
  14418. return this.stack[this.stack.length - 1];
  14419. }
  14420. /**
  14421. * Remove and return the next unexpanded token.
  14422. */
  14423. popToken() {
  14424. this.future(); // ensure non-empty stack
  14425. return this.stack.pop();
  14426. }
  14427. /**
  14428. * Add a given token to the token stack. In particular, this get be used
  14429. * to put back a token returned from one of the other methods.
  14430. */
  14431. pushToken(token) {
  14432. this.stack.push(token);
  14433. }
  14434. /**
  14435. * Append an array of tokens to the token stack.
  14436. */
  14437. pushTokens(tokens) {
  14438. this.stack.push(...tokens);
  14439. }
  14440. /**
  14441. * Find an macro argument without expanding tokens and append the array of
  14442. * tokens to the token stack. Uses Token as a container for the result.
  14443. */
  14444. scanArgument(isOptional) {
  14445. var start;
  14446. var end;
  14447. var tokens;
  14448. if (isOptional) {
  14449. this.consumeSpaces(); // \@ifnextchar gobbles any space following it
  14450. if (this.future().text !== "[") {
  14451. return null;
  14452. }
  14453. start = this.popToken(); // don't include [ in tokens
  14454. ({
  14455. tokens,
  14456. end
  14457. } = this.consumeArg(["]"]));
  14458. } else {
  14459. ({
  14460. tokens,
  14461. start,
  14462. end
  14463. } = this.consumeArg());
  14464. }
  14465. // indicate the end of an argument
  14466. this.pushToken(new Token("EOF", end.loc));
  14467. this.pushTokens(tokens);
  14468. return new Token("", SourceLocation.range(start, end));
  14469. }
  14470. /**
  14471. * Consume all following space tokens, without expansion.
  14472. */
  14473. consumeSpaces() {
  14474. for (;;) {
  14475. var token = this.future();
  14476. if (token.text === " ") {
  14477. this.stack.pop();
  14478. } else {
  14479. break;
  14480. }
  14481. }
  14482. }
  14483. /**
  14484. * Consume an argument from the token stream, and return the resulting array
  14485. * of tokens and start/end token.
  14486. */
  14487. consumeArg(delims) {
  14488. // The argument for a delimited parameter is the shortest (possibly
  14489. // empty) sequence of tokens with properly nested {...} groups that is
  14490. // followed ... by this particular list of non-parameter tokens.
  14491. // The argument for an undelimited parameter is the next nonblank
  14492. // token, unless that token is ‘{’, when the argument will be the
  14493. // entire {...} group that follows.
  14494. var tokens = [];
  14495. var isDelimited = delims && delims.length > 0;
  14496. if (!isDelimited) {
  14497. // Ignore spaces between arguments. As the TeXbook says:
  14498. // "After you have said ‘\def\row#1#2{...}’, you are allowed to
  14499. // put spaces between the arguments (e.g., ‘\row x n’), because
  14500. // TeX doesn’t use single spaces as undelimited arguments."
  14501. this.consumeSpaces();
  14502. }
  14503. var start = this.future();
  14504. var tok;
  14505. var depth = 0;
  14506. var match = 0;
  14507. do {
  14508. tok = this.popToken();
  14509. tokens.push(tok);
  14510. if (tok.text === "{") {
  14511. ++depth;
  14512. } else if (tok.text === "}") {
  14513. --depth;
  14514. if (depth === -1) {
  14515. throw new ParseError("Extra }", tok);
  14516. }
  14517. } else if (tok.text === "EOF") {
  14518. throw new ParseError("Unexpected end of input in a macro argument" + ", expected '" + (delims && isDelimited ? delims[match] : "}") + "'", tok);
  14519. }
  14520. if (delims && isDelimited) {
  14521. if ((depth === 0 || depth === 1 && delims[match] === "{") && tok.text === delims[match]) {
  14522. ++match;
  14523. if (match === delims.length) {
  14524. // don't include delims in tokens
  14525. tokens.splice(-match, match);
  14526. break;
  14527. }
  14528. } else {
  14529. match = 0;
  14530. }
  14531. }
  14532. } while (depth !== 0 || isDelimited);
  14533. // If the argument found ... has the form ‘{<nested tokens>}’,
  14534. // ... the outermost braces enclosing the argument are removed
  14535. if (start.text === "{" && tokens[tokens.length - 1].text === "}") {
  14536. tokens.pop();
  14537. tokens.shift();
  14538. }
  14539. tokens.reverse(); // to fit in with stack order
  14540. return {
  14541. tokens,
  14542. start,
  14543. end: tok
  14544. };
  14545. }
  14546. /**
  14547. * Consume the specified number of (delimited) arguments from the token
  14548. * stream and return the resulting array of arguments.
  14549. */
  14550. consumeArgs(numArgs, delimiters) {
  14551. if (delimiters) {
  14552. if (delimiters.length !== numArgs + 1) {
  14553. throw new ParseError("The length of delimiters doesn't match the number of args!");
  14554. }
  14555. var delims = delimiters[0];
  14556. for (var i = 0; i < delims.length; i++) {
  14557. var tok = this.popToken();
  14558. if (delims[i] !== tok.text) {
  14559. throw new ParseError("Use of the macro doesn't match its definition", tok);
  14560. }
  14561. }
  14562. }
  14563. var args = [];
  14564. for (var _i = 0; _i < numArgs; _i++) {
  14565. args.push(this.consumeArg(delimiters && delimiters[_i + 1]).tokens);
  14566. }
  14567. return args;
  14568. }
  14569. /**
  14570. * Increment `expansionCount` by the specified amount.
  14571. * Throw an error if it exceeds `maxExpand`.
  14572. */
  14573. countExpansion(amount) {
  14574. this.expansionCount += amount;
  14575. if (this.expansionCount > this.settings.maxExpand) {
  14576. throw new ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting");
  14577. }
  14578. }
  14579. /**
  14580. * Expand the next token only once if possible.
  14581. *
  14582. * If the token is expanded, the resulting tokens will be pushed onto
  14583. * the stack in reverse order, and the number of such tokens will be
  14584. * returned. This number might be zero or positive.
  14585. *
  14586. * If not, the return value is `false`, and the next token remains at the
  14587. * top of the stack.
  14588. *
  14589. * In either case, the next token will be on the top of the stack,
  14590. * or the stack will be empty (in case of empty expansion
  14591. * and no other tokens).
  14592. *
  14593. * Used to implement `expandAfterFuture` and `expandNextToken`.
  14594. *
  14595. * If expandableOnly, only expandable tokens are expanded and
  14596. * an undefined control sequence results in an error.
  14597. */
  14598. expandOnce(expandableOnly) {
  14599. var topToken = this.popToken();
  14600. var name = topToken.text;
  14601. var expansion = !topToken.noexpand ? this._getExpansion(name) : null;
  14602. if (expansion == null || expandableOnly && expansion.unexpandable) {
  14603. if (expandableOnly && expansion == null && name[0] === "\\" && !this.isDefined(name)) {
  14604. throw new ParseError("Undefined control sequence: " + name);
  14605. }
  14606. this.pushToken(topToken);
  14607. return false;
  14608. }
  14609. this.countExpansion(1);
  14610. var tokens = expansion.tokens;
  14611. var args = this.consumeArgs(expansion.numArgs, expansion.delimiters);
  14612. if (expansion.numArgs) {
  14613. // paste arguments in place of the placeholders
  14614. tokens = tokens.slice(); // make a shallow copy
  14615. for (var i = tokens.length - 1; i >= 0; --i) {
  14616. var tok = tokens[i];
  14617. if (tok.text === "#") {
  14618. if (i === 0) {
  14619. throw new ParseError("Incomplete placeholder at end of macro body", tok);
  14620. }
  14621. tok = tokens[--i]; // next token on stack
  14622. if (tok.text === "#") {
  14623. // ## → #
  14624. tokens.splice(i + 1, 1); // drop first #
  14625. } else if (/^[1-9]$/.test(tok.text)) {
  14626. // replace the placeholder with the indicated argument
  14627. tokens.splice(i, 2, ...args[+tok.text - 1]);
  14628. } else {
  14629. throw new ParseError("Not a valid argument number", tok);
  14630. }
  14631. }
  14632. }
  14633. }
  14634. // Concatenate expansion onto top of stack.
  14635. this.pushTokens(tokens);
  14636. return tokens.length;
  14637. }
  14638. /**
  14639. * Expand the next token only once (if possible), and return the resulting
  14640. * top token on the stack (without removing anything from the stack).
  14641. * Similar in behavior to TeX's `\expandafter\futurelet`.
  14642. * Equivalent to expandOnce() followed by future().
  14643. */
  14644. expandAfterFuture() {
  14645. this.expandOnce();
  14646. return this.future();
  14647. }
  14648. /**
  14649. * Recursively expand first token, then return first non-expandable token.
  14650. */
  14651. expandNextToken() {
  14652. for (;;) {
  14653. if (this.expandOnce() === false) {
  14654. // fully expanded
  14655. var token = this.stack.pop();
  14656. // the token after \noexpand is interpreted as if its meaning
  14657. // were ‘\relax’
  14658. if (token.treatAsRelax) {
  14659. token.text = "\\relax";
  14660. }
  14661. return token;
  14662. }
  14663. }
  14664. }
  14665. /**
  14666. * Fully expand the given macro name and return the resulting list of
  14667. * tokens, or return `undefined` if no such macro is defined.
  14668. */
  14669. expandMacro(name) {
  14670. return this.macros.has(name) ? this.expandTokens([new Token(name)]) : undefined;
  14671. }
  14672. /**
  14673. * Fully expand the given token stream and return the resulting list of
  14674. * tokens. Note that the input tokens are in reverse order, but the
  14675. * output tokens are in forward order.
  14676. */
  14677. expandTokens(tokens) {
  14678. var output = [];
  14679. var oldStackLength = this.stack.length;
  14680. this.pushTokens(tokens);
  14681. while (this.stack.length > oldStackLength) {
  14682. // Expand only expandable tokens
  14683. if (this.expandOnce(true) === false) {
  14684. // fully expanded
  14685. var token = this.stack.pop();
  14686. if (token.treatAsRelax) {
  14687. // the expansion of \noexpand is the token itself
  14688. token.noexpand = false;
  14689. token.treatAsRelax = false;
  14690. }
  14691. output.push(token);
  14692. }
  14693. }
  14694. // Count all of these tokens as additional expansions, to prevent
  14695. // exponential blowup from linearly many \edef's.
  14696. this.countExpansion(output.length);
  14697. return output;
  14698. }
  14699. /**
  14700. * Fully expand the given macro name and return the result as a string,
  14701. * or return `undefined` if no such macro is defined.
  14702. */
  14703. expandMacroAsText(name) {
  14704. var tokens = this.expandMacro(name);
  14705. if (tokens) {
  14706. return tokens.map(token => token.text).join("");
  14707. } else {
  14708. return tokens;
  14709. }
  14710. }
  14711. /**
  14712. * Returns the expanded macro as a reversed array of tokens and a macro
  14713. * argument count. Or returns `null` if no such macro.
  14714. */
  14715. _getExpansion(name) {
  14716. var definition = this.macros.get(name);
  14717. if (definition == null) {
  14718. // mainly checking for undefined here
  14719. return definition;
  14720. }
  14721. // If a single character has an associated catcode other than 13
  14722. // (active character), then don't expand it.
  14723. if (name.length === 1) {
  14724. var catcode = this.lexer.catcodes[name];
  14725. if (catcode != null && catcode !== 13) {
  14726. return;
  14727. }
  14728. }
  14729. var expansion = typeof definition === "function" ? definition(this) : definition;
  14730. if (typeof expansion === "string") {
  14731. var numArgs = 0;
  14732. if (expansion.includes("#")) {
  14733. var stripped = expansion.replace(/##/g, "");
  14734. while (stripped.includes("#" + (numArgs + 1))) {
  14735. ++numArgs;
  14736. }
  14737. }
  14738. var bodyLexer = new Lexer(expansion, this.settings);
  14739. var tokens = [];
  14740. var tok = bodyLexer.lex();
  14741. while (tok.text !== "EOF") {
  14742. tokens.push(tok);
  14743. tok = bodyLexer.lex();
  14744. }
  14745. tokens.reverse(); // to fit in with stack using push and pop
  14746. var expanded = {
  14747. tokens,
  14748. numArgs
  14749. };
  14750. return expanded;
  14751. }
  14752. return expansion;
  14753. }
  14754. /**
  14755. * Determine whether a command is currently "defined" (has some
  14756. * functionality), meaning that it's a macro (in the current group),
  14757. * a function, a symbol, or one of the special commands listed in
  14758. * `implicitCommands`.
  14759. */
  14760. isDefined(name) {
  14761. return this.macros.has(name) || functions.hasOwnProperty(name) || symbols.math.hasOwnProperty(name) || symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name);
  14762. }
  14763. /**
  14764. * Determine whether a command is expandable.
  14765. */
  14766. isExpandable(name) {
  14767. var macro = this.macros.get(name);
  14768. return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable : functions.hasOwnProperty(name) && !functions[name].primitive;
  14769. }
  14770. }
  14771. // Helpers for Parser.js handling of Unicode (sub|super)script characters.
  14772. var unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/;
  14773. var uSubsAndSups = Object.freeze({
  14774. '₊': '+',
  14775. '₋': '-',
  14776. '₌': '=',
  14777. '₍': '(',
  14778. '₎': ')',
  14779. '₀': '0',
  14780. '₁': '1',
  14781. '₂': '2',
  14782. '₃': '3',
  14783. '₄': '4',
  14784. '₅': '5',
  14785. '₆': '6',
  14786. '₇': '7',
  14787. '₈': '8',
  14788. '₉': '9',
  14789. '\u2090': 'a',
  14790. '\u2091': 'e',
  14791. '\u2095': 'h',
  14792. '\u1D62': 'i',
  14793. '\u2C7C': 'j',
  14794. '\u2096': 'k',
  14795. '\u2097': 'l',
  14796. '\u2098': 'm',
  14797. '\u2099': 'n',
  14798. '\u2092': 'o',
  14799. '\u209A': 'p',
  14800. '\u1D63': 'r',
  14801. '\u209B': 's',
  14802. '\u209C': 't',
  14803. '\u1D64': 'u',
  14804. '\u1D65': 'v',
  14805. '\u2093': 'x',
  14806. '\u1D66': 'β',
  14807. '\u1D67': 'γ',
  14808. '\u1D68': 'ρ',
  14809. '\u1D69': '\u03d5',
  14810. '\u1D6A': 'χ',
  14811. '⁺': '+',
  14812. '⁻': '-',
  14813. '⁼': '=',
  14814. '⁽': '(',
  14815. '⁾': ')',
  14816. '⁰': '0',
  14817. '¹': '1',
  14818. '²': '2',
  14819. '³': '3',
  14820. '⁴': '4',
  14821. '⁵': '5',
  14822. '⁶': '6',
  14823. '⁷': '7',
  14824. '⁸': '8',
  14825. '⁹': '9',
  14826. '\u1D2C': 'A',
  14827. '\u1D2E': 'B',
  14828. '\u1D30': 'D',
  14829. '\u1D31': 'E',
  14830. '\u1D33': 'G',
  14831. '\u1D34': 'H',
  14832. '\u1D35': 'I',
  14833. '\u1D36': 'J',
  14834. '\u1D37': 'K',
  14835. '\u1D38': 'L',
  14836. '\u1D39': 'M',
  14837. '\u1D3A': 'N',
  14838. '\u1D3C': 'O',
  14839. '\u1D3E': 'P',
  14840. '\u1D3F': 'R',
  14841. '\u1D40': 'T',
  14842. '\u1D41': 'U',
  14843. '\u2C7D': 'V',
  14844. '\u1D42': 'W',
  14845. '\u1D43': 'a',
  14846. '\u1D47': 'b',
  14847. '\u1D9C': 'c',
  14848. '\u1D48': 'd',
  14849. '\u1D49': 'e',
  14850. '\u1DA0': 'f',
  14851. '\u1D4D': 'g',
  14852. '\u02B0': 'h',
  14853. '\u2071': 'i',
  14854. '\u02B2': 'j',
  14855. '\u1D4F': 'k',
  14856. '\u02E1': 'l',
  14857. '\u1D50': 'm',
  14858. '\u207F': 'n',
  14859. '\u1D52': 'o',
  14860. '\u1D56': 'p',
  14861. '\u02B3': 'r',
  14862. '\u02E2': 's',
  14863. '\u1D57': 't',
  14864. '\u1D58': 'u',
  14865. '\u1D5B': 'v',
  14866. '\u02B7': 'w',
  14867. '\u02E3': 'x',
  14868. '\u02B8': 'y',
  14869. '\u1DBB': 'z',
  14870. '\u1D5D': 'β',
  14871. '\u1D5E': 'γ',
  14872. '\u1D5F': 'δ',
  14873. '\u1D60': '\u03d5',
  14874. '\u1D61': 'χ',
  14875. '\u1DBF': 'θ'
  14876. });
  14877. /* eslint no-constant-condition:0 */
  14878. // Pre-evaluate both modules as unicodeSymbols require String.normalize()
  14879. var unicodeAccents = {
  14880. "́": {
  14881. "text": "\\'",
  14882. "math": "\\acute"
  14883. },
  14884. "̀": {
  14885. "text": "\\`",
  14886. "math": "\\grave"
  14887. },
  14888. "̈": {
  14889. "text": "\\\"",
  14890. "math": "\\ddot"
  14891. },
  14892. "̃": {
  14893. "text": "\\~",
  14894. "math": "\\tilde"
  14895. },
  14896. "̄": {
  14897. "text": "\\=",
  14898. "math": "\\bar"
  14899. },
  14900. "̆": {
  14901. "text": "\\u",
  14902. "math": "\\breve"
  14903. },
  14904. "̌": {
  14905. "text": "\\v",
  14906. "math": "\\check"
  14907. },
  14908. "̂": {
  14909. "text": "\\^",
  14910. "math": "\\hat"
  14911. },
  14912. "̇": {
  14913. "text": "\\.",
  14914. "math": "\\dot"
  14915. },
  14916. "̊": {
  14917. "text": "\\r",
  14918. "math": "\\mathring"
  14919. },
  14920. "̋": {
  14921. "text": "\\H"
  14922. },
  14923. "̧": {
  14924. "text": "\\c"
  14925. }
  14926. };
  14927. var unicodeSymbols = {
  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. "Ȧ": "Ȧ",
  15101. "Ǡ": "Ǡ",
  15102. "Å": "Å",
  15103. "Ǻ": "Ǻ",
  15104. "Ḃ": "Ḃ",
  15105. "Ć": "Ć",
  15106. "Ḉ": "Ḉ",
  15107. "Č": "Č",
  15108. "Ĉ": "Ĉ",
  15109. "Ċ": "Ċ",
  15110. "Ç": "Ç",
  15111. "Ď": "Ď",
  15112. "Ḋ": "Ḋ",
  15113. "Ḑ": "Ḑ",
  15114. "É": "É",
  15115. "È": "È",
  15116. "Ë": "Ë",
  15117. "Ẽ": "Ẽ",
  15118. "Ē": "Ē",
  15119. "Ḗ": "Ḗ",
  15120. "Ḕ": "Ḕ",
  15121. "Ĕ": "Ĕ",
  15122. "Ḝ": "Ḝ",
  15123. "Ě": "Ě",
  15124. "Ê": "Ê",
  15125. "Ế": "Ế",
  15126. "Ề": "Ề",
  15127. "Ễ": "Ễ",
  15128. "Ė": "Ė",
  15129. "Ȩ": "Ȩ",
  15130. "Ḟ": "Ḟ",
  15131. "Ǵ": "Ǵ",
  15132. "Ḡ": "Ḡ",
  15133. "Ğ": "Ğ",
  15134. "Ǧ": "Ǧ",
  15135. "Ĝ": "Ĝ",
  15136. "Ġ": "Ġ",
  15137. "Ģ": "Ģ",
  15138. "Ḧ": "Ḧ",
  15139. "Ȟ": "Ȟ",
  15140. "Ĥ": "Ĥ",
  15141. "Ḣ": "Ḣ",
  15142. "Ḩ": "Ḩ",
  15143. "Í": "Í",
  15144. "Ì": "Ì",
  15145. "Ï": "Ï",
  15146. "Ḯ": "Ḯ",
  15147. "Ĩ": "Ĩ",
  15148. "Ī": "Ī",
  15149. "Ĭ": "Ĭ",
  15150. "Ǐ": "Ǐ",
  15151. "Î": "Î",
  15152. "İ": "İ",
  15153. "Ĵ": "Ĵ",
  15154. "Ḱ": "Ḱ",
  15155. "Ǩ": "Ǩ",
  15156. "Ķ": "Ķ",
  15157. "Ĺ": "Ĺ",
  15158. "Ľ": "Ľ",
  15159. "Ļ": "Ļ",
  15160. "Ḿ": "Ḿ",
  15161. "Ṁ": "Ṁ",
  15162. "Ń": "Ń",
  15163. "Ǹ": "Ǹ",
  15164. "Ñ": "Ñ",
  15165. "Ň": "Ň",
  15166. "Ṅ": "Ṅ",
  15167. "Ņ": "Ņ",
  15168. "Ó": "Ó",
  15169. "Ò": "Ò",
  15170. "Ö": "Ö",
  15171. "Ȫ": "Ȫ",
  15172. "Õ": "Õ",
  15173. "Ṍ": "Ṍ",
  15174. "Ṏ": "Ṏ",
  15175. "Ȭ": "Ȭ",
  15176. "Ō": "Ō",
  15177. "Ṓ": "Ṓ",
  15178. "Ṑ": "Ṑ",
  15179. "Ŏ": "Ŏ",
  15180. "Ǒ": "Ǒ",
  15181. "Ô": "Ô",
  15182. "Ố": "Ố",
  15183. "Ồ": "Ồ",
  15184. "Ỗ": "Ỗ",
  15185. "Ȯ": "Ȯ",
  15186. "Ȱ": "Ȱ",
  15187. "Ő": "Ő",
  15188. "Ṕ": "Ṕ",
  15189. "Ṗ": "Ṗ",
  15190. "Ŕ": "Ŕ",
  15191. "Ř": "Ř",
  15192. "Ṙ": "Ṙ",
  15193. "Ŗ": "Ŗ",
  15194. "Ś": "Ś",
  15195. "Ṥ": "Ṥ",
  15196. "Š": "Š",
  15197. "Ṧ": "Ṧ",
  15198. "Ŝ": "Ŝ",
  15199. "Ṡ": "Ṡ",
  15200. "Ş": "Ş",
  15201. "Ť": "Ť",
  15202. "Ṫ": "Ṫ",
  15203. "Ţ": "Ţ",
  15204. "Ú": "Ú",
  15205. "Ù": "Ù",
  15206. "Ü": "Ü",
  15207. "Ǘ": "Ǘ",
  15208. "Ǜ": "Ǜ",
  15209. "Ǖ": "Ǖ",
  15210. "Ǚ": "Ǚ",
  15211. "Ũ": "Ũ",
  15212. "Ṹ": "Ṹ",
  15213. "Ū": "Ū",
  15214. "Ṻ": "Ṻ",
  15215. "Ŭ": "Ŭ",
  15216. "Ǔ": "Ǔ",
  15217. "Û": "Û",
  15218. "Ů": "Ů",
  15219. "Ű": "Ű",
  15220. "Ṽ": "Ṽ",
  15221. "Ẃ": "Ẃ",
  15222. "Ẁ": "Ẁ",
  15223. "Ẅ": "Ẅ",
  15224. "Ŵ": "Ŵ",
  15225. "Ẇ": "Ẇ",
  15226. "Ẍ": "Ẍ",
  15227. "Ẋ": "Ẋ",
  15228. "Ý": "Ý",
  15229. "Ỳ": "Ỳ",
  15230. "Ÿ": "Ÿ",
  15231. "Ỹ": "Ỹ",
  15232. "Ȳ": "Ȳ",
  15233. "Ŷ": "Ŷ",
  15234. "Ẏ": "Ẏ",
  15235. "Ź": "Ź",
  15236. "Ž": "Ž",
  15237. "Ẑ": "Ẑ",
  15238. "Ż": "Ż",
  15239. "ά": "ά",
  15240. "ὰ": "ὰ",
  15241. "ᾱ": "ᾱ",
  15242. "ᾰ": "ᾰ",
  15243. "έ": "έ",
  15244. "ὲ": "ὲ",
  15245. "ή": "ή",
  15246. "ὴ": "ὴ",
  15247. "ί": "ί",
  15248. "ὶ": "ὶ",
  15249. "ϊ": "ϊ",
  15250. "ΐ": "ΐ",
  15251. "ῒ": "ῒ",
  15252. "ῑ": "ῑ",
  15253. "ῐ": "ῐ",
  15254. "ό": "ό",
  15255. "ὸ": "ὸ",
  15256. "ύ": "ύ",
  15257. "ὺ": "ὺ",
  15258. "ϋ": "ϋ",
  15259. "ΰ": "ΰ",
  15260. "ῢ": "ῢ",
  15261. "ῡ": "ῡ",
  15262. "ῠ": "ῠ",
  15263. "ώ": "ώ",
  15264. "ὼ": "ὼ",
  15265. "Ύ": "Ύ",
  15266. "Ὺ": "Ὺ",
  15267. "Ϋ": "Ϋ",
  15268. "Ῡ": "Ῡ",
  15269. "Ῠ": "Ῠ",
  15270. "Ώ": "Ώ",
  15271. "Ὼ": "Ὼ"
  15272. };
  15273. /**
  15274. * This file contains the parser used to parse out a TeX expression from the
  15275. * input. Since TeX isn't context-free, standard parsers don't work particularly
  15276. * well.
  15277. *
  15278. * The strategy of this parser is as such:
  15279. *
  15280. * The main functions (the `.parse...` ones) take a position in the current
  15281. * parse string to parse tokens from. The lexer (found in Lexer.js, stored at
  15282. * this.gullet.lexer) also supports pulling out tokens at arbitrary places. When
  15283. * individual tokens are needed at a position, the lexer is called to pull out a
  15284. * token, which is then used.
  15285. *
  15286. * The parser has a property called "mode" indicating the mode that
  15287. * the parser is currently in. Currently it has to be one of "math" or
  15288. * "text", which denotes whether the current environment is a math-y
  15289. * one or a text-y one (e.g. inside \text). Currently, this serves to
  15290. * limit the functions which can be used in text mode.
  15291. *
  15292. * The main functions then return an object which contains the useful data that
  15293. * was parsed at its given point, and a new position at the end of the parsed
  15294. * data. The main functions can call each other and continue the parsing by
  15295. * using the returned position as a new starting point.
  15296. *
  15297. * There are also extra `.handle...` functions, which pull out some reused
  15298. * functionality into self-contained functions.
  15299. *
  15300. * The functions return ParseNodes.
  15301. */
  15302. class Parser {
  15303. constructor(input, settings) {
  15304. // Start in math mode
  15305. this.mode = "math";
  15306. // Create a new macro expander (gullet) and (indirectly via that) also a
  15307. // new lexer (mouth) for this parser (stomach, in the language of TeX)
  15308. this.gullet = new MacroExpander(input, settings, this.mode);
  15309. // Store the settings for use in parsing
  15310. this.settings = settings;
  15311. // Count leftright depth (for \middle errors)
  15312. this.leftrightDepth = 0;
  15313. this.nextToken = null;
  15314. }
  15315. /**
  15316. * Checks a result to make sure it has the right type, and throws an
  15317. * appropriate error otherwise.
  15318. */
  15319. expect(text, consume) {
  15320. if (consume === void 0) {
  15321. consume = true;
  15322. }
  15323. if (this.fetch().text !== text) {
  15324. throw new ParseError("Expected '" + text + "', got '" + this.fetch().text + "'", this.fetch());
  15325. }
  15326. if (consume) {
  15327. this.consume();
  15328. }
  15329. }
  15330. /**
  15331. * Discards the current lookahead token, considering it consumed.
  15332. */
  15333. consume() {
  15334. this.nextToken = null;
  15335. }
  15336. /**
  15337. * Return the current lookahead token, or if there isn't one (at the
  15338. * beginning, or if the previous lookahead token was consume()d),
  15339. * fetch the next token as the new lookahead token and return it.
  15340. */
  15341. fetch() {
  15342. if (this.nextToken == null) {
  15343. this.nextToken = this.gullet.expandNextToken();
  15344. }
  15345. return this.nextToken;
  15346. }
  15347. /**
  15348. * Switches between "text" and "math" modes.
  15349. */
  15350. switchMode(newMode) {
  15351. this.mode = newMode;
  15352. this.gullet.switchMode(newMode);
  15353. }
  15354. /**
  15355. * Main parsing function, which parses an entire input.
  15356. */
  15357. parse() {
  15358. if (!this.settings.globalGroup) {
  15359. // Create a group namespace for the math expression.
  15360. // (LaTeX creates a new group for every $...$, $$...$$, \[...\].)
  15361. this.gullet.beginGroup();
  15362. }
  15363. // Use old \color behavior (same as LaTeX's \textcolor) if requested.
  15364. // We do this within the group for the math expression, so it doesn't
  15365. // pollute settings.macros.
  15366. if (this.settings.colorIsTextColor) {
  15367. this.gullet.macros.set("\\color", "\\textcolor");
  15368. }
  15369. try {
  15370. // Try to parse the input
  15371. var parse = this.parseExpression(false);
  15372. // If we succeeded, make sure there's an EOF at the end
  15373. this.expect("EOF");
  15374. // End the group namespace for the expression
  15375. if (!this.settings.globalGroup) {
  15376. this.gullet.endGroup();
  15377. }
  15378. return parse;
  15379. // Close any leftover groups in case of a parse error.
  15380. } finally {
  15381. this.gullet.endGroups();
  15382. }
  15383. }
  15384. /**
  15385. * Fully parse a separate sequence of tokens as a separate job.
  15386. * Tokens should be specified in reverse order, as in a MacroDefinition.
  15387. */
  15388. subparse(tokens) {
  15389. // Save the next token from the current job.
  15390. var oldToken = this.nextToken;
  15391. this.consume();
  15392. // Run the new job, terminating it with an excess '}'
  15393. this.gullet.pushToken(new Token("}"));
  15394. this.gullet.pushTokens(tokens);
  15395. var parse = this.parseExpression(false);
  15396. this.expect("}");
  15397. // Restore the next token from the current job.
  15398. this.nextToken = oldToken;
  15399. return parse;
  15400. }
  15401. /**
  15402. * Parses an "expression", which is a list of atoms.
  15403. *
  15404. * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This
  15405. * happens when functions have higher precedence than infix
  15406. * nodes in implicit parses.
  15407. *
  15408. * `breakOnTokenText`: The text of the token that the expression should end
  15409. * with, or `null` if something else should end the
  15410. * expression.
  15411. */
  15412. parseExpression(breakOnInfix, breakOnTokenText) {
  15413. var body = [];
  15414. // Keep adding atoms to the body until we can't parse any more atoms (either
  15415. // we reached the end, a }, or a \right)
  15416. while (true) {
  15417. // Ignore spaces in math mode
  15418. if (this.mode === "math") {
  15419. this.consumeSpaces();
  15420. }
  15421. var lex = this.fetch();
  15422. if (Parser.endOfExpression.has(lex.text)) {
  15423. break;
  15424. }
  15425. if (breakOnTokenText && lex.text === breakOnTokenText) {
  15426. break;
  15427. }
  15428. if (breakOnInfix && functions[lex.text] && functions[lex.text].infix) {
  15429. break;
  15430. }
  15431. var atom = this.parseAtom(breakOnTokenText);
  15432. if (!atom) {
  15433. break;
  15434. } else if (atom.type === "internal") {
  15435. // Internal nodes do not appear in parse tree
  15436. continue;
  15437. }
  15438. body.push(atom);
  15439. }
  15440. if (this.mode === "text") {
  15441. this.formLigatures(body);
  15442. }
  15443. return this.handleInfixNodes(body);
  15444. }
  15445. /**
  15446. * Rewrites infix operators such as \over with corresponding commands such
  15447. * as \frac.
  15448. *
  15449. * There can only be one infix operator per group. If there's more than one
  15450. * then the expression is ambiguous. This can be resolved by adding {}.
  15451. */
  15452. handleInfixNodes(body) {
  15453. var overIndex = -1;
  15454. var funcName;
  15455. for (var i = 0; i < body.length; i++) {
  15456. var node = body[i];
  15457. if (node.type === "infix") {
  15458. if (overIndex !== -1) {
  15459. throw new ParseError("only one infix operator per group", node.token);
  15460. }
  15461. overIndex = i;
  15462. funcName = node.replaceWith;
  15463. }
  15464. }
  15465. if (overIndex !== -1 && funcName) {
  15466. var numerNode;
  15467. var denomNode;
  15468. var numerBody = body.slice(0, overIndex);
  15469. var denomBody = body.slice(overIndex + 1);
  15470. if (numerBody.length === 1 && numerBody[0].type === "ordgroup") {
  15471. numerNode = numerBody[0];
  15472. } else {
  15473. numerNode = {
  15474. type: "ordgroup",
  15475. mode: this.mode,
  15476. body: numerBody
  15477. };
  15478. }
  15479. if (denomBody.length === 1 && denomBody[0].type === "ordgroup") {
  15480. denomNode = denomBody[0];
  15481. } else {
  15482. denomNode = {
  15483. type: "ordgroup",
  15484. mode: this.mode,
  15485. body: denomBody
  15486. };
  15487. }
  15488. var _node;
  15489. if (funcName === "\\\\abovefrac") {
  15490. _node = this.callFunction(funcName, [numerNode, body[overIndex], denomNode], []);
  15491. } else {
  15492. _node = this.callFunction(funcName, [numerNode, denomNode], []);
  15493. }
  15494. return [_node];
  15495. } else {
  15496. return body;
  15497. }
  15498. }
  15499. /**
  15500. * Handle a subscript or superscript with nice errors.
  15501. */
  15502. handleSupSubscript(name) {
  15503. var symbolToken = this.fetch();
  15504. var symbol = symbolToken.text;
  15505. this.consume();
  15506. this.consumeSpaces(); // ignore spaces before sup/subscript argument
  15507. // Skip over allowed internal nodes such as \relax
  15508. var group;
  15509. do {
  15510. var _group;
  15511. group = this.parseGroup(name);
  15512. } while (((_group = group) == null ? void 0 : _group.type) === "internal");
  15513. if (!group) {
  15514. throw new ParseError("Expected group after '" + symbol + "'", symbolToken);
  15515. }
  15516. return group;
  15517. }
  15518. /**
  15519. * Converts the textual input of an unsupported command into a text node
  15520. * contained within a color node whose color is determined by errorColor
  15521. */
  15522. formatUnsupportedCmd(text) {
  15523. var textordArray = [];
  15524. for (var i = 0; i < text.length; i++) {
  15525. textordArray.push({
  15526. type: "textord",
  15527. mode: "text",
  15528. text: text[i]
  15529. });
  15530. }
  15531. var textNode = {
  15532. type: "text",
  15533. mode: this.mode,
  15534. body: textordArray
  15535. };
  15536. var colorNode = {
  15537. type: "color",
  15538. mode: this.mode,
  15539. color: this.settings.errorColor,
  15540. body: [textNode]
  15541. };
  15542. return colorNode;
  15543. }
  15544. /**
  15545. * Parses a group with optional super/subscripts.
  15546. */
  15547. parseAtom(breakOnTokenText) {
  15548. // The body of an atom is an implicit group, so that things like
  15549. // \left(x\right)^2 work correctly.
  15550. var base = this.parseGroup("atom", breakOnTokenText);
  15551. // Internal nodes (e.g. \relax) cannot support super/subscripts.
  15552. // Instead we will pick up super/subscripts with blank base next round.
  15553. if ((base == null ? void 0 : base.type) === "internal") {
  15554. return base;
  15555. }
  15556. // In text mode, we don't have superscripts or subscripts
  15557. if (this.mode === "text") {
  15558. return base;
  15559. }
  15560. // Note that base may be empty (i.e. null) at this point.
  15561. var superscript;
  15562. var subscript;
  15563. while (true) {
  15564. // Guaranteed in math mode, so eat any spaces first.
  15565. this.consumeSpaces();
  15566. // Lex the first token
  15567. var lex = this.fetch();
  15568. if (lex.text === "\\limits" || lex.text === "\\nolimits") {
  15569. // We got a limit control
  15570. if (base && base.type === "op") {
  15571. var limits = lex.text === "\\limits";
  15572. base.limits = limits;
  15573. base.alwaysHandleSupSub = true;
  15574. } else if (base && base.type === "operatorname") {
  15575. if (base.alwaysHandleSupSub) {
  15576. base.limits = lex.text === "\\limits";
  15577. }
  15578. } else {
  15579. throw new ParseError("Limit controls must follow a math operator", lex);
  15580. }
  15581. this.consume();
  15582. } else if (lex.text === "^") {
  15583. // We got a superscript start
  15584. if (superscript) {
  15585. throw new ParseError("Double superscript", lex);
  15586. }
  15587. superscript = this.handleSupSubscript("superscript");
  15588. } else if (lex.text === "_") {
  15589. // We got a subscript start
  15590. if (subscript) {
  15591. throw new ParseError("Double subscript", lex);
  15592. }
  15593. subscript = this.handleSupSubscript("subscript");
  15594. } else if (lex.text === "'") {
  15595. // We got a prime
  15596. if (superscript) {
  15597. throw new ParseError("Double superscript", lex);
  15598. }
  15599. var prime = {
  15600. type: "textord",
  15601. mode: this.mode,
  15602. text: "\\prime"
  15603. };
  15604. // Many primes can be grouped together, so we handle this here
  15605. var primes = [prime];
  15606. this.consume();
  15607. // Keep lexing tokens until we get something that's not a prime
  15608. while (this.fetch().text === "'") {
  15609. // For each one, add another prime to the list
  15610. primes.push(prime);
  15611. this.consume();
  15612. }
  15613. // If there's a superscript following the primes, combine that
  15614. // superscript in with the primes.
  15615. if (this.fetch().text === "^") {
  15616. primes.push(this.handleSupSubscript("superscript"));
  15617. }
  15618. // Put everything into an ordgroup as the superscript
  15619. superscript = {
  15620. type: "ordgroup",
  15621. mode: this.mode,
  15622. body: primes
  15623. };
  15624. } else if (uSubsAndSups[lex.text]) {
  15625. // A Unicode subscript or superscript character.
  15626. // We treat these similarly to the unicode-math package.
  15627. // So we render a string of Unicode (sub|super)scripts the
  15628. // same as a (sub|super)script of regular characters.
  15629. var isSub = unicodeSubRegEx.test(lex.text);
  15630. var subsupTokens = [];
  15631. subsupTokens.push(new Token(uSubsAndSups[lex.text]));
  15632. this.consume();
  15633. // Continue fetching tokens to fill out the string.
  15634. while (true) {
  15635. var token = this.fetch().text;
  15636. if (!uSubsAndSups[token]) {
  15637. break;
  15638. }
  15639. if (unicodeSubRegEx.test(token) !== isSub) {
  15640. break;
  15641. }
  15642. subsupTokens.unshift(new Token(uSubsAndSups[token]));
  15643. this.consume();
  15644. }
  15645. // Now create a (sub|super)script.
  15646. var body = this.subparse(subsupTokens);
  15647. if (isSub) {
  15648. subscript = {
  15649. type: "ordgroup",
  15650. mode: "math",
  15651. body
  15652. };
  15653. } else {
  15654. superscript = {
  15655. type: "ordgroup",
  15656. mode: "math",
  15657. body
  15658. };
  15659. }
  15660. } else {
  15661. // If it wasn't ^, _, or ', stop parsing super/subscripts
  15662. break;
  15663. }
  15664. }
  15665. // Base must be set if superscript or subscript are set per logic above,
  15666. // but need to check here for type check to pass.
  15667. if (superscript || subscript) {
  15668. // If we got either a superscript or subscript, create a supsub
  15669. return {
  15670. type: "supsub",
  15671. mode: this.mode,
  15672. base: base,
  15673. sup: superscript,
  15674. sub: subscript
  15675. };
  15676. } else {
  15677. // Otherwise return the original body
  15678. return base;
  15679. }
  15680. }
  15681. /**
  15682. * Parses an entire function, including its base and all of its arguments.
  15683. */
  15684. parseFunction(breakOnTokenText, name) {
  15685. var token = this.fetch();
  15686. var func = token.text;
  15687. var funcData = functions[func];
  15688. if (!funcData) {
  15689. return null;
  15690. }
  15691. this.consume(); // consume command token
  15692. if (name && name !== "atom" && !funcData.allowedInArgument) {
  15693. throw new ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token);
  15694. } else if (this.mode === "text" && !funcData.allowedInText) {
  15695. throw new ParseError("Can't use function '" + func + "' in text mode", token);
  15696. } else if (this.mode === "math" && funcData.allowedInMath === false) {
  15697. throw new ParseError("Can't use function '" + func + "' in math mode", token);
  15698. }
  15699. var {
  15700. args,
  15701. optArgs
  15702. } = this.parseArguments(func, funcData);
  15703. return this.callFunction(func, args, optArgs, token, breakOnTokenText);
  15704. }
  15705. /**
  15706. * Call a function handler with a suitable context and arguments.
  15707. */
  15708. callFunction(name, args, optArgs, token, breakOnTokenText) {
  15709. var context = {
  15710. funcName: name,
  15711. parser: this,
  15712. token,
  15713. breakOnTokenText
  15714. };
  15715. var func = functions[name];
  15716. if (func && func.handler) {
  15717. return func.handler(context, args, optArgs);
  15718. } else {
  15719. throw new ParseError("No function handler for " + name);
  15720. }
  15721. }
  15722. /**
  15723. * Parses the arguments of a function or environment
  15724. */
  15725. parseArguments(func,
  15726. // Should look like "\name" or "\begin{name}".
  15727. funcData) {
  15728. var totalArgs = funcData.numArgs + funcData.numOptionalArgs;
  15729. if (totalArgs === 0) {
  15730. return {
  15731. args: [],
  15732. optArgs: []
  15733. };
  15734. }
  15735. var args = [];
  15736. var optArgs = [];
  15737. for (var i = 0; i < totalArgs; i++) {
  15738. var argType = funcData.argTypes && funcData.argTypes[i];
  15739. var isOptional = i < funcData.numOptionalArgs;
  15740. if ("primitive" in funcData && funcData.primitive && argType == null ||
  15741. // \sqrt expands into primitive if optional argument doesn't exist
  15742. funcData.type === "sqrt" && i === 1 && optArgs[0] == null) {
  15743. argType = "primitive";
  15744. }
  15745. var arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional);
  15746. if (isOptional) {
  15747. optArgs.push(arg);
  15748. } else if (arg != null) {
  15749. args.push(arg);
  15750. } else {
  15751. // should be unreachable
  15752. throw new ParseError("Null argument, please report this as a bug");
  15753. }
  15754. }
  15755. return {
  15756. args,
  15757. optArgs
  15758. };
  15759. }
  15760. /**
  15761. * Parses a group when the mode is changing.
  15762. */
  15763. parseGroupOfType(name, type, optional) {
  15764. switch (type) {
  15765. case "color":
  15766. return this.parseColorGroup(optional);
  15767. case "size":
  15768. return this.parseSizeGroup(optional);
  15769. case "url":
  15770. return this.parseUrlGroup(optional);
  15771. case "math":
  15772. case "text":
  15773. return this.parseArgumentGroup(optional, type);
  15774. case "hbox":
  15775. {
  15776. // hbox argument type wraps the argument in the equivalent of
  15777. // \hbox, which is like \text but switching to \textstyle size.
  15778. var group = this.parseArgumentGroup(optional, "text");
  15779. return group != null ? {
  15780. type: "styling",
  15781. mode: group.mode,
  15782. body: [group],
  15783. style: "text" // simulate \textstyle
  15784. } : null;
  15785. }
  15786. case "raw":
  15787. {
  15788. var token = this.parseStringGroup("raw", optional);
  15789. return token != null ? {
  15790. type: "raw",
  15791. mode: "text",
  15792. string: token.text
  15793. } : null;
  15794. }
  15795. case "primitive":
  15796. {
  15797. if (optional) {
  15798. throw new ParseError("A primitive argument cannot be optional");
  15799. }
  15800. var _group2 = this.parseGroup(name);
  15801. if (_group2 == null) {
  15802. throw new ParseError("Expected group as " + name, this.fetch());
  15803. }
  15804. return _group2;
  15805. }
  15806. case "original":
  15807. case null:
  15808. case undefined:
  15809. return this.parseArgumentGroup(optional);
  15810. default:
  15811. throw new ParseError("Unknown group type as " + name, this.fetch());
  15812. }
  15813. }
  15814. /**
  15815. * Discard any space tokens, fetching the next non-space token.
  15816. */
  15817. consumeSpaces() {
  15818. while (this.fetch().text === " ") {
  15819. this.consume();
  15820. }
  15821. }
  15822. /**
  15823. * Parses a group, essentially returning the string formed by the
  15824. * brace-enclosed tokens plus some position information.
  15825. */
  15826. parseStringGroup(modeName,
  15827. // Used to describe the mode in error messages.
  15828. optional) {
  15829. var argToken = this.gullet.scanArgument(optional);
  15830. if (argToken == null) {
  15831. return null;
  15832. }
  15833. var str = "";
  15834. var nextToken;
  15835. while ((nextToken = this.fetch()).text !== "EOF") {
  15836. str += nextToken.text;
  15837. this.consume();
  15838. }
  15839. this.consume(); // consume the end of the argument
  15840. argToken.text = str;
  15841. return argToken;
  15842. }
  15843. /**
  15844. * Parses a regex-delimited group: the largest sequence of tokens
  15845. * whose concatenated strings match `regex`. Returns the string
  15846. * formed by the tokens plus some position information.
  15847. */
  15848. parseRegexGroup(regex, modeName) {
  15849. var firstToken = this.fetch();
  15850. var lastToken = firstToken;
  15851. var str = "";
  15852. var nextToken;
  15853. while ((nextToken = this.fetch()).text !== "EOF" && regex.test(str + nextToken.text)) {
  15854. lastToken = nextToken;
  15855. str += lastToken.text;
  15856. this.consume();
  15857. }
  15858. if (str === "") {
  15859. throw new ParseError("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken);
  15860. }
  15861. return firstToken.range(lastToken, str);
  15862. }
  15863. /**
  15864. * Parses a color description.
  15865. */
  15866. parseColorGroup(optional) {
  15867. var res = this.parseStringGroup("color", optional);
  15868. if (res == null) {
  15869. return null;
  15870. }
  15871. var match = /^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(res.text);
  15872. if (!match) {
  15873. throw new ParseError("Invalid color: '" + res.text + "'", res);
  15874. }
  15875. var color = match[0];
  15876. if (/^[0-9a-f]{6}$/i.test(color)) {
  15877. // We allow a 6-digit HTML color spec without a leading "#".
  15878. // This follows the xcolor package's HTML color model.
  15879. // Predefined color names are all missed by this RegEx pattern.
  15880. color = "#" + color;
  15881. }
  15882. return {
  15883. type: "color-token",
  15884. mode: this.mode,
  15885. color
  15886. };
  15887. }
  15888. /**
  15889. * Parses a size specification, consisting of magnitude and unit.
  15890. */
  15891. parseSizeGroup(optional) {
  15892. var res;
  15893. var isBlank = false;
  15894. // don't expand before parseStringGroup
  15895. this.gullet.consumeSpaces();
  15896. if (!optional && this.gullet.future().text !== "{") {
  15897. res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size");
  15898. } else {
  15899. res = this.parseStringGroup("size", optional);
  15900. }
  15901. if (!res) {
  15902. return null;
  15903. }
  15904. if (!optional && res.text.length === 0) {
  15905. // Because we've tested for what is !optional, this block won't
  15906. // affect \kern, \hspace, etc. It will capture the mandatory arguments
  15907. // to \genfrac and \above.
  15908. res.text = "0pt"; // Enable \above{}
  15909. isBlank = true; // This is here specifically for \genfrac
  15910. }
  15911. var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text);
  15912. if (!match) {
  15913. throw new ParseError("Invalid size: '" + res.text + "'", res);
  15914. }
  15915. var data = {
  15916. number: +(match[1] + match[2]),
  15917. // sign + magnitude, cast to number
  15918. unit: match[3]
  15919. };
  15920. if (!validUnit(data)) {
  15921. throw new ParseError("Invalid unit: '" + data.unit + "'", res);
  15922. }
  15923. return {
  15924. type: "size",
  15925. mode: this.mode,
  15926. value: data,
  15927. isBlank
  15928. };
  15929. }
  15930. /**
  15931. * Parses an URL, checking escaped letters and allowed protocols,
  15932. * and setting the catcode of % as an active character (as in \hyperref).
  15933. */
  15934. parseUrlGroup(optional) {
  15935. this.gullet.lexer.setCatcode("%", 13); // active character
  15936. this.gullet.lexer.setCatcode("~", 12); // other character
  15937. var res = this.parseStringGroup("url", optional);
  15938. this.gullet.lexer.setCatcode("%", 14); // comment character
  15939. this.gullet.lexer.setCatcode("~", 13); // active character
  15940. if (res == null) {
  15941. return null;
  15942. }
  15943. // hyperref package allows backslashes alone in href, but doesn't
  15944. // generate valid links in such cases; we interpret this as
  15945. // "undefined" behaviour, and keep them as-is. Some browser will
  15946. // replace backslashes with forward slashes.
  15947. var url = res.text.replace(/\\([#$%&~_^{}])/g, '$1');
  15948. return {
  15949. type: "url",
  15950. mode: this.mode,
  15951. url
  15952. };
  15953. }
  15954. /**
  15955. * Parses an argument with the mode specified.
  15956. */
  15957. parseArgumentGroup(optional, mode) {
  15958. var argToken = this.gullet.scanArgument(optional);
  15959. if (argToken == null) {
  15960. return null;
  15961. }
  15962. var outerMode = this.mode;
  15963. if (mode) {
  15964. // Switch to specified mode
  15965. this.switchMode(mode);
  15966. }
  15967. this.gullet.beginGroup();
  15968. var expression = this.parseExpression(false, "EOF");
  15969. // TODO: find an alternative way to denote the end
  15970. this.expect("EOF"); // expect the end of the argument
  15971. this.gullet.endGroup();
  15972. var result = {
  15973. type: "ordgroup",
  15974. mode: this.mode,
  15975. loc: argToken.loc,
  15976. body: expression
  15977. };
  15978. if (mode) {
  15979. // Switch mode back
  15980. this.switchMode(outerMode);
  15981. }
  15982. return result;
  15983. }
  15984. /**
  15985. * Parses an ordinary group, which is either a single nucleus (like "x")
  15986. * or an expression in braces (like "{x+y}") or an implicit group, a group
  15987. * that starts at the current position, and ends right before a higher explicit
  15988. * group ends, or at EOF.
  15989. */
  15990. parseGroup(name,
  15991. // For error reporting.
  15992. breakOnTokenText) {
  15993. var firstToken = this.fetch();
  15994. var text = firstToken.text;
  15995. var result;
  15996. // Try to parse an open brace or \begingroup
  15997. if (text === "{" || text === "\\begingroup") {
  15998. this.consume();
  15999. var groupEnd = text === "{" ? "}" : "\\endgroup";
  16000. this.gullet.beginGroup();
  16001. // If we get a brace, parse an expression
  16002. var expression = this.parseExpression(false, groupEnd);
  16003. var lastToken = this.fetch();
  16004. this.expect(groupEnd); // Check that we got a matching closing brace
  16005. this.gullet.endGroup();
  16006. result = {
  16007. type: "ordgroup",
  16008. mode: this.mode,
  16009. loc: SourceLocation.range(firstToken, lastToken),
  16010. body: expression,
  16011. // A group formed by \begingroup...\endgroup is a semi-simple group
  16012. // which doesn't affect spacing in math mode, i.e., is transparent.
  16013. // https://tex.stackexchange.com/questions/1930/when-should-one-
  16014. // use-begingroup-instead-of-bgroup
  16015. semisimple: text === "\\begingroup" || undefined
  16016. };
  16017. } else {
  16018. // If there exists a function with this name, parse the function.
  16019. // Otherwise, just return a nucleus
  16020. result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol();
  16021. if (result == null && text[0] === "\\" && !implicitCommands.hasOwnProperty(text)) {
  16022. if (this.settings.throwOnError) {
  16023. throw new ParseError("Undefined control sequence: " + text, firstToken);
  16024. }
  16025. result = this.formatUnsupportedCmd(text);
  16026. this.consume();
  16027. }
  16028. }
  16029. return result;
  16030. }
  16031. /**
  16032. * Form ligature-like combinations of characters for text mode.
  16033. * This includes inputs like "--", "---", "``" and "''".
  16034. * The result will simply replace multiple textord nodes with a single
  16035. * character in each value by a single textord node having multiple
  16036. * characters in its value. The representation is still ASCII source.
  16037. * The group will be modified in place.
  16038. */
  16039. formLigatures(group) {
  16040. var n = group.length - 1;
  16041. for (var i = 0; i < n; ++i) {
  16042. var a = group[i];
  16043. if (a.type !== "textord") {
  16044. continue;
  16045. }
  16046. var v = a.text;
  16047. var next = group[i + 1];
  16048. if (!next || next.type !== "textord") {
  16049. continue;
  16050. }
  16051. if (v === "-" && next.text === "-") {
  16052. var afterNext = group[i + 2];
  16053. if (i + 1 < n && afterNext && afterNext.type === "textord" && afterNext.text === "-") {
  16054. group.splice(i, 3, {
  16055. type: "textord",
  16056. mode: "text",
  16057. loc: SourceLocation.range(a, afterNext),
  16058. text: "---"
  16059. });
  16060. n -= 2;
  16061. } else {
  16062. group.splice(i, 2, {
  16063. type: "textord",
  16064. mode: "text",
  16065. loc: SourceLocation.range(a, next),
  16066. text: "--"
  16067. });
  16068. n -= 1;
  16069. }
  16070. }
  16071. if ((v === "'" || v === "`") && next.text === v) {
  16072. group.splice(i, 2, {
  16073. type: "textord",
  16074. mode: "text",
  16075. loc: SourceLocation.range(a, next),
  16076. text: v + v
  16077. });
  16078. n -= 1;
  16079. }
  16080. }
  16081. }
  16082. /**
  16083. * Parse a single symbol out of the string. Here, we handle single character
  16084. * symbols and special functions like \verb.
  16085. */
  16086. parseSymbol() {
  16087. var nucleus = this.fetch();
  16088. var text = nucleus.text;
  16089. if (/^\\verb[^a-zA-Z]/.test(text)) {
  16090. this.consume();
  16091. var arg = text.slice(5);
  16092. var star = arg.charAt(0) === "*";
  16093. if (star) {
  16094. arg = arg.slice(1);
  16095. }
  16096. // Lexer's tokenRegex is constructed to always have matching
  16097. // first/last characters.
  16098. if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) {
  16099. throw new ParseError("\\verb assertion failed --\n please report what input caused this bug");
  16100. }
  16101. arg = arg.slice(1, -1); // remove first and last char
  16102. return {
  16103. type: "verb",
  16104. mode: "text",
  16105. body: arg,
  16106. star
  16107. };
  16108. }
  16109. // At this point, we should have a symbol, possibly with accents.
  16110. // First expand any accented base symbol according to unicodeSymbols.
  16111. if (unicodeSymbols.hasOwnProperty(text[0]) && !symbols[this.mode][text[0]]) {
  16112. // This behavior is not strict (XeTeX-compatible) in math mode.
  16113. if (this.settings.strict && this.mode === "math") {
  16114. this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus);
  16115. }
  16116. text = unicodeSymbols[text[0]] + text.slice(1);
  16117. }
  16118. // Strip off any combining characters
  16119. var match = combiningDiacriticalMarksEndRegex.exec(text);
  16120. if (match) {
  16121. text = text.substring(0, match.index);
  16122. if (text === 'i') {
  16123. text = '\u0131'; // dotless i, in math and text mode
  16124. } else if (text === 'j') {
  16125. text = '\u0237'; // dotless j, in math and text mode
  16126. }
  16127. }
  16128. // Recognize base symbol
  16129. var symbol;
  16130. if (symbols[this.mode][text]) {
  16131. if (this.settings.strict && this.mode === 'math' && extraLatin.includes(text)) {
  16132. this.settings.reportNonstrict("unicodeTextInMathMode", "Latin-1/Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus);
  16133. }
  16134. var group = symbols[this.mode][text].group;
  16135. var loc = SourceLocation.range(nucleus);
  16136. var s;
  16137. if (ATOMS.hasOwnProperty(group)) {
  16138. // TODO(ts)
  16139. var family = group;
  16140. s = {
  16141. type: "atom",
  16142. mode: this.mode,
  16143. family,
  16144. loc,
  16145. text
  16146. };
  16147. } else {
  16148. // TODO(ts)
  16149. s = {
  16150. type: group,
  16151. mode: this.mode,
  16152. loc,
  16153. text
  16154. };
  16155. }
  16156. // TODO(ts)
  16157. symbol = s;
  16158. } else if (text.charCodeAt(0) >= 0x80) {
  16159. // no symbol for e.g. ^
  16160. if (this.settings.strict) {
  16161. if (!supportedCodepoint(text.charCodeAt(0))) {
  16162. this.settings.reportNonstrict("unknownSymbol", "Unrecognized Unicode character \"" + text[0] + "\"" + (" (" + text.charCodeAt(0) + ")"), nucleus);
  16163. } else if (this.mode === "math") {
  16164. this.settings.reportNonstrict("unicodeTextInMathMode", "Unicode text character \"" + text[0] + "\" used in math mode", nucleus);
  16165. }
  16166. }
  16167. // All nonmathematical Unicode characters are rendered as if they
  16168. // are in text mode (wrapped in \text) because that's what it
  16169. // takes to render them in LaTeX. Setting `mode: this.mode` is
  16170. // another natural choice (the user requested math mode), but
  16171. // this makes it more difficult for getCharacterMetrics() to
  16172. // distinguish Unicode characters without metrics and those for
  16173. // which we want to simulate the letter M.
  16174. symbol = {
  16175. type: "textord",
  16176. mode: "text",
  16177. loc: SourceLocation.range(nucleus),
  16178. text
  16179. };
  16180. } else {
  16181. return null; // EOF, ^, _, {, }, etc.
  16182. }
  16183. this.consume();
  16184. // Transform combining characters into accents
  16185. if (match) {
  16186. for (var i = 0; i < match[0].length; i++) {
  16187. var accent = match[0][i];
  16188. if (!unicodeAccents[accent]) {
  16189. throw new ParseError("Unknown accent ' " + accent + "'", nucleus);
  16190. }
  16191. var command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text;
  16192. if (!command) {
  16193. throw new ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus);
  16194. }
  16195. symbol = {
  16196. type: "accent",
  16197. mode: this.mode,
  16198. loc: SourceLocation.range(nucleus),
  16199. label: command,
  16200. isStretchy: false,
  16201. isShifty: true,
  16202. // TODO(ts)
  16203. base: symbol
  16204. };
  16205. }
  16206. }
  16207. // TODO(ts)
  16208. return symbol;
  16209. }
  16210. }
  16211. Parser.endOfExpression = new Set(["}", "\\endgroup", "\\end", "\\right", "&"]);
  16212. /**
  16213. * Provides a single function for parsing an expression using a Parser
  16214. * TODO(emily): Remove this
  16215. */
  16216. /**
  16217. * Parses an expression using a Parser, then returns the parsed result.
  16218. */
  16219. var parseTree = function parseTree(toParse, settings) {
  16220. if (!(typeof toParse === 'string' || toParse instanceof String)) {
  16221. throw new TypeError('KaTeX can only parse string typed expression');
  16222. }
  16223. var parser = new Parser(toParse, settings);
  16224. // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors
  16225. delete parser.gullet.macros.current["\\df@tag"];
  16226. var tree = parser.parse();
  16227. // Prevent a color definition from persisting between calls to katex.render().
  16228. delete parser.gullet.macros.current["\\current@color"];
  16229. delete parser.gullet.macros.current["\\color"];
  16230. // If the input used \tag, it will set the \df@tag macro to the tag.
  16231. // In this case, we separately parse the tag and wrap the tree.
  16232. if (parser.gullet.macros.get("\\df@tag")) {
  16233. if (!settings.displayMode) {
  16234. throw new ParseError("\\tag works only in display equations");
  16235. }
  16236. tree = [{
  16237. type: "tag",
  16238. mode: "text",
  16239. body: tree,
  16240. tag: parser.subparse([new Token("\\df@tag")])
  16241. }];
  16242. }
  16243. return tree;
  16244. };
  16245. /* eslint no-console:0 */
  16246. /**
  16247. * Parse and build an expression, and place that expression in the DOM node
  16248. * given.
  16249. */
  16250. var render = function render(expression, baseNode, options) {
  16251. baseNode.textContent = "";
  16252. var node = renderToDomTree(expression, options).toNode();
  16253. baseNode.appendChild(node);
  16254. };
  16255. // KaTeX's styles don't work properly in quirks mode. Print out an error, and
  16256. // disable rendering.
  16257. if (typeof document !== "undefined") {
  16258. if (document.compatMode !== "CSS1Compat") {
  16259. typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype.");
  16260. render = function render() {
  16261. throw new ParseError("KaTeX doesn't work in quirks mode.");
  16262. };
  16263. }
  16264. }
  16265. /**
  16266. * Parse and build an expression, and return the markup for that.
  16267. */
  16268. var renderToString = function renderToString(expression, options) {
  16269. var markup = renderToDomTree(expression, options).toMarkup();
  16270. return markup;
  16271. };
  16272. /**
  16273. * Parse an expression and return the parse tree.
  16274. */
  16275. var generateParseTree = function generateParseTree(expression, options) {
  16276. var settings = new Settings(options);
  16277. return parseTree(expression, settings);
  16278. };
  16279. /**
  16280. * If the given error is a KaTeX ParseError and options.throwOnError is false,
  16281. * renders the invalid LaTeX as a span with hover title giving the KaTeX
  16282. * error message. Otherwise, simply throws the error.
  16283. */
  16284. var renderError = function renderError(error, expression, options) {
  16285. if (options.throwOnError || !(error instanceof ParseError)) {
  16286. throw error;
  16287. }
  16288. var node = makeSpan(["katex-error"], [new SymbolNode(expression)]);
  16289. node.setAttribute("title", error.toString());
  16290. node.setAttribute("style", "color:" + options.errorColor);
  16291. return node;
  16292. };
  16293. /**
  16294. * Generates and returns the katex build tree. This is used for advanced
  16295. * use cases (like rendering to custom output).
  16296. */
  16297. var renderToDomTree = function renderToDomTree(expression, options) {
  16298. var settings = new Settings(options);
  16299. try {
  16300. var tree = parseTree(expression, settings);
  16301. return buildTree(tree, expression, settings);
  16302. } catch (error) {
  16303. return renderError(error, expression, settings);
  16304. }
  16305. };
  16306. /**
  16307. * Generates and returns the katex build tree, with just HTML (no MathML).
  16308. * This is used for advanced use cases (like rendering to custom output).
  16309. */
  16310. var renderToHTMLTree = function renderToHTMLTree(expression, options) {
  16311. var settings = new Settings(options);
  16312. try {
  16313. var tree = parseTree(expression, settings);
  16314. return buildHTMLTree(tree, expression, settings);
  16315. } catch (error) {
  16316. return renderError(error, expression, settings);
  16317. }
  16318. };
  16319. var version = "0.16.44";
  16320. var __domTree = {
  16321. Span,
  16322. Anchor,
  16323. SymbolNode,
  16324. SvgNode,
  16325. PathNode,
  16326. LineNode
  16327. };
  16328. // CJS exports and ESM default export
  16329. var katex = {
  16330. /**
  16331. * Current KaTeX version
  16332. */
  16333. version,
  16334. /**
  16335. * Renders the given LaTeX into an HTML+MathML combination, and adds
  16336. * it as a child to the specified DOM node.
  16337. */
  16338. render,
  16339. /**
  16340. * Renders the given LaTeX into an HTML+MathML combination string,
  16341. * for sending to the client.
  16342. */
  16343. renderToString,
  16344. /**
  16345. * KaTeX error, usually during parsing.
  16346. */
  16347. ParseError,
  16348. /**
  16349. * The schema of Settings
  16350. */
  16351. SETTINGS_SCHEMA,
  16352. /**
  16353. * Parses the given LaTeX into KaTeX's internal parse tree structure,
  16354. * without rendering to HTML or MathML.
  16355. *
  16356. * NOTE: This method is not currently recommended for public use.
  16357. * The internal tree representation is unstable and is very likely
  16358. * to change. Use at your own risk.
  16359. */
  16360. __parse: generateParseTree,
  16361. /**
  16362. * Renders the given LaTeX into an HTML+MathML internal DOM tree
  16363. * representation, without flattening that representation to a string.
  16364. *
  16365. * NOTE: This method is not currently recommended for public use.
  16366. * The internal tree representation is unstable and is very likely
  16367. * to change. Use at your own risk.
  16368. */
  16369. __renderToDomTree: renderToDomTree,
  16370. /**
  16371. * Renders the given LaTeX into an HTML internal DOM tree representation,
  16372. * without MathML and without flattening that representation to a string.
  16373. *
  16374. * NOTE: This method is not currently recommended for public use.
  16375. * The internal tree representation is unstable and is very likely
  16376. * to change. Use at your own risk.
  16377. */
  16378. __renderToHTMLTree: renderToHTMLTree,
  16379. /**
  16380. * extends internal font metrics object with a new object
  16381. * each key in the new object represents a font name
  16382. */
  16383. __setFontMetrics: setFontMetrics,
  16384. /**
  16385. * adds a new symbol to builtin symbols table
  16386. */
  16387. __defineSymbol: defineSymbol,
  16388. /**
  16389. * adds a new function to builtin function list,
  16390. * which directly produce parse tree elements
  16391. * and have their own html/mathml builders
  16392. */
  16393. __defineFunction: defineFunction,
  16394. /**
  16395. * adds a new macro to builtin macro list
  16396. */
  16397. __defineMacro: defineMacro,
  16398. /**
  16399. * Expose the dom tree node types, which can be useful for type checking nodes.
  16400. *
  16401. * NOTE: These methods are not currently recommended for public use.
  16402. * The internal tree representation is unstable and is very likely
  16403. * to change. Use at your own risk.
  16404. */
  16405. __domTree
  16406. };
  16407. export { ParseError, SETTINGS_SCHEMA, defineFunction as __defineFunction, defineMacro as __defineMacro, defineSymbol as __defineSymbol, __domTree, generateParseTree as __parse, renderToDomTree as __renderToDomTree, renderToHTMLTree as __renderToHTMLTree, setFontMetrics as __setFontMetrics, katex as default, render, renderToString, version };