deps_markdown-it.js 269 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442
  1. /*! markdown-it 13.0.2 https://github.com/markdown-it/markdown-it @license MIT */
  2. (function(global, factory) {
  3. typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self,
  4. global.markdownit = factory());
  5. })(this, (function() {
  6. "use strict";
  7. function createCommonjsModule(fn, basedir, module) {
  8. return module = {
  9. path: basedir,
  10. exports: {},
  11. require: function(path, base) {
  12. return commonjsRequire(path, base === undefined || base === null ? module.path : base);
  13. }
  14. }, fn(module, module.exports), module.exports;
  15. }
  16. function getAugmentedNamespace(n) {
  17. if (n.__esModule) return n;
  18. var a = Object.defineProperty({}, "__esModule", {
  19. value: true
  20. });
  21. Object.keys(n).forEach((function(k) {
  22. var d = Object.getOwnPropertyDescriptor(n, k);
  23. Object.defineProperty(a, k, d.get ? d : {
  24. enumerable: true,
  25. get: function() {
  26. return n[k];
  27. }
  28. });
  29. }));
  30. return a;
  31. }
  32. function commonjsRequire() {
  33. throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
  34. }
  35. var require$$0 = {
  36. Aacute: "\xc1",
  37. aacute: "\xe1",
  38. Abreve: "\u0102",
  39. abreve: "\u0103",
  40. ac: "\u223e",
  41. acd: "\u223f",
  42. acE: "\u223e\u0333",
  43. Acirc: "\xc2",
  44. acirc: "\xe2",
  45. acute: "\xb4",
  46. Acy: "\u0410",
  47. acy: "\u0430",
  48. AElig: "\xc6",
  49. aelig: "\xe6",
  50. af: "\u2061",
  51. Afr: "\ud835\udd04",
  52. afr: "\ud835\udd1e",
  53. Agrave: "\xc0",
  54. agrave: "\xe0",
  55. alefsym: "\u2135",
  56. aleph: "\u2135",
  57. Alpha: "\u0391",
  58. alpha: "\u03b1",
  59. Amacr: "\u0100",
  60. amacr: "\u0101",
  61. amalg: "\u2a3f",
  62. amp: "&",
  63. AMP: "&",
  64. andand: "\u2a55",
  65. And: "\u2a53",
  66. and: "\u2227",
  67. andd: "\u2a5c",
  68. andslope: "\u2a58",
  69. andv: "\u2a5a",
  70. ang: "\u2220",
  71. ange: "\u29a4",
  72. angle: "\u2220",
  73. angmsdaa: "\u29a8",
  74. angmsdab: "\u29a9",
  75. angmsdac: "\u29aa",
  76. angmsdad: "\u29ab",
  77. angmsdae: "\u29ac",
  78. angmsdaf: "\u29ad",
  79. angmsdag: "\u29ae",
  80. angmsdah: "\u29af",
  81. angmsd: "\u2221",
  82. angrt: "\u221f",
  83. angrtvb: "\u22be",
  84. angrtvbd: "\u299d",
  85. angsph: "\u2222",
  86. angst: "\xc5",
  87. angzarr: "\u237c",
  88. Aogon: "\u0104",
  89. aogon: "\u0105",
  90. Aopf: "\ud835\udd38",
  91. aopf: "\ud835\udd52",
  92. apacir: "\u2a6f",
  93. ap: "\u2248",
  94. apE: "\u2a70",
  95. ape: "\u224a",
  96. apid: "\u224b",
  97. apos: "'",
  98. ApplyFunction: "\u2061",
  99. approx: "\u2248",
  100. approxeq: "\u224a",
  101. Aring: "\xc5",
  102. aring: "\xe5",
  103. Ascr: "\ud835\udc9c",
  104. ascr: "\ud835\udcb6",
  105. Assign: "\u2254",
  106. ast: "*",
  107. asymp: "\u2248",
  108. asympeq: "\u224d",
  109. Atilde: "\xc3",
  110. atilde: "\xe3",
  111. Auml: "\xc4",
  112. auml: "\xe4",
  113. awconint: "\u2233",
  114. awint: "\u2a11",
  115. backcong: "\u224c",
  116. backepsilon: "\u03f6",
  117. backprime: "\u2035",
  118. backsim: "\u223d",
  119. backsimeq: "\u22cd",
  120. Backslash: "\u2216",
  121. Barv: "\u2ae7",
  122. barvee: "\u22bd",
  123. barwed: "\u2305",
  124. Barwed: "\u2306",
  125. barwedge: "\u2305",
  126. bbrk: "\u23b5",
  127. bbrktbrk: "\u23b6",
  128. bcong: "\u224c",
  129. Bcy: "\u0411",
  130. bcy: "\u0431",
  131. bdquo: "\u201e",
  132. becaus: "\u2235",
  133. because: "\u2235",
  134. Because: "\u2235",
  135. bemptyv: "\u29b0",
  136. bepsi: "\u03f6",
  137. bernou: "\u212c",
  138. Bernoullis: "\u212c",
  139. Beta: "\u0392",
  140. beta: "\u03b2",
  141. beth: "\u2136",
  142. between: "\u226c",
  143. Bfr: "\ud835\udd05",
  144. bfr: "\ud835\udd1f",
  145. bigcap: "\u22c2",
  146. bigcirc: "\u25ef",
  147. bigcup: "\u22c3",
  148. bigodot: "\u2a00",
  149. bigoplus: "\u2a01",
  150. bigotimes: "\u2a02",
  151. bigsqcup: "\u2a06",
  152. bigstar: "\u2605",
  153. bigtriangledown: "\u25bd",
  154. bigtriangleup: "\u25b3",
  155. biguplus: "\u2a04",
  156. bigvee: "\u22c1",
  157. bigwedge: "\u22c0",
  158. bkarow: "\u290d",
  159. blacklozenge: "\u29eb",
  160. blacksquare: "\u25aa",
  161. blacktriangle: "\u25b4",
  162. blacktriangledown: "\u25be",
  163. blacktriangleleft: "\u25c2",
  164. blacktriangleright: "\u25b8",
  165. blank: "\u2423",
  166. blk12: "\u2592",
  167. blk14: "\u2591",
  168. blk34: "\u2593",
  169. block: "\u2588",
  170. bne: "=\u20e5",
  171. bnequiv: "\u2261\u20e5",
  172. bNot: "\u2aed",
  173. bnot: "\u2310",
  174. Bopf: "\ud835\udd39",
  175. bopf: "\ud835\udd53",
  176. bot: "\u22a5",
  177. bottom: "\u22a5",
  178. bowtie: "\u22c8",
  179. boxbox: "\u29c9",
  180. boxdl: "\u2510",
  181. boxdL: "\u2555",
  182. boxDl: "\u2556",
  183. boxDL: "\u2557",
  184. boxdr: "\u250c",
  185. boxdR: "\u2552",
  186. boxDr: "\u2553",
  187. boxDR: "\u2554",
  188. boxh: "\u2500",
  189. boxH: "\u2550",
  190. boxhd: "\u252c",
  191. boxHd: "\u2564",
  192. boxhD: "\u2565",
  193. boxHD: "\u2566",
  194. boxhu: "\u2534",
  195. boxHu: "\u2567",
  196. boxhU: "\u2568",
  197. boxHU: "\u2569",
  198. boxminus: "\u229f",
  199. boxplus: "\u229e",
  200. boxtimes: "\u22a0",
  201. boxul: "\u2518",
  202. boxuL: "\u255b",
  203. boxUl: "\u255c",
  204. boxUL: "\u255d",
  205. boxur: "\u2514",
  206. boxuR: "\u2558",
  207. boxUr: "\u2559",
  208. boxUR: "\u255a",
  209. boxv: "\u2502",
  210. boxV: "\u2551",
  211. boxvh: "\u253c",
  212. boxvH: "\u256a",
  213. boxVh: "\u256b",
  214. boxVH: "\u256c",
  215. boxvl: "\u2524",
  216. boxvL: "\u2561",
  217. boxVl: "\u2562",
  218. boxVL: "\u2563",
  219. boxvr: "\u251c",
  220. boxvR: "\u255e",
  221. boxVr: "\u255f",
  222. boxVR: "\u2560",
  223. bprime: "\u2035",
  224. breve: "\u02d8",
  225. Breve: "\u02d8",
  226. brvbar: "\xa6",
  227. bscr: "\ud835\udcb7",
  228. Bscr: "\u212c",
  229. bsemi: "\u204f",
  230. bsim: "\u223d",
  231. bsime: "\u22cd",
  232. bsolb: "\u29c5",
  233. bsol: "\\",
  234. bsolhsub: "\u27c8",
  235. bull: "\u2022",
  236. bullet: "\u2022",
  237. bump: "\u224e",
  238. bumpE: "\u2aae",
  239. bumpe: "\u224f",
  240. Bumpeq: "\u224e",
  241. bumpeq: "\u224f",
  242. Cacute: "\u0106",
  243. cacute: "\u0107",
  244. capand: "\u2a44",
  245. capbrcup: "\u2a49",
  246. capcap: "\u2a4b",
  247. cap: "\u2229",
  248. Cap: "\u22d2",
  249. capcup: "\u2a47",
  250. capdot: "\u2a40",
  251. CapitalDifferentialD: "\u2145",
  252. caps: "\u2229\ufe00",
  253. caret: "\u2041",
  254. caron: "\u02c7",
  255. Cayleys: "\u212d",
  256. ccaps: "\u2a4d",
  257. Ccaron: "\u010c",
  258. ccaron: "\u010d",
  259. Ccedil: "\xc7",
  260. ccedil: "\xe7",
  261. Ccirc: "\u0108",
  262. ccirc: "\u0109",
  263. Cconint: "\u2230",
  264. ccups: "\u2a4c",
  265. ccupssm: "\u2a50",
  266. Cdot: "\u010a",
  267. cdot: "\u010b",
  268. cedil: "\xb8",
  269. Cedilla: "\xb8",
  270. cemptyv: "\u29b2",
  271. cent: "\xa2",
  272. centerdot: "\xb7",
  273. CenterDot: "\xb7",
  274. cfr: "\ud835\udd20",
  275. Cfr: "\u212d",
  276. CHcy: "\u0427",
  277. chcy: "\u0447",
  278. check: "\u2713",
  279. checkmark: "\u2713",
  280. Chi: "\u03a7",
  281. chi: "\u03c7",
  282. circ: "\u02c6",
  283. circeq: "\u2257",
  284. circlearrowleft: "\u21ba",
  285. circlearrowright: "\u21bb",
  286. circledast: "\u229b",
  287. circledcirc: "\u229a",
  288. circleddash: "\u229d",
  289. CircleDot: "\u2299",
  290. circledR: "\xae",
  291. circledS: "\u24c8",
  292. CircleMinus: "\u2296",
  293. CirclePlus: "\u2295",
  294. CircleTimes: "\u2297",
  295. cir: "\u25cb",
  296. cirE: "\u29c3",
  297. cire: "\u2257",
  298. cirfnint: "\u2a10",
  299. cirmid: "\u2aef",
  300. cirscir: "\u29c2",
  301. ClockwiseContourIntegral: "\u2232",
  302. CloseCurlyDoubleQuote: "\u201d",
  303. CloseCurlyQuote: "\u2019",
  304. clubs: "\u2663",
  305. clubsuit: "\u2663",
  306. colon: ":",
  307. Colon: "\u2237",
  308. Colone: "\u2a74",
  309. colone: "\u2254",
  310. coloneq: "\u2254",
  311. comma: ",",
  312. commat: "@",
  313. comp: "\u2201",
  314. compfn: "\u2218",
  315. complement: "\u2201",
  316. complexes: "\u2102",
  317. cong: "\u2245",
  318. congdot: "\u2a6d",
  319. Congruent: "\u2261",
  320. conint: "\u222e",
  321. Conint: "\u222f",
  322. ContourIntegral: "\u222e",
  323. copf: "\ud835\udd54",
  324. Copf: "\u2102",
  325. coprod: "\u2210",
  326. Coproduct: "\u2210",
  327. copy: "\xa9",
  328. COPY: "\xa9",
  329. copysr: "\u2117",
  330. CounterClockwiseContourIntegral: "\u2233",
  331. crarr: "\u21b5",
  332. cross: "\u2717",
  333. Cross: "\u2a2f",
  334. Cscr: "\ud835\udc9e",
  335. cscr: "\ud835\udcb8",
  336. csub: "\u2acf",
  337. csube: "\u2ad1",
  338. csup: "\u2ad0",
  339. csupe: "\u2ad2",
  340. ctdot: "\u22ef",
  341. cudarrl: "\u2938",
  342. cudarrr: "\u2935",
  343. cuepr: "\u22de",
  344. cuesc: "\u22df",
  345. cularr: "\u21b6",
  346. cularrp: "\u293d",
  347. cupbrcap: "\u2a48",
  348. cupcap: "\u2a46",
  349. CupCap: "\u224d",
  350. cup: "\u222a",
  351. Cup: "\u22d3",
  352. cupcup: "\u2a4a",
  353. cupdot: "\u228d",
  354. cupor: "\u2a45",
  355. cups: "\u222a\ufe00",
  356. curarr: "\u21b7",
  357. curarrm: "\u293c",
  358. curlyeqprec: "\u22de",
  359. curlyeqsucc: "\u22df",
  360. curlyvee: "\u22ce",
  361. curlywedge: "\u22cf",
  362. curren: "\xa4",
  363. curvearrowleft: "\u21b6",
  364. curvearrowright: "\u21b7",
  365. cuvee: "\u22ce",
  366. cuwed: "\u22cf",
  367. cwconint: "\u2232",
  368. cwint: "\u2231",
  369. cylcty: "\u232d",
  370. dagger: "\u2020",
  371. Dagger: "\u2021",
  372. daleth: "\u2138",
  373. darr: "\u2193",
  374. Darr: "\u21a1",
  375. dArr: "\u21d3",
  376. dash: "\u2010",
  377. Dashv: "\u2ae4",
  378. dashv: "\u22a3",
  379. dbkarow: "\u290f",
  380. dblac: "\u02dd",
  381. Dcaron: "\u010e",
  382. dcaron: "\u010f",
  383. Dcy: "\u0414",
  384. dcy: "\u0434",
  385. ddagger: "\u2021",
  386. ddarr: "\u21ca",
  387. DD: "\u2145",
  388. dd: "\u2146",
  389. DDotrahd: "\u2911",
  390. ddotseq: "\u2a77",
  391. deg: "\xb0",
  392. Del: "\u2207",
  393. Delta: "\u0394",
  394. delta: "\u03b4",
  395. demptyv: "\u29b1",
  396. dfisht: "\u297f",
  397. Dfr: "\ud835\udd07",
  398. dfr: "\ud835\udd21",
  399. dHar: "\u2965",
  400. dharl: "\u21c3",
  401. dharr: "\u21c2",
  402. DiacriticalAcute: "\xb4",
  403. DiacriticalDot: "\u02d9",
  404. DiacriticalDoubleAcute: "\u02dd",
  405. DiacriticalGrave: "`",
  406. DiacriticalTilde: "\u02dc",
  407. diam: "\u22c4",
  408. diamond: "\u22c4",
  409. Diamond: "\u22c4",
  410. diamondsuit: "\u2666",
  411. diams: "\u2666",
  412. die: "\xa8",
  413. DifferentialD: "\u2146",
  414. digamma: "\u03dd",
  415. disin: "\u22f2",
  416. div: "\xf7",
  417. divide: "\xf7",
  418. divideontimes: "\u22c7",
  419. divonx: "\u22c7",
  420. DJcy: "\u0402",
  421. djcy: "\u0452",
  422. dlcorn: "\u231e",
  423. dlcrop: "\u230d",
  424. dollar: "$",
  425. Dopf: "\ud835\udd3b",
  426. dopf: "\ud835\udd55",
  427. Dot: "\xa8",
  428. dot: "\u02d9",
  429. DotDot: "\u20dc",
  430. doteq: "\u2250",
  431. doteqdot: "\u2251",
  432. DotEqual: "\u2250",
  433. dotminus: "\u2238",
  434. dotplus: "\u2214",
  435. dotsquare: "\u22a1",
  436. doublebarwedge: "\u2306",
  437. DoubleContourIntegral: "\u222f",
  438. DoubleDot: "\xa8",
  439. DoubleDownArrow: "\u21d3",
  440. DoubleLeftArrow: "\u21d0",
  441. DoubleLeftRightArrow: "\u21d4",
  442. DoubleLeftTee: "\u2ae4",
  443. DoubleLongLeftArrow: "\u27f8",
  444. DoubleLongLeftRightArrow: "\u27fa",
  445. DoubleLongRightArrow: "\u27f9",
  446. DoubleRightArrow: "\u21d2",
  447. DoubleRightTee: "\u22a8",
  448. DoubleUpArrow: "\u21d1",
  449. DoubleUpDownArrow: "\u21d5",
  450. DoubleVerticalBar: "\u2225",
  451. DownArrowBar: "\u2913",
  452. downarrow: "\u2193",
  453. DownArrow: "\u2193",
  454. Downarrow: "\u21d3",
  455. DownArrowUpArrow: "\u21f5",
  456. DownBreve: "\u0311",
  457. downdownarrows: "\u21ca",
  458. downharpoonleft: "\u21c3",
  459. downharpoonright: "\u21c2",
  460. DownLeftRightVector: "\u2950",
  461. DownLeftTeeVector: "\u295e",
  462. DownLeftVectorBar: "\u2956",
  463. DownLeftVector: "\u21bd",
  464. DownRightTeeVector: "\u295f",
  465. DownRightVectorBar: "\u2957",
  466. DownRightVector: "\u21c1",
  467. DownTeeArrow: "\u21a7",
  468. DownTee: "\u22a4",
  469. drbkarow: "\u2910",
  470. drcorn: "\u231f",
  471. drcrop: "\u230c",
  472. Dscr: "\ud835\udc9f",
  473. dscr: "\ud835\udcb9",
  474. DScy: "\u0405",
  475. dscy: "\u0455",
  476. dsol: "\u29f6",
  477. Dstrok: "\u0110",
  478. dstrok: "\u0111",
  479. dtdot: "\u22f1",
  480. dtri: "\u25bf",
  481. dtrif: "\u25be",
  482. duarr: "\u21f5",
  483. duhar: "\u296f",
  484. dwangle: "\u29a6",
  485. DZcy: "\u040f",
  486. dzcy: "\u045f",
  487. dzigrarr: "\u27ff",
  488. Eacute: "\xc9",
  489. eacute: "\xe9",
  490. easter: "\u2a6e",
  491. Ecaron: "\u011a",
  492. ecaron: "\u011b",
  493. Ecirc: "\xca",
  494. ecirc: "\xea",
  495. ecir: "\u2256",
  496. ecolon: "\u2255",
  497. Ecy: "\u042d",
  498. ecy: "\u044d",
  499. eDDot: "\u2a77",
  500. Edot: "\u0116",
  501. edot: "\u0117",
  502. eDot: "\u2251",
  503. ee: "\u2147",
  504. efDot: "\u2252",
  505. Efr: "\ud835\udd08",
  506. efr: "\ud835\udd22",
  507. eg: "\u2a9a",
  508. Egrave: "\xc8",
  509. egrave: "\xe8",
  510. egs: "\u2a96",
  511. egsdot: "\u2a98",
  512. el: "\u2a99",
  513. Element: "\u2208",
  514. elinters: "\u23e7",
  515. ell: "\u2113",
  516. els: "\u2a95",
  517. elsdot: "\u2a97",
  518. Emacr: "\u0112",
  519. emacr: "\u0113",
  520. empty: "\u2205",
  521. emptyset: "\u2205",
  522. EmptySmallSquare: "\u25fb",
  523. emptyv: "\u2205",
  524. EmptyVerySmallSquare: "\u25ab",
  525. emsp13: "\u2004",
  526. emsp14: "\u2005",
  527. emsp: "\u2003",
  528. ENG: "\u014a",
  529. eng: "\u014b",
  530. ensp: "\u2002",
  531. Eogon: "\u0118",
  532. eogon: "\u0119",
  533. Eopf: "\ud835\udd3c",
  534. eopf: "\ud835\udd56",
  535. epar: "\u22d5",
  536. eparsl: "\u29e3",
  537. eplus: "\u2a71",
  538. epsi: "\u03b5",
  539. Epsilon: "\u0395",
  540. epsilon: "\u03b5",
  541. epsiv: "\u03f5",
  542. eqcirc: "\u2256",
  543. eqcolon: "\u2255",
  544. eqsim: "\u2242",
  545. eqslantgtr: "\u2a96",
  546. eqslantless: "\u2a95",
  547. Equal: "\u2a75",
  548. equals: "=",
  549. EqualTilde: "\u2242",
  550. equest: "\u225f",
  551. Equilibrium: "\u21cc",
  552. equiv: "\u2261",
  553. equivDD: "\u2a78",
  554. eqvparsl: "\u29e5",
  555. erarr: "\u2971",
  556. erDot: "\u2253",
  557. escr: "\u212f",
  558. Escr: "\u2130",
  559. esdot: "\u2250",
  560. Esim: "\u2a73",
  561. esim: "\u2242",
  562. Eta: "\u0397",
  563. eta: "\u03b7",
  564. ETH: "\xd0",
  565. eth: "\xf0",
  566. Euml: "\xcb",
  567. euml: "\xeb",
  568. euro: "\u20ac",
  569. excl: "!",
  570. exist: "\u2203",
  571. Exists: "\u2203",
  572. expectation: "\u2130",
  573. exponentiale: "\u2147",
  574. ExponentialE: "\u2147",
  575. fallingdotseq: "\u2252",
  576. Fcy: "\u0424",
  577. fcy: "\u0444",
  578. female: "\u2640",
  579. ffilig: "\ufb03",
  580. fflig: "\ufb00",
  581. ffllig: "\ufb04",
  582. Ffr: "\ud835\udd09",
  583. ffr: "\ud835\udd23",
  584. filig: "\ufb01",
  585. FilledSmallSquare: "\u25fc",
  586. FilledVerySmallSquare: "\u25aa",
  587. fjlig: "fj",
  588. flat: "\u266d",
  589. fllig: "\ufb02",
  590. fltns: "\u25b1",
  591. fnof: "\u0192",
  592. Fopf: "\ud835\udd3d",
  593. fopf: "\ud835\udd57",
  594. forall: "\u2200",
  595. ForAll: "\u2200",
  596. fork: "\u22d4",
  597. forkv: "\u2ad9",
  598. Fouriertrf: "\u2131",
  599. fpartint: "\u2a0d",
  600. frac12: "\xbd",
  601. frac13: "\u2153",
  602. frac14: "\xbc",
  603. frac15: "\u2155",
  604. frac16: "\u2159",
  605. frac18: "\u215b",
  606. frac23: "\u2154",
  607. frac25: "\u2156",
  608. frac34: "\xbe",
  609. frac35: "\u2157",
  610. frac38: "\u215c",
  611. frac45: "\u2158",
  612. frac56: "\u215a",
  613. frac58: "\u215d",
  614. frac78: "\u215e",
  615. frasl: "\u2044",
  616. frown: "\u2322",
  617. fscr: "\ud835\udcbb",
  618. Fscr: "\u2131",
  619. gacute: "\u01f5",
  620. Gamma: "\u0393",
  621. gamma: "\u03b3",
  622. Gammad: "\u03dc",
  623. gammad: "\u03dd",
  624. gap: "\u2a86",
  625. Gbreve: "\u011e",
  626. gbreve: "\u011f",
  627. Gcedil: "\u0122",
  628. Gcirc: "\u011c",
  629. gcirc: "\u011d",
  630. Gcy: "\u0413",
  631. gcy: "\u0433",
  632. Gdot: "\u0120",
  633. gdot: "\u0121",
  634. ge: "\u2265",
  635. gE: "\u2267",
  636. gEl: "\u2a8c",
  637. gel: "\u22db",
  638. geq: "\u2265",
  639. geqq: "\u2267",
  640. geqslant: "\u2a7e",
  641. gescc: "\u2aa9",
  642. ges: "\u2a7e",
  643. gesdot: "\u2a80",
  644. gesdoto: "\u2a82",
  645. gesdotol: "\u2a84",
  646. gesl: "\u22db\ufe00",
  647. gesles: "\u2a94",
  648. Gfr: "\ud835\udd0a",
  649. gfr: "\ud835\udd24",
  650. gg: "\u226b",
  651. Gg: "\u22d9",
  652. ggg: "\u22d9",
  653. gimel: "\u2137",
  654. GJcy: "\u0403",
  655. gjcy: "\u0453",
  656. gla: "\u2aa5",
  657. gl: "\u2277",
  658. glE: "\u2a92",
  659. glj: "\u2aa4",
  660. gnap: "\u2a8a",
  661. gnapprox: "\u2a8a",
  662. gne: "\u2a88",
  663. gnE: "\u2269",
  664. gneq: "\u2a88",
  665. gneqq: "\u2269",
  666. gnsim: "\u22e7",
  667. Gopf: "\ud835\udd3e",
  668. gopf: "\ud835\udd58",
  669. grave: "`",
  670. GreaterEqual: "\u2265",
  671. GreaterEqualLess: "\u22db",
  672. GreaterFullEqual: "\u2267",
  673. GreaterGreater: "\u2aa2",
  674. GreaterLess: "\u2277",
  675. GreaterSlantEqual: "\u2a7e",
  676. GreaterTilde: "\u2273",
  677. Gscr: "\ud835\udca2",
  678. gscr: "\u210a",
  679. gsim: "\u2273",
  680. gsime: "\u2a8e",
  681. gsiml: "\u2a90",
  682. gtcc: "\u2aa7",
  683. gtcir: "\u2a7a",
  684. gt: ">",
  685. GT: ">",
  686. Gt: "\u226b",
  687. gtdot: "\u22d7",
  688. gtlPar: "\u2995",
  689. gtquest: "\u2a7c",
  690. gtrapprox: "\u2a86",
  691. gtrarr: "\u2978",
  692. gtrdot: "\u22d7",
  693. gtreqless: "\u22db",
  694. gtreqqless: "\u2a8c",
  695. gtrless: "\u2277",
  696. gtrsim: "\u2273",
  697. gvertneqq: "\u2269\ufe00",
  698. gvnE: "\u2269\ufe00",
  699. Hacek: "\u02c7",
  700. hairsp: "\u200a",
  701. half: "\xbd",
  702. hamilt: "\u210b",
  703. HARDcy: "\u042a",
  704. hardcy: "\u044a",
  705. harrcir: "\u2948",
  706. harr: "\u2194",
  707. hArr: "\u21d4",
  708. harrw: "\u21ad",
  709. Hat: "^",
  710. hbar: "\u210f",
  711. Hcirc: "\u0124",
  712. hcirc: "\u0125",
  713. hearts: "\u2665",
  714. heartsuit: "\u2665",
  715. hellip: "\u2026",
  716. hercon: "\u22b9",
  717. hfr: "\ud835\udd25",
  718. Hfr: "\u210c",
  719. HilbertSpace: "\u210b",
  720. hksearow: "\u2925",
  721. hkswarow: "\u2926",
  722. hoarr: "\u21ff",
  723. homtht: "\u223b",
  724. hookleftarrow: "\u21a9",
  725. hookrightarrow: "\u21aa",
  726. hopf: "\ud835\udd59",
  727. Hopf: "\u210d",
  728. horbar: "\u2015",
  729. HorizontalLine: "\u2500",
  730. hscr: "\ud835\udcbd",
  731. Hscr: "\u210b",
  732. hslash: "\u210f",
  733. Hstrok: "\u0126",
  734. hstrok: "\u0127",
  735. HumpDownHump: "\u224e",
  736. HumpEqual: "\u224f",
  737. hybull: "\u2043",
  738. hyphen: "\u2010",
  739. Iacute: "\xcd",
  740. iacute: "\xed",
  741. ic: "\u2063",
  742. Icirc: "\xce",
  743. icirc: "\xee",
  744. Icy: "\u0418",
  745. icy: "\u0438",
  746. Idot: "\u0130",
  747. IEcy: "\u0415",
  748. iecy: "\u0435",
  749. iexcl: "\xa1",
  750. iff: "\u21d4",
  751. ifr: "\ud835\udd26",
  752. Ifr: "\u2111",
  753. Igrave: "\xcc",
  754. igrave: "\xec",
  755. ii: "\u2148",
  756. iiiint: "\u2a0c",
  757. iiint: "\u222d",
  758. iinfin: "\u29dc",
  759. iiota: "\u2129",
  760. IJlig: "\u0132",
  761. ijlig: "\u0133",
  762. Imacr: "\u012a",
  763. imacr: "\u012b",
  764. image: "\u2111",
  765. ImaginaryI: "\u2148",
  766. imagline: "\u2110",
  767. imagpart: "\u2111",
  768. imath: "\u0131",
  769. Im: "\u2111",
  770. imof: "\u22b7",
  771. imped: "\u01b5",
  772. Implies: "\u21d2",
  773. incare: "\u2105",
  774. in: "\u2208",
  775. infin: "\u221e",
  776. infintie: "\u29dd",
  777. inodot: "\u0131",
  778. intcal: "\u22ba",
  779. int: "\u222b",
  780. Int: "\u222c",
  781. integers: "\u2124",
  782. Integral: "\u222b",
  783. intercal: "\u22ba",
  784. Intersection: "\u22c2",
  785. intlarhk: "\u2a17",
  786. intprod: "\u2a3c",
  787. InvisibleComma: "\u2063",
  788. InvisibleTimes: "\u2062",
  789. IOcy: "\u0401",
  790. iocy: "\u0451",
  791. Iogon: "\u012e",
  792. iogon: "\u012f",
  793. Iopf: "\ud835\udd40",
  794. iopf: "\ud835\udd5a",
  795. Iota: "\u0399",
  796. iota: "\u03b9",
  797. iprod: "\u2a3c",
  798. iquest: "\xbf",
  799. iscr: "\ud835\udcbe",
  800. Iscr: "\u2110",
  801. isin: "\u2208",
  802. isindot: "\u22f5",
  803. isinE: "\u22f9",
  804. isins: "\u22f4",
  805. isinsv: "\u22f3",
  806. isinv: "\u2208",
  807. it: "\u2062",
  808. Itilde: "\u0128",
  809. itilde: "\u0129",
  810. Iukcy: "\u0406",
  811. iukcy: "\u0456",
  812. Iuml: "\xcf",
  813. iuml: "\xef",
  814. Jcirc: "\u0134",
  815. jcirc: "\u0135",
  816. Jcy: "\u0419",
  817. jcy: "\u0439",
  818. Jfr: "\ud835\udd0d",
  819. jfr: "\ud835\udd27",
  820. jmath: "\u0237",
  821. Jopf: "\ud835\udd41",
  822. jopf: "\ud835\udd5b",
  823. Jscr: "\ud835\udca5",
  824. jscr: "\ud835\udcbf",
  825. Jsercy: "\u0408",
  826. jsercy: "\u0458",
  827. Jukcy: "\u0404",
  828. jukcy: "\u0454",
  829. Kappa: "\u039a",
  830. kappa: "\u03ba",
  831. kappav: "\u03f0",
  832. Kcedil: "\u0136",
  833. kcedil: "\u0137",
  834. Kcy: "\u041a",
  835. kcy: "\u043a",
  836. Kfr: "\ud835\udd0e",
  837. kfr: "\ud835\udd28",
  838. kgreen: "\u0138",
  839. KHcy: "\u0425",
  840. khcy: "\u0445",
  841. KJcy: "\u040c",
  842. kjcy: "\u045c",
  843. Kopf: "\ud835\udd42",
  844. kopf: "\ud835\udd5c",
  845. Kscr: "\ud835\udca6",
  846. kscr: "\ud835\udcc0",
  847. lAarr: "\u21da",
  848. Lacute: "\u0139",
  849. lacute: "\u013a",
  850. laemptyv: "\u29b4",
  851. lagran: "\u2112",
  852. Lambda: "\u039b",
  853. lambda: "\u03bb",
  854. lang: "\u27e8",
  855. Lang: "\u27ea",
  856. langd: "\u2991",
  857. langle: "\u27e8",
  858. lap: "\u2a85",
  859. Laplacetrf: "\u2112",
  860. laquo: "\xab",
  861. larrb: "\u21e4",
  862. larrbfs: "\u291f",
  863. larr: "\u2190",
  864. Larr: "\u219e",
  865. lArr: "\u21d0",
  866. larrfs: "\u291d",
  867. larrhk: "\u21a9",
  868. larrlp: "\u21ab",
  869. larrpl: "\u2939",
  870. larrsim: "\u2973",
  871. larrtl: "\u21a2",
  872. latail: "\u2919",
  873. lAtail: "\u291b",
  874. lat: "\u2aab",
  875. late: "\u2aad",
  876. lates: "\u2aad\ufe00",
  877. lbarr: "\u290c",
  878. lBarr: "\u290e",
  879. lbbrk: "\u2772",
  880. lbrace: "{",
  881. lbrack: "[",
  882. lbrke: "\u298b",
  883. lbrksld: "\u298f",
  884. lbrkslu: "\u298d",
  885. Lcaron: "\u013d",
  886. lcaron: "\u013e",
  887. Lcedil: "\u013b",
  888. lcedil: "\u013c",
  889. lceil: "\u2308",
  890. lcub: "{",
  891. Lcy: "\u041b",
  892. lcy: "\u043b",
  893. ldca: "\u2936",
  894. ldquo: "\u201c",
  895. ldquor: "\u201e",
  896. ldrdhar: "\u2967",
  897. ldrushar: "\u294b",
  898. ldsh: "\u21b2",
  899. le: "\u2264",
  900. lE: "\u2266",
  901. LeftAngleBracket: "\u27e8",
  902. LeftArrowBar: "\u21e4",
  903. leftarrow: "\u2190",
  904. LeftArrow: "\u2190",
  905. Leftarrow: "\u21d0",
  906. LeftArrowRightArrow: "\u21c6",
  907. leftarrowtail: "\u21a2",
  908. LeftCeiling: "\u2308",
  909. LeftDoubleBracket: "\u27e6",
  910. LeftDownTeeVector: "\u2961",
  911. LeftDownVectorBar: "\u2959",
  912. LeftDownVector: "\u21c3",
  913. LeftFloor: "\u230a",
  914. leftharpoondown: "\u21bd",
  915. leftharpoonup: "\u21bc",
  916. leftleftarrows: "\u21c7",
  917. leftrightarrow: "\u2194",
  918. LeftRightArrow: "\u2194",
  919. Leftrightarrow: "\u21d4",
  920. leftrightarrows: "\u21c6",
  921. leftrightharpoons: "\u21cb",
  922. leftrightsquigarrow: "\u21ad",
  923. LeftRightVector: "\u294e",
  924. LeftTeeArrow: "\u21a4",
  925. LeftTee: "\u22a3",
  926. LeftTeeVector: "\u295a",
  927. leftthreetimes: "\u22cb",
  928. LeftTriangleBar: "\u29cf",
  929. LeftTriangle: "\u22b2",
  930. LeftTriangleEqual: "\u22b4",
  931. LeftUpDownVector: "\u2951",
  932. LeftUpTeeVector: "\u2960",
  933. LeftUpVectorBar: "\u2958",
  934. LeftUpVector: "\u21bf",
  935. LeftVectorBar: "\u2952",
  936. LeftVector: "\u21bc",
  937. lEg: "\u2a8b",
  938. leg: "\u22da",
  939. leq: "\u2264",
  940. leqq: "\u2266",
  941. leqslant: "\u2a7d",
  942. lescc: "\u2aa8",
  943. les: "\u2a7d",
  944. lesdot: "\u2a7f",
  945. lesdoto: "\u2a81",
  946. lesdotor: "\u2a83",
  947. lesg: "\u22da\ufe00",
  948. lesges: "\u2a93",
  949. lessapprox: "\u2a85",
  950. lessdot: "\u22d6",
  951. lesseqgtr: "\u22da",
  952. lesseqqgtr: "\u2a8b",
  953. LessEqualGreater: "\u22da",
  954. LessFullEqual: "\u2266",
  955. LessGreater: "\u2276",
  956. lessgtr: "\u2276",
  957. LessLess: "\u2aa1",
  958. lesssim: "\u2272",
  959. LessSlantEqual: "\u2a7d",
  960. LessTilde: "\u2272",
  961. lfisht: "\u297c",
  962. lfloor: "\u230a",
  963. Lfr: "\ud835\udd0f",
  964. lfr: "\ud835\udd29",
  965. lg: "\u2276",
  966. lgE: "\u2a91",
  967. lHar: "\u2962",
  968. lhard: "\u21bd",
  969. lharu: "\u21bc",
  970. lharul: "\u296a",
  971. lhblk: "\u2584",
  972. LJcy: "\u0409",
  973. ljcy: "\u0459",
  974. llarr: "\u21c7",
  975. ll: "\u226a",
  976. Ll: "\u22d8",
  977. llcorner: "\u231e",
  978. Lleftarrow: "\u21da",
  979. llhard: "\u296b",
  980. lltri: "\u25fa",
  981. Lmidot: "\u013f",
  982. lmidot: "\u0140",
  983. lmoustache: "\u23b0",
  984. lmoust: "\u23b0",
  985. lnap: "\u2a89",
  986. lnapprox: "\u2a89",
  987. lne: "\u2a87",
  988. lnE: "\u2268",
  989. lneq: "\u2a87",
  990. lneqq: "\u2268",
  991. lnsim: "\u22e6",
  992. loang: "\u27ec",
  993. loarr: "\u21fd",
  994. lobrk: "\u27e6",
  995. longleftarrow: "\u27f5",
  996. LongLeftArrow: "\u27f5",
  997. Longleftarrow: "\u27f8",
  998. longleftrightarrow: "\u27f7",
  999. LongLeftRightArrow: "\u27f7",
  1000. Longleftrightarrow: "\u27fa",
  1001. longmapsto: "\u27fc",
  1002. longrightarrow: "\u27f6",
  1003. LongRightArrow: "\u27f6",
  1004. Longrightarrow: "\u27f9",
  1005. looparrowleft: "\u21ab",
  1006. looparrowright: "\u21ac",
  1007. lopar: "\u2985",
  1008. Lopf: "\ud835\udd43",
  1009. lopf: "\ud835\udd5d",
  1010. loplus: "\u2a2d",
  1011. lotimes: "\u2a34",
  1012. lowast: "\u2217",
  1013. lowbar: "_",
  1014. LowerLeftArrow: "\u2199",
  1015. LowerRightArrow: "\u2198",
  1016. loz: "\u25ca",
  1017. lozenge: "\u25ca",
  1018. lozf: "\u29eb",
  1019. lpar: "(",
  1020. lparlt: "\u2993",
  1021. lrarr: "\u21c6",
  1022. lrcorner: "\u231f",
  1023. lrhar: "\u21cb",
  1024. lrhard: "\u296d",
  1025. lrm: "\u200e",
  1026. lrtri: "\u22bf",
  1027. lsaquo: "\u2039",
  1028. lscr: "\ud835\udcc1",
  1029. Lscr: "\u2112",
  1030. lsh: "\u21b0",
  1031. Lsh: "\u21b0",
  1032. lsim: "\u2272",
  1033. lsime: "\u2a8d",
  1034. lsimg: "\u2a8f",
  1035. lsqb: "[",
  1036. lsquo: "\u2018",
  1037. lsquor: "\u201a",
  1038. Lstrok: "\u0141",
  1039. lstrok: "\u0142",
  1040. ltcc: "\u2aa6",
  1041. ltcir: "\u2a79",
  1042. lt: "<",
  1043. LT: "<",
  1044. Lt: "\u226a",
  1045. ltdot: "\u22d6",
  1046. lthree: "\u22cb",
  1047. ltimes: "\u22c9",
  1048. ltlarr: "\u2976",
  1049. ltquest: "\u2a7b",
  1050. ltri: "\u25c3",
  1051. ltrie: "\u22b4",
  1052. ltrif: "\u25c2",
  1053. ltrPar: "\u2996",
  1054. lurdshar: "\u294a",
  1055. luruhar: "\u2966",
  1056. lvertneqq: "\u2268\ufe00",
  1057. lvnE: "\u2268\ufe00",
  1058. macr: "\xaf",
  1059. male: "\u2642",
  1060. malt: "\u2720",
  1061. maltese: "\u2720",
  1062. Map: "\u2905",
  1063. map: "\u21a6",
  1064. mapsto: "\u21a6",
  1065. mapstodown: "\u21a7",
  1066. mapstoleft: "\u21a4",
  1067. mapstoup: "\u21a5",
  1068. marker: "\u25ae",
  1069. mcomma: "\u2a29",
  1070. Mcy: "\u041c",
  1071. mcy: "\u043c",
  1072. mdash: "\u2014",
  1073. mDDot: "\u223a",
  1074. measuredangle: "\u2221",
  1075. MediumSpace: "\u205f",
  1076. Mellintrf: "\u2133",
  1077. Mfr: "\ud835\udd10",
  1078. mfr: "\ud835\udd2a",
  1079. mho: "\u2127",
  1080. micro: "\xb5",
  1081. midast: "*",
  1082. midcir: "\u2af0",
  1083. mid: "\u2223",
  1084. middot: "\xb7",
  1085. minusb: "\u229f",
  1086. minus: "\u2212",
  1087. minusd: "\u2238",
  1088. minusdu: "\u2a2a",
  1089. MinusPlus: "\u2213",
  1090. mlcp: "\u2adb",
  1091. mldr: "\u2026",
  1092. mnplus: "\u2213",
  1093. models: "\u22a7",
  1094. Mopf: "\ud835\udd44",
  1095. mopf: "\ud835\udd5e",
  1096. mp: "\u2213",
  1097. mscr: "\ud835\udcc2",
  1098. Mscr: "\u2133",
  1099. mstpos: "\u223e",
  1100. Mu: "\u039c",
  1101. mu: "\u03bc",
  1102. multimap: "\u22b8",
  1103. mumap: "\u22b8",
  1104. nabla: "\u2207",
  1105. Nacute: "\u0143",
  1106. nacute: "\u0144",
  1107. nang: "\u2220\u20d2",
  1108. nap: "\u2249",
  1109. napE: "\u2a70\u0338",
  1110. napid: "\u224b\u0338",
  1111. napos: "\u0149",
  1112. napprox: "\u2249",
  1113. natural: "\u266e",
  1114. naturals: "\u2115",
  1115. natur: "\u266e",
  1116. nbsp: "\xa0",
  1117. nbump: "\u224e\u0338",
  1118. nbumpe: "\u224f\u0338",
  1119. ncap: "\u2a43",
  1120. Ncaron: "\u0147",
  1121. ncaron: "\u0148",
  1122. Ncedil: "\u0145",
  1123. ncedil: "\u0146",
  1124. ncong: "\u2247",
  1125. ncongdot: "\u2a6d\u0338",
  1126. ncup: "\u2a42",
  1127. Ncy: "\u041d",
  1128. ncy: "\u043d",
  1129. ndash: "\u2013",
  1130. nearhk: "\u2924",
  1131. nearr: "\u2197",
  1132. neArr: "\u21d7",
  1133. nearrow: "\u2197",
  1134. ne: "\u2260",
  1135. nedot: "\u2250\u0338",
  1136. NegativeMediumSpace: "\u200b",
  1137. NegativeThickSpace: "\u200b",
  1138. NegativeThinSpace: "\u200b",
  1139. NegativeVeryThinSpace: "\u200b",
  1140. nequiv: "\u2262",
  1141. nesear: "\u2928",
  1142. nesim: "\u2242\u0338",
  1143. NestedGreaterGreater: "\u226b",
  1144. NestedLessLess: "\u226a",
  1145. NewLine: "\n",
  1146. nexist: "\u2204",
  1147. nexists: "\u2204",
  1148. Nfr: "\ud835\udd11",
  1149. nfr: "\ud835\udd2b",
  1150. ngE: "\u2267\u0338",
  1151. nge: "\u2271",
  1152. ngeq: "\u2271",
  1153. ngeqq: "\u2267\u0338",
  1154. ngeqslant: "\u2a7e\u0338",
  1155. nges: "\u2a7e\u0338",
  1156. nGg: "\u22d9\u0338",
  1157. ngsim: "\u2275",
  1158. nGt: "\u226b\u20d2",
  1159. ngt: "\u226f",
  1160. ngtr: "\u226f",
  1161. nGtv: "\u226b\u0338",
  1162. nharr: "\u21ae",
  1163. nhArr: "\u21ce",
  1164. nhpar: "\u2af2",
  1165. ni: "\u220b",
  1166. nis: "\u22fc",
  1167. nisd: "\u22fa",
  1168. niv: "\u220b",
  1169. NJcy: "\u040a",
  1170. njcy: "\u045a",
  1171. nlarr: "\u219a",
  1172. nlArr: "\u21cd",
  1173. nldr: "\u2025",
  1174. nlE: "\u2266\u0338",
  1175. nle: "\u2270",
  1176. nleftarrow: "\u219a",
  1177. nLeftarrow: "\u21cd",
  1178. nleftrightarrow: "\u21ae",
  1179. nLeftrightarrow: "\u21ce",
  1180. nleq: "\u2270",
  1181. nleqq: "\u2266\u0338",
  1182. nleqslant: "\u2a7d\u0338",
  1183. nles: "\u2a7d\u0338",
  1184. nless: "\u226e",
  1185. nLl: "\u22d8\u0338",
  1186. nlsim: "\u2274",
  1187. nLt: "\u226a\u20d2",
  1188. nlt: "\u226e",
  1189. nltri: "\u22ea",
  1190. nltrie: "\u22ec",
  1191. nLtv: "\u226a\u0338",
  1192. nmid: "\u2224",
  1193. NoBreak: "\u2060",
  1194. NonBreakingSpace: "\xa0",
  1195. nopf: "\ud835\udd5f",
  1196. Nopf: "\u2115",
  1197. Not: "\u2aec",
  1198. not: "\xac",
  1199. NotCongruent: "\u2262",
  1200. NotCupCap: "\u226d",
  1201. NotDoubleVerticalBar: "\u2226",
  1202. NotElement: "\u2209",
  1203. NotEqual: "\u2260",
  1204. NotEqualTilde: "\u2242\u0338",
  1205. NotExists: "\u2204",
  1206. NotGreater: "\u226f",
  1207. NotGreaterEqual: "\u2271",
  1208. NotGreaterFullEqual: "\u2267\u0338",
  1209. NotGreaterGreater: "\u226b\u0338",
  1210. NotGreaterLess: "\u2279",
  1211. NotGreaterSlantEqual: "\u2a7e\u0338",
  1212. NotGreaterTilde: "\u2275",
  1213. NotHumpDownHump: "\u224e\u0338",
  1214. NotHumpEqual: "\u224f\u0338",
  1215. notin: "\u2209",
  1216. notindot: "\u22f5\u0338",
  1217. notinE: "\u22f9\u0338",
  1218. notinva: "\u2209",
  1219. notinvb: "\u22f7",
  1220. notinvc: "\u22f6",
  1221. NotLeftTriangleBar: "\u29cf\u0338",
  1222. NotLeftTriangle: "\u22ea",
  1223. NotLeftTriangleEqual: "\u22ec",
  1224. NotLess: "\u226e",
  1225. NotLessEqual: "\u2270",
  1226. NotLessGreater: "\u2278",
  1227. NotLessLess: "\u226a\u0338",
  1228. NotLessSlantEqual: "\u2a7d\u0338",
  1229. NotLessTilde: "\u2274",
  1230. NotNestedGreaterGreater: "\u2aa2\u0338",
  1231. NotNestedLessLess: "\u2aa1\u0338",
  1232. notni: "\u220c",
  1233. notniva: "\u220c",
  1234. notnivb: "\u22fe",
  1235. notnivc: "\u22fd",
  1236. NotPrecedes: "\u2280",
  1237. NotPrecedesEqual: "\u2aaf\u0338",
  1238. NotPrecedesSlantEqual: "\u22e0",
  1239. NotReverseElement: "\u220c",
  1240. NotRightTriangleBar: "\u29d0\u0338",
  1241. NotRightTriangle: "\u22eb",
  1242. NotRightTriangleEqual: "\u22ed",
  1243. NotSquareSubset: "\u228f\u0338",
  1244. NotSquareSubsetEqual: "\u22e2",
  1245. NotSquareSuperset: "\u2290\u0338",
  1246. NotSquareSupersetEqual: "\u22e3",
  1247. NotSubset: "\u2282\u20d2",
  1248. NotSubsetEqual: "\u2288",
  1249. NotSucceeds: "\u2281",
  1250. NotSucceedsEqual: "\u2ab0\u0338",
  1251. NotSucceedsSlantEqual: "\u22e1",
  1252. NotSucceedsTilde: "\u227f\u0338",
  1253. NotSuperset: "\u2283\u20d2",
  1254. NotSupersetEqual: "\u2289",
  1255. NotTilde: "\u2241",
  1256. NotTildeEqual: "\u2244",
  1257. NotTildeFullEqual: "\u2247",
  1258. NotTildeTilde: "\u2249",
  1259. NotVerticalBar: "\u2224",
  1260. nparallel: "\u2226",
  1261. npar: "\u2226",
  1262. nparsl: "\u2afd\u20e5",
  1263. npart: "\u2202\u0338",
  1264. npolint: "\u2a14",
  1265. npr: "\u2280",
  1266. nprcue: "\u22e0",
  1267. nprec: "\u2280",
  1268. npreceq: "\u2aaf\u0338",
  1269. npre: "\u2aaf\u0338",
  1270. nrarrc: "\u2933\u0338",
  1271. nrarr: "\u219b",
  1272. nrArr: "\u21cf",
  1273. nrarrw: "\u219d\u0338",
  1274. nrightarrow: "\u219b",
  1275. nRightarrow: "\u21cf",
  1276. nrtri: "\u22eb",
  1277. nrtrie: "\u22ed",
  1278. nsc: "\u2281",
  1279. nsccue: "\u22e1",
  1280. nsce: "\u2ab0\u0338",
  1281. Nscr: "\ud835\udca9",
  1282. nscr: "\ud835\udcc3",
  1283. nshortmid: "\u2224",
  1284. nshortparallel: "\u2226",
  1285. nsim: "\u2241",
  1286. nsime: "\u2244",
  1287. nsimeq: "\u2244",
  1288. nsmid: "\u2224",
  1289. nspar: "\u2226",
  1290. nsqsube: "\u22e2",
  1291. nsqsupe: "\u22e3",
  1292. nsub: "\u2284",
  1293. nsubE: "\u2ac5\u0338",
  1294. nsube: "\u2288",
  1295. nsubset: "\u2282\u20d2",
  1296. nsubseteq: "\u2288",
  1297. nsubseteqq: "\u2ac5\u0338",
  1298. nsucc: "\u2281",
  1299. nsucceq: "\u2ab0\u0338",
  1300. nsup: "\u2285",
  1301. nsupE: "\u2ac6\u0338",
  1302. nsupe: "\u2289",
  1303. nsupset: "\u2283\u20d2",
  1304. nsupseteq: "\u2289",
  1305. nsupseteqq: "\u2ac6\u0338",
  1306. ntgl: "\u2279",
  1307. Ntilde: "\xd1",
  1308. ntilde: "\xf1",
  1309. ntlg: "\u2278",
  1310. ntriangleleft: "\u22ea",
  1311. ntrianglelefteq: "\u22ec",
  1312. ntriangleright: "\u22eb",
  1313. ntrianglerighteq: "\u22ed",
  1314. Nu: "\u039d",
  1315. nu: "\u03bd",
  1316. num: "#",
  1317. numero: "\u2116",
  1318. numsp: "\u2007",
  1319. nvap: "\u224d\u20d2",
  1320. nvdash: "\u22ac",
  1321. nvDash: "\u22ad",
  1322. nVdash: "\u22ae",
  1323. nVDash: "\u22af",
  1324. nvge: "\u2265\u20d2",
  1325. nvgt: ">\u20d2",
  1326. nvHarr: "\u2904",
  1327. nvinfin: "\u29de",
  1328. nvlArr: "\u2902",
  1329. nvle: "\u2264\u20d2",
  1330. nvlt: "<\u20d2",
  1331. nvltrie: "\u22b4\u20d2",
  1332. nvrArr: "\u2903",
  1333. nvrtrie: "\u22b5\u20d2",
  1334. nvsim: "\u223c\u20d2",
  1335. nwarhk: "\u2923",
  1336. nwarr: "\u2196",
  1337. nwArr: "\u21d6",
  1338. nwarrow: "\u2196",
  1339. nwnear: "\u2927",
  1340. Oacute: "\xd3",
  1341. oacute: "\xf3",
  1342. oast: "\u229b",
  1343. Ocirc: "\xd4",
  1344. ocirc: "\xf4",
  1345. ocir: "\u229a",
  1346. Ocy: "\u041e",
  1347. ocy: "\u043e",
  1348. odash: "\u229d",
  1349. Odblac: "\u0150",
  1350. odblac: "\u0151",
  1351. odiv: "\u2a38",
  1352. odot: "\u2299",
  1353. odsold: "\u29bc",
  1354. OElig: "\u0152",
  1355. oelig: "\u0153",
  1356. ofcir: "\u29bf",
  1357. Ofr: "\ud835\udd12",
  1358. ofr: "\ud835\udd2c",
  1359. ogon: "\u02db",
  1360. Ograve: "\xd2",
  1361. ograve: "\xf2",
  1362. ogt: "\u29c1",
  1363. ohbar: "\u29b5",
  1364. ohm: "\u03a9",
  1365. oint: "\u222e",
  1366. olarr: "\u21ba",
  1367. olcir: "\u29be",
  1368. olcross: "\u29bb",
  1369. oline: "\u203e",
  1370. olt: "\u29c0",
  1371. Omacr: "\u014c",
  1372. omacr: "\u014d",
  1373. Omega: "\u03a9",
  1374. omega: "\u03c9",
  1375. Omicron: "\u039f",
  1376. omicron: "\u03bf",
  1377. omid: "\u29b6",
  1378. ominus: "\u2296",
  1379. Oopf: "\ud835\udd46",
  1380. oopf: "\ud835\udd60",
  1381. opar: "\u29b7",
  1382. OpenCurlyDoubleQuote: "\u201c",
  1383. OpenCurlyQuote: "\u2018",
  1384. operp: "\u29b9",
  1385. oplus: "\u2295",
  1386. orarr: "\u21bb",
  1387. Or: "\u2a54",
  1388. or: "\u2228",
  1389. ord: "\u2a5d",
  1390. order: "\u2134",
  1391. orderof: "\u2134",
  1392. ordf: "\xaa",
  1393. ordm: "\xba",
  1394. origof: "\u22b6",
  1395. oror: "\u2a56",
  1396. orslope: "\u2a57",
  1397. orv: "\u2a5b",
  1398. oS: "\u24c8",
  1399. Oscr: "\ud835\udcaa",
  1400. oscr: "\u2134",
  1401. Oslash: "\xd8",
  1402. oslash: "\xf8",
  1403. osol: "\u2298",
  1404. Otilde: "\xd5",
  1405. otilde: "\xf5",
  1406. otimesas: "\u2a36",
  1407. Otimes: "\u2a37",
  1408. otimes: "\u2297",
  1409. Ouml: "\xd6",
  1410. ouml: "\xf6",
  1411. ovbar: "\u233d",
  1412. OverBar: "\u203e",
  1413. OverBrace: "\u23de",
  1414. OverBracket: "\u23b4",
  1415. OverParenthesis: "\u23dc",
  1416. para: "\xb6",
  1417. parallel: "\u2225",
  1418. par: "\u2225",
  1419. parsim: "\u2af3",
  1420. parsl: "\u2afd",
  1421. part: "\u2202",
  1422. PartialD: "\u2202",
  1423. Pcy: "\u041f",
  1424. pcy: "\u043f",
  1425. percnt: "%",
  1426. period: ".",
  1427. permil: "\u2030",
  1428. perp: "\u22a5",
  1429. pertenk: "\u2031",
  1430. Pfr: "\ud835\udd13",
  1431. pfr: "\ud835\udd2d",
  1432. Phi: "\u03a6",
  1433. phi: "\u03c6",
  1434. phiv: "\u03d5",
  1435. phmmat: "\u2133",
  1436. phone: "\u260e",
  1437. Pi: "\u03a0",
  1438. pi: "\u03c0",
  1439. pitchfork: "\u22d4",
  1440. piv: "\u03d6",
  1441. planck: "\u210f",
  1442. planckh: "\u210e",
  1443. plankv: "\u210f",
  1444. plusacir: "\u2a23",
  1445. plusb: "\u229e",
  1446. pluscir: "\u2a22",
  1447. plus: "+",
  1448. plusdo: "\u2214",
  1449. plusdu: "\u2a25",
  1450. pluse: "\u2a72",
  1451. PlusMinus: "\xb1",
  1452. plusmn: "\xb1",
  1453. plussim: "\u2a26",
  1454. plustwo: "\u2a27",
  1455. pm: "\xb1",
  1456. Poincareplane: "\u210c",
  1457. pointint: "\u2a15",
  1458. popf: "\ud835\udd61",
  1459. Popf: "\u2119",
  1460. pound: "\xa3",
  1461. prap: "\u2ab7",
  1462. Pr: "\u2abb",
  1463. pr: "\u227a",
  1464. prcue: "\u227c",
  1465. precapprox: "\u2ab7",
  1466. prec: "\u227a",
  1467. preccurlyeq: "\u227c",
  1468. Precedes: "\u227a",
  1469. PrecedesEqual: "\u2aaf",
  1470. PrecedesSlantEqual: "\u227c",
  1471. PrecedesTilde: "\u227e",
  1472. preceq: "\u2aaf",
  1473. precnapprox: "\u2ab9",
  1474. precneqq: "\u2ab5",
  1475. precnsim: "\u22e8",
  1476. pre: "\u2aaf",
  1477. prE: "\u2ab3",
  1478. precsim: "\u227e",
  1479. prime: "\u2032",
  1480. Prime: "\u2033",
  1481. primes: "\u2119",
  1482. prnap: "\u2ab9",
  1483. prnE: "\u2ab5",
  1484. prnsim: "\u22e8",
  1485. prod: "\u220f",
  1486. Product: "\u220f",
  1487. profalar: "\u232e",
  1488. profline: "\u2312",
  1489. profsurf: "\u2313",
  1490. prop: "\u221d",
  1491. Proportional: "\u221d",
  1492. Proportion: "\u2237",
  1493. propto: "\u221d",
  1494. prsim: "\u227e",
  1495. prurel: "\u22b0",
  1496. Pscr: "\ud835\udcab",
  1497. pscr: "\ud835\udcc5",
  1498. Psi: "\u03a8",
  1499. psi: "\u03c8",
  1500. puncsp: "\u2008",
  1501. Qfr: "\ud835\udd14",
  1502. qfr: "\ud835\udd2e",
  1503. qint: "\u2a0c",
  1504. qopf: "\ud835\udd62",
  1505. Qopf: "\u211a",
  1506. qprime: "\u2057",
  1507. Qscr: "\ud835\udcac",
  1508. qscr: "\ud835\udcc6",
  1509. quaternions: "\u210d",
  1510. quatint: "\u2a16",
  1511. quest: "?",
  1512. questeq: "\u225f",
  1513. quot: '"',
  1514. QUOT: '"',
  1515. rAarr: "\u21db",
  1516. race: "\u223d\u0331",
  1517. Racute: "\u0154",
  1518. racute: "\u0155",
  1519. radic: "\u221a",
  1520. raemptyv: "\u29b3",
  1521. rang: "\u27e9",
  1522. Rang: "\u27eb",
  1523. rangd: "\u2992",
  1524. range: "\u29a5",
  1525. rangle: "\u27e9",
  1526. raquo: "\xbb",
  1527. rarrap: "\u2975",
  1528. rarrb: "\u21e5",
  1529. rarrbfs: "\u2920",
  1530. rarrc: "\u2933",
  1531. rarr: "\u2192",
  1532. Rarr: "\u21a0",
  1533. rArr: "\u21d2",
  1534. rarrfs: "\u291e",
  1535. rarrhk: "\u21aa",
  1536. rarrlp: "\u21ac",
  1537. rarrpl: "\u2945",
  1538. rarrsim: "\u2974",
  1539. Rarrtl: "\u2916",
  1540. rarrtl: "\u21a3",
  1541. rarrw: "\u219d",
  1542. ratail: "\u291a",
  1543. rAtail: "\u291c",
  1544. ratio: "\u2236",
  1545. rationals: "\u211a",
  1546. rbarr: "\u290d",
  1547. rBarr: "\u290f",
  1548. RBarr: "\u2910",
  1549. rbbrk: "\u2773",
  1550. rbrace: "}",
  1551. rbrack: "]",
  1552. rbrke: "\u298c",
  1553. rbrksld: "\u298e",
  1554. rbrkslu: "\u2990",
  1555. Rcaron: "\u0158",
  1556. rcaron: "\u0159",
  1557. Rcedil: "\u0156",
  1558. rcedil: "\u0157",
  1559. rceil: "\u2309",
  1560. rcub: "}",
  1561. Rcy: "\u0420",
  1562. rcy: "\u0440",
  1563. rdca: "\u2937",
  1564. rdldhar: "\u2969",
  1565. rdquo: "\u201d",
  1566. rdquor: "\u201d",
  1567. rdsh: "\u21b3",
  1568. real: "\u211c",
  1569. realine: "\u211b",
  1570. realpart: "\u211c",
  1571. reals: "\u211d",
  1572. Re: "\u211c",
  1573. rect: "\u25ad",
  1574. reg: "\xae",
  1575. REG: "\xae",
  1576. ReverseElement: "\u220b",
  1577. ReverseEquilibrium: "\u21cb",
  1578. ReverseUpEquilibrium: "\u296f",
  1579. rfisht: "\u297d",
  1580. rfloor: "\u230b",
  1581. rfr: "\ud835\udd2f",
  1582. Rfr: "\u211c",
  1583. rHar: "\u2964",
  1584. rhard: "\u21c1",
  1585. rharu: "\u21c0",
  1586. rharul: "\u296c",
  1587. Rho: "\u03a1",
  1588. rho: "\u03c1",
  1589. rhov: "\u03f1",
  1590. RightAngleBracket: "\u27e9",
  1591. RightArrowBar: "\u21e5",
  1592. rightarrow: "\u2192",
  1593. RightArrow: "\u2192",
  1594. Rightarrow: "\u21d2",
  1595. RightArrowLeftArrow: "\u21c4",
  1596. rightarrowtail: "\u21a3",
  1597. RightCeiling: "\u2309",
  1598. RightDoubleBracket: "\u27e7",
  1599. RightDownTeeVector: "\u295d",
  1600. RightDownVectorBar: "\u2955",
  1601. RightDownVector: "\u21c2",
  1602. RightFloor: "\u230b",
  1603. rightharpoondown: "\u21c1",
  1604. rightharpoonup: "\u21c0",
  1605. rightleftarrows: "\u21c4",
  1606. rightleftharpoons: "\u21cc",
  1607. rightrightarrows: "\u21c9",
  1608. rightsquigarrow: "\u219d",
  1609. RightTeeArrow: "\u21a6",
  1610. RightTee: "\u22a2",
  1611. RightTeeVector: "\u295b",
  1612. rightthreetimes: "\u22cc",
  1613. RightTriangleBar: "\u29d0",
  1614. RightTriangle: "\u22b3",
  1615. RightTriangleEqual: "\u22b5",
  1616. RightUpDownVector: "\u294f",
  1617. RightUpTeeVector: "\u295c",
  1618. RightUpVectorBar: "\u2954",
  1619. RightUpVector: "\u21be",
  1620. RightVectorBar: "\u2953",
  1621. RightVector: "\u21c0",
  1622. ring: "\u02da",
  1623. risingdotseq: "\u2253",
  1624. rlarr: "\u21c4",
  1625. rlhar: "\u21cc",
  1626. rlm: "\u200f",
  1627. rmoustache: "\u23b1",
  1628. rmoust: "\u23b1",
  1629. rnmid: "\u2aee",
  1630. roang: "\u27ed",
  1631. roarr: "\u21fe",
  1632. robrk: "\u27e7",
  1633. ropar: "\u2986",
  1634. ropf: "\ud835\udd63",
  1635. Ropf: "\u211d",
  1636. roplus: "\u2a2e",
  1637. rotimes: "\u2a35",
  1638. RoundImplies: "\u2970",
  1639. rpar: ")",
  1640. rpargt: "\u2994",
  1641. rppolint: "\u2a12",
  1642. rrarr: "\u21c9",
  1643. Rrightarrow: "\u21db",
  1644. rsaquo: "\u203a",
  1645. rscr: "\ud835\udcc7",
  1646. Rscr: "\u211b",
  1647. rsh: "\u21b1",
  1648. Rsh: "\u21b1",
  1649. rsqb: "]",
  1650. rsquo: "\u2019",
  1651. rsquor: "\u2019",
  1652. rthree: "\u22cc",
  1653. rtimes: "\u22ca",
  1654. rtri: "\u25b9",
  1655. rtrie: "\u22b5",
  1656. rtrif: "\u25b8",
  1657. rtriltri: "\u29ce",
  1658. RuleDelayed: "\u29f4",
  1659. ruluhar: "\u2968",
  1660. rx: "\u211e",
  1661. Sacute: "\u015a",
  1662. sacute: "\u015b",
  1663. sbquo: "\u201a",
  1664. scap: "\u2ab8",
  1665. Scaron: "\u0160",
  1666. scaron: "\u0161",
  1667. Sc: "\u2abc",
  1668. sc: "\u227b",
  1669. sccue: "\u227d",
  1670. sce: "\u2ab0",
  1671. scE: "\u2ab4",
  1672. Scedil: "\u015e",
  1673. scedil: "\u015f",
  1674. Scirc: "\u015c",
  1675. scirc: "\u015d",
  1676. scnap: "\u2aba",
  1677. scnE: "\u2ab6",
  1678. scnsim: "\u22e9",
  1679. scpolint: "\u2a13",
  1680. scsim: "\u227f",
  1681. Scy: "\u0421",
  1682. scy: "\u0441",
  1683. sdotb: "\u22a1",
  1684. sdot: "\u22c5",
  1685. sdote: "\u2a66",
  1686. searhk: "\u2925",
  1687. searr: "\u2198",
  1688. seArr: "\u21d8",
  1689. searrow: "\u2198",
  1690. sect: "\xa7",
  1691. semi: ";",
  1692. seswar: "\u2929",
  1693. setminus: "\u2216",
  1694. setmn: "\u2216",
  1695. sext: "\u2736",
  1696. Sfr: "\ud835\udd16",
  1697. sfr: "\ud835\udd30",
  1698. sfrown: "\u2322",
  1699. sharp: "\u266f",
  1700. SHCHcy: "\u0429",
  1701. shchcy: "\u0449",
  1702. SHcy: "\u0428",
  1703. shcy: "\u0448",
  1704. ShortDownArrow: "\u2193",
  1705. ShortLeftArrow: "\u2190",
  1706. shortmid: "\u2223",
  1707. shortparallel: "\u2225",
  1708. ShortRightArrow: "\u2192",
  1709. ShortUpArrow: "\u2191",
  1710. shy: "\xad",
  1711. Sigma: "\u03a3",
  1712. sigma: "\u03c3",
  1713. sigmaf: "\u03c2",
  1714. sigmav: "\u03c2",
  1715. sim: "\u223c",
  1716. simdot: "\u2a6a",
  1717. sime: "\u2243",
  1718. simeq: "\u2243",
  1719. simg: "\u2a9e",
  1720. simgE: "\u2aa0",
  1721. siml: "\u2a9d",
  1722. simlE: "\u2a9f",
  1723. simne: "\u2246",
  1724. simplus: "\u2a24",
  1725. simrarr: "\u2972",
  1726. slarr: "\u2190",
  1727. SmallCircle: "\u2218",
  1728. smallsetminus: "\u2216",
  1729. smashp: "\u2a33",
  1730. smeparsl: "\u29e4",
  1731. smid: "\u2223",
  1732. smile: "\u2323",
  1733. smt: "\u2aaa",
  1734. smte: "\u2aac",
  1735. smtes: "\u2aac\ufe00",
  1736. SOFTcy: "\u042c",
  1737. softcy: "\u044c",
  1738. solbar: "\u233f",
  1739. solb: "\u29c4",
  1740. sol: "/",
  1741. Sopf: "\ud835\udd4a",
  1742. sopf: "\ud835\udd64",
  1743. spades: "\u2660",
  1744. spadesuit: "\u2660",
  1745. spar: "\u2225",
  1746. sqcap: "\u2293",
  1747. sqcaps: "\u2293\ufe00",
  1748. sqcup: "\u2294",
  1749. sqcups: "\u2294\ufe00",
  1750. Sqrt: "\u221a",
  1751. sqsub: "\u228f",
  1752. sqsube: "\u2291",
  1753. sqsubset: "\u228f",
  1754. sqsubseteq: "\u2291",
  1755. sqsup: "\u2290",
  1756. sqsupe: "\u2292",
  1757. sqsupset: "\u2290",
  1758. sqsupseteq: "\u2292",
  1759. square: "\u25a1",
  1760. Square: "\u25a1",
  1761. SquareIntersection: "\u2293",
  1762. SquareSubset: "\u228f",
  1763. SquareSubsetEqual: "\u2291",
  1764. SquareSuperset: "\u2290",
  1765. SquareSupersetEqual: "\u2292",
  1766. SquareUnion: "\u2294",
  1767. squarf: "\u25aa",
  1768. squ: "\u25a1",
  1769. squf: "\u25aa",
  1770. srarr: "\u2192",
  1771. Sscr: "\ud835\udcae",
  1772. sscr: "\ud835\udcc8",
  1773. ssetmn: "\u2216",
  1774. ssmile: "\u2323",
  1775. sstarf: "\u22c6",
  1776. Star: "\u22c6",
  1777. star: "\u2606",
  1778. starf: "\u2605",
  1779. straightepsilon: "\u03f5",
  1780. straightphi: "\u03d5",
  1781. strns: "\xaf",
  1782. sub: "\u2282",
  1783. Sub: "\u22d0",
  1784. subdot: "\u2abd",
  1785. subE: "\u2ac5",
  1786. sube: "\u2286",
  1787. subedot: "\u2ac3",
  1788. submult: "\u2ac1",
  1789. subnE: "\u2acb",
  1790. subne: "\u228a",
  1791. subplus: "\u2abf",
  1792. subrarr: "\u2979",
  1793. subset: "\u2282",
  1794. Subset: "\u22d0",
  1795. subseteq: "\u2286",
  1796. subseteqq: "\u2ac5",
  1797. SubsetEqual: "\u2286",
  1798. subsetneq: "\u228a",
  1799. subsetneqq: "\u2acb",
  1800. subsim: "\u2ac7",
  1801. subsub: "\u2ad5",
  1802. subsup: "\u2ad3",
  1803. succapprox: "\u2ab8",
  1804. succ: "\u227b",
  1805. succcurlyeq: "\u227d",
  1806. Succeeds: "\u227b",
  1807. SucceedsEqual: "\u2ab0",
  1808. SucceedsSlantEqual: "\u227d",
  1809. SucceedsTilde: "\u227f",
  1810. succeq: "\u2ab0",
  1811. succnapprox: "\u2aba",
  1812. succneqq: "\u2ab6",
  1813. succnsim: "\u22e9",
  1814. succsim: "\u227f",
  1815. SuchThat: "\u220b",
  1816. sum: "\u2211",
  1817. Sum: "\u2211",
  1818. sung: "\u266a",
  1819. sup1: "\xb9",
  1820. sup2: "\xb2",
  1821. sup3: "\xb3",
  1822. sup: "\u2283",
  1823. Sup: "\u22d1",
  1824. supdot: "\u2abe",
  1825. supdsub: "\u2ad8",
  1826. supE: "\u2ac6",
  1827. supe: "\u2287",
  1828. supedot: "\u2ac4",
  1829. Superset: "\u2283",
  1830. SupersetEqual: "\u2287",
  1831. suphsol: "\u27c9",
  1832. suphsub: "\u2ad7",
  1833. suplarr: "\u297b",
  1834. supmult: "\u2ac2",
  1835. supnE: "\u2acc",
  1836. supne: "\u228b",
  1837. supplus: "\u2ac0",
  1838. supset: "\u2283",
  1839. Supset: "\u22d1",
  1840. supseteq: "\u2287",
  1841. supseteqq: "\u2ac6",
  1842. supsetneq: "\u228b",
  1843. supsetneqq: "\u2acc",
  1844. supsim: "\u2ac8",
  1845. supsub: "\u2ad4",
  1846. supsup: "\u2ad6",
  1847. swarhk: "\u2926",
  1848. swarr: "\u2199",
  1849. swArr: "\u21d9",
  1850. swarrow: "\u2199",
  1851. swnwar: "\u292a",
  1852. szlig: "\xdf",
  1853. Tab: "\t",
  1854. target: "\u2316",
  1855. Tau: "\u03a4",
  1856. tau: "\u03c4",
  1857. tbrk: "\u23b4",
  1858. Tcaron: "\u0164",
  1859. tcaron: "\u0165",
  1860. Tcedil: "\u0162",
  1861. tcedil: "\u0163",
  1862. Tcy: "\u0422",
  1863. tcy: "\u0442",
  1864. tdot: "\u20db",
  1865. telrec: "\u2315",
  1866. Tfr: "\ud835\udd17",
  1867. tfr: "\ud835\udd31",
  1868. there4: "\u2234",
  1869. therefore: "\u2234",
  1870. Therefore: "\u2234",
  1871. Theta: "\u0398",
  1872. theta: "\u03b8",
  1873. thetasym: "\u03d1",
  1874. thetav: "\u03d1",
  1875. thickapprox: "\u2248",
  1876. thicksim: "\u223c",
  1877. ThickSpace: "\u205f\u200a",
  1878. ThinSpace: "\u2009",
  1879. thinsp: "\u2009",
  1880. thkap: "\u2248",
  1881. thksim: "\u223c",
  1882. THORN: "\xde",
  1883. thorn: "\xfe",
  1884. tilde: "\u02dc",
  1885. Tilde: "\u223c",
  1886. TildeEqual: "\u2243",
  1887. TildeFullEqual: "\u2245",
  1888. TildeTilde: "\u2248",
  1889. timesbar: "\u2a31",
  1890. timesb: "\u22a0",
  1891. times: "\xd7",
  1892. timesd: "\u2a30",
  1893. tint: "\u222d",
  1894. toea: "\u2928",
  1895. topbot: "\u2336",
  1896. topcir: "\u2af1",
  1897. top: "\u22a4",
  1898. Topf: "\ud835\udd4b",
  1899. topf: "\ud835\udd65",
  1900. topfork: "\u2ada",
  1901. tosa: "\u2929",
  1902. tprime: "\u2034",
  1903. trade: "\u2122",
  1904. TRADE: "\u2122",
  1905. triangle: "\u25b5",
  1906. triangledown: "\u25bf",
  1907. triangleleft: "\u25c3",
  1908. trianglelefteq: "\u22b4",
  1909. triangleq: "\u225c",
  1910. triangleright: "\u25b9",
  1911. trianglerighteq: "\u22b5",
  1912. tridot: "\u25ec",
  1913. trie: "\u225c",
  1914. triminus: "\u2a3a",
  1915. TripleDot: "\u20db",
  1916. triplus: "\u2a39",
  1917. trisb: "\u29cd",
  1918. tritime: "\u2a3b",
  1919. trpezium: "\u23e2",
  1920. Tscr: "\ud835\udcaf",
  1921. tscr: "\ud835\udcc9",
  1922. TScy: "\u0426",
  1923. tscy: "\u0446",
  1924. TSHcy: "\u040b",
  1925. tshcy: "\u045b",
  1926. Tstrok: "\u0166",
  1927. tstrok: "\u0167",
  1928. twixt: "\u226c",
  1929. twoheadleftarrow: "\u219e",
  1930. twoheadrightarrow: "\u21a0",
  1931. Uacute: "\xda",
  1932. uacute: "\xfa",
  1933. uarr: "\u2191",
  1934. Uarr: "\u219f",
  1935. uArr: "\u21d1",
  1936. Uarrocir: "\u2949",
  1937. Ubrcy: "\u040e",
  1938. ubrcy: "\u045e",
  1939. Ubreve: "\u016c",
  1940. ubreve: "\u016d",
  1941. Ucirc: "\xdb",
  1942. ucirc: "\xfb",
  1943. Ucy: "\u0423",
  1944. ucy: "\u0443",
  1945. udarr: "\u21c5",
  1946. Udblac: "\u0170",
  1947. udblac: "\u0171",
  1948. udhar: "\u296e",
  1949. ufisht: "\u297e",
  1950. Ufr: "\ud835\udd18",
  1951. ufr: "\ud835\udd32",
  1952. Ugrave: "\xd9",
  1953. ugrave: "\xf9",
  1954. uHar: "\u2963",
  1955. uharl: "\u21bf",
  1956. uharr: "\u21be",
  1957. uhblk: "\u2580",
  1958. ulcorn: "\u231c",
  1959. ulcorner: "\u231c",
  1960. ulcrop: "\u230f",
  1961. ultri: "\u25f8",
  1962. Umacr: "\u016a",
  1963. umacr: "\u016b",
  1964. uml: "\xa8",
  1965. UnderBar: "_",
  1966. UnderBrace: "\u23df",
  1967. UnderBracket: "\u23b5",
  1968. UnderParenthesis: "\u23dd",
  1969. Union: "\u22c3",
  1970. UnionPlus: "\u228e",
  1971. Uogon: "\u0172",
  1972. uogon: "\u0173",
  1973. Uopf: "\ud835\udd4c",
  1974. uopf: "\ud835\udd66",
  1975. UpArrowBar: "\u2912",
  1976. uparrow: "\u2191",
  1977. UpArrow: "\u2191",
  1978. Uparrow: "\u21d1",
  1979. UpArrowDownArrow: "\u21c5",
  1980. updownarrow: "\u2195",
  1981. UpDownArrow: "\u2195",
  1982. Updownarrow: "\u21d5",
  1983. UpEquilibrium: "\u296e",
  1984. upharpoonleft: "\u21bf",
  1985. upharpoonright: "\u21be",
  1986. uplus: "\u228e",
  1987. UpperLeftArrow: "\u2196",
  1988. UpperRightArrow: "\u2197",
  1989. upsi: "\u03c5",
  1990. Upsi: "\u03d2",
  1991. upsih: "\u03d2",
  1992. Upsilon: "\u03a5",
  1993. upsilon: "\u03c5",
  1994. UpTeeArrow: "\u21a5",
  1995. UpTee: "\u22a5",
  1996. upuparrows: "\u21c8",
  1997. urcorn: "\u231d",
  1998. urcorner: "\u231d",
  1999. urcrop: "\u230e",
  2000. Uring: "\u016e",
  2001. uring: "\u016f",
  2002. urtri: "\u25f9",
  2003. Uscr: "\ud835\udcb0",
  2004. uscr: "\ud835\udcca",
  2005. utdot: "\u22f0",
  2006. Utilde: "\u0168",
  2007. utilde: "\u0169",
  2008. utri: "\u25b5",
  2009. utrif: "\u25b4",
  2010. uuarr: "\u21c8",
  2011. Uuml: "\xdc",
  2012. uuml: "\xfc",
  2013. uwangle: "\u29a7",
  2014. vangrt: "\u299c",
  2015. varepsilon: "\u03f5",
  2016. varkappa: "\u03f0",
  2017. varnothing: "\u2205",
  2018. varphi: "\u03d5",
  2019. varpi: "\u03d6",
  2020. varpropto: "\u221d",
  2021. varr: "\u2195",
  2022. vArr: "\u21d5",
  2023. varrho: "\u03f1",
  2024. varsigma: "\u03c2",
  2025. varsubsetneq: "\u228a\ufe00",
  2026. varsubsetneqq: "\u2acb\ufe00",
  2027. varsupsetneq: "\u228b\ufe00",
  2028. varsupsetneqq: "\u2acc\ufe00",
  2029. vartheta: "\u03d1",
  2030. vartriangleleft: "\u22b2",
  2031. vartriangleright: "\u22b3",
  2032. vBar: "\u2ae8",
  2033. Vbar: "\u2aeb",
  2034. vBarv: "\u2ae9",
  2035. Vcy: "\u0412",
  2036. vcy: "\u0432",
  2037. vdash: "\u22a2",
  2038. vDash: "\u22a8",
  2039. Vdash: "\u22a9",
  2040. VDash: "\u22ab",
  2041. Vdashl: "\u2ae6",
  2042. veebar: "\u22bb",
  2043. vee: "\u2228",
  2044. Vee: "\u22c1",
  2045. veeeq: "\u225a",
  2046. vellip: "\u22ee",
  2047. verbar: "|",
  2048. Verbar: "\u2016",
  2049. vert: "|",
  2050. Vert: "\u2016",
  2051. VerticalBar: "\u2223",
  2052. VerticalLine: "|",
  2053. VerticalSeparator: "\u2758",
  2054. VerticalTilde: "\u2240",
  2055. VeryThinSpace: "\u200a",
  2056. Vfr: "\ud835\udd19",
  2057. vfr: "\ud835\udd33",
  2058. vltri: "\u22b2",
  2059. vnsub: "\u2282\u20d2",
  2060. vnsup: "\u2283\u20d2",
  2061. Vopf: "\ud835\udd4d",
  2062. vopf: "\ud835\udd67",
  2063. vprop: "\u221d",
  2064. vrtri: "\u22b3",
  2065. Vscr: "\ud835\udcb1",
  2066. vscr: "\ud835\udccb",
  2067. vsubnE: "\u2acb\ufe00",
  2068. vsubne: "\u228a\ufe00",
  2069. vsupnE: "\u2acc\ufe00",
  2070. vsupne: "\u228b\ufe00",
  2071. Vvdash: "\u22aa",
  2072. vzigzag: "\u299a",
  2073. Wcirc: "\u0174",
  2074. wcirc: "\u0175",
  2075. wedbar: "\u2a5f",
  2076. wedge: "\u2227",
  2077. Wedge: "\u22c0",
  2078. wedgeq: "\u2259",
  2079. weierp: "\u2118",
  2080. Wfr: "\ud835\udd1a",
  2081. wfr: "\ud835\udd34",
  2082. Wopf: "\ud835\udd4e",
  2083. wopf: "\ud835\udd68",
  2084. wp: "\u2118",
  2085. wr: "\u2240",
  2086. wreath: "\u2240",
  2087. Wscr: "\ud835\udcb2",
  2088. wscr: "\ud835\udccc",
  2089. xcap: "\u22c2",
  2090. xcirc: "\u25ef",
  2091. xcup: "\u22c3",
  2092. xdtri: "\u25bd",
  2093. Xfr: "\ud835\udd1b",
  2094. xfr: "\ud835\udd35",
  2095. xharr: "\u27f7",
  2096. xhArr: "\u27fa",
  2097. Xi: "\u039e",
  2098. xi: "\u03be",
  2099. xlarr: "\u27f5",
  2100. xlArr: "\u27f8",
  2101. xmap: "\u27fc",
  2102. xnis: "\u22fb",
  2103. xodot: "\u2a00",
  2104. Xopf: "\ud835\udd4f",
  2105. xopf: "\ud835\udd69",
  2106. xoplus: "\u2a01",
  2107. xotime: "\u2a02",
  2108. xrarr: "\u27f6",
  2109. xrArr: "\u27f9",
  2110. Xscr: "\ud835\udcb3",
  2111. xscr: "\ud835\udccd",
  2112. xsqcup: "\u2a06",
  2113. xuplus: "\u2a04",
  2114. xutri: "\u25b3",
  2115. xvee: "\u22c1",
  2116. xwedge: "\u22c0",
  2117. Yacute: "\xdd",
  2118. yacute: "\xfd",
  2119. YAcy: "\u042f",
  2120. yacy: "\u044f",
  2121. Ycirc: "\u0176",
  2122. ycirc: "\u0177",
  2123. Ycy: "\u042b",
  2124. ycy: "\u044b",
  2125. yen: "\xa5",
  2126. Yfr: "\ud835\udd1c",
  2127. yfr: "\ud835\udd36",
  2128. YIcy: "\u0407",
  2129. yicy: "\u0457",
  2130. Yopf: "\ud835\udd50",
  2131. yopf: "\ud835\udd6a",
  2132. Yscr: "\ud835\udcb4",
  2133. yscr: "\ud835\udcce",
  2134. YUcy: "\u042e",
  2135. yucy: "\u044e",
  2136. yuml: "\xff",
  2137. Yuml: "\u0178",
  2138. Zacute: "\u0179",
  2139. zacute: "\u017a",
  2140. Zcaron: "\u017d",
  2141. zcaron: "\u017e",
  2142. Zcy: "\u0417",
  2143. zcy: "\u0437",
  2144. Zdot: "\u017b",
  2145. zdot: "\u017c",
  2146. zeetrf: "\u2128",
  2147. ZeroWidthSpace: "\u200b",
  2148. Zeta: "\u0396",
  2149. zeta: "\u03b6",
  2150. zfr: "\ud835\udd37",
  2151. Zfr: "\u2128",
  2152. ZHcy: "\u0416",
  2153. zhcy: "\u0436",
  2154. zigrarr: "\u21dd",
  2155. zopf: "\ud835\udd6b",
  2156. Zopf: "\u2124",
  2157. Zscr: "\ud835\udcb5",
  2158. zscr: "\ud835\udccf",
  2159. zwj: "\u200d",
  2160. zwnj: "\u200c"
  2161. };
  2162. /*eslint quotes:0*/ var entities = require$$0;
  2163. var regex$4 = /[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/;
  2164. var encodeCache = {};
  2165. // Create a lookup array where anything but characters in `chars` string
  2166. // and alphanumeric chars is percent-encoded.
  2167. function getEncodeCache(exclude) {
  2168. var i, ch, cache = encodeCache[exclude];
  2169. if (cache) {
  2170. return cache;
  2171. }
  2172. cache = encodeCache[exclude] = [];
  2173. for (i = 0; i < 128; i++) {
  2174. ch = String.fromCharCode(i);
  2175. if (/^[0-9a-z]$/i.test(ch)) {
  2176. // always allow unencoded alphanumeric characters
  2177. cache.push(ch);
  2178. } else {
  2179. cache.push("%" + ("0" + i.toString(16).toUpperCase()).slice(-2));
  2180. }
  2181. }
  2182. for (i = 0; i < exclude.length; i++) {
  2183. cache[exclude.charCodeAt(i)] = exclude[i];
  2184. }
  2185. return cache;
  2186. }
  2187. // Encode unsafe characters with percent-encoding, skipping already
  2188. // encoded sequences.
  2189. // - string - string to encode
  2190. // - exclude - list of characters to ignore (in addition to a-zA-Z0-9)
  2191. // - keepEscaped - don't encode '%' in a correct escape sequence (default: true)
  2192. function encode$2(string, exclude, keepEscaped) {
  2193. var i, l, code, nextCode, cache, result = "";
  2194. if (typeof exclude !== "string") {
  2195. // encode(string, keepEscaped)
  2196. keepEscaped = exclude;
  2197. exclude = encode$2.defaultChars;
  2198. }
  2199. if (typeof keepEscaped === "undefined") {
  2200. keepEscaped = true;
  2201. }
  2202. cache = getEncodeCache(exclude);
  2203. for (i = 0, l = string.length; i < l; i++) {
  2204. code = string.charCodeAt(i);
  2205. if (keepEscaped && code === 37 /* % */ && i + 2 < l) {
  2206. if (/^[0-9a-f]{2}$/i.test(string.slice(i + 1, i + 3))) {
  2207. result += string.slice(i, i + 3);
  2208. i += 2;
  2209. continue;
  2210. }
  2211. }
  2212. if (code < 128) {
  2213. result += cache[code];
  2214. continue;
  2215. }
  2216. if (code >= 55296 && code <= 57343) {
  2217. if (code >= 55296 && code <= 56319 && i + 1 < l) {
  2218. nextCode = string.charCodeAt(i + 1);
  2219. if (nextCode >= 56320 && nextCode <= 57343) {
  2220. result += encodeURIComponent(string[i] + string[i + 1]);
  2221. i++;
  2222. continue;
  2223. }
  2224. }
  2225. result += "%EF%BF%BD";
  2226. continue;
  2227. }
  2228. result += encodeURIComponent(string[i]);
  2229. }
  2230. return result;
  2231. }
  2232. encode$2.defaultChars = ";/?:@&=+$,-_.!~*'()#";
  2233. encode$2.componentChars = "-_.!~*'()";
  2234. var encode_1 = encode$2;
  2235. /* eslint-disable no-bitwise */ var decodeCache = {};
  2236. function getDecodeCache(exclude) {
  2237. var i, ch, cache = decodeCache[exclude];
  2238. if (cache) {
  2239. return cache;
  2240. }
  2241. cache = decodeCache[exclude] = [];
  2242. for (i = 0; i < 128; i++) {
  2243. ch = String.fromCharCode(i);
  2244. cache.push(ch);
  2245. }
  2246. for (i = 0; i < exclude.length; i++) {
  2247. ch = exclude.charCodeAt(i);
  2248. cache[ch] = "%" + ("0" + ch.toString(16).toUpperCase()).slice(-2);
  2249. }
  2250. return cache;
  2251. }
  2252. // Decode percent-encoded string.
  2253. function decode$2(string, exclude) {
  2254. var cache;
  2255. if (typeof exclude !== "string") {
  2256. exclude = decode$2.defaultChars;
  2257. }
  2258. cache = getDecodeCache(exclude);
  2259. return string.replace(/(%[a-f0-9]{2})+/gi, (function(seq) {
  2260. var i, l, b1, b2, b3, b4, chr, result = "";
  2261. for (i = 0, l = seq.length; i < l; i += 3) {
  2262. b1 = parseInt(seq.slice(i + 1, i + 3), 16);
  2263. if (b1 < 128) {
  2264. result += cache[b1];
  2265. continue;
  2266. }
  2267. if ((b1 & 224) === 192 && i + 3 < l) {
  2268. // 110xxxxx 10xxxxxx
  2269. b2 = parseInt(seq.slice(i + 4, i + 6), 16);
  2270. if ((b2 & 192) === 128) {
  2271. chr = b1 << 6 & 1984 | b2 & 63;
  2272. if (chr < 128) {
  2273. result += "\ufffd\ufffd";
  2274. } else {
  2275. result += String.fromCharCode(chr);
  2276. }
  2277. i += 3;
  2278. continue;
  2279. }
  2280. }
  2281. if ((b1 & 240) === 224 && i + 6 < l) {
  2282. // 1110xxxx 10xxxxxx 10xxxxxx
  2283. b2 = parseInt(seq.slice(i + 4, i + 6), 16);
  2284. b3 = parseInt(seq.slice(i + 7, i + 9), 16);
  2285. if ((b2 & 192) === 128 && (b3 & 192) === 128) {
  2286. chr = b1 << 12 & 61440 | b2 << 6 & 4032 | b3 & 63;
  2287. if (chr < 2048 || chr >= 55296 && chr <= 57343) {
  2288. result += "\ufffd\ufffd\ufffd";
  2289. } else {
  2290. result += String.fromCharCode(chr);
  2291. }
  2292. i += 6;
  2293. continue;
  2294. }
  2295. }
  2296. if ((b1 & 248) === 240 && i + 9 < l) {
  2297. // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx
  2298. b2 = parseInt(seq.slice(i + 4, i + 6), 16);
  2299. b3 = parseInt(seq.slice(i + 7, i + 9), 16);
  2300. b4 = parseInt(seq.slice(i + 10, i + 12), 16);
  2301. if ((b2 & 192) === 128 && (b3 & 192) === 128 && (b4 & 192) === 128) {
  2302. chr = b1 << 18 & 1835008 | b2 << 12 & 258048 | b3 << 6 & 4032 | b4 & 63;
  2303. if (chr < 65536 || chr > 1114111) {
  2304. result += "\ufffd\ufffd\ufffd\ufffd";
  2305. } else {
  2306. chr -= 65536;
  2307. result += String.fromCharCode(55296 + (chr >> 10), 56320 + (chr & 1023));
  2308. }
  2309. i += 9;
  2310. continue;
  2311. }
  2312. }
  2313. result += "\ufffd";
  2314. }
  2315. return result;
  2316. }));
  2317. }
  2318. decode$2.defaultChars = ";/?:@&=+$,#";
  2319. decode$2.componentChars = "";
  2320. var decode_1 = decode$2;
  2321. var format$1 = function format(url) {
  2322. var result = "";
  2323. result += url.protocol || "";
  2324. result += url.slashes ? "//" : "";
  2325. result += url.auth ? url.auth + "@" : "";
  2326. if (url.hostname && url.hostname.indexOf(":") !== -1) {
  2327. // ipv6 address
  2328. result += "[" + url.hostname + "]";
  2329. } else {
  2330. result += url.hostname || "";
  2331. }
  2332. result += url.port ? ":" + url.port : "";
  2333. result += url.pathname || "";
  2334. result += url.search || "";
  2335. result += url.hash || "";
  2336. return result;
  2337. };
  2338. // Copyright Joyent, Inc. and other Node contributors.
  2339. // Changes from joyent/node:
  2340. // 1. No leading slash in paths,
  2341. // e.g. in `url.parse('http://foo?bar')` pathname is ``, not `/`
  2342. // 2. Backslashes are not replaced with slashes,
  2343. // so `http:\\example.org\` is treated like a relative path
  2344. // 3. Trailing colon is treated like a part of the path,
  2345. // i.e. in `http://example.org:foo` pathname is `:foo`
  2346. // 4. Nothing is URL-encoded in the resulting object,
  2347. // (in joyent/node some chars in auth and paths are encoded)
  2348. // 5. `url.parse()` does not have `parseQueryString` argument
  2349. // 6. Removed extraneous result properties: `host`, `path`, `query`, etc.,
  2350. // which can be constructed using other parts of the url.
  2351. function Url() {
  2352. this.protocol = null;
  2353. this.slashes = null;
  2354. this.auth = null;
  2355. this.port = null;
  2356. this.hostname = null;
  2357. this.hash = null;
  2358. this.search = null;
  2359. this.pathname = null;
  2360. }
  2361. // Reference: RFC 3986, RFC 1808, RFC 2396
  2362. // define these here so at least they only have to be
  2363. // compiled once on the first module load.
  2364. var protocolPattern = /^([a-z0-9.+-]+:)/i, portPattern = /:[0-9]*$/,
  2365. // Special case for a simple path URL
  2366. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  2367. // RFC 2396: characters reserved for delimiting URLs.
  2368. // We actually just auto-escape these.
  2369. delims = [ "<", ">", '"', "`", " ", "\r", "\n", "\t" ],
  2370. // RFC 2396: characters not allowed for various reasons.
  2371. unwise = [ "{", "}", "|", "\\", "^", "`" ].concat(delims),
  2372. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  2373. autoEscape = [ "'" ].concat(unwise),
  2374. // Characters that are never ever allowed in a hostname.
  2375. // Note that any invalid chars are also handled, but these
  2376. // are the ones that are *expected* to be seen, so we fast-path
  2377. // them.
  2378. nonHostChars = [ "%", "/", "?", ";", "#" ].concat(autoEscape), hostEndingChars = [ "/", "?", "#" ], hostnameMaxLen = 255, hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  2379. // protocols that can allow "unsafe" and "unwise" chars.
  2380. /* eslint-disable no-script-url */
  2381. // protocols that never have a hostname.
  2382. hostlessProtocol = {
  2383. javascript: true,
  2384. "javascript:": true
  2385. },
  2386. // protocols that always contain a // bit.
  2387. slashedProtocol = {
  2388. http: true,
  2389. https: true,
  2390. ftp: true,
  2391. gopher: true,
  2392. file: true,
  2393. "http:": true,
  2394. "https:": true,
  2395. "ftp:": true,
  2396. "gopher:": true,
  2397. "file:": true
  2398. };
  2399. /* eslint-enable no-script-url */ function urlParse(url, slashesDenoteHost) {
  2400. if (url && url instanceof Url) {
  2401. return url;
  2402. }
  2403. var u = new Url;
  2404. u.parse(url, slashesDenoteHost);
  2405. return u;
  2406. }
  2407. Url.prototype.parse = function(url, slashesDenoteHost) {
  2408. var i, l, lowerProto, hec, slashes, rest = url;
  2409. // trim before proceeding.
  2410. // This is to support parse stuff like " http://foo.com \n"
  2411. rest = rest.trim();
  2412. if (!slashesDenoteHost && url.split("#").length === 1) {
  2413. // Try fast path regexp
  2414. var simplePath = simplePathPattern.exec(rest);
  2415. if (simplePath) {
  2416. this.pathname = simplePath[1];
  2417. if (simplePath[2]) {
  2418. this.search = simplePath[2];
  2419. }
  2420. return this;
  2421. }
  2422. }
  2423. var proto = protocolPattern.exec(rest);
  2424. if (proto) {
  2425. proto = proto[0];
  2426. lowerProto = proto.toLowerCase();
  2427. this.protocol = proto;
  2428. rest = rest.substr(proto.length);
  2429. }
  2430. // figure out if it's got a host
  2431. // user@server is *always* interpreted as a hostname, and url
  2432. // resolution will treat //foo/bar as host=foo,path=bar because that's
  2433. // how the browser resolves relative URLs.
  2434. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  2435. slashes = rest.substr(0, 2) === "//";
  2436. if (slashes && !(proto && hostlessProtocol[proto])) {
  2437. rest = rest.substr(2);
  2438. this.slashes = true;
  2439. }
  2440. }
  2441. if (!hostlessProtocol[proto] && (slashes || proto && !slashedProtocol[proto])) {
  2442. // there's a hostname.
  2443. // the first instance of /, ?, ;, or # ends the host.
  2444. // If there is an @ in the hostname, then non-host chars *are* allowed
  2445. // to the left of the last @ sign, unless some host-ending character
  2446. // comes *before* the @-sign.
  2447. // URLs are obnoxious.
  2448. // ex:
  2449. // http://a@b@c/ => user:a@b host:c
  2450. // http://a@b?@c => user:a host:c path:/?@c
  2451. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  2452. // Review our test case against browsers more comprehensively.
  2453. // find the first instance of any hostEndingChars
  2454. var hostEnd = -1;
  2455. for (i = 0; i < hostEndingChars.length; i++) {
  2456. hec = rest.indexOf(hostEndingChars[i]);
  2457. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
  2458. hostEnd = hec;
  2459. }
  2460. }
  2461. // at this point, either we have an explicit point where the
  2462. // auth portion cannot go past, or the last @ char is the decider.
  2463. var auth, atSign;
  2464. if (hostEnd === -1) {
  2465. // atSign can be anywhere.
  2466. atSign = rest.lastIndexOf("@");
  2467. } else {
  2468. // atSign must be in auth portion.
  2469. // http://a@b/c@d => host:b auth:a path:/c@d
  2470. atSign = rest.lastIndexOf("@", hostEnd);
  2471. }
  2472. // Now we have a portion which is definitely the auth.
  2473. // Pull that off.
  2474. if (atSign !== -1) {
  2475. auth = rest.slice(0, atSign);
  2476. rest = rest.slice(atSign + 1);
  2477. this.auth = auth;
  2478. }
  2479. // the host is the remaining to the left of the first non-host char
  2480. hostEnd = -1;
  2481. for (i = 0; i < nonHostChars.length; i++) {
  2482. hec = rest.indexOf(nonHostChars[i]);
  2483. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
  2484. hostEnd = hec;
  2485. }
  2486. }
  2487. // if we still have not hit it, then the entire thing is a host.
  2488. if (hostEnd === -1) {
  2489. hostEnd = rest.length;
  2490. }
  2491. if (rest[hostEnd - 1] === ":") {
  2492. hostEnd--;
  2493. }
  2494. var host = rest.slice(0, hostEnd);
  2495. rest = rest.slice(hostEnd);
  2496. // pull out port.
  2497. this.parseHost(host);
  2498. // we've indicated that there is a hostname,
  2499. // so even if it's empty, it has to be present.
  2500. this.hostname = this.hostname || "";
  2501. // if hostname begins with [ and ends with ]
  2502. // assume that it's an IPv6 address.
  2503. var ipv6Hostname = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]";
  2504. // validate a little.
  2505. if (!ipv6Hostname) {
  2506. var hostparts = this.hostname.split(/\./);
  2507. for (i = 0, l = hostparts.length; i < l; i++) {
  2508. var part = hostparts[i];
  2509. if (!part) {
  2510. continue;
  2511. }
  2512. if (!part.match(hostnamePartPattern)) {
  2513. var newpart = "";
  2514. for (var j = 0, k = part.length; j < k; j++) {
  2515. if (part.charCodeAt(j) > 127) {
  2516. // we replace non-ASCII char with a temporary placeholder
  2517. // we need this to make sure size of hostname is not
  2518. // broken by replacing non-ASCII by nothing
  2519. newpart += "x";
  2520. } else {
  2521. newpart += part[j];
  2522. }
  2523. }
  2524. // we test again with ASCII char only
  2525. if (!newpart.match(hostnamePartPattern)) {
  2526. var validParts = hostparts.slice(0, i);
  2527. var notHost = hostparts.slice(i + 1);
  2528. var bit = part.match(hostnamePartStart);
  2529. if (bit) {
  2530. validParts.push(bit[1]);
  2531. notHost.unshift(bit[2]);
  2532. }
  2533. if (notHost.length) {
  2534. rest = notHost.join(".") + rest;
  2535. }
  2536. this.hostname = validParts.join(".");
  2537. break;
  2538. }
  2539. }
  2540. }
  2541. }
  2542. if (this.hostname.length > hostnameMaxLen) {
  2543. this.hostname = "";
  2544. }
  2545. // strip [ and ] from the hostname
  2546. // the host field still retains them, though
  2547. if (ipv6Hostname) {
  2548. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  2549. }
  2550. }
  2551. // chop off from the tail first.
  2552. var hash = rest.indexOf("#");
  2553. if (hash !== -1) {
  2554. // got a fragment string.
  2555. this.hash = rest.substr(hash);
  2556. rest = rest.slice(0, hash);
  2557. }
  2558. var qm = rest.indexOf("?");
  2559. if (qm !== -1) {
  2560. this.search = rest.substr(qm);
  2561. rest = rest.slice(0, qm);
  2562. }
  2563. if (rest) {
  2564. this.pathname = rest;
  2565. }
  2566. if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) {
  2567. this.pathname = "";
  2568. }
  2569. return this;
  2570. };
  2571. Url.prototype.parseHost = function(host) {
  2572. var port = portPattern.exec(host);
  2573. if (port) {
  2574. port = port[0];
  2575. if (port !== ":") {
  2576. this.port = port.substr(1);
  2577. }
  2578. host = host.substr(0, host.length - port.length);
  2579. }
  2580. if (host) {
  2581. this.hostname = host;
  2582. }
  2583. };
  2584. var parse$1 = urlParse;
  2585. var encode$1 = encode_1;
  2586. var decode$1 = decode_1;
  2587. var format = format$1;
  2588. var parse = parse$1;
  2589. var mdurl = {
  2590. encode: encode$1,
  2591. decode: decode$1,
  2592. format: format,
  2593. parse: parse
  2594. };
  2595. var regex$3 = /[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
  2596. var regex$2 = /[\0-\x1F\x7F-\x9F]/;
  2597. var regex$1 = /[\xAD\u0600-\u0605\u061C\u06DD\u070F\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/;
  2598. var regex = /[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;
  2599. var Any = regex$3;
  2600. var Cc = regex$2;
  2601. var Cf = regex$1;
  2602. var P = regex$4;
  2603. var Z = regex;
  2604. var uc_micro = {
  2605. Any: Any,
  2606. Cc: Cc,
  2607. Cf: Cf,
  2608. P: P,
  2609. Z: Z
  2610. };
  2611. var utils = createCommonjsModule((function(module, exports) {
  2612. function _class(obj) {
  2613. return Object.prototype.toString.call(obj);
  2614. }
  2615. function isString(obj) {
  2616. return _class(obj) === "[object String]";
  2617. }
  2618. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  2619. function has(object, key) {
  2620. return _hasOwnProperty.call(object, key);
  2621. }
  2622. // Merge objects
  2623. function assign(obj /*from1, from2, from3, ...*/) {
  2624. var sources = Array.prototype.slice.call(arguments, 1);
  2625. sources.forEach((function(source) {
  2626. if (!source) {
  2627. return;
  2628. }
  2629. if (typeof source !== "object") {
  2630. throw new TypeError(source + "must be object");
  2631. }
  2632. Object.keys(source).forEach((function(key) {
  2633. obj[key] = source[key];
  2634. }));
  2635. }));
  2636. return obj;
  2637. }
  2638. // Remove element from array and put another array at those position.
  2639. // Useful for some operations with tokens
  2640. function arrayReplaceAt(src, pos, newElements) {
  2641. return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1));
  2642. }
  2643. ////////////////////////////////////////////////////////////////////////////////
  2644. function isValidEntityCode(c) {
  2645. /*eslint no-bitwise:0*/
  2646. // broken sequence
  2647. if (c >= 55296 && c <= 57343) {
  2648. return false;
  2649. }
  2650. // never used
  2651. if (c >= 64976 && c <= 65007) {
  2652. return false;
  2653. }
  2654. if ((c & 65535) === 65535 || (c & 65535) === 65534) {
  2655. return false;
  2656. }
  2657. // control codes
  2658. if (c >= 0 && c <= 8) {
  2659. return false;
  2660. }
  2661. if (c === 11) {
  2662. return false;
  2663. }
  2664. if (c >= 14 && c <= 31) {
  2665. return false;
  2666. }
  2667. if (c >= 127 && c <= 159) {
  2668. return false;
  2669. }
  2670. // out of range
  2671. if (c > 1114111) {
  2672. return false;
  2673. }
  2674. return true;
  2675. }
  2676. function fromCodePoint(c) {
  2677. /*eslint no-bitwise:0*/
  2678. if (c > 65535) {
  2679. c -= 65536;
  2680. var surrogate1 = 55296 + (c >> 10), surrogate2 = 56320 + (c & 1023);
  2681. return String.fromCharCode(surrogate1, surrogate2);
  2682. }
  2683. return String.fromCharCode(c);
  2684. }
  2685. var UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g;
  2686. var ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi;
  2687. var UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + "|" + ENTITY_RE.source, "gi");
  2688. var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;
  2689. function replaceEntityPattern(match, name) {
  2690. var code;
  2691. if (has(entities, name)) {
  2692. return entities[name];
  2693. }
  2694. if (name.charCodeAt(0) === 35 /* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {
  2695. code = name[1].toLowerCase() === "x" ? parseInt(name.slice(2), 16) : parseInt(name.slice(1), 10);
  2696. if (isValidEntityCode(code)) {
  2697. return fromCodePoint(code);
  2698. }
  2699. }
  2700. return match;
  2701. }
  2702. /*function replaceEntities(str) {
  2703. if (str.indexOf('&') < 0) { return str; }
  2704. return str.replace(ENTITY_RE, replaceEntityPattern);
  2705. }*/ function unescapeMd(str) {
  2706. if (str.indexOf("\\") < 0) {
  2707. return str;
  2708. }
  2709. return str.replace(UNESCAPE_MD_RE, "$1");
  2710. }
  2711. function unescapeAll(str) {
  2712. if (str.indexOf("\\") < 0 && str.indexOf("&") < 0) {
  2713. return str;
  2714. }
  2715. return str.replace(UNESCAPE_ALL_RE, (function(match, escaped, entity) {
  2716. if (escaped) {
  2717. return escaped;
  2718. }
  2719. return replaceEntityPattern(match, entity);
  2720. }));
  2721. }
  2722. ////////////////////////////////////////////////////////////////////////////////
  2723. var HTML_ESCAPE_TEST_RE = /[&<>"]/;
  2724. var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;
  2725. var HTML_REPLACEMENTS = {
  2726. "&": "&amp;",
  2727. "<": "&lt;",
  2728. ">": "&gt;",
  2729. '"': "&quot;"
  2730. };
  2731. function replaceUnsafeChar(ch) {
  2732. return HTML_REPLACEMENTS[ch];
  2733. }
  2734. function escapeHtml(str) {
  2735. if (HTML_ESCAPE_TEST_RE.test(str)) {
  2736. return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
  2737. }
  2738. return str;
  2739. }
  2740. ////////////////////////////////////////////////////////////////////////////////
  2741. var REGEXP_ESCAPE_RE = /[.?*+^$[\]\\(){}|-]/g;
  2742. function escapeRE(str) {
  2743. return str.replace(REGEXP_ESCAPE_RE, "\\$&");
  2744. }
  2745. ////////////////////////////////////////////////////////////////////////////////
  2746. function isSpace(code) {
  2747. switch (code) {
  2748. case 9:
  2749. case 32:
  2750. return true;
  2751. }
  2752. return false;
  2753. }
  2754. // Zs (unicode class) || [\t\f\v\r\n]
  2755. function isWhiteSpace(code) {
  2756. if (code >= 8192 && code <= 8202) {
  2757. return true;
  2758. }
  2759. switch (code) {
  2760. case 9:
  2761. // \t
  2762. case 10:
  2763. // \n
  2764. case 11:
  2765. // \v
  2766. case 12:
  2767. // \f
  2768. case 13:
  2769. // \r
  2770. case 32:
  2771. case 160:
  2772. case 5760:
  2773. case 8239:
  2774. case 8287:
  2775. case 12288:
  2776. return true;
  2777. }
  2778. return false;
  2779. }
  2780. ////////////////////////////////////////////////////////////////////////////////
  2781. /*eslint-disable max-len*/
  2782. // Currently without astral characters support.
  2783. function isPunctChar(ch) {
  2784. return regex$4.test(ch);
  2785. }
  2786. // Markdown ASCII punctuation characters.
  2787. // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
  2788. // http://spec.commonmark.org/0.15/#ascii-punctuation-character
  2789. // Don't confuse with unicode punctuation !!! It lacks some chars in ascii range.
  2790. function isMdAsciiPunct(ch) {
  2791. switch (ch) {
  2792. case 33 /* ! */ :
  2793. case 34 /* " */ :
  2794. case 35 /* # */ :
  2795. case 36 /* $ */ :
  2796. case 37 /* % */ :
  2797. case 38 /* & */ :
  2798. case 39 /* ' */ :
  2799. case 40 /* ( */ :
  2800. case 41 /* ) */ :
  2801. case 42 /* * */ :
  2802. case 43 /* + */ :
  2803. case 44 /* , */ :
  2804. case 45 /* - */ :
  2805. case 46 /* . */ :
  2806. case 47 /* / */ :
  2807. case 58 /* : */ :
  2808. case 59 /* ; */ :
  2809. case 60 /* < */ :
  2810. case 61 /* = */ :
  2811. case 62 /* > */ :
  2812. case 63 /* ? */ :
  2813. case 64 /* @ */ :
  2814. case 91 /* [ */ :
  2815. case 92 /* \ */ :
  2816. case 93 /* ] */ :
  2817. case 94 /* ^ */ :
  2818. case 95 /* _ */ :
  2819. case 96 /* ` */ :
  2820. case 123 /* { */ :
  2821. case 124 /* | */ :
  2822. case 125 /* } */ :
  2823. case 126 /* ~ */ :
  2824. return true;
  2825. default:
  2826. return false;
  2827. }
  2828. }
  2829. // Hepler to unify [reference labels].
  2830. function normalizeReference(str) {
  2831. // Trim and collapse whitespace
  2832. str = str.trim().replace(/\s+/g, " ");
  2833. // In node v10 'ẞ'.toLowerCase() === 'Ṿ', which is presumed to be a bug
  2834. // fixed in v12 (couldn't find any details).
  2835. // So treat this one as a special case
  2836. // (remove this when node v10 is no longer supported).
  2837. if ("\u1e9e".toLowerCase() === "\u1e7e") {
  2838. str = str.replace(/\u1e9e/g, "\xdf");
  2839. }
  2840. // .toLowerCase().toUpperCase() should get rid of all differences
  2841. // between letter variants.
  2842. // Simple .toLowerCase() doesn't normalize 125 code points correctly,
  2843. // and .toUpperCase doesn't normalize 6 of them (list of exceptions:
  2844. // İ, ϴ, ẞ, Ω, K, Å - those are already uppercased, but have differently
  2845. // uppercased versions).
  2846. // Here's an example showing how it happens. Lets take greek letter omega:
  2847. // uppercase U+0398 (Θ), U+03f4 (ϴ) and lowercase U+03b8 (θ), U+03d1 (ϑ)
  2848. // Unicode entries:
  2849. // 0398;GREEK CAPITAL LETTER THETA;Lu;0;L;;;;;N;;;;03B8;
  2850. // 03B8;GREEK SMALL LETTER THETA;Ll;0;L;;;;;N;;;0398;;0398
  2851. // 03D1;GREEK THETA SYMBOL;Ll;0;L;<compat> 03B8;;;;N;GREEK SMALL LETTER SCRIPT THETA;;0398;;0398
  2852. // 03F4;GREEK CAPITAL THETA SYMBOL;Lu;0;L;<compat> 0398;;;;N;;;;03B8;
  2853. // Case-insensitive comparison should treat all of them as equivalent.
  2854. // But .toLowerCase() doesn't change ϑ (it's already lowercase),
  2855. // and .toUpperCase() doesn't change ϴ (already uppercase).
  2856. // Applying first lower then upper case normalizes any character:
  2857. // '\u0398\u03f4\u03b8\u03d1'.toLowerCase().toUpperCase() === '\u0398\u0398\u0398\u0398'
  2858. // Note: this is equivalent to unicode case folding; unicode normalization
  2859. // is a different step that is not required here.
  2860. // Final result should be uppercased, because it's later stored in an object
  2861. // (this avoid a conflict with Object.prototype members,
  2862. // most notably, `__proto__`)
  2863. return str.toLowerCase().toUpperCase();
  2864. }
  2865. ////////////////////////////////////////////////////////////////////////////////
  2866. // Re-export libraries commonly used in both markdown-it and its plugins,
  2867. // so plugins won't have to depend on them explicitly, which reduces their
  2868. // bundled size (e.g. a browser build).
  2869. exports.lib = {};
  2870. exports.lib.mdurl = mdurl;
  2871. exports.lib.ucmicro = uc_micro;
  2872. exports.assign = assign;
  2873. exports.isString = isString;
  2874. exports.has = has;
  2875. exports.unescapeMd = unescapeMd;
  2876. exports.unescapeAll = unescapeAll;
  2877. exports.isValidEntityCode = isValidEntityCode;
  2878. exports.fromCodePoint = fromCodePoint;
  2879. // exports.replaceEntities = replaceEntities;
  2880. exports.escapeHtml = escapeHtml;
  2881. exports.arrayReplaceAt = arrayReplaceAt;
  2882. exports.isSpace = isSpace;
  2883. exports.isWhiteSpace = isWhiteSpace;
  2884. exports.isMdAsciiPunct = isMdAsciiPunct;
  2885. exports.isPunctChar = isPunctChar;
  2886. exports.escapeRE = escapeRE;
  2887. exports.normalizeReference = normalizeReference;
  2888. }));
  2889. // Parse link label
  2890. var parse_link_label = function parseLinkLabel(state, start, disableNested) {
  2891. var level, found, marker, prevPos, labelEnd = -1, max = state.posMax, oldPos = state.pos;
  2892. state.pos = start + 1;
  2893. level = 1;
  2894. while (state.pos < max) {
  2895. marker = state.src.charCodeAt(state.pos);
  2896. if (marker === 93 /* ] */) {
  2897. level--;
  2898. if (level === 0) {
  2899. found = true;
  2900. break;
  2901. }
  2902. }
  2903. prevPos = state.pos;
  2904. state.md.inline.skipToken(state);
  2905. if (marker === 91 /* [ */) {
  2906. if (prevPos === state.pos - 1) {
  2907. // increase level if we find text `[`, which is not a part of any token
  2908. level++;
  2909. } else if (disableNested) {
  2910. state.pos = oldPos;
  2911. return -1;
  2912. }
  2913. }
  2914. }
  2915. if (found) {
  2916. labelEnd = state.pos;
  2917. }
  2918. // restore old state
  2919. state.pos = oldPos;
  2920. return labelEnd;
  2921. };
  2922. var unescapeAll$2 = utils.unescapeAll;
  2923. var parse_link_destination = function parseLinkDestination(str, start, max) {
  2924. var code, level, pos = start, result = {
  2925. ok: false,
  2926. pos: 0,
  2927. lines: 0,
  2928. str: ""
  2929. };
  2930. if (str.charCodeAt(pos) === 60 /* < */) {
  2931. pos++;
  2932. while (pos < max) {
  2933. code = str.charCodeAt(pos);
  2934. if (code === 10 /* \n */) {
  2935. return result;
  2936. }
  2937. if (code === 60 /* < */) {
  2938. return result;
  2939. }
  2940. if (code === 62 /* > */) {
  2941. result.pos = pos + 1;
  2942. result.str = unescapeAll$2(str.slice(start + 1, pos));
  2943. result.ok = true;
  2944. return result;
  2945. }
  2946. if (code === 92 /* \ */ && pos + 1 < max) {
  2947. pos += 2;
  2948. continue;
  2949. }
  2950. pos++;
  2951. }
  2952. // no closing '>'
  2953. return result;
  2954. }
  2955. // this should be ... } else { ... branch
  2956. level = 0;
  2957. while (pos < max) {
  2958. code = str.charCodeAt(pos);
  2959. if (code === 32) {
  2960. break;
  2961. }
  2962. // ascii control characters
  2963. if (code < 32 || code === 127) {
  2964. break;
  2965. }
  2966. if (code === 92 /* \ */ && pos + 1 < max) {
  2967. if (str.charCodeAt(pos + 1) === 32) {
  2968. break;
  2969. }
  2970. pos += 2;
  2971. continue;
  2972. }
  2973. if (code === 40 /* ( */) {
  2974. level++;
  2975. if (level > 32) {
  2976. return result;
  2977. }
  2978. }
  2979. if (code === 41 /* ) */) {
  2980. if (level === 0) {
  2981. break;
  2982. }
  2983. level--;
  2984. }
  2985. pos++;
  2986. }
  2987. if (start === pos) {
  2988. return result;
  2989. }
  2990. if (level !== 0) {
  2991. return result;
  2992. }
  2993. result.str = unescapeAll$2(str.slice(start, pos));
  2994. result.pos = pos;
  2995. result.ok = true;
  2996. return result;
  2997. };
  2998. var unescapeAll$1 = utils.unescapeAll;
  2999. var parse_link_title = function parseLinkTitle(str, start, max) {
  3000. var code, marker, lines = 0, pos = start, result = {
  3001. ok: false,
  3002. pos: 0,
  3003. lines: 0,
  3004. str: ""
  3005. };
  3006. if (pos >= max) {
  3007. return result;
  3008. }
  3009. marker = str.charCodeAt(pos);
  3010. if (marker !== 34 /* " */ && marker !== 39 /* ' */ && marker !== 40 /* ( */) {
  3011. return result;
  3012. }
  3013. pos++;
  3014. // if opening marker is "(", switch it to closing marker ")"
  3015. if (marker === 40) {
  3016. marker = 41;
  3017. }
  3018. while (pos < max) {
  3019. code = str.charCodeAt(pos);
  3020. if (code === marker) {
  3021. result.pos = pos + 1;
  3022. result.lines = lines;
  3023. result.str = unescapeAll$1(str.slice(start + 1, pos));
  3024. result.ok = true;
  3025. return result;
  3026. } else if (code === 40 /* ( */ && marker === 41 /* ) */) {
  3027. return result;
  3028. } else if (code === 10) {
  3029. lines++;
  3030. } else if (code === 92 /* \ */ && pos + 1 < max) {
  3031. pos++;
  3032. if (str.charCodeAt(pos) === 10) {
  3033. lines++;
  3034. }
  3035. }
  3036. pos++;
  3037. }
  3038. return result;
  3039. };
  3040. var parseLinkLabel = parse_link_label;
  3041. var parseLinkDestination = parse_link_destination;
  3042. var parseLinkTitle = parse_link_title;
  3043. var helpers = {
  3044. parseLinkLabel: parseLinkLabel,
  3045. parseLinkDestination: parseLinkDestination,
  3046. parseLinkTitle: parseLinkTitle
  3047. };
  3048. var assign$1 = utils.assign;
  3049. var unescapeAll = utils.unescapeAll;
  3050. var escapeHtml = utils.escapeHtml;
  3051. ////////////////////////////////////////////////////////////////////////////////
  3052. var default_rules = {};
  3053. default_rules.code_inline = function(tokens, idx, options, env, slf) {
  3054. var token = tokens[idx];
  3055. return "<code" + slf.renderAttrs(token) + ">" + escapeHtml(token.content) + "</code>";
  3056. };
  3057. default_rules.code_block = function(tokens, idx, options, env, slf) {
  3058. var token = tokens[idx];
  3059. return "<pre" + slf.renderAttrs(token) + "><code>" + escapeHtml(tokens[idx].content) + "</code></pre>\n";
  3060. };
  3061. default_rules.fence = function(tokens, idx, options, env, slf) {
  3062. var token = tokens[idx], info = token.info ? unescapeAll(token.info).trim() : "", langName = "", langAttrs = "", highlighted, i, arr, tmpAttrs, tmpToken;
  3063. if (info) {
  3064. arr = info.split(/(\s+)/g);
  3065. langName = arr[0];
  3066. langAttrs = arr.slice(2).join("");
  3067. }
  3068. if (options.highlight) {
  3069. highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content);
  3070. } else {
  3071. highlighted = escapeHtml(token.content);
  3072. }
  3073. if (highlighted.indexOf("<pre") === 0) {
  3074. return highlighted + "\n";
  3075. }
  3076. // If language exists, inject class gently, without modifying original token.
  3077. // May be, one day we will add .deepClone() for token and simplify this part, but
  3078. // now we prefer to keep things local.
  3079. if (info) {
  3080. i = token.attrIndex("class");
  3081. tmpAttrs = token.attrs ? token.attrs.slice() : [];
  3082. if (i < 0) {
  3083. tmpAttrs.push([ "class", options.langPrefix + langName ]);
  3084. } else {
  3085. tmpAttrs[i] = tmpAttrs[i].slice();
  3086. tmpAttrs[i][1] += " " + options.langPrefix + langName;
  3087. }
  3088. // Fake token just to render attributes
  3089. tmpToken = {
  3090. attrs: tmpAttrs
  3091. };
  3092. return "<pre><code" + slf.renderAttrs(tmpToken) + ">" + highlighted + "</code></pre>\n";
  3093. }
  3094. return "<pre><code" + slf.renderAttrs(token) + ">" + highlighted + "</code></pre>\n";
  3095. };
  3096. default_rules.image = function(tokens, idx, options, env, slf) {
  3097. var token = tokens[idx];
  3098. // "alt" attr MUST be set, even if empty. Because it's mandatory and
  3099. // should be placed on proper position for tests.
  3100. // Replace content with actual value
  3101. token.attrs[token.attrIndex("alt")][1] = slf.renderInlineAsText(token.children, options, env);
  3102. return slf.renderToken(tokens, idx, options);
  3103. };
  3104. default_rules.hardbreak = function(tokens, idx, options /*, env */) {
  3105. return options.xhtmlOut ? "<br />\n" : "<br>\n";
  3106. };
  3107. default_rules.softbreak = function(tokens, idx, options /*, env */) {
  3108. return options.breaks ? options.xhtmlOut ? "<br />\n" : "<br>\n" : "\n";
  3109. };
  3110. default_rules.text = function(tokens, idx /*, options, env */) {
  3111. return escapeHtml(tokens[idx].content);
  3112. };
  3113. default_rules.html_block = function(tokens, idx /*, options, env */) {
  3114. return tokens[idx].content;
  3115. };
  3116. default_rules.html_inline = function(tokens, idx /*, options, env */) {
  3117. return tokens[idx].content;
  3118. };
  3119. /**
  3120. * new Renderer()
  3121. *
  3122. * Creates new [[Renderer]] instance and fill [[Renderer#rules]] with defaults.
  3123. **/ function Renderer() {
  3124. /**
  3125. * Renderer#rules -> Object
  3126. *
  3127. * Contains render rules for tokens. Can be updated and extended.
  3128. *
  3129. * ##### Example
  3130. *
  3131. * ```javascript
  3132. * var md = require('markdown-it')();
  3133. *
  3134. * md.renderer.rules.strong_open = function () { return '<b>'; };
  3135. * md.renderer.rules.strong_close = function () { return '</b>'; };
  3136. *
  3137. * var result = md.renderInline(...);
  3138. * ```
  3139. *
  3140. * Each rule is called as independent static function with fixed signature:
  3141. *
  3142. * ```javascript
  3143. * function my_token_render(tokens, idx, options, env, renderer) {
  3144. * // ...
  3145. * return renderedHTML;
  3146. * }
  3147. * ```
  3148. *
  3149. * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js)
  3150. * for more details and examples.
  3151. **/
  3152. this.rules = assign$1({}, default_rules);
  3153. }
  3154. /**
  3155. * Renderer.renderAttrs(token) -> String
  3156. *
  3157. * Render token attributes to string.
  3158. **/ Renderer.prototype.renderAttrs = function renderAttrs(token) {
  3159. var i, l, result;
  3160. if (!token.attrs) {
  3161. return "";
  3162. }
  3163. result = "";
  3164. for (i = 0, l = token.attrs.length; i < l; i++) {
  3165. result += " " + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
  3166. }
  3167. return result;
  3168. };
  3169. /**
  3170. * Renderer.renderToken(tokens, idx, options) -> String
  3171. * - tokens (Array): list of tokens
  3172. * - idx (Numbed): token index to render
  3173. * - options (Object): params of parser instance
  3174. *
  3175. * Default token renderer. Can be overriden by custom function
  3176. * in [[Renderer#rules]].
  3177. **/ Renderer.prototype.renderToken = function renderToken(tokens, idx, options) {
  3178. var nextToken, result = "", needLf = false, token = tokens[idx];
  3179. // Tight list paragraphs
  3180. if (token.hidden) {
  3181. return "";
  3182. }
  3183. // Insert a newline between hidden paragraph and subsequent opening
  3184. // block-level tag.
  3185. // For example, here we should insert a newline before blockquote:
  3186. // - a
  3187. // >
  3188. if (token.block && token.nesting !== -1 && idx && tokens[idx - 1].hidden) {
  3189. result += "\n";
  3190. }
  3191. // Add token name, e.g. `<img`
  3192. result += (token.nesting === -1 ? "</" : "<") + token.tag;
  3193. // Encode attributes, e.g. `<img src="foo"`
  3194. result += this.renderAttrs(token);
  3195. // Add a slash for self-closing tags, e.g. `<img src="foo" /`
  3196. if (token.nesting === 0 && options.xhtmlOut) {
  3197. result += " /";
  3198. }
  3199. // Check if we need to add a newline after this tag
  3200. if (token.block) {
  3201. needLf = true;
  3202. if (token.nesting === 1) {
  3203. if (idx + 1 < tokens.length) {
  3204. nextToken = tokens[idx + 1];
  3205. if (nextToken.type === "inline" || nextToken.hidden) {
  3206. // Block-level tag containing an inline tag.
  3207. needLf = false;
  3208. } else if (nextToken.nesting === -1 && nextToken.tag === token.tag) {
  3209. // Opening tag + closing tag of the same type. E.g. `<li></li>`.
  3210. needLf = false;
  3211. }
  3212. }
  3213. }
  3214. }
  3215. result += needLf ? ">\n" : ">";
  3216. return result;
  3217. };
  3218. /**
  3219. * Renderer.renderInline(tokens, options, env) -> String
  3220. * - tokens (Array): list on block tokens to render
  3221. * - options (Object): params of parser instance
  3222. * - env (Object): additional data from parsed input (references, for example)
  3223. *
  3224. * The same as [[Renderer.render]], but for single token of `inline` type.
  3225. **/ Renderer.prototype.renderInline = function(tokens, options, env) {
  3226. var type, result = "", rules = this.rules;
  3227. for (var i = 0, len = tokens.length; i < len; i++) {
  3228. type = tokens[i].type;
  3229. if (typeof rules[type] !== "undefined") {
  3230. result += rules[type](tokens, i, options, env, this);
  3231. } else {
  3232. result += this.renderToken(tokens, i, options);
  3233. }
  3234. }
  3235. return result;
  3236. };
  3237. /** internal
  3238. * Renderer.renderInlineAsText(tokens, options, env) -> String
  3239. * - tokens (Array): list on block tokens to render
  3240. * - options (Object): params of parser instance
  3241. * - env (Object): additional data from parsed input (references, for example)
  3242. *
  3243. * Special kludge for image `alt` attributes to conform CommonMark spec.
  3244. * Don't try to use it! Spec requires to show `alt` content with stripped markup,
  3245. * instead of simple escaping.
  3246. **/ Renderer.prototype.renderInlineAsText = function(tokens, options, env) {
  3247. var result = "";
  3248. for (var i = 0, len = tokens.length; i < len; i++) {
  3249. if (tokens[i].type === "text") {
  3250. result += tokens[i].content;
  3251. } else if (tokens[i].type === "image") {
  3252. result += this.renderInlineAsText(tokens[i].children, options, env);
  3253. } else if (tokens[i].type === "softbreak") {
  3254. result += "\n";
  3255. }
  3256. }
  3257. return result;
  3258. };
  3259. /**
  3260. * Renderer.render(tokens, options, env) -> String
  3261. * - tokens (Array): list on block tokens to render
  3262. * - options (Object): params of parser instance
  3263. * - env (Object): additional data from parsed input (references, for example)
  3264. *
  3265. * Takes token stream and generates HTML. Probably, you will never need to call
  3266. * this method directly.
  3267. **/ Renderer.prototype.render = function(tokens, options, env) {
  3268. var i, len, type, result = "", rules = this.rules;
  3269. for (i = 0, len = tokens.length; i < len; i++) {
  3270. type = tokens[i].type;
  3271. if (type === "inline") {
  3272. result += this.renderInline(tokens[i].children, options, env);
  3273. } else if (typeof rules[type] !== "undefined") {
  3274. result += rules[type](tokens, i, options, env, this);
  3275. } else {
  3276. result += this.renderToken(tokens, i, options, env);
  3277. }
  3278. }
  3279. return result;
  3280. };
  3281. var renderer = Renderer;
  3282. /**
  3283. * class Ruler
  3284. *
  3285. * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and
  3286. * [[MarkdownIt#inline]] to manage sequences of functions (rules):
  3287. *
  3288. * - keep rules in defined order
  3289. * - assign the name to each rule
  3290. * - enable/disable rules
  3291. * - add/replace rules
  3292. * - allow assign rules to additional named chains (in the same)
  3293. * - cacheing lists of active rules
  3294. *
  3295. * You will not need use this class directly until write plugins. For simple
  3296. * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and
  3297. * [[MarkdownIt.use]].
  3298. **/
  3299. /**
  3300. * new Ruler()
  3301. **/ function Ruler() {
  3302. // List of added rules. Each element is:
  3303. // {
  3304. // name: XXX,
  3305. // enabled: Boolean,
  3306. // fn: Function(),
  3307. // alt: [ name2, name3 ]
  3308. // }
  3309. this.__rules__ = [];
  3310. // Cached rule chains.
  3311. // First level - chain name, '' for default.
  3312. // Second level - diginal anchor for fast filtering by charcodes.
  3313. this.__cache__ = null;
  3314. }
  3315. ////////////////////////////////////////////////////////////////////////////////
  3316. // Helper methods, should not be used directly
  3317. // Find rule index by name
  3318. Ruler.prototype.__find__ = function(name) {
  3319. for (var i = 0; i < this.__rules__.length; i++) {
  3320. if (this.__rules__[i].name === name) {
  3321. return i;
  3322. }
  3323. }
  3324. return -1;
  3325. };
  3326. // Build rules lookup cache
  3327. Ruler.prototype.__compile__ = function() {
  3328. var self = this;
  3329. var chains = [ "" ];
  3330. // collect unique names
  3331. self.__rules__.forEach((function(rule) {
  3332. if (!rule.enabled) {
  3333. return;
  3334. }
  3335. rule.alt.forEach((function(altName) {
  3336. if (chains.indexOf(altName) < 0) {
  3337. chains.push(altName);
  3338. }
  3339. }));
  3340. }));
  3341. self.__cache__ = {};
  3342. chains.forEach((function(chain) {
  3343. self.__cache__[chain] = [];
  3344. self.__rules__.forEach((function(rule) {
  3345. if (!rule.enabled) {
  3346. return;
  3347. }
  3348. if (chain && rule.alt.indexOf(chain) < 0) {
  3349. return;
  3350. }
  3351. self.__cache__[chain].push(rule.fn);
  3352. }));
  3353. }));
  3354. };
  3355. /**
  3356. * Ruler.at(name, fn [, options])
  3357. * - name (String): rule name to replace.
  3358. * - fn (Function): new rule function.
  3359. * - options (Object): new rule options (not mandatory).
  3360. *
  3361. * Replace rule by name with new function & options. Throws error if name not
  3362. * found.
  3363. *
  3364. * ##### Options:
  3365. *
  3366. * - __alt__ - array with names of "alternate" chains.
  3367. *
  3368. * ##### Example
  3369. *
  3370. * Replace existing typographer replacement rule with new one:
  3371. *
  3372. * ```javascript
  3373. * var md = require('markdown-it')();
  3374. *
  3375. * md.core.ruler.at('replacements', function replace(state) {
  3376. * //...
  3377. * });
  3378. * ```
  3379. **/ Ruler.prototype.at = function(name, fn, options) {
  3380. var index = this.__find__(name);
  3381. var opt = options || {};
  3382. if (index === -1) {
  3383. throw new Error("Parser rule not found: " + name);
  3384. }
  3385. this.__rules__[index].fn = fn;
  3386. this.__rules__[index].alt = opt.alt || [];
  3387. this.__cache__ = null;
  3388. };
  3389. /**
  3390. * Ruler.before(beforeName, ruleName, fn [, options])
  3391. * - beforeName (String): new rule will be added before this one.
  3392. * - ruleName (String): name of added rule.
  3393. * - fn (Function): rule function.
  3394. * - options (Object): rule options (not mandatory).
  3395. *
  3396. * Add new rule to chain before one with given name. See also
  3397. * [[Ruler.after]], [[Ruler.push]].
  3398. *
  3399. * ##### Options:
  3400. *
  3401. * - __alt__ - array with names of "alternate" chains.
  3402. *
  3403. * ##### Example
  3404. *
  3405. * ```javascript
  3406. * var md = require('markdown-it')();
  3407. *
  3408. * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {
  3409. * //...
  3410. * });
  3411. * ```
  3412. **/ Ruler.prototype.before = function(beforeName, ruleName, fn, options) {
  3413. var index = this.__find__(beforeName);
  3414. var opt = options || {};
  3415. if (index === -1) {
  3416. throw new Error("Parser rule not found: " + beforeName);
  3417. }
  3418. this.__rules__.splice(index, 0, {
  3419. name: ruleName,
  3420. enabled: true,
  3421. fn: fn,
  3422. alt: opt.alt || []
  3423. });
  3424. this.__cache__ = null;
  3425. };
  3426. /**
  3427. * Ruler.after(afterName, ruleName, fn [, options])
  3428. * - afterName (String): new rule will be added after this one.
  3429. * - ruleName (String): name of added rule.
  3430. * - fn (Function): rule function.
  3431. * - options (Object): rule options (not mandatory).
  3432. *
  3433. * Add new rule to chain after one with given name. See also
  3434. * [[Ruler.before]], [[Ruler.push]].
  3435. *
  3436. * ##### Options:
  3437. *
  3438. * - __alt__ - array with names of "alternate" chains.
  3439. *
  3440. * ##### Example
  3441. *
  3442. * ```javascript
  3443. * var md = require('markdown-it')();
  3444. *
  3445. * md.inline.ruler.after('text', 'my_rule', function replace(state) {
  3446. * //...
  3447. * });
  3448. * ```
  3449. **/ Ruler.prototype.after = function(afterName, ruleName, fn, options) {
  3450. var index = this.__find__(afterName);
  3451. var opt = options || {};
  3452. if (index === -1) {
  3453. throw new Error("Parser rule not found: " + afterName);
  3454. }
  3455. this.__rules__.splice(index + 1, 0, {
  3456. name: ruleName,
  3457. enabled: true,
  3458. fn: fn,
  3459. alt: opt.alt || []
  3460. });
  3461. this.__cache__ = null;
  3462. };
  3463. /**
  3464. * Ruler.push(ruleName, fn [, options])
  3465. * - ruleName (String): name of added rule.
  3466. * - fn (Function): rule function.
  3467. * - options (Object): rule options (not mandatory).
  3468. *
  3469. * Push new rule to the end of chain. See also
  3470. * [[Ruler.before]], [[Ruler.after]].
  3471. *
  3472. * ##### Options:
  3473. *
  3474. * - __alt__ - array with names of "alternate" chains.
  3475. *
  3476. * ##### Example
  3477. *
  3478. * ```javascript
  3479. * var md = require('markdown-it')();
  3480. *
  3481. * md.core.ruler.push('my_rule', function replace(state) {
  3482. * //...
  3483. * });
  3484. * ```
  3485. **/ Ruler.prototype.push = function(ruleName, fn, options) {
  3486. var opt = options || {};
  3487. this.__rules__.push({
  3488. name: ruleName,
  3489. enabled: true,
  3490. fn: fn,
  3491. alt: opt.alt || []
  3492. });
  3493. this.__cache__ = null;
  3494. };
  3495. /**
  3496. * Ruler.enable(list [, ignoreInvalid]) -> Array
  3497. * - list (String|Array): list of rule names to enable.
  3498. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  3499. *
  3500. * Enable rules with given names. If any rule name not found - throw Error.
  3501. * Errors can be disabled by second param.
  3502. *
  3503. * Returns list of found rule names (if no exception happened).
  3504. *
  3505. * See also [[Ruler.disable]], [[Ruler.enableOnly]].
  3506. **/ Ruler.prototype.enable = function(list, ignoreInvalid) {
  3507. if (!Array.isArray(list)) {
  3508. list = [ list ];
  3509. }
  3510. var result = [];
  3511. // Search by name and enable
  3512. list.forEach((function(name) {
  3513. var idx = this.__find__(name);
  3514. if (idx < 0) {
  3515. if (ignoreInvalid) {
  3516. return;
  3517. }
  3518. throw new Error("Rules manager: invalid rule name " + name);
  3519. }
  3520. this.__rules__[idx].enabled = true;
  3521. result.push(name);
  3522. }), this);
  3523. this.__cache__ = null;
  3524. return result;
  3525. };
  3526. /**
  3527. * Ruler.enableOnly(list [, ignoreInvalid])
  3528. * - list (String|Array): list of rule names to enable (whitelist).
  3529. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  3530. *
  3531. * Enable rules with given names, and disable everything else. If any rule name
  3532. * not found - throw Error. Errors can be disabled by second param.
  3533. *
  3534. * See also [[Ruler.disable]], [[Ruler.enable]].
  3535. **/ Ruler.prototype.enableOnly = function(list, ignoreInvalid) {
  3536. if (!Array.isArray(list)) {
  3537. list = [ list ];
  3538. }
  3539. this.__rules__.forEach((function(rule) {
  3540. rule.enabled = false;
  3541. }));
  3542. this.enable(list, ignoreInvalid);
  3543. };
  3544. /**
  3545. * Ruler.disable(list [, ignoreInvalid]) -> Array
  3546. * - list (String|Array): list of rule names to disable.
  3547. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  3548. *
  3549. * Disable rules with given names. If any rule name not found - throw Error.
  3550. * Errors can be disabled by second param.
  3551. *
  3552. * Returns list of found rule names (if no exception happened).
  3553. *
  3554. * See also [[Ruler.enable]], [[Ruler.enableOnly]].
  3555. **/ Ruler.prototype.disable = function(list, ignoreInvalid) {
  3556. if (!Array.isArray(list)) {
  3557. list = [ list ];
  3558. }
  3559. var result = [];
  3560. // Search by name and disable
  3561. list.forEach((function(name) {
  3562. var idx = this.__find__(name);
  3563. if (idx < 0) {
  3564. if (ignoreInvalid) {
  3565. return;
  3566. }
  3567. throw new Error("Rules manager: invalid rule name " + name);
  3568. }
  3569. this.__rules__[idx].enabled = false;
  3570. result.push(name);
  3571. }), this);
  3572. this.__cache__ = null;
  3573. return result;
  3574. };
  3575. /**
  3576. * Ruler.getRules(chainName) -> Array
  3577. *
  3578. * Return array of active functions (rules) for given chain name. It analyzes
  3579. * rules configuration, compiles caches if not exists and returns result.
  3580. *
  3581. * Default chain name is `''` (empty string). It can't be skipped. That's
  3582. * done intentionally, to keep signature monomorphic for high speed.
  3583. **/ Ruler.prototype.getRules = function(chainName) {
  3584. if (this.__cache__ === null) {
  3585. this.__compile__();
  3586. }
  3587. // Chain can be empty, if rules disabled. But we still have to return Array.
  3588. return this.__cache__[chainName] || [];
  3589. };
  3590. var ruler = Ruler;
  3591. // Normalize input string
  3592. // https://spec.commonmark.org/0.29/#line-ending
  3593. var NEWLINES_RE = /\r\n?|\n/g;
  3594. var NULL_RE = /\0/g;
  3595. var normalize = function normalize(state) {
  3596. var str;
  3597. // Normalize newlines
  3598. str = state.src.replace(NEWLINES_RE, "\n");
  3599. // Replace NULL characters
  3600. str = str.replace(NULL_RE, "\ufffd");
  3601. state.src = str;
  3602. };
  3603. var block = function block(state) {
  3604. var token;
  3605. if (state.inlineMode) {
  3606. token = new state.Token("inline", "", 0);
  3607. token.content = state.src;
  3608. token.map = [ 0, 1 ];
  3609. token.children = [];
  3610. state.tokens.push(token);
  3611. } else {
  3612. state.md.block.parse(state.src, state.md, state.env, state.tokens);
  3613. }
  3614. };
  3615. var inline = function inline(state) {
  3616. var tokens = state.tokens, tok, i, l;
  3617. // Parse inlines
  3618. for (i = 0, l = tokens.length; i < l; i++) {
  3619. tok = tokens[i];
  3620. if (tok.type === "inline") {
  3621. state.md.inline.parse(tok.content, state.md, state.env, tok.children);
  3622. }
  3623. }
  3624. };
  3625. var arrayReplaceAt = utils.arrayReplaceAt;
  3626. function isLinkOpen$1(str) {
  3627. return /^<a[>\s]/i.test(str);
  3628. }
  3629. function isLinkClose$1(str) {
  3630. return /^<\/a\s*>/i.test(str);
  3631. }
  3632. var linkify$1 = function linkify(state) {
  3633. var i, j, l, tokens, token, currentToken, nodes, ln, text, pos, lastPos, level, htmlLinkLevel, url, fullUrl, urlText, blockTokens = state.tokens, links;
  3634. if (!state.md.options.linkify) {
  3635. return;
  3636. }
  3637. for (j = 0, l = blockTokens.length; j < l; j++) {
  3638. if (blockTokens[j].type !== "inline" || !state.md.linkify.pretest(blockTokens[j].content)) {
  3639. continue;
  3640. }
  3641. tokens = blockTokens[j].children;
  3642. htmlLinkLevel = 0;
  3643. // We scan from the end, to keep position when new tags added.
  3644. // Use reversed logic in links start/end match
  3645. for (i = tokens.length - 1; i >= 0; i--) {
  3646. currentToken = tokens[i];
  3647. // Skip content of markdown links
  3648. if (currentToken.type === "link_close") {
  3649. i--;
  3650. while (tokens[i].level !== currentToken.level && tokens[i].type !== "link_open") {
  3651. i--;
  3652. }
  3653. continue;
  3654. }
  3655. // Skip content of html tag links
  3656. if (currentToken.type === "html_inline") {
  3657. if (isLinkOpen$1(currentToken.content) && htmlLinkLevel > 0) {
  3658. htmlLinkLevel--;
  3659. }
  3660. if (isLinkClose$1(currentToken.content)) {
  3661. htmlLinkLevel++;
  3662. }
  3663. }
  3664. if (htmlLinkLevel > 0) {
  3665. continue;
  3666. }
  3667. if (currentToken.type === "text" && state.md.linkify.test(currentToken.content)) {
  3668. text = currentToken.content;
  3669. links = state.md.linkify.match(text);
  3670. // Now split string to nodes
  3671. nodes = [];
  3672. level = currentToken.level;
  3673. lastPos = 0;
  3674. // forbid escape sequence at the start of the string,
  3675. // this avoids http\://example.com/ from being linkified as
  3676. // http:<a href="//example.com/">//example.com/</a>
  3677. if (links.length > 0 && links[0].index === 0 && i > 0 && tokens[i - 1].type === "text_special") {
  3678. links = links.slice(1);
  3679. }
  3680. for (ln = 0; ln < links.length; ln++) {
  3681. url = links[ln].url;
  3682. fullUrl = state.md.normalizeLink(url);
  3683. if (!state.md.validateLink(fullUrl)) {
  3684. continue;
  3685. }
  3686. urlText = links[ln].text;
  3687. // Linkifier might send raw hostnames like "example.com", where url
  3688. // starts with domain name. So we prepend http:// in those cases,
  3689. // and remove it afterwards.
  3690. if (!links[ln].schema) {
  3691. urlText = state.md.normalizeLinkText("http://" + urlText).replace(/^http:\/\//, "");
  3692. } else if (links[ln].schema === "mailto:" && !/^mailto:/i.test(urlText)) {
  3693. urlText = state.md.normalizeLinkText("mailto:" + urlText).replace(/^mailto:/, "");
  3694. } else {
  3695. urlText = state.md.normalizeLinkText(urlText);
  3696. }
  3697. pos = links[ln].index;
  3698. if (pos > lastPos) {
  3699. token = new state.Token("text", "", 0);
  3700. token.content = text.slice(lastPos, pos);
  3701. token.level = level;
  3702. nodes.push(token);
  3703. }
  3704. token = new state.Token("link_open", "a", 1);
  3705. token.attrs = [ [ "href", fullUrl ] ];
  3706. token.level = level++;
  3707. token.markup = "linkify";
  3708. token.info = "auto";
  3709. nodes.push(token);
  3710. token = new state.Token("text", "", 0);
  3711. token.content = urlText;
  3712. token.level = level;
  3713. nodes.push(token);
  3714. token = new state.Token("link_close", "a", -1);
  3715. token.level = --level;
  3716. token.markup = "linkify";
  3717. token.info = "auto";
  3718. nodes.push(token);
  3719. lastPos = links[ln].lastIndex;
  3720. }
  3721. if (lastPos < text.length) {
  3722. token = new state.Token("text", "", 0);
  3723. token.content = text.slice(lastPos);
  3724. token.level = level;
  3725. nodes.push(token);
  3726. }
  3727. // replace current node
  3728. blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);
  3729. }
  3730. }
  3731. }
  3732. };
  3733. // Simple typographic replacements
  3734. // TODO:
  3735. // - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
  3736. // - multiplications 2 x 4 -> 2 × 4
  3737. var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
  3738. // Workaround for phantomjs - need regex without /g flag,
  3739. // or root check will fail every second time
  3740. var SCOPED_ABBR_TEST_RE = /\((c|tm|r)\)/i;
  3741. var SCOPED_ABBR_RE = /\((c|tm|r)\)/gi;
  3742. var SCOPED_ABBR = {
  3743. c: "\xa9",
  3744. r: "\xae",
  3745. tm: "\u2122"
  3746. };
  3747. function replaceFn(match, name) {
  3748. return SCOPED_ABBR[name.toLowerCase()];
  3749. }
  3750. function replace_scoped(inlineTokens) {
  3751. var i, token, inside_autolink = 0;
  3752. for (i = inlineTokens.length - 1; i >= 0; i--) {
  3753. token = inlineTokens[i];
  3754. if (token.type === "text" && !inside_autolink) {
  3755. token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn);
  3756. }
  3757. if (token.type === "link_open" && token.info === "auto") {
  3758. inside_autolink--;
  3759. }
  3760. if (token.type === "link_close" && token.info === "auto") {
  3761. inside_autolink++;
  3762. }
  3763. }
  3764. }
  3765. function replace_rare(inlineTokens) {
  3766. var i, token, inside_autolink = 0;
  3767. for (i = inlineTokens.length - 1; i >= 0; i--) {
  3768. token = inlineTokens[i];
  3769. if (token.type === "text" && !inside_autolink) {
  3770. if (RARE_RE.test(token.content)) {
  3771. token.content = token.content.replace(/\+-/g, "\xb1").replace(/\.{2,}/g, "\u2026").replace(/([?!])\u2026/g, "$1..").replace(/([?!]){4,}/g, "$1$1$1").replace(/,{2,}/g, ",").replace(/(^|[^-])---(?=[^-]|$)/gm, "$1\u2014").replace(/(^|\s)--(?=\s|$)/gm, "$1\u2013").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm, "$1\u2013");
  3772. }
  3773. }
  3774. if (token.type === "link_open" && token.info === "auto") {
  3775. inside_autolink--;
  3776. }
  3777. if (token.type === "link_close" && token.info === "auto") {
  3778. inside_autolink++;
  3779. }
  3780. }
  3781. }
  3782. var replacements = function replace(state) {
  3783. var blkIdx;
  3784. if (!state.md.options.typographer) {
  3785. return;
  3786. }
  3787. for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
  3788. if (state.tokens[blkIdx].type !== "inline") {
  3789. continue;
  3790. }
  3791. if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {
  3792. replace_scoped(state.tokens[blkIdx].children);
  3793. }
  3794. if (RARE_RE.test(state.tokens[blkIdx].content)) {
  3795. replace_rare(state.tokens[blkIdx].children);
  3796. }
  3797. }
  3798. };
  3799. var isWhiteSpace$1 = utils.isWhiteSpace;
  3800. var isPunctChar$1 = utils.isPunctChar;
  3801. var isMdAsciiPunct$1 = utils.isMdAsciiPunct;
  3802. var QUOTE_TEST_RE = /['"]/;
  3803. var QUOTE_RE = /['"]/g;
  3804. var APOSTROPHE = "\u2019";
  3805. /* ’ */ function replaceAt(str, index, ch) {
  3806. return str.slice(0, index) + ch + str.slice(index + 1);
  3807. }
  3808. function process_inlines(tokens, state) {
  3809. var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar, isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace, canOpen, canClose, j, isSingle, stack, openQuote, closeQuote;
  3810. stack = [];
  3811. for (i = 0; i < tokens.length; i++) {
  3812. token = tokens[i];
  3813. thisLevel = tokens[i].level;
  3814. for (j = stack.length - 1; j >= 0; j--) {
  3815. if (stack[j].level <= thisLevel) {
  3816. break;
  3817. }
  3818. }
  3819. stack.length = j + 1;
  3820. if (token.type !== "text") {
  3821. continue;
  3822. }
  3823. text = token.content;
  3824. pos = 0;
  3825. max = text.length;
  3826. /*eslint no-labels:0,block-scoped-var:0*/ OUTER: while (pos < max) {
  3827. QUOTE_RE.lastIndex = pos;
  3828. t = QUOTE_RE.exec(text);
  3829. if (!t) {
  3830. break;
  3831. }
  3832. canOpen = canClose = true;
  3833. pos = t.index + 1;
  3834. isSingle = t[0] === "'";
  3835. // Find previous character,
  3836. // default to space if it's the beginning of the line
  3837. lastChar = 32;
  3838. if (t.index - 1 >= 0) {
  3839. lastChar = text.charCodeAt(t.index - 1);
  3840. } else {
  3841. for (j = i - 1; j >= 0; j--) {
  3842. if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak") break;
  3843. // lastChar defaults to 0x20
  3844. if (!tokens[j].content) continue;
  3845. // should skip all tokens except 'text', 'html_inline' or 'code_inline'
  3846. lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
  3847. break;
  3848. }
  3849. }
  3850. // Find next character,
  3851. // default to space if it's the end of the line
  3852. nextChar = 32;
  3853. if (pos < max) {
  3854. nextChar = text.charCodeAt(pos);
  3855. } else {
  3856. for (j = i + 1; j < tokens.length; j++) {
  3857. if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak") break;
  3858. // nextChar defaults to 0x20
  3859. if (!tokens[j].content) continue;
  3860. // should skip all tokens except 'text', 'html_inline' or 'code_inline'
  3861. nextChar = tokens[j].content.charCodeAt(0);
  3862. break;
  3863. }
  3864. }
  3865. isLastPunctChar = isMdAsciiPunct$1(lastChar) || isPunctChar$1(String.fromCharCode(lastChar));
  3866. isNextPunctChar = isMdAsciiPunct$1(nextChar) || isPunctChar$1(String.fromCharCode(nextChar));
  3867. isLastWhiteSpace = isWhiteSpace$1(lastChar);
  3868. isNextWhiteSpace = isWhiteSpace$1(nextChar);
  3869. if (isNextWhiteSpace) {
  3870. canOpen = false;
  3871. } else if (isNextPunctChar) {
  3872. if (!(isLastWhiteSpace || isLastPunctChar)) {
  3873. canOpen = false;
  3874. }
  3875. }
  3876. if (isLastWhiteSpace) {
  3877. canClose = false;
  3878. } else if (isLastPunctChar) {
  3879. if (!(isNextWhiteSpace || isNextPunctChar)) {
  3880. canClose = false;
  3881. }
  3882. }
  3883. if (nextChar === 34 /* " */ && t[0] === '"') {
  3884. if (lastChar >= 48 /* 0 */ && lastChar <= 57 /* 9 */) {
  3885. // special case: 1"" - count first quote as an inch
  3886. canClose = canOpen = false;
  3887. }
  3888. }
  3889. if (canOpen && canClose) {
  3890. // Replace quotes in the middle of punctuation sequence, but not
  3891. // in the middle of the words, i.e.:
  3892. // 1. foo " bar " baz - not replaced
  3893. // 2. foo-"-bar-"-baz - replaced
  3894. // 3. foo"bar"baz - not replaced
  3895. canOpen = isLastPunctChar;
  3896. canClose = isNextPunctChar;
  3897. }
  3898. if (!canOpen && !canClose) {
  3899. // middle of word
  3900. if (isSingle) {
  3901. token.content = replaceAt(token.content, t.index, APOSTROPHE);
  3902. }
  3903. continue;
  3904. }
  3905. if (canClose) {
  3906. // this could be a closing quote, rewind the stack to get a match
  3907. for (j = stack.length - 1; j >= 0; j--) {
  3908. item = stack[j];
  3909. if (stack[j].level < thisLevel) {
  3910. break;
  3911. }
  3912. if (item.single === isSingle && stack[j].level === thisLevel) {
  3913. item = stack[j];
  3914. if (isSingle) {
  3915. openQuote = state.md.options.quotes[2];
  3916. closeQuote = state.md.options.quotes[3];
  3917. } else {
  3918. openQuote = state.md.options.quotes[0];
  3919. closeQuote = state.md.options.quotes[1];
  3920. }
  3921. // replace token.content *before* tokens[item.token].content,
  3922. // because, if they are pointing at the same token, replaceAt
  3923. // could mess up indices when quote length != 1
  3924. token.content = replaceAt(token.content, t.index, closeQuote);
  3925. tokens[item.token].content = replaceAt(tokens[item.token].content, item.pos, openQuote);
  3926. pos += closeQuote.length - 1;
  3927. if (item.token === i) {
  3928. pos += openQuote.length - 1;
  3929. }
  3930. text = token.content;
  3931. max = text.length;
  3932. stack.length = j;
  3933. continue OUTER;
  3934. }
  3935. }
  3936. }
  3937. if (canOpen) {
  3938. stack.push({
  3939. token: i,
  3940. pos: t.index,
  3941. single: isSingle,
  3942. level: thisLevel
  3943. });
  3944. } else if (canClose && isSingle) {
  3945. token.content = replaceAt(token.content, t.index, APOSTROPHE);
  3946. }
  3947. }
  3948. }
  3949. }
  3950. var smartquotes = function smartquotes(state) {
  3951. /*eslint max-depth:0*/
  3952. var blkIdx;
  3953. if (!state.md.options.typographer) {
  3954. return;
  3955. }
  3956. for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
  3957. if (state.tokens[blkIdx].type !== "inline" || !QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) {
  3958. continue;
  3959. }
  3960. process_inlines(state.tokens[blkIdx].children, state);
  3961. }
  3962. };
  3963. // Join raw text tokens with the rest of the text
  3964. var text_join = function text_join(state) {
  3965. var j, l, tokens, curr, max, last, blockTokens = state.tokens;
  3966. for (j = 0, l = blockTokens.length; j < l; j++) {
  3967. if (blockTokens[j].type !== "inline") continue;
  3968. tokens = blockTokens[j].children;
  3969. max = tokens.length;
  3970. for (curr = 0; curr < max; curr++) {
  3971. if (tokens[curr].type === "text_special") {
  3972. tokens[curr].type = "text";
  3973. }
  3974. }
  3975. for (curr = last = 0; curr < max; curr++) {
  3976. if (tokens[curr].type === "text" && curr + 1 < max && tokens[curr + 1].type === "text") {
  3977. // collapse two adjacent text nodes
  3978. tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
  3979. } else {
  3980. if (curr !== last) {
  3981. tokens[last] = tokens[curr];
  3982. }
  3983. last++;
  3984. }
  3985. }
  3986. if (curr !== last) {
  3987. tokens.length = last;
  3988. }
  3989. }
  3990. };
  3991. // Token class
  3992. /**
  3993. * class Token
  3994. **/
  3995. /**
  3996. * new Token(type, tag, nesting)
  3997. *
  3998. * Create new token and fill passed properties.
  3999. **/ function Token(type, tag, nesting) {
  4000. /**
  4001. * Token#type -> String
  4002. *
  4003. * Type of the token (string, e.g. "paragraph_open")
  4004. **/
  4005. this.type = type;
  4006. /**
  4007. * Token#tag -> String
  4008. *
  4009. * html tag name, e.g. "p"
  4010. **/ this.tag = tag;
  4011. /**
  4012. * Token#attrs -> Array
  4013. *
  4014. * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`
  4015. **/ this.attrs = null;
  4016. /**
  4017. * Token#map -> Array
  4018. *
  4019. * Source map info. Format: `[ line_begin, line_end ]`
  4020. **/ this.map = null;
  4021. /**
  4022. * Token#nesting -> Number
  4023. *
  4024. * Level change (number in {-1, 0, 1} set), where:
  4025. *
  4026. * - `1` means the tag is opening
  4027. * - `0` means the tag is self-closing
  4028. * - `-1` means the tag is closing
  4029. **/ this.nesting = nesting;
  4030. /**
  4031. * Token#level -> Number
  4032. *
  4033. * nesting level, the same as `state.level`
  4034. **/ this.level = 0;
  4035. /**
  4036. * Token#children -> Array
  4037. *
  4038. * An array of child nodes (inline and img tokens)
  4039. **/ this.children = null;
  4040. /**
  4041. * Token#content -> String
  4042. *
  4043. * In a case of self-closing tag (code, html, fence, etc.),
  4044. * it has contents of this tag.
  4045. **/ this.content = "";
  4046. /**
  4047. * Token#markup -> String
  4048. *
  4049. * '*' or '_' for emphasis, fence string for fence, etc.
  4050. **/ this.markup = "";
  4051. /**
  4052. * Token#info -> String
  4053. *
  4054. * Additional information:
  4055. *
  4056. * - Info string for "fence" tokens
  4057. * - The value "auto" for autolink "link_open" and "link_close" tokens
  4058. * - The string value of the item marker for ordered-list "list_item_open" tokens
  4059. **/ this.info = "";
  4060. /**
  4061. * Token#meta -> Object
  4062. *
  4063. * A place for plugins to store an arbitrary data
  4064. **/ this.meta = null;
  4065. /**
  4066. * Token#block -> Boolean
  4067. *
  4068. * True for block-level tokens, false for inline tokens.
  4069. * Used in renderer to calculate line breaks
  4070. **/ this.block = false;
  4071. /**
  4072. * Token#hidden -> Boolean
  4073. *
  4074. * If it's true, ignore this element when rendering. Used for tight lists
  4075. * to hide paragraphs.
  4076. **/ this.hidden = false;
  4077. }
  4078. /**
  4079. * Token.attrIndex(name) -> Number
  4080. *
  4081. * Search attribute index by name.
  4082. **/ Token.prototype.attrIndex = function attrIndex(name) {
  4083. var attrs, i, len;
  4084. if (!this.attrs) {
  4085. return -1;
  4086. }
  4087. attrs = this.attrs;
  4088. for (i = 0, len = attrs.length; i < len; i++) {
  4089. if (attrs[i][0] === name) {
  4090. return i;
  4091. }
  4092. }
  4093. return -1;
  4094. };
  4095. /**
  4096. * Token.attrPush(attrData)
  4097. *
  4098. * Add `[ name, value ]` attribute to list. Init attrs if necessary
  4099. **/ Token.prototype.attrPush = function attrPush(attrData) {
  4100. if (this.attrs) {
  4101. this.attrs.push(attrData);
  4102. } else {
  4103. this.attrs = [ attrData ];
  4104. }
  4105. };
  4106. /**
  4107. * Token.attrSet(name, value)
  4108. *
  4109. * Set `name` attribute to `value`. Override old value if exists.
  4110. **/ Token.prototype.attrSet = function attrSet(name, value) {
  4111. var idx = this.attrIndex(name), attrData = [ name, value ];
  4112. if (idx < 0) {
  4113. this.attrPush(attrData);
  4114. } else {
  4115. this.attrs[idx] = attrData;
  4116. }
  4117. };
  4118. /**
  4119. * Token.attrGet(name)
  4120. *
  4121. * Get the value of attribute `name`, or null if it does not exist.
  4122. **/ Token.prototype.attrGet = function attrGet(name) {
  4123. var idx = this.attrIndex(name), value = null;
  4124. if (idx >= 0) {
  4125. value = this.attrs[idx][1];
  4126. }
  4127. return value;
  4128. };
  4129. /**
  4130. * Token.attrJoin(name, value)
  4131. *
  4132. * Join value to existing attribute via space. Or create new attribute if not
  4133. * exists. Useful to operate with token classes.
  4134. **/ Token.prototype.attrJoin = function attrJoin(name, value) {
  4135. var idx = this.attrIndex(name);
  4136. if (idx < 0) {
  4137. this.attrPush([ name, value ]);
  4138. } else {
  4139. this.attrs[idx][1] = this.attrs[idx][1] + " " + value;
  4140. }
  4141. };
  4142. var token = Token;
  4143. function StateCore(src, md, env) {
  4144. this.src = src;
  4145. this.env = env;
  4146. this.tokens = [];
  4147. this.inlineMode = false;
  4148. this.md = md;
  4149. // link to parser instance
  4150. }
  4151. // re-export Token class to use in core rules
  4152. StateCore.prototype.Token = token;
  4153. var state_core = StateCore;
  4154. var _rules$2 = [ [ "normalize", normalize ], [ "block", block ], [ "inline", inline ], [ "linkify", linkify$1 ], [ "replacements", replacements ], [ "smartquotes", smartquotes ],
  4155. // `text_join` finds `text_special` tokens (for escape sequences)
  4156. // and joins them with the rest of the text
  4157. [ "text_join", text_join ] ];
  4158. /**
  4159. * new Core()
  4160. **/ function Core() {
  4161. /**
  4162. * Core#ruler -> Ruler
  4163. *
  4164. * [[Ruler]] instance. Keep configuration of core rules.
  4165. **/
  4166. this.ruler = new ruler;
  4167. for (var i = 0; i < _rules$2.length; i++) {
  4168. this.ruler.push(_rules$2[i][0], _rules$2[i][1]);
  4169. }
  4170. }
  4171. /**
  4172. * Core.process(state)
  4173. *
  4174. * Executes core chain rules.
  4175. **/ Core.prototype.process = function(state) {
  4176. var i, l, rules;
  4177. rules = this.ruler.getRules("");
  4178. for (i = 0, l = rules.length; i < l; i++) {
  4179. rules[i](state);
  4180. }
  4181. };
  4182. Core.prototype.State = state_core;
  4183. var parser_core = Core;
  4184. var isSpace$a = utils.isSpace;
  4185. function getLine(state, line) {
  4186. var pos = state.bMarks[line] + state.tShift[line], max = state.eMarks[line];
  4187. return state.src.slice(pos, max);
  4188. }
  4189. function escapedSplit(str) {
  4190. var result = [], pos = 0, max = str.length, ch, isEscaped = false, lastPos = 0, current = "";
  4191. ch = str.charCodeAt(pos);
  4192. while (pos < max) {
  4193. if (ch === 124 /* | */) {
  4194. if (!isEscaped) {
  4195. // pipe separating cells, '|'
  4196. result.push(current + str.substring(lastPos, pos));
  4197. current = "";
  4198. lastPos = pos + 1;
  4199. } else {
  4200. // escaped pipe, '\|'
  4201. current += str.substring(lastPos, pos - 1);
  4202. lastPos = pos;
  4203. }
  4204. }
  4205. isEscaped = ch === 92 /* \ */;
  4206. pos++;
  4207. ch = str.charCodeAt(pos);
  4208. }
  4209. result.push(current + str.substring(lastPos));
  4210. return result;
  4211. }
  4212. var table = function table(state, startLine, endLine, silent) {
  4213. var ch, lineText, pos, i, l, nextLine, columns, columnCount, token, aligns, t, tableLines, tbodyLines, oldParentType, terminate, terminatorRules, firstCh, secondCh;
  4214. // should have at least two lines
  4215. if (startLine + 2 > endLine) {
  4216. return false;
  4217. }
  4218. nextLine = startLine + 1;
  4219. if (state.sCount[nextLine] < state.blkIndent) {
  4220. return false;
  4221. }
  4222. // if it's indented more than 3 spaces, it should be a code block
  4223. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  4224. return false;
  4225. }
  4226. // first character of the second line should be '|', '-', ':',
  4227. // and no other characters are allowed but spaces;
  4228. // basically, this is the equivalent of /^[-:|][-:|\s]*$/ regexp
  4229. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  4230. if (pos >= state.eMarks[nextLine]) {
  4231. return false;
  4232. }
  4233. firstCh = state.src.charCodeAt(pos++);
  4234. if (firstCh !== 124 /* | */ && firstCh !== 45 /* - */ && firstCh !== 58 /* : */) {
  4235. return false;
  4236. }
  4237. if (pos >= state.eMarks[nextLine]) {
  4238. return false;
  4239. }
  4240. secondCh = state.src.charCodeAt(pos++);
  4241. if (secondCh !== 124 /* | */ && secondCh !== 45 /* - */ && secondCh !== 58 /* : */ && !isSpace$a(secondCh)) {
  4242. return false;
  4243. }
  4244. // if first character is '-', then second character must not be a space
  4245. // (due to parsing ambiguity with list)
  4246. if (firstCh === 45 /* - */ && isSpace$a(secondCh)) {
  4247. return false;
  4248. }
  4249. while (pos < state.eMarks[nextLine]) {
  4250. ch = state.src.charCodeAt(pos);
  4251. if (ch !== 124 /* | */ && ch !== 45 /* - */ && ch !== 58 /* : */ && !isSpace$a(ch)) {
  4252. return false;
  4253. }
  4254. pos++;
  4255. }
  4256. lineText = getLine(state, startLine + 1);
  4257. columns = lineText.split("|");
  4258. aligns = [];
  4259. for (i = 0; i < columns.length; i++) {
  4260. t = columns[i].trim();
  4261. if (!t) {
  4262. // allow empty columns before and after table, but not in between columns;
  4263. // e.g. allow ` |---| `, disallow ` ---||--- `
  4264. if (i === 0 || i === columns.length - 1) {
  4265. continue;
  4266. } else {
  4267. return false;
  4268. }
  4269. }
  4270. if (!/^:?-+:?$/.test(t)) {
  4271. return false;
  4272. }
  4273. if (t.charCodeAt(t.length - 1) === 58 /* : */) {
  4274. aligns.push(t.charCodeAt(0) === 58 /* : */ ? "center" : "right");
  4275. } else if (t.charCodeAt(0) === 58 /* : */) {
  4276. aligns.push("left");
  4277. } else {
  4278. aligns.push("");
  4279. }
  4280. }
  4281. lineText = getLine(state, startLine).trim();
  4282. if (lineText.indexOf("|") === -1) {
  4283. return false;
  4284. }
  4285. if (state.sCount[startLine] - state.blkIndent >= 4) {
  4286. return false;
  4287. }
  4288. columns = escapedSplit(lineText);
  4289. if (columns.length && columns[0] === "") columns.shift();
  4290. if (columns.length && columns[columns.length - 1] === "") columns.pop();
  4291. // header row will define an amount of columns in the entire table,
  4292. // and align row should be exactly the same (the rest of the rows can differ)
  4293. columnCount = columns.length;
  4294. if (columnCount === 0 || columnCount !== aligns.length) {
  4295. return false;
  4296. }
  4297. if (silent) {
  4298. return true;
  4299. }
  4300. oldParentType = state.parentType;
  4301. state.parentType = "table";
  4302. // use 'blockquote' lists for termination because it's
  4303. // the most similar to tables
  4304. terminatorRules = state.md.block.ruler.getRules("blockquote");
  4305. token = state.push("table_open", "table", 1);
  4306. token.map = tableLines = [ startLine, 0 ];
  4307. token = state.push("thead_open", "thead", 1);
  4308. token.map = [ startLine, startLine + 1 ];
  4309. token = state.push("tr_open", "tr", 1);
  4310. token.map = [ startLine, startLine + 1 ];
  4311. for (i = 0; i < columns.length; i++) {
  4312. token = state.push("th_open", "th", 1);
  4313. if (aligns[i]) {
  4314. token.attrs = [ [ "style", "text-align:" + aligns[i] ] ];
  4315. }
  4316. token = state.push("inline", "", 0);
  4317. token.content = columns[i].trim();
  4318. token.children = [];
  4319. token = state.push("th_close", "th", -1);
  4320. }
  4321. token = state.push("tr_close", "tr", -1);
  4322. token = state.push("thead_close", "thead", -1);
  4323. for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {
  4324. if (state.sCount[nextLine] < state.blkIndent) {
  4325. break;
  4326. }
  4327. terminate = false;
  4328. for (i = 0, l = terminatorRules.length; i < l; i++) {
  4329. if (terminatorRules[i](state, nextLine, endLine, true)) {
  4330. terminate = true;
  4331. break;
  4332. }
  4333. }
  4334. if (terminate) {
  4335. break;
  4336. }
  4337. lineText = getLine(state, nextLine).trim();
  4338. if (!lineText) {
  4339. break;
  4340. }
  4341. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  4342. break;
  4343. }
  4344. columns = escapedSplit(lineText);
  4345. if (columns.length && columns[0] === "") columns.shift();
  4346. if (columns.length && columns[columns.length - 1] === "") columns.pop();
  4347. if (nextLine === startLine + 2) {
  4348. token = state.push("tbody_open", "tbody", 1);
  4349. token.map = tbodyLines = [ startLine + 2, 0 ];
  4350. }
  4351. token = state.push("tr_open", "tr", 1);
  4352. token.map = [ nextLine, nextLine + 1 ];
  4353. for (i = 0; i < columnCount; i++) {
  4354. token = state.push("td_open", "td", 1);
  4355. if (aligns[i]) {
  4356. token.attrs = [ [ "style", "text-align:" + aligns[i] ] ];
  4357. }
  4358. token = state.push("inline", "", 0);
  4359. token.content = columns[i] ? columns[i].trim() : "";
  4360. token.children = [];
  4361. token = state.push("td_close", "td", -1);
  4362. }
  4363. token = state.push("tr_close", "tr", -1);
  4364. }
  4365. if (tbodyLines) {
  4366. token = state.push("tbody_close", "tbody", -1);
  4367. tbodyLines[1] = nextLine;
  4368. }
  4369. token = state.push("table_close", "table", -1);
  4370. tableLines[1] = nextLine;
  4371. state.parentType = oldParentType;
  4372. state.line = nextLine;
  4373. return true;
  4374. };
  4375. // Code block (4 spaces padded)
  4376. var code = function code(state, startLine, endLine /*, silent*/) {
  4377. var nextLine, last, token;
  4378. if (state.sCount[startLine] - state.blkIndent < 4) {
  4379. return false;
  4380. }
  4381. last = nextLine = startLine + 1;
  4382. while (nextLine < endLine) {
  4383. if (state.isEmpty(nextLine)) {
  4384. nextLine++;
  4385. continue;
  4386. }
  4387. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  4388. nextLine++;
  4389. last = nextLine;
  4390. continue;
  4391. }
  4392. break;
  4393. }
  4394. state.line = last;
  4395. token = state.push("code_block", "code", 0);
  4396. token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + "\n";
  4397. token.map = [ startLine, state.line ];
  4398. return true;
  4399. };
  4400. // fences (``` lang, ~~~ lang)
  4401. var fence = function fence(state, startLine, endLine, silent) {
  4402. var marker, len, params, nextLine, mem, token, markup, haveEndMarker = false, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
  4403. // if it's indented more than 3 spaces, it should be a code block
  4404. if (state.sCount[startLine] - state.blkIndent >= 4) {
  4405. return false;
  4406. }
  4407. if (pos + 3 > max) {
  4408. return false;
  4409. }
  4410. marker = state.src.charCodeAt(pos);
  4411. if (marker !== 126 /* ~ */ && marker !== 96 /* ` */) {
  4412. return false;
  4413. }
  4414. // scan marker length
  4415. mem = pos;
  4416. pos = state.skipChars(pos, marker);
  4417. len = pos - mem;
  4418. if (len < 3) {
  4419. return false;
  4420. }
  4421. markup = state.src.slice(mem, pos);
  4422. params = state.src.slice(pos, max);
  4423. if (marker === 96 /* ` */) {
  4424. if (params.indexOf(String.fromCharCode(marker)) >= 0) {
  4425. return false;
  4426. }
  4427. }
  4428. // Since start is found, we can report success here in validation mode
  4429. if (silent) {
  4430. return true;
  4431. }
  4432. // search end of block
  4433. nextLine = startLine;
  4434. for (;;) {
  4435. nextLine++;
  4436. if (nextLine >= endLine) {
  4437. // unclosed block should be autoclosed by end of document.
  4438. // also block seems to be autoclosed by end of parent
  4439. break;
  4440. }
  4441. pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
  4442. max = state.eMarks[nextLine];
  4443. if (pos < max && state.sCount[nextLine] < state.blkIndent) {
  4444. // non-empty line with negative indent should stop the list:
  4445. // - ```
  4446. // test
  4447. break;
  4448. }
  4449. if (state.src.charCodeAt(pos) !== marker) {
  4450. continue;
  4451. }
  4452. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  4453. // closing fence should be indented less than 4 spaces
  4454. continue;
  4455. }
  4456. pos = state.skipChars(pos, marker);
  4457. // closing code fence must be at least as long as the opening one
  4458. if (pos - mem < len) {
  4459. continue;
  4460. }
  4461. // make sure tail has spaces only
  4462. pos = state.skipSpaces(pos);
  4463. if (pos < max) {
  4464. continue;
  4465. }
  4466. haveEndMarker = true;
  4467. // found!
  4468. break;
  4469. }
  4470. // If a fence has heading spaces, they should be removed from its inner block
  4471. len = state.sCount[startLine];
  4472. state.line = nextLine + (haveEndMarker ? 1 : 0);
  4473. token = state.push("fence", "code", 0);
  4474. token.info = params;
  4475. token.content = state.getLines(startLine + 1, nextLine, len, true);
  4476. token.markup = markup;
  4477. token.map = [ startLine, state.line ];
  4478. return true;
  4479. };
  4480. var isSpace$9 = utils.isSpace;
  4481. var blockquote = function blockquote(state, startLine, endLine, silent) {
  4482. var adjustTab, ch, i, initial, l, lastLineEmpty, lines, nextLine, offset, oldBMarks, oldBSCount, oldIndent, oldParentType, oldSCount, oldTShift, spaceAfterMarker, terminate, terminatorRules, token, isOutdented, oldLineMax = state.lineMax, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
  4483. // if it's indented more than 3 spaces, it should be a code block
  4484. if (state.sCount[startLine] - state.blkIndent >= 4) {
  4485. return false;
  4486. }
  4487. // check the block quote marker
  4488. if (state.src.charCodeAt(pos) !== 62 /* > */) {
  4489. return false;
  4490. }
  4491. // we know that it's going to be a valid blockquote,
  4492. // so no point trying to find the end of it in silent mode
  4493. if (silent) {
  4494. return true;
  4495. }
  4496. oldBMarks = [];
  4497. oldBSCount = [];
  4498. oldSCount = [];
  4499. oldTShift = [];
  4500. terminatorRules = state.md.block.ruler.getRules("blockquote");
  4501. oldParentType = state.parentType;
  4502. state.parentType = "blockquote";
  4503. // Search the end of the block
  4504. // Block ends with either:
  4505. // 1. an empty line outside:
  4506. // ```
  4507. // > test
  4508. // ```
  4509. // 2. an empty line inside:
  4510. // ```
  4511. // >
  4512. // test
  4513. // ```
  4514. // 3. another tag:
  4515. // ```
  4516. // > test
  4517. // - - -
  4518. // ```
  4519. for (nextLine = startLine; nextLine < endLine; nextLine++) {
  4520. // check if it's outdented, i.e. it's inside list item and indented
  4521. // less than said list item:
  4522. // ```
  4523. // 1. anything
  4524. // > current blockquote
  4525. // 2. checking this line
  4526. // ```
  4527. isOutdented = state.sCount[nextLine] < state.blkIndent;
  4528. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  4529. max = state.eMarks[nextLine];
  4530. if (pos >= max) {
  4531. // Case 1: line is not inside the blockquote, and this line is empty.
  4532. break;
  4533. }
  4534. if (state.src.charCodeAt(pos++) === 62 /* > */ && !isOutdented) {
  4535. // This line is inside the blockquote.
  4536. // set offset past spaces and ">"
  4537. initial = state.sCount[nextLine] + 1;
  4538. // skip one optional space after '>'
  4539. if (state.src.charCodeAt(pos) === 32 /* space */) {
  4540. // ' > test '
  4541. // ^ -- position start of line here:
  4542. pos++;
  4543. initial++;
  4544. adjustTab = false;
  4545. spaceAfterMarker = true;
  4546. } else if (state.src.charCodeAt(pos) === 9 /* tab */) {
  4547. spaceAfterMarker = true;
  4548. if ((state.bsCount[nextLine] + initial) % 4 === 3) {
  4549. // ' >\t test '
  4550. // ^ -- position start of line here (tab has width===1)
  4551. pos++;
  4552. initial++;
  4553. adjustTab = false;
  4554. } else {
  4555. // ' >\t test '
  4556. // ^ -- position start of line here + shift bsCount slightly
  4557. // to make extra space appear
  4558. adjustTab = true;
  4559. }
  4560. } else {
  4561. spaceAfterMarker = false;
  4562. }
  4563. offset = initial;
  4564. oldBMarks.push(state.bMarks[nextLine]);
  4565. state.bMarks[nextLine] = pos;
  4566. while (pos < max) {
  4567. ch = state.src.charCodeAt(pos);
  4568. if (isSpace$9(ch)) {
  4569. if (ch === 9) {
  4570. offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4;
  4571. } else {
  4572. offset++;
  4573. }
  4574. } else {
  4575. break;
  4576. }
  4577. pos++;
  4578. }
  4579. lastLineEmpty = pos >= max;
  4580. oldBSCount.push(state.bsCount[nextLine]);
  4581. state.bsCount[nextLine] = state.sCount[nextLine] + 1 + (spaceAfterMarker ? 1 : 0);
  4582. oldSCount.push(state.sCount[nextLine]);
  4583. state.sCount[nextLine] = offset - initial;
  4584. oldTShift.push(state.tShift[nextLine]);
  4585. state.tShift[nextLine] = pos - state.bMarks[nextLine];
  4586. continue;
  4587. }
  4588. // Case 2: line is not inside the blockquote, and the last line was empty.
  4589. if (lastLineEmpty) {
  4590. break;
  4591. }
  4592. // Case 3: another tag found.
  4593. terminate = false;
  4594. for (i = 0, l = terminatorRules.length; i < l; i++) {
  4595. if (terminatorRules[i](state, nextLine, endLine, true)) {
  4596. terminate = true;
  4597. break;
  4598. }
  4599. }
  4600. if (terminate) {
  4601. // Quirk to enforce "hard termination mode" for paragraphs;
  4602. // normally if you call `tokenize(state, startLine, nextLine)`,
  4603. // paragraphs will look below nextLine for paragraph continuation,
  4604. // but if blockquote is terminated by another tag, they shouldn't
  4605. state.lineMax = nextLine;
  4606. if (state.blkIndent !== 0) {
  4607. // state.blkIndent was non-zero, we now set it to zero,
  4608. // so we need to re-calculate all offsets to appear as
  4609. // if indent wasn't changed
  4610. oldBMarks.push(state.bMarks[nextLine]);
  4611. oldBSCount.push(state.bsCount[nextLine]);
  4612. oldTShift.push(state.tShift[nextLine]);
  4613. oldSCount.push(state.sCount[nextLine]);
  4614. state.sCount[nextLine] -= state.blkIndent;
  4615. }
  4616. break;
  4617. }
  4618. oldBMarks.push(state.bMarks[nextLine]);
  4619. oldBSCount.push(state.bsCount[nextLine]);
  4620. oldTShift.push(state.tShift[nextLine]);
  4621. oldSCount.push(state.sCount[nextLine]);
  4622. // A negative indentation means that this is a paragraph continuation
  4623. state.sCount[nextLine] = -1;
  4624. }
  4625. oldIndent = state.blkIndent;
  4626. state.blkIndent = 0;
  4627. token = state.push("blockquote_open", "blockquote", 1);
  4628. token.markup = ">";
  4629. token.map = lines = [ startLine, 0 ];
  4630. state.md.block.tokenize(state, startLine, nextLine);
  4631. token = state.push("blockquote_close", "blockquote", -1);
  4632. token.markup = ">";
  4633. state.lineMax = oldLineMax;
  4634. state.parentType = oldParentType;
  4635. lines[1] = state.line;
  4636. // Restore original tShift; this might not be necessary since the parser
  4637. // has already been here, but just to make sure we can do that.
  4638. for (i = 0; i < oldTShift.length; i++) {
  4639. state.bMarks[i + startLine] = oldBMarks[i];
  4640. state.tShift[i + startLine] = oldTShift[i];
  4641. state.sCount[i + startLine] = oldSCount[i];
  4642. state.bsCount[i + startLine] = oldBSCount[i];
  4643. }
  4644. state.blkIndent = oldIndent;
  4645. return true;
  4646. };
  4647. var isSpace$8 = utils.isSpace;
  4648. var hr = function hr(state, startLine, endLine, silent) {
  4649. var marker, cnt, ch, token, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
  4650. // if it's indented more than 3 spaces, it should be a code block
  4651. if (state.sCount[startLine] - state.blkIndent >= 4) {
  4652. return false;
  4653. }
  4654. marker = state.src.charCodeAt(pos++);
  4655. // Check hr marker
  4656. if (marker !== 42 /* * */ && marker !== 45 /* - */ && marker !== 95 /* _ */) {
  4657. return false;
  4658. }
  4659. // markers can be mixed with spaces, but there should be at least 3 of them
  4660. cnt = 1;
  4661. while (pos < max) {
  4662. ch = state.src.charCodeAt(pos++);
  4663. if (ch !== marker && !isSpace$8(ch)) {
  4664. return false;
  4665. }
  4666. if (ch === marker) {
  4667. cnt++;
  4668. }
  4669. }
  4670. if (cnt < 3) {
  4671. return false;
  4672. }
  4673. if (silent) {
  4674. return true;
  4675. }
  4676. state.line = startLine + 1;
  4677. token = state.push("hr", "hr", 0);
  4678. token.map = [ startLine, state.line ];
  4679. token.markup = Array(cnt + 1).join(String.fromCharCode(marker));
  4680. return true;
  4681. };
  4682. var isSpace$7 = utils.isSpace;
  4683. // Search `[-+*][\n ]`, returns next pos after marker on success
  4684. // or -1 on fail.
  4685. function skipBulletListMarker(state, startLine) {
  4686. var marker, pos, max, ch;
  4687. pos = state.bMarks[startLine] + state.tShift[startLine];
  4688. max = state.eMarks[startLine];
  4689. marker = state.src.charCodeAt(pos++);
  4690. // Check bullet
  4691. if (marker !== 42 /* * */ && marker !== 45 /* - */ && marker !== 43 /* + */) {
  4692. return -1;
  4693. }
  4694. if (pos < max) {
  4695. ch = state.src.charCodeAt(pos);
  4696. if (!isSpace$7(ch)) {
  4697. // " -test " - is not a list item
  4698. return -1;
  4699. }
  4700. }
  4701. return pos;
  4702. }
  4703. // Search `\d+[.)][\n ]`, returns next pos after marker on success
  4704. // or -1 on fail.
  4705. function skipOrderedListMarker(state, startLine) {
  4706. var ch, start = state.bMarks[startLine] + state.tShift[startLine], pos = start, max = state.eMarks[startLine];
  4707. // List marker should have at least 2 chars (digit + dot)
  4708. if (pos + 1 >= max) {
  4709. return -1;
  4710. }
  4711. ch = state.src.charCodeAt(pos++);
  4712. if (ch < 48 /* 0 */ || ch > 57 /* 9 */) {
  4713. return -1;
  4714. }
  4715. for (;;) {
  4716. // EOL -> fail
  4717. if (pos >= max) {
  4718. return -1;
  4719. }
  4720. ch = state.src.charCodeAt(pos++);
  4721. if (ch >= 48 /* 0 */ && ch <= 57 /* 9 */) {
  4722. // List marker should have no more than 9 digits
  4723. // (prevents integer overflow in browsers)
  4724. if (pos - start >= 10) {
  4725. return -1;
  4726. }
  4727. continue;
  4728. }
  4729. // found valid marker
  4730. if (ch === 41 /* ) */ || ch === 46 /* . */) {
  4731. break;
  4732. }
  4733. return -1;
  4734. }
  4735. if (pos < max) {
  4736. ch = state.src.charCodeAt(pos);
  4737. if (!isSpace$7(ch)) {
  4738. // " 1.test " - is not a list item
  4739. return -1;
  4740. }
  4741. }
  4742. return pos;
  4743. }
  4744. function markTightParagraphs(state, idx) {
  4745. var i, l, level = state.level + 2;
  4746. for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
  4747. if (state.tokens[i].level === level && state.tokens[i].type === "paragraph_open") {
  4748. state.tokens[i + 2].hidden = true;
  4749. state.tokens[i].hidden = true;
  4750. i += 2;
  4751. }
  4752. }
  4753. }
  4754. var list = function list(state, startLine, endLine, silent) {
  4755. var ch, contentStart, i, indent, indentAfterMarker, initial, isOrdered, itemLines, l, listLines, listTokIdx, markerCharCode, markerValue, max, offset, oldListIndent, oldParentType, oldSCount, oldTShift, oldTight, pos, posAfterMarker, prevEmptyEnd, start, terminate, terminatorRules, token, nextLine = startLine, isTerminatingParagraph = false, tight = true;
  4756. // if it's indented more than 3 spaces, it should be a code block
  4757. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  4758. return false;
  4759. }
  4760. // Special case:
  4761. // - item 1
  4762. // - item 2
  4763. // - item 3
  4764. // - item 4
  4765. // - this one is a paragraph continuation
  4766. if (state.listIndent >= 0 && state.sCount[nextLine] - state.listIndent >= 4 && state.sCount[nextLine] < state.blkIndent) {
  4767. return false;
  4768. }
  4769. // limit conditions when list can interrupt
  4770. // a paragraph (validation mode only)
  4771. if (silent && state.parentType === "paragraph") {
  4772. // Next list item should still terminate previous list item;
  4773. // This code can fail if plugins use blkIndent as well as lists,
  4774. // but I hope the spec gets fixed long before that happens.
  4775. if (state.sCount[nextLine] >= state.blkIndent) {
  4776. isTerminatingParagraph = true;
  4777. }
  4778. }
  4779. // Detect list type and position after marker
  4780. if ((posAfterMarker = skipOrderedListMarker(state, nextLine)) >= 0) {
  4781. isOrdered = true;
  4782. start = state.bMarks[nextLine] + state.tShift[nextLine];
  4783. markerValue = Number(state.src.slice(start, posAfterMarker - 1));
  4784. // If we're starting a new ordered list right after
  4785. // a paragraph, it should start with 1.
  4786. if (isTerminatingParagraph && markerValue !== 1) return false;
  4787. } else if ((posAfterMarker = skipBulletListMarker(state, nextLine)) >= 0) {
  4788. isOrdered = false;
  4789. } else {
  4790. return false;
  4791. }
  4792. // If we're starting a new unordered list right after
  4793. // a paragraph, first line should not be empty.
  4794. if (isTerminatingParagraph) {
  4795. if (state.skipSpaces(posAfterMarker) >= state.eMarks[nextLine]) return false;
  4796. }
  4797. // For validation mode we can terminate immediately
  4798. if (silent) {
  4799. return true;
  4800. }
  4801. // We should terminate list on style change. Remember first one to compare.
  4802. markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
  4803. // Start list
  4804. listTokIdx = state.tokens.length;
  4805. if (isOrdered) {
  4806. token = state.push("ordered_list_open", "ol", 1);
  4807. if (markerValue !== 1) {
  4808. token.attrs = [ [ "start", markerValue ] ];
  4809. }
  4810. } else {
  4811. token = state.push("bullet_list_open", "ul", 1);
  4812. }
  4813. token.map = listLines = [ nextLine, 0 ];
  4814. token.markup = String.fromCharCode(markerCharCode);
  4815. // Iterate list items
  4816. prevEmptyEnd = false;
  4817. terminatorRules = state.md.block.ruler.getRules("list");
  4818. oldParentType = state.parentType;
  4819. state.parentType = "list";
  4820. while (nextLine < endLine) {
  4821. pos = posAfterMarker;
  4822. max = state.eMarks[nextLine];
  4823. initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[nextLine] + state.tShift[nextLine]);
  4824. while (pos < max) {
  4825. ch = state.src.charCodeAt(pos);
  4826. if (ch === 9) {
  4827. offset += 4 - (offset + state.bsCount[nextLine]) % 4;
  4828. } else if (ch === 32) {
  4829. offset++;
  4830. } else {
  4831. break;
  4832. }
  4833. pos++;
  4834. }
  4835. contentStart = pos;
  4836. if (contentStart >= max) {
  4837. // trimming space in "- \n 3" case, indent is 1 here
  4838. indentAfterMarker = 1;
  4839. } else {
  4840. indentAfterMarker = offset - initial;
  4841. }
  4842. // If we have more than 4 spaces, the indent is 1
  4843. // (the rest is just indented code block)
  4844. if (indentAfterMarker > 4) {
  4845. indentAfterMarker = 1;
  4846. }
  4847. // " - test"
  4848. // ^^^^^ - calculating total length of this thing
  4849. indent = initial + indentAfterMarker;
  4850. // Run subparser & write tokens
  4851. token = state.push("list_item_open", "li", 1);
  4852. token.markup = String.fromCharCode(markerCharCode);
  4853. token.map = itemLines = [ nextLine, 0 ];
  4854. if (isOrdered) {
  4855. token.info = state.src.slice(start, posAfterMarker - 1);
  4856. }
  4857. // change current state, then restore it after parser subcall
  4858. oldTight = state.tight;
  4859. oldTShift = state.tShift[nextLine];
  4860. oldSCount = state.sCount[nextLine];
  4861. // - example list
  4862. // ^ listIndent position will be here
  4863. // ^ blkIndent position will be here
  4864. oldListIndent = state.listIndent;
  4865. state.listIndent = state.blkIndent;
  4866. state.blkIndent = indent;
  4867. state.tight = true;
  4868. state.tShift[nextLine] = contentStart - state.bMarks[nextLine];
  4869. state.sCount[nextLine] = offset;
  4870. if (contentStart >= max && state.isEmpty(nextLine + 1)) {
  4871. // workaround for this case
  4872. // (list item is empty, list terminates before "foo"):
  4873. // ~~~~~~~~
  4874. // -
  4875. // foo
  4876. // ~~~~~~~~
  4877. state.line = Math.min(state.line + 2, endLine);
  4878. } else {
  4879. state.md.block.tokenize(state, nextLine, endLine, true);
  4880. }
  4881. // If any of list item is tight, mark list as tight
  4882. if (!state.tight || prevEmptyEnd) {
  4883. tight = false;
  4884. }
  4885. // Item become loose if finish with empty line,
  4886. // but we should filter last element, because it means list finish
  4887. prevEmptyEnd = state.line - nextLine > 1 && state.isEmpty(state.line - 1);
  4888. state.blkIndent = state.listIndent;
  4889. state.listIndent = oldListIndent;
  4890. state.tShift[nextLine] = oldTShift;
  4891. state.sCount[nextLine] = oldSCount;
  4892. state.tight = oldTight;
  4893. token = state.push("list_item_close", "li", -1);
  4894. token.markup = String.fromCharCode(markerCharCode);
  4895. nextLine = state.line;
  4896. itemLines[1] = nextLine;
  4897. if (nextLine >= endLine) {
  4898. break;
  4899. }
  4900. // Try to check if list is terminated or continued.
  4901. if (state.sCount[nextLine] < state.blkIndent) {
  4902. break;
  4903. }
  4904. // if it's indented more than 3 spaces, it should be a code block
  4905. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  4906. break;
  4907. }
  4908. // fail if terminating block found
  4909. terminate = false;
  4910. for (i = 0, l = terminatorRules.length; i < l; i++) {
  4911. if (terminatorRules[i](state, nextLine, endLine, true)) {
  4912. terminate = true;
  4913. break;
  4914. }
  4915. }
  4916. if (terminate) {
  4917. break;
  4918. }
  4919. // fail if list has another type
  4920. if (isOrdered) {
  4921. posAfterMarker = skipOrderedListMarker(state, nextLine);
  4922. if (posAfterMarker < 0) {
  4923. break;
  4924. }
  4925. start = state.bMarks[nextLine] + state.tShift[nextLine];
  4926. } else {
  4927. posAfterMarker = skipBulletListMarker(state, nextLine);
  4928. if (posAfterMarker < 0) {
  4929. break;
  4930. }
  4931. }
  4932. if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) {
  4933. break;
  4934. }
  4935. }
  4936. // Finalize list
  4937. if (isOrdered) {
  4938. token = state.push("ordered_list_close", "ol", -1);
  4939. } else {
  4940. token = state.push("bullet_list_close", "ul", -1);
  4941. }
  4942. token.markup = String.fromCharCode(markerCharCode);
  4943. listLines[1] = nextLine;
  4944. state.line = nextLine;
  4945. state.parentType = oldParentType;
  4946. // mark paragraphs tight if needed
  4947. if (tight) {
  4948. markTightParagraphs(state, listTokIdx);
  4949. }
  4950. return true;
  4951. };
  4952. var normalizeReference$2 = utils.normalizeReference;
  4953. var isSpace$6 = utils.isSpace;
  4954. var reference = function reference(state, startLine, _endLine, silent) {
  4955. var ch, destEndPos, destEndLineNo, endLine, href, i, l, label, labelEnd, oldParentType, res, start, str, terminate, terminatorRules, title, lines = 0, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine], nextLine = startLine + 1;
  4956. // if it's indented more than 3 spaces, it should be a code block
  4957. if (state.sCount[startLine] - state.blkIndent >= 4) {
  4958. return false;
  4959. }
  4960. if (state.src.charCodeAt(pos) !== 91 /* [ */) {
  4961. return false;
  4962. }
  4963. // Simple check to quickly interrupt scan on [link](url) at the start of line.
  4964. // Can be useful on practice: https://github.com/markdown-it/markdown-it/issues/54
  4965. while (++pos < max) {
  4966. if (state.src.charCodeAt(pos) === 93 /* ] */ && state.src.charCodeAt(pos - 1) !== 92 /* \ */) {
  4967. if (pos + 1 === max) {
  4968. return false;
  4969. }
  4970. if (state.src.charCodeAt(pos + 1) !== 58 /* : */) {
  4971. return false;
  4972. }
  4973. break;
  4974. }
  4975. }
  4976. endLine = state.lineMax;
  4977. // jump line-by-line until empty one or EOF
  4978. terminatorRules = state.md.block.ruler.getRules("reference");
  4979. oldParentType = state.parentType;
  4980. state.parentType = "reference";
  4981. for (;nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
  4982. // this would be a code block normally, but after paragraph
  4983. // it's considered a lazy continuation regardless of what's there
  4984. if (state.sCount[nextLine] - state.blkIndent > 3) {
  4985. continue;
  4986. }
  4987. // quirk for blockquotes, this line should already be checked by that rule
  4988. if (state.sCount[nextLine] < 0) {
  4989. continue;
  4990. }
  4991. // Some tags can terminate paragraph without empty line.
  4992. terminate = false;
  4993. for (i = 0, l = terminatorRules.length; i < l; i++) {
  4994. if (terminatorRules[i](state, nextLine, endLine, true)) {
  4995. terminate = true;
  4996. break;
  4997. }
  4998. }
  4999. if (terminate) {
  5000. break;
  5001. }
  5002. }
  5003. str = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
  5004. max = str.length;
  5005. for (pos = 1; pos < max; pos++) {
  5006. ch = str.charCodeAt(pos);
  5007. if (ch === 91 /* [ */) {
  5008. return false;
  5009. } else if (ch === 93 /* ] */) {
  5010. labelEnd = pos;
  5011. break;
  5012. } else if (ch === 10 /* \n */) {
  5013. lines++;
  5014. } else if (ch === 92 /* \ */) {
  5015. pos++;
  5016. if (pos < max && str.charCodeAt(pos) === 10) {
  5017. lines++;
  5018. }
  5019. }
  5020. }
  5021. if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 58 /* : */) {
  5022. return false;
  5023. }
  5024. // [label]: destination 'title'
  5025. // ^^^ skip optional whitespace here
  5026. for (pos = labelEnd + 2; pos < max; pos++) {
  5027. ch = str.charCodeAt(pos);
  5028. if (ch === 10) {
  5029. lines++;
  5030. } else if (isSpace$6(ch)) ; else {
  5031. break;
  5032. }
  5033. }
  5034. // [label]: destination 'title'
  5035. // ^^^^^^^^^^^ parse this
  5036. res = state.md.helpers.parseLinkDestination(str, pos, max);
  5037. if (!res.ok) {
  5038. return false;
  5039. }
  5040. href = state.md.normalizeLink(res.str);
  5041. if (!state.md.validateLink(href)) {
  5042. return false;
  5043. }
  5044. pos = res.pos;
  5045. lines += res.lines;
  5046. // save cursor state, we could require to rollback later
  5047. destEndPos = pos;
  5048. destEndLineNo = lines;
  5049. // [label]: destination 'title'
  5050. // ^^^ skipping those spaces
  5051. start = pos;
  5052. for (;pos < max; pos++) {
  5053. ch = str.charCodeAt(pos);
  5054. if (ch === 10) {
  5055. lines++;
  5056. } else if (isSpace$6(ch)) ; else {
  5057. break;
  5058. }
  5059. }
  5060. // [label]: destination 'title'
  5061. // ^^^^^^^ parse this
  5062. res = state.md.helpers.parseLinkTitle(str, pos, max);
  5063. if (pos < max && start !== pos && res.ok) {
  5064. title = res.str;
  5065. pos = res.pos;
  5066. lines += res.lines;
  5067. } else {
  5068. title = "";
  5069. pos = destEndPos;
  5070. lines = destEndLineNo;
  5071. }
  5072. // skip trailing spaces until the rest of the line
  5073. while (pos < max) {
  5074. ch = str.charCodeAt(pos);
  5075. if (!isSpace$6(ch)) {
  5076. break;
  5077. }
  5078. pos++;
  5079. }
  5080. if (pos < max && str.charCodeAt(pos) !== 10) {
  5081. if (title) {
  5082. // garbage at the end of the line after title,
  5083. // but it could still be a valid reference if we roll back
  5084. title = "";
  5085. pos = destEndPos;
  5086. lines = destEndLineNo;
  5087. while (pos < max) {
  5088. ch = str.charCodeAt(pos);
  5089. if (!isSpace$6(ch)) {
  5090. break;
  5091. }
  5092. pos++;
  5093. }
  5094. }
  5095. }
  5096. if (pos < max && str.charCodeAt(pos) !== 10) {
  5097. // garbage at the end of the line
  5098. return false;
  5099. }
  5100. label = normalizeReference$2(str.slice(1, labelEnd));
  5101. if (!label) {
  5102. // CommonMark 0.20 disallows empty labels
  5103. return false;
  5104. }
  5105. // Reference can not terminate anything. This check is for safety only.
  5106. /*istanbul ignore if*/ if (silent) {
  5107. return true;
  5108. }
  5109. if (typeof state.env.references === "undefined") {
  5110. state.env.references = {};
  5111. }
  5112. if (typeof state.env.references[label] === "undefined") {
  5113. state.env.references[label] = {
  5114. title: title,
  5115. href: href
  5116. };
  5117. }
  5118. state.parentType = oldParentType;
  5119. state.line = startLine + lines + 1;
  5120. return true;
  5121. };
  5122. // List of valid html blocks names, accorting to commonmark spec
  5123. var html_blocks = [ "address", "article", "aside", "base", "basefont", "blockquote", "body", "caption", "center", "col", "colgroup", "dd", "details", "dialog", "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form", "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hr", "html", "iframe", "legend", "li", "link", "main", "menu", "menuitem", "nav", "noframes", "ol", "optgroup", "option", "p", "param", "section", "source", "summary", "table", "tbody", "td", "tfoot", "th", "thead", "title", "tr", "track", "ul" ];
  5124. // Regexps to match html elements
  5125. var attr_name = "[a-zA-Z_:][a-zA-Z0-9:._-]*";
  5126. var unquoted = "[^\"'=<>`\\x00-\\x20]+";
  5127. var single_quoted = "'[^']*'";
  5128. var double_quoted = '"[^"]*"';
  5129. var attr_value = "(?:" + unquoted + "|" + single_quoted + "|" + double_quoted + ")";
  5130. var attribute = "(?:\\s+" + attr_name + "(?:\\s*=\\s*" + attr_value + ")?)";
  5131. var open_tag = "<[A-Za-z][A-Za-z0-9\\-]*" + attribute + "*\\s*\\/?>";
  5132. var close_tag = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>";
  5133. var comment = "\x3c!----\x3e|\x3c!--(?:-?[^>-])(?:-?[^-])*--\x3e";
  5134. var processing = "<[?][\\s\\S]*?[?]>";
  5135. var declaration = "<![A-Z]+\\s+[^>]*>";
  5136. var cdata = "<!\\[CDATA\\[[\\s\\S]*?\\]\\]>";
  5137. var HTML_TAG_RE$1 = new RegExp("^(?:" + open_tag + "|" + close_tag + "|" + comment + "|" + processing + "|" + declaration + "|" + cdata + ")");
  5138. var HTML_OPEN_CLOSE_TAG_RE$1 = new RegExp("^(?:" + open_tag + "|" + close_tag + ")");
  5139. var HTML_TAG_RE_1 = HTML_TAG_RE$1;
  5140. var HTML_OPEN_CLOSE_TAG_RE_1 = HTML_OPEN_CLOSE_TAG_RE$1;
  5141. var html_re = {
  5142. HTML_TAG_RE: HTML_TAG_RE_1,
  5143. HTML_OPEN_CLOSE_TAG_RE: HTML_OPEN_CLOSE_TAG_RE_1
  5144. };
  5145. var HTML_OPEN_CLOSE_TAG_RE = html_re.HTML_OPEN_CLOSE_TAG_RE;
  5146. // An array of opening and corresponding closing sequences for html tags,
  5147. // last argument defines whether it can terminate a paragraph or not
  5148. var HTML_SEQUENCES = [ [ /^<(script|pre|style|textarea)(?=(\s|>|$))/i, /<\/(script|pre|style|textarea)>/i, true ], [ /^<!--/, /-->/, true ], [ /^<\?/, /\?>/, true ], [ /^<![A-Z]/, />/, true ], [ /^<!\[CDATA\[/, /\]\]>/, true ], [ new RegExp("^</?(" + html_blocks.join("|") + ")(?=(\\s|/?>|$))", "i"), /^$/, true ], [ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + "\\s*$"), /^$/, false ] ];
  5149. var html_block = function html_block(state, startLine, endLine, silent) {
  5150. var i, nextLine, token, lineText, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
  5151. // if it's indented more than 3 spaces, it should be a code block
  5152. if (state.sCount[startLine] - state.blkIndent >= 4) {
  5153. return false;
  5154. }
  5155. if (!state.md.options.html) {
  5156. return false;
  5157. }
  5158. if (state.src.charCodeAt(pos) !== 60 /* < */) {
  5159. return false;
  5160. }
  5161. lineText = state.src.slice(pos, max);
  5162. for (i = 0; i < HTML_SEQUENCES.length; i++) {
  5163. if (HTML_SEQUENCES[i][0].test(lineText)) {
  5164. break;
  5165. }
  5166. }
  5167. if (i === HTML_SEQUENCES.length) {
  5168. return false;
  5169. }
  5170. if (silent) {
  5171. // true if this sequence can be a terminator, false otherwise
  5172. return HTML_SEQUENCES[i][2];
  5173. }
  5174. nextLine = startLine + 1;
  5175. // If we are here - we detected HTML block.
  5176. // Let's roll down till block end.
  5177. if (!HTML_SEQUENCES[i][1].test(lineText)) {
  5178. for (;nextLine < endLine; nextLine++) {
  5179. if (state.sCount[nextLine] < state.blkIndent) {
  5180. break;
  5181. }
  5182. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  5183. max = state.eMarks[nextLine];
  5184. lineText = state.src.slice(pos, max);
  5185. if (HTML_SEQUENCES[i][1].test(lineText)) {
  5186. if (lineText.length !== 0) {
  5187. nextLine++;
  5188. }
  5189. break;
  5190. }
  5191. }
  5192. }
  5193. state.line = nextLine;
  5194. token = state.push("html_block", "", 0);
  5195. token.map = [ startLine, nextLine ];
  5196. token.content = state.getLines(startLine, nextLine, state.blkIndent, true);
  5197. return true;
  5198. };
  5199. var isSpace$5 = utils.isSpace;
  5200. var heading = function heading(state, startLine, endLine, silent) {
  5201. var ch, level, tmp, token, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
  5202. // if it's indented more than 3 spaces, it should be a code block
  5203. if (state.sCount[startLine] - state.blkIndent >= 4) {
  5204. return false;
  5205. }
  5206. ch = state.src.charCodeAt(pos);
  5207. if (ch !== 35 /* # */ || pos >= max) {
  5208. return false;
  5209. }
  5210. // count heading level
  5211. level = 1;
  5212. ch = state.src.charCodeAt(++pos);
  5213. while (ch === 35 /* # */ && pos < max && level <= 6) {
  5214. level++;
  5215. ch = state.src.charCodeAt(++pos);
  5216. }
  5217. if (level > 6 || pos < max && !isSpace$5(ch)) {
  5218. return false;
  5219. }
  5220. if (silent) {
  5221. return true;
  5222. }
  5223. // Let's cut tails like ' ### ' from the end of string
  5224. max = state.skipSpacesBack(max, pos);
  5225. tmp = state.skipCharsBack(max, 35, pos);
  5226. // #
  5227. if (tmp > pos && isSpace$5(state.src.charCodeAt(tmp - 1))) {
  5228. max = tmp;
  5229. }
  5230. state.line = startLine + 1;
  5231. token = state.push("heading_open", "h" + String(level), 1);
  5232. token.markup = "########".slice(0, level);
  5233. token.map = [ startLine, state.line ];
  5234. token = state.push("inline", "", 0);
  5235. token.content = state.src.slice(pos, max).trim();
  5236. token.map = [ startLine, state.line ];
  5237. token.children = [];
  5238. token = state.push("heading_close", "h" + String(level), -1);
  5239. token.markup = "########".slice(0, level);
  5240. return true;
  5241. };
  5242. // lheading (---, ===)
  5243. var lheading = function lheading(state, startLine, endLine /*, silent*/) {
  5244. var content, terminate, i, l, token, pos, max, level, marker, nextLine = startLine + 1, oldParentType, terminatorRules = state.md.block.ruler.getRules("paragraph");
  5245. // if it's indented more than 3 spaces, it should be a code block
  5246. if (state.sCount[startLine] - state.blkIndent >= 4) {
  5247. return false;
  5248. }
  5249. oldParentType = state.parentType;
  5250. state.parentType = "paragraph";
  5251. // use paragraph to match terminatorRules
  5252. // jump line-by-line until empty one or EOF
  5253. for (;nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
  5254. // this would be a code block normally, but after paragraph
  5255. // it's considered a lazy continuation regardless of what's there
  5256. if (state.sCount[nextLine] - state.blkIndent > 3) {
  5257. continue;
  5258. }
  5259. // Check for underline in setext header
  5260. if (state.sCount[nextLine] >= state.blkIndent) {
  5261. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  5262. max = state.eMarks[nextLine];
  5263. if (pos < max) {
  5264. marker = state.src.charCodeAt(pos);
  5265. if (marker === 45 /* - */ || marker === 61 /* = */) {
  5266. pos = state.skipChars(pos, marker);
  5267. pos = state.skipSpaces(pos);
  5268. if (pos >= max) {
  5269. level = marker === 61 /* = */ ? 1 : 2;
  5270. break;
  5271. }
  5272. }
  5273. }
  5274. }
  5275. // quirk for blockquotes, this line should already be checked by that rule
  5276. if (state.sCount[nextLine] < 0) {
  5277. continue;
  5278. }
  5279. // Some tags can terminate paragraph without empty line.
  5280. terminate = false;
  5281. for (i = 0, l = terminatorRules.length; i < l; i++) {
  5282. if (terminatorRules[i](state, nextLine, endLine, true)) {
  5283. terminate = true;
  5284. break;
  5285. }
  5286. }
  5287. if (terminate) {
  5288. break;
  5289. }
  5290. }
  5291. if (!level) {
  5292. // Didn't find valid underline
  5293. return false;
  5294. }
  5295. content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
  5296. state.line = nextLine + 1;
  5297. token = state.push("heading_open", "h" + String(level), 1);
  5298. token.markup = String.fromCharCode(marker);
  5299. token.map = [ startLine, state.line ];
  5300. token = state.push("inline", "", 0);
  5301. token.content = content;
  5302. token.map = [ startLine, state.line - 1 ];
  5303. token.children = [];
  5304. token = state.push("heading_close", "h" + String(level), -1);
  5305. token.markup = String.fromCharCode(marker);
  5306. state.parentType = oldParentType;
  5307. return true;
  5308. };
  5309. // Paragraph
  5310. var paragraph = function paragraph(state, startLine, endLine) {
  5311. var content, terminate, i, l, token, oldParentType, nextLine = startLine + 1, terminatorRules = state.md.block.ruler.getRules("paragraph");
  5312. oldParentType = state.parentType;
  5313. state.parentType = "paragraph";
  5314. // jump line-by-line until empty one or EOF
  5315. for (;nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
  5316. // this would be a code block normally, but after paragraph
  5317. // it's considered a lazy continuation regardless of what's there
  5318. if (state.sCount[nextLine] - state.blkIndent > 3) {
  5319. continue;
  5320. }
  5321. // quirk for blockquotes, this line should already be checked by that rule
  5322. if (state.sCount[nextLine] < 0) {
  5323. continue;
  5324. }
  5325. // Some tags can terminate paragraph without empty line.
  5326. terminate = false;
  5327. for (i = 0, l = terminatorRules.length; i < l; i++) {
  5328. if (terminatorRules[i](state, nextLine, endLine, true)) {
  5329. terminate = true;
  5330. break;
  5331. }
  5332. }
  5333. if (terminate) {
  5334. break;
  5335. }
  5336. }
  5337. content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
  5338. state.line = nextLine;
  5339. token = state.push("paragraph_open", "p", 1);
  5340. token.map = [ startLine, state.line ];
  5341. token = state.push("inline", "", 0);
  5342. token.content = content;
  5343. token.map = [ startLine, state.line ];
  5344. token.children = [];
  5345. token = state.push("paragraph_close", "p", -1);
  5346. state.parentType = oldParentType;
  5347. return true;
  5348. };
  5349. var isSpace$4 = utils.isSpace;
  5350. function StateBlock(src, md, env, tokens) {
  5351. var ch, s, start, pos, len, indent, offset, indent_found;
  5352. this.src = src;
  5353. // link to parser instance
  5354. this.md = md;
  5355. this.env = env;
  5356. // Internal state vartiables
  5357. this.tokens = tokens;
  5358. this.bMarks = [];
  5359. // line begin offsets for fast jumps
  5360. this.eMarks = [];
  5361. // line end offsets for fast jumps
  5362. this.tShift = [];
  5363. // offsets of the first non-space characters (tabs not expanded)
  5364. this.sCount = [];
  5365. // indents for each line (tabs expanded)
  5366. // An amount of virtual spaces (tabs expanded) between beginning
  5367. // of each line (bMarks) and real beginning of that line.
  5368. // It exists only as a hack because blockquotes override bMarks
  5369. // losing information in the process.
  5370. // It's used only when expanding tabs, you can think about it as
  5371. // an initial tab length, e.g. bsCount=21 applied to string `\t123`
  5372. // means first tab should be expanded to 4-21%4 === 3 spaces.
  5373. this.bsCount = [];
  5374. // block parser variables
  5375. this.blkIndent = 0;
  5376. // required block content indent (for example, if we are
  5377. // inside a list, it would be positioned after list marker)
  5378. this.line = 0;
  5379. // line index in src
  5380. this.lineMax = 0;
  5381. // lines count
  5382. this.tight = false;
  5383. // loose/tight mode for lists
  5384. this.ddIndent = -1;
  5385. // indent of the current dd block (-1 if there isn't any)
  5386. this.listIndent = -1;
  5387. // indent of the current list block (-1 if there isn't any)
  5388. // can be 'blockquote', 'list', 'root', 'paragraph' or 'reference'
  5389. // used in lists to determine if they interrupt a paragraph
  5390. this.parentType = "root";
  5391. this.level = 0;
  5392. // renderer
  5393. this.result = "";
  5394. // Create caches
  5395. // Generate markers.
  5396. s = this.src;
  5397. indent_found = false;
  5398. for (start = pos = indent = offset = 0, len = s.length; pos < len; pos++) {
  5399. ch = s.charCodeAt(pos);
  5400. if (!indent_found) {
  5401. if (isSpace$4(ch)) {
  5402. indent++;
  5403. if (ch === 9) {
  5404. offset += 4 - offset % 4;
  5405. } else {
  5406. offset++;
  5407. }
  5408. continue;
  5409. } else {
  5410. indent_found = true;
  5411. }
  5412. }
  5413. if (ch === 10 || pos === len - 1) {
  5414. if (ch !== 10) {
  5415. pos++;
  5416. }
  5417. this.bMarks.push(start);
  5418. this.eMarks.push(pos);
  5419. this.tShift.push(indent);
  5420. this.sCount.push(offset);
  5421. this.bsCount.push(0);
  5422. indent_found = false;
  5423. indent = 0;
  5424. offset = 0;
  5425. start = pos + 1;
  5426. }
  5427. }
  5428. // Push fake entry to simplify cache bounds checks
  5429. this.bMarks.push(s.length);
  5430. this.eMarks.push(s.length);
  5431. this.tShift.push(0);
  5432. this.sCount.push(0);
  5433. this.bsCount.push(0);
  5434. this.lineMax = this.bMarks.length - 1;
  5435. // don't count last fake line
  5436. }
  5437. // Push new token to "stream".
  5438. StateBlock.prototype.push = function(type, tag, nesting) {
  5439. var token$1 = new token(type, tag, nesting);
  5440. token$1.block = true;
  5441. if (nesting < 0) this.level--;
  5442. // closing tag
  5443. token$1.level = this.level;
  5444. if (nesting > 0) this.level++;
  5445. // opening tag
  5446. this.tokens.push(token$1);
  5447. return token$1;
  5448. };
  5449. StateBlock.prototype.isEmpty = function isEmpty(line) {
  5450. return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];
  5451. };
  5452. StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {
  5453. for (var max = this.lineMax; from < max; from++) {
  5454. if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) {
  5455. break;
  5456. }
  5457. }
  5458. return from;
  5459. };
  5460. // Skip spaces from given position.
  5461. StateBlock.prototype.skipSpaces = function skipSpaces(pos) {
  5462. var ch;
  5463. for (var max = this.src.length; pos < max; pos++) {
  5464. ch = this.src.charCodeAt(pos);
  5465. if (!isSpace$4(ch)) {
  5466. break;
  5467. }
  5468. }
  5469. return pos;
  5470. };
  5471. // Skip spaces from given position in reverse.
  5472. StateBlock.prototype.skipSpacesBack = function skipSpacesBack(pos, min) {
  5473. if (pos <= min) {
  5474. return pos;
  5475. }
  5476. while (pos > min) {
  5477. if (!isSpace$4(this.src.charCodeAt(--pos))) {
  5478. return pos + 1;
  5479. }
  5480. }
  5481. return pos;
  5482. };
  5483. // Skip char codes from given position
  5484. StateBlock.prototype.skipChars = function skipChars(pos, code) {
  5485. for (var max = this.src.length; pos < max; pos++) {
  5486. if (this.src.charCodeAt(pos) !== code) {
  5487. break;
  5488. }
  5489. }
  5490. return pos;
  5491. };
  5492. // Skip char codes reverse from given position - 1
  5493. StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {
  5494. if (pos <= min) {
  5495. return pos;
  5496. }
  5497. while (pos > min) {
  5498. if (code !== this.src.charCodeAt(--pos)) {
  5499. return pos + 1;
  5500. }
  5501. }
  5502. return pos;
  5503. };
  5504. // cut lines range from source.
  5505. StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {
  5506. var i, lineIndent, ch, first, last, queue, lineStart, line = begin;
  5507. if (begin >= end) {
  5508. return "";
  5509. }
  5510. queue = new Array(end - begin);
  5511. for (i = 0; line < end; line++, i++) {
  5512. lineIndent = 0;
  5513. lineStart = first = this.bMarks[line];
  5514. if (line + 1 < end || keepLastLF) {
  5515. // No need for bounds check because we have fake entry on tail.
  5516. last = this.eMarks[line] + 1;
  5517. } else {
  5518. last = this.eMarks[line];
  5519. }
  5520. while (first < last && lineIndent < indent) {
  5521. ch = this.src.charCodeAt(first);
  5522. if (isSpace$4(ch)) {
  5523. if (ch === 9) {
  5524. lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4;
  5525. } else {
  5526. lineIndent++;
  5527. }
  5528. } else if (first - lineStart < this.tShift[line]) {
  5529. // patched tShift masked characters to look like spaces (blockquotes, list markers)
  5530. lineIndent++;
  5531. } else {
  5532. break;
  5533. }
  5534. first++;
  5535. }
  5536. if (lineIndent > indent) {
  5537. // partially expanding tabs in code blocks, e.g '\t\tfoobar'
  5538. // with indent=2 becomes ' \tfoobar'
  5539. queue[i] = new Array(lineIndent - indent + 1).join(" ") + this.src.slice(first, last);
  5540. } else {
  5541. queue[i] = this.src.slice(first, last);
  5542. }
  5543. }
  5544. return queue.join("");
  5545. };
  5546. // re-export Token class to use in block rules
  5547. StateBlock.prototype.Token = token;
  5548. var state_block = StateBlock;
  5549. var _rules$1 = [
  5550. // First 2 params - rule name & source. Secondary array - list of rules,
  5551. // which can be terminated by this one.
  5552. [ "table", table, [ "paragraph", "reference" ] ], [ "code", code ], [ "fence", fence, [ "paragraph", "reference", "blockquote", "list" ] ], [ "blockquote", blockquote, [ "paragraph", "reference", "blockquote", "list" ] ], [ "hr", hr, [ "paragraph", "reference", "blockquote", "list" ] ], [ "list", list, [ "paragraph", "reference", "blockquote" ] ], [ "reference", reference ], [ "html_block", html_block, [ "paragraph", "reference", "blockquote" ] ], [ "heading", heading, [ "paragraph", "reference", "blockquote" ] ], [ "lheading", lheading ], [ "paragraph", paragraph ] ];
  5553. /**
  5554. * new ParserBlock()
  5555. **/ function ParserBlock() {
  5556. /**
  5557. * ParserBlock#ruler -> Ruler
  5558. *
  5559. * [[Ruler]] instance. Keep configuration of block rules.
  5560. **/
  5561. this.ruler = new ruler;
  5562. for (var i = 0; i < _rules$1.length; i++) {
  5563. this.ruler.push(_rules$1[i][0], _rules$1[i][1], {
  5564. alt: (_rules$1[i][2] || []).slice()
  5565. });
  5566. }
  5567. }
  5568. // Generate tokens for input range
  5569. ParserBlock.prototype.tokenize = function(state, startLine, endLine) {
  5570. var ok, i, prevLine, rules = this.ruler.getRules(""), len = rules.length, line = startLine, hasEmptyLines = false, maxNesting = state.md.options.maxNesting;
  5571. while (line < endLine) {
  5572. state.line = line = state.skipEmptyLines(line);
  5573. if (line >= endLine) {
  5574. break;
  5575. }
  5576. // Termination condition for nested calls.
  5577. // Nested calls currently used for blockquotes & lists
  5578. if (state.sCount[line] < state.blkIndent) {
  5579. break;
  5580. }
  5581. // If nesting level exceeded - skip tail to the end. That's not ordinary
  5582. // situation and we should not care about content.
  5583. if (state.level >= maxNesting) {
  5584. state.line = endLine;
  5585. break;
  5586. }
  5587. // Try all possible rules.
  5588. // On success, rule should:
  5589. // - update `state.line`
  5590. // - update `state.tokens`
  5591. // - return true
  5592. prevLine = state.line;
  5593. for (i = 0; i < len; i++) {
  5594. ok = rules[i](state, line, endLine, false);
  5595. if (ok) {
  5596. if (prevLine >= state.line) {
  5597. throw new Error("block rule didn't increment state.line");
  5598. }
  5599. break;
  5600. }
  5601. }
  5602. // this can only happen if user disables paragraph rule
  5603. if (!ok) throw new Error("none of the block rules matched");
  5604. // set state.tight if we had an empty line before current tag
  5605. // i.e. latest empty line should not count
  5606. state.tight = !hasEmptyLines;
  5607. // paragraph might "eat" one newline after it in nested lists
  5608. if (state.isEmpty(state.line - 1)) {
  5609. hasEmptyLines = true;
  5610. }
  5611. line = state.line;
  5612. if (line < endLine && state.isEmpty(line)) {
  5613. hasEmptyLines = true;
  5614. line++;
  5615. state.line = line;
  5616. }
  5617. }
  5618. };
  5619. /**
  5620. * ParserBlock.parse(str, md, env, outTokens)
  5621. *
  5622. * Process input string and push block tokens into `outTokens`
  5623. **/ ParserBlock.prototype.parse = function(src, md, env, outTokens) {
  5624. var state;
  5625. if (!src) {
  5626. return;
  5627. }
  5628. state = new this.State(src, md, env, outTokens);
  5629. this.tokenize(state, state.line, state.lineMax);
  5630. };
  5631. ParserBlock.prototype.State = state_block;
  5632. var parser_block = ParserBlock;
  5633. // Skip text characters for text token, place those to pending buffer
  5634. // Rule to skip pure text
  5635. // '{}$%@~+=:' reserved for extentions
  5636. // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
  5637. // !!!! Don't confuse with "Markdown ASCII Punctuation" chars
  5638. // http://spec.commonmark.org/0.15/#ascii-punctuation-character
  5639. function isTerminatorChar(ch) {
  5640. switch (ch) {
  5641. case 10 /* \n */ :
  5642. case 33 /* ! */ :
  5643. case 35 /* # */ :
  5644. case 36 /* $ */ :
  5645. case 37 /* % */ :
  5646. case 38 /* & */ :
  5647. case 42 /* * */ :
  5648. case 43 /* + */ :
  5649. case 45 /* - */ :
  5650. case 58 /* : */ :
  5651. case 60 /* < */ :
  5652. case 61 /* = */ :
  5653. case 62 /* > */ :
  5654. case 64 /* @ */ :
  5655. case 91 /* [ */ :
  5656. case 92 /* \ */ :
  5657. case 93 /* ] */ :
  5658. case 94 /* ^ */ :
  5659. case 95 /* _ */ :
  5660. case 96 /* ` */ :
  5661. case 123 /* { */ :
  5662. case 125 /* } */ :
  5663. case 126 /* ~ */ :
  5664. return true;
  5665. default:
  5666. return false;
  5667. }
  5668. }
  5669. var text = function text(state, silent) {
  5670. var pos = state.pos;
  5671. while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) {
  5672. pos++;
  5673. }
  5674. if (pos === state.pos) {
  5675. return false;
  5676. }
  5677. if (!silent) {
  5678. state.pending += state.src.slice(state.pos, pos);
  5679. }
  5680. state.pos = pos;
  5681. return true;
  5682. };
  5683. // Process links like https://example.org/
  5684. // RFC3986: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
  5685. var SCHEME_RE = /(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;
  5686. var linkify = function linkify(state, silent) {
  5687. var pos, max, match, proto, link, url, fullUrl, token;
  5688. if (!state.md.options.linkify) return false;
  5689. if (state.linkLevel > 0) return false;
  5690. pos = state.pos;
  5691. max = state.posMax;
  5692. if (pos + 3 > max) return false;
  5693. if (state.src.charCodeAt(pos) !== 58 /* : */) return false;
  5694. if (state.src.charCodeAt(pos + 1) !== 47 /* / */) return false;
  5695. if (state.src.charCodeAt(pos + 2) !== 47 /* / */) return false;
  5696. match = state.pending.match(SCHEME_RE);
  5697. if (!match) return false;
  5698. proto = match[1];
  5699. link = state.md.linkify.matchAtStart(state.src.slice(pos - proto.length));
  5700. if (!link) return false;
  5701. url = link.url;
  5702. // invalid link, but still detected by linkify somehow;
  5703. // need to check to prevent infinite loop below
  5704. if (url.length <= proto.length) return false;
  5705. // disallow '*' at the end of the link (conflicts with emphasis)
  5706. url = url.replace(/\*+$/, "");
  5707. fullUrl = state.md.normalizeLink(url);
  5708. if (!state.md.validateLink(fullUrl)) return false;
  5709. if (!silent) {
  5710. state.pending = state.pending.slice(0, -proto.length);
  5711. token = state.push("link_open", "a", 1);
  5712. token.attrs = [ [ "href", fullUrl ] ];
  5713. token.markup = "linkify";
  5714. token.info = "auto";
  5715. token = state.push("text", "", 0);
  5716. token.content = state.md.normalizeLinkText(url);
  5717. token = state.push("link_close", "a", -1);
  5718. token.markup = "linkify";
  5719. token.info = "auto";
  5720. }
  5721. state.pos += url.length - proto.length;
  5722. return true;
  5723. };
  5724. var isSpace$3 = utils.isSpace;
  5725. var newline = function newline(state, silent) {
  5726. var pmax, max, ws, pos = state.pos;
  5727. if (state.src.charCodeAt(pos) !== 10 /* \n */) {
  5728. return false;
  5729. }
  5730. pmax = state.pending.length - 1;
  5731. max = state.posMax;
  5732. // ' \n' -> hardbreak
  5733. // Lookup in pending chars is bad practice! Don't copy to other rules!
  5734. // Pending string is stored in concat mode, indexed lookups will cause
  5735. // convertion to flat mode.
  5736. if (!silent) {
  5737. if (pmax >= 0 && state.pending.charCodeAt(pmax) === 32) {
  5738. if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 32) {
  5739. // Find whitespaces tail of pending chars.
  5740. ws = pmax - 1;
  5741. while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 32) ws--;
  5742. state.pending = state.pending.slice(0, ws);
  5743. state.push("hardbreak", "br", 0);
  5744. } else {
  5745. state.pending = state.pending.slice(0, -1);
  5746. state.push("softbreak", "br", 0);
  5747. }
  5748. } else {
  5749. state.push("softbreak", "br", 0);
  5750. }
  5751. }
  5752. pos++;
  5753. // skip heading spaces for next line
  5754. while (pos < max && isSpace$3(state.src.charCodeAt(pos))) {
  5755. pos++;
  5756. }
  5757. state.pos = pos;
  5758. return true;
  5759. };
  5760. var isSpace$2 = utils.isSpace;
  5761. var ESCAPED = [];
  5762. for (var i = 0; i < 256; i++) {
  5763. ESCAPED.push(0);
  5764. }
  5765. "\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(ch) {
  5766. ESCAPED[ch.charCodeAt(0)] = 1;
  5767. }));
  5768. var _escape = function escape(state, silent) {
  5769. var ch1, ch2, origStr, escapedStr, token, pos = state.pos, max = state.posMax;
  5770. if (state.src.charCodeAt(pos) !== 92 /* \ */) return false;
  5771. pos++;
  5772. // '\' at the end of the inline block
  5773. if (pos >= max) return false;
  5774. ch1 = state.src.charCodeAt(pos);
  5775. if (ch1 === 10) {
  5776. if (!silent) {
  5777. state.push("hardbreak", "br", 0);
  5778. }
  5779. pos++;
  5780. // skip leading whitespaces from next line
  5781. while (pos < max) {
  5782. ch1 = state.src.charCodeAt(pos);
  5783. if (!isSpace$2(ch1)) break;
  5784. pos++;
  5785. }
  5786. state.pos = pos;
  5787. return true;
  5788. }
  5789. escapedStr = state.src[pos];
  5790. if (ch1 >= 55296 && ch1 <= 56319 && pos + 1 < max) {
  5791. ch2 = state.src.charCodeAt(pos + 1);
  5792. if (ch2 >= 56320 && ch2 <= 57343) {
  5793. escapedStr += state.src[pos + 1];
  5794. pos++;
  5795. }
  5796. }
  5797. origStr = "\\" + escapedStr;
  5798. if (!silent) {
  5799. token = state.push("text_special", "", 0);
  5800. if (ch1 < 256 && ESCAPED[ch1] !== 0) {
  5801. token.content = escapedStr;
  5802. } else {
  5803. token.content = origStr;
  5804. }
  5805. token.markup = origStr;
  5806. token.info = "escape";
  5807. }
  5808. state.pos = pos + 1;
  5809. return true;
  5810. };
  5811. // Parse backticks
  5812. var backticks = function backtick(state, silent) {
  5813. var start, max, marker, token, matchStart, matchEnd, openerLength, closerLength, pos = state.pos, ch = state.src.charCodeAt(pos);
  5814. if (ch !== 96 /* ` */) {
  5815. return false;
  5816. }
  5817. start = pos;
  5818. pos++;
  5819. max = state.posMax;
  5820. // scan marker length
  5821. while (pos < max && state.src.charCodeAt(pos) === 96 /* ` */) {
  5822. pos++;
  5823. }
  5824. marker = state.src.slice(start, pos);
  5825. openerLength = marker.length;
  5826. if (state.backticksScanned && (state.backticks[openerLength] || 0) <= start) {
  5827. if (!silent) state.pending += marker;
  5828. state.pos += openerLength;
  5829. return true;
  5830. }
  5831. matchEnd = pos;
  5832. // Nothing found in the cache, scan until the end of the line (or until marker is found)
  5833. while ((matchStart = state.src.indexOf("`", matchEnd)) !== -1) {
  5834. matchEnd = matchStart + 1;
  5835. // scan marker length
  5836. while (matchEnd < max && state.src.charCodeAt(matchEnd) === 96 /* ` */) {
  5837. matchEnd++;
  5838. }
  5839. closerLength = matchEnd - matchStart;
  5840. if (closerLength === openerLength) {
  5841. // Found matching closer length.
  5842. if (!silent) {
  5843. token = state.push("code_inline", "code", 0);
  5844. token.markup = marker;
  5845. token.content = state.src.slice(pos, matchStart).replace(/\n/g, " ").replace(/^ (.+) $/, "$1");
  5846. }
  5847. state.pos = matchEnd;
  5848. return true;
  5849. }
  5850. // Some different length found, put it in cache as upper limit of where closer can be found
  5851. state.backticks[closerLength] = matchStart;
  5852. }
  5853. // Scanned through the end, didn't find anything
  5854. state.backticksScanned = true;
  5855. if (!silent) state.pending += marker;
  5856. state.pos += openerLength;
  5857. return true;
  5858. };
  5859. // ~~strike through~~
  5860. // Insert each marker as a separate text token, and add it to delimiter list
  5861. var tokenize$1 = function strikethrough(state, silent) {
  5862. var i, scanned, token, len, ch, start = state.pos, marker = state.src.charCodeAt(start);
  5863. if (silent) {
  5864. return false;
  5865. }
  5866. if (marker !== 126 /* ~ */) {
  5867. return false;
  5868. }
  5869. scanned = state.scanDelims(state.pos, true);
  5870. len = scanned.length;
  5871. ch = String.fromCharCode(marker);
  5872. if (len < 2) {
  5873. return false;
  5874. }
  5875. if (len % 2) {
  5876. token = state.push("text", "", 0);
  5877. token.content = ch;
  5878. len--;
  5879. }
  5880. for (i = 0; i < len; i += 2) {
  5881. token = state.push("text", "", 0);
  5882. token.content = ch + ch;
  5883. state.delimiters.push({
  5884. marker: marker,
  5885. length: 0,
  5886. // disable "rule of 3" length checks meant for emphasis
  5887. token: state.tokens.length - 1,
  5888. end: -1,
  5889. open: scanned.can_open,
  5890. close: scanned.can_close
  5891. });
  5892. }
  5893. state.pos += scanned.length;
  5894. return true;
  5895. };
  5896. function postProcess$1(state, delimiters) {
  5897. var i, j, startDelim, endDelim, token, loneMarkers = [], max = delimiters.length;
  5898. for (i = 0; i < max; i++) {
  5899. startDelim = delimiters[i];
  5900. if (startDelim.marker !== 126 /* ~ */) {
  5901. continue;
  5902. }
  5903. if (startDelim.end === -1) {
  5904. continue;
  5905. }
  5906. endDelim = delimiters[startDelim.end];
  5907. token = state.tokens[startDelim.token];
  5908. token.type = "s_open";
  5909. token.tag = "s";
  5910. token.nesting = 1;
  5911. token.markup = "~~";
  5912. token.content = "";
  5913. token = state.tokens[endDelim.token];
  5914. token.type = "s_close";
  5915. token.tag = "s";
  5916. token.nesting = -1;
  5917. token.markup = "~~";
  5918. token.content = "";
  5919. if (state.tokens[endDelim.token - 1].type === "text" && state.tokens[endDelim.token - 1].content === "~") {
  5920. loneMarkers.push(endDelim.token - 1);
  5921. }
  5922. }
  5923. // If a marker sequence has an odd number of characters, it's splitted
  5924. // like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the
  5925. // start of the sequence.
  5926. // So, we have to move all those markers after subsequent s_close tags.
  5927. while (loneMarkers.length) {
  5928. i = loneMarkers.pop();
  5929. j = i + 1;
  5930. while (j < state.tokens.length && state.tokens[j].type === "s_close") {
  5931. j++;
  5932. }
  5933. j--;
  5934. if (i !== j) {
  5935. token = state.tokens[j];
  5936. state.tokens[j] = state.tokens[i];
  5937. state.tokens[i] = token;
  5938. }
  5939. }
  5940. }
  5941. // Walk through delimiter list and replace text tokens with tags
  5942. var postProcess_1$1 = function strikethrough(state) {
  5943. var curr, tokens_meta = state.tokens_meta, max = state.tokens_meta.length;
  5944. postProcess$1(state, state.delimiters);
  5945. for (curr = 0; curr < max; curr++) {
  5946. if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
  5947. postProcess$1(state, tokens_meta[curr].delimiters);
  5948. }
  5949. }
  5950. };
  5951. var strikethrough = {
  5952. tokenize: tokenize$1,
  5953. postProcess: postProcess_1$1
  5954. };
  5955. // Process *this* and _that_
  5956. // Insert each marker as a separate text token, and add it to delimiter list
  5957. var tokenize = function emphasis(state, silent) {
  5958. var i, scanned, token, start = state.pos, marker = state.src.charCodeAt(start);
  5959. if (silent) {
  5960. return false;
  5961. }
  5962. if (marker !== 95 /* _ */ && marker !== 42 /* * */) {
  5963. return false;
  5964. }
  5965. scanned = state.scanDelims(state.pos, marker === 42);
  5966. for (i = 0; i < scanned.length; i++) {
  5967. token = state.push("text", "", 0);
  5968. token.content = String.fromCharCode(marker);
  5969. state.delimiters.push({
  5970. // Char code of the starting marker (number).
  5971. marker: marker,
  5972. // Total length of these series of delimiters.
  5973. length: scanned.length,
  5974. // A position of the token this delimiter corresponds to.
  5975. token: state.tokens.length - 1,
  5976. // If this delimiter is matched as a valid opener, `end` will be
  5977. // equal to its position, otherwise it's `-1`.
  5978. end: -1,
  5979. // Boolean flags that determine if this delimiter could open or close
  5980. // an emphasis.
  5981. open: scanned.can_open,
  5982. close: scanned.can_close
  5983. });
  5984. }
  5985. state.pos += scanned.length;
  5986. return true;
  5987. };
  5988. function postProcess(state, delimiters) {
  5989. var i, startDelim, endDelim, token, ch, isStrong, max = delimiters.length;
  5990. for (i = max - 1; i >= 0; i--) {
  5991. startDelim = delimiters[i];
  5992. if (startDelim.marker !== 95 /* _ */ && startDelim.marker !== 42 /* * */) {
  5993. continue;
  5994. }
  5995. // Process only opening markers
  5996. if (startDelim.end === -1) {
  5997. continue;
  5998. }
  5999. endDelim = delimiters[startDelim.end];
  6000. // If the previous delimiter has the same marker and is adjacent to this one,
  6001. // merge those into one strong delimiter.
  6002. // `<em><em>whatever</em></em>` -> `<strong>whatever</strong>`
  6003. isStrong = i > 0 && delimiters[i - 1].end === startDelim.end + 1 &&
  6004. // check that first two markers match and adjacent
  6005. delimiters[i - 1].marker === startDelim.marker && delimiters[i - 1].token === startDelim.token - 1 &&
  6006. // check that last two markers are adjacent (we can safely assume they match)
  6007. delimiters[startDelim.end + 1].token === endDelim.token + 1;
  6008. ch = String.fromCharCode(startDelim.marker);
  6009. token = state.tokens[startDelim.token];
  6010. token.type = isStrong ? "strong_open" : "em_open";
  6011. token.tag = isStrong ? "strong" : "em";
  6012. token.nesting = 1;
  6013. token.markup = isStrong ? ch + ch : ch;
  6014. token.content = "";
  6015. token = state.tokens[endDelim.token];
  6016. token.type = isStrong ? "strong_close" : "em_close";
  6017. token.tag = isStrong ? "strong" : "em";
  6018. token.nesting = -1;
  6019. token.markup = isStrong ? ch + ch : ch;
  6020. token.content = "";
  6021. if (isStrong) {
  6022. state.tokens[delimiters[i - 1].token].content = "";
  6023. state.tokens[delimiters[startDelim.end + 1].token].content = "";
  6024. i--;
  6025. }
  6026. }
  6027. }
  6028. // Walk through delimiter list and replace text tokens with tags
  6029. var postProcess_1 = function emphasis(state) {
  6030. var curr, tokens_meta = state.tokens_meta, max = state.tokens_meta.length;
  6031. postProcess(state, state.delimiters);
  6032. for (curr = 0; curr < max; curr++) {
  6033. if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
  6034. postProcess(state, tokens_meta[curr].delimiters);
  6035. }
  6036. }
  6037. };
  6038. var emphasis = {
  6039. tokenize: tokenize,
  6040. postProcess: postProcess_1
  6041. };
  6042. var normalizeReference$1 = utils.normalizeReference;
  6043. var isSpace$1 = utils.isSpace;
  6044. var link = function link(state, silent) {
  6045. var attrs, code, label, labelEnd, labelStart, pos, res, ref, token, href = "", title = "", oldPos = state.pos, max = state.posMax, start = state.pos, parseReference = true;
  6046. if (state.src.charCodeAt(state.pos) !== 91 /* [ */) {
  6047. return false;
  6048. }
  6049. labelStart = state.pos + 1;
  6050. labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, true);
  6051. // parser failed to find ']', so it's not a valid link
  6052. if (labelEnd < 0) {
  6053. return false;
  6054. }
  6055. pos = labelEnd + 1;
  6056. if (pos < max && state.src.charCodeAt(pos) === 40 /* ( */) {
  6057. // Inline link
  6058. // might have found a valid shortcut link, disable reference parsing
  6059. parseReference = false;
  6060. // [link]( <href> "title" )
  6061. // ^^ skipping these spaces
  6062. pos++;
  6063. for (;pos < max; pos++) {
  6064. code = state.src.charCodeAt(pos);
  6065. if (!isSpace$1(code) && code !== 10) {
  6066. break;
  6067. }
  6068. }
  6069. if (pos >= max) {
  6070. return false;
  6071. }
  6072. // [link]( <href> "title" )
  6073. // ^^^^^^ parsing link destination
  6074. start = pos;
  6075. res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
  6076. if (res.ok) {
  6077. href = state.md.normalizeLink(res.str);
  6078. if (state.md.validateLink(href)) {
  6079. pos = res.pos;
  6080. } else {
  6081. href = "";
  6082. }
  6083. // [link]( <href> "title" )
  6084. // ^^ skipping these spaces
  6085. start = pos;
  6086. for (;pos < max; pos++) {
  6087. code = state.src.charCodeAt(pos);
  6088. if (!isSpace$1(code) && code !== 10) {
  6089. break;
  6090. }
  6091. }
  6092. // [link]( <href> "title" )
  6093. // ^^^^^^^ parsing link title
  6094. res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
  6095. if (pos < max && start !== pos && res.ok) {
  6096. title = res.str;
  6097. pos = res.pos;
  6098. // [link]( <href> "title" )
  6099. // ^^ skipping these spaces
  6100. for (;pos < max; pos++) {
  6101. code = state.src.charCodeAt(pos);
  6102. if (!isSpace$1(code) && code !== 10) {
  6103. break;
  6104. }
  6105. }
  6106. }
  6107. }
  6108. if (pos >= max || state.src.charCodeAt(pos) !== 41 /* ) */) {
  6109. // parsing a valid shortcut link failed, fallback to reference
  6110. parseReference = true;
  6111. }
  6112. pos++;
  6113. }
  6114. if (parseReference) {
  6115. // Link reference
  6116. if (typeof state.env.references === "undefined") {
  6117. return false;
  6118. }
  6119. if (pos < max && state.src.charCodeAt(pos) === 91 /* [ */) {
  6120. start = pos + 1;
  6121. pos = state.md.helpers.parseLinkLabel(state, pos);
  6122. if (pos >= 0) {
  6123. label = state.src.slice(start, pos++);
  6124. } else {
  6125. pos = labelEnd + 1;
  6126. }
  6127. } else {
  6128. pos = labelEnd + 1;
  6129. }
  6130. // covers label === '' and label === undefined
  6131. // (collapsed reference link and shortcut reference link respectively)
  6132. if (!label) {
  6133. label = state.src.slice(labelStart, labelEnd);
  6134. }
  6135. ref = state.env.references[normalizeReference$1(label)];
  6136. if (!ref) {
  6137. state.pos = oldPos;
  6138. return false;
  6139. }
  6140. href = ref.href;
  6141. title = ref.title;
  6142. }
  6143. // We found the end of the link, and know for a fact it's a valid link;
  6144. // so all that's left to do is to call tokenizer.
  6145. if (!silent) {
  6146. state.pos = labelStart;
  6147. state.posMax = labelEnd;
  6148. token = state.push("link_open", "a", 1);
  6149. token.attrs = attrs = [ [ "href", href ] ];
  6150. if (title) {
  6151. attrs.push([ "title", title ]);
  6152. }
  6153. state.linkLevel++;
  6154. state.md.inline.tokenize(state);
  6155. state.linkLevel--;
  6156. token = state.push("link_close", "a", -1);
  6157. }
  6158. state.pos = pos;
  6159. state.posMax = max;
  6160. return true;
  6161. };
  6162. var normalizeReference = utils.normalizeReference;
  6163. var isSpace = utils.isSpace;
  6164. var image = function image(state, silent) {
  6165. var attrs, code, content, label, labelEnd, labelStart, pos, ref, res, title, token, tokens, start, href = "", oldPos = state.pos, max = state.posMax;
  6166. if (state.src.charCodeAt(state.pos) !== 33 /* ! */) {
  6167. return false;
  6168. }
  6169. if (state.src.charCodeAt(state.pos + 1) !== 91 /* [ */) {
  6170. return false;
  6171. }
  6172. labelStart = state.pos + 2;
  6173. labelEnd = state.md.helpers.parseLinkLabel(state, state.pos + 1, false);
  6174. // parser failed to find ']', so it's not a valid link
  6175. if (labelEnd < 0) {
  6176. return false;
  6177. }
  6178. pos = labelEnd + 1;
  6179. if (pos < max && state.src.charCodeAt(pos) === 40 /* ( */) {
  6180. // Inline link
  6181. // [link]( <href> "title" )
  6182. // ^^ skipping these spaces
  6183. pos++;
  6184. for (;pos < max; pos++) {
  6185. code = state.src.charCodeAt(pos);
  6186. if (!isSpace(code) && code !== 10) {
  6187. break;
  6188. }
  6189. }
  6190. if (pos >= max) {
  6191. return false;
  6192. }
  6193. // [link]( <href> "title" )
  6194. // ^^^^^^ parsing link destination
  6195. start = pos;
  6196. res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
  6197. if (res.ok) {
  6198. href = state.md.normalizeLink(res.str);
  6199. if (state.md.validateLink(href)) {
  6200. pos = res.pos;
  6201. } else {
  6202. href = "";
  6203. }
  6204. }
  6205. // [link]( <href> "title" )
  6206. // ^^ skipping these spaces
  6207. start = pos;
  6208. for (;pos < max; pos++) {
  6209. code = state.src.charCodeAt(pos);
  6210. if (!isSpace(code) && code !== 10) {
  6211. break;
  6212. }
  6213. }
  6214. // [link]( <href> "title" )
  6215. // ^^^^^^^ parsing link title
  6216. res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
  6217. if (pos < max && start !== pos && res.ok) {
  6218. title = res.str;
  6219. pos = res.pos;
  6220. // [link]( <href> "title" )
  6221. // ^^ skipping these spaces
  6222. for (;pos < max; pos++) {
  6223. code = state.src.charCodeAt(pos);
  6224. if (!isSpace(code) && code !== 10) {
  6225. break;
  6226. }
  6227. }
  6228. } else {
  6229. title = "";
  6230. }
  6231. if (pos >= max || state.src.charCodeAt(pos) !== 41 /* ) */) {
  6232. state.pos = oldPos;
  6233. return false;
  6234. }
  6235. pos++;
  6236. } else {
  6237. // Link reference
  6238. if (typeof state.env.references === "undefined") {
  6239. return false;
  6240. }
  6241. if (pos < max && state.src.charCodeAt(pos) === 91 /* [ */) {
  6242. start = pos + 1;
  6243. pos = state.md.helpers.parseLinkLabel(state, pos);
  6244. if (pos >= 0) {
  6245. label = state.src.slice(start, pos++);
  6246. } else {
  6247. pos = labelEnd + 1;
  6248. }
  6249. } else {
  6250. pos = labelEnd + 1;
  6251. }
  6252. // covers label === '' and label === undefined
  6253. // (collapsed reference link and shortcut reference link respectively)
  6254. if (!label) {
  6255. label = state.src.slice(labelStart, labelEnd);
  6256. }
  6257. ref = state.env.references[normalizeReference(label)];
  6258. if (!ref) {
  6259. state.pos = oldPos;
  6260. return false;
  6261. }
  6262. href = ref.href;
  6263. title = ref.title;
  6264. }
  6265. // We found the end of the link, and know for a fact it's a valid link;
  6266. // so all that's left to do is to call tokenizer.
  6267. if (!silent) {
  6268. content = state.src.slice(labelStart, labelEnd);
  6269. state.md.inline.parse(content, state.md, state.env, tokens = []);
  6270. token = state.push("image", "img", 0);
  6271. token.attrs = attrs = [ [ "src", href ], [ "alt", "" ] ];
  6272. token.children = tokens;
  6273. token.content = content;
  6274. if (title) {
  6275. attrs.push([ "title", title ]);
  6276. }
  6277. }
  6278. state.pos = pos;
  6279. state.posMax = max;
  6280. return true;
  6281. };
  6282. // Process autolinks '<protocol:...>'
  6283. /*eslint max-len:0*/ var EMAIL_RE = /^([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/;
  6284. var AUTOLINK_RE = /^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;
  6285. var autolink = function autolink(state, silent) {
  6286. var url, fullUrl, token, ch, start, max, pos = state.pos;
  6287. if (state.src.charCodeAt(pos) !== 60 /* < */) {
  6288. return false;
  6289. }
  6290. start = state.pos;
  6291. max = state.posMax;
  6292. for (;;) {
  6293. if (++pos >= max) return false;
  6294. ch = state.src.charCodeAt(pos);
  6295. if (ch === 60 /* < */) return false;
  6296. if (ch === 62 /* > */) break;
  6297. }
  6298. url = state.src.slice(start + 1, pos);
  6299. if (AUTOLINK_RE.test(url)) {
  6300. fullUrl = state.md.normalizeLink(url);
  6301. if (!state.md.validateLink(fullUrl)) {
  6302. return false;
  6303. }
  6304. if (!silent) {
  6305. token = state.push("link_open", "a", 1);
  6306. token.attrs = [ [ "href", fullUrl ] ];
  6307. token.markup = "autolink";
  6308. token.info = "auto";
  6309. token = state.push("text", "", 0);
  6310. token.content = state.md.normalizeLinkText(url);
  6311. token = state.push("link_close", "a", -1);
  6312. token.markup = "autolink";
  6313. token.info = "auto";
  6314. }
  6315. state.pos += url.length + 2;
  6316. return true;
  6317. }
  6318. if (EMAIL_RE.test(url)) {
  6319. fullUrl = state.md.normalizeLink("mailto:" + url);
  6320. if (!state.md.validateLink(fullUrl)) {
  6321. return false;
  6322. }
  6323. if (!silent) {
  6324. token = state.push("link_open", "a", 1);
  6325. token.attrs = [ [ "href", fullUrl ] ];
  6326. token.markup = "autolink";
  6327. token.info = "auto";
  6328. token = state.push("text", "", 0);
  6329. token.content = state.md.normalizeLinkText(url);
  6330. token = state.push("link_close", "a", -1);
  6331. token.markup = "autolink";
  6332. token.info = "auto";
  6333. }
  6334. state.pos += url.length + 2;
  6335. return true;
  6336. }
  6337. return false;
  6338. };
  6339. var HTML_TAG_RE = html_re.HTML_TAG_RE;
  6340. function isLinkOpen(str) {
  6341. return /^<a[>\s]/i.test(str);
  6342. }
  6343. function isLinkClose(str) {
  6344. return /^<\/a\s*>/i.test(str);
  6345. }
  6346. function isLetter(ch) {
  6347. /*eslint no-bitwise:0*/
  6348. var lc = ch | 32;
  6349. // to lower case
  6350. return lc >= 97 /* a */ && lc <= 122 /* z */;
  6351. }
  6352. var html_inline = function html_inline(state, silent) {
  6353. var ch, match, max, token, pos = state.pos;
  6354. if (!state.md.options.html) {
  6355. return false;
  6356. }
  6357. // Check start
  6358. max = state.posMax;
  6359. if (state.src.charCodeAt(pos) !== 60 /* < */ || pos + 2 >= max) {
  6360. return false;
  6361. }
  6362. // Quick fail on second char
  6363. ch = state.src.charCodeAt(pos + 1);
  6364. if (ch !== 33 /* ! */ && ch !== 63 /* ? */ && ch !== 47 /* / */ && !isLetter(ch)) {
  6365. return false;
  6366. }
  6367. match = state.src.slice(pos).match(HTML_TAG_RE);
  6368. if (!match) {
  6369. return false;
  6370. }
  6371. if (!silent) {
  6372. token = state.push("html_inline", "", 0);
  6373. token.content = match[0];
  6374. if (isLinkOpen(token.content)) state.linkLevel++;
  6375. if (isLinkClose(token.content)) state.linkLevel--;
  6376. }
  6377. state.pos += match[0].length;
  6378. return true;
  6379. };
  6380. var has = utils.has;
  6381. var isValidEntityCode = utils.isValidEntityCode;
  6382. var fromCodePoint = utils.fromCodePoint;
  6383. var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;
  6384. var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
  6385. var entity = function entity(state, silent) {
  6386. var ch, code, match, token, pos = state.pos, max = state.posMax;
  6387. if (state.src.charCodeAt(pos) !== 38 /* & */) return false;
  6388. if (pos + 1 >= max) return false;
  6389. ch = state.src.charCodeAt(pos + 1);
  6390. if (ch === 35 /* # */) {
  6391. match = state.src.slice(pos).match(DIGITAL_RE);
  6392. if (match) {
  6393. if (!silent) {
  6394. code = match[1][0].toLowerCase() === "x" ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10);
  6395. token = state.push("text_special", "", 0);
  6396. token.content = isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(65533);
  6397. token.markup = match[0];
  6398. token.info = "entity";
  6399. }
  6400. state.pos += match[0].length;
  6401. return true;
  6402. }
  6403. } else {
  6404. match = state.src.slice(pos).match(NAMED_RE);
  6405. if (match) {
  6406. if (has(entities, match[1])) {
  6407. if (!silent) {
  6408. token = state.push("text_special", "", 0);
  6409. token.content = entities[match[1]];
  6410. token.markup = match[0];
  6411. token.info = "entity";
  6412. }
  6413. state.pos += match[0].length;
  6414. return true;
  6415. }
  6416. }
  6417. }
  6418. return false;
  6419. };
  6420. // For each opening emphasis-like marker find a matching closing one
  6421. function processDelimiters(delimiters) {
  6422. var closerIdx, openerIdx, closer, opener, minOpenerIdx, newMinOpenerIdx, isOddMatch, lastJump, openersBottom = {}, max = delimiters.length;
  6423. if (!max) return;
  6424. // headerIdx is the first delimiter of the current (where closer is) delimiter run
  6425. var headerIdx = 0;
  6426. var lastTokenIdx = -2;
  6427. // needs any value lower than -1
  6428. var jumps = [];
  6429. for (closerIdx = 0; closerIdx < max; closerIdx++) {
  6430. closer = delimiters[closerIdx];
  6431. jumps.push(0);
  6432. // markers belong to same delimiter run if:
  6433. // - they have adjacent tokens
  6434. // - AND markers are the same
  6435. if (delimiters[headerIdx].marker !== closer.marker || lastTokenIdx !== closer.token - 1) {
  6436. headerIdx = closerIdx;
  6437. }
  6438. lastTokenIdx = closer.token;
  6439. // Length is only used for emphasis-specific "rule of 3",
  6440. // if it's not defined (in strikethrough or 3rd party plugins),
  6441. // we can default it to 0 to disable those checks.
  6442. closer.length = closer.length || 0;
  6443. if (!closer.close) continue;
  6444. // Previously calculated lower bounds (previous fails)
  6445. // for each marker, each delimiter length modulo 3,
  6446. // and for whether this closer can be an opener;
  6447. // https://github.com/commonmark/cmark/commit/34250e12ccebdc6372b8b49c44fab57c72443460
  6448. if (!openersBottom.hasOwnProperty(closer.marker)) {
  6449. openersBottom[closer.marker] = [ -1, -1, -1, -1, -1, -1 ];
  6450. }
  6451. minOpenerIdx = openersBottom[closer.marker][(closer.open ? 3 : 0) + closer.length % 3];
  6452. openerIdx = headerIdx - jumps[headerIdx] - 1;
  6453. newMinOpenerIdx = openerIdx;
  6454. for (;openerIdx > minOpenerIdx; openerIdx -= jumps[openerIdx] + 1) {
  6455. opener = delimiters[openerIdx];
  6456. if (opener.marker !== closer.marker) continue;
  6457. if (opener.open && opener.end < 0) {
  6458. isOddMatch = false;
  6459. // from spec:
  6460. // If one of the delimiters can both open and close emphasis, then the
  6461. // sum of the lengths of the delimiter runs containing the opening and
  6462. // closing delimiters must not be a multiple of 3 unless both lengths
  6463. // are multiples of 3.
  6464. if (opener.close || closer.open) {
  6465. if ((opener.length + closer.length) % 3 === 0) {
  6466. if (opener.length % 3 !== 0 || closer.length % 3 !== 0) {
  6467. isOddMatch = true;
  6468. }
  6469. }
  6470. }
  6471. if (!isOddMatch) {
  6472. // If previous delimiter cannot be an opener, we can safely skip
  6473. // the entire sequence in future checks. This is required to make
  6474. // sure algorithm has linear complexity (see *_*_*_*_*_... case).
  6475. lastJump = openerIdx > 0 && !delimiters[openerIdx - 1].open ? jumps[openerIdx - 1] + 1 : 0;
  6476. jumps[closerIdx] = closerIdx - openerIdx + lastJump;
  6477. jumps[openerIdx] = lastJump;
  6478. closer.open = false;
  6479. opener.end = closerIdx;
  6480. opener.close = false;
  6481. newMinOpenerIdx = -1;
  6482. // treat next token as start of run,
  6483. // it optimizes skips in **<...>**a**<...>** pathological case
  6484. lastTokenIdx = -2;
  6485. break;
  6486. }
  6487. }
  6488. }
  6489. if (newMinOpenerIdx !== -1) {
  6490. // If match for this delimiter run failed, we want to set lower bound for
  6491. // future lookups. This is required to make sure algorithm has linear
  6492. // complexity.
  6493. // See details here:
  6494. // https://github.com/commonmark/cmark/issues/178#issuecomment-270417442
  6495. openersBottom[closer.marker][(closer.open ? 3 : 0) + (closer.length || 0) % 3] = newMinOpenerIdx;
  6496. }
  6497. }
  6498. }
  6499. var balance_pairs = function link_pairs(state) {
  6500. var curr, tokens_meta = state.tokens_meta, max = state.tokens_meta.length;
  6501. processDelimiters(state.delimiters);
  6502. for (curr = 0; curr < max; curr++) {
  6503. if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
  6504. processDelimiters(tokens_meta[curr].delimiters);
  6505. }
  6506. }
  6507. };
  6508. // Clean up tokens after emphasis and strikethrough postprocessing:
  6509. var fragments_join = function fragments_join(state) {
  6510. var curr, last, level = 0, tokens = state.tokens, max = state.tokens.length;
  6511. for (curr = last = 0; curr < max; curr++) {
  6512. // re-calculate levels after emphasis/strikethrough turns some text nodes
  6513. // into opening/closing tags
  6514. if (tokens[curr].nesting < 0) level--;
  6515. // closing tag
  6516. tokens[curr].level = level;
  6517. if (tokens[curr].nesting > 0) level++;
  6518. // opening tag
  6519. if (tokens[curr].type === "text" && curr + 1 < max && tokens[curr + 1].type === "text") {
  6520. // collapse two adjacent text nodes
  6521. tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
  6522. } else {
  6523. if (curr !== last) {
  6524. tokens[last] = tokens[curr];
  6525. }
  6526. last++;
  6527. }
  6528. }
  6529. if (curr !== last) {
  6530. tokens.length = last;
  6531. }
  6532. };
  6533. var isWhiteSpace = utils.isWhiteSpace;
  6534. var isPunctChar = utils.isPunctChar;
  6535. var isMdAsciiPunct = utils.isMdAsciiPunct;
  6536. function StateInline(src, md, env, outTokens) {
  6537. this.src = src;
  6538. this.env = env;
  6539. this.md = md;
  6540. this.tokens = outTokens;
  6541. this.tokens_meta = Array(outTokens.length);
  6542. this.pos = 0;
  6543. this.posMax = this.src.length;
  6544. this.level = 0;
  6545. this.pending = "";
  6546. this.pendingLevel = 0;
  6547. // Stores { start: end } pairs. Useful for backtrack
  6548. // optimization of pairs parse (emphasis, strikes).
  6549. this.cache = {};
  6550. // List of emphasis-like delimiters for current tag
  6551. this.delimiters = [];
  6552. // Stack of delimiter lists for upper level tags
  6553. this._prev_delimiters = [];
  6554. // backtick length => last seen position
  6555. this.backticks = {};
  6556. this.backticksScanned = false;
  6557. // Counter used to disable inline linkify-it execution
  6558. // inside <a> and markdown links
  6559. this.linkLevel = 0;
  6560. }
  6561. // Flush pending text
  6562. StateInline.prototype.pushPending = function() {
  6563. var token$1 = new token("text", "", 0);
  6564. token$1.content = this.pending;
  6565. token$1.level = this.pendingLevel;
  6566. this.tokens.push(token$1);
  6567. this.pending = "";
  6568. return token$1;
  6569. };
  6570. // Push new token to "stream".
  6571. // If pending text exists - flush it as text token
  6572. StateInline.prototype.push = function(type, tag, nesting) {
  6573. if (this.pending) {
  6574. this.pushPending();
  6575. }
  6576. var token$1 = new token(type, tag, nesting);
  6577. var token_meta = null;
  6578. if (nesting < 0) {
  6579. // closing tag
  6580. this.level--;
  6581. this.delimiters = this._prev_delimiters.pop();
  6582. }
  6583. token$1.level = this.level;
  6584. if (nesting > 0) {
  6585. // opening tag
  6586. this.level++;
  6587. this._prev_delimiters.push(this.delimiters);
  6588. this.delimiters = [];
  6589. token_meta = {
  6590. delimiters: this.delimiters
  6591. };
  6592. }
  6593. this.pendingLevel = this.level;
  6594. this.tokens.push(token$1);
  6595. this.tokens_meta.push(token_meta);
  6596. return token$1;
  6597. };
  6598. // Scan a sequence of emphasis-like markers, and determine whether
  6599. // it can start an emphasis sequence or end an emphasis sequence.
  6600. // - start - position to scan from (it should point at a valid marker);
  6601. // - canSplitWord - determine if these markers can be found inside a word
  6602. StateInline.prototype.scanDelims = function(start, canSplitWord) {
  6603. var pos = start, lastChar, nextChar, count, can_open, can_close, isLastWhiteSpace, isLastPunctChar, isNextWhiteSpace, isNextPunctChar, left_flanking = true, right_flanking = true, max = this.posMax, marker = this.src.charCodeAt(start);
  6604. // treat beginning of the line as a whitespace
  6605. lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 32;
  6606. while (pos < max && this.src.charCodeAt(pos) === marker) {
  6607. pos++;
  6608. }
  6609. count = pos - start;
  6610. // treat end of the line as a whitespace
  6611. nextChar = pos < max ? this.src.charCodeAt(pos) : 32;
  6612. isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
  6613. isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
  6614. isLastWhiteSpace = isWhiteSpace(lastChar);
  6615. isNextWhiteSpace = isWhiteSpace(nextChar);
  6616. if (isNextWhiteSpace) {
  6617. left_flanking = false;
  6618. } else if (isNextPunctChar) {
  6619. if (!(isLastWhiteSpace || isLastPunctChar)) {
  6620. left_flanking = false;
  6621. }
  6622. }
  6623. if (isLastWhiteSpace) {
  6624. right_flanking = false;
  6625. } else if (isLastPunctChar) {
  6626. if (!(isNextWhiteSpace || isNextPunctChar)) {
  6627. right_flanking = false;
  6628. }
  6629. }
  6630. if (!canSplitWord) {
  6631. can_open = left_flanking && (!right_flanking || isLastPunctChar);
  6632. can_close = right_flanking && (!left_flanking || isNextPunctChar);
  6633. } else {
  6634. can_open = left_flanking;
  6635. can_close = right_flanking;
  6636. }
  6637. return {
  6638. can_open: can_open,
  6639. can_close: can_close,
  6640. length: count
  6641. };
  6642. };
  6643. // re-export Token class to use in block rules
  6644. StateInline.prototype.Token = token;
  6645. var state_inline = StateInline;
  6646. ////////////////////////////////////////////////////////////////////////////////
  6647. // Parser rules
  6648. var _rules = [ [ "text", text ], [ "linkify", linkify ], [ "newline", newline ], [ "escape", _escape ], [ "backticks", backticks ], [ "strikethrough", strikethrough.tokenize ], [ "emphasis", emphasis.tokenize ], [ "link", link ], [ "image", image ], [ "autolink", autolink ], [ "html_inline", html_inline ], [ "entity", entity ] ];
  6649. // `rule2` ruleset was created specifically for emphasis/strikethrough
  6650. // post-processing and may be changed in the future.
  6651. // Don't use this for anything except pairs (plugins working with `balance_pairs`).
  6652. var _rules2 = [ [ "balance_pairs", balance_pairs ], [ "strikethrough", strikethrough.postProcess ], [ "emphasis", emphasis.postProcess ],
  6653. // rules for pairs separate '**' into its own text tokens, which may be left unused,
  6654. // rule below merges unused segments back with the rest of the text
  6655. [ "fragments_join", fragments_join ] ];
  6656. /**
  6657. * new ParserInline()
  6658. **/ function ParserInline() {
  6659. var i;
  6660. /**
  6661. * ParserInline#ruler -> Ruler
  6662. *
  6663. * [[Ruler]] instance. Keep configuration of inline rules.
  6664. **/ this.ruler = new ruler;
  6665. for (i = 0; i < _rules.length; i++) {
  6666. this.ruler.push(_rules[i][0], _rules[i][1]);
  6667. }
  6668. /**
  6669. * ParserInline#ruler2 -> Ruler
  6670. *
  6671. * [[Ruler]] instance. Second ruler used for post-processing
  6672. * (e.g. in emphasis-like rules).
  6673. **/ this.ruler2 = new ruler;
  6674. for (i = 0; i < _rules2.length; i++) {
  6675. this.ruler2.push(_rules2[i][0], _rules2[i][1]);
  6676. }
  6677. }
  6678. // Skip single token by running all rules in validation mode;
  6679. // returns `true` if any rule reported success
  6680. ParserInline.prototype.skipToken = function(state) {
  6681. var ok, i, pos = state.pos, rules = this.ruler.getRules(""), len = rules.length, maxNesting = state.md.options.maxNesting, cache = state.cache;
  6682. if (typeof cache[pos] !== "undefined") {
  6683. state.pos = cache[pos];
  6684. return;
  6685. }
  6686. if (state.level < maxNesting) {
  6687. for (i = 0; i < len; i++) {
  6688. // Increment state.level and decrement it later to limit recursion.
  6689. // It's harmless to do here, because no tokens are created. But ideally,
  6690. // we'd need a separate private state variable for this purpose.
  6691. state.level++;
  6692. ok = rules[i](state, true);
  6693. state.level--;
  6694. if (ok) {
  6695. if (pos >= state.pos) {
  6696. throw new Error("inline rule didn't increment state.pos");
  6697. }
  6698. break;
  6699. }
  6700. }
  6701. } else {
  6702. // Too much nesting, just skip until the end of the paragraph.
  6703. // NOTE: this will cause links to behave incorrectly in the following case,
  6704. // when an amount of `[` is exactly equal to `maxNesting + 1`:
  6705. // [[[[[[[[[[[[[[[[[[[[[foo]()
  6706. // TODO: remove this workaround when CM standard will allow nested links
  6707. // (we can replace it by preventing links from being parsed in
  6708. // validation mode)
  6709. state.pos = state.posMax;
  6710. }
  6711. if (!ok) {
  6712. state.pos++;
  6713. }
  6714. cache[pos] = state.pos;
  6715. };
  6716. // Generate tokens for input range
  6717. ParserInline.prototype.tokenize = function(state) {
  6718. var ok, i, prevPos, rules = this.ruler.getRules(""), len = rules.length, end = state.posMax, maxNesting = state.md.options.maxNesting;
  6719. while (state.pos < end) {
  6720. // Try all possible rules.
  6721. // On success, rule should:
  6722. // - update `state.pos`
  6723. // - update `state.tokens`
  6724. // - return true
  6725. prevPos = state.pos;
  6726. if (state.level < maxNesting) {
  6727. for (i = 0; i < len; i++) {
  6728. ok = rules[i](state, false);
  6729. if (ok) {
  6730. if (prevPos >= state.pos) {
  6731. throw new Error("inline rule didn't increment state.pos");
  6732. }
  6733. break;
  6734. }
  6735. }
  6736. }
  6737. if (ok) {
  6738. if (state.pos >= end) {
  6739. break;
  6740. }
  6741. continue;
  6742. }
  6743. state.pending += state.src[state.pos++];
  6744. }
  6745. if (state.pending) {
  6746. state.pushPending();
  6747. }
  6748. };
  6749. /**
  6750. * ParserInline.parse(str, md, env, outTokens)
  6751. *
  6752. * Process input string and push inline tokens into `outTokens`
  6753. **/ ParserInline.prototype.parse = function(str, md, env, outTokens) {
  6754. var i, rules, len;
  6755. var state = new this.State(str, md, env, outTokens);
  6756. this.tokenize(state);
  6757. rules = this.ruler2.getRules("");
  6758. len = rules.length;
  6759. for (i = 0; i < len; i++) {
  6760. rules[i](state);
  6761. }
  6762. };
  6763. ParserInline.prototype.State = state_inline;
  6764. var parser_inline = ParserInline;
  6765. var re = function(opts) {
  6766. var re = {};
  6767. opts = opts || {};
  6768. // Use direct extract instead of `regenerate` to reduse browserified size
  6769. re.src_Any = regex$3.source;
  6770. re.src_Cc = regex$2.source;
  6771. re.src_Z = regex.source;
  6772. re.src_P = regex$4.source;
  6773. // \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation)
  6774. re.src_ZPCc = [ re.src_Z, re.src_P, re.src_Cc ].join("|");
  6775. // \p{\Z\Cc} (white spaces + control)
  6776. re.src_ZCc = [ re.src_Z, re.src_Cc ].join("|");
  6777. // Experimental. List of chars, completely prohibited in links
  6778. // because can separate it from other part of text
  6779. var text_separators = "[><\uff5c]";
  6780. // All possible word characters (everything without punctuation, spaces & controls)
  6781. // Defined via punctuation & spaces to save space
  6782. // Should be something like \p{\L\N\S\M} (\w but without `_`)
  6783. re.src_pseudo_letter = "(?:(?!" + text_separators + "|" + re.src_ZPCc + ")" + re.src_Any + ")";
  6784. // The same as abothe but without [0-9]
  6785. // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
  6786. ////////////////////////////////////////////////////////////////////////////////
  6787. re.src_ip4 = "(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)";
  6788. // Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
  6789. re.src_auth = "(?:(?:(?!" + re.src_ZCc + "|[@/\\[\\]()]).)+@)?";
  6790. re.src_port = "(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?";
  6791. re.src_host_terminator = "(?=$|" + text_separators + "|" + re.src_ZPCc + ")" + "(?!" + (opts["---"] ? "-(?!--)|" : "-|") + "_|:\\d|\\.-|\\.(?!$|" + re.src_ZPCc + "))";
  6792. re.src_path = "(?:" + "[/?#]" + "(?:" + "(?!" + re.src_ZCc + "|" + text_separators + "|[()[\\]{}.,\"'?!\\-;]).|" + "\\[(?:(?!" + re.src_ZCc + "|\\]).)*\\]|" + "\\((?:(?!" + re.src_ZCc + "|[)]).)*\\)|" + "\\{(?:(?!" + re.src_ZCc + "|[}]).)*\\}|" + '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' + "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" + "\\'(?=" + re.src_pseudo_letter + "|[-])|" + // allow `I'm_king` if no pair found
  6793. "\\.{2,}[a-zA-Z0-9%/&]|" + // google has many dots in "google search" links (#66, #81).
  6794. // github has ... in commit range links,
  6795. // Restrict to
  6796. // - english
  6797. // - percent-encoded
  6798. // - parts of file path
  6799. // - params separator
  6800. // until more examples found.
  6801. "\\.(?!" + re.src_ZCc + "|[.]|$)|" + (opts["---"] ? "\\-(?!--(?:[^-]|$))(?:-*)|" : "\\-+|") + ",(?!" + re.src_ZCc + "|$)|" + // allow `,,,` in paths
  6802. ";(?!" + re.src_ZCc + "|$)|" + // allow `;` if not followed by space-like char
  6803. "\\!+(?!" + re.src_ZCc + "|[!]|$)|" + // allow `!!!` in paths, but not at the end
  6804. "\\?(?!" + re.src_ZCc + "|[?]|$)" + ")+" + "|\\/" + ")?";
  6805. // Allow anything in markdown spec, forbid quote (") at the first position
  6806. // because emails enclosed in quotes are far more common
  6807. re.src_email_name = '[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*';
  6808. re.src_xn = "xn--[a-z0-9\\-]{1,59}";
  6809. // More to read about domain names
  6810. // http://serverfault.com/questions/638260/
  6811. re.src_domain_root =
  6812. // Allow letters & digits (http://test1)
  6813. "(?:" + re.src_xn + "|" + re.src_pseudo_letter + "{1,63}" + ")";
  6814. re.src_domain = "(?:" + re.src_xn + "|" + "(?:" + re.src_pseudo_letter + ")" + "|" + "(?:" + re.src_pseudo_letter + "(?:-|" + re.src_pseudo_letter + "){0,61}" + re.src_pseudo_letter + ")" + ")";
  6815. re.src_host = "(?:" +
  6816. // Don't need IP check, because digits are already allowed in normal domain names
  6817. // src_ip4 +
  6818. // '|' +
  6819. "(?:(?:(?:" + re.src_domain + ")\\.)*" + re.src_domain /*_root*/ + ")" + ")";
  6820. re.tpl_host_fuzzy = "(?:" + re.src_ip4 + "|" + "(?:(?:(?:" + re.src_domain + ")\\.)+(?:%TLDS%))" + ")";
  6821. re.tpl_host_no_ip_fuzzy = "(?:(?:(?:" + re.src_domain + ")\\.)+(?:%TLDS%))";
  6822. re.src_host_strict = re.src_host + re.src_host_terminator;
  6823. re.tpl_host_fuzzy_strict = re.tpl_host_fuzzy + re.src_host_terminator;
  6824. re.src_host_port_strict = re.src_host + re.src_port + re.src_host_terminator;
  6825. re.tpl_host_port_fuzzy_strict = re.tpl_host_fuzzy + re.src_port + re.src_host_terminator;
  6826. re.tpl_host_port_no_ip_fuzzy_strict = re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
  6827. ////////////////////////////////////////////////////////////////////////////////
  6828. // Main rules
  6829. // Rude test fuzzy links by host, for quick deny
  6830. re.tpl_host_fuzzy_test = "localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:" + re.src_ZPCc + "|>|$))";
  6831. re.tpl_email_fuzzy = "(^|" + text_separators + '|"|\\(|' + re.src_ZCc + ")" + "(" + re.src_email_name + "@" + re.tpl_host_fuzzy_strict + ")";
  6832. re.tpl_link_fuzzy =
  6833. // Fuzzy link can't be prepended with .:/\- and non punctuation.
  6834. // but can start with > (markdown blockquote)
  6835. "(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|" + re.src_ZPCc + "))" + "((?![$+<=>^`|\uff5c])" + re.tpl_host_port_fuzzy_strict + re.src_path + ")";
  6836. re.tpl_link_no_ip_fuzzy =
  6837. // Fuzzy link can't be prepended with .:/\- and non punctuation.
  6838. // but can start with > (markdown blockquote)
  6839. "(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|" + re.src_ZPCc + "))" + "((?![$+<=>^`|\uff5c])" + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ")";
  6840. return re;
  6841. };
  6842. ////////////////////////////////////////////////////////////////////////////////
  6843. // Helpers
  6844. // Merge objects
  6845. function assign(obj /*from1, from2, from3, ...*/) {
  6846. var sources = Array.prototype.slice.call(arguments, 1);
  6847. sources.forEach((function(source) {
  6848. if (!source) {
  6849. return;
  6850. }
  6851. Object.keys(source).forEach((function(key) {
  6852. obj[key] = source[key];
  6853. }));
  6854. }));
  6855. return obj;
  6856. }
  6857. function _class(obj) {
  6858. return Object.prototype.toString.call(obj);
  6859. }
  6860. function isString(obj) {
  6861. return _class(obj) === "[object String]";
  6862. }
  6863. function isObject(obj) {
  6864. return _class(obj) === "[object Object]";
  6865. }
  6866. function isRegExp(obj) {
  6867. return _class(obj) === "[object RegExp]";
  6868. }
  6869. function isFunction(obj) {
  6870. return _class(obj) === "[object Function]";
  6871. }
  6872. function escapeRE(str) {
  6873. return str.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
  6874. }
  6875. ////////////////////////////////////////////////////////////////////////////////
  6876. var defaultOptions = {
  6877. fuzzyLink: true,
  6878. fuzzyEmail: true,
  6879. fuzzyIP: false
  6880. };
  6881. function isOptionsObj(obj) {
  6882. return Object.keys(obj || {}).reduce((function(acc, k) {
  6883. return acc || defaultOptions.hasOwnProperty(k);
  6884. }), false);
  6885. }
  6886. var defaultSchemas = {
  6887. "http:": {
  6888. validate: function(text, pos, self) {
  6889. var tail = text.slice(pos);
  6890. if (!self.re.http) {
  6891. // compile lazily, because "host"-containing variables can change on tlds update.
  6892. self.re.http = new RegExp("^\\/\\/" + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path, "i");
  6893. }
  6894. if (self.re.http.test(tail)) {
  6895. return tail.match(self.re.http)[0].length;
  6896. }
  6897. return 0;
  6898. }
  6899. },
  6900. "https:": "http:",
  6901. "ftp:": "http:",
  6902. "//": {
  6903. validate: function(text, pos, self) {
  6904. var tail = text.slice(pos);
  6905. if (!self.re.no_http) {
  6906. // compile lazily, because "host"-containing variables can change on tlds update.
  6907. self.re.no_http = new RegExp("^" + self.re.src_auth +
  6908. // Don't allow single-level domains, because of false positives like '//test'
  6909. // with code comments
  6910. "(?:localhost|(?:(?:" + self.re.src_domain + ")\\.)+" + self.re.src_domain_root + ")" + self.re.src_port + self.re.src_host_terminator + self.re.src_path, "i");
  6911. }
  6912. if (self.re.no_http.test(tail)) {
  6913. // should not be `://` & `///`, that protects from errors in protocol name
  6914. if (pos >= 3 && text[pos - 3] === ":") {
  6915. return 0;
  6916. }
  6917. if (pos >= 3 && text[pos - 3] === "/") {
  6918. return 0;
  6919. }
  6920. return tail.match(self.re.no_http)[0].length;
  6921. }
  6922. return 0;
  6923. }
  6924. },
  6925. "mailto:": {
  6926. validate: function(text, pos, self) {
  6927. var tail = text.slice(pos);
  6928. if (!self.re.mailto) {
  6929. self.re.mailto = new RegExp("^" + self.re.src_email_name + "@" + self.re.src_host_strict, "i");
  6930. }
  6931. if (self.re.mailto.test(tail)) {
  6932. return tail.match(self.re.mailto)[0].length;
  6933. }
  6934. return 0;
  6935. }
  6936. }
  6937. };
  6938. /*eslint-disable max-len*/
  6939. // RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)
  6940. var tlds_2ch_src_re = "a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]";
  6941. // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
  6942. var tlds_default = "biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");
  6943. /*eslint-enable max-len*/
  6944. ////////////////////////////////////////////////////////////////////////////////
  6945. function resetScanCache(self) {
  6946. self.__index__ = -1;
  6947. self.__text_cache__ = "";
  6948. }
  6949. function createValidator(re) {
  6950. return function(text, pos) {
  6951. var tail = text.slice(pos);
  6952. if (re.test(tail)) {
  6953. return tail.match(re)[0].length;
  6954. }
  6955. return 0;
  6956. };
  6957. }
  6958. function createNormalizer() {
  6959. return function(match, self) {
  6960. self.normalize(match);
  6961. };
  6962. }
  6963. // Schemas compiler. Build regexps.
  6964. function compile(self) {
  6965. // Load & clone RE patterns.
  6966. var re$1 = self.re = re(self.__opts__);
  6967. // Define dynamic patterns
  6968. var tlds = self.__tlds__.slice();
  6969. self.onCompile();
  6970. if (!self.__tlds_replaced__) {
  6971. tlds.push(tlds_2ch_src_re);
  6972. }
  6973. tlds.push(re$1.src_xn);
  6974. re$1.src_tlds = tlds.join("|");
  6975. function untpl(tpl) {
  6976. return tpl.replace("%TLDS%", re$1.src_tlds);
  6977. }
  6978. re$1.email_fuzzy = RegExp(untpl(re$1.tpl_email_fuzzy), "i");
  6979. re$1.link_fuzzy = RegExp(untpl(re$1.tpl_link_fuzzy), "i");
  6980. re$1.link_no_ip_fuzzy = RegExp(untpl(re$1.tpl_link_no_ip_fuzzy), "i");
  6981. re$1.host_fuzzy_test = RegExp(untpl(re$1.tpl_host_fuzzy_test), "i");
  6982. // Compile each schema
  6983. var aliases = [];
  6984. self.__compiled__ = {};
  6985. // Reset compiled data
  6986. function schemaError(name, val) {
  6987. throw new Error('(LinkifyIt) Invalid schema "' + name + '": ' + val);
  6988. }
  6989. Object.keys(self.__schemas__).forEach((function(name) {
  6990. var val = self.__schemas__[name];
  6991. // skip disabled methods
  6992. if (val === null) {
  6993. return;
  6994. }
  6995. var compiled = {
  6996. validate: null,
  6997. link: null
  6998. };
  6999. self.__compiled__[name] = compiled;
  7000. if (isObject(val)) {
  7001. if (isRegExp(val.validate)) {
  7002. compiled.validate = createValidator(val.validate);
  7003. } else if (isFunction(val.validate)) {
  7004. compiled.validate = val.validate;
  7005. } else {
  7006. schemaError(name, val);
  7007. }
  7008. if (isFunction(val.normalize)) {
  7009. compiled.normalize = val.normalize;
  7010. } else if (!val.normalize) {
  7011. compiled.normalize = createNormalizer();
  7012. } else {
  7013. schemaError(name, val);
  7014. }
  7015. return;
  7016. }
  7017. if (isString(val)) {
  7018. aliases.push(name);
  7019. return;
  7020. }
  7021. schemaError(name, val);
  7022. }));
  7023. // Compile postponed aliases
  7024. aliases.forEach((function(alias) {
  7025. if (!self.__compiled__[self.__schemas__[alias]]) {
  7026. // Silently fail on missed schemas to avoid errons on disable.
  7027. // schemaError(alias, self.__schemas__[alias]);
  7028. return;
  7029. }
  7030. self.__compiled__[alias].validate = self.__compiled__[self.__schemas__[alias]].validate;
  7031. self.__compiled__[alias].normalize = self.__compiled__[self.__schemas__[alias]].normalize;
  7032. }));
  7033. // Fake record for guessed links
  7034. self.__compiled__[""] = {
  7035. validate: null,
  7036. normalize: createNormalizer()
  7037. };
  7038. // Build schema condition
  7039. var slist = Object.keys(self.__compiled__).filter((function(name) {
  7040. // Filter disabled & fake schemas
  7041. return name.length > 0 && self.__compiled__[name];
  7042. })).map(escapeRE).join("|");
  7043. // (?!_) cause 1.5x slowdown
  7044. self.re.schema_test = RegExp("(^|(?!_)(?:[><\uff5c]|" + re$1.src_ZPCc + "))(" + slist + ")", "i");
  7045. self.re.schema_search = RegExp("(^|(?!_)(?:[><\uff5c]|" + re$1.src_ZPCc + "))(" + slist + ")", "ig");
  7046. self.re.schema_at_start = RegExp("^" + self.re.schema_search.source, "i");
  7047. self.re.pretest = RegExp("(" + self.re.schema_test.source + ")|(" + self.re.host_fuzzy_test.source + ")|@", "i");
  7048. // Cleanup
  7049. resetScanCache(self);
  7050. }
  7051. /**
  7052. * class Match
  7053. *
  7054. * Match result. Single element of array, returned by [[LinkifyIt#match]]
  7055. **/ function Match(self, shift) {
  7056. var start = self.__index__, end = self.__last_index__, text = self.__text_cache__.slice(start, end);
  7057. /**
  7058. * Match#schema -> String
  7059. *
  7060. * Prefix (protocol) for matched string.
  7061. **/ this.schema = self.__schema__.toLowerCase();
  7062. /**
  7063. * Match#index -> Number
  7064. *
  7065. * First position of matched string.
  7066. **/ this.index = start + shift;
  7067. /**
  7068. * Match#lastIndex -> Number
  7069. *
  7070. * Next position after matched string.
  7071. **/ this.lastIndex = end + shift;
  7072. /**
  7073. * Match#raw -> String
  7074. *
  7075. * Matched string.
  7076. **/ this.raw = text;
  7077. /**
  7078. * Match#text -> String
  7079. *
  7080. * Notmalized text of matched string.
  7081. **/ this.text = text;
  7082. /**
  7083. * Match#url -> String
  7084. *
  7085. * Normalized url of matched string.
  7086. **/ this.url = text;
  7087. }
  7088. function createMatch(self, shift) {
  7089. var match = new Match(self, shift);
  7090. self.__compiled__[match.schema].normalize(match, self);
  7091. return match;
  7092. }
  7093. /**
  7094. * class LinkifyIt
  7095. **/
  7096. /**
  7097. * new LinkifyIt(schemas, options)
  7098. * - schemas (Object): Optional. Additional schemas to validate (prefix/validator)
  7099. * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
  7100. *
  7101. * Creates new linkifier instance with optional additional schemas.
  7102. * Can be called without `new` keyword for convenience.
  7103. *
  7104. * By default understands:
  7105. *
  7106. * - `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links
  7107. * - "fuzzy" links and emails (example.com, foo@bar.com).
  7108. *
  7109. * `schemas` is an object, where each key/value describes protocol/rule:
  7110. *
  7111. * - __key__ - link prefix (usually, protocol name with `:` at the end, `skype:`
  7112. * for example). `linkify-it` makes shure that prefix is not preceeded with
  7113. * alphanumeric char and symbols. Only whitespaces and punctuation allowed.
  7114. * - __value__ - rule to check tail after link prefix
  7115. * - _String_ - just alias to existing rule
  7116. * - _Object_
  7117. * - _validate_ - validator function (should return matched length on success),
  7118. * or `RegExp`.
  7119. * - _normalize_ - optional function to normalize text & url of matched result
  7120. * (for example, for @twitter mentions).
  7121. *
  7122. * `options`:
  7123. *
  7124. * - __fuzzyLink__ - recognige URL-s without `http(s):` prefix. Default `true`.
  7125. * - __fuzzyIP__ - allow IPs in fuzzy links above. Can conflict with some texts
  7126. * like version numbers. Default `false`.
  7127. * - __fuzzyEmail__ - recognize emails without `mailto:` prefix.
  7128. *
  7129. **/ function LinkifyIt(schemas, options) {
  7130. if (!(this instanceof LinkifyIt)) {
  7131. return new LinkifyIt(schemas, options);
  7132. }
  7133. if (!options) {
  7134. if (isOptionsObj(schemas)) {
  7135. options = schemas;
  7136. schemas = {};
  7137. }
  7138. }
  7139. this.__opts__ = assign({}, defaultOptions, options);
  7140. // Cache last tested result. Used to skip repeating steps on next `match` call.
  7141. this.__index__ = -1;
  7142. this.__last_index__ = -1;
  7143. // Next scan position
  7144. this.__schema__ = "";
  7145. this.__text_cache__ = "";
  7146. this.__schemas__ = assign({}, defaultSchemas, schemas);
  7147. this.__compiled__ = {};
  7148. this.__tlds__ = tlds_default;
  7149. this.__tlds_replaced__ = false;
  7150. this.re = {};
  7151. compile(this);
  7152. }
  7153. /** chainable
  7154. * LinkifyIt#add(schema, definition)
  7155. * - schema (String): rule name (fixed pattern prefix)
  7156. * - definition (String|RegExp|Object): schema definition
  7157. *
  7158. * Add new rule definition. See constructor description for details.
  7159. **/ LinkifyIt.prototype.add = function add(schema, definition) {
  7160. this.__schemas__[schema] = definition;
  7161. compile(this);
  7162. return this;
  7163. };
  7164. /** chainable
  7165. * LinkifyIt#set(options)
  7166. * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
  7167. *
  7168. * Set recognition options for links without schema.
  7169. **/ LinkifyIt.prototype.set = function set(options) {
  7170. this.__opts__ = assign(this.__opts__, options);
  7171. return this;
  7172. };
  7173. /**
  7174. * LinkifyIt#test(text) -> Boolean
  7175. *
  7176. * Searches linkifiable pattern and returns `true` on success or `false` on fail.
  7177. **/ LinkifyIt.prototype.test = function test(text) {
  7178. // Reset scan cache
  7179. this.__text_cache__ = text;
  7180. this.__index__ = -1;
  7181. if (!text.length) {
  7182. return false;
  7183. }
  7184. var m, ml, me, len, shift, next, re, tld_pos, at_pos;
  7185. // try to scan for link with schema - that's the most simple rule
  7186. if (this.re.schema_test.test(text)) {
  7187. re = this.re.schema_search;
  7188. re.lastIndex = 0;
  7189. while ((m = re.exec(text)) !== null) {
  7190. len = this.testSchemaAt(text, m[2], re.lastIndex);
  7191. if (len) {
  7192. this.__schema__ = m[2];
  7193. this.__index__ = m.index + m[1].length;
  7194. this.__last_index__ = m.index + m[0].length + len;
  7195. break;
  7196. }
  7197. }
  7198. }
  7199. if (this.__opts__.fuzzyLink && this.__compiled__["http:"]) {
  7200. // guess schemaless links
  7201. tld_pos = text.search(this.re.host_fuzzy_test);
  7202. if (tld_pos >= 0) {
  7203. // if tld is located after found link - no need to check fuzzy pattern
  7204. if (this.__index__ < 0 || tld_pos < this.__index__) {
  7205. if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
  7206. shift = ml.index + ml[1].length;
  7207. if (this.__index__ < 0 || shift < this.__index__) {
  7208. this.__schema__ = "";
  7209. this.__index__ = shift;
  7210. this.__last_index__ = ml.index + ml[0].length;
  7211. }
  7212. }
  7213. }
  7214. }
  7215. }
  7216. if (this.__opts__.fuzzyEmail && this.__compiled__["mailto:"]) {
  7217. // guess schemaless emails
  7218. at_pos = text.indexOf("@");
  7219. if (at_pos >= 0) {
  7220. // We can't skip this check, because this cases are possible:
  7221. // 192.168.1.1@gmail.com, my.in@example.com
  7222. if ((me = text.match(this.re.email_fuzzy)) !== null) {
  7223. shift = me.index + me[1].length;
  7224. next = me.index + me[0].length;
  7225. if (this.__index__ < 0 || shift < this.__index__ || shift === this.__index__ && next > this.__last_index__) {
  7226. this.__schema__ = "mailto:";
  7227. this.__index__ = shift;
  7228. this.__last_index__ = next;
  7229. }
  7230. }
  7231. }
  7232. }
  7233. return this.__index__ >= 0;
  7234. };
  7235. /**
  7236. * LinkifyIt#pretest(text) -> Boolean
  7237. *
  7238. * Very quick check, that can give false positives. Returns true if link MAY BE
  7239. * can exists. Can be used for speed optimization, when you need to check that
  7240. * link NOT exists.
  7241. **/ LinkifyIt.prototype.pretest = function pretest(text) {
  7242. return this.re.pretest.test(text);
  7243. };
  7244. /**
  7245. * LinkifyIt#testSchemaAt(text, name, position) -> Number
  7246. * - text (String): text to scan
  7247. * - name (String): rule (schema) name
  7248. * - position (Number): text offset to check from
  7249. *
  7250. * Similar to [[LinkifyIt#test]] but checks only specific protocol tail exactly
  7251. * at given position. Returns length of found pattern (0 on fail).
  7252. **/ LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {
  7253. // If not supported schema check requested - terminate
  7254. if (!this.__compiled__[schema.toLowerCase()]) {
  7255. return 0;
  7256. }
  7257. return this.__compiled__[schema.toLowerCase()].validate(text, pos, this);
  7258. };
  7259. /**
  7260. * LinkifyIt#match(text) -> Array|null
  7261. *
  7262. * Returns array of found link descriptions or `null` on fail. We strongly
  7263. * recommend to use [[LinkifyIt#test]] first, for best speed.
  7264. *
  7265. * ##### Result match description
  7266. *
  7267. * - __schema__ - link schema, can be empty for fuzzy links, or `//` for
  7268. * protocol-neutral links.
  7269. * - __index__ - offset of matched text
  7270. * - __lastIndex__ - index of next char after mathch end
  7271. * - __raw__ - matched text
  7272. * - __text__ - normalized text
  7273. * - __url__ - link, generated from matched text
  7274. **/ LinkifyIt.prototype.match = function match(text) {
  7275. var shift = 0, result = [];
  7276. // Try to take previous element from cache, if .test() called before
  7277. if (this.__index__ >= 0 && this.__text_cache__ === text) {
  7278. result.push(createMatch(this, shift));
  7279. shift = this.__last_index__;
  7280. }
  7281. // Cut head if cache was used
  7282. var tail = shift ? text.slice(shift) : text;
  7283. // Scan string until end reached
  7284. while (this.test(tail)) {
  7285. result.push(createMatch(this, shift));
  7286. tail = tail.slice(this.__last_index__);
  7287. shift += this.__last_index__;
  7288. }
  7289. if (result.length) {
  7290. return result;
  7291. }
  7292. return null;
  7293. };
  7294. /**
  7295. * LinkifyIt#matchAtStart(text) -> Match|null
  7296. *
  7297. * Returns fully-formed (not fuzzy) link if it starts at the beginning
  7298. * of the string, and null otherwise.
  7299. **/ LinkifyIt.prototype.matchAtStart = function matchAtStart(text) {
  7300. // Reset scan cache
  7301. this.__text_cache__ = text;
  7302. this.__index__ = -1;
  7303. if (!text.length) return null;
  7304. var m = this.re.schema_at_start.exec(text);
  7305. if (!m) return null;
  7306. var len = this.testSchemaAt(text, m[2], m[0].length);
  7307. if (!len) return null;
  7308. this.__schema__ = m[2];
  7309. this.__index__ = m.index + m[1].length;
  7310. this.__last_index__ = m.index + m[0].length + len;
  7311. return createMatch(this, 0);
  7312. };
  7313. /** chainable
  7314. * LinkifyIt#tlds(list [, keepOld]) -> this
  7315. * - list (Array): list of tlds
  7316. * - keepOld (Boolean): merge with current list if `true` (`false` by default)
  7317. *
  7318. * Load (or merge) new tlds list. Those are user for fuzzy links (without prefix)
  7319. * to avoid false positives. By default this algorythm used:
  7320. *
  7321. * - hostname with any 2-letter root zones are ok.
  7322. * - biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф
  7323. * are ok.
  7324. * - encoded (`xn--...`) root zones are ok.
  7325. *
  7326. * If list is replaced, then exact match for 2-chars root zones will be checked.
  7327. **/ LinkifyIt.prototype.tlds = function tlds(list, keepOld) {
  7328. list = Array.isArray(list) ? list : [ list ];
  7329. if (!keepOld) {
  7330. this.__tlds__ = list.slice();
  7331. this.__tlds_replaced__ = true;
  7332. compile(this);
  7333. return this;
  7334. }
  7335. this.__tlds__ = this.__tlds__.concat(list).sort().filter((function(el, idx, arr) {
  7336. return el !== arr[idx - 1];
  7337. })).reverse();
  7338. compile(this);
  7339. return this;
  7340. };
  7341. /**
  7342. * LinkifyIt#normalize(match)
  7343. *
  7344. * Default normalizer (if schema does not define it's own).
  7345. **/ LinkifyIt.prototype.normalize = function normalize(match) {
  7346. // Do minimal possible changes by default. Need to collect feedback prior
  7347. // to move forward https://github.com/markdown-it/linkify-it/issues/1
  7348. if (!match.schema) {
  7349. match.url = "http://" + match.url;
  7350. }
  7351. if (match.schema === "mailto:" && !/^mailto:/i.test(match.url)) {
  7352. match.url = "mailto:" + match.url;
  7353. }
  7354. };
  7355. /**
  7356. * LinkifyIt#onCompile()
  7357. *
  7358. * Override to modify basic RegExp-s.
  7359. **/ LinkifyIt.prototype.onCompile = function onCompile() {};
  7360. var linkifyIt = LinkifyIt;
  7361. /*! https://mths.be/punycode v1.4.1 by @mathias */
  7362. /** Highest positive signed 32-bit float value */ var maxInt = 2147483647;
  7363. // aka. 0x7FFFFFFF or 2^31-1
  7364. /** Bootstring parameters */ var base = 36;
  7365. var tMin = 1;
  7366. var tMax = 26;
  7367. var skew = 38;
  7368. var damp = 700;
  7369. var initialBias = 72;
  7370. var initialN = 128;
  7371. // 0x80
  7372. var delimiter = "-";
  7373. // '\x2D'
  7374. /** Regular expressions */ var regexPunycode = /^xn--/;
  7375. var regexNonASCII = /[^\x20-\x7E]/;
  7376. // unprintable ASCII chars + non-ASCII chars
  7377. var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
  7378. // RFC 3490 separators
  7379. /** Error messages */ var errors = {
  7380. overflow: "Overflow: input needs wider integers to process",
  7381. "not-basic": "Illegal input >= 0x80 (not a basic code point)",
  7382. "invalid-input": "Invalid input"
  7383. };
  7384. /** Convenience shortcuts */ var baseMinusTMin = base - tMin;
  7385. var floor = Math.floor;
  7386. var stringFromCharCode = String.fromCharCode;
  7387. /*--------------------------------------------------------------------------*/
  7388. /**
  7389. * A generic error utility function.
  7390. * @private
  7391. * @param {String} type The error type.
  7392. * @returns {Error} Throws a `RangeError` with the applicable error message.
  7393. */ function error(type) {
  7394. throw new RangeError(errors[type]);
  7395. }
  7396. /**
  7397. * A generic `Array#map` utility function.
  7398. * @private
  7399. * @param {Array} array The array to iterate over.
  7400. * @param {Function} callback The function that gets called for every array
  7401. * item.
  7402. * @returns {Array} A new array of values returned by the callback function.
  7403. */ function map(array, fn) {
  7404. var length = array.length;
  7405. var result = [];
  7406. while (length--) {
  7407. result[length] = fn(array[length]);
  7408. }
  7409. return result;
  7410. }
  7411. /**
  7412. * A simple `Array#map`-like wrapper to work with domain name strings or email
  7413. * addresses.
  7414. * @private
  7415. * @param {String} domain The domain name or email address.
  7416. * @param {Function} callback The function that gets called for every
  7417. * character.
  7418. * @returns {Array} A new string of characters returned by the callback
  7419. * function.
  7420. */ function mapDomain(string, fn) {
  7421. var parts = string.split("@");
  7422. var result = "";
  7423. if (parts.length > 1) {
  7424. // In email addresses, only the domain name should be punycoded. Leave
  7425. // the local part (i.e. everything up to `@`) intact.
  7426. result = parts[0] + "@";
  7427. string = parts[1];
  7428. }
  7429. // Avoid `split(regex)` for IE8 compatibility. See #17.
  7430. string = string.replace(regexSeparators, ".");
  7431. var labels = string.split(".");
  7432. var encoded = map(labels, fn).join(".");
  7433. return result + encoded;
  7434. }
  7435. /**
  7436. * Creates an array containing the numeric code points of each Unicode
  7437. * character in the string. While JavaScript uses UCS-2 internally,
  7438. * this function will convert a pair of surrogate halves (each of which
  7439. * UCS-2 exposes as separate characters) into a single code point,
  7440. * matching UTF-16.
  7441. * @see `punycode.ucs2.encode`
  7442. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  7443. * @memberOf punycode.ucs2
  7444. * @name decode
  7445. * @param {String} string The Unicode input string (UCS-2).
  7446. * @returns {Array} The new array of code points.
  7447. */ function ucs2decode(string) {
  7448. var output = [], counter = 0, length = string.length, value, extra;
  7449. while (counter < length) {
  7450. value = string.charCodeAt(counter++);
  7451. if (value >= 55296 && value <= 56319 && counter < length) {
  7452. // high surrogate, and there is a next character
  7453. extra = string.charCodeAt(counter++);
  7454. if ((extra & 64512) == 56320) {
  7455. // low surrogate
  7456. output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
  7457. } else {
  7458. // unmatched surrogate; only append this code unit, in case the next
  7459. // code unit is the high surrogate of a surrogate pair
  7460. output.push(value);
  7461. counter--;
  7462. }
  7463. } else {
  7464. output.push(value);
  7465. }
  7466. }
  7467. return output;
  7468. }
  7469. /**
  7470. * Creates a string based on an array of numeric code points.
  7471. * @see `punycode.ucs2.decode`
  7472. * @memberOf punycode.ucs2
  7473. * @name encode
  7474. * @param {Array} codePoints The array of numeric code points.
  7475. * @returns {String} The new Unicode string (UCS-2).
  7476. */ function ucs2encode(array) {
  7477. return map(array, (function(value) {
  7478. var output = "";
  7479. if (value > 65535) {
  7480. value -= 65536;
  7481. output += stringFromCharCode(value >>> 10 & 1023 | 55296);
  7482. value = 56320 | value & 1023;
  7483. }
  7484. output += stringFromCharCode(value);
  7485. return output;
  7486. })).join("");
  7487. }
  7488. /**
  7489. * Converts a basic code point into a digit/integer.
  7490. * @see `digitToBasic()`
  7491. * @private
  7492. * @param {Number} codePoint The basic numeric code point value.
  7493. * @returns {Number} The numeric value of a basic code point (for use in
  7494. * representing integers) in the range `0` to `base - 1`, or `base` if
  7495. * the code point does not represent a value.
  7496. */ function basicToDigit(codePoint) {
  7497. if (codePoint - 48 < 10) {
  7498. return codePoint - 22;
  7499. }
  7500. if (codePoint - 65 < 26) {
  7501. return codePoint - 65;
  7502. }
  7503. if (codePoint - 97 < 26) {
  7504. return codePoint - 97;
  7505. }
  7506. return base;
  7507. }
  7508. /**
  7509. * Converts a digit/integer into a basic code point.
  7510. * @see `basicToDigit()`
  7511. * @private
  7512. * @param {Number} digit The numeric value of a basic code point.
  7513. * @returns {Number} The basic code point whose value (when used for
  7514. * representing integers) is `digit`, which needs to be in the range
  7515. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  7516. * used; else, the lowercase form is used. The behavior is undefined
  7517. * if `flag` is non-zero and `digit` has no uppercase form.
  7518. */ function digitToBasic(digit, flag) {
  7519. // 0..25 map to ASCII a..z or A..Z
  7520. // 26..35 map to ASCII 0..9
  7521. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  7522. }
  7523. /**
  7524. * Bias adaptation function as per section 3.4 of RFC 3492.
  7525. * https://tools.ietf.org/html/rfc3492#section-3.4
  7526. * @private
  7527. */ function adapt(delta, numPoints, firstTime) {
  7528. var k = 0;
  7529. delta = firstTime ? floor(delta / damp) : delta >> 1;
  7530. delta += floor(delta / numPoints);
  7531. for (;delta > baseMinusTMin * tMax >> 1; k += base) {
  7532. delta = floor(delta / baseMinusTMin);
  7533. }
  7534. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  7535. }
  7536. /**
  7537. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  7538. * symbols.
  7539. * @memberOf punycode
  7540. * @param {String} input The Punycode string of ASCII-only symbols.
  7541. * @returns {String} The resulting string of Unicode symbols.
  7542. */ function decode(input) {
  7543. // Don't use UCS-2
  7544. var output = [], inputLength = input.length, out, i = 0, n = initialN, bias = initialBias, basic, j, index, oldi, w, k, digit, t,
  7545. /** Cached calculation results */
  7546. baseMinusT;
  7547. // Handle the basic code points: let `basic` be the number of input code
  7548. // points before the last delimiter, or `0` if there is none, then copy
  7549. // the first basic code points to the output.
  7550. basic = input.lastIndexOf(delimiter);
  7551. if (basic < 0) {
  7552. basic = 0;
  7553. }
  7554. for (j = 0; j < basic; ++j) {
  7555. // if it's not a basic code point
  7556. if (input.charCodeAt(j) >= 128) {
  7557. error("not-basic");
  7558. }
  7559. output.push(input.charCodeAt(j));
  7560. }
  7561. // Main decoding loop: start just after the last delimiter if any basic code
  7562. // points were copied; start at the beginning otherwise.
  7563. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
  7564. // `index` is the index of the next character to be consumed.
  7565. // Decode a generalized variable-length integer into `delta`,
  7566. // which gets added to `i`. The overflow checking is easier
  7567. // if we increase `i` as we go, then subtract off its starting
  7568. // value at the end to obtain `delta`.
  7569. for (oldi = i, w = 1, k = base; ;k += base) {
  7570. if (index >= inputLength) {
  7571. error("invalid-input");
  7572. }
  7573. digit = basicToDigit(input.charCodeAt(index++));
  7574. if (digit >= base || digit > floor((maxInt - i) / w)) {
  7575. error("overflow");
  7576. }
  7577. i += digit * w;
  7578. t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  7579. if (digit < t) {
  7580. break;
  7581. }
  7582. baseMinusT = base - t;
  7583. if (w > floor(maxInt / baseMinusT)) {
  7584. error("overflow");
  7585. }
  7586. w *= baseMinusT;
  7587. }
  7588. out = output.length + 1;
  7589. bias = adapt(i - oldi, out, oldi == 0);
  7590. // `i` was supposed to wrap around from `out` to `0`,
  7591. // incrementing `n` each time, so we'll fix that now:
  7592. if (floor(i / out) > maxInt - n) {
  7593. error("overflow");
  7594. }
  7595. n += floor(i / out);
  7596. i %= out;
  7597. // Insert `n` at position `i` of the output
  7598. output.splice(i++, 0, n);
  7599. }
  7600. return ucs2encode(output);
  7601. }
  7602. /**
  7603. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  7604. * Punycode string of ASCII-only symbols.
  7605. * @memberOf punycode
  7606. * @param {String} input The string of Unicode symbols.
  7607. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  7608. */ function encode(input) {
  7609. var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [],
  7610. /** `inputLength` will hold the number of code points in `input`. */
  7611. inputLength,
  7612. /** Cached calculation results */
  7613. handledCPCountPlusOne, baseMinusT, qMinusT;
  7614. // Convert the input in UCS-2 to Unicode
  7615. input = ucs2decode(input);
  7616. // Cache the length
  7617. inputLength = input.length;
  7618. // Initialize the state
  7619. n = initialN;
  7620. delta = 0;
  7621. bias = initialBias;
  7622. // Handle the basic code points
  7623. for (j = 0; j < inputLength; ++j) {
  7624. currentValue = input[j];
  7625. if (currentValue < 128) {
  7626. output.push(stringFromCharCode(currentValue));
  7627. }
  7628. }
  7629. handledCPCount = basicLength = output.length;
  7630. // `handledCPCount` is the number of code points that have been handled;
  7631. // `basicLength` is the number of basic code points.
  7632. // Finish the basic string - if it is not empty - with a delimiter
  7633. if (basicLength) {
  7634. output.push(delimiter);
  7635. }
  7636. // Main encoding loop:
  7637. while (handledCPCount < inputLength) {
  7638. // All non-basic code points < n have been handled already. Find the next
  7639. // larger one:
  7640. for (m = maxInt, j = 0; j < inputLength; ++j) {
  7641. currentValue = input[j];
  7642. if (currentValue >= n && currentValue < m) {
  7643. m = currentValue;
  7644. }
  7645. }
  7646. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  7647. // but guard against overflow
  7648. handledCPCountPlusOne = handledCPCount + 1;
  7649. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  7650. error("overflow");
  7651. }
  7652. delta += (m - n) * handledCPCountPlusOne;
  7653. n = m;
  7654. for (j = 0; j < inputLength; ++j) {
  7655. currentValue = input[j];
  7656. if (currentValue < n && ++delta > maxInt) {
  7657. error("overflow");
  7658. }
  7659. if (currentValue == n) {
  7660. // Represent delta as a generalized variable-length integer
  7661. for (q = delta, k = base; ;k += base) {
  7662. t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  7663. if (q < t) {
  7664. break;
  7665. }
  7666. qMinusT = q - t;
  7667. baseMinusT = base - t;
  7668. output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
  7669. q = floor(qMinusT / baseMinusT);
  7670. }
  7671. output.push(stringFromCharCode(digitToBasic(q, 0)));
  7672. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  7673. delta = 0;
  7674. ++handledCPCount;
  7675. }
  7676. }
  7677. ++delta;
  7678. ++n;
  7679. }
  7680. return output.join("");
  7681. }
  7682. /**
  7683. * Converts a Punycode string representing a domain name or an email address
  7684. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  7685. * it doesn't matter if you call it on a string that has already been
  7686. * converted to Unicode.
  7687. * @memberOf punycode
  7688. * @param {String} input The Punycoded domain name or email address to
  7689. * convert to Unicode.
  7690. * @returns {String} The Unicode representation of the given Punycode
  7691. * string.
  7692. */ function toUnicode(input) {
  7693. return mapDomain(input, (function(string) {
  7694. return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
  7695. }));
  7696. }
  7697. /**
  7698. * Converts a Unicode string representing a domain name or an email address to
  7699. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  7700. * i.e. it doesn't matter if you call it with a domain that's already in
  7701. * ASCII.
  7702. * @memberOf punycode
  7703. * @param {String} input The domain name or email address to convert, as a
  7704. * Unicode string.
  7705. * @returns {String} The Punycode representation of the given domain name or
  7706. * email address.
  7707. */ function toASCII(input) {
  7708. return mapDomain(input, (function(string) {
  7709. return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
  7710. }));
  7711. }
  7712. var version = "1.4.1";
  7713. /**
  7714. * An object of methods to convert from JavaScript's internal character
  7715. * representation (UCS-2) to Unicode code points, and back.
  7716. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  7717. * @memberOf punycode
  7718. * @type Object
  7719. */ var ucs2 = {
  7720. decode: ucs2decode,
  7721. encode: ucs2encode
  7722. };
  7723. var punycode$1 = {
  7724. version: version,
  7725. ucs2: ucs2,
  7726. toASCII: toASCII,
  7727. toUnicode: toUnicode,
  7728. encode: encode,
  7729. decode: decode
  7730. };
  7731. var punycode$2 = Object.freeze({
  7732. __proto__: null,
  7733. decode: decode,
  7734. encode: encode,
  7735. toUnicode: toUnicode,
  7736. toASCII: toASCII,
  7737. version: version,
  7738. ucs2: ucs2,
  7739. default: punycode$1
  7740. });
  7741. // markdown-it default options
  7742. var _default = {
  7743. options: {
  7744. html: false,
  7745. // Enable HTML tags in source
  7746. xhtmlOut: false,
  7747. // Use '/' to close single tags (<br />)
  7748. breaks: false,
  7749. // Convert '\n' in paragraphs into <br>
  7750. langPrefix: "language-",
  7751. // CSS language prefix for fenced blocks
  7752. linkify: false,
  7753. // autoconvert URL-like texts to links
  7754. // Enable some language-neutral replacements + quotes beautification
  7755. typographer: false,
  7756. // Double + single quotes replacement pairs, when typographer enabled,
  7757. // and smartquotes on. Could be either a String or an Array.
  7758. // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  7759. // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  7760. quotes: "\u201c\u201d\u2018\u2019",
  7761. /* “”‘’ */
  7762. // Highlighter function. Should return escaped HTML,
  7763. // or '' if the source string is not changed and should be escaped externaly.
  7764. // If result starts with <pre... internal wrapper is skipped.
  7765. // function (/*str, lang*/) { return ''; }
  7766. highlight: null,
  7767. maxNesting: 100
  7768. },
  7769. components: {
  7770. core: {},
  7771. block: {},
  7772. inline: {}
  7773. }
  7774. };
  7775. // "Zero" preset, with nothing enabled. Useful for manual configuring of simple
  7776. var zero = {
  7777. options: {
  7778. html: false,
  7779. // Enable HTML tags in source
  7780. xhtmlOut: false,
  7781. // Use '/' to close single tags (<br />)
  7782. breaks: false,
  7783. // Convert '\n' in paragraphs into <br>
  7784. langPrefix: "language-",
  7785. // CSS language prefix for fenced blocks
  7786. linkify: false,
  7787. // autoconvert URL-like texts to links
  7788. // Enable some language-neutral replacements + quotes beautification
  7789. typographer: false,
  7790. // Double + single quotes replacement pairs, when typographer enabled,
  7791. // and smartquotes on. Could be either a String or an Array.
  7792. // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  7793. // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  7794. quotes: "\u201c\u201d\u2018\u2019",
  7795. /* “”‘’ */
  7796. // Highlighter function. Should return escaped HTML,
  7797. // or '' if the source string is not changed and should be escaped externaly.
  7798. // If result starts with <pre... internal wrapper is skipped.
  7799. // function (/*str, lang*/) { return ''; }
  7800. highlight: null,
  7801. maxNesting: 20
  7802. },
  7803. components: {
  7804. core: {
  7805. rules: [ "normalize", "block", "inline", "text_join" ]
  7806. },
  7807. block: {
  7808. rules: [ "paragraph" ]
  7809. },
  7810. inline: {
  7811. rules: [ "text" ],
  7812. rules2: [ "balance_pairs", "fragments_join" ]
  7813. }
  7814. }
  7815. };
  7816. // Commonmark default options
  7817. var commonmark = {
  7818. options: {
  7819. html: true,
  7820. // Enable HTML tags in source
  7821. xhtmlOut: true,
  7822. // Use '/' to close single tags (<br />)
  7823. breaks: false,
  7824. // Convert '\n' in paragraphs into <br>
  7825. langPrefix: "language-",
  7826. // CSS language prefix for fenced blocks
  7827. linkify: false,
  7828. // autoconvert URL-like texts to links
  7829. // Enable some language-neutral replacements + quotes beautification
  7830. typographer: false,
  7831. // Double + single quotes replacement pairs, when typographer enabled,
  7832. // and smartquotes on. Could be either a String or an Array.
  7833. // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  7834. // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  7835. quotes: "\u201c\u201d\u2018\u2019",
  7836. /* “”‘’ */
  7837. // Highlighter function. Should return escaped HTML,
  7838. // or '' if the source string is not changed and should be escaped externaly.
  7839. // If result starts with <pre... internal wrapper is skipped.
  7840. // function (/*str, lang*/) { return ''; }
  7841. highlight: null,
  7842. maxNesting: 20
  7843. },
  7844. components: {
  7845. core: {
  7846. rules: [ "normalize", "block", "inline", "text_join" ]
  7847. },
  7848. block: {
  7849. rules: [ "blockquote", "code", "fence", "heading", "hr", "html_block", "lheading", "list", "reference", "paragraph" ]
  7850. },
  7851. inline: {
  7852. rules: [ "autolink", "backticks", "emphasis", "entity", "escape", "html_inline", "image", "link", "newline", "text" ],
  7853. rules2: [ "balance_pairs", "emphasis", "fragments_join" ]
  7854. }
  7855. }
  7856. };
  7857. var punycode = getAugmentedNamespace(punycode$2);
  7858. var config = {
  7859. default: _default,
  7860. zero: zero,
  7861. commonmark: commonmark
  7862. };
  7863. ////////////////////////////////////////////////////////////////////////////////
  7864. // This validator can prohibit more than really needed to prevent XSS. It's a
  7865. // tradeoff to keep code simple and to be secure by default.
  7866. // If you need different setup - override validator method as you wish. Or
  7867. // replace it with dummy function and use external sanitizer.
  7868. var BAD_PROTO_RE = /^(vbscript|javascript|file|data):/;
  7869. var GOOD_DATA_RE = /^data:image\/(gif|png|jpeg|webp);/;
  7870. function validateLink(url) {
  7871. // url should be normalized at this point, and existing entities are decoded
  7872. var str = url.trim().toLowerCase();
  7873. return BAD_PROTO_RE.test(str) ? GOOD_DATA_RE.test(str) ? true : false : true;
  7874. }
  7875. ////////////////////////////////////////////////////////////////////////////////
  7876. var RECODE_HOSTNAME_FOR = [ "http:", "https:", "mailto:" ];
  7877. function normalizeLink(url) {
  7878. var parsed = mdurl.parse(url, true);
  7879. if (parsed.hostname) {
  7880. // Encode hostnames in urls like:
  7881. // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
  7882. // We don't encode unknown schemas, because it's likely that we encode
  7883. // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
  7884. if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
  7885. try {
  7886. parsed.hostname = punycode.toASCII(parsed.hostname);
  7887. } catch (er) {}
  7888. }
  7889. }
  7890. return mdurl.encode(mdurl.format(parsed));
  7891. }
  7892. function normalizeLinkText(url) {
  7893. var parsed = mdurl.parse(url, true);
  7894. if (parsed.hostname) {
  7895. // Encode hostnames in urls like:
  7896. // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
  7897. // We don't encode unknown schemas, because it's likely that we encode
  7898. // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
  7899. if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
  7900. try {
  7901. parsed.hostname = punycode.toUnicode(parsed.hostname);
  7902. } catch (er) {}
  7903. }
  7904. }
  7905. // add '%' to exclude list because of https://github.com/markdown-it/markdown-it/issues/720
  7906. return mdurl.decode(mdurl.format(parsed), mdurl.decode.defaultChars + "%");
  7907. }
  7908. /**
  7909. * class MarkdownIt
  7910. *
  7911. * Main parser/renderer class.
  7912. *
  7913. * ##### Usage
  7914. *
  7915. * ```javascript
  7916. * // node.js, "classic" way:
  7917. * var MarkdownIt = require('markdown-it'),
  7918. * md = new MarkdownIt();
  7919. * var result = md.render('# markdown-it rulezz!');
  7920. *
  7921. * // node.js, the same, but with sugar:
  7922. * var md = require('markdown-it')();
  7923. * var result = md.render('# markdown-it rulezz!');
  7924. *
  7925. * // browser without AMD, added to "window" on script load
  7926. * // Note, there are no dash.
  7927. * var md = window.markdownit();
  7928. * var result = md.render('# markdown-it rulezz!');
  7929. * ```
  7930. *
  7931. * Single line rendering, without paragraph wrap:
  7932. *
  7933. * ```javascript
  7934. * var md = require('markdown-it')();
  7935. * var result = md.renderInline('__markdown-it__ rulezz!');
  7936. * ```
  7937. **/
  7938. /**
  7939. * new MarkdownIt([presetName, options])
  7940. * - presetName (String): optional, `commonmark` / `zero`
  7941. * - options (Object)
  7942. *
  7943. * Creates parser instanse with given config. Can be called without `new`.
  7944. *
  7945. * ##### presetName
  7946. *
  7947. * MarkdownIt provides named presets as a convenience to quickly
  7948. * enable/disable active syntax rules and options for common use cases.
  7949. *
  7950. * - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js) -
  7951. * configures parser to strict [CommonMark](http://commonmark.org/) mode.
  7952. * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) -
  7953. * similar to GFM, used when no preset name given. Enables all available rules,
  7954. * but still without html, typographer & autolinker.
  7955. * - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) -
  7956. * all rules disabled. Useful to quickly setup your config via `.enable()`.
  7957. * For example, when you need only `bold` and `italic` markup and nothing else.
  7958. *
  7959. * ##### options:
  7960. *
  7961. * - __html__ - `false`. Set `true` to enable HTML tags in source. Be careful!
  7962. * That's not safe! You may need external sanitizer to protect output from XSS.
  7963. * It's better to extend features via plugins, instead of enabling HTML.
  7964. * - __xhtmlOut__ - `false`. Set `true` to add '/' when closing single tags
  7965. * (`<br />`). This is needed only for full CommonMark compatibility. In real
  7966. * world you will need HTML output.
  7967. * - __breaks__ - `false`. Set `true` to convert `\n` in paragraphs into `<br>`.
  7968. * - __langPrefix__ - `language-`. CSS language class prefix for fenced blocks.
  7969. * Can be useful for external highlighters.
  7970. * - __linkify__ - `false`. Set `true` to autoconvert URL-like text to links.
  7971. * - __typographer__ - `false`. Set `true` to enable [some language-neutral
  7972. * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +
  7973. * quotes beautification (smartquotes).
  7974. * - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement
  7975. * pairs, when typographer enabled and smartquotes on. For example, you can
  7976. * use `'«»„“'` for Russian, `'„“‚‘'` for German, and
  7977. * `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).
  7978. * - __highlight__ - `null`. Highlighter function for fenced code blocks.
  7979. * Highlighter `function (str, lang)` should return escaped HTML. It can also
  7980. * return empty string if the source was not changed and should be escaped
  7981. * externaly. If result starts with <pre... internal wrapper is skipped.
  7982. *
  7983. * ##### Example
  7984. *
  7985. * ```javascript
  7986. * // commonmark mode
  7987. * var md = require('markdown-it')('commonmark');
  7988. *
  7989. * // default mode
  7990. * var md = require('markdown-it')();
  7991. *
  7992. * // enable everything
  7993. * var md = require('markdown-it')({
  7994. * html: true,
  7995. * linkify: true,
  7996. * typographer: true
  7997. * });
  7998. * ```
  7999. *
  8000. * ##### Syntax highlighting
  8001. *
  8002. * ```js
  8003. * var hljs = require('highlight.js') // https://highlightjs.org/
  8004. *
  8005. * var md = require('markdown-it')({
  8006. * highlight: function (str, lang) {
  8007. * if (lang && hljs.getLanguage(lang)) {
  8008. * try {
  8009. * return hljs.highlight(str, { language: lang, ignoreIllegals: true }).value;
  8010. * } catch (__) {}
  8011. * }
  8012. *
  8013. * return ''; // use external default escaping
  8014. * }
  8015. * });
  8016. * ```
  8017. *
  8018. * Or with full wrapper override (if you need assign class to `<pre>`):
  8019. *
  8020. * ```javascript
  8021. * var hljs = require('highlight.js') // https://highlightjs.org/
  8022. *
  8023. * // Actual default values
  8024. * var md = require('markdown-it')({
  8025. * highlight: function (str, lang) {
  8026. * if (lang && hljs.getLanguage(lang)) {
  8027. * try {
  8028. * return '<pre class="hljs"><code>' +
  8029. * hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
  8030. * '</code></pre>';
  8031. * } catch (__) {}
  8032. * }
  8033. *
  8034. * return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
  8035. * }
  8036. * });
  8037. * ```
  8038. *
  8039. **/ function MarkdownIt(presetName, options) {
  8040. if (!(this instanceof MarkdownIt)) {
  8041. return new MarkdownIt(presetName, options);
  8042. }
  8043. if (!options) {
  8044. if (!utils.isString(presetName)) {
  8045. options = presetName || {};
  8046. presetName = "default";
  8047. }
  8048. }
  8049. /**
  8050. * MarkdownIt#inline -> ParserInline
  8051. *
  8052. * Instance of [[ParserInline]]. You may need it to add new rules when
  8053. * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
  8054. * [[MarkdownIt.enable]].
  8055. **/ this.inline = new parser_inline;
  8056. /**
  8057. * MarkdownIt#block -> ParserBlock
  8058. *
  8059. * Instance of [[ParserBlock]]. You may need it to add new rules when
  8060. * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
  8061. * [[MarkdownIt.enable]].
  8062. **/ this.block = new parser_block;
  8063. /**
  8064. * MarkdownIt#core -> Core
  8065. *
  8066. * Instance of [[Core]] chain executor. You may need it to add new rules when
  8067. * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
  8068. * [[MarkdownIt.enable]].
  8069. **/ this.core = new parser_core;
  8070. /**
  8071. * MarkdownIt#renderer -> Renderer
  8072. *
  8073. * Instance of [[Renderer]]. Use it to modify output look. Or to add rendering
  8074. * rules for new token types, generated by plugins.
  8075. *
  8076. * ##### Example
  8077. *
  8078. * ```javascript
  8079. * var md = require('markdown-it')();
  8080. *
  8081. * function myToken(tokens, idx, options, env, self) {
  8082. * //...
  8083. * return result;
  8084. * };
  8085. *
  8086. * md.renderer.rules['my_token'] = myToken
  8087. * ```
  8088. *
  8089. * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js).
  8090. **/ this.renderer = new renderer;
  8091. /**
  8092. * MarkdownIt#linkify -> LinkifyIt
  8093. *
  8094. * [linkify-it](https://github.com/markdown-it/linkify-it) instance.
  8095. * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js)
  8096. * rule.
  8097. **/ this.linkify = new linkifyIt;
  8098. /**
  8099. * MarkdownIt#validateLink(url) -> Boolean
  8100. *
  8101. * Link validation function. CommonMark allows too much in links. By default
  8102. * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas
  8103. * except some embedded image types.
  8104. *
  8105. * You can change this behaviour:
  8106. *
  8107. * ```javascript
  8108. * var md = require('markdown-it')();
  8109. * // enable everything
  8110. * md.validateLink = function () { return true; }
  8111. * ```
  8112. **/ this.validateLink = validateLink;
  8113. /**
  8114. * MarkdownIt#normalizeLink(url) -> String
  8115. *
  8116. * Function used to encode link url to a machine-readable format,
  8117. * which includes url-encoding, punycode, etc.
  8118. **/ this.normalizeLink = normalizeLink;
  8119. /**
  8120. * MarkdownIt#normalizeLinkText(url) -> String
  8121. *
  8122. * Function used to decode link url to a human-readable format`
  8123. **/ this.normalizeLinkText = normalizeLinkText;
  8124. // Expose utils & helpers for easy acces from plugins
  8125. /**
  8126. * MarkdownIt#utils -> utils
  8127. *
  8128. * Assorted utility functions, useful to write plugins. See details
  8129. * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.js).
  8130. **/ this.utils = utils;
  8131. /**
  8132. * MarkdownIt#helpers -> helpers
  8133. *
  8134. * Link components parser functions, useful to write plugins. See details
  8135. * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/helpers).
  8136. **/ this.helpers = utils.assign({}, helpers);
  8137. this.options = {};
  8138. this.configure(presetName);
  8139. if (options) {
  8140. this.set(options);
  8141. }
  8142. }
  8143. /** chainable
  8144. * MarkdownIt.set(options)
  8145. *
  8146. * Set parser options (in the same format as in constructor). Probably, you
  8147. * will never need it, but you can change options after constructor call.
  8148. *
  8149. * ##### Example
  8150. *
  8151. * ```javascript
  8152. * var md = require('markdown-it')()
  8153. * .set({ html: true, breaks: true })
  8154. * .set({ typographer, true });
  8155. * ```
  8156. *
  8157. * __Note:__ To achieve the best possible performance, don't modify a
  8158. * `markdown-it` instance options on the fly. If you need multiple configurations
  8159. * it's best to create multiple instances and initialize each with separate
  8160. * config.
  8161. **/ MarkdownIt.prototype.set = function(options) {
  8162. utils.assign(this.options, options);
  8163. return this;
  8164. };
  8165. /** chainable, internal
  8166. * MarkdownIt.configure(presets)
  8167. *
  8168. * Batch load of all options and compenent settings. This is internal method,
  8169. * and you probably will not need it. But if you will - see available presets
  8170. * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets)
  8171. *
  8172. * We strongly recommend to use presets instead of direct config loads. That
  8173. * will give better compatibility with next versions.
  8174. **/ MarkdownIt.prototype.configure = function(presets) {
  8175. var self = this, presetName;
  8176. if (utils.isString(presets)) {
  8177. presetName = presets;
  8178. presets = config[presetName];
  8179. if (!presets) {
  8180. throw new Error('Wrong `markdown-it` preset "' + presetName + '", check name');
  8181. }
  8182. }
  8183. if (!presets) {
  8184. throw new Error("Wrong `markdown-it` preset, can't be empty");
  8185. }
  8186. if (presets.options) {
  8187. self.set(presets.options);
  8188. }
  8189. if (presets.components) {
  8190. Object.keys(presets.components).forEach((function(name) {
  8191. if (presets.components[name].rules) {
  8192. self[name].ruler.enableOnly(presets.components[name].rules);
  8193. }
  8194. if (presets.components[name].rules2) {
  8195. self[name].ruler2.enableOnly(presets.components[name].rules2);
  8196. }
  8197. }));
  8198. }
  8199. return this;
  8200. };
  8201. /** chainable
  8202. * MarkdownIt.enable(list, ignoreInvalid)
  8203. * - list (String|Array): rule name or list of rule names to enable
  8204. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  8205. *
  8206. * Enable list or rules. It will automatically find appropriate components,
  8207. * containing rules with given names. If rule not found, and `ignoreInvalid`
  8208. * not set - throws exception.
  8209. *
  8210. * ##### Example
  8211. *
  8212. * ```javascript
  8213. * var md = require('markdown-it')()
  8214. * .enable(['sub', 'sup'])
  8215. * .disable('smartquotes');
  8216. * ```
  8217. **/ MarkdownIt.prototype.enable = function(list, ignoreInvalid) {
  8218. var result = [];
  8219. if (!Array.isArray(list)) {
  8220. list = [ list ];
  8221. }
  8222. [ "core", "block", "inline" ].forEach((function(chain) {
  8223. result = result.concat(this[chain].ruler.enable(list, true));
  8224. }), this);
  8225. result = result.concat(this.inline.ruler2.enable(list, true));
  8226. var missed = list.filter((function(name) {
  8227. return result.indexOf(name) < 0;
  8228. }));
  8229. if (missed.length && !ignoreInvalid) {
  8230. throw new Error("MarkdownIt. Failed to enable unknown rule(s): " + missed);
  8231. }
  8232. return this;
  8233. };
  8234. /** chainable
  8235. * MarkdownIt.disable(list, ignoreInvalid)
  8236. * - list (String|Array): rule name or list of rule names to disable.
  8237. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  8238. *
  8239. * The same as [[MarkdownIt.enable]], but turn specified rules off.
  8240. **/ MarkdownIt.prototype.disable = function(list, ignoreInvalid) {
  8241. var result = [];
  8242. if (!Array.isArray(list)) {
  8243. list = [ list ];
  8244. }
  8245. [ "core", "block", "inline" ].forEach((function(chain) {
  8246. result = result.concat(this[chain].ruler.disable(list, true));
  8247. }), this);
  8248. result = result.concat(this.inline.ruler2.disable(list, true));
  8249. var missed = list.filter((function(name) {
  8250. return result.indexOf(name) < 0;
  8251. }));
  8252. if (missed.length && !ignoreInvalid) {
  8253. throw new Error("MarkdownIt. Failed to disable unknown rule(s): " + missed);
  8254. }
  8255. return this;
  8256. };
  8257. /** chainable
  8258. * MarkdownIt.use(plugin, params)
  8259. *
  8260. * Load specified plugin with given params into current parser instance.
  8261. * It's just a sugar to call `plugin(md, params)` with curring.
  8262. *
  8263. * ##### Example
  8264. *
  8265. * ```javascript
  8266. * var iterator = require('markdown-it-for-inline');
  8267. * var md = require('markdown-it')()
  8268. * .use(iterator, 'foo_replace', 'text', function (tokens, idx) {
  8269. * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');
  8270. * });
  8271. * ```
  8272. **/ MarkdownIt.prototype.use = function(plugin /*, params, ... */) {
  8273. var args = [ this ].concat(Array.prototype.slice.call(arguments, 1));
  8274. plugin.apply(plugin, args);
  8275. return this;
  8276. };
  8277. /** internal
  8278. * MarkdownIt.parse(src, env) -> Array
  8279. * - src (String): source string
  8280. * - env (Object): environment sandbox
  8281. *
  8282. * Parse input string and return list of block tokens (special token type
  8283. * "inline" will contain list of inline tokens). You should not call this
  8284. * method directly, until you write custom renderer (for example, to produce
  8285. * AST).
  8286. *
  8287. * `env` is used to pass data between "distributed" rules and return additional
  8288. * metadata like reference info, needed for the renderer. It also can be used to
  8289. * inject data in specific cases. Usually, you will be ok to pass `{}`,
  8290. * and then pass updated object to renderer.
  8291. **/ MarkdownIt.prototype.parse = function(src, env) {
  8292. if (typeof src !== "string") {
  8293. throw new Error("Input data should be a String");
  8294. }
  8295. var state = new this.core.State(src, this, env);
  8296. this.core.process(state);
  8297. return state.tokens;
  8298. };
  8299. /**
  8300. * MarkdownIt.render(src [, env]) -> String
  8301. * - src (String): source string
  8302. * - env (Object): environment sandbox
  8303. *
  8304. * Render markdown string into html. It does all magic for you :).
  8305. *
  8306. * `env` can be used to inject additional metadata (`{}` by default).
  8307. * But you will not need it with high probability. See also comment
  8308. * in [[MarkdownIt.parse]].
  8309. **/ MarkdownIt.prototype.render = function(src, env) {
  8310. env = env || {};
  8311. return this.renderer.render(this.parse(src, env), this.options, env);
  8312. };
  8313. /** internal
  8314. * MarkdownIt.parseInline(src, env) -> Array
  8315. * - src (String): source string
  8316. * - env (Object): environment sandbox
  8317. *
  8318. * The same as [[MarkdownIt.parse]] but skip all block rules. It returns the
  8319. * block tokens list with the single `inline` element, containing parsed inline
  8320. * tokens in `children` property. Also updates `env` object.
  8321. **/ MarkdownIt.prototype.parseInline = function(src, env) {
  8322. var state = new this.core.State(src, this, env);
  8323. state.inlineMode = true;
  8324. this.core.process(state);
  8325. return state.tokens;
  8326. };
  8327. /**
  8328. * MarkdownIt.renderInline(src [, env]) -> String
  8329. * - src (String): source string
  8330. * - env (Object): environment sandbox
  8331. *
  8332. * Similar to [[MarkdownIt.render]] but for single paragraph content. Result
  8333. * will NOT be wrapped into `<p>` tags.
  8334. **/ MarkdownIt.prototype.renderInline = function(src, env) {
  8335. env = env || {};
  8336. return this.renderer.render(this.parseInline(src, env), this.options, env);
  8337. };
  8338. var lib = MarkdownIt;
  8339. var markdownIt = lib;
  8340. return markdownIt;
  8341. }));