markdown-it.js 252 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965
  1. /*! markdown-it 8.4.2 https://github.com//markdown-it/markdown-it @license MIT */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownit = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
  2. // HTML5 entities map: { name -> utf16string }
  3. //
  4. 'use strict';
  5. /*eslint quotes:0*/
  6. module.exports = require('entities/maps/entities.json');
  7. },{"entities/maps/entities.json":52}],2:[function(require,module,exports){
  8. // List of valid html blocks names, accorting to commonmark spec
  9. // http://jgm.github.io/CommonMark/spec.html#html-blocks
  10. 'use strict';
  11. module.exports = [
  12. 'address',
  13. 'article',
  14. 'aside',
  15. 'base',
  16. 'basefont',
  17. 'blockquote',
  18. 'body',
  19. 'caption',
  20. 'center',
  21. 'col',
  22. 'colgroup',
  23. 'dd',
  24. 'details',
  25. 'dialog',
  26. 'dir',
  27. 'div',
  28. 'dl',
  29. 'dt',
  30. 'fieldset',
  31. 'figcaption',
  32. 'figure',
  33. 'footer',
  34. 'form',
  35. 'frame',
  36. 'frameset',
  37. 'h1',
  38. 'h2',
  39. 'h3',
  40. 'h4',
  41. 'h5',
  42. 'h6',
  43. 'head',
  44. 'header',
  45. 'hr',
  46. 'html',
  47. 'iframe',
  48. 'legend',
  49. 'li',
  50. 'link',
  51. 'main',
  52. 'menu',
  53. 'menuitem',
  54. 'meta',
  55. 'nav',
  56. 'noframes',
  57. 'ol',
  58. 'optgroup',
  59. 'option',
  60. 'p',
  61. 'param',
  62. 'section',
  63. 'source',
  64. 'summary',
  65. 'table',
  66. 'tbody',
  67. 'td',
  68. 'tfoot',
  69. 'th',
  70. 'thead',
  71. 'title',
  72. 'tr',
  73. 'track',
  74. 'ul'
  75. ];
  76. },{}],3:[function(require,module,exports){
  77. // Regexps to match html elements
  78. 'use strict';
  79. var attr_name = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
  80. var unquoted = '[^"\'=<>`\\x00-\\x20]+';
  81. var single_quoted = "'[^']*'";
  82. var double_quoted = '"[^"]*"';
  83. var attr_value = '(?:' + unquoted + '|' + single_quoted + '|' + double_quoted + ')';
  84. var attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)';
  85. var open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>';
  86. var close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>';
  87. var comment = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->';
  88. var processing = '<[?].*?[?]>';
  89. var declaration = '<![A-Z]+\\s+[^>]*>';
  90. var cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>';
  91. var HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment +
  92. '|' + processing + '|' + declaration + '|' + cdata + ')');
  93. var HTML_OPEN_CLOSE_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + ')');
  94. module.exports.HTML_TAG_RE = HTML_TAG_RE;
  95. module.exports.HTML_OPEN_CLOSE_TAG_RE = HTML_OPEN_CLOSE_TAG_RE;
  96. },{}],4:[function(require,module,exports){
  97. // Utilities
  98. //
  99. 'use strict';
  100. function _class(obj) { return Object.prototype.toString.call(obj); }
  101. function isString(obj) { return _class(obj) === '[object String]'; }
  102. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  103. function has(object, key) {
  104. return _hasOwnProperty.call(object, key);
  105. }
  106. // Merge objects
  107. //
  108. function assign(obj /*from1, from2, from3, ...*/) {
  109. var sources = Array.prototype.slice.call(arguments, 1);
  110. sources.forEach(function (source) {
  111. if (!source) { return; }
  112. if (typeof source !== 'object') {
  113. throw new TypeError(source + 'must be object');
  114. }
  115. Object.keys(source).forEach(function (key) {
  116. obj[key] = source[key];
  117. });
  118. });
  119. return obj;
  120. }
  121. // Remove element from array and put another array at those position.
  122. // Useful for some operations with tokens
  123. function arrayReplaceAt(src, pos, newElements) {
  124. return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1));
  125. }
  126. ////////////////////////////////////////////////////////////////////////////////
  127. function isValidEntityCode(c) {
  128. /*eslint no-bitwise:0*/
  129. // broken sequence
  130. if (c >= 0xD800 && c <= 0xDFFF) { return false; }
  131. // never used
  132. if (c >= 0xFDD0 && c <= 0xFDEF) { return false; }
  133. if ((c & 0xFFFF) === 0xFFFF || (c & 0xFFFF) === 0xFFFE) { return false; }
  134. // control codes
  135. if (c >= 0x00 && c <= 0x08) { return false; }
  136. if (c === 0x0B) { return false; }
  137. if (c >= 0x0E && c <= 0x1F) { return false; }
  138. if (c >= 0x7F && c <= 0x9F) { return false; }
  139. // out of range
  140. if (c > 0x10FFFF) { return false; }
  141. return true;
  142. }
  143. function fromCodePoint(c) {
  144. /*eslint no-bitwise:0*/
  145. if (c > 0xffff) {
  146. c -= 0x10000;
  147. var surrogate1 = 0xd800 + (c >> 10),
  148. surrogate2 = 0xdc00 + (c & 0x3ff);
  149. return String.fromCharCode(surrogate1, surrogate2);
  150. }
  151. return String.fromCharCode(c);
  152. }
  153. var UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g;
  154. var ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi;
  155. var UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + '|' + ENTITY_RE.source, 'gi');
  156. var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;
  157. var entities = require('./entities');
  158. function replaceEntityPattern(match, name) {
  159. var code = 0;
  160. if (has(entities, name)) {
  161. return entities[name];
  162. }
  163. if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {
  164. code = name[1].toLowerCase() === 'x' ?
  165. parseInt(name.slice(2), 16)
  166. :
  167. parseInt(name.slice(1), 10);
  168. if (isValidEntityCode(code)) {
  169. return fromCodePoint(code);
  170. }
  171. }
  172. return match;
  173. }
  174. /*function replaceEntities(str) {
  175. if (str.indexOf('&') < 0) { return str; }
  176. return str.replace(ENTITY_RE, replaceEntityPattern);
  177. }*/
  178. function unescapeMd(str) {
  179. if (str.indexOf('\\') < 0) { return str; }
  180. return str.replace(UNESCAPE_MD_RE, '$1');
  181. }
  182. function unescapeAll(str) {
  183. if (str.indexOf('\\') < 0 && str.indexOf('&') < 0) { return str; }
  184. return str.replace(UNESCAPE_ALL_RE, function (match, escaped, entity) {
  185. if (escaped) { return escaped; }
  186. return replaceEntityPattern(match, entity);
  187. });
  188. }
  189. ////////////////////////////////////////////////////////////////////////////////
  190. var HTML_ESCAPE_TEST_RE = /[&<>"]/;
  191. var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;
  192. var HTML_REPLACEMENTS = {
  193. '&': '&amp;',
  194. '<': '&lt;',
  195. '>': '&gt;',
  196. '"': '&quot;'
  197. };
  198. function replaceUnsafeChar(ch) {
  199. return HTML_REPLACEMENTS[ch];
  200. }
  201. function escapeHtml(str) {
  202. if (HTML_ESCAPE_TEST_RE.test(str)) {
  203. return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
  204. }
  205. return str;
  206. }
  207. ////////////////////////////////////////////////////////////////////////////////
  208. var REGEXP_ESCAPE_RE = /[.?*+^$[\]\\(){}|-]/g;
  209. function escapeRE(str) {
  210. return str.replace(REGEXP_ESCAPE_RE, '\\$&');
  211. }
  212. ////////////////////////////////////////////////////////////////////////////////
  213. function isSpace(code) {
  214. switch (code) {
  215. case 0x09:
  216. case 0x20:
  217. return true;
  218. }
  219. return false;
  220. }
  221. // Zs (unicode class) || [\t\f\v\r\n]
  222. function isWhiteSpace(code) {
  223. if (code >= 0x2000 && code <= 0x200A) { return true; }
  224. switch (code) {
  225. case 0x09: // \t
  226. case 0x0A: // \n
  227. case 0x0B: // \v
  228. case 0x0C: // \f
  229. case 0x0D: // \r
  230. case 0x20:
  231. case 0xA0:
  232. case 0x1680:
  233. case 0x202F:
  234. case 0x205F:
  235. case 0x3000:
  236. return true;
  237. }
  238. return false;
  239. }
  240. ////////////////////////////////////////////////////////////////////////////////
  241. /*eslint-disable max-len*/
  242. var UNICODE_PUNCT_RE = require('uc.micro/categories/P/regex');
  243. // Currently without astral characters support.
  244. function isPunctChar(ch) {
  245. return UNICODE_PUNCT_RE.test(ch);
  246. }
  247. // Markdown ASCII punctuation characters.
  248. //
  249. // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
  250. // http://spec.commonmark.org/0.15/#ascii-punctuation-character
  251. //
  252. // Don't confuse with unicode punctuation !!! It lacks some chars in ascii range.
  253. //
  254. function isMdAsciiPunct(ch) {
  255. switch (ch) {
  256. case 0x21/* ! */:
  257. case 0x22/* " */:
  258. case 0x23/* # */:
  259. case 0x24/* $ */:
  260. case 0x25/* % */:
  261. case 0x26/* & */:
  262. case 0x27/* ' */:
  263. case 0x28/* ( */:
  264. case 0x29/* ) */:
  265. case 0x2A/* * */:
  266. case 0x2B/* + */:
  267. case 0x2C/* , */:
  268. case 0x2D/* - */:
  269. case 0x2E/* . */:
  270. case 0x2F/* / */:
  271. case 0x3A/* : */:
  272. case 0x3B/* ; */:
  273. case 0x3C/* < */:
  274. case 0x3D/* = */:
  275. case 0x3E/* > */:
  276. case 0x3F/* ? */:
  277. case 0x40/* @ */:
  278. case 0x5B/* [ */:
  279. case 0x5C/* \ */:
  280. case 0x5D/* ] */:
  281. case 0x5E/* ^ */:
  282. case 0x5F/* _ */:
  283. case 0x60/* ` */:
  284. case 0x7B/* { */:
  285. case 0x7C/* | */:
  286. case 0x7D/* } */:
  287. case 0x7E/* ~ */:
  288. return true;
  289. default:
  290. return false;
  291. }
  292. }
  293. // Hepler to unify [reference labels].
  294. //
  295. function normalizeReference(str) {
  296. // use .toUpperCase() instead of .toLowerCase()
  297. // here to avoid a conflict with Object.prototype
  298. // members (most notably, `__proto__`)
  299. return str.trim().replace(/\s+/g, ' ').toUpperCase();
  300. }
  301. ////////////////////////////////////////////////////////////////////////////////
  302. // Re-export libraries commonly used in both markdown-it and its plugins,
  303. // so plugins won't have to depend on them explicitly, which reduces their
  304. // bundled size (e.g. a browser build).
  305. //
  306. exports.lib = {};
  307. exports.lib.mdurl = require('mdurl');
  308. exports.lib.ucmicro = require('uc.micro');
  309. exports.assign = assign;
  310. exports.isString = isString;
  311. exports.has = has;
  312. exports.unescapeMd = unescapeMd;
  313. exports.unescapeAll = unescapeAll;
  314. exports.isValidEntityCode = isValidEntityCode;
  315. exports.fromCodePoint = fromCodePoint;
  316. // exports.replaceEntities = replaceEntities;
  317. exports.escapeHtml = escapeHtml;
  318. exports.arrayReplaceAt = arrayReplaceAt;
  319. exports.isSpace = isSpace;
  320. exports.isWhiteSpace = isWhiteSpace;
  321. exports.isMdAsciiPunct = isMdAsciiPunct;
  322. exports.isPunctChar = isPunctChar;
  323. exports.escapeRE = escapeRE;
  324. exports.normalizeReference = normalizeReference;
  325. },{"./entities":1,"mdurl":58,"uc.micro":65,"uc.micro/categories/P/regex":63}],5:[function(require,module,exports){
  326. // Just a shortcut for bulk export
  327. 'use strict';
  328. exports.parseLinkLabel = require('./parse_link_label');
  329. exports.parseLinkDestination = require('./parse_link_destination');
  330. exports.parseLinkTitle = require('./parse_link_title');
  331. },{"./parse_link_destination":6,"./parse_link_label":7,"./parse_link_title":8}],6:[function(require,module,exports){
  332. // Parse link destination
  333. //
  334. 'use strict';
  335. var isSpace = require('../common/utils').isSpace;
  336. var unescapeAll = require('../common/utils').unescapeAll;
  337. module.exports = function parseLinkDestination(str, pos, max) {
  338. var code, level,
  339. lines = 0,
  340. start = pos,
  341. result = {
  342. ok: false,
  343. pos: 0,
  344. lines: 0,
  345. str: ''
  346. };
  347. if (str.charCodeAt(pos) === 0x3C /* < */) {
  348. pos++;
  349. while (pos < max) {
  350. code = str.charCodeAt(pos);
  351. if (code === 0x0A /* \n */ || isSpace(code)) { return result; }
  352. if (code === 0x3E /* > */) {
  353. result.pos = pos + 1;
  354. result.str = unescapeAll(str.slice(start + 1, pos));
  355. result.ok = true;
  356. return result;
  357. }
  358. if (code === 0x5C /* \ */ && pos + 1 < max) {
  359. pos += 2;
  360. continue;
  361. }
  362. pos++;
  363. }
  364. // no closing '>'
  365. return result;
  366. }
  367. // this should be ... } else { ... branch
  368. level = 0;
  369. while (pos < max) {
  370. code = str.charCodeAt(pos);
  371. if (code === 0x20) { break; }
  372. // ascii control characters
  373. if (code < 0x20 || code === 0x7F) { break; }
  374. if (code === 0x5C /* \ */ && pos + 1 < max) {
  375. pos += 2;
  376. continue;
  377. }
  378. if (code === 0x28 /* ( */) {
  379. level++;
  380. }
  381. if (code === 0x29 /* ) */) {
  382. if (level === 0) { break; }
  383. level--;
  384. }
  385. pos++;
  386. }
  387. if (start === pos) { return result; }
  388. if (level !== 0) { return result; }
  389. result.str = unescapeAll(str.slice(start, pos));
  390. result.lines = lines;
  391. result.pos = pos;
  392. result.ok = true;
  393. return result;
  394. };
  395. },{"../common/utils":4}],7:[function(require,module,exports){
  396. // Parse link label
  397. //
  398. // this function assumes that first character ("[") already matches;
  399. // returns the end of the label
  400. //
  401. 'use strict';
  402. module.exports = function parseLinkLabel(state, start, disableNested) {
  403. var level, found, marker, prevPos,
  404. labelEnd = -1,
  405. max = state.posMax,
  406. oldPos = state.pos;
  407. state.pos = start + 1;
  408. level = 1;
  409. while (state.pos < max) {
  410. marker = state.src.charCodeAt(state.pos);
  411. if (marker === 0x5D /* ] */) {
  412. level--;
  413. if (level === 0) {
  414. found = true;
  415. break;
  416. }
  417. }
  418. prevPos = state.pos;
  419. state.md.inline.skipToken(state);
  420. if (marker === 0x5B /* [ */) {
  421. if (prevPos === state.pos - 1) {
  422. // increase level if we find text `[`, which is not a part of any token
  423. level++;
  424. } else if (disableNested) {
  425. state.pos = oldPos;
  426. return -1;
  427. }
  428. }
  429. }
  430. if (found) {
  431. labelEnd = state.pos;
  432. }
  433. // restore old state
  434. state.pos = oldPos;
  435. return labelEnd;
  436. };
  437. },{}],8:[function(require,module,exports){
  438. // Parse link title
  439. //
  440. 'use strict';
  441. var unescapeAll = require('../common/utils').unescapeAll;
  442. module.exports = function parseLinkTitle(str, pos, max) {
  443. var code,
  444. marker,
  445. lines = 0,
  446. start = pos,
  447. result = {
  448. ok: false,
  449. pos: 0,
  450. lines: 0,
  451. str: ''
  452. };
  453. if (pos >= max) { return result; }
  454. marker = str.charCodeAt(pos);
  455. if (marker !== 0x22 /* " */ && marker !== 0x27 /* ' */ && marker !== 0x28 /* ( */) { return result; }
  456. pos++;
  457. // if opening marker is "(", switch it to closing marker ")"
  458. if (marker === 0x28) { marker = 0x29; }
  459. while (pos < max) {
  460. code = str.charCodeAt(pos);
  461. if (code === marker) {
  462. result.pos = pos + 1;
  463. result.lines = lines;
  464. result.str = unescapeAll(str.slice(start + 1, pos));
  465. result.ok = true;
  466. return result;
  467. } else if (code === 0x0A) {
  468. lines++;
  469. } else if (code === 0x5C /* \ */ && pos + 1 < max) {
  470. pos++;
  471. if (str.charCodeAt(pos) === 0x0A) {
  472. lines++;
  473. }
  474. }
  475. pos++;
  476. }
  477. return result;
  478. };
  479. },{"../common/utils":4}],9:[function(require,module,exports){
  480. // Main parser class
  481. 'use strict';
  482. var utils = require('./common/utils');
  483. var helpers = require('./helpers');
  484. var Renderer = require('./renderer');
  485. var ParserCore = require('./parser_core');
  486. var ParserBlock = require('./parser_block');
  487. var ParserInline = require('./parser_inline');
  488. var LinkifyIt = require('linkify-it');
  489. var mdurl = require('mdurl');
  490. var punycode = require('punycode');
  491. var config = {
  492. 'default': require('./presets/default'),
  493. zero: require('./presets/zero'),
  494. commonmark: require('./presets/commonmark')
  495. };
  496. ////////////////////////////////////////////////////////////////////////////////
  497. //
  498. // This validator can prohibit more than really needed to prevent XSS. It's a
  499. // tradeoff to keep code simple and to be secure by default.
  500. //
  501. // If you need different setup - override validator method as you wish. Or
  502. // replace it with dummy function and use external sanitizer.
  503. //
  504. var BAD_PROTO_RE = /^(vbscript|javascript|file|data):/;
  505. var GOOD_DATA_RE = /^data:image\/(gif|png|jpeg|webp);/;
  506. function validateLink(url) {
  507. // url should be normalized at this point, and existing entities are decoded
  508. var str = url.trim().toLowerCase();
  509. return BAD_PROTO_RE.test(str) ? (GOOD_DATA_RE.test(str) ? true : false) : true;
  510. }
  511. ////////////////////////////////////////////////////////////////////////////////
  512. var RECODE_HOSTNAME_FOR = [ 'http:', 'https:', 'mailto:' ];
  513. function normalizeLink(url) {
  514. var parsed = mdurl.parse(url, true);
  515. if (parsed.hostname) {
  516. // Encode hostnames in urls like:
  517. // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
  518. //
  519. // We don't encode unknown schemas, because it's likely that we encode
  520. // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
  521. //
  522. if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
  523. try {
  524. parsed.hostname = punycode.toASCII(parsed.hostname);
  525. } catch (er) { /**/ }
  526. }
  527. }
  528. return mdurl.encode(mdurl.format(parsed));
  529. }
  530. function normalizeLinkText(url) {
  531. var parsed = mdurl.parse(url, true);
  532. if (parsed.hostname) {
  533. // Encode hostnames in urls like:
  534. // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
  535. //
  536. // We don't encode unknown schemas, because it's likely that we encode
  537. // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
  538. //
  539. if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
  540. try {
  541. parsed.hostname = punycode.toUnicode(parsed.hostname);
  542. } catch (er) { /**/ }
  543. }
  544. }
  545. return mdurl.decode(mdurl.format(parsed));
  546. }
  547. /**
  548. * class MarkdownIt
  549. *
  550. * Main parser/renderer class.
  551. *
  552. * ##### Usage
  553. *
  554. * ```javascript
  555. * // node.js, "classic" way:
  556. * var MarkdownIt = require('markdown-it'),
  557. * md = new MarkdownIt();
  558. * var result = md.render('# markdown-it rulezz!');
  559. *
  560. * // node.js, the same, but with sugar:
  561. * var md = require('markdown-it')();
  562. * var result = md.render('# markdown-it rulezz!');
  563. *
  564. * // browser without AMD, added to "window" on script load
  565. * // Note, there are no dash.
  566. * var md = window.markdownit();
  567. * var result = md.render('# markdown-it rulezz!');
  568. * ```
  569. *
  570. * Single line rendering, without paragraph wrap:
  571. *
  572. * ```javascript
  573. * var md = require('markdown-it')();
  574. * var result = md.renderInline('__markdown-it__ rulezz!');
  575. * ```
  576. **/
  577. /**
  578. * new MarkdownIt([presetName, options])
  579. * - presetName (String): optional, `commonmark` / `zero`
  580. * - options (Object)
  581. *
  582. * Creates parser instanse with given config. Can be called without `new`.
  583. *
  584. * ##### presetName
  585. *
  586. * MarkdownIt provides named presets as a convenience to quickly
  587. * enable/disable active syntax rules and options for common use cases.
  588. *
  589. * - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js) -
  590. * configures parser to strict [CommonMark](http://commonmark.org/) mode.
  591. * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) -
  592. * similar to GFM, used when no preset name given. Enables all available rules,
  593. * but still without html, typographer & autolinker.
  594. * - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) -
  595. * all rules disabled. Useful to quickly setup your config via `.enable()`.
  596. * For example, when you need only `bold` and `italic` markup and nothing else.
  597. *
  598. * ##### options:
  599. *
  600. * - __html__ - `false`. Set `true` to enable HTML tags in source. Be careful!
  601. * That's not safe! You may need external sanitizer to protect output from XSS.
  602. * It's better to extend features via plugins, instead of enabling HTML.
  603. * - __xhtmlOut__ - `false`. Set `true` to add '/' when closing single tags
  604. * (`<br />`). This is needed only for full CommonMark compatibility. In real
  605. * world you will need HTML output.
  606. * - __breaks__ - `false`. Set `true` to convert `\n` in paragraphs into `<br>`.
  607. * - __langPrefix__ - `language-`. CSS language class prefix for fenced blocks.
  608. * Can be useful for external highlighters.
  609. * - __linkify__ - `false`. Set `true` to autoconvert URL-like text to links.
  610. * - __typographer__ - `false`. Set `true` to enable [some language-neutral
  611. * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +
  612. * quotes beautification (smartquotes).
  613. * - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement
  614. * pairs, when typographer enabled and smartquotes on. For example, you can
  615. * use `'«»„“'` for Russian, `'„“‚‘'` for German, and
  616. * `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).
  617. * - __highlight__ - `null`. Highlighter function for fenced code blocks.
  618. * Highlighter `function (str, lang)` should return escaped HTML. It can also
  619. * return empty string if the source was not changed and should be escaped
  620. * externaly. If result starts with <pre... internal wrapper is skipped.
  621. *
  622. * ##### Example
  623. *
  624. * ```javascript
  625. * // commonmark mode
  626. * var md = require('markdown-it')('commonmark');
  627. *
  628. * // default mode
  629. * var md = require('markdown-it')();
  630. *
  631. * // enable everything
  632. * var md = require('markdown-it')({
  633. * html: true,
  634. * linkify: true,
  635. * typographer: true
  636. * });
  637. * ```
  638. *
  639. * ##### Syntax highlighting
  640. *
  641. * ```js
  642. * var hljs = require('highlight.js') // https://highlightjs.org/
  643. *
  644. * var md = require('markdown-it')({
  645. * highlight: function (str, lang) {
  646. * if (lang && hljs.getLanguage(lang)) {
  647. * try {
  648. * return hljs.highlight(lang, str, true).value;
  649. * } catch (__) {}
  650. * }
  651. *
  652. * return ''; // use external default escaping
  653. * }
  654. * });
  655. * ```
  656. *
  657. * Or with full wrapper override (if you need assign class to `<pre>`):
  658. *
  659. * ```javascript
  660. * var hljs = require('highlight.js') // https://highlightjs.org/
  661. *
  662. * // Actual default values
  663. * var md = require('markdown-it')({
  664. * highlight: function (str, lang) {
  665. * if (lang && hljs.getLanguage(lang)) {
  666. * try {
  667. * return '<pre class="hljs"><code>' +
  668. * hljs.highlight(lang, str, true).value +
  669. * '</code></pre>';
  670. * } catch (__) {}
  671. * }
  672. *
  673. * return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
  674. * }
  675. * });
  676. * ```
  677. *
  678. **/
  679. function MarkdownIt(presetName, options) {
  680. if (!(this instanceof MarkdownIt)) {
  681. return new MarkdownIt(presetName, options);
  682. }
  683. if (!options) {
  684. if (!utils.isString(presetName)) {
  685. options = presetName || {};
  686. presetName = 'default';
  687. }
  688. }
  689. /**
  690. * MarkdownIt#inline -> ParserInline
  691. *
  692. * Instance of [[ParserInline]]. You may need it to add new rules when
  693. * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
  694. * [[MarkdownIt.enable]].
  695. **/
  696. this.inline = new ParserInline();
  697. /**
  698. * MarkdownIt#block -> ParserBlock
  699. *
  700. * Instance of [[ParserBlock]]. You may need it to add new rules when
  701. * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
  702. * [[MarkdownIt.enable]].
  703. **/
  704. this.block = new ParserBlock();
  705. /**
  706. * MarkdownIt#core -> Core
  707. *
  708. * Instance of [[Core]] chain executor. You may need it to add new rules when
  709. * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
  710. * [[MarkdownIt.enable]].
  711. **/
  712. this.core = new ParserCore();
  713. /**
  714. * MarkdownIt#renderer -> Renderer
  715. *
  716. * Instance of [[Renderer]]. Use it to modify output look. Or to add rendering
  717. * rules for new token types, generated by plugins.
  718. *
  719. * ##### Example
  720. *
  721. * ```javascript
  722. * var md = require('markdown-it')();
  723. *
  724. * function myToken(tokens, idx, options, env, self) {
  725. * //...
  726. * return result;
  727. * };
  728. *
  729. * md.renderer.rules['my_token'] = myToken
  730. * ```
  731. *
  732. * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js).
  733. **/
  734. this.renderer = new Renderer();
  735. /**
  736. * MarkdownIt#linkify -> LinkifyIt
  737. *
  738. * [linkify-it](https://github.com/markdown-it/linkify-it) instance.
  739. * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js)
  740. * rule.
  741. **/
  742. this.linkify = new LinkifyIt();
  743. /**
  744. * MarkdownIt#validateLink(url) -> Boolean
  745. *
  746. * Link validation function. CommonMark allows too much in links. By default
  747. * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas
  748. * except some embedded image types.
  749. *
  750. * You can change this behaviour:
  751. *
  752. * ```javascript
  753. * var md = require('markdown-it')();
  754. * // enable everything
  755. * md.validateLink = function () { return true; }
  756. * ```
  757. **/
  758. this.validateLink = validateLink;
  759. /**
  760. * MarkdownIt#normalizeLink(url) -> String
  761. *
  762. * Function used to encode link url to a machine-readable format,
  763. * which includes url-encoding, punycode, etc.
  764. **/
  765. this.normalizeLink = normalizeLink;
  766. /**
  767. * MarkdownIt#normalizeLinkText(url) -> String
  768. *
  769. * Function used to decode link url to a human-readable format`
  770. **/
  771. this.normalizeLinkText = normalizeLinkText;
  772. // Expose utils & helpers for easy acces from plugins
  773. /**
  774. * MarkdownIt#utils -> utils
  775. *
  776. * Assorted utility functions, useful to write plugins. See details
  777. * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.js).
  778. **/
  779. this.utils = utils;
  780. /**
  781. * MarkdownIt#helpers -> helpers
  782. *
  783. * Link components parser functions, useful to write plugins. See details
  784. * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/helpers).
  785. **/
  786. this.helpers = utils.assign({}, helpers);
  787. this.options = {};
  788. this.configure(presetName);
  789. if (options) { this.set(options); }
  790. }
  791. /** chainable
  792. * MarkdownIt.set(options)
  793. *
  794. * Set parser options (in the same format as in constructor). Probably, you
  795. * will never need it, but you can change options after constructor call.
  796. *
  797. * ##### Example
  798. *
  799. * ```javascript
  800. * var md = require('markdown-it')()
  801. * .set({ html: true, breaks: true })
  802. * .set({ typographer, true });
  803. * ```
  804. *
  805. * __Note:__ To achieve the best possible performance, don't modify a
  806. * `markdown-it` instance options on the fly. If you need multiple configurations
  807. * it's best to create multiple instances and initialize each with separate
  808. * config.
  809. **/
  810. MarkdownIt.prototype.set = function (options) {
  811. utils.assign(this.options, options);
  812. return this;
  813. };
  814. /** chainable, internal
  815. * MarkdownIt.configure(presets)
  816. *
  817. * Batch load of all options and compenent settings. This is internal method,
  818. * and you probably will not need it. But if you with - see available presets
  819. * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets)
  820. *
  821. * We strongly recommend to use presets instead of direct config loads. That
  822. * will give better compatibility with next versions.
  823. **/
  824. MarkdownIt.prototype.configure = function (presets) {
  825. var self = this, presetName;
  826. if (utils.isString(presets)) {
  827. presetName = presets;
  828. presets = config[presetName];
  829. if (!presets) { throw new Error('Wrong `markdown-it` preset "' + presetName + '", check name'); }
  830. }
  831. if (!presets) { throw new Error('Wrong `markdown-it` preset, can\'t be empty'); }
  832. if (presets.options) { self.set(presets.options); }
  833. if (presets.components) {
  834. Object.keys(presets.components).forEach(function (name) {
  835. if (presets.components[name].rules) {
  836. self[name].ruler.enableOnly(presets.components[name].rules);
  837. }
  838. if (presets.components[name].rules2) {
  839. self[name].ruler2.enableOnly(presets.components[name].rules2);
  840. }
  841. });
  842. }
  843. return this;
  844. };
  845. /** chainable
  846. * MarkdownIt.enable(list, ignoreInvalid)
  847. * - list (String|Array): rule name or list of rule names to enable
  848. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  849. *
  850. * Enable list or rules. It will automatically find appropriate components,
  851. * containing rules with given names. If rule not found, and `ignoreInvalid`
  852. * not set - throws exception.
  853. *
  854. * ##### Example
  855. *
  856. * ```javascript
  857. * var md = require('markdown-it')()
  858. * .enable(['sub', 'sup'])
  859. * .disable('smartquotes');
  860. * ```
  861. **/
  862. MarkdownIt.prototype.enable = function (list, ignoreInvalid) {
  863. var result = [];
  864. if (!Array.isArray(list)) { list = [ list ]; }
  865. [ 'core', 'block', 'inline' ].forEach(function (chain) {
  866. result = result.concat(this[chain].ruler.enable(list, true));
  867. }, this);
  868. result = result.concat(this.inline.ruler2.enable(list, true));
  869. var missed = list.filter(function (name) { return result.indexOf(name) < 0; });
  870. if (missed.length && !ignoreInvalid) {
  871. throw new Error('MarkdownIt. Failed to enable unknown rule(s): ' + missed);
  872. }
  873. return this;
  874. };
  875. /** chainable
  876. * MarkdownIt.disable(list, ignoreInvalid)
  877. * - list (String|Array): rule name or list of rule names to disable.
  878. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  879. *
  880. * The same as [[MarkdownIt.enable]], but turn specified rules off.
  881. **/
  882. MarkdownIt.prototype.disable = function (list, ignoreInvalid) {
  883. var result = [];
  884. if (!Array.isArray(list)) { list = [ list ]; }
  885. [ 'core', 'block', 'inline' ].forEach(function (chain) {
  886. result = result.concat(this[chain].ruler.disable(list, true));
  887. }, this);
  888. result = result.concat(this.inline.ruler2.disable(list, true));
  889. var missed = list.filter(function (name) { return result.indexOf(name) < 0; });
  890. if (missed.length && !ignoreInvalid) {
  891. throw new Error('MarkdownIt. Failed to disable unknown rule(s): ' + missed);
  892. }
  893. return this;
  894. };
  895. /** chainable
  896. * MarkdownIt.use(plugin, params)
  897. *
  898. * Load specified plugin with given params into current parser instance.
  899. * It's just a sugar to call `plugin(md, params)` with curring.
  900. *
  901. * ##### Example
  902. *
  903. * ```javascript
  904. * var iterator = require('markdown-it-for-inline');
  905. * var md = require('markdown-it')()
  906. * .use(iterator, 'foo_replace', 'text', function (tokens, idx) {
  907. * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');
  908. * });
  909. * ```
  910. **/
  911. MarkdownIt.prototype.use = function (plugin /*, params, ... */) {
  912. var args = [ this ].concat(Array.prototype.slice.call(arguments, 1));
  913. plugin.apply(plugin, args);
  914. return this;
  915. };
  916. /** internal
  917. * MarkdownIt.parse(src, env) -> Array
  918. * - src (String): source string
  919. * - env (Object): environment sandbox
  920. *
  921. * Parse input string and returns list of block tokens (special token type
  922. * "inline" will contain list of inline tokens). You should not call this
  923. * method directly, until you write custom renderer (for example, to produce
  924. * AST).
  925. *
  926. * `env` is used to pass data between "distributed" rules and return additional
  927. * metadata like reference info, needed for the renderer. It also can be used to
  928. * inject data in specific cases. Usually, you will be ok to pass `{}`,
  929. * and then pass updated object to renderer.
  930. **/
  931. MarkdownIt.prototype.parse = function (src, env) {
  932. if (typeof src !== 'string') {
  933. throw new Error('Input data should be a String');
  934. }
  935. var state = new this.core.State(src, this, env);
  936. this.core.process(state);
  937. return state.tokens;
  938. };
  939. /**
  940. * MarkdownIt.render(src [, env]) -> String
  941. * - src (String): source string
  942. * - env (Object): environment sandbox
  943. *
  944. * Render markdown string into html. It does all magic for you :).
  945. *
  946. * `env` can be used to inject additional metadata (`{}` by default).
  947. * But you will not need it with high probability. See also comment
  948. * in [[MarkdownIt.parse]].
  949. **/
  950. MarkdownIt.prototype.render = function (src, env) {
  951. env = env || {};
  952. return this.renderer.render(this.parse(src, env), this.options, env);
  953. };
  954. /** internal
  955. * MarkdownIt.parseInline(src, env) -> Array
  956. * - src (String): source string
  957. * - env (Object): environment sandbox
  958. *
  959. * The same as [[MarkdownIt.parse]] but skip all block rules. It returns the
  960. * block tokens list with the single `inline` element, containing parsed inline
  961. * tokens in `children` property. Also updates `env` object.
  962. **/
  963. MarkdownIt.prototype.parseInline = function (src, env) {
  964. var state = new this.core.State(src, this, env);
  965. state.inlineMode = true;
  966. this.core.process(state);
  967. return state.tokens;
  968. };
  969. /**
  970. * MarkdownIt.renderInline(src [, env]) -> String
  971. * - src (String): source string
  972. * - env (Object): environment sandbox
  973. *
  974. * Similar to [[MarkdownIt.render]] but for single paragraph content. Result
  975. * will NOT be wrapped into `<p>` tags.
  976. **/
  977. MarkdownIt.prototype.renderInline = function (src, env) {
  978. env = env || {};
  979. return this.renderer.render(this.parseInline(src, env), this.options, env);
  980. };
  981. module.exports = MarkdownIt;
  982. },{"./common/utils":4,"./helpers":5,"./parser_block":10,"./parser_core":11,"./parser_inline":12,"./presets/commonmark":13,"./presets/default":14,"./presets/zero":15,"./renderer":16,"linkify-it":53,"mdurl":58,"punycode":60}],10:[function(require,module,exports){
  983. /** internal
  984. * class ParserBlock
  985. *
  986. * Block-level tokenizer.
  987. **/
  988. 'use strict';
  989. var Ruler = require('./ruler');
  990. var _rules = [
  991. // First 2 params - rule name & source. Secondary array - list of rules,
  992. // which can be terminated by this one.
  993. [ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ],
  994. [ 'code', require('./rules_block/code') ],
  995. [ 'fence', require('./rules_block/fence'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
  996. [ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
  997. [ 'hr', require('./rules_block/hr'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
  998. [ 'list', require('./rules_block/list'), [ 'paragraph', 'reference', 'blockquote' ] ],
  999. [ 'reference', require('./rules_block/reference') ],
  1000. [ 'heading', require('./rules_block/heading'), [ 'paragraph', 'reference', 'blockquote' ] ],
  1001. [ 'lheading', require('./rules_block/lheading') ],
  1002. [ 'html_block', require('./rules_block/html_block'), [ 'paragraph', 'reference', 'blockquote' ] ],
  1003. [ 'paragraph', require('./rules_block/paragraph') ]
  1004. ];
  1005. /**
  1006. * new ParserBlock()
  1007. **/
  1008. function ParserBlock() {
  1009. /**
  1010. * ParserBlock#ruler -> Ruler
  1011. *
  1012. * [[Ruler]] instance. Keep configuration of block rules.
  1013. **/
  1014. this.ruler = new Ruler();
  1015. for (var i = 0; i < _rules.length; i++) {
  1016. this.ruler.push(_rules[i][0], _rules[i][1], { alt: (_rules[i][2] || []).slice() });
  1017. }
  1018. }
  1019. // Generate tokens for input range
  1020. //
  1021. ParserBlock.prototype.tokenize = function (state, startLine, endLine) {
  1022. var ok, i,
  1023. rules = this.ruler.getRules(''),
  1024. len = rules.length,
  1025. line = startLine,
  1026. hasEmptyLines = false,
  1027. maxNesting = state.md.options.maxNesting;
  1028. while (line < endLine) {
  1029. state.line = line = state.skipEmptyLines(line);
  1030. if (line >= endLine) { break; }
  1031. // Termination condition for nested calls.
  1032. // Nested calls currently used for blockquotes & lists
  1033. if (state.sCount[line] < state.blkIndent) { break; }
  1034. // If nesting level exceeded - skip tail to the end. That's not ordinary
  1035. // situation and we should not care about content.
  1036. if (state.level >= maxNesting) {
  1037. state.line = endLine;
  1038. break;
  1039. }
  1040. // Try all possible rules.
  1041. // On success, rule should:
  1042. //
  1043. // - update `state.line`
  1044. // - update `state.tokens`
  1045. // - return true
  1046. for (i = 0; i < len; i++) {
  1047. ok = rules[i](state, line, endLine, false);
  1048. if (ok) { break; }
  1049. }
  1050. // set state.tight if we had an empty line before current tag
  1051. // i.e. latest empty line should not count
  1052. state.tight = !hasEmptyLines;
  1053. // paragraph might "eat" one newline after it in nested lists
  1054. if (state.isEmpty(state.line - 1)) {
  1055. hasEmptyLines = true;
  1056. }
  1057. line = state.line;
  1058. if (line < endLine && state.isEmpty(line)) {
  1059. hasEmptyLines = true;
  1060. line++;
  1061. state.line = line;
  1062. }
  1063. }
  1064. };
  1065. /**
  1066. * ParserBlock.parse(str, md, env, outTokens)
  1067. *
  1068. * Process input string and push block tokens into `outTokens`
  1069. **/
  1070. ParserBlock.prototype.parse = function (src, md, env, outTokens) {
  1071. var state;
  1072. if (!src) { return; }
  1073. state = new this.State(src, md, env, outTokens);
  1074. this.tokenize(state, state.line, state.lineMax);
  1075. };
  1076. ParserBlock.prototype.State = require('./rules_block/state_block');
  1077. module.exports = ParserBlock;
  1078. },{"./ruler":17,"./rules_block/blockquote":18,"./rules_block/code":19,"./rules_block/fence":20,"./rules_block/heading":21,"./rules_block/hr":22,"./rules_block/html_block":23,"./rules_block/lheading":24,"./rules_block/list":25,"./rules_block/paragraph":26,"./rules_block/reference":27,"./rules_block/state_block":28,"./rules_block/table":29}],11:[function(require,module,exports){
  1079. /** internal
  1080. * class Core
  1081. *
  1082. * Top-level rules executor. Glues block/inline parsers and does intermediate
  1083. * transformations.
  1084. **/
  1085. 'use strict';
  1086. var Ruler = require('./ruler');
  1087. var _rules = [
  1088. [ 'normalize', require('./rules_core/normalize') ],
  1089. [ 'block', require('./rules_core/block') ],
  1090. [ 'inline', require('./rules_core/inline') ],
  1091. [ 'linkify', require('./rules_core/linkify') ],
  1092. [ 'replacements', require('./rules_core/replacements') ],
  1093. [ 'smartquotes', require('./rules_core/smartquotes') ]
  1094. ];
  1095. /**
  1096. * new Core()
  1097. **/
  1098. function Core() {
  1099. /**
  1100. * Core#ruler -> Ruler
  1101. *
  1102. * [[Ruler]] instance. Keep configuration of core rules.
  1103. **/
  1104. this.ruler = new Ruler();
  1105. for (var i = 0; i < _rules.length; i++) {
  1106. this.ruler.push(_rules[i][0], _rules[i][1]);
  1107. }
  1108. }
  1109. /**
  1110. * Core.process(state)
  1111. *
  1112. * Executes core chain rules.
  1113. **/
  1114. Core.prototype.process = function (state) {
  1115. var i, l, rules;
  1116. rules = this.ruler.getRules('');
  1117. for (i = 0, l = rules.length; i < l; i++) {
  1118. rules[i](state);
  1119. }
  1120. };
  1121. Core.prototype.State = require('./rules_core/state_core');
  1122. module.exports = Core;
  1123. },{"./ruler":17,"./rules_core/block":30,"./rules_core/inline":31,"./rules_core/linkify":32,"./rules_core/normalize":33,"./rules_core/replacements":34,"./rules_core/smartquotes":35,"./rules_core/state_core":36}],12:[function(require,module,exports){
  1124. /** internal
  1125. * class ParserInline
  1126. *
  1127. * Tokenizes paragraph content.
  1128. **/
  1129. 'use strict';
  1130. var Ruler = require('./ruler');
  1131. ////////////////////////////////////////////////////////////////////////////////
  1132. // Parser rules
  1133. var _rules = [
  1134. [ 'text', require('./rules_inline/text') ],
  1135. [ 'newline', require('./rules_inline/newline') ],
  1136. [ 'escape', require('./rules_inline/escape') ],
  1137. [ 'backticks', require('./rules_inline/backticks') ],
  1138. [ 'strikethrough', require('./rules_inline/strikethrough').tokenize ],
  1139. [ 'emphasis', require('./rules_inline/emphasis').tokenize ],
  1140. [ 'link', require('./rules_inline/link') ],
  1141. [ 'image', require('./rules_inline/image') ],
  1142. [ 'autolink', require('./rules_inline/autolink') ],
  1143. [ 'html_inline', require('./rules_inline/html_inline') ],
  1144. [ 'entity', require('./rules_inline/entity') ]
  1145. ];
  1146. var _rules2 = [
  1147. [ 'balance_pairs', require('./rules_inline/balance_pairs') ],
  1148. [ 'strikethrough', require('./rules_inline/strikethrough').postProcess ],
  1149. [ 'emphasis', require('./rules_inline/emphasis').postProcess ],
  1150. [ 'text_collapse', require('./rules_inline/text_collapse') ]
  1151. ];
  1152. /**
  1153. * new ParserInline()
  1154. **/
  1155. function ParserInline() {
  1156. var i;
  1157. /**
  1158. * ParserInline#ruler -> Ruler
  1159. *
  1160. * [[Ruler]] instance. Keep configuration of inline rules.
  1161. **/
  1162. this.ruler = new Ruler();
  1163. for (i = 0; i < _rules.length; i++) {
  1164. this.ruler.push(_rules[i][0], _rules[i][1]);
  1165. }
  1166. /**
  1167. * ParserInline#ruler2 -> Ruler
  1168. *
  1169. * [[Ruler]] instance. Second ruler used for post-processing
  1170. * (e.g. in emphasis-like rules).
  1171. **/
  1172. this.ruler2 = new Ruler();
  1173. for (i = 0; i < _rules2.length; i++) {
  1174. this.ruler2.push(_rules2[i][0], _rules2[i][1]);
  1175. }
  1176. }
  1177. // Skip single token by running all rules in validation mode;
  1178. // returns `true` if any rule reported success
  1179. //
  1180. ParserInline.prototype.skipToken = function (state) {
  1181. var ok, i, pos = state.pos,
  1182. rules = this.ruler.getRules(''),
  1183. len = rules.length,
  1184. maxNesting = state.md.options.maxNesting,
  1185. cache = state.cache;
  1186. if (typeof cache[pos] !== 'undefined') {
  1187. state.pos = cache[pos];
  1188. return;
  1189. }
  1190. if (state.level < maxNesting) {
  1191. for (i = 0; i < len; i++) {
  1192. // Increment state.level and decrement it later to limit recursion.
  1193. // It's harmless to do here, because no tokens are created. But ideally,
  1194. // we'd need a separate private state variable for this purpose.
  1195. //
  1196. state.level++;
  1197. ok = rules[i](state, true);
  1198. state.level--;
  1199. if (ok) { break; }
  1200. }
  1201. } else {
  1202. // Too much nesting, just skip until the end of the paragraph.
  1203. //
  1204. // NOTE: this will cause links to behave incorrectly in the following case,
  1205. // when an amount of `[` is exactly equal to `maxNesting + 1`:
  1206. //
  1207. // [[[[[[[[[[[[[[[[[[[[[foo]()
  1208. //
  1209. // TODO: remove this workaround when CM standard will allow nested links
  1210. // (we can replace it by preventing links from being parsed in
  1211. // validation mode)
  1212. //
  1213. state.pos = state.posMax;
  1214. }
  1215. if (!ok) { state.pos++; }
  1216. cache[pos] = state.pos;
  1217. };
  1218. // Generate tokens for input range
  1219. //
  1220. ParserInline.prototype.tokenize = function (state) {
  1221. var ok, i,
  1222. rules = this.ruler.getRules(''),
  1223. len = rules.length,
  1224. end = state.posMax,
  1225. maxNesting = state.md.options.maxNesting;
  1226. while (state.pos < end) {
  1227. // Try all possible rules.
  1228. // On success, rule should:
  1229. //
  1230. // - update `state.pos`
  1231. // - update `state.tokens`
  1232. // - return true
  1233. if (state.level < maxNesting) {
  1234. for (i = 0; i < len; i++) {
  1235. ok = rules[i](state, false);
  1236. if (ok) { break; }
  1237. }
  1238. }
  1239. if (ok) {
  1240. if (state.pos >= end) { break; }
  1241. continue;
  1242. }
  1243. state.pending += state.src[state.pos++];
  1244. }
  1245. if (state.pending) {
  1246. state.pushPending();
  1247. }
  1248. };
  1249. /**
  1250. * ParserInline.parse(str, md, env, outTokens)
  1251. *
  1252. * Process input string and push inline tokens into `outTokens`
  1253. **/
  1254. ParserInline.prototype.parse = function (str, md, env, outTokens) {
  1255. var i, rules, len;
  1256. var state = new this.State(str, md, env, outTokens);
  1257. this.tokenize(state);
  1258. rules = this.ruler2.getRules('');
  1259. len = rules.length;
  1260. for (i = 0; i < len; i++) {
  1261. rules[i](state);
  1262. }
  1263. };
  1264. ParserInline.prototype.State = require('./rules_inline/state_inline');
  1265. module.exports = ParserInline;
  1266. },{"./ruler":17,"./rules_inline/autolink":37,"./rules_inline/backticks":38,"./rules_inline/balance_pairs":39,"./rules_inline/emphasis":40,"./rules_inline/entity":41,"./rules_inline/escape":42,"./rules_inline/html_inline":43,"./rules_inline/image":44,"./rules_inline/link":45,"./rules_inline/newline":46,"./rules_inline/state_inline":47,"./rules_inline/strikethrough":48,"./rules_inline/text":49,"./rules_inline/text_collapse":50}],13:[function(require,module,exports){
  1267. // Commonmark default options
  1268. 'use strict';
  1269. module.exports = {
  1270. options: {
  1271. html: true, // Enable HTML tags in source
  1272. xhtmlOut: true, // Use '/' to close single tags (<br />)
  1273. breaks: false, // Convert '\n' in paragraphs into <br>
  1274. langPrefix: 'language-', // CSS language prefix for fenced blocks
  1275. linkify: false, // autoconvert URL-like texts to links
  1276. // Enable some language-neutral replacements + quotes beautification
  1277. typographer: false,
  1278. // Double + single quotes replacement pairs, when typographer enabled,
  1279. // and smartquotes on. Could be either a String or an Array.
  1280. //
  1281. // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  1282. // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  1283. quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
  1284. // Highlighter function. Should return escaped HTML,
  1285. // or '' if the source string is not changed and should be escaped externaly.
  1286. // If result starts with <pre... internal wrapper is skipped.
  1287. //
  1288. // function (/*str, lang*/) { return ''; }
  1289. //
  1290. highlight: null,
  1291. maxNesting: 20 // Internal protection, recursion limit
  1292. },
  1293. components: {
  1294. core: {
  1295. rules: [
  1296. 'normalize',
  1297. 'block',
  1298. 'inline'
  1299. ]
  1300. },
  1301. block: {
  1302. rules: [
  1303. 'blockquote',
  1304. 'code',
  1305. 'fence',
  1306. 'heading',
  1307. 'hr',
  1308. 'html_block',
  1309. 'lheading',
  1310. 'list',
  1311. 'reference',
  1312. 'paragraph'
  1313. ]
  1314. },
  1315. inline: {
  1316. rules: [
  1317. 'autolink',
  1318. 'backticks',
  1319. 'emphasis',
  1320. 'entity',
  1321. 'escape',
  1322. 'html_inline',
  1323. 'image',
  1324. 'link',
  1325. 'newline',
  1326. 'text'
  1327. ],
  1328. rules2: [
  1329. 'balance_pairs',
  1330. 'emphasis',
  1331. 'text_collapse'
  1332. ]
  1333. }
  1334. }
  1335. };
  1336. },{}],14:[function(require,module,exports){
  1337. // markdown-it default options
  1338. 'use strict';
  1339. module.exports = {
  1340. options: {
  1341. html: false, // Enable HTML tags in source
  1342. xhtmlOut: false, // Use '/' to close single tags (<br />)
  1343. breaks: false, // Convert '\n' in paragraphs into <br>
  1344. langPrefix: 'language-', // CSS language prefix for fenced blocks
  1345. linkify: false, // autoconvert URL-like texts to links
  1346. // Enable some language-neutral replacements + quotes beautification
  1347. typographer: false,
  1348. // Double + single quotes replacement pairs, when typographer enabled,
  1349. // and smartquotes on. Could be either a String or an Array.
  1350. //
  1351. // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  1352. // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  1353. quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
  1354. // Highlighter function. Should return escaped HTML,
  1355. // or '' if the source string is not changed and should be escaped externaly.
  1356. // If result starts with <pre... internal wrapper is skipped.
  1357. //
  1358. // function (/*str, lang*/) { return ''; }
  1359. //
  1360. highlight: null,
  1361. maxNesting: 100 // Internal protection, recursion limit
  1362. },
  1363. components: {
  1364. core: {},
  1365. block: {},
  1366. inline: {}
  1367. }
  1368. };
  1369. },{}],15:[function(require,module,exports){
  1370. // "Zero" preset, with nothing enabled. Useful for manual configuring of simple
  1371. // modes. For example, to parse bold/italic only.
  1372. 'use strict';
  1373. module.exports = {
  1374. options: {
  1375. html: false, // Enable HTML tags in source
  1376. xhtmlOut: false, // Use '/' to close single tags (<br />)
  1377. breaks: false, // Convert '\n' in paragraphs into <br>
  1378. langPrefix: 'language-', // CSS language prefix for fenced blocks
  1379. linkify: false, // autoconvert URL-like texts to links
  1380. // Enable some language-neutral replacements + quotes beautification
  1381. typographer: false,
  1382. // Double + single quotes replacement pairs, when typographer enabled,
  1383. // and smartquotes on. Could be either a String or an Array.
  1384. //
  1385. // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  1386. // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  1387. quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
  1388. // Highlighter function. Should return escaped HTML,
  1389. // or '' if the source string is not changed and should be escaped externaly.
  1390. // If result starts with <pre... internal wrapper is skipped.
  1391. //
  1392. // function (/*str, lang*/) { return ''; }
  1393. //
  1394. highlight: null,
  1395. maxNesting: 20 // Internal protection, recursion limit
  1396. },
  1397. components: {
  1398. core: {
  1399. rules: [
  1400. 'normalize',
  1401. 'block',
  1402. 'inline'
  1403. ]
  1404. },
  1405. block: {
  1406. rules: [
  1407. 'paragraph'
  1408. ]
  1409. },
  1410. inline: {
  1411. rules: [
  1412. 'text'
  1413. ],
  1414. rules2: [
  1415. 'balance_pairs',
  1416. 'text_collapse'
  1417. ]
  1418. }
  1419. }
  1420. };
  1421. },{}],16:[function(require,module,exports){
  1422. /**
  1423. * class Renderer
  1424. *
  1425. * Generates HTML from parsed token stream. Each instance has independent
  1426. * copy of rules. Those can be rewritten with ease. Also, you can add new
  1427. * rules if you create plugin and adds new token types.
  1428. **/
  1429. 'use strict';
  1430. var assign = require('./common/utils').assign;
  1431. var unescapeAll = require('./common/utils').unescapeAll;
  1432. var escapeHtml = require('./common/utils').escapeHtml;
  1433. ////////////////////////////////////////////////////////////////////////////////
  1434. var default_rules = {};
  1435. default_rules.code_inline = function (tokens, idx, options, env, slf) {
  1436. var token = tokens[idx];
  1437. return '<code' + slf.renderAttrs(token) + '>' +
  1438. escapeHtml(tokens[idx].content) +
  1439. '</code>';
  1440. };
  1441. default_rules.code_block = function (tokens, idx, options, env, slf) {
  1442. var token = tokens[idx];
  1443. return '<pre' + slf.renderAttrs(token) + '><code>' +
  1444. escapeHtml(tokens[idx].content) +
  1445. '</code></pre>\n';
  1446. };
  1447. default_rules.fence = function (tokens, idx, options, env, slf) {
  1448. var token = tokens[idx],
  1449. info = token.info ? unescapeAll(token.info).trim() : '',
  1450. langName = '',
  1451. highlighted, i, tmpAttrs, tmpToken;
  1452. if (info) {
  1453. langName = info.split(/\s+/g)[0];
  1454. }
  1455. if (options.highlight) {
  1456. highlighted = options.highlight(token.content, langName) || escapeHtml(token.content);
  1457. } else {
  1458. highlighted = escapeHtml(token.content);
  1459. }
  1460. if (highlighted.indexOf('<pre') === 0) {
  1461. return highlighted + '\n';
  1462. }
  1463. // If language exists, inject class gently, without modifying original token.
  1464. // May be, one day we will add .clone() for token and simplify this part, but
  1465. // now we prefer to keep things local.
  1466. if (info) {
  1467. i = token.attrIndex('class');
  1468. tmpAttrs = token.attrs ? token.attrs.slice() : [];
  1469. if (i < 0) {
  1470. tmpAttrs.push([ 'class', options.langPrefix + langName ]);
  1471. } else {
  1472. tmpAttrs[i][1] += ' ' + options.langPrefix + langName;
  1473. }
  1474. // Fake token just to render attributes
  1475. tmpToken = {
  1476. attrs: tmpAttrs
  1477. };
  1478. return '<pre><code' + slf.renderAttrs(tmpToken) + '>'
  1479. + highlighted
  1480. + '</code></pre>\n';
  1481. }
  1482. return '<pre><code' + slf.renderAttrs(token) + '>'
  1483. + highlighted
  1484. + '</code></pre>\n';
  1485. };
  1486. default_rules.image = function (tokens, idx, options, env, slf) {
  1487. var token = tokens[idx];
  1488. // "alt" attr MUST be set, even if empty. Because it's mandatory and
  1489. // should be placed on proper position for tests.
  1490. //
  1491. // Replace content with actual value
  1492. token.attrs[token.attrIndex('alt')][1] =
  1493. slf.renderInlineAsText(token.children, options, env);
  1494. return slf.renderToken(tokens, idx, options);
  1495. };
  1496. default_rules.hardbreak = function (tokens, idx, options /*, env */) {
  1497. return options.xhtmlOut ? '<br />\n' : '<br>\n';
  1498. };
  1499. default_rules.softbreak = function (tokens, idx, options /*, env */) {
  1500. return options.breaks ? (options.xhtmlOut ? '<br />\n' : '<br>\n') : '\n';
  1501. };
  1502. default_rules.text = function (tokens, idx /*, options, env */) {
  1503. return escapeHtml(tokens[idx].content);
  1504. };
  1505. default_rules.html_block = function (tokens, idx /*, options, env */) {
  1506. return tokens[idx].content;
  1507. };
  1508. default_rules.html_inline = function (tokens, idx /*, options, env */) {
  1509. return tokens[idx].content;
  1510. };
  1511. /**
  1512. * new Renderer()
  1513. *
  1514. * Creates new [[Renderer]] instance and fill [[Renderer#rules]] with defaults.
  1515. **/
  1516. function Renderer() {
  1517. /**
  1518. * Renderer#rules -> Object
  1519. *
  1520. * Contains render rules for tokens. Can be updated and extended.
  1521. *
  1522. * ##### Example
  1523. *
  1524. * ```javascript
  1525. * var md = require('markdown-it')();
  1526. *
  1527. * md.renderer.rules.strong_open = function () { return '<b>'; };
  1528. * md.renderer.rules.strong_close = function () { return '</b>'; };
  1529. *
  1530. * var result = md.renderInline(...);
  1531. * ```
  1532. *
  1533. * Each rule is called as independent static function with fixed signature:
  1534. *
  1535. * ```javascript
  1536. * function my_token_render(tokens, idx, options, env, renderer) {
  1537. * // ...
  1538. * return renderedHTML;
  1539. * }
  1540. * ```
  1541. *
  1542. * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js)
  1543. * for more details and examples.
  1544. **/
  1545. this.rules = assign({}, default_rules);
  1546. }
  1547. /**
  1548. * Renderer.renderAttrs(token) -> String
  1549. *
  1550. * Render token attributes to string.
  1551. **/
  1552. Renderer.prototype.renderAttrs = function renderAttrs(token) {
  1553. var i, l, result;
  1554. if (!token.attrs) { return ''; }
  1555. result = '';
  1556. for (i = 0, l = token.attrs.length; i < l; i++) {
  1557. result += ' ' + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
  1558. }
  1559. return result;
  1560. };
  1561. /**
  1562. * Renderer.renderToken(tokens, idx, options) -> String
  1563. * - tokens (Array): list of tokens
  1564. * - idx (Numbed): token index to render
  1565. * - options (Object): params of parser instance
  1566. *
  1567. * Default token renderer. Can be overriden by custom function
  1568. * in [[Renderer#rules]].
  1569. **/
  1570. Renderer.prototype.renderToken = function renderToken(tokens, idx, options) {
  1571. var nextToken,
  1572. result = '',
  1573. needLf = false,
  1574. token = tokens[idx];
  1575. // Tight list paragraphs
  1576. if (token.hidden) {
  1577. return '';
  1578. }
  1579. // Insert a newline between hidden paragraph and subsequent opening
  1580. // block-level tag.
  1581. //
  1582. // For example, here we should insert a newline before blockquote:
  1583. // - a
  1584. // >
  1585. //
  1586. if (token.block && token.nesting !== -1 && idx && tokens[idx - 1].hidden) {
  1587. result += '\n';
  1588. }
  1589. // Add token name, e.g. `<img`
  1590. result += (token.nesting === -1 ? '</' : '<') + token.tag;
  1591. // Encode attributes, e.g. `<img src="foo"`
  1592. result += this.renderAttrs(token);
  1593. // Add a slash for self-closing tags, e.g. `<img src="foo" /`
  1594. if (token.nesting === 0 && options.xhtmlOut) {
  1595. result += ' /';
  1596. }
  1597. // Check if we need to add a newline after this tag
  1598. if (token.block) {
  1599. needLf = true;
  1600. if (token.nesting === 1) {
  1601. if (idx + 1 < tokens.length) {
  1602. nextToken = tokens[idx + 1];
  1603. if (nextToken.type === 'inline' || nextToken.hidden) {
  1604. // Block-level tag containing an inline tag.
  1605. //
  1606. needLf = false;
  1607. } else if (nextToken.nesting === -1 && nextToken.tag === token.tag) {
  1608. // Opening tag + closing tag of the same type. E.g. `<li></li>`.
  1609. //
  1610. needLf = false;
  1611. }
  1612. }
  1613. }
  1614. }
  1615. result += needLf ? '>\n' : '>';
  1616. return result;
  1617. };
  1618. /**
  1619. * Renderer.renderInline(tokens, options, env) -> String
  1620. * - tokens (Array): list on block tokens to renter
  1621. * - options (Object): params of parser instance
  1622. * - env (Object): additional data from parsed input (references, for example)
  1623. *
  1624. * The same as [[Renderer.render]], but for single token of `inline` type.
  1625. **/
  1626. Renderer.prototype.renderInline = function (tokens, options, env) {
  1627. var type,
  1628. result = '',
  1629. rules = this.rules;
  1630. for (var i = 0, len = tokens.length; i < len; i++) {
  1631. type = tokens[i].type;
  1632. if (typeof rules[type] !== 'undefined') {
  1633. result += rules[type](tokens, i, options, env, this);
  1634. } else {
  1635. result += this.renderToken(tokens, i, options);
  1636. }
  1637. }
  1638. return result;
  1639. };
  1640. /** internal
  1641. * Renderer.renderInlineAsText(tokens, options, env) -> String
  1642. * - tokens (Array): list on block tokens to renter
  1643. * - options (Object): params of parser instance
  1644. * - env (Object): additional data from parsed input (references, for example)
  1645. *
  1646. * Special kludge for image `alt` attributes to conform CommonMark spec.
  1647. * Don't try to use it! Spec requires to show `alt` content with stripped markup,
  1648. * instead of simple escaping.
  1649. **/
  1650. Renderer.prototype.renderInlineAsText = function (tokens, options, env) {
  1651. var result = '';
  1652. for (var i = 0, len = tokens.length; i < len; i++) {
  1653. if (tokens[i].type === 'text') {
  1654. result += tokens[i].content;
  1655. } else if (tokens[i].type === 'image') {
  1656. result += this.renderInlineAsText(tokens[i].children, options, env);
  1657. }
  1658. }
  1659. return result;
  1660. };
  1661. /**
  1662. * Renderer.render(tokens, options, env) -> String
  1663. * - tokens (Array): list on block tokens to renter
  1664. * - options (Object): params of parser instance
  1665. * - env (Object): additional data from parsed input (references, for example)
  1666. *
  1667. * Takes token stream and generates HTML. Probably, you will never need to call
  1668. * this method directly.
  1669. **/
  1670. Renderer.prototype.render = function (tokens, options, env) {
  1671. var i, len, type,
  1672. result = '',
  1673. rules = this.rules;
  1674. for (i = 0, len = tokens.length; i < len; i++) {
  1675. type = tokens[i].type;
  1676. if (type === 'inline') {
  1677. result += this.renderInline(tokens[i].children, options, env);
  1678. } else if (typeof rules[type] !== 'undefined') {
  1679. result += rules[tokens[i].type](tokens, i, options, env, this);
  1680. } else {
  1681. result += this.renderToken(tokens, i, options, env);
  1682. }
  1683. }
  1684. return result;
  1685. };
  1686. module.exports = Renderer;
  1687. },{"./common/utils":4}],17:[function(require,module,exports){
  1688. /**
  1689. * class Ruler
  1690. *
  1691. * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and
  1692. * [[MarkdownIt#inline]] to manage sequences of functions (rules):
  1693. *
  1694. * - keep rules in defined order
  1695. * - assign the name to each rule
  1696. * - enable/disable rules
  1697. * - add/replace rules
  1698. * - allow assign rules to additional named chains (in the same)
  1699. * - cacheing lists of active rules
  1700. *
  1701. * You will not need use this class directly until write plugins. For simple
  1702. * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and
  1703. * [[MarkdownIt.use]].
  1704. **/
  1705. 'use strict';
  1706. /**
  1707. * new Ruler()
  1708. **/
  1709. function Ruler() {
  1710. // List of added rules. Each element is:
  1711. //
  1712. // {
  1713. // name: XXX,
  1714. // enabled: Boolean,
  1715. // fn: Function(),
  1716. // alt: [ name2, name3 ]
  1717. // }
  1718. //
  1719. this.__rules__ = [];
  1720. // Cached rule chains.
  1721. //
  1722. // First level - chain name, '' for default.
  1723. // Second level - diginal anchor for fast filtering by charcodes.
  1724. //
  1725. this.__cache__ = null;
  1726. }
  1727. ////////////////////////////////////////////////////////////////////////////////
  1728. // Helper methods, should not be used directly
  1729. // Find rule index by name
  1730. //
  1731. Ruler.prototype.__find__ = function (name) {
  1732. for (var i = 0; i < this.__rules__.length; i++) {
  1733. if (this.__rules__[i].name === name) {
  1734. return i;
  1735. }
  1736. }
  1737. return -1;
  1738. };
  1739. // Build rules lookup cache
  1740. //
  1741. Ruler.prototype.__compile__ = function () {
  1742. var self = this;
  1743. var chains = [ '' ];
  1744. // collect unique names
  1745. self.__rules__.forEach(function (rule) {
  1746. if (!rule.enabled) { return; }
  1747. rule.alt.forEach(function (altName) {
  1748. if (chains.indexOf(altName) < 0) {
  1749. chains.push(altName);
  1750. }
  1751. });
  1752. });
  1753. self.__cache__ = {};
  1754. chains.forEach(function (chain) {
  1755. self.__cache__[chain] = [];
  1756. self.__rules__.forEach(function (rule) {
  1757. if (!rule.enabled) { return; }
  1758. if (chain && rule.alt.indexOf(chain) < 0) { return; }
  1759. self.__cache__[chain].push(rule.fn);
  1760. });
  1761. });
  1762. };
  1763. /**
  1764. * Ruler.at(name, fn [, options])
  1765. * - name (String): rule name to replace.
  1766. * - fn (Function): new rule function.
  1767. * - options (Object): new rule options (not mandatory).
  1768. *
  1769. * Replace rule by name with new function & options. Throws error if name not
  1770. * found.
  1771. *
  1772. * ##### Options:
  1773. *
  1774. * - __alt__ - array with names of "alternate" chains.
  1775. *
  1776. * ##### Example
  1777. *
  1778. * Replace existing typographer replacement rule with new one:
  1779. *
  1780. * ```javascript
  1781. * var md = require('markdown-it')();
  1782. *
  1783. * md.core.ruler.at('replacements', function replace(state) {
  1784. * //...
  1785. * });
  1786. * ```
  1787. **/
  1788. Ruler.prototype.at = function (name, fn, options) {
  1789. var index = this.__find__(name);
  1790. var opt = options || {};
  1791. if (index === -1) { throw new Error('Parser rule not found: ' + name); }
  1792. this.__rules__[index].fn = fn;
  1793. this.__rules__[index].alt = opt.alt || [];
  1794. this.__cache__ = null;
  1795. };
  1796. /**
  1797. * Ruler.before(beforeName, ruleName, fn [, options])
  1798. * - beforeName (String): new rule will be added before this one.
  1799. * - ruleName (String): name of added rule.
  1800. * - fn (Function): rule function.
  1801. * - options (Object): rule options (not mandatory).
  1802. *
  1803. * Add new rule to chain before one with given name. See also
  1804. * [[Ruler.after]], [[Ruler.push]].
  1805. *
  1806. * ##### Options:
  1807. *
  1808. * - __alt__ - array with names of "alternate" chains.
  1809. *
  1810. * ##### Example
  1811. *
  1812. * ```javascript
  1813. * var md = require('markdown-it')();
  1814. *
  1815. * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {
  1816. * //...
  1817. * });
  1818. * ```
  1819. **/
  1820. Ruler.prototype.before = function (beforeName, ruleName, fn, options) {
  1821. var index = this.__find__(beforeName);
  1822. var opt = options || {};
  1823. if (index === -1) { throw new Error('Parser rule not found: ' + beforeName); }
  1824. this.__rules__.splice(index, 0, {
  1825. name: ruleName,
  1826. enabled: true,
  1827. fn: fn,
  1828. alt: opt.alt || []
  1829. });
  1830. this.__cache__ = null;
  1831. };
  1832. /**
  1833. * Ruler.after(afterName, ruleName, fn [, options])
  1834. * - afterName (String): new rule will be added after this one.
  1835. * - ruleName (String): name of added rule.
  1836. * - fn (Function): rule function.
  1837. * - options (Object): rule options (not mandatory).
  1838. *
  1839. * Add new rule to chain after one with given name. See also
  1840. * [[Ruler.before]], [[Ruler.push]].
  1841. *
  1842. * ##### Options:
  1843. *
  1844. * - __alt__ - array with names of "alternate" chains.
  1845. *
  1846. * ##### Example
  1847. *
  1848. * ```javascript
  1849. * var md = require('markdown-it')();
  1850. *
  1851. * md.inline.ruler.after('text', 'my_rule', function replace(state) {
  1852. * //...
  1853. * });
  1854. * ```
  1855. **/
  1856. Ruler.prototype.after = function (afterName, ruleName, fn, options) {
  1857. var index = this.__find__(afterName);
  1858. var opt = options || {};
  1859. if (index === -1) { throw new Error('Parser rule not found: ' + afterName); }
  1860. this.__rules__.splice(index + 1, 0, {
  1861. name: ruleName,
  1862. enabled: true,
  1863. fn: fn,
  1864. alt: opt.alt || []
  1865. });
  1866. this.__cache__ = null;
  1867. };
  1868. /**
  1869. * Ruler.push(ruleName, fn [, options])
  1870. * - ruleName (String): name of added rule.
  1871. * - fn (Function): rule function.
  1872. * - options (Object): rule options (not mandatory).
  1873. *
  1874. * Push new rule to the end of chain. See also
  1875. * [[Ruler.before]], [[Ruler.after]].
  1876. *
  1877. * ##### Options:
  1878. *
  1879. * - __alt__ - array with names of "alternate" chains.
  1880. *
  1881. * ##### Example
  1882. *
  1883. * ```javascript
  1884. * var md = require('markdown-it')();
  1885. *
  1886. * md.core.ruler.push('my_rule', function replace(state) {
  1887. * //...
  1888. * });
  1889. * ```
  1890. **/
  1891. Ruler.prototype.push = function (ruleName, fn, options) {
  1892. var opt = options || {};
  1893. this.__rules__.push({
  1894. name: ruleName,
  1895. enabled: true,
  1896. fn: fn,
  1897. alt: opt.alt || []
  1898. });
  1899. this.__cache__ = null;
  1900. };
  1901. /**
  1902. * Ruler.enable(list [, ignoreInvalid]) -> Array
  1903. * - list (String|Array): list of rule names to enable.
  1904. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  1905. *
  1906. * Enable rules with given names. If any rule name not found - throw Error.
  1907. * Errors can be disabled by second param.
  1908. *
  1909. * Returns list of found rule names (if no exception happened).
  1910. *
  1911. * See also [[Ruler.disable]], [[Ruler.enableOnly]].
  1912. **/
  1913. Ruler.prototype.enable = function (list, ignoreInvalid) {
  1914. if (!Array.isArray(list)) { list = [ list ]; }
  1915. var result = [];
  1916. // Search by name and enable
  1917. list.forEach(function (name) {
  1918. var idx = this.__find__(name);
  1919. if (idx < 0) {
  1920. if (ignoreInvalid) { return; }
  1921. throw new Error('Rules manager: invalid rule name ' + name);
  1922. }
  1923. this.__rules__[idx].enabled = true;
  1924. result.push(name);
  1925. }, this);
  1926. this.__cache__ = null;
  1927. return result;
  1928. };
  1929. /**
  1930. * Ruler.enableOnly(list [, ignoreInvalid])
  1931. * - list (String|Array): list of rule names to enable (whitelist).
  1932. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  1933. *
  1934. * Enable rules with given names, and disable everything else. If any rule name
  1935. * not found - throw Error. Errors can be disabled by second param.
  1936. *
  1937. * See also [[Ruler.disable]], [[Ruler.enable]].
  1938. **/
  1939. Ruler.prototype.enableOnly = function (list, ignoreInvalid) {
  1940. if (!Array.isArray(list)) { list = [ list ]; }
  1941. this.__rules__.forEach(function (rule) { rule.enabled = false; });
  1942. this.enable(list, ignoreInvalid);
  1943. };
  1944. /**
  1945. * Ruler.disable(list [, ignoreInvalid]) -> Array
  1946. * - list (String|Array): list of rule names to disable.
  1947. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  1948. *
  1949. * Disable rules with given names. If any rule name not found - throw Error.
  1950. * Errors can be disabled by second param.
  1951. *
  1952. * Returns list of found rule names (if no exception happened).
  1953. *
  1954. * See also [[Ruler.enable]], [[Ruler.enableOnly]].
  1955. **/
  1956. Ruler.prototype.disable = function (list, ignoreInvalid) {
  1957. if (!Array.isArray(list)) { list = [ list ]; }
  1958. var result = [];
  1959. // Search by name and disable
  1960. list.forEach(function (name) {
  1961. var idx = this.__find__(name);
  1962. if (idx < 0) {
  1963. if (ignoreInvalid) { return; }
  1964. throw new Error('Rules manager: invalid rule name ' + name);
  1965. }
  1966. this.__rules__[idx].enabled = false;
  1967. result.push(name);
  1968. }, this);
  1969. this.__cache__ = null;
  1970. return result;
  1971. };
  1972. /**
  1973. * Ruler.getRules(chainName) -> Array
  1974. *
  1975. * Return array of active functions (rules) for given chain name. It analyzes
  1976. * rules configuration, compiles caches if not exists and returns result.
  1977. *
  1978. * Default chain name is `''` (empty string). It can't be skipped. That's
  1979. * done intentionally, to keep signature monomorphic for high speed.
  1980. **/
  1981. Ruler.prototype.getRules = function (chainName) {
  1982. if (this.__cache__ === null) {
  1983. this.__compile__();
  1984. }
  1985. // Chain can be empty, if rules disabled. But we still have to return Array.
  1986. return this.__cache__[chainName] || [];
  1987. };
  1988. module.exports = Ruler;
  1989. },{}],18:[function(require,module,exports){
  1990. // Block quotes
  1991. 'use strict';
  1992. var isSpace = require('../common/utils').isSpace;
  1993. module.exports = function blockquote(state, startLine, endLine, silent) {
  1994. var adjustTab,
  1995. ch,
  1996. i,
  1997. initial,
  1998. l,
  1999. lastLineEmpty,
  2000. lines,
  2001. nextLine,
  2002. offset,
  2003. oldBMarks,
  2004. oldBSCount,
  2005. oldIndent,
  2006. oldParentType,
  2007. oldSCount,
  2008. oldTShift,
  2009. spaceAfterMarker,
  2010. terminate,
  2011. terminatorRules,
  2012. token,
  2013. wasOutdented,
  2014. oldLineMax = state.lineMax,
  2015. pos = state.bMarks[startLine] + state.tShift[startLine],
  2016. max = state.eMarks[startLine];
  2017. // if it's indented more than 3 spaces, it should be a code block
  2018. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2019. // check the block quote marker
  2020. if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; }
  2021. // we know that it's going to be a valid blockquote,
  2022. // so no point trying to find the end of it in silent mode
  2023. if (silent) { return true; }
  2024. // skip spaces after ">" and re-calculate offset
  2025. initial = offset = state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]);
  2026. // skip one optional space after '>'
  2027. if (state.src.charCodeAt(pos) === 0x20 /* space */) {
  2028. // ' > test '
  2029. // ^ -- position start of line here:
  2030. pos++;
  2031. initial++;
  2032. offset++;
  2033. adjustTab = false;
  2034. spaceAfterMarker = true;
  2035. } else if (state.src.charCodeAt(pos) === 0x09 /* tab */) {
  2036. spaceAfterMarker = true;
  2037. if ((state.bsCount[startLine] + offset) % 4 === 3) {
  2038. // ' >\t test '
  2039. // ^ -- position start of line here (tab has width===1)
  2040. pos++;
  2041. initial++;
  2042. offset++;
  2043. adjustTab = false;
  2044. } else {
  2045. // ' >\t test '
  2046. // ^ -- position start of line here + shift bsCount slightly
  2047. // to make extra space appear
  2048. adjustTab = true;
  2049. }
  2050. } else {
  2051. spaceAfterMarker = false;
  2052. }
  2053. oldBMarks = [ state.bMarks[startLine] ];
  2054. state.bMarks[startLine] = pos;
  2055. while (pos < max) {
  2056. ch = state.src.charCodeAt(pos);
  2057. if (isSpace(ch)) {
  2058. if (ch === 0x09) {
  2059. offset += 4 - (offset + state.bsCount[startLine] + (adjustTab ? 1 : 0)) % 4;
  2060. } else {
  2061. offset++;
  2062. }
  2063. } else {
  2064. break;
  2065. }
  2066. pos++;
  2067. }
  2068. oldBSCount = [ state.bsCount[startLine] ];
  2069. state.bsCount[startLine] = state.sCount[startLine] + 1 + (spaceAfterMarker ? 1 : 0);
  2070. lastLineEmpty = pos >= max;
  2071. oldSCount = [ state.sCount[startLine] ];
  2072. state.sCount[startLine] = offset - initial;
  2073. oldTShift = [ state.tShift[startLine] ];
  2074. state.tShift[startLine] = pos - state.bMarks[startLine];
  2075. terminatorRules = state.md.block.ruler.getRules('blockquote');
  2076. oldParentType = state.parentType;
  2077. state.parentType = 'blockquote';
  2078. wasOutdented = false;
  2079. // Search the end of the block
  2080. //
  2081. // Block ends with either:
  2082. // 1. an empty line outside:
  2083. // ```
  2084. // > test
  2085. //
  2086. // ```
  2087. // 2. an empty line inside:
  2088. // ```
  2089. // >
  2090. // test
  2091. // ```
  2092. // 3. another tag:
  2093. // ```
  2094. // > test
  2095. // - - -
  2096. // ```
  2097. for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
  2098. // check if it's outdented, i.e. it's inside list item and indented
  2099. // less than said list item:
  2100. //
  2101. // ```
  2102. // 1. anything
  2103. // > current blockquote
  2104. // 2. checking this line
  2105. // ```
  2106. if (state.sCount[nextLine] < state.blkIndent) wasOutdented = true;
  2107. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  2108. max = state.eMarks[nextLine];
  2109. if (pos >= max) {
  2110. // Case 1: line is not inside the blockquote, and this line is empty.
  2111. break;
  2112. }
  2113. if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !wasOutdented) {
  2114. // This line is inside the blockquote.
  2115. // skip spaces after ">" and re-calculate offset
  2116. initial = offset = state.sCount[nextLine] + pos - (state.bMarks[nextLine] + state.tShift[nextLine]);
  2117. // skip one optional space after '>'
  2118. if (state.src.charCodeAt(pos) === 0x20 /* space */) {
  2119. // ' > test '
  2120. // ^ -- position start of line here:
  2121. pos++;
  2122. initial++;
  2123. offset++;
  2124. adjustTab = false;
  2125. spaceAfterMarker = true;
  2126. } else if (state.src.charCodeAt(pos) === 0x09 /* tab */) {
  2127. spaceAfterMarker = true;
  2128. if ((state.bsCount[nextLine] + offset) % 4 === 3) {
  2129. // ' >\t test '
  2130. // ^ -- position start of line here (tab has width===1)
  2131. pos++;
  2132. initial++;
  2133. offset++;
  2134. adjustTab = false;
  2135. } else {
  2136. // ' >\t test '
  2137. // ^ -- position start of line here + shift bsCount slightly
  2138. // to make extra space appear
  2139. adjustTab = true;
  2140. }
  2141. } else {
  2142. spaceAfterMarker = false;
  2143. }
  2144. oldBMarks.push(state.bMarks[nextLine]);
  2145. state.bMarks[nextLine] = pos;
  2146. while (pos < max) {
  2147. ch = state.src.charCodeAt(pos);
  2148. if (isSpace(ch)) {
  2149. if (ch === 0x09) {
  2150. offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4;
  2151. } else {
  2152. offset++;
  2153. }
  2154. } else {
  2155. break;
  2156. }
  2157. pos++;
  2158. }
  2159. lastLineEmpty = pos >= max;
  2160. oldBSCount.push(state.bsCount[nextLine]);
  2161. state.bsCount[nextLine] = state.sCount[nextLine] + 1 + (spaceAfterMarker ? 1 : 0);
  2162. oldSCount.push(state.sCount[nextLine]);
  2163. state.sCount[nextLine] = offset - initial;
  2164. oldTShift.push(state.tShift[nextLine]);
  2165. state.tShift[nextLine] = pos - state.bMarks[nextLine];
  2166. continue;
  2167. }
  2168. // Case 2: line is not inside the blockquote, and the last line was empty.
  2169. if (lastLineEmpty) { break; }
  2170. // Case 3: another tag found.
  2171. terminate = false;
  2172. for (i = 0, l = terminatorRules.length; i < l; i++) {
  2173. if (terminatorRules[i](state, nextLine, endLine, true)) {
  2174. terminate = true;
  2175. break;
  2176. }
  2177. }
  2178. if (terminate) {
  2179. // Quirk to enforce "hard termination mode" for paragraphs;
  2180. // normally if you call `tokenize(state, startLine, nextLine)`,
  2181. // paragraphs will look below nextLine for paragraph continuation,
  2182. // but if blockquote is terminated by another tag, they shouldn't
  2183. state.lineMax = nextLine;
  2184. if (state.blkIndent !== 0) {
  2185. // state.blkIndent was non-zero, we now set it to zero,
  2186. // so we need to re-calculate all offsets to appear as
  2187. // if indent wasn't changed
  2188. oldBMarks.push(state.bMarks[nextLine]);
  2189. oldBSCount.push(state.bsCount[nextLine]);
  2190. oldTShift.push(state.tShift[nextLine]);
  2191. oldSCount.push(state.sCount[nextLine]);
  2192. state.sCount[nextLine] -= state.blkIndent;
  2193. }
  2194. break;
  2195. }
  2196. oldBMarks.push(state.bMarks[nextLine]);
  2197. oldBSCount.push(state.bsCount[nextLine]);
  2198. oldTShift.push(state.tShift[nextLine]);
  2199. oldSCount.push(state.sCount[nextLine]);
  2200. // A negative indentation means that this is a paragraph continuation
  2201. //
  2202. state.sCount[nextLine] = -1;
  2203. }
  2204. oldIndent = state.blkIndent;
  2205. state.blkIndent = 0;
  2206. token = state.push('blockquote_open', 'blockquote', 1);
  2207. token.markup = '>';
  2208. token.map = lines = [ startLine, 0 ];
  2209. state.md.block.tokenize(state, startLine, nextLine);
  2210. token = state.push('blockquote_close', 'blockquote', -1);
  2211. token.markup = '>';
  2212. state.lineMax = oldLineMax;
  2213. state.parentType = oldParentType;
  2214. lines[1] = state.line;
  2215. // Restore original tShift; this might not be necessary since the parser
  2216. // has already been here, but just to make sure we can do that.
  2217. for (i = 0; i < oldTShift.length; i++) {
  2218. state.bMarks[i + startLine] = oldBMarks[i];
  2219. state.tShift[i + startLine] = oldTShift[i];
  2220. state.sCount[i + startLine] = oldSCount[i];
  2221. state.bsCount[i + startLine] = oldBSCount[i];
  2222. }
  2223. state.blkIndent = oldIndent;
  2224. return true;
  2225. };
  2226. },{"../common/utils":4}],19:[function(require,module,exports){
  2227. // Code block (4 spaces padded)
  2228. 'use strict';
  2229. module.exports = function code(state, startLine, endLine/*, silent*/) {
  2230. var nextLine, last, token;
  2231. if (state.sCount[startLine] - state.blkIndent < 4) { return false; }
  2232. last = nextLine = startLine + 1;
  2233. while (nextLine < endLine) {
  2234. if (state.isEmpty(nextLine)) {
  2235. nextLine++;
  2236. continue;
  2237. }
  2238. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  2239. nextLine++;
  2240. last = nextLine;
  2241. continue;
  2242. }
  2243. break;
  2244. }
  2245. state.line = last;
  2246. token = state.push('code_block', 'code', 0);
  2247. token.content = state.getLines(startLine, last, 4 + state.blkIndent, true);
  2248. token.map = [ startLine, state.line ];
  2249. return true;
  2250. };
  2251. },{}],20:[function(require,module,exports){
  2252. // fences (``` lang, ~~~ lang)
  2253. 'use strict';
  2254. module.exports = function fence(state, startLine, endLine, silent) {
  2255. var marker, len, params, nextLine, mem, token, markup,
  2256. haveEndMarker = false,
  2257. pos = state.bMarks[startLine] + state.tShift[startLine],
  2258. max = state.eMarks[startLine];
  2259. // if it's indented more than 3 spaces, it should be a code block
  2260. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2261. if (pos + 3 > max) { return false; }
  2262. marker = state.src.charCodeAt(pos);
  2263. if (marker !== 0x7E/* ~ */ && marker !== 0x60 /* ` */) {
  2264. return false;
  2265. }
  2266. // scan marker length
  2267. mem = pos;
  2268. pos = state.skipChars(pos, marker);
  2269. len = pos - mem;
  2270. if (len < 3) { return false; }
  2271. markup = state.src.slice(mem, pos);
  2272. params = state.src.slice(pos, max);
  2273. if (params.indexOf(String.fromCharCode(marker)) >= 0) { return false; }
  2274. // Since start is found, we can report success here in validation mode
  2275. if (silent) { return true; }
  2276. // search end of block
  2277. nextLine = startLine;
  2278. for (;;) {
  2279. nextLine++;
  2280. if (nextLine >= endLine) {
  2281. // unclosed block should be autoclosed by end of document.
  2282. // also block seems to be autoclosed by end of parent
  2283. break;
  2284. }
  2285. pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
  2286. max = state.eMarks[nextLine];
  2287. if (pos < max && state.sCount[nextLine] < state.blkIndent) {
  2288. // non-empty line with negative indent should stop the list:
  2289. // - ```
  2290. // test
  2291. break;
  2292. }
  2293. if (state.src.charCodeAt(pos) !== marker) { continue; }
  2294. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  2295. // closing fence should be indented less than 4 spaces
  2296. continue;
  2297. }
  2298. pos = state.skipChars(pos, marker);
  2299. // closing code fence must be at least as long as the opening one
  2300. if (pos - mem < len) { continue; }
  2301. // make sure tail has spaces only
  2302. pos = state.skipSpaces(pos);
  2303. if (pos < max) { continue; }
  2304. haveEndMarker = true;
  2305. // found!
  2306. break;
  2307. }
  2308. // If a fence has heading spaces, they should be removed from its inner block
  2309. len = state.sCount[startLine];
  2310. state.line = nextLine + (haveEndMarker ? 1 : 0);
  2311. token = state.push('fence', 'code', 0);
  2312. token.info = params;
  2313. token.content = state.getLines(startLine + 1, nextLine, len, true);
  2314. token.markup = markup;
  2315. token.map = [ startLine, state.line ];
  2316. return true;
  2317. };
  2318. },{}],21:[function(require,module,exports){
  2319. // heading (#, ##, ...)
  2320. 'use strict';
  2321. var isSpace = require('../common/utils').isSpace;
  2322. module.exports = function heading(state, startLine, endLine, silent) {
  2323. var ch, level, tmp, token,
  2324. pos = state.bMarks[startLine] + state.tShift[startLine],
  2325. max = state.eMarks[startLine];
  2326. // if it's indented more than 3 spaces, it should be a code block
  2327. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2328. ch = state.src.charCodeAt(pos);
  2329. if (ch !== 0x23/* # */ || pos >= max) { return false; }
  2330. // count heading level
  2331. level = 1;
  2332. ch = state.src.charCodeAt(++pos);
  2333. while (ch === 0x23/* # */ && pos < max && level <= 6) {
  2334. level++;
  2335. ch = state.src.charCodeAt(++pos);
  2336. }
  2337. if (level > 6 || (pos < max && !isSpace(ch))) { return false; }
  2338. if (silent) { return true; }
  2339. // Let's cut tails like ' ### ' from the end of string
  2340. max = state.skipSpacesBack(max, pos);
  2341. tmp = state.skipCharsBack(max, 0x23, pos); // #
  2342. if (tmp > pos && isSpace(state.src.charCodeAt(tmp - 1))) {
  2343. max = tmp;
  2344. }
  2345. state.line = startLine + 1;
  2346. token = state.push('heading_open', 'h' + String(level), 1);
  2347. token.markup = '########'.slice(0, level);
  2348. token.map = [ startLine, state.line ];
  2349. token = state.push('inline', '', 0);
  2350. token.content = state.src.slice(pos, max).trim();
  2351. token.map = [ startLine, state.line ];
  2352. token.children = [];
  2353. token = state.push('heading_close', 'h' + String(level), -1);
  2354. token.markup = '########'.slice(0, level);
  2355. return true;
  2356. };
  2357. },{"../common/utils":4}],22:[function(require,module,exports){
  2358. // Horizontal rule
  2359. 'use strict';
  2360. var isSpace = require('../common/utils').isSpace;
  2361. module.exports = function hr(state, startLine, endLine, silent) {
  2362. var marker, cnt, ch, token,
  2363. pos = state.bMarks[startLine] + state.tShift[startLine],
  2364. max = state.eMarks[startLine];
  2365. // if it's indented more than 3 spaces, it should be a code block
  2366. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2367. marker = state.src.charCodeAt(pos++);
  2368. // Check hr marker
  2369. if (marker !== 0x2A/* * */ &&
  2370. marker !== 0x2D/* - */ &&
  2371. marker !== 0x5F/* _ */) {
  2372. return false;
  2373. }
  2374. // markers can be mixed with spaces, but there should be at least 3 of them
  2375. cnt = 1;
  2376. while (pos < max) {
  2377. ch = state.src.charCodeAt(pos++);
  2378. if (ch !== marker && !isSpace(ch)) { return false; }
  2379. if (ch === marker) { cnt++; }
  2380. }
  2381. if (cnt < 3) { return false; }
  2382. if (silent) { return true; }
  2383. state.line = startLine + 1;
  2384. token = state.push('hr', 'hr', 0);
  2385. token.map = [ startLine, state.line ];
  2386. token.markup = Array(cnt + 1).join(String.fromCharCode(marker));
  2387. return true;
  2388. };
  2389. },{"../common/utils":4}],23:[function(require,module,exports){
  2390. // HTML block
  2391. 'use strict';
  2392. var block_names = require('../common/html_blocks');
  2393. var HTML_OPEN_CLOSE_TAG_RE = require('../common/html_re').HTML_OPEN_CLOSE_TAG_RE;
  2394. // An array of opening and corresponding closing sequences for html tags,
  2395. // last argument defines whether it can terminate a paragraph or not
  2396. //
  2397. var HTML_SEQUENCES = [
  2398. [ /^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true ],
  2399. [ /^<!--/, /-->/, true ],
  2400. [ /^<\?/, /\?>/, true ],
  2401. [ /^<![A-Z]/, />/, true ],
  2402. [ /^<!\[CDATA\[/, /\]\]>/, true ],
  2403. [ new RegExp('^</?(' + block_names.join('|') + ')(?=(\\s|/?>|$))', 'i'), /^$/, true ],
  2404. [ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false ]
  2405. ];
  2406. module.exports = function html_block(state, startLine, endLine, silent) {
  2407. var i, nextLine, token, lineText,
  2408. pos = state.bMarks[startLine] + state.tShift[startLine],
  2409. max = state.eMarks[startLine];
  2410. // if it's indented more than 3 spaces, it should be a code block
  2411. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2412. if (!state.md.options.html) { return false; }
  2413. if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
  2414. lineText = state.src.slice(pos, max);
  2415. for (i = 0; i < HTML_SEQUENCES.length; i++) {
  2416. if (HTML_SEQUENCES[i][0].test(lineText)) { break; }
  2417. }
  2418. if (i === HTML_SEQUENCES.length) { return false; }
  2419. if (silent) {
  2420. // true if this sequence can be a terminator, false otherwise
  2421. return HTML_SEQUENCES[i][2];
  2422. }
  2423. nextLine = startLine + 1;
  2424. // If we are here - we detected HTML block.
  2425. // Let's roll down till block end.
  2426. if (!HTML_SEQUENCES[i][1].test(lineText)) {
  2427. for (; nextLine < endLine; nextLine++) {
  2428. if (state.sCount[nextLine] < state.blkIndent) { break; }
  2429. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  2430. max = state.eMarks[nextLine];
  2431. lineText = state.src.slice(pos, max);
  2432. if (HTML_SEQUENCES[i][1].test(lineText)) {
  2433. if (lineText.length !== 0) { nextLine++; }
  2434. break;
  2435. }
  2436. }
  2437. }
  2438. state.line = nextLine;
  2439. token = state.push('html_block', '', 0);
  2440. token.map = [ startLine, nextLine ];
  2441. token.content = state.getLines(startLine, nextLine, state.blkIndent, true);
  2442. return true;
  2443. };
  2444. },{"../common/html_blocks":2,"../common/html_re":3}],24:[function(require,module,exports){
  2445. // lheading (---, ===)
  2446. 'use strict';
  2447. module.exports = function lheading(state, startLine, endLine/*, silent*/) {
  2448. var content, terminate, i, l, token, pos, max, level, marker,
  2449. nextLine = startLine + 1, oldParentType,
  2450. terminatorRules = state.md.block.ruler.getRules('paragraph');
  2451. // if it's indented more than 3 spaces, it should be a code block
  2452. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2453. oldParentType = state.parentType;
  2454. state.parentType = 'paragraph'; // use paragraph to match terminatorRules
  2455. // jump line-by-line until empty one or EOF
  2456. for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
  2457. // this would be a code block normally, but after paragraph
  2458. // it's considered a lazy continuation regardless of what's there
  2459. if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
  2460. //
  2461. // Check for underline in setext header
  2462. //
  2463. if (state.sCount[nextLine] >= state.blkIndent) {
  2464. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  2465. max = state.eMarks[nextLine];
  2466. if (pos < max) {
  2467. marker = state.src.charCodeAt(pos);
  2468. if (marker === 0x2D/* - */ || marker === 0x3D/* = */) {
  2469. pos = state.skipChars(pos, marker);
  2470. pos = state.skipSpaces(pos);
  2471. if (pos >= max) {
  2472. level = (marker === 0x3D/* = */ ? 1 : 2);
  2473. break;
  2474. }
  2475. }
  2476. }
  2477. }
  2478. // quirk for blockquotes, this line should already be checked by that rule
  2479. if (state.sCount[nextLine] < 0) { continue; }
  2480. // Some tags can terminate paragraph without empty line.
  2481. terminate = false;
  2482. for (i = 0, l = terminatorRules.length; i < l; i++) {
  2483. if (terminatorRules[i](state, nextLine, endLine, true)) {
  2484. terminate = true;
  2485. break;
  2486. }
  2487. }
  2488. if (terminate) { break; }
  2489. }
  2490. if (!level) {
  2491. // Didn't find valid underline
  2492. return false;
  2493. }
  2494. content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
  2495. state.line = nextLine + 1;
  2496. token = state.push('heading_open', 'h' + String(level), 1);
  2497. token.markup = String.fromCharCode(marker);
  2498. token.map = [ startLine, state.line ];
  2499. token = state.push('inline', '', 0);
  2500. token.content = content;
  2501. token.map = [ startLine, state.line - 1 ];
  2502. token.children = [];
  2503. token = state.push('heading_close', 'h' + String(level), -1);
  2504. token.markup = String.fromCharCode(marker);
  2505. state.parentType = oldParentType;
  2506. return true;
  2507. };
  2508. },{}],25:[function(require,module,exports){
  2509. // Lists
  2510. 'use strict';
  2511. var isSpace = require('../common/utils').isSpace;
  2512. // Search `[-+*][\n ]`, returns next pos after marker on success
  2513. // or -1 on fail.
  2514. function skipBulletListMarker(state, startLine) {
  2515. var marker, pos, max, ch;
  2516. pos = state.bMarks[startLine] + state.tShift[startLine];
  2517. max = state.eMarks[startLine];
  2518. marker = state.src.charCodeAt(pos++);
  2519. // Check bullet
  2520. if (marker !== 0x2A/* * */ &&
  2521. marker !== 0x2D/* - */ &&
  2522. marker !== 0x2B/* + */) {
  2523. return -1;
  2524. }
  2525. if (pos < max) {
  2526. ch = state.src.charCodeAt(pos);
  2527. if (!isSpace(ch)) {
  2528. // " -test " - is not a list item
  2529. return -1;
  2530. }
  2531. }
  2532. return pos;
  2533. }
  2534. // Search `\d+[.)][\n ]`, returns next pos after marker on success
  2535. // or -1 on fail.
  2536. function skipOrderedListMarker(state, startLine) {
  2537. var ch,
  2538. start = state.bMarks[startLine] + state.tShift[startLine],
  2539. pos = start,
  2540. max = state.eMarks[startLine];
  2541. // List marker should have at least 2 chars (digit + dot)
  2542. if (pos + 1 >= max) { return -1; }
  2543. ch = state.src.charCodeAt(pos++);
  2544. if (ch < 0x30/* 0 */ || ch > 0x39/* 9 */) { return -1; }
  2545. for (;;) {
  2546. // EOL -> fail
  2547. if (pos >= max) { return -1; }
  2548. ch = state.src.charCodeAt(pos++);
  2549. if (ch >= 0x30/* 0 */ && ch <= 0x39/* 9 */) {
  2550. // List marker should have no more than 9 digits
  2551. // (prevents integer overflow in browsers)
  2552. if (pos - start >= 10) { return -1; }
  2553. continue;
  2554. }
  2555. // found valid marker
  2556. if (ch === 0x29/* ) */ || ch === 0x2e/* . */) {
  2557. break;
  2558. }
  2559. return -1;
  2560. }
  2561. if (pos < max) {
  2562. ch = state.src.charCodeAt(pos);
  2563. if (!isSpace(ch)) {
  2564. // " 1.test " - is not a list item
  2565. return -1;
  2566. }
  2567. }
  2568. return pos;
  2569. }
  2570. function markTightParagraphs(state, idx) {
  2571. var i, l,
  2572. level = state.level + 2;
  2573. for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
  2574. if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') {
  2575. state.tokens[i + 2].hidden = true;
  2576. state.tokens[i].hidden = true;
  2577. i += 2;
  2578. }
  2579. }
  2580. }
  2581. module.exports = function list(state, startLine, endLine, silent) {
  2582. var ch,
  2583. contentStart,
  2584. i,
  2585. indent,
  2586. indentAfterMarker,
  2587. initial,
  2588. isOrdered,
  2589. itemLines,
  2590. l,
  2591. listLines,
  2592. listTokIdx,
  2593. markerCharCode,
  2594. markerValue,
  2595. max,
  2596. nextLine,
  2597. offset,
  2598. oldIndent,
  2599. oldLIndent,
  2600. oldParentType,
  2601. oldTShift,
  2602. oldTight,
  2603. pos,
  2604. posAfterMarker,
  2605. prevEmptyEnd,
  2606. start,
  2607. terminate,
  2608. terminatorRules,
  2609. token,
  2610. isTerminatingParagraph = false,
  2611. tight = true;
  2612. // if it's indented more than 3 spaces, it should be a code block
  2613. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2614. // limit conditions when list can interrupt
  2615. // a paragraph (validation mode only)
  2616. if (silent && state.parentType === 'paragraph') {
  2617. // Next list item should still terminate previous list item;
  2618. //
  2619. // This code can fail if plugins use blkIndent as well as lists,
  2620. // but I hope the spec gets fixed long before that happens.
  2621. //
  2622. if (state.tShift[startLine] >= state.blkIndent) {
  2623. isTerminatingParagraph = true;
  2624. }
  2625. }
  2626. // Detect list type and position after marker
  2627. if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {
  2628. isOrdered = true;
  2629. start = state.bMarks[startLine] + state.tShift[startLine];
  2630. markerValue = Number(state.src.substr(start, posAfterMarker - start - 1));
  2631. // If we're starting a new ordered list right after
  2632. // a paragraph, it should start with 1.
  2633. if (isTerminatingParagraph && markerValue !== 1) return false;
  2634. } else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {
  2635. isOrdered = false;
  2636. } else {
  2637. return false;
  2638. }
  2639. // If we're starting a new unordered list right after
  2640. // a paragraph, first line should not be empty.
  2641. if (isTerminatingParagraph) {
  2642. if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine]) return false;
  2643. }
  2644. // We should terminate list on style change. Remember first one to compare.
  2645. markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
  2646. // For validation mode we can terminate immediately
  2647. if (silent) { return true; }
  2648. // Start list
  2649. listTokIdx = state.tokens.length;
  2650. if (isOrdered) {
  2651. token = state.push('ordered_list_open', 'ol', 1);
  2652. if (markerValue !== 1) {
  2653. token.attrs = [ [ 'start', markerValue ] ];
  2654. }
  2655. } else {
  2656. token = state.push('bullet_list_open', 'ul', 1);
  2657. }
  2658. token.map = listLines = [ startLine, 0 ];
  2659. token.markup = String.fromCharCode(markerCharCode);
  2660. //
  2661. // Iterate list items
  2662. //
  2663. nextLine = startLine;
  2664. prevEmptyEnd = false;
  2665. terminatorRules = state.md.block.ruler.getRules('list');
  2666. oldParentType = state.parentType;
  2667. state.parentType = 'list';
  2668. while (nextLine < endLine) {
  2669. pos = posAfterMarker;
  2670. max = state.eMarks[nextLine];
  2671. initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[startLine] + state.tShift[startLine]);
  2672. while (pos < max) {
  2673. ch = state.src.charCodeAt(pos);
  2674. if (ch === 0x09) {
  2675. offset += 4 - (offset + state.bsCount[nextLine]) % 4;
  2676. } else if (ch === 0x20) {
  2677. offset++;
  2678. } else {
  2679. break;
  2680. }
  2681. pos++;
  2682. }
  2683. contentStart = pos;
  2684. if (contentStart >= max) {
  2685. // trimming space in "- \n 3" case, indent is 1 here
  2686. indentAfterMarker = 1;
  2687. } else {
  2688. indentAfterMarker = offset - initial;
  2689. }
  2690. // If we have more than 4 spaces, the indent is 1
  2691. // (the rest is just indented code block)
  2692. if (indentAfterMarker > 4) { indentAfterMarker = 1; }
  2693. // " - test"
  2694. // ^^^^^ - calculating total length of this thing
  2695. indent = initial + indentAfterMarker;
  2696. // Run subparser & write tokens
  2697. token = state.push('list_item_open', 'li', 1);
  2698. token.markup = String.fromCharCode(markerCharCode);
  2699. token.map = itemLines = [ startLine, 0 ];
  2700. oldIndent = state.blkIndent;
  2701. oldTight = state.tight;
  2702. oldTShift = state.tShift[startLine];
  2703. oldLIndent = state.sCount[startLine];
  2704. state.blkIndent = indent;
  2705. state.tight = true;
  2706. state.tShift[startLine] = contentStart - state.bMarks[startLine];
  2707. state.sCount[startLine] = offset;
  2708. if (contentStart >= max && state.isEmpty(startLine + 1)) {
  2709. // workaround for this case
  2710. // (list item is empty, list terminates before "foo"):
  2711. // ~~~~~~~~
  2712. // -
  2713. //
  2714. // foo
  2715. // ~~~~~~~~
  2716. state.line = Math.min(state.line + 2, endLine);
  2717. } else {
  2718. state.md.block.tokenize(state, startLine, endLine, true);
  2719. }
  2720. // If any of list item is tight, mark list as tight
  2721. if (!state.tight || prevEmptyEnd) {
  2722. tight = false;
  2723. }
  2724. // Item become loose if finish with empty line,
  2725. // but we should filter last element, because it means list finish
  2726. prevEmptyEnd = (state.line - startLine) > 1 && state.isEmpty(state.line - 1);
  2727. state.blkIndent = oldIndent;
  2728. state.tShift[startLine] = oldTShift;
  2729. state.sCount[startLine] = oldLIndent;
  2730. state.tight = oldTight;
  2731. token = state.push('list_item_close', 'li', -1);
  2732. token.markup = String.fromCharCode(markerCharCode);
  2733. nextLine = startLine = state.line;
  2734. itemLines[1] = nextLine;
  2735. contentStart = state.bMarks[startLine];
  2736. if (nextLine >= endLine) { break; }
  2737. //
  2738. // Try to check if list is terminated or continued.
  2739. //
  2740. if (state.sCount[nextLine] < state.blkIndent) { break; }
  2741. // fail if terminating block found
  2742. terminate = false;
  2743. for (i = 0, l = terminatorRules.length; i < l; i++) {
  2744. if (terminatorRules[i](state, nextLine, endLine, true)) {
  2745. terminate = true;
  2746. break;
  2747. }
  2748. }
  2749. if (terminate) { break; }
  2750. // fail if list has another type
  2751. if (isOrdered) {
  2752. posAfterMarker = skipOrderedListMarker(state, nextLine);
  2753. if (posAfterMarker < 0) { break; }
  2754. } else {
  2755. posAfterMarker = skipBulletListMarker(state, nextLine);
  2756. if (posAfterMarker < 0) { break; }
  2757. }
  2758. if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; }
  2759. }
  2760. // Finalize list
  2761. if (isOrdered) {
  2762. token = state.push('ordered_list_close', 'ol', -1);
  2763. } else {
  2764. token = state.push('bullet_list_close', 'ul', -1);
  2765. }
  2766. token.markup = String.fromCharCode(markerCharCode);
  2767. listLines[1] = nextLine;
  2768. state.line = nextLine;
  2769. state.parentType = oldParentType;
  2770. // mark paragraphs tight if needed
  2771. if (tight) {
  2772. markTightParagraphs(state, listTokIdx);
  2773. }
  2774. return true;
  2775. };
  2776. },{"../common/utils":4}],26:[function(require,module,exports){
  2777. // Paragraph
  2778. 'use strict';
  2779. module.exports = function paragraph(state, startLine/*, endLine*/) {
  2780. var content, terminate, i, l, token, oldParentType,
  2781. nextLine = startLine + 1,
  2782. terminatorRules = state.md.block.ruler.getRules('paragraph'),
  2783. endLine = state.lineMax;
  2784. oldParentType = state.parentType;
  2785. state.parentType = 'paragraph';
  2786. // jump line-by-line until empty one or EOF
  2787. for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
  2788. // this would be a code block normally, but after paragraph
  2789. // it's considered a lazy continuation regardless of what's there
  2790. if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
  2791. // quirk for blockquotes, this line should already be checked by that rule
  2792. if (state.sCount[nextLine] < 0) { continue; }
  2793. // Some tags can terminate paragraph without empty line.
  2794. terminate = false;
  2795. for (i = 0, l = terminatorRules.length; i < l; i++) {
  2796. if (terminatorRules[i](state, nextLine, endLine, true)) {
  2797. terminate = true;
  2798. break;
  2799. }
  2800. }
  2801. if (terminate) { break; }
  2802. }
  2803. content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
  2804. state.line = nextLine;
  2805. token = state.push('paragraph_open', 'p', 1);
  2806. token.map = [ startLine, state.line ];
  2807. token = state.push('inline', '', 0);
  2808. token.content = content;
  2809. token.map = [ startLine, state.line ];
  2810. token.children = [];
  2811. token = state.push('paragraph_close', 'p', -1);
  2812. state.parentType = oldParentType;
  2813. return true;
  2814. };
  2815. },{}],27:[function(require,module,exports){
  2816. 'use strict';
  2817. var normalizeReference = require('../common/utils').normalizeReference;
  2818. var isSpace = require('../common/utils').isSpace;
  2819. module.exports = function reference(state, startLine, _endLine, silent) {
  2820. var ch,
  2821. destEndPos,
  2822. destEndLineNo,
  2823. endLine,
  2824. href,
  2825. i,
  2826. l,
  2827. label,
  2828. labelEnd,
  2829. oldParentType,
  2830. res,
  2831. start,
  2832. str,
  2833. terminate,
  2834. terminatorRules,
  2835. title,
  2836. lines = 0,
  2837. pos = state.bMarks[startLine] + state.tShift[startLine],
  2838. max = state.eMarks[startLine],
  2839. nextLine = startLine + 1;
  2840. // if it's indented more than 3 spaces, it should be a code block
  2841. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2842. if (state.src.charCodeAt(pos) !== 0x5B/* [ */) { return false; }
  2843. // Simple check to quickly interrupt scan on [link](url) at the start of line.
  2844. // Can be useful on practice: https://github.com/markdown-it/markdown-it/issues/54
  2845. while (++pos < max) {
  2846. if (state.src.charCodeAt(pos) === 0x5D /* ] */ &&
  2847. state.src.charCodeAt(pos - 1) !== 0x5C/* \ */) {
  2848. if (pos + 1 === max) { return false; }
  2849. if (state.src.charCodeAt(pos + 1) !== 0x3A/* : */) { return false; }
  2850. break;
  2851. }
  2852. }
  2853. endLine = state.lineMax;
  2854. // jump line-by-line until empty one or EOF
  2855. terminatorRules = state.md.block.ruler.getRules('reference');
  2856. oldParentType = state.parentType;
  2857. state.parentType = 'reference';
  2858. for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
  2859. // this would be a code block normally, but after paragraph
  2860. // it's considered a lazy continuation regardless of what's there
  2861. if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
  2862. // quirk for blockquotes, this line should already be checked by that rule
  2863. if (state.sCount[nextLine] < 0) { continue; }
  2864. // Some tags can terminate paragraph without empty line.
  2865. terminate = false;
  2866. for (i = 0, l = terminatorRules.length; i < l; i++) {
  2867. if (terminatorRules[i](state, nextLine, endLine, true)) {
  2868. terminate = true;
  2869. break;
  2870. }
  2871. }
  2872. if (terminate) { break; }
  2873. }
  2874. str = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
  2875. max = str.length;
  2876. for (pos = 1; pos < max; pos++) {
  2877. ch = str.charCodeAt(pos);
  2878. if (ch === 0x5B /* [ */) {
  2879. return false;
  2880. } else if (ch === 0x5D /* ] */) {
  2881. labelEnd = pos;
  2882. break;
  2883. } else if (ch === 0x0A /* \n */) {
  2884. lines++;
  2885. } else if (ch === 0x5C /* \ */) {
  2886. pos++;
  2887. if (pos < max && str.charCodeAt(pos) === 0x0A) {
  2888. lines++;
  2889. }
  2890. }
  2891. }
  2892. if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return false; }
  2893. // [label]: destination 'title'
  2894. // ^^^ skip optional whitespace here
  2895. for (pos = labelEnd + 2; pos < max; pos++) {
  2896. ch = str.charCodeAt(pos);
  2897. if (ch === 0x0A) {
  2898. lines++;
  2899. } else if (isSpace(ch)) {
  2900. /*eslint no-empty:0*/
  2901. } else {
  2902. break;
  2903. }
  2904. }
  2905. // [label]: destination 'title'
  2906. // ^^^^^^^^^^^ parse this
  2907. res = state.md.helpers.parseLinkDestination(str, pos, max);
  2908. if (!res.ok) { return false; }
  2909. href = state.md.normalizeLink(res.str);
  2910. if (!state.md.validateLink(href)) { return false; }
  2911. pos = res.pos;
  2912. lines += res.lines;
  2913. // save cursor state, we could require to rollback later
  2914. destEndPos = pos;
  2915. destEndLineNo = lines;
  2916. // [label]: destination 'title'
  2917. // ^^^ skipping those spaces
  2918. start = pos;
  2919. for (; pos < max; pos++) {
  2920. ch = str.charCodeAt(pos);
  2921. if (ch === 0x0A) {
  2922. lines++;
  2923. } else if (isSpace(ch)) {
  2924. /*eslint no-empty:0*/
  2925. } else {
  2926. break;
  2927. }
  2928. }
  2929. // [label]: destination 'title'
  2930. // ^^^^^^^ parse this
  2931. res = state.md.helpers.parseLinkTitle(str, pos, max);
  2932. if (pos < max && start !== pos && res.ok) {
  2933. title = res.str;
  2934. pos = res.pos;
  2935. lines += res.lines;
  2936. } else {
  2937. title = '';
  2938. pos = destEndPos;
  2939. lines = destEndLineNo;
  2940. }
  2941. // skip trailing spaces until the rest of the line
  2942. while (pos < max) {
  2943. ch = str.charCodeAt(pos);
  2944. if (!isSpace(ch)) { break; }
  2945. pos++;
  2946. }
  2947. if (pos < max && str.charCodeAt(pos) !== 0x0A) {
  2948. if (title) {
  2949. // garbage at the end of the line after title,
  2950. // but it could still be a valid reference if we roll back
  2951. title = '';
  2952. pos = destEndPos;
  2953. lines = destEndLineNo;
  2954. while (pos < max) {
  2955. ch = str.charCodeAt(pos);
  2956. if (!isSpace(ch)) { break; }
  2957. pos++;
  2958. }
  2959. }
  2960. }
  2961. if (pos < max && str.charCodeAt(pos) !== 0x0A) {
  2962. // garbage at the end of the line
  2963. return false;
  2964. }
  2965. label = normalizeReference(str.slice(1, labelEnd));
  2966. if (!label) {
  2967. // CommonMark 0.20 disallows empty labels
  2968. return false;
  2969. }
  2970. // Reference can not terminate anything. This check is for safety only.
  2971. /*istanbul ignore if*/
  2972. if (silent) { return true; }
  2973. if (typeof state.env.references === 'undefined') {
  2974. state.env.references = {};
  2975. }
  2976. if (typeof state.env.references[label] === 'undefined') {
  2977. state.env.references[label] = { title: title, href: href };
  2978. }
  2979. state.parentType = oldParentType;
  2980. state.line = startLine + lines + 1;
  2981. return true;
  2982. };
  2983. },{"../common/utils":4}],28:[function(require,module,exports){
  2984. // Parser state class
  2985. 'use strict';
  2986. var Token = require('../token');
  2987. var isSpace = require('../common/utils').isSpace;
  2988. function StateBlock(src, md, env, tokens) {
  2989. var ch, s, start, pos, len, indent, offset, indent_found;
  2990. this.src = src;
  2991. // link to parser instance
  2992. this.md = md;
  2993. this.env = env;
  2994. //
  2995. // Internal state vartiables
  2996. //
  2997. this.tokens = tokens;
  2998. this.bMarks = []; // line begin offsets for fast jumps
  2999. this.eMarks = []; // line end offsets for fast jumps
  3000. this.tShift = []; // offsets of the first non-space characters (tabs not expanded)
  3001. this.sCount = []; // indents for each line (tabs expanded)
  3002. // An amount of virtual spaces (tabs expanded) between beginning
  3003. // of each line (bMarks) and real beginning of that line.
  3004. //
  3005. // It exists only as a hack because blockquotes override bMarks
  3006. // losing information in the process.
  3007. //
  3008. // It's used only when expanding tabs, you can think about it as
  3009. // an initial tab length, e.g. bsCount=21 applied to string `\t123`
  3010. // means first tab should be expanded to 4-21%4 === 3 spaces.
  3011. //
  3012. this.bsCount = [];
  3013. // block parser variables
  3014. this.blkIndent = 0; // required block content indent
  3015. // (for example, if we are in list)
  3016. this.line = 0; // line index in src
  3017. this.lineMax = 0; // lines count
  3018. this.tight = false; // loose/tight mode for lists
  3019. this.ddIndent = -1; // indent of the current dd block (-1 if there isn't any)
  3020. // can be 'blockquote', 'list', 'root', 'paragraph' or 'reference'
  3021. // used in lists to determine if they interrupt a paragraph
  3022. this.parentType = 'root';
  3023. this.level = 0;
  3024. // renderer
  3025. this.result = '';
  3026. // Create caches
  3027. // Generate markers.
  3028. s = this.src;
  3029. indent_found = false;
  3030. for (start = pos = indent = offset = 0, len = s.length; pos < len; pos++) {
  3031. ch = s.charCodeAt(pos);
  3032. if (!indent_found) {
  3033. if (isSpace(ch)) {
  3034. indent++;
  3035. if (ch === 0x09) {
  3036. offset += 4 - offset % 4;
  3037. } else {
  3038. offset++;
  3039. }
  3040. continue;
  3041. } else {
  3042. indent_found = true;
  3043. }
  3044. }
  3045. if (ch === 0x0A || pos === len - 1) {
  3046. if (ch !== 0x0A) { pos++; }
  3047. this.bMarks.push(start);
  3048. this.eMarks.push(pos);
  3049. this.tShift.push(indent);
  3050. this.sCount.push(offset);
  3051. this.bsCount.push(0);
  3052. indent_found = false;
  3053. indent = 0;
  3054. offset = 0;
  3055. start = pos + 1;
  3056. }
  3057. }
  3058. // Push fake entry to simplify cache bounds checks
  3059. this.bMarks.push(s.length);
  3060. this.eMarks.push(s.length);
  3061. this.tShift.push(0);
  3062. this.sCount.push(0);
  3063. this.bsCount.push(0);
  3064. this.lineMax = this.bMarks.length - 1; // don't count last fake line
  3065. }
  3066. // Push new token to "stream".
  3067. //
  3068. StateBlock.prototype.push = function (type, tag, nesting) {
  3069. var token = new Token(type, tag, nesting);
  3070. token.block = true;
  3071. if (nesting < 0) { this.level--; }
  3072. token.level = this.level;
  3073. if (nesting > 0) { this.level++; }
  3074. this.tokens.push(token);
  3075. return token;
  3076. };
  3077. StateBlock.prototype.isEmpty = function isEmpty(line) {
  3078. return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];
  3079. };
  3080. StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {
  3081. for (var max = this.lineMax; from < max; from++) {
  3082. if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) {
  3083. break;
  3084. }
  3085. }
  3086. return from;
  3087. };
  3088. // Skip spaces from given position.
  3089. StateBlock.prototype.skipSpaces = function skipSpaces(pos) {
  3090. var ch;
  3091. for (var max = this.src.length; pos < max; pos++) {
  3092. ch = this.src.charCodeAt(pos);
  3093. if (!isSpace(ch)) { break; }
  3094. }
  3095. return pos;
  3096. };
  3097. // Skip spaces from given position in reverse.
  3098. StateBlock.prototype.skipSpacesBack = function skipSpacesBack(pos, min) {
  3099. if (pos <= min) { return pos; }
  3100. while (pos > min) {
  3101. if (!isSpace(this.src.charCodeAt(--pos))) { return pos + 1; }
  3102. }
  3103. return pos;
  3104. };
  3105. // Skip char codes from given position
  3106. StateBlock.prototype.skipChars = function skipChars(pos, code) {
  3107. for (var max = this.src.length; pos < max; pos++) {
  3108. if (this.src.charCodeAt(pos) !== code) { break; }
  3109. }
  3110. return pos;
  3111. };
  3112. // Skip char codes reverse from given position - 1
  3113. StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {
  3114. if (pos <= min) { return pos; }
  3115. while (pos > min) {
  3116. if (code !== this.src.charCodeAt(--pos)) { return pos + 1; }
  3117. }
  3118. return pos;
  3119. };
  3120. // cut lines range from source.
  3121. StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {
  3122. var i, lineIndent, ch, first, last, queue, lineStart,
  3123. line = begin;
  3124. if (begin >= end) {
  3125. return '';
  3126. }
  3127. queue = new Array(end - begin);
  3128. for (i = 0; line < end; line++, i++) {
  3129. lineIndent = 0;
  3130. lineStart = first = this.bMarks[line];
  3131. if (line + 1 < end || keepLastLF) {
  3132. // No need for bounds check because we have fake entry on tail.
  3133. last = this.eMarks[line] + 1;
  3134. } else {
  3135. last = this.eMarks[line];
  3136. }
  3137. while (first < last && lineIndent < indent) {
  3138. ch = this.src.charCodeAt(first);
  3139. if (isSpace(ch)) {
  3140. if (ch === 0x09) {
  3141. lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4;
  3142. } else {
  3143. lineIndent++;
  3144. }
  3145. } else if (first - lineStart < this.tShift[line]) {
  3146. // patched tShift masked characters to look like spaces (blockquotes, list markers)
  3147. lineIndent++;
  3148. } else {
  3149. break;
  3150. }
  3151. first++;
  3152. }
  3153. if (lineIndent > indent) {
  3154. // partially expanding tabs in code blocks, e.g '\t\tfoobar'
  3155. // with indent=2 becomes ' \tfoobar'
  3156. queue[i] = new Array(lineIndent - indent + 1).join(' ') + this.src.slice(first, last);
  3157. } else {
  3158. queue[i] = this.src.slice(first, last);
  3159. }
  3160. }
  3161. return queue.join('');
  3162. };
  3163. // re-export Token class to use in block rules
  3164. StateBlock.prototype.Token = Token;
  3165. module.exports = StateBlock;
  3166. },{"../common/utils":4,"../token":51}],29:[function(require,module,exports){
  3167. // GFM table, non-standard
  3168. 'use strict';
  3169. var isSpace = require('../common/utils').isSpace;
  3170. function getLine(state, line) {
  3171. var pos = state.bMarks[line] + state.blkIndent,
  3172. max = state.eMarks[line];
  3173. return state.src.substr(pos, max - pos);
  3174. }
  3175. function escapedSplit(str) {
  3176. var result = [],
  3177. pos = 0,
  3178. max = str.length,
  3179. ch,
  3180. escapes = 0,
  3181. lastPos = 0,
  3182. backTicked = false,
  3183. lastBackTick = 0;
  3184. ch = str.charCodeAt(pos);
  3185. while (pos < max) {
  3186. if (ch === 0x60/* ` */) {
  3187. if (backTicked) {
  3188. // make \` close code sequence, but not open it;
  3189. // the reason is: `\` is correct code block
  3190. backTicked = false;
  3191. lastBackTick = pos;
  3192. } else if (escapes % 2 === 0) {
  3193. backTicked = true;
  3194. lastBackTick = pos;
  3195. }
  3196. } else if (ch === 0x7c/* | */ && (escapes % 2 === 0) && !backTicked) {
  3197. result.push(str.substring(lastPos, pos));
  3198. lastPos = pos + 1;
  3199. }
  3200. if (ch === 0x5c/* \ */) {
  3201. escapes++;
  3202. } else {
  3203. escapes = 0;
  3204. }
  3205. pos++;
  3206. // If there was an un-closed backtick, go back to just after
  3207. // the last backtick, but as if it was a normal character
  3208. if (pos === max && backTicked) {
  3209. backTicked = false;
  3210. pos = lastBackTick + 1;
  3211. }
  3212. ch = str.charCodeAt(pos);
  3213. }
  3214. result.push(str.substring(lastPos));
  3215. return result;
  3216. }
  3217. module.exports = function table(state, startLine, endLine, silent) {
  3218. var ch, lineText, pos, i, nextLine, columns, columnCount, token,
  3219. aligns, t, tableLines, tbodyLines;
  3220. // should have at least two lines
  3221. if (startLine + 2 > endLine) { return false; }
  3222. nextLine = startLine + 1;
  3223. if (state.sCount[nextLine] < state.blkIndent) { return false; }
  3224. // if it's indented more than 3 spaces, it should be a code block
  3225. if (state.sCount[nextLine] - state.blkIndent >= 4) { return false; }
  3226. // first character of the second line should be '|', '-', ':',
  3227. // and no other characters are allowed but spaces;
  3228. // basically, this is the equivalent of /^[-:|][-:|\s]*$/ regexp
  3229. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  3230. if (pos >= state.eMarks[nextLine]) { return false; }
  3231. ch = state.src.charCodeAt(pos++);
  3232. if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */) { return false; }
  3233. while (pos < state.eMarks[nextLine]) {
  3234. ch = state.src.charCodeAt(pos);
  3235. if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */ && !isSpace(ch)) { return false; }
  3236. pos++;
  3237. }
  3238. lineText = getLine(state, startLine + 1);
  3239. columns = lineText.split('|');
  3240. aligns = [];
  3241. for (i = 0; i < columns.length; i++) {
  3242. t = columns[i].trim();
  3243. if (!t) {
  3244. // allow empty columns before and after table, but not in between columns;
  3245. // e.g. allow ` |---| `, disallow ` ---||--- `
  3246. if (i === 0 || i === columns.length - 1) {
  3247. continue;
  3248. } else {
  3249. return false;
  3250. }
  3251. }
  3252. if (!/^:?-+:?$/.test(t)) { return false; }
  3253. if (t.charCodeAt(t.length - 1) === 0x3A/* : */) {
  3254. aligns.push(t.charCodeAt(0) === 0x3A/* : */ ? 'center' : 'right');
  3255. } else if (t.charCodeAt(0) === 0x3A/* : */) {
  3256. aligns.push('left');
  3257. } else {
  3258. aligns.push('');
  3259. }
  3260. }
  3261. lineText = getLine(state, startLine).trim();
  3262. if (lineText.indexOf('|') === -1) { return false; }
  3263. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  3264. columns = escapedSplit(lineText.replace(/^\||\|$/g, ''));
  3265. // header row will define an amount of columns in the entire table,
  3266. // and align row shouldn't be smaller than that (the rest of the rows can)
  3267. columnCount = columns.length;
  3268. if (columnCount > aligns.length) { return false; }
  3269. if (silent) { return true; }
  3270. token = state.push('table_open', 'table', 1);
  3271. token.map = tableLines = [ startLine, 0 ];
  3272. token = state.push('thead_open', 'thead', 1);
  3273. token.map = [ startLine, startLine + 1 ];
  3274. token = state.push('tr_open', 'tr', 1);
  3275. token.map = [ startLine, startLine + 1 ];
  3276. for (i = 0; i < columns.length; i++) {
  3277. token = state.push('th_open', 'th', 1);
  3278. token.map = [ startLine, startLine + 1 ];
  3279. if (aligns[i]) {
  3280. token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];
  3281. }
  3282. token = state.push('inline', '', 0);
  3283. token.content = columns[i].trim();
  3284. token.map = [ startLine, startLine + 1 ];
  3285. token.children = [];
  3286. token = state.push('th_close', 'th', -1);
  3287. }
  3288. token = state.push('tr_close', 'tr', -1);
  3289. token = state.push('thead_close', 'thead', -1);
  3290. token = state.push('tbody_open', 'tbody', 1);
  3291. token.map = tbodyLines = [ startLine + 2, 0 ];
  3292. for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {
  3293. if (state.sCount[nextLine] < state.blkIndent) { break; }
  3294. lineText = getLine(state, nextLine).trim();
  3295. if (lineText.indexOf('|') === -1) { break; }
  3296. if (state.sCount[nextLine] - state.blkIndent >= 4) { break; }
  3297. columns = escapedSplit(lineText.replace(/^\||\|$/g, ''));
  3298. token = state.push('tr_open', 'tr', 1);
  3299. for (i = 0; i < columnCount; i++) {
  3300. token = state.push('td_open', 'td', 1);
  3301. if (aligns[i]) {
  3302. token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];
  3303. }
  3304. token = state.push('inline', '', 0);
  3305. token.content = columns[i] ? columns[i].trim() : '';
  3306. token.children = [];
  3307. token = state.push('td_close', 'td', -1);
  3308. }
  3309. token = state.push('tr_close', 'tr', -1);
  3310. }
  3311. token = state.push('tbody_close', 'tbody', -1);
  3312. token = state.push('table_close', 'table', -1);
  3313. tableLines[1] = tbodyLines[1] = nextLine;
  3314. state.line = nextLine;
  3315. return true;
  3316. };
  3317. },{"../common/utils":4}],30:[function(require,module,exports){
  3318. 'use strict';
  3319. module.exports = function block(state) {
  3320. var token;
  3321. if (state.inlineMode) {
  3322. token = new state.Token('inline', '', 0);
  3323. token.content = state.src;
  3324. token.map = [ 0, 1 ];
  3325. token.children = [];
  3326. state.tokens.push(token);
  3327. } else {
  3328. state.md.block.parse(state.src, state.md, state.env, state.tokens);
  3329. }
  3330. };
  3331. },{}],31:[function(require,module,exports){
  3332. 'use strict';
  3333. module.exports = function inline(state) {
  3334. var tokens = state.tokens, tok, i, l;
  3335. // Parse inlines
  3336. for (i = 0, l = tokens.length; i < l; i++) {
  3337. tok = tokens[i];
  3338. if (tok.type === 'inline') {
  3339. state.md.inline.parse(tok.content, state.md, state.env, tok.children);
  3340. }
  3341. }
  3342. };
  3343. },{}],32:[function(require,module,exports){
  3344. // Replace link-like texts with link nodes.
  3345. //
  3346. // Currently restricted by `md.validateLink()` to http/https/ftp
  3347. //
  3348. 'use strict';
  3349. var arrayReplaceAt = require('../common/utils').arrayReplaceAt;
  3350. function isLinkOpen(str) {
  3351. return /^<a[>\s]/i.test(str);
  3352. }
  3353. function isLinkClose(str) {
  3354. return /^<\/a\s*>/i.test(str);
  3355. }
  3356. module.exports = function linkify(state) {
  3357. var i, j, l, tokens, token, currentToken, nodes, ln, text, pos, lastPos,
  3358. level, htmlLinkLevel, url, fullUrl, urlText,
  3359. blockTokens = state.tokens,
  3360. links;
  3361. if (!state.md.options.linkify) { return; }
  3362. for (j = 0, l = blockTokens.length; j < l; j++) {
  3363. if (blockTokens[j].type !== 'inline' ||
  3364. !state.md.linkify.pretest(blockTokens[j].content)) {
  3365. continue;
  3366. }
  3367. tokens = blockTokens[j].children;
  3368. htmlLinkLevel = 0;
  3369. // We scan from the end, to keep position when new tags added.
  3370. // Use reversed logic in links start/end match
  3371. for (i = tokens.length - 1; i >= 0; i--) {
  3372. currentToken = tokens[i];
  3373. // Skip content of markdown links
  3374. if (currentToken.type === 'link_close') {
  3375. i--;
  3376. while (tokens[i].level !== currentToken.level && tokens[i].type !== 'link_open') {
  3377. i--;
  3378. }
  3379. continue;
  3380. }
  3381. // Skip content of html tag links
  3382. if (currentToken.type === 'html_inline') {
  3383. if (isLinkOpen(currentToken.content) && htmlLinkLevel > 0) {
  3384. htmlLinkLevel--;
  3385. }
  3386. if (isLinkClose(currentToken.content)) {
  3387. htmlLinkLevel++;
  3388. }
  3389. }
  3390. if (htmlLinkLevel > 0) { continue; }
  3391. if (currentToken.type === 'text' && state.md.linkify.test(currentToken.content)) {
  3392. text = currentToken.content;
  3393. links = state.md.linkify.match(text);
  3394. // Now split string to nodes
  3395. nodes = [];
  3396. level = currentToken.level;
  3397. lastPos = 0;
  3398. for (ln = 0; ln < links.length; ln++) {
  3399. url = links[ln].url;
  3400. fullUrl = state.md.normalizeLink(url);
  3401. if (!state.md.validateLink(fullUrl)) { continue; }
  3402. urlText = links[ln].text;
  3403. // Linkifier might send raw hostnames like "example.com", where url
  3404. // starts with domain name. So we prepend http:// in those cases,
  3405. // and remove it afterwards.
  3406. //
  3407. if (!links[ln].schema) {
  3408. urlText = state.md.normalizeLinkText('http://' + urlText).replace(/^http:\/\//, '');
  3409. } else if (links[ln].schema === 'mailto:' && !/^mailto:/i.test(urlText)) {
  3410. urlText = state.md.normalizeLinkText('mailto:' + urlText).replace(/^mailto:/, '');
  3411. } else {
  3412. urlText = state.md.normalizeLinkText(urlText);
  3413. }
  3414. pos = links[ln].index;
  3415. if (pos > lastPos) {
  3416. token = new state.Token('text', '', 0);
  3417. token.content = text.slice(lastPos, pos);
  3418. token.level = level;
  3419. nodes.push(token);
  3420. }
  3421. token = new state.Token('link_open', 'a', 1);
  3422. token.attrs = [ [ 'href', fullUrl ] ];
  3423. token.level = level++;
  3424. token.markup = 'linkify';
  3425. token.info = 'auto';
  3426. nodes.push(token);
  3427. token = new state.Token('text', '', 0);
  3428. token.content = urlText;
  3429. token.level = level;
  3430. nodes.push(token);
  3431. token = new state.Token('link_close', 'a', -1);
  3432. token.level = --level;
  3433. token.markup = 'linkify';
  3434. token.info = 'auto';
  3435. nodes.push(token);
  3436. lastPos = links[ln].lastIndex;
  3437. }
  3438. if (lastPos < text.length) {
  3439. token = new state.Token('text', '', 0);
  3440. token.content = text.slice(lastPos);
  3441. token.level = level;
  3442. nodes.push(token);
  3443. }
  3444. // replace current node
  3445. blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);
  3446. }
  3447. }
  3448. }
  3449. };
  3450. },{"../common/utils":4}],33:[function(require,module,exports){
  3451. // Normalize input string
  3452. 'use strict';
  3453. var NEWLINES_RE = /\r[\n\u0085]?|[\u2424\u2028\u0085]/g;
  3454. var NULL_RE = /\u0000/g;
  3455. module.exports = function inline(state) {
  3456. var str;
  3457. // Normalize newlines
  3458. str = state.src.replace(NEWLINES_RE, '\n');
  3459. // Replace NULL characters
  3460. str = str.replace(NULL_RE, '\uFFFD');
  3461. state.src = str;
  3462. };
  3463. },{}],34:[function(require,module,exports){
  3464. // Simple typographyc replacements
  3465. //
  3466. // (c) (C) → ©
  3467. // (tm) (TM) → ™
  3468. // (r) (R) → ®
  3469. // +- → ±
  3470. // (p) (P) -> §
  3471. // ... → … (also ?.... → ?.., !.... → !..)
  3472. // ???????? → ???, !!!!! → !!!, `,,` → `,`
  3473. // -- → &ndash;, --- → &mdash;
  3474. //
  3475. 'use strict';
  3476. // TODO:
  3477. // - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
  3478. // - miltiplication 2 x 4 -> 2 × 4
  3479. var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
  3480. // Workaround for phantomjs - need regex without /g flag,
  3481. // or root check will fail every second time
  3482. var SCOPED_ABBR_TEST_RE = /\((c|tm|r|p)\)/i;
  3483. var SCOPED_ABBR_RE = /\((c|tm|r|p)\)/ig;
  3484. var SCOPED_ABBR = {
  3485. c: '©',
  3486. r: '®',
  3487. p: '§',
  3488. tm: '™'
  3489. };
  3490. function replaceFn(match, name) {
  3491. return SCOPED_ABBR[name.toLowerCase()];
  3492. }
  3493. function replace_scoped(inlineTokens) {
  3494. var i, token, inside_autolink = 0;
  3495. for (i = inlineTokens.length - 1; i >= 0; i--) {
  3496. token = inlineTokens[i];
  3497. if (token.type === 'text' && !inside_autolink) {
  3498. token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn);
  3499. }
  3500. if (token.type === 'link_open' && token.info === 'auto') {
  3501. inside_autolink--;
  3502. }
  3503. if (token.type === 'link_close' && token.info === 'auto') {
  3504. inside_autolink++;
  3505. }
  3506. }
  3507. }
  3508. function replace_rare(inlineTokens) {
  3509. var i, token, inside_autolink = 0;
  3510. for (i = inlineTokens.length - 1; i >= 0; i--) {
  3511. token = inlineTokens[i];
  3512. if (token.type === 'text' && !inside_autolink) {
  3513. if (RARE_RE.test(token.content)) {
  3514. token.content = token.content
  3515. .replace(/\+-/g, '±')
  3516. // .., ..., ....... -> …
  3517. // but ?..... & !..... -> ?.. & !..
  3518. .replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..')
  3519. .replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',')
  3520. // em-dash
  3521. .replace(/(^|[^-])---([^-]|$)/mg, '$1\u2014$2')
  3522. // en-dash
  3523. .replace(/(^|\s)--(\s|$)/mg, '$1\u2013$2')
  3524. .replace(/(^|[^-\s])--([^-\s]|$)/mg, '$1\u2013$2');
  3525. }
  3526. }
  3527. if (token.type === 'link_open' && token.info === 'auto') {
  3528. inside_autolink--;
  3529. }
  3530. if (token.type === 'link_close' && token.info === 'auto') {
  3531. inside_autolink++;
  3532. }
  3533. }
  3534. }
  3535. module.exports = function replace(state) {
  3536. var blkIdx;
  3537. if (!state.md.options.typographer) { return; }
  3538. for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
  3539. if (state.tokens[blkIdx].type !== 'inline') { continue; }
  3540. if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {
  3541. replace_scoped(state.tokens[blkIdx].children);
  3542. }
  3543. if (RARE_RE.test(state.tokens[blkIdx].content)) {
  3544. replace_rare(state.tokens[blkIdx].children);
  3545. }
  3546. }
  3547. };
  3548. },{}],35:[function(require,module,exports){
  3549. // Convert straight quotation marks to typographic ones
  3550. //
  3551. 'use strict';
  3552. var isWhiteSpace = require('../common/utils').isWhiteSpace;
  3553. var isPunctChar = require('../common/utils').isPunctChar;
  3554. var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct;
  3555. var QUOTE_TEST_RE = /['"]/;
  3556. var QUOTE_RE = /['"]/g;
  3557. var APOSTROPHE = '\u2019'; /* ’ */
  3558. function replaceAt(str, index, ch) {
  3559. return str.substr(0, index) + ch + str.substr(index + 1);
  3560. }
  3561. function process_inlines(tokens, state) {
  3562. var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar,
  3563. isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace,
  3564. canOpen, canClose, j, isSingle, stack, openQuote, closeQuote;
  3565. stack = [];
  3566. for (i = 0; i < tokens.length; i++) {
  3567. token = tokens[i];
  3568. thisLevel = tokens[i].level;
  3569. for (j = stack.length - 1; j >= 0; j--) {
  3570. if (stack[j].level <= thisLevel) { break; }
  3571. }
  3572. stack.length = j + 1;
  3573. if (token.type !== 'text') { continue; }
  3574. text = token.content;
  3575. pos = 0;
  3576. max = text.length;
  3577. /*eslint no-labels:0,block-scoped-var:0*/
  3578. OUTER:
  3579. while (pos < max) {
  3580. QUOTE_RE.lastIndex = pos;
  3581. t = QUOTE_RE.exec(text);
  3582. if (!t) { break; }
  3583. canOpen = canClose = true;
  3584. pos = t.index + 1;
  3585. isSingle = (t[0] === "'");
  3586. // Find previous character,
  3587. // default to space if it's the beginning of the line
  3588. //
  3589. lastChar = 0x20;
  3590. if (t.index - 1 >= 0) {
  3591. lastChar = text.charCodeAt(t.index - 1);
  3592. } else {
  3593. for (j = i - 1; j >= 0; j--) {
  3594. if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // lastChar defaults to 0x20
  3595. if (tokens[j].type !== 'text') continue;
  3596. lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
  3597. break;
  3598. }
  3599. }
  3600. // Find next character,
  3601. // default to space if it's the end of the line
  3602. //
  3603. nextChar = 0x20;
  3604. if (pos < max) {
  3605. nextChar = text.charCodeAt(pos);
  3606. } else {
  3607. for (j = i + 1; j < tokens.length; j++) {
  3608. if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // nextChar defaults to 0x20
  3609. if (tokens[j].type !== 'text') continue;
  3610. nextChar = tokens[j].content.charCodeAt(0);
  3611. break;
  3612. }
  3613. }
  3614. isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
  3615. isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
  3616. isLastWhiteSpace = isWhiteSpace(lastChar);
  3617. isNextWhiteSpace = isWhiteSpace(nextChar);
  3618. if (isNextWhiteSpace) {
  3619. canOpen = false;
  3620. } else if (isNextPunctChar) {
  3621. if (!(isLastWhiteSpace || isLastPunctChar)) {
  3622. canOpen = false;
  3623. }
  3624. }
  3625. if (isLastWhiteSpace) {
  3626. canClose = false;
  3627. } else if (isLastPunctChar) {
  3628. if (!(isNextWhiteSpace || isNextPunctChar)) {
  3629. canClose = false;
  3630. }
  3631. }
  3632. if (nextChar === 0x22 /* " */ && t[0] === '"') {
  3633. if (lastChar >= 0x30 /* 0 */ && lastChar <= 0x39 /* 9 */) {
  3634. // special case: 1"" - count first quote as an inch
  3635. canClose = canOpen = false;
  3636. }
  3637. }
  3638. if (canOpen && canClose) {
  3639. // treat this as the middle of the word
  3640. canOpen = false;
  3641. canClose = isNextPunctChar;
  3642. }
  3643. if (!canOpen && !canClose) {
  3644. // middle of word
  3645. if (isSingle) {
  3646. token.content = replaceAt(token.content, t.index, APOSTROPHE);
  3647. }
  3648. continue;
  3649. }
  3650. if (canClose) {
  3651. // this could be a closing quote, rewind the stack to get a match
  3652. for (j = stack.length - 1; j >= 0; j--) {
  3653. item = stack[j];
  3654. if (stack[j].level < thisLevel) { break; }
  3655. if (item.single === isSingle && stack[j].level === thisLevel) {
  3656. item = stack[j];
  3657. if (isSingle) {
  3658. openQuote = state.md.options.quotes[2];
  3659. closeQuote = state.md.options.quotes[3];
  3660. } else {
  3661. openQuote = state.md.options.quotes[0];
  3662. closeQuote = state.md.options.quotes[1];
  3663. }
  3664. // replace token.content *before* tokens[item.token].content,
  3665. // because, if they are pointing at the same token, replaceAt
  3666. // could mess up indices when quote length != 1
  3667. token.content = replaceAt(token.content, t.index, closeQuote);
  3668. tokens[item.token].content = replaceAt(
  3669. tokens[item.token].content, item.pos, openQuote);
  3670. pos += closeQuote.length - 1;
  3671. if (item.token === i) { pos += openQuote.length - 1; }
  3672. text = token.content;
  3673. max = text.length;
  3674. stack.length = j;
  3675. continue OUTER;
  3676. }
  3677. }
  3678. }
  3679. if (canOpen) {
  3680. stack.push({
  3681. token: i,
  3682. pos: t.index,
  3683. single: isSingle,
  3684. level: thisLevel
  3685. });
  3686. } else if (canClose && isSingle) {
  3687. token.content = replaceAt(token.content, t.index, APOSTROPHE);
  3688. }
  3689. }
  3690. }
  3691. }
  3692. module.exports = function smartquotes(state) {
  3693. /*eslint max-depth:0*/
  3694. var blkIdx;
  3695. if (!state.md.options.typographer) { return; }
  3696. for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
  3697. if (state.tokens[blkIdx].type !== 'inline' ||
  3698. !QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) {
  3699. continue;
  3700. }
  3701. process_inlines(state.tokens[blkIdx].children, state);
  3702. }
  3703. };
  3704. },{"../common/utils":4}],36:[function(require,module,exports){
  3705. // Core state object
  3706. //
  3707. 'use strict';
  3708. var Token = require('../token');
  3709. function StateCore(src, md, env) {
  3710. this.src = src;
  3711. this.env = env;
  3712. this.tokens = [];
  3713. this.inlineMode = false;
  3714. this.md = md; // link to parser instance
  3715. }
  3716. // re-export Token class to use in core rules
  3717. StateCore.prototype.Token = Token;
  3718. module.exports = StateCore;
  3719. },{"../token":51}],37:[function(require,module,exports){
  3720. // Process autolinks '<protocol:...>'
  3721. 'use strict';
  3722. /*eslint max-len:0*/
  3723. 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])?)*)>/;
  3724. var AUTOLINK_RE = /^<([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)>/;
  3725. module.exports = function autolink(state, silent) {
  3726. var tail, linkMatch, emailMatch, url, fullUrl, token,
  3727. pos = state.pos;
  3728. if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
  3729. tail = state.src.slice(pos);
  3730. if (tail.indexOf('>') < 0) { return false; }
  3731. if (AUTOLINK_RE.test(tail)) {
  3732. linkMatch = tail.match(AUTOLINK_RE);
  3733. url = linkMatch[0].slice(1, -1);
  3734. fullUrl = state.md.normalizeLink(url);
  3735. if (!state.md.validateLink(fullUrl)) { return false; }
  3736. if (!silent) {
  3737. token = state.push('link_open', 'a', 1);
  3738. token.attrs = [ [ 'href', fullUrl ] ];
  3739. token.markup = 'autolink';
  3740. token.info = 'auto';
  3741. token = state.push('text', '', 0);
  3742. token.content = state.md.normalizeLinkText(url);
  3743. token = state.push('link_close', 'a', -1);
  3744. token.markup = 'autolink';
  3745. token.info = 'auto';
  3746. }
  3747. state.pos += linkMatch[0].length;
  3748. return true;
  3749. }
  3750. if (EMAIL_RE.test(tail)) {
  3751. emailMatch = tail.match(EMAIL_RE);
  3752. url = emailMatch[0].slice(1, -1);
  3753. fullUrl = state.md.normalizeLink('mailto:' + url);
  3754. if (!state.md.validateLink(fullUrl)) { return false; }
  3755. if (!silent) {
  3756. token = state.push('link_open', 'a', 1);
  3757. token.attrs = [ [ 'href', fullUrl ] ];
  3758. token.markup = 'autolink';
  3759. token.info = 'auto';
  3760. token = state.push('text', '', 0);
  3761. token.content = state.md.normalizeLinkText(url);
  3762. token = state.push('link_close', 'a', -1);
  3763. token.markup = 'autolink';
  3764. token.info = 'auto';
  3765. }
  3766. state.pos += emailMatch[0].length;
  3767. return true;
  3768. }
  3769. return false;
  3770. };
  3771. },{}],38:[function(require,module,exports){
  3772. // Parse backticks
  3773. 'use strict';
  3774. module.exports = function backtick(state, silent) {
  3775. var start, max, marker, matchStart, matchEnd, token,
  3776. pos = state.pos,
  3777. ch = state.src.charCodeAt(pos);
  3778. if (ch !== 0x60/* ` */) { return false; }
  3779. start = pos;
  3780. pos++;
  3781. max = state.posMax;
  3782. while (pos < max && state.src.charCodeAt(pos) === 0x60/* ` */) { pos++; }
  3783. marker = state.src.slice(start, pos);
  3784. matchStart = matchEnd = pos;
  3785. while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) {
  3786. matchEnd = matchStart + 1;
  3787. while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60/* ` */) { matchEnd++; }
  3788. if (matchEnd - matchStart === marker.length) {
  3789. if (!silent) {
  3790. token = state.push('code_inline', 'code', 0);
  3791. token.markup = marker;
  3792. token.content = state.src.slice(pos, matchStart)
  3793. .replace(/[ \n]+/g, ' ')
  3794. .trim();
  3795. }
  3796. state.pos = matchEnd;
  3797. return true;
  3798. }
  3799. }
  3800. if (!silent) { state.pending += marker; }
  3801. state.pos += marker.length;
  3802. return true;
  3803. };
  3804. },{}],39:[function(require,module,exports){
  3805. // For each opening emphasis-like marker find a matching closing one
  3806. //
  3807. 'use strict';
  3808. module.exports = function link_pairs(state) {
  3809. var i, j, lastDelim, currDelim,
  3810. delimiters = state.delimiters,
  3811. max = state.delimiters.length;
  3812. for (i = 0; i < max; i++) {
  3813. lastDelim = delimiters[i];
  3814. if (!lastDelim.close) { continue; }
  3815. j = i - lastDelim.jump - 1;
  3816. while (j >= 0) {
  3817. currDelim = delimiters[j];
  3818. if (currDelim.open &&
  3819. currDelim.marker === lastDelim.marker &&
  3820. currDelim.end < 0 &&
  3821. currDelim.level === lastDelim.level) {
  3822. // typeofs are for backward compatibility with plugins
  3823. var odd_match = (currDelim.close || lastDelim.open) &&
  3824. typeof currDelim.length !== 'undefined' &&
  3825. typeof lastDelim.length !== 'undefined' &&
  3826. (currDelim.length + lastDelim.length) % 3 === 0;
  3827. if (!odd_match) {
  3828. lastDelim.jump = i - j;
  3829. lastDelim.open = false;
  3830. currDelim.end = i;
  3831. currDelim.jump = 0;
  3832. break;
  3833. }
  3834. }
  3835. j -= currDelim.jump + 1;
  3836. }
  3837. }
  3838. };
  3839. },{}],40:[function(require,module,exports){
  3840. // Process *this* and _that_
  3841. //
  3842. 'use strict';
  3843. // Insert each marker as a separate text token, and add it to delimiter list
  3844. //
  3845. module.exports.tokenize = function emphasis(state, silent) {
  3846. var i, scanned, token,
  3847. start = state.pos,
  3848. marker = state.src.charCodeAt(start);
  3849. if (silent) { return false; }
  3850. if (marker !== 0x5F /* _ */ && marker !== 0x2A /* * */) { return false; }
  3851. scanned = state.scanDelims(state.pos, marker === 0x2A);
  3852. for (i = 0; i < scanned.length; i++) {
  3853. token = state.push('text', '', 0);
  3854. token.content = String.fromCharCode(marker);
  3855. state.delimiters.push({
  3856. // Char code of the starting marker (number).
  3857. //
  3858. marker: marker,
  3859. // Total length of these series of delimiters.
  3860. //
  3861. length: scanned.length,
  3862. // An amount of characters before this one that's equivalent to
  3863. // current one. In plain English: if this delimiter does not open
  3864. // an emphasis, neither do previous `jump` characters.
  3865. //
  3866. // Used to skip sequences like "*****" in one step, for 1st asterisk
  3867. // value will be 0, for 2nd it's 1 and so on.
  3868. //
  3869. jump: i,
  3870. // A position of the token this delimiter corresponds to.
  3871. //
  3872. token: state.tokens.length - 1,
  3873. // Token level.
  3874. //
  3875. level: state.level,
  3876. // If this delimiter is matched as a valid opener, `end` will be
  3877. // equal to its position, otherwise it's `-1`.
  3878. //
  3879. end: -1,
  3880. // Boolean flags that determine if this delimiter could open or close
  3881. // an emphasis.
  3882. //
  3883. open: scanned.can_open,
  3884. close: scanned.can_close
  3885. });
  3886. }
  3887. state.pos += scanned.length;
  3888. return true;
  3889. };
  3890. // Walk through delimiter list and replace text tokens with tags
  3891. //
  3892. module.exports.postProcess = function emphasis(state) {
  3893. var i,
  3894. startDelim,
  3895. endDelim,
  3896. token,
  3897. ch,
  3898. isStrong,
  3899. delimiters = state.delimiters,
  3900. max = state.delimiters.length;
  3901. for (i = max - 1; i >= 0; i--) {
  3902. startDelim = delimiters[i];
  3903. if (startDelim.marker !== 0x5F/* _ */ && startDelim.marker !== 0x2A/* * */) {
  3904. continue;
  3905. }
  3906. // Process only opening markers
  3907. if (startDelim.end === -1) {
  3908. continue;
  3909. }
  3910. endDelim = delimiters[startDelim.end];
  3911. // If the previous delimiter has the same marker and is adjacent to this one,
  3912. // merge those into one strong delimiter.
  3913. //
  3914. // `<em><em>whatever</em></em>` -> `<strong>whatever</strong>`
  3915. //
  3916. isStrong = i > 0 &&
  3917. delimiters[i - 1].end === startDelim.end + 1 &&
  3918. delimiters[i - 1].token === startDelim.token - 1 &&
  3919. delimiters[startDelim.end + 1].token === endDelim.token + 1 &&
  3920. delimiters[i - 1].marker === startDelim.marker;
  3921. ch = String.fromCharCode(startDelim.marker);
  3922. token = state.tokens[startDelim.token];
  3923. token.type = isStrong ? 'strong_open' : 'em_open';
  3924. token.tag = isStrong ? 'strong' : 'em';
  3925. token.nesting = 1;
  3926. token.markup = isStrong ? ch + ch : ch;
  3927. token.content = '';
  3928. token = state.tokens[endDelim.token];
  3929. token.type = isStrong ? 'strong_close' : 'em_close';
  3930. token.tag = isStrong ? 'strong' : 'em';
  3931. token.nesting = -1;
  3932. token.markup = isStrong ? ch + ch : ch;
  3933. token.content = '';
  3934. if (isStrong) {
  3935. state.tokens[delimiters[i - 1].token].content = '';
  3936. state.tokens[delimiters[startDelim.end + 1].token].content = '';
  3937. i--;
  3938. }
  3939. }
  3940. };
  3941. },{}],41:[function(require,module,exports){
  3942. // Process html entity - &#123;, &#xAF;, &quot;, ...
  3943. 'use strict';
  3944. var entities = require('../common/entities');
  3945. var has = require('../common/utils').has;
  3946. var isValidEntityCode = require('../common/utils').isValidEntityCode;
  3947. var fromCodePoint = require('../common/utils').fromCodePoint;
  3948. var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i;
  3949. var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
  3950. module.exports = function entity(state, silent) {
  3951. var ch, code, match, pos = state.pos, max = state.posMax;
  3952. if (state.src.charCodeAt(pos) !== 0x26/* & */) { return false; }
  3953. if (pos + 1 < max) {
  3954. ch = state.src.charCodeAt(pos + 1);
  3955. if (ch === 0x23 /* # */) {
  3956. match = state.src.slice(pos).match(DIGITAL_RE);
  3957. if (match) {
  3958. if (!silent) {
  3959. code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10);
  3960. state.pending += isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD);
  3961. }
  3962. state.pos += match[0].length;
  3963. return true;
  3964. }
  3965. } else {
  3966. match = state.src.slice(pos).match(NAMED_RE);
  3967. if (match) {
  3968. if (has(entities, match[1])) {
  3969. if (!silent) { state.pending += entities[match[1]]; }
  3970. state.pos += match[0].length;
  3971. return true;
  3972. }
  3973. }
  3974. }
  3975. }
  3976. if (!silent) { state.pending += '&'; }
  3977. state.pos++;
  3978. return true;
  3979. };
  3980. },{"../common/entities":1,"../common/utils":4}],42:[function(require,module,exports){
  3981. // Process escaped chars and hardbreaks
  3982. 'use strict';
  3983. var isSpace = require('../common/utils').isSpace;
  3984. var ESCAPED = [];
  3985. for (var i = 0; i < 256; i++) { ESCAPED.push(0); }
  3986. '\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-'
  3987. .split('').forEach(function (ch) { ESCAPED[ch.charCodeAt(0)] = 1; });
  3988. module.exports = function escape(state, silent) {
  3989. var ch, pos = state.pos, max = state.posMax;
  3990. if (state.src.charCodeAt(pos) !== 0x5C/* \ */) { return false; }
  3991. pos++;
  3992. if (pos < max) {
  3993. ch = state.src.charCodeAt(pos);
  3994. if (ch < 256 && ESCAPED[ch] !== 0) {
  3995. if (!silent) { state.pending += state.src[pos]; }
  3996. state.pos += 2;
  3997. return true;
  3998. }
  3999. if (ch === 0x0A) {
  4000. if (!silent) {
  4001. state.push('hardbreak', 'br', 0);
  4002. }
  4003. pos++;
  4004. // skip leading whitespaces from next line
  4005. while (pos < max) {
  4006. ch = state.src.charCodeAt(pos);
  4007. if (!isSpace(ch)) { break; }
  4008. pos++;
  4009. }
  4010. state.pos = pos;
  4011. return true;
  4012. }
  4013. }
  4014. if (!silent) { state.pending += '\\'; }
  4015. state.pos++;
  4016. return true;
  4017. };
  4018. },{"../common/utils":4}],43:[function(require,module,exports){
  4019. // Process html tags
  4020. 'use strict';
  4021. var HTML_TAG_RE = require('../common/html_re').HTML_TAG_RE;
  4022. function isLetter(ch) {
  4023. /*eslint no-bitwise:0*/
  4024. var lc = ch | 0x20; // to lower case
  4025. return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */);
  4026. }
  4027. module.exports = function html_inline(state, silent) {
  4028. var ch, match, max, token,
  4029. pos = state.pos;
  4030. if (!state.md.options.html) { return false; }
  4031. // Check start
  4032. max = state.posMax;
  4033. if (state.src.charCodeAt(pos) !== 0x3C/* < */ ||
  4034. pos + 2 >= max) {
  4035. return false;
  4036. }
  4037. // Quick fail on second char
  4038. ch = state.src.charCodeAt(pos + 1);
  4039. if (ch !== 0x21/* ! */ &&
  4040. ch !== 0x3F/* ? */ &&
  4041. ch !== 0x2F/* / */ &&
  4042. !isLetter(ch)) {
  4043. return false;
  4044. }
  4045. match = state.src.slice(pos).match(HTML_TAG_RE);
  4046. if (!match) { return false; }
  4047. if (!silent) {
  4048. token = state.push('html_inline', '', 0);
  4049. token.content = state.src.slice(pos, pos + match[0].length);
  4050. }
  4051. state.pos += match[0].length;
  4052. return true;
  4053. };
  4054. },{"../common/html_re":3}],44:[function(require,module,exports){
  4055. // Process ![image](<src> "title")
  4056. 'use strict';
  4057. var normalizeReference = require('../common/utils').normalizeReference;
  4058. var isSpace = require('../common/utils').isSpace;
  4059. module.exports = function image(state, silent) {
  4060. var attrs,
  4061. code,
  4062. content,
  4063. label,
  4064. labelEnd,
  4065. labelStart,
  4066. pos,
  4067. ref,
  4068. res,
  4069. title,
  4070. token,
  4071. tokens,
  4072. start,
  4073. href = '',
  4074. oldPos = state.pos,
  4075. max = state.posMax;
  4076. if (state.src.charCodeAt(state.pos) !== 0x21/* ! */) { return false; }
  4077. if (state.src.charCodeAt(state.pos + 1) !== 0x5B/* [ */) { return false; }
  4078. labelStart = state.pos + 2;
  4079. labelEnd = state.md.helpers.parseLinkLabel(state, state.pos + 1, false);
  4080. // parser failed to find ']', so it's not a valid link
  4081. if (labelEnd < 0) { return false; }
  4082. pos = labelEnd + 1;
  4083. if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {
  4084. //
  4085. // Inline link
  4086. //
  4087. // [link]( <href> "title" )
  4088. // ^^ skipping these spaces
  4089. pos++;
  4090. for (; pos < max; pos++) {
  4091. code = state.src.charCodeAt(pos);
  4092. if (!isSpace(code) && code !== 0x0A) { break; }
  4093. }
  4094. if (pos >= max) { return false; }
  4095. // [link]( <href> "title" )
  4096. // ^^^^^^ parsing link destination
  4097. start = pos;
  4098. res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
  4099. if (res.ok) {
  4100. href = state.md.normalizeLink(res.str);
  4101. if (state.md.validateLink(href)) {
  4102. pos = res.pos;
  4103. } else {
  4104. href = '';
  4105. }
  4106. }
  4107. // [link]( <href> "title" )
  4108. // ^^ skipping these spaces
  4109. start = pos;
  4110. for (; pos < max; pos++) {
  4111. code = state.src.charCodeAt(pos);
  4112. if (!isSpace(code) && code !== 0x0A) { break; }
  4113. }
  4114. // [link]( <href> "title" )
  4115. // ^^^^^^^ parsing link title
  4116. res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
  4117. if (pos < max && start !== pos && res.ok) {
  4118. title = res.str;
  4119. pos = res.pos;
  4120. // [link]( <href> "title" )
  4121. // ^^ skipping these spaces
  4122. for (; pos < max; pos++) {
  4123. code = state.src.charCodeAt(pos);
  4124. if (!isSpace(code) && code !== 0x0A) { break; }
  4125. }
  4126. } else {
  4127. title = '';
  4128. }
  4129. if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
  4130. state.pos = oldPos;
  4131. return false;
  4132. }
  4133. pos++;
  4134. } else {
  4135. //
  4136. // Link reference
  4137. //
  4138. if (typeof state.env.references === 'undefined') { return false; }
  4139. if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
  4140. start = pos + 1;
  4141. pos = state.md.helpers.parseLinkLabel(state, pos);
  4142. if (pos >= 0) {
  4143. label = state.src.slice(start, pos++);
  4144. } else {
  4145. pos = labelEnd + 1;
  4146. }
  4147. } else {
  4148. pos = labelEnd + 1;
  4149. }
  4150. // covers label === '' and label === undefined
  4151. // (collapsed reference link and shortcut reference link respectively)
  4152. if (!label) { label = state.src.slice(labelStart, labelEnd); }
  4153. ref = state.env.references[normalizeReference(label)];
  4154. if (!ref) {
  4155. state.pos = oldPos;
  4156. return false;
  4157. }
  4158. href = ref.href;
  4159. title = ref.title;
  4160. }
  4161. //
  4162. // We found the end of the link, and know for a fact it's a valid link;
  4163. // so all that's left to do is to call tokenizer.
  4164. //
  4165. if (!silent) {
  4166. content = state.src.slice(labelStart, labelEnd);
  4167. state.md.inline.parse(
  4168. content,
  4169. state.md,
  4170. state.env,
  4171. tokens = []
  4172. );
  4173. token = state.push('image', 'img', 0);
  4174. token.attrs = attrs = [ [ 'src', href ], [ 'alt', '' ] ];
  4175. token.children = tokens;
  4176. token.content = content;
  4177. if (title) {
  4178. attrs.push([ 'title', title ]);
  4179. }
  4180. }
  4181. state.pos = pos;
  4182. state.posMax = max;
  4183. return true;
  4184. };
  4185. },{"../common/utils":4}],45:[function(require,module,exports){
  4186. // Process [link](<to> "stuff")
  4187. 'use strict';
  4188. var normalizeReference = require('../common/utils').normalizeReference;
  4189. var isSpace = require('../common/utils').isSpace;
  4190. module.exports = function link(state, silent) {
  4191. var attrs,
  4192. code,
  4193. label,
  4194. labelEnd,
  4195. labelStart,
  4196. pos,
  4197. res,
  4198. ref,
  4199. title,
  4200. token,
  4201. href = '',
  4202. oldPos = state.pos,
  4203. max = state.posMax,
  4204. start = state.pos,
  4205. parseReference = true;
  4206. if (state.src.charCodeAt(state.pos) !== 0x5B/* [ */) { return false; }
  4207. labelStart = state.pos + 1;
  4208. labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, true);
  4209. // parser failed to find ']', so it's not a valid link
  4210. if (labelEnd < 0) { return false; }
  4211. pos = labelEnd + 1;
  4212. if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {
  4213. //
  4214. // Inline link
  4215. //
  4216. // might have found a valid shortcut link, disable reference parsing
  4217. parseReference = false;
  4218. // [link]( <href> "title" )
  4219. // ^^ skipping these spaces
  4220. pos++;
  4221. for (; pos < max; pos++) {
  4222. code = state.src.charCodeAt(pos);
  4223. if (!isSpace(code) && code !== 0x0A) { break; }
  4224. }
  4225. if (pos >= max) { return false; }
  4226. // [link]( <href> "title" )
  4227. // ^^^^^^ parsing link destination
  4228. start = pos;
  4229. res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
  4230. if (res.ok) {
  4231. href = state.md.normalizeLink(res.str);
  4232. if (state.md.validateLink(href)) {
  4233. pos = res.pos;
  4234. } else {
  4235. href = '';
  4236. }
  4237. }
  4238. // [link]( <href> "title" )
  4239. // ^^ skipping these spaces
  4240. start = pos;
  4241. for (; pos < max; pos++) {
  4242. code = state.src.charCodeAt(pos);
  4243. if (!isSpace(code) && code !== 0x0A) { break; }
  4244. }
  4245. // [link]( <href> "title" )
  4246. // ^^^^^^^ parsing link title
  4247. res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
  4248. if (pos < max && start !== pos && res.ok) {
  4249. title = res.str;
  4250. pos = res.pos;
  4251. // [link]( <href> "title" )
  4252. // ^^ skipping these spaces
  4253. for (; pos < max; pos++) {
  4254. code = state.src.charCodeAt(pos);
  4255. if (!isSpace(code) && code !== 0x0A) { break; }
  4256. }
  4257. } else {
  4258. title = '';
  4259. }
  4260. if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
  4261. // parsing a valid shortcut link failed, fallback to reference
  4262. parseReference = true;
  4263. }
  4264. pos++;
  4265. }
  4266. if (parseReference) {
  4267. //
  4268. // Link reference
  4269. //
  4270. if (typeof state.env.references === 'undefined') { return false; }
  4271. if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
  4272. start = pos + 1;
  4273. pos = state.md.helpers.parseLinkLabel(state, pos);
  4274. if (pos >= 0) {
  4275. label = state.src.slice(start, pos++);
  4276. } else {
  4277. pos = labelEnd + 1;
  4278. }
  4279. } else {
  4280. pos = labelEnd + 1;
  4281. }
  4282. // covers label === '' and label === undefined
  4283. // (collapsed reference link and shortcut reference link respectively)
  4284. if (!label) { label = state.src.slice(labelStart, labelEnd); }
  4285. ref = state.env.references[normalizeReference(label)];
  4286. if (!ref) {
  4287. state.pos = oldPos;
  4288. return false;
  4289. }
  4290. href = ref.href;
  4291. title = ref.title;
  4292. }
  4293. //
  4294. // We found the end of the link, and know for a fact it's a valid link;
  4295. // so all that's left to do is to call tokenizer.
  4296. //
  4297. if (!silent) {
  4298. state.pos = labelStart;
  4299. state.posMax = labelEnd;
  4300. token = state.push('link_open', 'a', 1);
  4301. token.attrs = attrs = [ [ 'href', href ] ];
  4302. if (title) {
  4303. attrs.push([ 'title', title ]);
  4304. }
  4305. state.md.inline.tokenize(state);
  4306. token = state.push('link_close', 'a', -1);
  4307. }
  4308. state.pos = pos;
  4309. state.posMax = max;
  4310. return true;
  4311. };
  4312. },{"../common/utils":4}],46:[function(require,module,exports){
  4313. // Proceess '\n'
  4314. 'use strict';
  4315. var isSpace = require('../common/utils').isSpace;
  4316. module.exports = function newline(state, silent) {
  4317. var pmax, max, pos = state.pos;
  4318. if (state.src.charCodeAt(pos) !== 0x0A/* \n */) { return false; }
  4319. pmax = state.pending.length - 1;
  4320. max = state.posMax;
  4321. // ' \n' -> hardbreak
  4322. // Lookup in pending chars is bad practice! Don't copy to other rules!
  4323. // Pending string is stored in concat mode, indexed lookups will cause
  4324. // convertion to flat mode.
  4325. if (!silent) {
  4326. if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) {
  4327. if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) {
  4328. state.pending = state.pending.replace(/ +$/, '');
  4329. state.push('hardbreak', 'br', 0);
  4330. } else {
  4331. state.pending = state.pending.slice(0, -1);
  4332. state.push('softbreak', 'br', 0);
  4333. }
  4334. } else {
  4335. state.push('softbreak', 'br', 0);
  4336. }
  4337. }
  4338. pos++;
  4339. // skip heading spaces for next line
  4340. while (pos < max && isSpace(state.src.charCodeAt(pos))) { pos++; }
  4341. state.pos = pos;
  4342. return true;
  4343. };
  4344. },{"../common/utils":4}],47:[function(require,module,exports){
  4345. // Inline parser state
  4346. 'use strict';
  4347. var Token = require('../token');
  4348. var isWhiteSpace = require('../common/utils').isWhiteSpace;
  4349. var isPunctChar = require('../common/utils').isPunctChar;
  4350. var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct;
  4351. function StateInline(src, md, env, outTokens) {
  4352. this.src = src;
  4353. this.env = env;
  4354. this.md = md;
  4355. this.tokens = outTokens;
  4356. this.pos = 0;
  4357. this.posMax = this.src.length;
  4358. this.level = 0;
  4359. this.pending = '';
  4360. this.pendingLevel = 0;
  4361. this.cache = {}; // Stores { start: end } pairs. Useful for backtrack
  4362. // optimization of pairs parse (emphasis, strikes).
  4363. this.delimiters = []; // Emphasis-like delimiters
  4364. }
  4365. // Flush pending text
  4366. //
  4367. StateInline.prototype.pushPending = function () {
  4368. var token = new Token('text', '', 0);
  4369. token.content = this.pending;
  4370. token.level = this.pendingLevel;
  4371. this.tokens.push(token);
  4372. this.pending = '';
  4373. return token;
  4374. };
  4375. // Push new token to "stream".
  4376. // If pending text exists - flush it as text token
  4377. //
  4378. StateInline.prototype.push = function (type, tag, nesting) {
  4379. if (this.pending) {
  4380. this.pushPending();
  4381. }
  4382. var token = new Token(type, tag, nesting);
  4383. if (nesting < 0) { this.level--; }
  4384. token.level = this.level;
  4385. if (nesting > 0) { this.level++; }
  4386. this.pendingLevel = this.level;
  4387. this.tokens.push(token);
  4388. return token;
  4389. };
  4390. // Scan a sequence of emphasis-like markers, and determine whether
  4391. // it can start an emphasis sequence or end an emphasis sequence.
  4392. //
  4393. // - start - position to scan from (it should point at a valid marker);
  4394. // - canSplitWord - determine if these markers can be found inside a word
  4395. //
  4396. StateInline.prototype.scanDelims = function (start, canSplitWord) {
  4397. var pos = start, lastChar, nextChar, count, can_open, can_close,
  4398. isLastWhiteSpace, isLastPunctChar,
  4399. isNextWhiteSpace, isNextPunctChar,
  4400. left_flanking = true,
  4401. right_flanking = true,
  4402. max = this.posMax,
  4403. marker = this.src.charCodeAt(start);
  4404. // treat beginning of the line as a whitespace
  4405. lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 0x20;
  4406. while (pos < max && this.src.charCodeAt(pos) === marker) { pos++; }
  4407. count = pos - start;
  4408. // treat end of the line as a whitespace
  4409. nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20;
  4410. isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
  4411. isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
  4412. isLastWhiteSpace = isWhiteSpace(lastChar);
  4413. isNextWhiteSpace = isWhiteSpace(nextChar);
  4414. if (isNextWhiteSpace) {
  4415. left_flanking = false;
  4416. } else if (isNextPunctChar) {
  4417. if (!(isLastWhiteSpace || isLastPunctChar)) {
  4418. left_flanking = false;
  4419. }
  4420. }
  4421. if (isLastWhiteSpace) {
  4422. right_flanking = false;
  4423. } else if (isLastPunctChar) {
  4424. if (!(isNextWhiteSpace || isNextPunctChar)) {
  4425. right_flanking = false;
  4426. }
  4427. }
  4428. if (!canSplitWord) {
  4429. can_open = left_flanking && (!right_flanking || isLastPunctChar);
  4430. can_close = right_flanking && (!left_flanking || isNextPunctChar);
  4431. } else {
  4432. can_open = left_flanking;
  4433. can_close = right_flanking;
  4434. }
  4435. return {
  4436. can_open: can_open,
  4437. can_close: can_close,
  4438. length: count
  4439. };
  4440. };
  4441. // re-export Token class to use in block rules
  4442. StateInline.prototype.Token = Token;
  4443. module.exports = StateInline;
  4444. },{"../common/utils":4,"../token":51}],48:[function(require,module,exports){
  4445. // ~~strike through~~
  4446. //
  4447. 'use strict';
  4448. // Insert each marker as a separate text token, and add it to delimiter list
  4449. //
  4450. module.exports.tokenize = function strikethrough(state, silent) {
  4451. var i, scanned, token, len, ch,
  4452. start = state.pos,
  4453. marker = state.src.charCodeAt(start);
  4454. if (silent) { return false; }
  4455. if (marker !== 0x7E/* ~ */) { return false; }
  4456. scanned = state.scanDelims(state.pos, true);
  4457. len = scanned.length;
  4458. ch = String.fromCharCode(marker);
  4459. if (len < 2) { return false; }
  4460. if (len % 2) {
  4461. token = state.push('text', '', 0);
  4462. token.content = ch;
  4463. len--;
  4464. }
  4465. for (i = 0; i < len; i += 2) {
  4466. token = state.push('text', '', 0);
  4467. token.content = ch + ch;
  4468. state.delimiters.push({
  4469. marker: marker,
  4470. jump: i,
  4471. token: state.tokens.length - 1,
  4472. level: state.level,
  4473. end: -1,
  4474. open: scanned.can_open,
  4475. close: scanned.can_close
  4476. });
  4477. }
  4478. state.pos += scanned.length;
  4479. return true;
  4480. };
  4481. // Walk through delimiter list and replace text tokens with tags
  4482. //
  4483. module.exports.postProcess = function strikethrough(state) {
  4484. var i, j,
  4485. startDelim,
  4486. endDelim,
  4487. token,
  4488. loneMarkers = [],
  4489. delimiters = state.delimiters,
  4490. max = state.delimiters.length;
  4491. for (i = 0; i < max; i++) {
  4492. startDelim = delimiters[i];
  4493. if (startDelim.marker !== 0x7E/* ~ */) {
  4494. continue;
  4495. }
  4496. if (startDelim.end === -1) {
  4497. continue;
  4498. }
  4499. endDelim = delimiters[startDelim.end];
  4500. token = state.tokens[startDelim.token];
  4501. token.type = 's_open';
  4502. token.tag = 's';
  4503. token.nesting = 1;
  4504. token.markup = '~~';
  4505. token.content = '';
  4506. token = state.tokens[endDelim.token];
  4507. token.type = 's_close';
  4508. token.tag = 's';
  4509. token.nesting = -1;
  4510. token.markup = '~~';
  4511. token.content = '';
  4512. if (state.tokens[endDelim.token - 1].type === 'text' &&
  4513. state.tokens[endDelim.token - 1].content === '~') {
  4514. loneMarkers.push(endDelim.token - 1);
  4515. }
  4516. }
  4517. // If a marker sequence has an odd number of characters, it's splitted
  4518. // like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the
  4519. // start of the sequence.
  4520. //
  4521. // So, we have to move all those markers after subsequent s_close tags.
  4522. //
  4523. while (loneMarkers.length) {
  4524. i = loneMarkers.pop();
  4525. j = i + 1;
  4526. while (j < state.tokens.length && state.tokens[j].type === 's_close') {
  4527. j++;
  4528. }
  4529. j--;
  4530. if (i !== j) {
  4531. token = state.tokens[j];
  4532. state.tokens[j] = state.tokens[i];
  4533. state.tokens[i] = token;
  4534. }
  4535. }
  4536. };
  4537. },{}],49:[function(require,module,exports){
  4538. // Skip text characters for text token, place those to pending buffer
  4539. // and increment current pos
  4540. 'use strict';
  4541. // Rule to skip pure text
  4542. // '{}$%@~+=:' reserved for extentions
  4543. // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
  4544. // !!!! Don't confuse with "Markdown ASCII Punctuation" chars
  4545. // http://spec.commonmark.org/0.15/#ascii-punctuation-character
  4546. function isTerminatorChar(ch) {
  4547. switch (ch) {
  4548. case 0x0A/* \n */:
  4549. case 0x21/* ! */:
  4550. case 0x23/* # */:
  4551. case 0x24/* $ */:
  4552. case 0x25/* % */:
  4553. case 0x26/* & */:
  4554. case 0x2A/* * */:
  4555. case 0x2B/* + */:
  4556. case 0x2D/* - */:
  4557. case 0x3A/* : */:
  4558. case 0x3C/* < */:
  4559. case 0x3D/* = */:
  4560. case 0x3E/* > */:
  4561. case 0x40/* @ */:
  4562. case 0x5B/* [ */:
  4563. case 0x5C/* \ */:
  4564. case 0x5D/* ] */:
  4565. case 0x5E/* ^ */:
  4566. case 0x5F/* _ */:
  4567. case 0x60/* ` */:
  4568. case 0x7B/* { */:
  4569. case 0x7D/* } */:
  4570. case 0x7E/* ~ */:
  4571. return true;
  4572. default:
  4573. return false;
  4574. }
  4575. }
  4576. module.exports = function text(state, silent) {
  4577. var pos = state.pos;
  4578. while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) {
  4579. pos++;
  4580. }
  4581. if (pos === state.pos) { return false; }
  4582. if (!silent) { state.pending += state.src.slice(state.pos, pos); }
  4583. state.pos = pos;
  4584. return true;
  4585. };
  4586. // Alternative implementation, for memory.
  4587. //
  4588. // It costs 10% of performance, but allows extend terminators list, if place it
  4589. // to `ParcerInline` property. Probably, will switch to it sometime, such
  4590. // flexibility required.
  4591. /*
  4592. var TERMINATOR_RE = /[\n!#$%&*+\-:<=>@[\\\]^_`{}~]/;
  4593. module.exports = function text(state, silent) {
  4594. var pos = state.pos,
  4595. idx = state.src.slice(pos).search(TERMINATOR_RE);
  4596. // first char is terminator -> empty text
  4597. if (idx === 0) { return false; }
  4598. // no terminator -> text till end of string
  4599. if (idx < 0) {
  4600. if (!silent) { state.pending += state.src.slice(pos); }
  4601. state.pos = state.src.length;
  4602. return true;
  4603. }
  4604. if (!silent) { state.pending += state.src.slice(pos, pos + idx); }
  4605. state.pos += idx;
  4606. return true;
  4607. };*/
  4608. },{}],50:[function(require,module,exports){
  4609. // Merge adjacent text nodes into one, and re-calculate all token levels
  4610. //
  4611. 'use strict';
  4612. module.exports = function text_collapse(state) {
  4613. var curr, last,
  4614. level = 0,
  4615. tokens = state.tokens,
  4616. max = state.tokens.length;
  4617. for (curr = last = 0; curr < max; curr++) {
  4618. // re-calculate levels
  4619. level += tokens[curr].nesting;
  4620. tokens[curr].level = level;
  4621. if (tokens[curr].type === 'text' &&
  4622. curr + 1 < max &&
  4623. tokens[curr + 1].type === 'text') {
  4624. // collapse two adjacent text nodes
  4625. tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
  4626. } else {
  4627. if (curr !== last) { tokens[last] = tokens[curr]; }
  4628. last++;
  4629. }
  4630. }
  4631. if (curr !== last) {
  4632. tokens.length = last;
  4633. }
  4634. };
  4635. },{}],51:[function(require,module,exports){
  4636. // Token class
  4637. 'use strict';
  4638. /**
  4639. * class Token
  4640. **/
  4641. /**
  4642. * new Token(type, tag, nesting)
  4643. *
  4644. * Create new token and fill passed properties.
  4645. **/
  4646. function Token(type, tag, nesting) {
  4647. /**
  4648. * Token#type -> String
  4649. *
  4650. * Type of the token (string, e.g. "paragraph_open")
  4651. **/
  4652. this.type = type;
  4653. /**
  4654. * Token#tag -> String
  4655. *
  4656. * html tag name, e.g. "p"
  4657. **/
  4658. this.tag = tag;
  4659. /**
  4660. * Token#attrs -> Array
  4661. *
  4662. * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`
  4663. **/
  4664. this.attrs = null;
  4665. /**
  4666. * Token#map -> Array
  4667. *
  4668. * Source map info. Format: `[ line_begin, line_end ]`
  4669. **/
  4670. this.map = null;
  4671. /**
  4672. * Token#nesting -> Number
  4673. *
  4674. * Level change (number in {-1, 0, 1} set), where:
  4675. *
  4676. * - `1` means the tag is opening
  4677. * - `0` means the tag is self-closing
  4678. * - `-1` means the tag is closing
  4679. **/
  4680. this.nesting = nesting;
  4681. /**
  4682. * Token#level -> Number
  4683. *
  4684. * nesting level, the same as `state.level`
  4685. **/
  4686. this.level = 0;
  4687. /**
  4688. * Token#children -> Array
  4689. *
  4690. * An array of child nodes (inline and img tokens)
  4691. **/
  4692. this.children = null;
  4693. /**
  4694. * Token#content -> String
  4695. *
  4696. * In a case of self-closing tag (code, html, fence, etc.),
  4697. * it has contents of this tag.
  4698. **/
  4699. this.content = '';
  4700. /**
  4701. * Token#markup -> String
  4702. *
  4703. * '*' or '_' for emphasis, fence string for fence, etc.
  4704. **/
  4705. this.markup = '';
  4706. /**
  4707. * Token#info -> String
  4708. *
  4709. * fence infostring
  4710. **/
  4711. this.info = '';
  4712. /**
  4713. * Token#meta -> Object
  4714. *
  4715. * A place for plugins to store an arbitrary data
  4716. **/
  4717. this.meta = null;
  4718. /**
  4719. * Token#block -> Boolean
  4720. *
  4721. * True for block-level tokens, false for inline tokens.
  4722. * Used in renderer to calculate line breaks
  4723. **/
  4724. this.block = false;
  4725. /**
  4726. * Token#hidden -> Boolean
  4727. *
  4728. * If it's true, ignore this element when rendering. Used for tight lists
  4729. * to hide paragraphs.
  4730. **/
  4731. this.hidden = false;
  4732. }
  4733. /**
  4734. * Token.attrIndex(name) -> Number
  4735. *
  4736. * Search attribute index by name.
  4737. **/
  4738. Token.prototype.attrIndex = function attrIndex(name) {
  4739. var attrs, i, len;
  4740. if (!this.attrs) { return -1; }
  4741. attrs = this.attrs;
  4742. for (i = 0, len = attrs.length; i < len; i++) {
  4743. if (attrs[i][0] === name) { return i; }
  4744. }
  4745. return -1;
  4746. };
  4747. /**
  4748. * Token.attrPush(attrData)
  4749. *
  4750. * Add `[ name, value ]` attribute to list. Init attrs if necessary
  4751. **/
  4752. Token.prototype.attrPush = function attrPush(attrData) {
  4753. if (this.attrs) {
  4754. this.attrs.push(attrData);
  4755. } else {
  4756. this.attrs = [ attrData ];
  4757. }
  4758. };
  4759. /**
  4760. * Token.attrSet(name, value)
  4761. *
  4762. * Set `name` attribute to `value`. Override old value if exists.
  4763. **/
  4764. Token.prototype.attrSet = function attrSet(name, value) {
  4765. var idx = this.attrIndex(name),
  4766. attrData = [ name, value ];
  4767. if (idx < 0) {
  4768. this.attrPush(attrData);
  4769. } else {
  4770. this.attrs[idx] = attrData;
  4771. }
  4772. };
  4773. /**
  4774. * Token.attrGet(name)
  4775. *
  4776. * Get the value of attribute `name`, or null if it does not exist.
  4777. **/
  4778. Token.prototype.attrGet = function attrGet(name) {
  4779. var idx = this.attrIndex(name), value = null;
  4780. if (idx >= 0) {
  4781. value = this.attrs[idx][1];
  4782. }
  4783. return value;
  4784. };
  4785. /**
  4786. * Token.attrJoin(name, value)
  4787. *
  4788. * Join value to existing attribute via space. Or create new attribute if not
  4789. * exists. Useful to operate with token classes.
  4790. **/
  4791. Token.prototype.attrJoin = function attrJoin(name, value) {
  4792. var idx = this.attrIndex(name);
  4793. if (idx < 0) {
  4794. this.attrPush([ name, value ]);
  4795. } else {
  4796. this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value;
  4797. }
  4798. };
  4799. module.exports = Token;
  4800. },{}],52:[function(require,module,exports){
  4801. module.exports={"Aacute":"\u00C1","aacute":"\u00E1","Abreve":"\u0102","abreve":"\u0103","ac":"\u223E","acd":"\u223F","acE":"\u223E\u0333","Acirc":"\u00C2","acirc":"\u00E2","acute":"\u00B4","Acy":"\u0410","acy":"\u0430","AElig":"\u00C6","aelig":"\u00E6","af":"\u2061","Afr":"\uD835\uDD04","afr":"\uD835\uDD1E","Agrave":"\u00C0","agrave":"\u00E0","alefsym":"\u2135","aleph":"\u2135","Alpha":"\u0391","alpha":"\u03B1","Amacr":"\u0100","amacr":"\u0101","amalg":"\u2A3F","amp":"&","AMP":"&","andand":"\u2A55","And":"\u2A53","and":"\u2227","andd":"\u2A5C","andslope":"\u2A58","andv":"\u2A5A","ang":"\u2220","ange":"\u29A4","angle":"\u2220","angmsdaa":"\u29A8","angmsdab":"\u29A9","angmsdac":"\u29AA","angmsdad":"\u29AB","angmsdae":"\u29AC","angmsdaf":"\u29AD","angmsdag":"\u29AE","angmsdah":"\u29AF","angmsd":"\u2221","angrt":"\u221F","angrtvb":"\u22BE","angrtvbd":"\u299D","angsph":"\u2222","angst":"\u00C5","angzarr":"\u237C","Aogon":"\u0104","aogon":"\u0105","Aopf":"\uD835\uDD38","aopf":"\uD835\uDD52","apacir":"\u2A6F","ap":"\u2248","apE":"\u2A70","ape":"\u224A","apid":"\u224B","apos":"'","ApplyFunction":"\u2061","approx":"\u2248","approxeq":"\u224A","Aring":"\u00C5","aring":"\u00E5","Ascr":"\uD835\uDC9C","ascr":"\uD835\uDCB6","Assign":"\u2254","ast":"*","asymp":"\u2248","asympeq":"\u224D","Atilde":"\u00C3","atilde":"\u00E3","Auml":"\u00C4","auml":"\u00E4","awconint":"\u2233","awint":"\u2A11","backcong":"\u224C","backepsilon":"\u03F6","backprime":"\u2035","backsim":"\u223D","backsimeq":"\u22CD","Backslash":"\u2216","Barv":"\u2AE7","barvee":"\u22BD","barwed":"\u2305","Barwed":"\u2306","barwedge":"\u2305","bbrk":"\u23B5","bbrktbrk":"\u23B6","bcong":"\u224C","Bcy":"\u0411","bcy":"\u0431","bdquo":"\u201E","becaus":"\u2235","because":"\u2235","Because":"\u2235","bemptyv":"\u29B0","bepsi":"\u03F6","bernou":"\u212C","Bernoullis":"\u212C","Beta":"\u0392","beta":"\u03B2","beth":"\u2136","between":"\u226C","Bfr":"\uD835\uDD05","bfr":"\uD835\uDD1F","bigcap":"\u22C2","bigcirc":"\u25EF","bigcup":"\u22C3","bigodot":"\u2A00","bigoplus":"\u2A01","bigotimes":"\u2A02","bigsqcup":"\u2A06","bigstar":"\u2605","bigtriangledown":"\u25BD","bigtriangleup":"\u25B3","biguplus":"\u2A04","bigvee":"\u22C1","bigwedge":"\u22C0","bkarow":"\u290D","blacklozenge":"\u29EB","blacksquare":"\u25AA","blacktriangle":"\u25B4","blacktriangledown":"\u25BE","blacktriangleleft":"\u25C2","blacktriangleright":"\u25B8","blank":"\u2423","blk12":"\u2592","blk14":"\u2591","blk34":"\u2593","block":"\u2588","bne":"=\u20E5","bnequiv":"\u2261\u20E5","bNot":"\u2AED","bnot":"\u2310","Bopf":"\uD835\uDD39","bopf":"\uD835\uDD53","bot":"\u22A5","bottom":"\u22A5","bowtie":"\u22C8","boxbox":"\u29C9","boxdl":"\u2510","boxdL":"\u2555","boxDl":"\u2556","boxDL":"\u2557","boxdr":"\u250C","boxdR":"\u2552","boxDr":"\u2553","boxDR":"\u2554","boxh":"\u2500","boxH":"\u2550","boxhd":"\u252C","boxHd":"\u2564","boxhD":"\u2565","boxHD":"\u2566","boxhu":"\u2534","boxHu":"\u2567","boxhU":"\u2568","boxHU":"\u2569","boxminus":"\u229F","boxplus":"\u229E","boxtimes":"\u22A0","boxul":"\u2518","boxuL":"\u255B","boxUl":"\u255C","boxUL":"\u255D","boxur":"\u2514","boxuR":"\u2558","boxUr":"\u2559","boxUR":"\u255A","boxv":"\u2502","boxV":"\u2551","boxvh":"\u253C","boxvH":"\u256A","boxVh":"\u256B","boxVH":"\u256C","boxvl":"\u2524","boxvL":"\u2561","boxVl":"\u2562","boxVL":"\u2563","boxvr":"\u251C","boxvR":"\u255E","boxVr":"\u255F","boxVR":"\u2560","bprime":"\u2035","breve":"\u02D8","Breve":"\u02D8","brvbar":"\u00A6","bscr":"\uD835\uDCB7","Bscr":"\u212C","bsemi":"\u204F","bsim":"\u223D","bsime":"\u22CD","bsolb":"\u29C5","bsol":"\\","bsolhsub":"\u27C8","bull":"\u2022","bullet":"\u2022","bump":"\u224E","bumpE":"\u2AAE","bumpe":"\u224F","Bumpeq":"\u224E","bumpeq":"\u224F","Cacute":"\u0106","cacute":"\u0107","capand":"\u2A44","capbrcup":"\u2A49","capcap":"\u2A4B","cap":"\u2229","Cap":"\u22D2","capcup":"\u2A47","capdot":"\u2A40","CapitalDifferentialD":"\u2145","caps":"\u2229\uFE00","caret":"\u2041","caron":"\u02C7","Cayleys":"\u212D","ccaps":"\u2A4D","Ccaron":"\u010C","ccaron":"\u010D","Ccedil":"\u00C7","ccedil":"\u00E7","Ccirc":"\u0108","ccirc":"\u0109","Cconint":"\u2230","ccups":"\u2A4C","ccupssm":"\u2A50","Cdot":"\u010A","cdot":"\u010B","cedil":"\u00B8","Cedilla":"\u00B8","cemptyv":"\u29B2","cent":"\u00A2","centerdot":"\u00B7","CenterDot":"\u00B7","cfr":"\uD835\uDD20","Cfr":"\u212D","CHcy":"\u0427","chcy":"\u0447","check":"\u2713","checkmark":"\u2713","Chi":"\u03A7","chi":"\u03C7","circ":"\u02C6","circeq":"\u2257","circlearrowleft":"\u21BA","circlearrowright":"\u21BB","circledast":"\u229B","circledcirc":"\u229A","circleddash":"\u229D","CircleDot":"\u2299","circledR":"\u00AE","circledS":"\u24C8","CircleMinus":"\u2296","CirclePlus":"\u2295","CircleTimes":"\u2297","cir":"\u25CB","cirE":"\u29C3","cire":"\u2257","cirfnint":"\u2A10","cirmid":"\u2AEF","cirscir":"\u29C2","ClockwiseContourIntegral":"\u2232","CloseCurlyDoubleQuote":"\u201D","CloseCurlyQuote":"\u2019","clubs":"\u2663","clubsuit":"\u2663","colon":":","Colon":"\u2237","Colone":"\u2A74","colone":"\u2254","coloneq":"\u2254","comma":",","commat":"@","comp":"\u2201","compfn":"\u2218","complement":"\u2201","complexes":"\u2102","cong":"\u2245","congdot":"\u2A6D","Congruent":"\u2261","conint":"\u222E","Conint":"\u222F","ContourIntegral":"\u222E","copf":"\uD835\uDD54","Copf":"\u2102","coprod":"\u2210","Coproduct":"\u2210","copy":"\u00A9","COPY":"\u00A9","copysr":"\u2117","CounterClockwiseContourIntegral":"\u2233","crarr":"\u21B5","cross":"\u2717","Cross":"\u2A2F","Cscr":"\uD835\uDC9E","cscr":"\uD835\uDCB8","csub":"\u2ACF","csube":"\u2AD1","csup":"\u2AD0","csupe":"\u2AD2","ctdot":"\u22EF","cudarrl":"\u2938","cudarrr":"\u2935","cuepr":"\u22DE","cuesc":"\u22DF","cularr":"\u21B6","cularrp":"\u293D","cupbrcap":"\u2A48","cupcap":"\u2A46","CupCap":"\u224D","cup":"\u222A","Cup":"\u22D3","cupcup":"\u2A4A","cupdot":"\u228D","cupor":"\u2A45","cups":"\u222A\uFE00","curarr":"\u21B7","curarrm":"\u293C","curlyeqprec":"\u22DE","curlyeqsucc":"\u22DF","curlyvee":"\u22CE","curlywedge":"\u22CF","curren":"\u00A4","curvearrowleft":"\u21B6","curvearrowright":"\u21B7","cuvee":"\u22CE","cuwed":"\u22CF","cwconint":"\u2232","cwint":"\u2231","cylcty":"\u232D","dagger":"\u2020","Dagger":"\u2021","daleth":"\u2138","darr":"\u2193","Darr":"\u21A1","dArr":"\u21D3","dash":"\u2010","Dashv":"\u2AE4","dashv":"\u22A3","dbkarow":"\u290F","dblac":"\u02DD","Dcaron":"\u010E","dcaron":"\u010F","Dcy":"\u0414","dcy":"\u0434","ddagger":"\u2021","ddarr":"\u21CA","DD":"\u2145","dd":"\u2146","DDotrahd":"\u2911","ddotseq":"\u2A77","deg":"\u00B0","Del":"\u2207","Delta":"\u0394","delta":"\u03B4","demptyv":"\u29B1","dfisht":"\u297F","Dfr":"\uD835\uDD07","dfr":"\uD835\uDD21","dHar":"\u2965","dharl":"\u21C3","dharr":"\u21C2","DiacriticalAcute":"\u00B4","DiacriticalDot":"\u02D9","DiacriticalDoubleAcute":"\u02DD","DiacriticalGrave":"`","DiacriticalTilde":"\u02DC","diam":"\u22C4","diamond":"\u22C4","Diamond":"\u22C4","diamondsuit":"\u2666","diams":"\u2666","die":"\u00A8","DifferentialD":"\u2146","digamma":"\u03DD","disin":"\u22F2","div":"\u00F7","divide":"\u00F7","divideontimes":"\u22C7","divonx":"\u22C7","DJcy":"\u0402","djcy":"\u0452","dlcorn":"\u231E","dlcrop":"\u230D","dollar":"$","Dopf":"\uD835\uDD3B","dopf":"\uD835\uDD55","Dot":"\u00A8","dot":"\u02D9","DotDot":"\u20DC","doteq":"\u2250","doteqdot":"\u2251","DotEqual":"\u2250","dotminus":"\u2238","dotplus":"\u2214","dotsquare":"\u22A1","doublebarwedge":"\u2306","DoubleContourIntegral":"\u222F","DoubleDot":"\u00A8","DoubleDownArrow":"\u21D3","DoubleLeftArrow":"\u21D0","DoubleLeftRightArrow":"\u21D4","DoubleLeftTee":"\u2AE4","DoubleLongLeftArrow":"\u27F8","DoubleLongLeftRightArrow":"\u27FA","DoubleLongRightArrow":"\u27F9","DoubleRightArrow":"\u21D2","DoubleRightTee":"\u22A8","DoubleUpArrow":"\u21D1","DoubleUpDownArrow":"\u21D5","DoubleVerticalBar":"\u2225","DownArrowBar":"\u2913","downarrow":"\u2193","DownArrow":"\u2193","Downarrow":"\u21D3","DownArrowUpArrow":"\u21F5","DownBreve":"\u0311","downdownarrows":"\u21CA","downharpoonleft":"\u21C3","downharpoonright":"\u21C2","DownLeftRightVector":"\u2950","DownLeftTeeVector":"\u295E","DownLeftVectorBar":"\u2956","DownLeftVector":"\u21BD","DownRightTeeVector":"\u295F","DownRightVectorBar":"\u2957","DownRightVector":"\u21C1","DownTeeArrow":"\u21A7","DownTee":"\u22A4","drbkarow":"\u2910","drcorn":"\u231F","drcrop":"\u230C","Dscr":"\uD835\uDC9F","dscr":"\uD835\uDCB9","DScy":"\u0405","dscy":"\u0455","dsol":"\u29F6","Dstrok":"\u0110","dstrok":"\u0111","dtdot":"\u22F1","dtri":"\u25BF","dtrif":"\u25BE","duarr":"\u21F5","duhar":"\u296F","dwangle":"\u29A6","DZcy":"\u040F","dzcy":"\u045F","dzigrarr":"\u27FF","Eacute":"\u00C9","eacute":"\u00E9","easter":"\u2A6E","Ecaron":"\u011A","ecaron":"\u011B","Ecirc":"\u00CA","ecirc":"\u00EA","ecir":"\u2256","ecolon":"\u2255","Ecy":"\u042D","ecy":"\u044D","eDDot":"\u2A77","Edot":"\u0116","edot":"\u0117","eDot":"\u2251","ee":"\u2147","efDot":"\u2252","Efr":"\uD835\uDD08","efr":"\uD835\uDD22","eg":"\u2A9A","Egrave":"\u00C8","egrave":"\u00E8","egs":"\u2A96","egsdot":"\u2A98","el":"\u2A99","Element":"\u2208","elinters":"\u23E7","ell":"\u2113","els":"\u2A95","elsdot":"\u2A97","Emacr":"\u0112","emacr":"\u0113","empty":"\u2205","emptyset":"\u2205","EmptySmallSquare":"\u25FB","emptyv":"\u2205","EmptyVerySmallSquare":"\u25AB","emsp13":"\u2004","emsp14":"\u2005","emsp":"\u2003","ENG":"\u014A","eng":"\u014B","ensp":"\u2002","Eogon":"\u0118","eogon":"\u0119","Eopf":"\uD835\uDD3C","eopf":"\uD835\uDD56","epar":"\u22D5","eparsl":"\u29E3","eplus":"\u2A71","epsi":"\u03B5","Epsilon":"\u0395","epsilon":"\u03B5","epsiv":"\u03F5","eqcirc":"\u2256","eqcolon":"\u2255","eqsim":"\u2242","eqslantgtr":"\u2A96","eqslantless":"\u2A95","Equal":"\u2A75","equals":"=","EqualTilde":"\u2242","equest":"\u225F","Equilibrium":"\u21CC","equiv":"\u2261","equivDD":"\u2A78","eqvparsl":"\u29E5","erarr":"\u2971","erDot":"\u2253","escr":"\u212F","Escr":"\u2130","esdot":"\u2250","Esim":"\u2A73","esim":"\u2242","Eta":"\u0397","eta":"\u03B7","ETH":"\u00D0","eth":"\u00F0","Euml":"\u00CB","euml":"\u00EB","euro":"\u20AC","excl":"!","exist":"\u2203","Exists":"\u2203","expectation":"\u2130","exponentiale":"\u2147","ExponentialE":"\u2147","fallingdotseq":"\u2252","Fcy":"\u0424","fcy":"\u0444","female":"\u2640","ffilig":"\uFB03","fflig":"\uFB00","ffllig":"\uFB04","Ffr":"\uD835\uDD09","ffr":"\uD835\uDD23","filig":"\uFB01","FilledSmallSquare":"\u25FC","FilledVerySmallSquare":"\u25AA","fjlig":"fj","flat":"\u266D","fllig":"\uFB02","fltns":"\u25B1","fnof":"\u0192","Fopf":"\uD835\uDD3D","fopf":"\uD835\uDD57","forall":"\u2200","ForAll":"\u2200","fork":"\u22D4","forkv":"\u2AD9","Fouriertrf":"\u2131","fpartint":"\u2A0D","frac12":"\u00BD","frac13":"\u2153","frac14":"\u00BC","frac15":"\u2155","frac16":"\u2159","frac18":"\u215B","frac23":"\u2154","frac25":"\u2156","frac34":"\u00BE","frac35":"\u2157","frac38":"\u215C","frac45":"\u2158","frac56":"\u215A","frac58":"\u215D","frac78":"\u215E","frasl":"\u2044","frown":"\u2322","fscr":"\uD835\uDCBB","Fscr":"\u2131","gacute":"\u01F5","Gamma":"\u0393","gamma":"\u03B3","Gammad":"\u03DC","gammad":"\u03DD","gap":"\u2A86","Gbreve":"\u011E","gbreve":"\u011F","Gcedil":"\u0122","Gcirc":"\u011C","gcirc":"\u011D","Gcy":"\u0413","gcy":"\u0433","Gdot":"\u0120","gdot":"\u0121","ge":"\u2265","gE":"\u2267","gEl":"\u2A8C","gel":"\u22DB","geq":"\u2265","geqq":"\u2267","geqslant":"\u2A7E","gescc":"\u2AA9","ges":"\u2A7E","gesdot":"\u2A80","gesdoto":"\u2A82","gesdotol":"\u2A84","gesl":"\u22DB\uFE00","gesles":"\u2A94","Gfr":"\uD835\uDD0A","gfr":"\uD835\uDD24","gg":"\u226B","Gg":"\u22D9","ggg":"\u22D9","gimel":"\u2137","GJcy":"\u0403","gjcy":"\u0453","gla":"\u2AA5","gl":"\u2277","glE":"\u2A92","glj":"\u2AA4","gnap":"\u2A8A","gnapprox":"\u2A8A","gne":"\u2A88","gnE":"\u2269","gneq":"\u2A88","gneqq":"\u2269","gnsim":"\u22E7","Gopf":"\uD835\uDD3E","gopf":"\uD835\uDD58","grave":"`","GreaterEqual":"\u2265","GreaterEqualLess":"\u22DB","GreaterFullEqual":"\u2267","GreaterGreater":"\u2AA2","GreaterLess":"\u2277","GreaterSlantEqual":"\u2A7E","GreaterTilde":"\u2273","Gscr":"\uD835\uDCA2","gscr":"\u210A","gsim":"\u2273","gsime":"\u2A8E","gsiml":"\u2A90","gtcc":"\u2AA7","gtcir":"\u2A7A","gt":">","GT":">","Gt":"\u226B","gtdot":"\u22D7","gtlPar":"\u2995","gtquest":"\u2A7C","gtrapprox":"\u2A86","gtrarr":"\u2978","gtrdot":"\u22D7","gtreqless":"\u22DB","gtreqqless":"\u2A8C","gtrless":"\u2277","gtrsim":"\u2273","gvertneqq":"\u2269\uFE00","gvnE":"\u2269\uFE00","Hacek":"\u02C7","hairsp":"\u200A","half":"\u00BD","hamilt":"\u210B","HARDcy":"\u042A","hardcy":"\u044A","harrcir":"\u2948","harr":"\u2194","hArr":"\u21D4","harrw":"\u21AD","Hat":"^","hbar":"\u210F","Hcirc":"\u0124","hcirc":"\u0125","hearts":"\u2665","heartsuit":"\u2665","hellip":"\u2026","hercon":"\u22B9","hfr":"\uD835\uDD25","Hfr":"\u210C","HilbertSpace":"\u210B","hksearow":"\u2925","hkswarow":"\u2926","hoarr":"\u21FF","homtht":"\u223B","hookleftarrow":"\u21A9","hookrightarrow":"\u21AA","hopf":"\uD835\uDD59","Hopf":"\u210D","horbar":"\u2015","HorizontalLine":"\u2500","hscr":"\uD835\uDCBD","Hscr":"\u210B","hslash":"\u210F","Hstrok":"\u0126","hstrok":"\u0127","HumpDownHump":"\u224E","HumpEqual":"\u224F","hybull":"\u2043","hyphen":"\u2010","Iacute":"\u00CD","iacute":"\u00ED","ic":"\u2063","Icirc":"\u00CE","icirc":"\u00EE","Icy":"\u0418","icy":"\u0438","Idot":"\u0130","IEcy":"\u0415","iecy":"\u0435","iexcl":"\u00A1","iff":"\u21D4","ifr":"\uD835\uDD26","Ifr":"\u2111","Igrave":"\u00CC","igrave":"\u00EC","ii":"\u2148","iiiint":"\u2A0C","iiint":"\u222D","iinfin":"\u29DC","iiota":"\u2129","IJlig":"\u0132","ijlig":"\u0133","Imacr":"\u012A","imacr":"\u012B","image":"\u2111","ImaginaryI":"\u2148","imagline":"\u2110","imagpart":"\u2111","imath":"\u0131","Im":"\u2111","imof":"\u22B7","imped":"\u01B5","Implies":"\u21D2","incare":"\u2105","in":"\u2208","infin":"\u221E","infintie":"\u29DD","inodot":"\u0131","intcal":"\u22BA","int":"\u222B","Int":"\u222C","integers":"\u2124","Integral":"\u222B","intercal":"\u22BA","Intersection":"\u22C2","intlarhk":"\u2A17","intprod":"\u2A3C","InvisibleComma":"\u2063","InvisibleTimes":"\u2062","IOcy":"\u0401","iocy":"\u0451","Iogon":"\u012E","iogon":"\u012F","Iopf":"\uD835\uDD40","iopf":"\uD835\uDD5A","Iota":"\u0399","iota":"\u03B9","iprod":"\u2A3C","iquest":"\u00BF","iscr":"\uD835\uDCBE","Iscr":"\u2110","isin":"\u2208","isindot":"\u22F5","isinE":"\u22F9","isins":"\u22F4","isinsv":"\u22F3","isinv":"\u2208","it":"\u2062","Itilde":"\u0128","itilde":"\u0129","Iukcy":"\u0406","iukcy":"\u0456","Iuml":"\u00CF","iuml":"\u00EF","Jcirc":"\u0134","jcirc":"\u0135","Jcy":"\u0419","jcy":"\u0439","Jfr":"\uD835\uDD0D","jfr":"\uD835\uDD27","jmath":"\u0237","Jopf":"\uD835\uDD41","jopf":"\uD835\uDD5B","Jscr":"\uD835\uDCA5","jscr":"\uD835\uDCBF","Jsercy":"\u0408","jsercy":"\u0458","Jukcy":"\u0404","jukcy":"\u0454","Kappa":"\u039A","kappa":"\u03BA","kappav":"\u03F0","Kcedil":"\u0136","kcedil":"\u0137","Kcy":"\u041A","kcy":"\u043A","Kfr":"\uD835\uDD0E","kfr":"\uD835\uDD28","kgreen":"\u0138","KHcy":"\u0425","khcy":"\u0445","KJcy":"\u040C","kjcy":"\u045C","Kopf":"\uD835\uDD42","kopf":"\uD835\uDD5C","Kscr":"\uD835\uDCA6","kscr":"\uD835\uDCC0","lAarr":"\u21DA","Lacute":"\u0139","lacute":"\u013A","laemptyv":"\u29B4","lagran":"\u2112","Lambda":"\u039B","lambda":"\u03BB","lang":"\u27E8","Lang":"\u27EA","langd":"\u2991","langle":"\u27E8","lap":"\u2A85","Laplacetrf":"\u2112","laquo":"\u00AB","larrb":"\u21E4","larrbfs":"\u291F","larr":"\u2190","Larr":"\u219E","lArr":"\u21D0","larrfs":"\u291D","larrhk":"\u21A9","larrlp":"\u21AB","larrpl":"\u2939","larrsim":"\u2973","larrtl":"\u21A2","latail":"\u2919","lAtail":"\u291B","lat":"\u2AAB","late":"\u2AAD","lates":"\u2AAD\uFE00","lbarr":"\u290C","lBarr":"\u290E","lbbrk":"\u2772","lbrace":"{","lbrack":"[","lbrke":"\u298B","lbrksld":"\u298F","lbrkslu":"\u298D","Lcaron":"\u013D","lcaron":"\u013E","Lcedil":"\u013B","lcedil":"\u013C","lceil":"\u2308","lcub":"{","Lcy":"\u041B","lcy":"\u043B","ldca":"\u2936","ldquo":"\u201C","ldquor":"\u201E","ldrdhar":"\u2967","ldrushar":"\u294B","ldsh":"\u21B2","le":"\u2264","lE":"\u2266","LeftAngleBracket":"\u27E8","LeftArrowBar":"\u21E4","leftarrow":"\u2190","LeftArrow":"\u2190","Leftarrow":"\u21D0","LeftArrowRightArrow":"\u21C6","leftarrowtail":"\u21A2","LeftCeiling":"\u2308","LeftDoubleBracket":"\u27E6","LeftDownTeeVector":"\u2961","LeftDownVectorBar":"\u2959","LeftDownVector":"\u21C3","LeftFloor":"\u230A","leftharpoondown":"\u21BD","leftharpoonup":"\u21BC","leftleftarrows":"\u21C7","leftrightarrow":"\u2194","LeftRightArrow":"\u2194","Leftrightarrow":"\u21D4","leftrightarrows":"\u21C6","leftrightharpoons":"\u21CB","leftrightsquigarrow":"\u21AD","LeftRightVector":"\u294E","LeftTeeArrow":"\u21A4","LeftTee":"\u22A3","LeftTeeVector":"\u295A","leftthreetimes":"\u22CB","LeftTriangleBar":"\u29CF","LeftTriangle":"\u22B2","LeftTriangleEqual":"\u22B4","LeftUpDownVector":"\u2951","LeftUpTeeVector":"\u2960","LeftUpVectorBar":"\u2958","LeftUpVector":"\u21BF","LeftVectorBar":"\u2952","LeftVector":"\u21BC","lEg":"\u2A8B","leg":"\u22DA","leq":"\u2264","leqq":"\u2266","leqslant":"\u2A7D","lescc":"\u2AA8","les":"\u2A7D","lesdot":"\u2A7F","lesdoto":"\u2A81","lesdotor":"\u2A83","lesg":"\u22DA\uFE00","lesges":"\u2A93","lessapprox":"\u2A85","lessdot":"\u22D6","lesseqgtr":"\u22DA","lesseqqgtr":"\u2A8B","LessEqualGreater":"\u22DA","LessFullEqual":"\u2266","LessGreater":"\u2276","lessgtr":"\u2276","LessLess":"\u2AA1","lesssim":"\u2272","LessSlantEqual":"\u2A7D","LessTilde":"\u2272","lfisht":"\u297C","lfloor":"\u230A","Lfr":"\uD835\uDD0F","lfr":"\uD835\uDD29","lg":"\u2276","lgE":"\u2A91","lHar":"\u2962","lhard":"\u21BD","lharu":"\u21BC","lharul":"\u296A","lhblk":"\u2584","LJcy":"\u0409","ljcy":"\u0459","llarr":"\u21C7","ll":"\u226A","Ll":"\u22D8","llcorner":"\u231E","Lleftarrow":"\u21DA","llhard":"\u296B","lltri":"\u25FA","Lmidot":"\u013F","lmidot":"\u0140","lmoustache":"\u23B0","lmoust":"\u23B0","lnap":"\u2A89","lnapprox":"\u2A89","lne":"\u2A87","lnE":"\u2268","lneq":"\u2A87","lneqq":"\u2268","lnsim":"\u22E6","loang":"\u27EC","loarr":"\u21FD","lobrk":"\u27E6","longleftarrow":"\u27F5","LongLeftArrow":"\u27F5","Longleftarrow":"\u27F8","longleftrightarrow":"\u27F7","LongLeftRightArrow":"\u27F7","Longleftrightarrow":"\u27FA","longmapsto":"\u27FC","longrightarrow":"\u27F6","LongRightArrow":"\u27F6","Longrightarrow":"\u27F9","looparrowleft":"\u21AB","looparrowright":"\u21AC","lopar":"\u2985","Lopf":"\uD835\uDD43","lopf":"\uD835\uDD5D","loplus":"\u2A2D","lotimes":"\u2A34","lowast":"\u2217","lowbar":"_","LowerLeftArrow":"\u2199","LowerRightArrow":"\u2198","loz":"\u25CA","lozenge":"\u25CA","lozf":"\u29EB","lpar":"(","lparlt":"\u2993","lrarr":"\u21C6","lrcorner":"\u231F","lrhar":"\u21CB","lrhard":"\u296D","lrm":"\u200E","lrtri":"\u22BF","lsaquo":"\u2039","lscr":"\uD835\uDCC1","Lscr":"\u2112","lsh":"\u21B0","Lsh":"\u21B0","lsim":"\u2272","lsime":"\u2A8D","lsimg":"\u2A8F","lsqb":"[","lsquo":"\u2018","lsquor":"\u201A","Lstrok":"\u0141","lstrok":"\u0142","ltcc":"\u2AA6","ltcir":"\u2A79","lt":"<","LT":"<","Lt":"\u226A","ltdot":"\u22D6","lthree":"\u22CB","ltimes":"\u22C9","ltlarr":"\u2976","ltquest":"\u2A7B","ltri":"\u25C3","ltrie":"\u22B4","ltrif":"\u25C2","ltrPar":"\u2996","lurdshar":"\u294A","luruhar":"\u2966","lvertneqq":"\u2268\uFE00","lvnE":"\u2268\uFE00","macr":"\u00AF","male":"\u2642","malt":"\u2720","maltese":"\u2720","Map":"\u2905","map":"\u21A6","mapsto":"\u21A6","mapstodown":"\u21A7","mapstoleft":"\u21A4","mapstoup":"\u21A5","marker":"\u25AE","mcomma":"\u2A29","Mcy":"\u041C","mcy":"\u043C","mdash":"\u2014","mDDot":"\u223A","measuredangle":"\u2221","MediumSpace":"\u205F","Mellintrf":"\u2133","Mfr":"\uD835\uDD10","mfr":"\uD835\uDD2A","mho":"\u2127","micro":"\u00B5","midast":"*","midcir":"\u2AF0","mid":"\u2223","middot":"\u00B7","minusb":"\u229F","minus":"\u2212","minusd":"\u2238","minusdu":"\u2A2A","MinusPlus":"\u2213","mlcp":"\u2ADB","mldr":"\u2026","mnplus":"\u2213","models":"\u22A7","Mopf":"\uD835\uDD44","mopf":"\uD835\uDD5E","mp":"\u2213","mscr":"\uD835\uDCC2","Mscr":"\u2133","mstpos":"\u223E","Mu":"\u039C","mu":"\u03BC","multimap":"\u22B8","mumap":"\u22B8","nabla":"\u2207","Nacute":"\u0143","nacute":"\u0144","nang":"\u2220\u20D2","nap":"\u2249","napE":"\u2A70\u0338","napid":"\u224B\u0338","napos":"\u0149","napprox":"\u2249","natural":"\u266E","naturals":"\u2115","natur":"\u266E","nbsp":"\u00A0","nbump":"\u224E\u0338","nbumpe":"\u224F\u0338","ncap":"\u2A43","Ncaron":"\u0147","ncaron":"\u0148","Ncedil":"\u0145","ncedil":"\u0146","ncong":"\u2247","ncongdot":"\u2A6D\u0338","ncup":"\u2A42","Ncy":"\u041D","ncy":"\u043D","ndash":"\u2013","nearhk":"\u2924","nearr":"\u2197","neArr":"\u21D7","nearrow":"\u2197","ne":"\u2260","nedot":"\u2250\u0338","NegativeMediumSpace":"\u200B","NegativeThickSpace":"\u200B","NegativeThinSpace":"\u200B","NegativeVeryThinSpace":"\u200B","nequiv":"\u2262","nesear":"\u2928","nesim":"\u2242\u0338","NestedGreaterGreater":"\u226B","NestedLessLess":"\u226A","NewLine":"\n","nexist":"\u2204","nexists":"\u2204","Nfr":"\uD835\uDD11","nfr":"\uD835\uDD2B","ngE":"\u2267\u0338","nge":"\u2271","ngeq":"\u2271","ngeqq":"\u2267\u0338","ngeqslant":"\u2A7E\u0338","nges":"\u2A7E\u0338","nGg":"\u22D9\u0338","ngsim":"\u2275","nGt":"\u226B\u20D2","ngt":"\u226F","ngtr":"\u226F","nGtv":"\u226B\u0338","nharr":"\u21AE","nhArr":"\u21CE","nhpar":"\u2AF2","ni":"\u220B","nis":"\u22FC","nisd":"\u22FA","niv":"\u220B","NJcy":"\u040A","njcy":"\u045A","nlarr":"\u219A","nlArr":"\u21CD","nldr":"\u2025","nlE":"\u2266\u0338","nle":"\u2270","nleftarrow":"\u219A","nLeftarrow":"\u21CD","nleftrightarrow":"\u21AE","nLeftrightarrow":"\u21CE","nleq":"\u2270","nleqq":"\u2266\u0338","nleqslant":"\u2A7D\u0338","nles":"\u2A7D\u0338","nless":"\u226E","nLl":"\u22D8\u0338","nlsim":"\u2274","nLt":"\u226A\u20D2","nlt":"\u226E","nltri":"\u22EA","nltrie":"\u22EC","nLtv":"\u226A\u0338","nmid":"\u2224","NoBreak":"\u2060","NonBreakingSpace":"\u00A0","nopf":"\uD835\uDD5F","Nopf":"\u2115","Not":"\u2AEC","not":"\u00AC","NotCongruent":"\u2262","NotCupCap":"\u226D","NotDoubleVerticalBar":"\u2226","NotElement":"\u2209","NotEqual":"\u2260","NotEqualTilde":"\u2242\u0338","NotExists":"\u2204","NotGreater":"\u226F","NotGreaterEqual":"\u2271","NotGreaterFullEqual":"\u2267\u0338","NotGreaterGreater":"\u226B\u0338","NotGreaterLess":"\u2279","NotGreaterSlantEqual":"\u2A7E\u0338","NotGreaterTilde":"\u2275","NotHumpDownHump":"\u224E\u0338","NotHumpEqual":"\u224F\u0338","notin":"\u2209","notindot":"\u22F5\u0338","notinE":"\u22F9\u0338","notinva":"\u2209","notinvb":"\u22F7","notinvc":"\u22F6","NotLeftTriangleBar":"\u29CF\u0338","NotLeftTriangle":"\u22EA","NotLeftTriangleEqual":"\u22EC","NotLess":"\u226E","NotLessEqual":"\u2270","NotLessGreater":"\u2278","NotLessLess":"\u226A\u0338","NotLessSlantEqual":"\u2A7D\u0338","NotLessTilde":"\u2274","NotNestedGreaterGreater":"\u2AA2\u0338","NotNestedLessLess":"\u2AA1\u0338","notni":"\u220C","notniva":"\u220C","notnivb":"\u22FE","notnivc":"\u22FD","NotPrecedes":"\u2280","NotPrecedesEqual":"\u2AAF\u0338","NotPrecedesSlantEqual":"\u22E0","NotReverseElement":"\u220C","NotRightTriangleBar":"\u29D0\u0338","NotRightTriangle":"\u22EB","NotRightTriangleEqual":"\u22ED","NotSquareSubset":"\u228F\u0338","NotSquareSubsetEqual":"\u22E2","NotSquareSuperset":"\u2290\u0338","NotSquareSupersetEqual":"\u22E3","NotSubset":"\u2282\u20D2","NotSubsetEqual":"\u2288","NotSucceeds":"\u2281","NotSucceedsEqual":"\u2AB0\u0338","NotSucceedsSlantEqual":"\u22E1","NotSucceedsTilde":"\u227F\u0338","NotSuperset":"\u2283\u20D2","NotSupersetEqual":"\u2289","NotTilde":"\u2241","NotTildeEqual":"\u2244","NotTildeFullEqual":"\u2247","NotTildeTilde":"\u2249","NotVerticalBar":"\u2224","nparallel":"\u2226","npar":"\u2226","nparsl":"\u2AFD\u20E5","npart":"\u2202\u0338","npolint":"\u2A14","npr":"\u2280","nprcue":"\u22E0","nprec":"\u2280","npreceq":"\u2AAF\u0338","npre":"\u2AAF\u0338","nrarrc":"\u2933\u0338","nrarr":"\u219B","nrArr":"\u21CF","nrarrw":"\u219D\u0338","nrightarrow":"\u219B","nRightarrow":"\u21CF","nrtri":"\u22EB","nrtrie":"\u22ED","nsc":"\u2281","nsccue":"\u22E1","nsce":"\u2AB0\u0338","Nscr":"\uD835\uDCA9","nscr":"\uD835\uDCC3","nshortmid":"\u2224","nshortparallel":"\u2226","nsim":"\u2241","nsime":"\u2244","nsimeq":"\u2244","nsmid":"\u2224","nspar":"\u2226","nsqsube":"\u22E2","nsqsupe":"\u22E3","nsub":"\u2284","nsubE":"\u2AC5\u0338","nsube":"\u2288","nsubset":"\u2282\u20D2","nsubseteq":"\u2288","nsubseteqq":"\u2AC5\u0338","nsucc":"\u2281","nsucceq":"\u2AB0\u0338","nsup":"\u2285","nsupE":"\u2AC6\u0338","nsupe":"\u2289","nsupset":"\u2283\u20D2","nsupseteq":"\u2289","nsupseteqq":"\u2AC6\u0338","ntgl":"\u2279","Ntilde":"\u00D1","ntilde":"\u00F1","ntlg":"\u2278","ntriangleleft":"\u22EA","ntrianglelefteq":"\u22EC","ntriangleright":"\u22EB","ntrianglerighteq":"\u22ED","Nu":"\u039D","nu":"\u03BD","num":"#","numero":"\u2116","numsp":"\u2007","nvap":"\u224D\u20D2","nvdash":"\u22AC","nvDash":"\u22AD","nVdash":"\u22AE","nVDash":"\u22AF","nvge":"\u2265\u20D2","nvgt":">\u20D2","nvHarr":"\u2904","nvinfin":"\u29DE","nvlArr":"\u2902","nvle":"\u2264\u20D2","nvlt":"<\u20D2","nvltrie":"\u22B4\u20D2","nvrArr":"\u2903","nvrtrie":"\u22B5\u20D2","nvsim":"\u223C\u20D2","nwarhk":"\u2923","nwarr":"\u2196","nwArr":"\u21D6","nwarrow":"\u2196","nwnear":"\u2927","Oacute":"\u00D3","oacute":"\u00F3","oast":"\u229B","Ocirc":"\u00D4","ocirc":"\u00F4","ocir":"\u229A","Ocy":"\u041E","ocy":"\u043E","odash":"\u229D","Odblac":"\u0150","odblac":"\u0151","odiv":"\u2A38","odot":"\u2299","odsold":"\u29BC","OElig":"\u0152","oelig":"\u0153","ofcir":"\u29BF","Ofr":"\uD835\uDD12","ofr":"\uD835\uDD2C","ogon":"\u02DB","Ograve":"\u00D2","ograve":"\u00F2","ogt":"\u29C1","ohbar":"\u29B5","ohm":"\u03A9","oint":"\u222E","olarr":"\u21BA","olcir":"\u29BE","olcross":"\u29BB","oline":"\u203E","olt":"\u29C0","Omacr":"\u014C","omacr":"\u014D","Omega":"\u03A9","omega":"\u03C9","Omicron":"\u039F","omicron":"\u03BF","omid":"\u29B6","ominus":"\u2296","Oopf":"\uD835\uDD46","oopf":"\uD835\uDD60","opar":"\u29B7","OpenCurlyDoubleQuote":"\u201C","OpenCurlyQuote":"\u2018","operp":"\u29B9","oplus":"\u2295","orarr":"\u21BB","Or":"\u2A54","or":"\u2228","ord":"\u2A5D","order":"\u2134","orderof":"\u2134","ordf":"\u00AA","ordm":"\u00BA","origof":"\u22B6","oror":"\u2A56","orslope":"\u2A57","orv":"\u2A5B","oS":"\u24C8","Oscr":"\uD835\uDCAA","oscr":"\u2134","Oslash":"\u00D8","oslash":"\u00F8","osol":"\u2298","Otilde":"\u00D5","otilde":"\u00F5","otimesas":"\u2A36","Otimes":"\u2A37","otimes":"\u2297","Ouml":"\u00D6","ouml":"\u00F6","ovbar":"\u233D","OverBar":"\u203E","OverBrace":"\u23DE","OverBracket":"\u23B4","OverParenthesis":"\u23DC","para":"\u00B6","parallel":"\u2225","par":"\u2225","parsim":"\u2AF3","parsl":"\u2AFD","part":"\u2202","PartialD":"\u2202","Pcy":"\u041F","pcy":"\u043F","percnt":"%","period":".","permil":"\u2030","perp":"\u22A5","pertenk":"\u2031","Pfr":"\uD835\uDD13","pfr":"\uD835\uDD2D","Phi":"\u03A6","phi":"\u03C6","phiv":"\u03D5","phmmat":"\u2133","phone":"\u260E","Pi":"\u03A0","pi":"\u03C0","pitchfork":"\u22D4","piv":"\u03D6","planck":"\u210F","planckh":"\u210E","plankv":"\u210F","plusacir":"\u2A23","plusb":"\u229E","pluscir":"\u2A22","plus":"+","plusdo":"\u2214","plusdu":"\u2A25","pluse":"\u2A72","PlusMinus":"\u00B1","plusmn":"\u00B1","plussim":"\u2A26","plustwo":"\u2A27","pm":"\u00B1","Poincareplane":"\u210C","pointint":"\u2A15","popf":"\uD835\uDD61","Popf":"\u2119","pound":"\u00A3","prap":"\u2AB7","Pr":"\u2ABB","pr":"\u227A","prcue":"\u227C","precapprox":"\u2AB7","prec":"\u227A","preccurlyeq":"\u227C","Precedes":"\u227A","PrecedesEqual":"\u2AAF","PrecedesSlantEqual":"\u227C","PrecedesTilde":"\u227E","preceq":"\u2AAF","precnapprox":"\u2AB9","precneqq":"\u2AB5","precnsim":"\u22E8","pre":"\u2AAF","prE":"\u2AB3","precsim":"\u227E","prime":"\u2032","Prime":"\u2033","primes":"\u2119","prnap":"\u2AB9","prnE":"\u2AB5","prnsim":"\u22E8","prod":"\u220F","Product":"\u220F","profalar":"\u232E","profline":"\u2312","profsurf":"\u2313","prop":"\u221D","Proportional":"\u221D","Proportion":"\u2237","propto":"\u221D","prsim":"\u227E","prurel":"\u22B0","Pscr":"\uD835\uDCAB","pscr":"\uD835\uDCC5","Psi":"\u03A8","psi":"\u03C8","puncsp":"\u2008","Qfr":"\uD835\uDD14","qfr":"\uD835\uDD2E","qint":"\u2A0C","qopf":"\uD835\uDD62","Qopf":"\u211A","qprime":"\u2057","Qscr":"\uD835\uDCAC","qscr":"\uD835\uDCC6","quaternions":"\u210D","quatint":"\u2A16","quest":"?","questeq":"\u225F","quot":"\"","QUOT":"\"","rAarr":"\u21DB","race":"\u223D\u0331","Racute":"\u0154","racute":"\u0155","radic":"\u221A","raemptyv":"\u29B3","rang":"\u27E9","Rang":"\u27EB","rangd":"\u2992","range":"\u29A5","rangle":"\u27E9","raquo":"\u00BB","rarrap":"\u2975","rarrb":"\u21E5","rarrbfs":"\u2920","rarrc":"\u2933","rarr":"\u2192","Rarr":"\u21A0","rArr":"\u21D2","rarrfs":"\u291E","rarrhk":"\u21AA","rarrlp":"\u21AC","rarrpl":"\u2945","rarrsim":"\u2974","Rarrtl":"\u2916","rarrtl":"\u21A3","rarrw":"\u219D","ratail":"\u291A","rAtail":"\u291C","ratio":"\u2236","rationals":"\u211A","rbarr":"\u290D","rBarr":"\u290F","RBarr":"\u2910","rbbrk":"\u2773","rbrace":"}","rbrack":"]","rbrke":"\u298C","rbrksld":"\u298E","rbrkslu":"\u2990","Rcaron":"\u0158","rcaron":"\u0159","Rcedil":"\u0156","rcedil":"\u0157","rceil":"\u2309","rcub":"}","Rcy":"\u0420","rcy":"\u0440","rdca":"\u2937","rdldhar":"\u2969","rdquo":"\u201D","rdquor":"\u201D","rdsh":"\u21B3","real":"\u211C","realine":"\u211B","realpart":"\u211C","reals":"\u211D","Re":"\u211C","rect":"\u25AD","reg":"\u00AE","REG":"\u00AE","ReverseElement":"\u220B","ReverseEquilibrium":"\u21CB","ReverseUpEquilibrium":"\u296F","rfisht":"\u297D","rfloor":"\u230B","rfr":"\uD835\uDD2F","Rfr":"\u211C","rHar":"\u2964","rhard":"\u21C1","rharu":"\u21C0","rharul":"\u296C","Rho":"\u03A1","rho":"\u03C1","rhov":"\u03F1","RightAngleBracket":"\u27E9","RightArrowBar":"\u21E5","rightarrow":"\u2192","RightArrow":"\u2192","Rightarrow":"\u21D2","RightArrowLeftArrow":"\u21C4","rightarrowtail":"\u21A3","RightCeiling":"\u2309","RightDoubleBracket":"\u27E7","RightDownTeeVector":"\u295D","RightDownVectorBar":"\u2955","RightDownVector":"\u21C2","RightFloor":"\u230B","rightharpoondown":"\u21C1","rightharpoonup":"\u21C0","rightleftarrows":"\u21C4","rightleftharpoons":"\u21CC","rightrightarrows":"\u21C9","rightsquigarrow":"\u219D","RightTeeArrow":"\u21A6","RightTee":"\u22A2","RightTeeVector":"\u295B","rightthreetimes":"\u22CC","RightTriangleBar":"\u29D0","RightTriangle":"\u22B3","RightTriangleEqual":"\u22B5","RightUpDownVector":"\u294F","RightUpTeeVector":"\u295C","RightUpVectorBar":"\u2954","RightUpVector":"\u21BE","RightVectorBar":"\u2953","RightVector":"\u21C0","ring":"\u02DA","risingdotseq":"\u2253","rlarr":"\u21C4","rlhar":"\u21CC","rlm":"\u200F","rmoustache":"\u23B1","rmoust":"\u23B1","rnmid":"\u2AEE","roang":"\u27ED","roarr":"\u21FE","robrk":"\u27E7","ropar":"\u2986","ropf":"\uD835\uDD63","Ropf":"\u211D","roplus":"\u2A2E","rotimes":"\u2A35","RoundImplies":"\u2970","rpar":")","rpargt":"\u2994","rppolint":"\u2A12","rrarr":"\u21C9","Rrightarrow":"\u21DB","rsaquo":"\u203A","rscr":"\uD835\uDCC7","Rscr":"\u211B","rsh":"\u21B1","Rsh":"\u21B1","rsqb":"]","rsquo":"\u2019","rsquor":"\u2019","rthree":"\u22CC","rtimes":"\u22CA","rtri":"\u25B9","rtrie":"\u22B5","rtrif":"\u25B8","rtriltri":"\u29CE","RuleDelayed":"\u29F4","ruluhar":"\u2968","rx":"\u211E","Sacute":"\u015A","sacute":"\u015B","sbquo":"\u201A","scap":"\u2AB8","Scaron":"\u0160","scaron":"\u0161","Sc":"\u2ABC","sc":"\u227B","sccue":"\u227D","sce":"\u2AB0","scE":"\u2AB4","Scedil":"\u015E","scedil":"\u015F","Scirc":"\u015C","scirc":"\u015D","scnap":"\u2ABA","scnE":"\u2AB6","scnsim":"\u22E9","scpolint":"\u2A13","scsim":"\u227F","Scy":"\u0421","scy":"\u0441","sdotb":"\u22A1","sdot":"\u22C5","sdote":"\u2A66","searhk":"\u2925","searr":"\u2198","seArr":"\u21D8","searrow":"\u2198","sect":"\u00A7","semi":";","seswar":"\u2929","setminus":"\u2216","setmn":"\u2216","sext":"\u2736","Sfr":"\uD835\uDD16","sfr":"\uD835\uDD30","sfrown":"\u2322","sharp":"\u266F","SHCHcy":"\u0429","shchcy":"\u0449","SHcy":"\u0428","shcy":"\u0448","ShortDownArrow":"\u2193","ShortLeftArrow":"\u2190","shortmid":"\u2223","shortparallel":"\u2225","ShortRightArrow":"\u2192","ShortUpArrow":"\u2191","shy":"\u00AD","Sigma":"\u03A3","sigma":"\u03C3","sigmaf":"\u03C2","sigmav":"\u03C2","sim":"\u223C","simdot":"\u2A6A","sime":"\u2243","simeq":"\u2243","simg":"\u2A9E","simgE":"\u2AA0","siml":"\u2A9D","simlE":"\u2A9F","simne":"\u2246","simplus":"\u2A24","simrarr":"\u2972","slarr":"\u2190","SmallCircle":"\u2218","smallsetminus":"\u2216","smashp":"\u2A33","smeparsl":"\u29E4","smid":"\u2223","smile":"\u2323","smt":"\u2AAA","smte":"\u2AAC","smtes":"\u2AAC\uFE00","SOFTcy":"\u042C","softcy":"\u044C","solbar":"\u233F","solb":"\u29C4","sol":"/","Sopf":"\uD835\uDD4A","sopf":"\uD835\uDD64","spades":"\u2660","spadesuit":"\u2660","spar":"\u2225","sqcap":"\u2293","sqcaps":"\u2293\uFE00","sqcup":"\u2294","sqcups":"\u2294\uFE00","Sqrt":"\u221A","sqsub":"\u228F","sqsube":"\u2291","sqsubset":"\u228F","sqsubseteq":"\u2291","sqsup":"\u2290","sqsupe":"\u2292","sqsupset":"\u2290","sqsupseteq":"\u2292","square":"\u25A1","Square":"\u25A1","SquareIntersection":"\u2293","SquareSubset":"\u228F","SquareSubsetEqual":"\u2291","SquareSuperset":"\u2290","SquareSupersetEqual":"\u2292","SquareUnion":"\u2294","squarf":"\u25AA","squ":"\u25A1","squf":"\u25AA","srarr":"\u2192","Sscr":"\uD835\uDCAE","sscr":"\uD835\uDCC8","ssetmn":"\u2216","ssmile":"\u2323","sstarf":"\u22C6","Star":"\u22C6","star":"\u2606","starf":"\u2605","straightepsilon":"\u03F5","straightphi":"\u03D5","strns":"\u00AF","sub":"\u2282","Sub":"\u22D0","subdot":"\u2ABD","subE":"\u2AC5","sube":"\u2286","subedot":"\u2AC3","submult":"\u2AC1","subnE":"\u2ACB","subne":"\u228A","subplus":"\u2ABF","subrarr":"\u2979","subset":"\u2282","Subset":"\u22D0","subseteq":"\u2286","subseteqq":"\u2AC5","SubsetEqual":"\u2286","subsetneq":"\u228A","subsetneqq":"\u2ACB","subsim":"\u2AC7","subsub":"\u2AD5","subsup":"\u2AD3","succapprox":"\u2AB8","succ":"\u227B","succcurlyeq":"\u227D","Succeeds":"\u227B","SucceedsEqual":"\u2AB0","SucceedsSlantEqual":"\u227D","SucceedsTilde":"\u227F","succeq":"\u2AB0","succnapprox":"\u2ABA","succneqq":"\u2AB6","succnsim":"\u22E9","succsim":"\u227F","SuchThat":"\u220B","sum":"\u2211","Sum":"\u2211","sung":"\u266A","sup1":"\u00B9","sup2":"\u00B2","sup3":"\u00B3","sup":"\u2283","Sup":"\u22D1","supdot":"\u2ABE","supdsub":"\u2AD8","supE":"\u2AC6","supe":"\u2287","supedot":"\u2AC4","Superset":"\u2283","SupersetEqual":"\u2287","suphsol":"\u27C9","suphsub":"\u2AD7","suplarr":"\u297B","supmult":"\u2AC2","supnE":"\u2ACC","supne":"\u228B","supplus":"\u2AC0","supset":"\u2283","Supset":"\u22D1","supseteq":"\u2287","supseteqq":"\u2AC6","supsetneq":"\u228B","supsetneqq":"\u2ACC","supsim":"\u2AC8","supsub":"\u2AD4","supsup":"\u2AD6","swarhk":"\u2926","swarr":"\u2199","swArr":"\u21D9","swarrow":"\u2199","swnwar":"\u292A","szlig":"\u00DF","Tab":"\t","target":"\u2316","Tau":"\u03A4","tau":"\u03C4","tbrk":"\u23B4","Tcaron":"\u0164","tcaron":"\u0165","Tcedil":"\u0162","tcedil":"\u0163","Tcy":"\u0422","tcy":"\u0442","tdot":"\u20DB","telrec":"\u2315","Tfr":"\uD835\uDD17","tfr":"\uD835\uDD31","there4":"\u2234","therefore":"\u2234","Therefore":"\u2234","Theta":"\u0398","theta":"\u03B8","thetasym":"\u03D1","thetav":"\u03D1","thickapprox":"\u2248","thicksim":"\u223C","ThickSpace":"\u205F\u200A","ThinSpace":"\u2009","thinsp":"\u2009","thkap":"\u2248","thksim":"\u223C","THORN":"\u00DE","thorn":"\u00FE","tilde":"\u02DC","Tilde":"\u223C","TildeEqual":"\u2243","TildeFullEqual":"\u2245","TildeTilde":"\u2248","timesbar":"\u2A31","timesb":"\u22A0","times":"\u00D7","timesd":"\u2A30","tint":"\u222D","toea":"\u2928","topbot":"\u2336","topcir":"\u2AF1","top":"\u22A4","Topf":"\uD835\uDD4B","topf":"\uD835\uDD65","topfork":"\u2ADA","tosa":"\u2929","tprime":"\u2034","trade":"\u2122","TRADE":"\u2122","triangle":"\u25B5","triangledown":"\u25BF","triangleleft":"\u25C3","trianglelefteq":"\u22B4","triangleq":"\u225C","triangleright":"\u25B9","trianglerighteq":"\u22B5","tridot":"\u25EC","trie":"\u225C","triminus":"\u2A3A","TripleDot":"\u20DB","triplus":"\u2A39","trisb":"\u29CD","tritime":"\u2A3B","trpezium":"\u23E2","Tscr":"\uD835\uDCAF","tscr":"\uD835\uDCC9","TScy":"\u0426","tscy":"\u0446","TSHcy":"\u040B","tshcy":"\u045B","Tstrok":"\u0166","tstrok":"\u0167","twixt":"\u226C","twoheadleftarrow":"\u219E","twoheadrightarrow":"\u21A0","Uacute":"\u00DA","uacute":"\u00FA","uarr":"\u2191","Uarr":"\u219F","uArr":"\u21D1","Uarrocir":"\u2949","Ubrcy":"\u040E","ubrcy":"\u045E","Ubreve":"\u016C","ubreve":"\u016D","Ucirc":"\u00DB","ucirc":"\u00FB","Ucy":"\u0423","ucy":"\u0443","udarr":"\u21C5","Udblac":"\u0170","udblac":"\u0171","udhar":"\u296E","ufisht":"\u297E","Ufr":"\uD835\uDD18","ufr":"\uD835\uDD32","Ugrave":"\u00D9","ugrave":"\u00F9","uHar":"\u2963","uharl":"\u21BF","uharr":"\u21BE","uhblk":"\u2580","ulcorn":"\u231C","ulcorner":"\u231C","ulcrop":"\u230F","ultri":"\u25F8","Umacr":"\u016A","umacr":"\u016B","uml":"\u00A8","UnderBar":"_","UnderBrace":"\u23DF","UnderBracket":"\u23B5","UnderParenthesis":"\u23DD","Union":"\u22C3","UnionPlus":"\u228E","Uogon":"\u0172","uogon":"\u0173","Uopf":"\uD835\uDD4C","uopf":"\uD835\uDD66","UpArrowBar":"\u2912","uparrow":"\u2191","UpArrow":"\u2191","Uparrow":"\u21D1","UpArrowDownArrow":"\u21C5","updownarrow":"\u2195","UpDownArrow":"\u2195","Updownarrow":"\u21D5","UpEquilibrium":"\u296E","upharpoonleft":"\u21BF","upharpoonright":"\u21BE","uplus":"\u228E","UpperLeftArrow":"\u2196","UpperRightArrow":"\u2197","upsi":"\u03C5","Upsi":"\u03D2","upsih":"\u03D2","Upsilon":"\u03A5","upsilon":"\u03C5","UpTeeArrow":"\u21A5","UpTee":"\u22A5","upuparrows":"\u21C8","urcorn":"\u231D","urcorner":"\u231D","urcrop":"\u230E","Uring":"\u016E","uring":"\u016F","urtri":"\u25F9","Uscr":"\uD835\uDCB0","uscr":"\uD835\uDCCA","utdot":"\u22F0","Utilde":"\u0168","utilde":"\u0169","utri":"\u25B5","utrif":"\u25B4","uuarr":"\u21C8","Uuml":"\u00DC","uuml":"\u00FC","uwangle":"\u29A7","vangrt":"\u299C","varepsilon":"\u03F5","varkappa":"\u03F0","varnothing":"\u2205","varphi":"\u03D5","varpi":"\u03D6","varpropto":"\u221D","varr":"\u2195","vArr":"\u21D5","varrho":"\u03F1","varsigma":"\u03C2","varsubsetneq":"\u228A\uFE00","varsubsetneqq":"\u2ACB\uFE00","varsupsetneq":"\u228B\uFE00","varsupsetneqq":"\u2ACC\uFE00","vartheta":"\u03D1","vartriangleleft":"\u22B2","vartriangleright":"\u22B3","vBar":"\u2AE8","Vbar":"\u2AEB","vBarv":"\u2AE9","Vcy":"\u0412","vcy":"\u0432","vdash":"\u22A2","vDash":"\u22A8","Vdash":"\u22A9","VDash":"\u22AB","Vdashl":"\u2AE6","veebar":"\u22BB","vee":"\u2228","Vee":"\u22C1","veeeq":"\u225A","vellip":"\u22EE","verbar":"|","Verbar":"\u2016","vert":"|","Vert":"\u2016","VerticalBar":"\u2223","VerticalLine":"|","VerticalSeparator":"\u2758","VerticalTilde":"\u2240","VeryThinSpace":"\u200A","Vfr":"\uD835\uDD19","vfr":"\uD835\uDD33","vltri":"\u22B2","vnsub":"\u2282\u20D2","vnsup":"\u2283\u20D2","Vopf":"\uD835\uDD4D","vopf":"\uD835\uDD67","vprop":"\u221D","vrtri":"\u22B3","Vscr":"\uD835\uDCB1","vscr":"\uD835\uDCCB","vsubnE":"\u2ACB\uFE00","vsubne":"\u228A\uFE00","vsupnE":"\u2ACC\uFE00","vsupne":"\u228B\uFE00","Vvdash":"\u22AA","vzigzag":"\u299A","Wcirc":"\u0174","wcirc":"\u0175","wedbar":"\u2A5F","wedge":"\u2227","Wedge":"\u22C0","wedgeq":"\u2259","weierp":"\u2118","Wfr":"\uD835\uDD1A","wfr":"\uD835\uDD34","Wopf":"\uD835\uDD4E","wopf":"\uD835\uDD68","wp":"\u2118","wr":"\u2240","wreath":"\u2240","Wscr":"\uD835\uDCB2","wscr":"\uD835\uDCCC","xcap":"\u22C2","xcirc":"\u25EF","xcup":"\u22C3","xdtri":"\u25BD","Xfr":"\uD835\uDD1B","xfr":"\uD835\uDD35","xharr":"\u27F7","xhArr":"\u27FA","Xi":"\u039E","xi":"\u03BE","xlarr":"\u27F5","xlArr":"\u27F8","xmap":"\u27FC","xnis":"\u22FB","xodot":"\u2A00","Xopf":"\uD835\uDD4F","xopf":"\uD835\uDD69","xoplus":"\u2A01","xotime":"\u2A02","xrarr":"\u27F6","xrArr":"\u27F9","Xscr":"\uD835\uDCB3","xscr":"\uD835\uDCCD","xsqcup":"\u2A06","xuplus":"\u2A04","xutri":"\u25B3","xvee":"\u22C1","xwedge":"\u22C0","Yacute":"\u00DD","yacute":"\u00FD","YAcy":"\u042F","yacy":"\u044F","Ycirc":"\u0176","ycirc":"\u0177","Ycy":"\u042B","ycy":"\u044B","yen":"\u00A5","Yfr":"\uD835\uDD1C","yfr":"\uD835\uDD36","YIcy":"\u0407","yicy":"\u0457","Yopf":"\uD835\uDD50","yopf":"\uD835\uDD6A","Yscr":"\uD835\uDCB4","yscr":"\uD835\uDCCE","YUcy":"\u042E","yucy":"\u044E","yuml":"\u00FF","Yuml":"\u0178","Zacute":"\u0179","zacute":"\u017A","Zcaron":"\u017D","zcaron":"\u017E","Zcy":"\u0417","zcy":"\u0437","Zdot":"\u017B","zdot":"\u017C","zeetrf":"\u2128","ZeroWidthSpace":"\u200B","Zeta":"\u0396","zeta":"\u03B6","zfr":"\uD835\uDD37","Zfr":"\u2128","ZHcy":"\u0416","zhcy":"\u0436","zigrarr":"\u21DD","zopf":"\uD835\uDD6B","Zopf":"\u2124","Zscr":"\uD835\uDCB5","zscr":"\uD835\uDCCF","zwj":"\u200D","zwnj":"\u200C"}
  4802. },{}],53:[function(require,module,exports){
  4803. 'use strict';
  4804. ////////////////////////////////////////////////////////////////////////////////
  4805. // Helpers
  4806. // Merge objects
  4807. //
  4808. function assign(obj /*from1, from2, from3, ...*/) {
  4809. var sources = Array.prototype.slice.call(arguments, 1);
  4810. sources.forEach(function (source) {
  4811. if (!source) { return; }
  4812. Object.keys(source).forEach(function (key) {
  4813. obj[key] = source[key];
  4814. });
  4815. });
  4816. return obj;
  4817. }
  4818. function _class(obj) { return Object.prototype.toString.call(obj); }
  4819. function isString(obj) { return _class(obj) === '[object String]'; }
  4820. function isObject(obj) { return _class(obj) === '[object Object]'; }
  4821. function isRegExp(obj) { return _class(obj) === '[object RegExp]'; }
  4822. function isFunction(obj) { return _class(obj) === '[object Function]'; }
  4823. function escapeRE(str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&'); }
  4824. ////////////////////////////////////////////////////////////////////////////////
  4825. var defaultOptions = {
  4826. fuzzyLink: true,
  4827. fuzzyEmail: true,
  4828. fuzzyIP: false
  4829. };
  4830. function isOptionsObj(obj) {
  4831. return Object.keys(obj || {}).reduce(function (acc, k) {
  4832. return acc || defaultOptions.hasOwnProperty(k);
  4833. }, false);
  4834. }
  4835. var defaultSchemas = {
  4836. 'http:': {
  4837. validate: function (text, pos, self) {
  4838. var tail = text.slice(pos);
  4839. if (!self.re.http) {
  4840. // compile lazily, because "host"-containing variables can change on tlds update.
  4841. self.re.http = new RegExp(
  4842. '^\\/\\/' + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path, 'i'
  4843. );
  4844. }
  4845. if (self.re.http.test(tail)) {
  4846. return tail.match(self.re.http)[0].length;
  4847. }
  4848. return 0;
  4849. }
  4850. },
  4851. 'https:': 'http:',
  4852. 'ftp:': 'http:',
  4853. '//': {
  4854. validate: function (text, pos, self) {
  4855. var tail = text.slice(pos);
  4856. if (!self.re.no_http) {
  4857. // compile lazily, because "host"-containing variables can change on tlds update.
  4858. self.re.no_http = new RegExp(
  4859. '^' +
  4860. self.re.src_auth +
  4861. // Don't allow single-level domains, because of false positives like '//test'
  4862. // with code comments
  4863. '(?:localhost|(?:(?:' + self.re.src_domain + ')\\.)+' + self.re.src_domain_root + ')' +
  4864. self.re.src_port +
  4865. self.re.src_host_terminator +
  4866. self.re.src_path,
  4867. 'i'
  4868. );
  4869. }
  4870. if (self.re.no_http.test(tail)) {
  4871. // should not be `://` & `///`, that protects from errors in protocol name
  4872. if (pos >= 3 && text[pos - 3] === ':') { return 0; }
  4873. if (pos >= 3 && text[pos - 3] === '/') { return 0; }
  4874. return tail.match(self.re.no_http)[0].length;
  4875. }
  4876. return 0;
  4877. }
  4878. },
  4879. 'mailto:': {
  4880. validate: function (text, pos, self) {
  4881. var tail = text.slice(pos);
  4882. if (!self.re.mailto) {
  4883. self.re.mailto = new RegExp(
  4884. '^' + self.re.src_email_name + '@' + self.re.src_host_strict, 'i'
  4885. );
  4886. }
  4887. if (self.re.mailto.test(tail)) {
  4888. return tail.match(self.re.mailto)[0].length;
  4889. }
  4890. return 0;
  4891. }
  4892. }
  4893. };
  4894. /*eslint-disable max-len*/
  4895. // RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)
  4896. 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]';
  4897. // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
  4898. var tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
  4899. /*eslint-enable max-len*/
  4900. ////////////////////////////////////////////////////////////////////////////////
  4901. function resetScanCache(self) {
  4902. self.__index__ = -1;
  4903. self.__text_cache__ = '';
  4904. }
  4905. function createValidator(re) {
  4906. return function (text, pos) {
  4907. var tail = text.slice(pos);
  4908. if (re.test(tail)) {
  4909. return tail.match(re)[0].length;
  4910. }
  4911. return 0;
  4912. };
  4913. }
  4914. function createNormalizer() {
  4915. return function (match, self) {
  4916. self.normalize(match);
  4917. };
  4918. }
  4919. // Schemas compiler. Build regexps.
  4920. //
  4921. function compile(self) {
  4922. // Load & clone RE patterns.
  4923. var re = self.re = require('./lib/re')(self.__opts__);
  4924. // Define dynamic patterns
  4925. var tlds = self.__tlds__.slice();
  4926. self.onCompile();
  4927. if (!self.__tlds_replaced__) {
  4928. tlds.push(tlds_2ch_src_re);
  4929. }
  4930. tlds.push(re.src_xn);
  4931. re.src_tlds = tlds.join('|');
  4932. function untpl(tpl) { return tpl.replace('%TLDS%', re.src_tlds); }
  4933. re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');
  4934. re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');
  4935. re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i');
  4936. re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');
  4937. //
  4938. // Compile each schema
  4939. //
  4940. var aliases = [];
  4941. self.__compiled__ = {}; // Reset compiled data
  4942. function schemaError(name, val) {
  4943. throw new Error('(LinkifyIt) Invalid schema "' + name + '": ' + val);
  4944. }
  4945. Object.keys(self.__schemas__).forEach(function (name) {
  4946. var val = self.__schemas__[name];
  4947. // skip disabled methods
  4948. if (val === null) { return; }
  4949. var compiled = { validate: null, link: null };
  4950. self.__compiled__[name] = compiled;
  4951. if (isObject(val)) {
  4952. if (isRegExp(val.validate)) {
  4953. compiled.validate = createValidator(val.validate);
  4954. } else if (isFunction(val.validate)) {
  4955. compiled.validate = val.validate;
  4956. } else {
  4957. schemaError(name, val);
  4958. }
  4959. if (isFunction(val.normalize)) {
  4960. compiled.normalize = val.normalize;
  4961. } else if (!val.normalize) {
  4962. compiled.normalize = createNormalizer();
  4963. } else {
  4964. schemaError(name, val);
  4965. }
  4966. return;
  4967. }
  4968. if (isString(val)) {
  4969. aliases.push(name);
  4970. return;
  4971. }
  4972. schemaError(name, val);
  4973. });
  4974. //
  4975. // Compile postponed aliases
  4976. //
  4977. aliases.forEach(function (alias) {
  4978. if (!self.__compiled__[self.__schemas__[alias]]) {
  4979. // Silently fail on missed schemas to avoid errons on disable.
  4980. // schemaError(alias, self.__schemas__[alias]);
  4981. return;
  4982. }
  4983. self.__compiled__[alias].validate =
  4984. self.__compiled__[self.__schemas__[alias]].validate;
  4985. self.__compiled__[alias].normalize =
  4986. self.__compiled__[self.__schemas__[alias]].normalize;
  4987. });
  4988. //
  4989. // Fake record for guessed links
  4990. //
  4991. self.__compiled__[''] = { validate: null, normalize: createNormalizer() };
  4992. //
  4993. // Build schema condition
  4994. //
  4995. var slist = Object.keys(self.__compiled__)
  4996. .filter(function (name) {
  4997. // Filter disabled & fake schemas
  4998. return name.length > 0 && self.__compiled__[name];
  4999. })
  5000. .map(escapeRE)
  5001. .join('|');
  5002. // (?!_) cause 1.5x slowdown
  5003. self.re.schema_test = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'i');
  5004. self.re.schema_search = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'ig');
  5005. self.re.pretest = RegExp(
  5006. '(' + self.re.schema_test.source + ')|' +
  5007. '(' + self.re.host_fuzzy_test.source + ')|' +
  5008. '@',
  5009. 'i');
  5010. //
  5011. // Cleanup
  5012. //
  5013. resetScanCache(self);
  5014. }
  5015. /**
  5016. * class Match
  5017. *
  5018. * Match result. Single element of array, returned by [[LinkifyIt#match]]
  5019. **/
  5020. function Match(self, shift) {
  5021. var start = self.__index__,
  5022. end = self.__last_index__,
  5023. text = self.__text_cache__.slice(start, end);
  5024. /**
  5025. * Match#schema -> String
  5026. *
  5027. * Prefix (protocol) for matched string.
  5028. **/
  5029. this.schema = self.__schema__.toLowerCase();
  5030. /**
  5031. * Match#index -> Number
  5032. *
  5033. * First position of matched string.
  5034. **/
  5035. this.index = start + shift;
  5036. /**
  5037. * Match#lastIndex -> Number
  5038. *
  5039. * Next position after matched string.
  5040. **/
  5041. this.lastIndex = end + shift;
  5042. /**
  5043. * Match#raw -> String
  5044. *
  5045. * Matched string.
  5046. **/
  5047. this.raw = text;
  5048. /**
  5049. * Match#text -> String
  5050. *
  5051. * Notmalized text of matched string.
  5052. **/
  5053. this.text = text;
  5054. /**
  5055. * Match#url -> String
  5056. *
  5057. * Normalized url of matched string.
  5058. **/
  5059. this.url = text;
  5060. }
  5061. function createMatch(self, shift) {
  5062. var match = new Match(self, shift);
  5063. self.__compiled__[match.schema].normalize(match, self);
  5064. return match;
  5065. }
  5066. /**
  5067. * class LinkifyIt
  5068. **/
  5069. /**
  5070. * new LinkifyIt(schemas, options)
  5071. * - schemas (Object): Optional. Additional schemas to validate (prefix/validator)
  5072. * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
  5073. *
  5074. * Creates new linkifier instance with optional additional schemas.
  5075. * Can be called without `new` keyword for convenience.
  5076. *
  5077. * By default understands:
  5078. *
  5079. * - `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links
  5080. * - "fuzzy" links and emails (example.com, foo@bar.com).
  5081. *
  5082. * `schemas` is an object, where each key/value describes protocol/rule:
  5083. *
  5084. * - __key__ - link prefix (usually, protocol name with `:` at the end, `skype:`
  5085. * for example). `linkify-it` makes shure that prefix is not preceeded with
  5086. * alphanumeric char and symbols. Only whitespaces and punctuation allowed.
  5087. * - __value__ - rule to check tail after link prefix
  5088. * - _String_ - just alias to existing rule
  5089. * - _Object_
  5090. * - _validate_ - validator function (should return matched length on success),
  5091. * or `RegExp`.
  5092. * - _normalize_ - optional function to normalize text & url of matched result
  5093. * (for example, for @twitter mentions).
  5094. *
  5095. * `options`:
  5096. *
  5097. * - __fuzzyLink__ - recognige URL-s without `http(s):` prefix. Default `true`.
  5098. * - __fuzzyIP__ - allow IPs in fuzzy links above. Can conflict with some texts
  5099. * like version numbers. Default `false`.
  5100. * - __fuzzyEmail__ - recognize emails without `mailto:` prefix.
  5101. *
  5102. **/
  5103. function LinkifyIt(schemas, options) {
  5104. if (!(this instanceof LinkifyIt)) {
  5105. return new LinkifyIt(schemas, options);
  5106. }
  5107. if (!options) {
  5108. if (isOptionsObj(schemas)) {
  5109. options = schemas;
  5110. schemas = {};
  5111. }
  5112. }
  5113. this.__opts__ = assign({}, defaultOptions, options);
  5114. // Cache last tested result. Used to skip repeating steps on next `match` call.
  5115. this.__index__ = -1;
  5116. this.__last_index__ = -1; // Next scan position
  5117. this.__schema__ = '';
  5118. this.__text_cache__ = '';
  5119. this.__schemas__ = assign({}, defaultSchemas, schemas);
  5120. this.__compiled__ = {};
  5121. this.__tlds__ = tlds_default;
  5122. this.__tlds_replaced__ = false;
  5123. this.re = {};
  5124. compile(this);
  5125. }
  5126. /** chainable
  5127. * LinkifyIt#add(schema, definition)
  5128. * - schema (String): rule name (fixed pattern prefix)
  5129. * - definition (String|RegExp|Object): schema definition
  5130. *
  5131. * Add new rule definition. See constructor description for details.
  5132. **/
  5133. LinkifyIt.prototype.add = function add(schema, definition) {
  5134. this.__schemas__[schema] = definition;
  5135. compile(this);
  5136. return this;
  5137. };
  5138. /** chainable
  5139. * LinkifyIt#set(options)
  5140. * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
  5141. *
  5142. * Set recognition options for links without schema.
  5143. **/
  5144. LinkifyIt.prototype.set = function set(options) {
  5145. this.__opts__ = assign(this.__opts__, options);
  5146. return this;
  5147. };
  5148. /**
  5149. * LinkifyIt#test(text) -> Boolean
  5150. *
  5151. * Searches linkifiable pattern and returns `true` on success or `false` on fail.
  5152. **/
  5153. LinkifyIt.prototype.test = function test(text) {
  5154. // Reset scan cache
  5155. this.__text_cache__ = text;
  5156. this.__index__ = -1;
  5157. if (!text.length) { return false; }
  5158. var m, ml, me, len, shift, next, re, tld_pos, at_pos;
  5159. // try to scan for link with schema - that's the most simple rule
  5160. if (this.re.schema_test.test(text)) {
  5161. re = this.re.schema_search;
  5162. re.lastIndex = 0;
  5163. while ((m = re.exec(text)) !== null) {
  5164. len = this.testSchemaAt(text, m[2], re.lastIndex);
  5165. if (len) {
  5166. this.__schema__ = m[2];
  5167. this.__index__ = m.index + m[1].length;
  5168. this.__last_index__ = m.index + m[0].length + len;
  5169. break;
  5170. }
  5171. }
  5172. }
  5173. if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
  5174. // guess schemaless links
  5175. tld_pos = text.search(this.re.host_fuzzy_test);
  5176. if (tld_pos >= 0) {
  5177. // if tld is located after found link - no need to check fuzzy pattern
  5178. if (this.__index__ < 0 || tld_pos < this.__index__) {
  5179. if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
  5180. shift = ml.index + ml[1].length;
  5181. if (this.__index__ < 0 || shift < this.__index__) {
  5182. this.__schema__ = '';
  5183. this.__index__ = shift;
  5184. this.__last_index__ = ml.index + ml[0].length;
  5185. }
  5186. }
  5187. }
  5188. }
  5189. }
  5190. if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
  5191. // guess schemaless emails
  5192. at_pos = text.indexOf('@');
  5193. if (at_pos >= 0) {
  5194. // We can't skip this check, because this cases are possible:
  5195. // 192.168.1.1@gmail.com, my.in@example.com
  5196. if ((me = text.match(this.re.email_fuzzy)) !== null) {
  5197. shift = me.index + me[1].length;
  5198. next = me.index + me[0].length;
  5199. if (this.__index__ < 0 || shift < this.__index__ ||
  5200. (shift === this.__index__ && next > this.__last_index__)) {
  5201. this.__schema__ = 'mailto:';
  5202. this.__index__ = shift;
  5203. this.__last_index__ = next;
  5204. }
  5205. }
  5206. }
  5207. }
  5208. return this.__index__ >= 0;
  5209. };
  5210. /**
  5211. * LinkifyIt#pretest(text) -> Boolean
  5212. *
  5213. * Very quick check, that can give false positives. Returns true if link MAY BE
  5214. * can exists. Can be used for speed optimization, when you need to check that
  5215. * link NOT exists.
  5216. **/
  5217. LinkifyIt.prototype.pretest = function pretest(text) {
  5218. return this.re.pretest.test(text);
  5219. };
  5220. /**
  5221. * LinkifyIt#testSchemaAt(text, name, position) -> Number
  5222. * - text (String): text to scan
  5223. * - name (String): rule (schema) name
  5224. * - position (Number): text offset to check from
  5225. *
  5226. * Similar to [[LinkifyIt#test]] but checks only specific protocol tail exactly
  5227. * at given position. Returns length of found pattern (0 on fail).
  5228. **/
  5229. LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {
  5230. // If not supported schema check requested - terminate
  5231. if (!this.__compiled__[schema.toLowerCase()]) {
  5232. return 0;
  5233. }
  5234. return this.__compiled__[schema.toLowerCase()].validate(text, pos, this);
  5235. };
  5236. /**
  5237. * LinkifyIt#match(text) -> Array|null
  5238. *
  5239. * Returns array of found link descriptions or `null` on fail. We strongly
  5240. * recommend to use [[LinkifyIt#test]] first, for best speed.
  5241. *
  5242. * ##### Result match description
  5243. *
  5244. * - __schema__ - link schema, can be empty for fuzzy links, or `//` for
  5245. * protocol-neutral links.
  5246. * - __index__ - offset of matched text
  5247. * - __lastIndex__ - index of next char after mathch end
  5248. * - __raw__ - matched text
  5249. * - __text__ - normalized text
  5250. * - __url__ - link, generated from matched text
  5251. **/
  5252. LinkifyIt.prototype.match = function match(text) {
  5253. var shift = 0, result = [];
  5254. // Try to take previous element from cache, if .test() called before
  5255. if (this.__index__ >= 0 && this.__text_cache__ === text) {
  5256. result.push(createMatch(this, shift));
  5257. shift = this.__last_index__;
  5258. }
  5259. // Cut head if cache was used
  5260. var tail = shift ? text.slice(shift) : text;
  5261. // Scan string until end reached
  5262. while (this.test(tail)) {
  5263. result.push(createMatch(this, shift));
  5264. tail = tail.slice(this.__last_index__);
  5265. shift += this.__last_index__;
  5266. }
  5267. if (result.length) {
  5268. return result;
  5269. }
  5270. return null;
  5271. };
  5272. /** chainable
  5273. * LinkifyIt#tlds(list [, keepOld]) -> this
  5274. * - list (Array): list of tlds
  5275. * - keepOld (Boolean): merge with current list if `true` (`false` by default)
  5276. *
  5277. * Load (or merge) new tlds list. Those are user for fuzzy links (without prefix)
  5278. * to avoid false positives. By default this algorythm used:
  5279. *
  5280. * - hostname with any 2-letter root zones are ok.
  5281. * - biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф
  5282. * are ok.
  5283. * - encoded (`xn--...`) root zones are ok.
  5284. *
  5285. * If list is replaced, then exact match for 2-chars root zones will be checked.
  5286. **/
  5287. LinkifyIt.prototype.tlds = function tlds(list, keepOld) {
  5288. list = Array.isArray(list) ? list : [ list ];
  5289. if (!keepOld) {
  5290. this.__tlds__ = list.slice();
  5291. this.__tlds_replaced__ = true;
  5292. compile(this);
  5293. return this;
  5294. }
  5295. this.__tlds__ = this.__tlds__.concat(list)
  5296. .sort()
  5297. .filter(function (el, idx, arr) {
  5298. return el !== arr[idx - 1];
  5299. })
  5300. .reverse();
  5301. compile(this);
  5302. return this;
  5303. };
  5304. /**
  5305. * LinkifyIt#normalize(match)
  5306. *
  5307. * Default normalizer (if schema does not define it's own).
  5308. **/
  5309. LinkifyIt.prototype.normalize = function normalize(match) {
  5310. // Do minimal possible changes by default. Need to collect feedback prior
  5311. // to move forward https://github.com/markdown-it/linkify-it/issues/1
  5312. if (!match.schema) { match.url = 'http://' + match.url; }
  5313. if (match.schema === 'mailto:' && !/^mailto:/i.test(match.url)) {
  5314. match.url = 'mailto:' + match.url;
  5315. }
  5316. };
  5317. /**
  5318. * LinkifyIt#onCompile()
  5319. *
  5320. * Override to modify basic RegExp-s.
  5321. **/
  5322. LinkifyIt.prototype.onCompile = function onCompile() {
  5323. };
  5324. module.exports = LinkifyIt;
  5325. },{"./lib/re":54}],54:[function(require,module,exports){
  5326. 'use strict';
  5327. module.exports = function (opts) {
  5328. var re = {};
  5329. // Use direct extract instead of `regenerate` to reduse browserified size
  5330. re.src_Any = require('uc.micro/properties/Any/regex').source;
  5331. re.src_Cc = require('uc.micro/categories/Cc/regex').source;
  5332. re.src_Z = require('uc.micro/categories/Z/regex').source;
  5333. re.src_P = require('uc.micro/categories/P/regex').source;
  5334. // \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation)
  5335. re.src_ZPCc = [ re.src_Z, re.src_P, re.src_Cc ].join('|');
  5336. // \p{\Z\Cc} (white spaces + control)
  5337. re.src_ZCc = [ re.src_Z, re.src_Cc ].join('|');
  5338. // Experimental. List of chars, completely prohibited in links
  5339. // because can separate it from other part of text
  5340. var text_separators = '[><\uff5c]';
  5341. // All possible word characters (everything without punctuation, spaces & controls)
  5342. // Defined via punctuation & spaces to save space
  5343. // Should be something like \p{\L\N\S\M} (\w but without `_`)
  5344. re.src_pseudo_letter = '(?:(?!' + text_separators + '|' + re.src_ZPCc + ')' + re.src_Any + ')';
  5345. // The same as abothe but without [0-9]
  5346. // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
  5347. ////////////////////////////////////////////////////////////////////////////////
  5348. re.src_ip4 =
  5349. '(?:(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]?)';
  5350. // Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
  5351. re.src_auth = '(?:(?:(?!' + re.src_ZCc + '|[@/\\[\\]()]).)+@)?';
  5352. re.src_port =
  5353. '(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?';
  5354. re.src_host_terminator =
  5355. '(?=$|' + text_separators + '|' + re.src_ZPCc + ')(?!-|_|:\\d|\\.-|\\.(?!$|' + re.src_ZPCc + '))';
  5356. re.src_path =
  5357. '(?:' +
  5358. '[/?#]' +
  5359. '(?:' +
  5360. '(?!' + re.src_ZCc + '|' + text_separators + '|[()[\\]{}.,"\'?!\\-]).|' +
  5361. '\\[(?:(?!' + re.src_ZCc + '|\\]).)*\\]|' +
  5362. '\\((?:(?!' + re.src_ZCc + '|[)]).)*\\)|' +
  5363. '\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}|' +
  5364. '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' +
  5365. "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" +
  5366. "\\'(?=" + re.src_pseudo_letter + '|[-]).|' + // allow `I'm_king` if no pair found
  5367. '\\.{2,3}[a-zA-Z0-9%/]|' + // github has ... in commit range links. Restrict to
  5368. // - english
  5369. // - percent-encoded
  5370. // - parts of file path
  5371. // until more examples found.
  5372. '\\.(?!' + re.src_ZCc + '|[.]).|' +
  5373. (opts && opts['---'] ?
  5374. '\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate
  5375. :
  5376. '\\-+|'
  5377. ) +
  5378. '\\,(?!' + re.src_ZCc + ').|' + // allow `,,,` in paths
  5379. '\\!(?!' + re.src_ZCc + '|[!]).|' +
  5380. '\\?(?!' + re.src_ZCc + '|[?]).' +
  5381. ')+' +
  5382. '|\\/' +
  5383. ')?';
  5384. re.src_email_name =
  5385. '[\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]+';
  5386. re.src_xn =
  5387. 'xn--[a-z0-9\\-]{1,59}';
  5388. // More to read about domain names
  5389. // http://serverfault.com/questions/638260/
  5390. re.src_domain_root =
  5391. // Allow letters & digits (http://test1)
  5392. '(?:' +
  5393. re.src_xn +
  5394. '|' +
  5395. re.src_pseudo_letter + '{1,63}' +
  5396. ')';
  5397. re.src_domain =
  5398. '(?:' +
  5399. re.src_xn +
  5400. '|' +
  5401. '(?:' + re.src_pseudo_letter + ')' +
  5402. '|' +
  5403. // don't allow `--` in domain names, because:
  5404. // - that can conflict with markdown &mdash; / &ndash;
  5405. // - nobody use those anyway
  5406. '(?:' + re.src_pseudo_letter + '(?:-(?!-)|' + re.src_pseudo_letter + '){0,61}' + re.src_pseudo_letter + ')' +
  5407. ')';
  5408. re.src_host =
  5409. '(?:' +
  5410. // Don't need IP check, because digits are already allowed in normal domain names
  5411. // src_ip4 +
  5412. // '|' +
  5413. '(?:(?:(?:' + re.src_domain + ')\\.)*' + re.src_domain/*_root*/ + ')' +
  5414. ')';
  5415. re.tpl_host_fuzzy =
  5416. '(?:' +
  5417. re.src_ip4 +
  5418. '|' +
  5419. '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))' +
  5420. ')';
  5421. re.tpl_host_no_ip_fuzzy =
  5422. '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))';
  5423. re.src_host_strict =
  5424. re.src_host + re.src_host_terminator;
  5425. re.tpl_host_fuzzy_strict =
  5426. re.tpl_host_fuzzy + re.src_host_terminator;
  5427. re.src_host_port_strict =
  5428. re.src_host + re.src_port + re.src_host_terminator;
  5429. re.tpl_host_port_fuzzy_strict =
  5430. re.tpl_host_fuzzy + re.src_port + re.src_host_terminator;
  5431. re.tpl_host_port_no_ip_fuzzy_strict =
  5432. re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
  5433. ////////////////////////////////////////////////////////////////////////////////
  5434. // Main rules
  5435. // Rude test fuzzy links by host, for quick deny
  5436. re.tpl_host_fuzzy_test =
  5437. 'localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:' + re.src_ZPCc + '|>|$))';
  5438. re.tpl_email_fuzzy =
  5439. '(^|' + text_separators + '|\\(|' + re.src_ZCc + ')(' + re.src_email_name + '@' + re.tpl_host_fuzzy_strict + ')';
  5440. re.tpl_link_fuzzy =
  5441. // Fuzzy link can't be prepended with .:/\- and non punctuation.
  5442. // but can start with > (markdown blockquote)
  5443. '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
  5444. '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_fuzzy_strict + re.src_path + ')';
  5445. re.tpl_link_no_ip_fuzzy =
  5446. // Fuzzy link can't be prepended with .:/\- and non punctuation.
  5447. // but can start with > (markdown blockquote)
  5448. '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
  5449. '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ')';
  5450. return re;
  5451. };
  5452. },{"uc.micro/categories/Cc/regex":61,"uc.micro/categories/P/regex":63,"uc.micro/categories/Z/regex":64,"uc.micro/properties/Any/regex":66}],55:[function(require,module,exports){
  5453. 'use strict';
  5454. /* eslint-disable no-bitwise */
  5455. var decodeCache = {};
  5456. function getDecodeCache(exclude) {
  5457. var i, ch, cache = decodeCache[exclude];
  5458. if (cache) { return cache; }
  5459. cache = decodeCache[exclude] = [];
  5460. for (i = 0; i < 128; i++) {
  5461. ch = String.fromCharCode(i);
  5462. cache.push(ch);
  5463. }
  5464. for (i = 0; i < exclude.length; i++) {
  5465. ch = exclude.charCodeAt(i);
  5466. cache[ch] = '%' + ('0' + ch.toString(16).toUpperCase()).slice(-2);
  5467. }
  5468. return cache;
  5469. }
  5470. // Decode percent-encoded string.
  5471. //
  5472. function decode(string, exclude) {
  5473. var cache;
  5474. if (typeof exclude !== 'string') {
  5475. exclude = decode.defaultChars;
  5476. }
  5477. cache = getDecodeCache(exclude);
  5478. return string.replace(/(%[a-f0-9]{2})+/gi, function(seq) {
  5479. var i, l, b1, b2, b3, b4, chr,
  5480. result = '';
  5481. for (i = 0, l = seq.length; i < l; i += 3) {
  5482. b1 = parseInt(seq.slice(i + 1, i + 3), 16);
  5483. if (b1 < 0x80) {
  5484. result += cache[b1];
  5485. continue;
  5486. }
  5487. if ((b1 & 0xE0) === 0xC0 && (i + 3 < l)) {
  5488. // 110xxxxx 10xxxxxx
  5489. b2 = parseInt(seq.slice(i + 4, i + 6), 16);
  5490. if ((b2 & 0xC0) === 0x80) {
  5491. chr = ((b1 << 6) & 0x7C0) | (b2 & 0x3F);
  5492. if (chr < 0x80) {
  5493. result += '\ufffd\ufffd';
  5494. } else {
  5495. result += String.fromCharCode(chr);
  5496. }
  5497. i += 3;
  5498. continue;
  5499. }
  5500. }
  5501. if ((b1 & 0xF0) === 0xE0 && (i + 6 < l)) {
  5502. // 1110xxxx 10xxxxxx 10xxxxxx
  5503. b2 = parseInt(seq.slice(i + 4, i + 6), 16);
  5504. b3 = parseInt(seq.slice(i + 7, i + 9), 16);
  5505. if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {
  5506. chr = ((b1 << 12) & 0xF000) | ((b2 << 6) & 0xFC0) | (b3 & 0x3F);
  5507. if (chr < 0x800 || (chr >= 0xD800 && chr <= 0xDFFF)) {
  5508. result += '\ufffd\ufffd\ufffd';
  5509. } else {
  5510. result += String.fromCharCode(chr);
  5511. }
  5512. i += 6;
  5513. continue;
  5514. }
  5515. }
  5516. if ((b1 & 0xF8) === 0xF0 && (i + 9 < l)) {
  5517. // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx
  5518. b2 = parseInt(seq.slice(i + 4, i + 6), 16);
  5519. b3 = parseInt(seq.slice(i + 7, i + 9), 16);
  5520. b4 = parseInt(seq.slice(i + 10, i + 12), 16);
  5521. if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80 && (b4 & 0xC0) === 0x80) {
  5522. chr = ((b1 << 18) & 0x1C0000) | ((b2 << 12) & 0x3F000) | ((b3 << 6) & 0xFC0) | (b4 & 0x3F);
  5523. if (chr < 0x10000 || chr > 0x10FFFF) {
  5524. result += '\ufffd\ufffd\ufffd\ufffd';
  5525. } else {
  5526. chr -= 0x10000;
  5527. result += String.fromCharCode(0xD800 + (chr >> 10), 0xDC00 + (chr & 0x3FF));
  5528. }
  5529. i += 9;
  5530. continue;
  5531. }
  5532. }
  5533. result += '\ufffd';
  5534. }
  5535. return result;
  5536. });
  5537. }
  5538. decode.defaultChars = ';/?:@&=+$,#';
  5539. decode.componentChars = '';
  5540. module.exports = decode;
  5541. },{}],56:[function(require,module,exports){
  5542. 'use strict';
  5543. var encodeCache = {};
  5544. // Create a lookup array where anything but characters in `chars` string
  5545. // and alphanumeric chars is percent-encoded.
  5546. //
  5547. function getEncodeCache(exclude) {
  5548. var i, ch, cache = encodeCache[exclude];
  5549. if (cache) { return cache; }
  5550. cache = encodeCache[exclude] = [];
  5551. for (i = 0; i < 128; i++) {
  5552. ch = String.fromCharCode(i);
  5553. if (/^[0-9a-z]$/i.test(ch)) {
  5554. // always allow unencoded alphanumeric characters
  5555. cache.push(ch);
  5556. } else {
  5557. cache.push('%' + ('0' + i.toString(16).toUpperCase()).slice(-2));
  5558. }
  5559. }
  5560. for (i = 0; i < exclude.length; i++) {
  5561. cache[exclude.charCodeAt(i)] = exclude[i];
  5562. }
  5563. return cache;
  5564. }
  5565. // Encode unsafe characters with percent-encoding, skipping already
  5566. // encoded sequences.
  5567. //
  5568. // - string - string to encode
  5569. // - exclude - list of characters to ignore (in addition to a-zA-Z0-9)
  5570. // - keepEscaped - don't encode '%' in a correct escape sequence (default: true)
  5571. //
  5572. function encode(string, exclude, keepEscaped) {
  5573. var i, l, code, nextCode, cache,
  5574. result = '';
  5575. if (typeof exclude !== 'string') {
  5576. // encode(string, keepEscaped)
  5577. keepEscaped = exclude;
  5578. exclude = encode.defaultChars;
  5579. }
  5580. if (typeof keepEscaped === 'undefined') {
  5581. keepEscaped = true;
  5582. }
  5583. cache = getEncodeCache(exclude);
  5584. for (i = 0, l = string.length; i < l; i++) {
  5585. code = string.charCodeAt(i);
  5586. if (keepEscaped && code === 0x25 /* % */ && i + 2 < l) {
  5587. if (/^[0-9a-f]{2}$/i.test(string.slice(i + 1, i + 3))) {
  5588. result += string.slice(i, i + 3);
  5589. i += 2;
  5590. continue;
  5591. }
  5592. }
  5593. if (code < 128) {
  5594. result += cache[code];
  5595. continue;
  5596. }
  5597. if (code >= 0xD800 && code <= 0xDFFF) {
  5598. if (code >= 0xD800 && code <= 0xDBFF && i + 1 < l) {
  5599. nextCode = string.charCodeAt(i + 1);
  5600. if (nextCode >= 0xDC00 && nextCode <= 0xDFFF) {
  5601. result += encodeURIComponent(string[i] + string[i + 1]);
  5602. i++;
  5603. continue;
  5604. }
  5605. }
  5606. result += '%EF%BF%BD';
  5607. continue;
  5608. }
  5609. result += encodeURIComponent(string[i]);
  5610. }
  5611. return result;
  5612. }
  5613. encode.defaultChars = ";/?:@&=+$,-_.!~*'()#";
  5614. encode.componentChars = "-_.!~*'()";
  5615. module.exports = encode;
  5616. },{}],57:[function(require,module,exports){
  5617. 'use strict';
  5618. module.exports = function format(url) {
  5619. var result = '';
  5620. result += url.protocol || '';
  5621. result += url.slashes ? '//' : '';
  5622. result += url.auth ? url.auth + '@' : '';
  5623. if (url.hostname && url.hostname.indexOf(':') !== -1) {
  5624. // ipv6 address
  5625. result += '[' + url.hostname + ']';
  5626. } else {
  5627. result += url.hostname || '';
  5628. }
  5629. result += url.port ? ':' + url.port : '';
  5630. result += url.pathname || '';
  5631. result += url.search || '';
  5632. result += url.hash || '';
  5633. return result;
  5634. };
  5635. },{}],58:[function(require,module,exports){
  5636. 'use strict';
  5637. module.exports.encode = require('./encode');
  5638. module.exports.decode = require('./decode');
  5639. module.exports.format = require('./format');
  5640. module.exports.parse = require('./parse');
  5641. },{"./decode":55,"./encode":56,"./format":57,"./parse":59}],59:[function(require,module,exports){
  5642. // Copyright Joyent, Inc. and other Node contributors.
  5643. //
  5644. // Permission is hereby granted, free of charge, to any person obtaining a
  5645. // copy of this software and associated documentation files (the
  5646. // "Software"), to deal in the Software without restriction, including
  5647. // without limitation the rights to use, copy, modify, merge, publish,
  5648. // distribute, sublicense, and/or sell copies of the Software, and to permit
  5649. // persons to whom the Software is furnished to do so, subject to the
  5650. // following conditions:
  5651. //
  5652. // The above copyright notice and this permission notice shall be included
  5653. // in all copies or substantial portions of the Software.
  5654. //
  5655. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  5656. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  5657. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  5658. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  5659. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  5660. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  5661. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  5662. 'use strict';
  5663. //
  5664. // Changes from joyent/node:
  5665. //
  5666. // 1. No leading slash in paths,
  5667. // e.g. in `url.parse('http://foo?bar')` pathname is ``, not `/`
  5668. //
  5669. // 2. Backslashes are not replaced with slashes,
  5670. // so `http:\\example.org\` is treated like a relative path
  5671. //
  5672. // 3. Trailing colon is treated like a part of the path,
  5673. // i.e. in `http://example.org:foo` pathname is `:foo`
  5674. //
  5675. // 4. Nothing is URL-encoded in the resulting object,
  5676. // (in joyent/node some chars in auth and paths are encoded)
  5677. //
  5678. // 5. `url.parse()` does not have `parseQueryString` argument
  5679. //
  5680. // 6. Removed extraneous result properties: `host`, `path`, `query`, etc.,
  5681. // which can be constructed using other parts of the url.
  5682. //
  5683. function Url() {
  5684. this.protocol = null;
  5685. this.slashes = null;
  5686. this.auth = null;
  5687. this.port = null;
  5688. this.hostname = null;
  5689. this.hash = null;
  5690. this.search = null;
  5691. this.pathname = null;
  5692. }
  5693. // Reference: RFC 3986, RFC 1808, RFC 2396
  5694. // define these here so at least they only have to be
  5695. // compiled once on the first module load.
  5696. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  5697. portPattern = /:[0-9]*$/,
  5698. // Special case for a simple path URL
  5699. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  5700. // RFC 2396: characters reserved for delimiting URLs.
  5701. // We actually just auto-escape these.
  5702. delims = [ '<', '>', '"', '`', ' ', '\r', '\n', '\t' ],
  5703. // RFC 2396: characters not allowed for various reasons.
  5704. unwise = [ '{', '}', '|', '\\', '^', '`' ].concat(delims),
  5705. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  5706. autoEscape = [ '\'' ].concat(unwise),
  5707. // Characters that are never ever allowed in a hostname.
  5708. // Note that any invalid chars are also handled, but these
  5709. // are the ones that are *expected* to be seen, so we fast-path
  5710. // them.
  5711. nonHostChars = [ '%', '/', '?', ';', '#' ].concat(autoEscape),
  5712. hostEndingChars = [ '/', '?', '#' ],
  5713. hostnameMaxLen = 255,
  5714. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  5715. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  5716. // protocols that can allow "unsafe" and "unwise" chars.
  5717. /* eslint-disable no-script-url */
  5718. // protocols that never have a hostname.
  5719. hostlessProtocol = {
  5720. 'javascript': true,
  5721. 'javascript:': true
  5722. },
  5723. // protocols that always contain a // bit.
  5724. slashedProtocol = {
  5725. 'http': true,
  5726. 'https': true,
  5727. 'ftp': true,
  5728. 'gopher': true,
  5729. 'file': true,
  5730. 'http:': true,
  5731. 'https:': true,
  5732. 'ftp:': true,
  5733. 'gopher:': true,
  5734. 'file:': true
  5735. };
  5736. /* eslint-enable no-script-url */
  5737. function urlParse(url, slashesDenoteHost) {
  5738. if (url && url instanceof Url) { return url; }
  5739. var u = new Url();
  5740. u.parse(url, slashesDenoteHost);
  5741. return u;
  5742. }
  5743. Url.prototype.parse = function(url, slashesDenoteHost) {
  5744. var i, l, lowerProto, hec, slashes,
  5745. rest = url;
  5746. // trim before proceeding.
  5747. // This is to support parse stuff like " http://foo.com \n"
  5748. rest = rest.trim();
  5749. if (!slashesDenoteHost && url.split('#').length === 1) {
  5750. // Try fast path regexp
  5751. var simplePath = simplePathPattern.exec(rest);
  5752. if (simplePath) {
  5753. this.pathname = simplePath[1];
  5754. if (simplePath[2]) {
  5755. this.search = simplePath[2];
  5756. }
  5757. return this;
  5758. }
  5759. }
  5760. var proto = protocolPattern.exec(rest);
  5761. if (proto) {
  5762. proto = proto[0];
  5763. lowerProto = proto.toLowerCase();
  5764. this.protocol = proto;
  5765. rest = rest.substr(proto.length);
  5766. }
  5767. // figure out if it's got a host
  5768. // user@server is *always* interpreted as a hostname, and url
  5769. // resolution will treat //foo/bar as host=foo,path=bar because that's
  5770. // how the browser resolves relative URLs.
  5771. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  5772. slashes = rest.substr(0, 2) === '//';
  5773. if (slashes && !(proto && hostlessProtocol[proto])) {
  5774. rest = rest.substr(2);
  5775. this.slashes = true;
  5776. }
  5777. }
  5778. if (!hostlessProtocol[proto] &&
  5779. (slashes || (proto && !slashedProtocol[proto]))) {
  5780. // there's a hostname.
  5781. // the first instance of /, ?, ;, or # ends the host.
  5782. //
  5783. // If there is an @ in the hostname, then non-host chars *are* allowed
  5784. // to the left of the last @ sign, unless some host-ending character
  5785. // comes *before* the @-sign.
  5786. // URLs are obnoxious.
  5787. //
  5788. // ex:
  5789. // http://a@b@c/ => user:a@b host:c
  5790. // http://a@b?@c => user:a host:c path:/?@c
  5791. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  5792. // Review our test case against browsers more comprehensively.
  5793. // find the first instance of any hostEndingChars
  5794. var hostEnd = -1;
  5795. for (i = 0; i < hostEndingChars.length; i++) {
  5796. hec = rest.indexOf(hostEndingChars[i]);
  5797. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
  5798. hostEnd = hec;
  5799. }
  5800. }
  5801. // at this point, either we have an explicit point where the
  5802. // auth portion cannot go past, or the last @ char is the decider.
  5803. var auth, atSign;
  5804. if (hostEnd === -1) {
  5805. // atSign can be anywhere.
  5806. atSign = rest.lastIndexOf('@');
  5807. } else {
  5808. // atSign must be in auth portion.
  5809. // http://a@b/c@d => host:b auth:a path:/c@d
  5810. atSign = rest.lastIndexOf('@', hostEnd);
  5811. }
  5812. // Now we have a portion which is definitely the auth.
  5813. // Pull that off.
  5814. if (atSign !== -1) {
  5815. auth = rest.slice(0, atSign);
  5816. rest = rest.slice(atSign + 1);
  5817. this.auth = auth;
  5818. }
  5819. // the host is the remaining to the left of the first non-host char
  5820. hostEnd = -1;
  5821. for (i = 0; i < nonHostChars.length; i++) {
  5822. hec = rest.indexOf(nonHostChars[i]);
  5823. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
  5824. hostEnd = hec;
  5825. }
  5826. }
  5827. // if we still have not hit it, then the entire thing is a host.
  5828. if (hostEnd === -1) {
  5829. hostEnd = rest.length;
  5830. }
  5831. if (rest[hostEnd - 1] === ':') { hostEnd--; }
  5832. var host = rest.slice(0, hostEnd);
  5833. rest = rest.slice(hostEnd);
  5834. // pull out port.
  5835. this.parseHost(host);
  5836. // we've indicated that there is a hostname,
  5837. // so even if it's empty, it has to be present.
  5838. this.hostname = this.hostname || '';
  5839. // if hostname begins with [ and ends with ]
  5840. // assume that it's an IPv6 address.
  5841. var ipv6Hostname = this.hostname[0] === '[' &&
  5842. this.hostname[this.hostname.length - 1] === ']';
  5843. // validate a little.
  5844. if (!ipv6Hostname) {
  5845. var hostparts = this.hostname.split(/\./);
  5846. for (i = 0, l = hostparts.length; i < l; i++) {
  5847. var part = hostparts[i];
  5848. if (!part) { continue; }
  5849. if (!part.match(hostnamePartPattern)) {
  5850. var newpart = '';
  5851. for (var j = 0, k = part.length; j < k; j++) {
  5852. if (part.charCodeAt(j) > 127) {
  5853. // we replace non-ASCII char with a temporary placeholder
  5854. // we need this to make sure size of hostname is not
  5855. // broken by replacing non-ASCII by nothing
  5856. newpart += 'x';
  5857. } else {
  5858. newpart += part[j];
  5859. }
  5860. }
  5861. // we test again with ASCII char only
  5862. if (!newpart.match(hostnamePartPattern)) {
  5863. var validParts = hostparts.slice(0, i);
  5864. var notHost = hostparts.slice(i + 1);
  5865. var bit = part.match(hostnamePartStart);
  5866. if (bit) {
  5867. validParts.push(bit[1]);
  5868. notHost.unshift(bit[2]);
  5869. }
  5870. if (notHost.length) {
  5871. rest = notHost.join('.') + rest;
  5872. }
  5873. this.hostname = validParts.join('.');
  5874. break;
  5875. }
  5876. }
  5877. }
  5878. }
  5879. if (this.hostname.length > hostnameMaxLen) {
  5880. this.hostname = '';
  5881. }
  5882. // strip [ and ] from the hostname
  5883. // the host field still retains them, though
  5884. if (ipv6Hostname) {
  5885. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  5886. }
  5887. }
  5888. // chop off from the tail first.
  5889. var hash = rest.indexOf('#');
  5890. if (hash !== -1) {
  5891. // got a fragment string.
  5892. this.hash = rest.substr(hash);
  5893. rest = rest.slice(0, hash);
  5894. }
  5895. var qm = rest.indexOf('?');
  5896. if (qm !== -1) {
  5897. this.search = rest.substr(qm);
  5898. rest = rest.slice(0, qm);
  5899. }
  5900. if (rest) { this.pathname = rest; }
  5901. if (slashedProtocol[lowerProto] &&
  5902. this.hostname && !this.pathname) {
  5903. this.pathname = '';
  5904. }
  5905. return this;
  5906. };
  5907. Url.prototype.parseHost = function(host) {
  5908. var port = portPattern.exec(host);
  5909. if (port) {
  5910. port = port[0];
  5911. if (port !== ':') {
  5912. this.port = port.substr(1);
  5913. }
  5914. host = host.substr(0, host.length - port.length);
  5915. }
  5916. if (host) { this.hostname = host; }
  5917. };
  5918. module.exports = urlParse;
  5919. },{}],60:[function(require,module,exports){
  5920. (function (global){
  5921. /*! https://mths.be/punycode v1.4.1 by @mathias */
  5922. ;(function(root) {
  5923. /** Detect free variables */
  5924. var freeExports = typeof exports == 'object' && exports &&
  5925. !exports.nodeType && exports;
  5926. var freeModule = typeof module == 'object' && module &&
  5927. !module.nodeType && module;
  5928. var freeGlobal = typeof global == 'object' && global;
  5929. if (
  5930. freeGlobal.global === freeGlobal ||
  5931. freeGlobal.window === freeGlobal ||
  5932. freeGlobal.self === freeGlobal
  5933. ) {
  5934. root = freeGlobal;
  5935. }
  5936. /**
  5937. * The `punycode` object.
  5938. * @name punycode
  5939. * @type Object
  5940. */
  5941. var punycode,
  5942. /** Highest positive signed 32-bit float value */
  5943. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  5944. /** Bootstring parameters */
  5945. base = 36,
  5946. tMin = 1,
  5947. tMax = 26,
  5948. skew = 38,
  5949. damp = 700,
  5950. initialBias = 72,
  5951. initialN = 128, // 0x80
  5952. delimiter = '-', // '\x2D'
  5953. /** Regular expressions */
  5954. regexPunycode = /^xn--/,
  5955. regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
  5956. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
  5957. /** Error messages */
  5958. errors = {
  5959. 'overflow': 'Overflow: input needs wider integers to process',
  5960. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  5961. 'invalid-input': 'Invalid input'
  5962. },
  5963. /** Convenience shortcuts */
  5964. baseMinusTMin = base - tMin,
  5965. floor = Math.floor,
  5966. stringFromCharCode = String.fromCharCode,
  5967. /** Temporary variable */
  5968. key;
  5969. /*--------------------------------------------------------------------------*/
  5970. /**
  5971. * A generic error utility function.
  5972. * @private
  5973. * @param {String} type The error type.
  5974. * @returns {Error} Throws a `RangeError` with the applicable error message.
  5975. */
  5976. function error(type) {
  5977. throw new RangeError(errors[type]);
  5978. }
  5979. /**
  5980. * A generic `Array#map` utility function.
  5981. * @private
  5982. * @param {Array} array The array to iterate over.
  5983. * @param {Function} callback The function that gets called for every array
  5984. * item.
  5985. * @returns {Array} A new array of values returned by the callback function.
  5986. */
  5987. function map(array, fn) {
  5988. var length = array.length;
  5989. var result = [];
  5990. while (length--) {
  5991. result[length] = fn(array[length]);
  5992. }
  5993. return result;
  5994. }
  5995. /**
  5996. * A simple `Array#map`-like wrapper to work with domain name strings or email
  5997. * addresses.
  5998. * @private
  5999. * @param {String} domain The domain name or email address.
  6000. * @param {Function} callback The function that gets called for every
  6001. * character.
  6002. * @returns {Array} A new string of characters returned by the callback
  6003. * function.
  6004. */
  6005. function mapDomain(string, fn) {
  6006. var parts = string.split('@');
  6007. var result = '';
  6008. if (parts.length > 1) {
  6009. // In email addresses, only the domain name should be punycoded. Leave
  6010. // the local part (i.e. everything up to `@`) intact.
  6011. result = parts[0] + '@';
  6012. string = parts[1];
  6013. }
  6014. // Avoid `split(regex)` for IE8 compatibility. See #17.
  6015. string = string.replace(regexSeparators, '\x2E');
  6016. var labels = string.split('.');
  6017. var encoded = map(labels, fn).join('.');
  6018. return result + encoded;
  6019. }
  6020. /**
  6021. * Creates an array containing the numeric code points of each Unicode
  6022. * character in the string. While JavaScript uses UCS-2 internally,
  6023. * this function will convert a pair of surrogate halves (each of which
  6024. * UCS-2 exposes as separate characters) into a single code point,
  6025. * matching UTF-16.
  6026. * @see `punycode.ucs2.encode`
  6027. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  6028. * @memberOf punycode.ucs2
  6029. * @name decode
  6030. * @param {String} string The Unicode input string (UCS-2).
  6031. * @returns {Array} The new array of code points.
  6032. */
  6033. function ucs2decode(string) {
  6034. var output = [],
  6035. counter = 0,
  6036. length = string.length,
  6037. value,
  6038. extra;
  6039. while (counter < length) {
  6040. value = string.charCodeAt(counter++);
  6041. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  6042. // high surrogate, and there is a next character
  6043. extra = string.charCodeAt(counter++);
  6044. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  6045. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  6046. } else {
  6047. // unmatched surrogate; only append this code unit, in case the next
  6048. // code unit is the high surrogate of a surrogate pair
  6049. output.push(value);
  6050. counter--;
  6051. }
  6052. } else {
  6053. output.push(value);
  6054. }
  6055. }
  6056. return output;
  6057. }
  6058. /**
  6059. * Creates a string based on an array of numeric code points.
  6060. * @see `punycode.ucs2.decode`
  6061. * @memberOf punycode.ucs2
  6062. * @name encode
  6063. * @param {Array} codePoints The array of numeric code points.
  6064. * @returns {String} The new Unicode string (UCS-2).
  6065. */
  6066. function ucs2encode(array) {
  6067. return map(array, function(value) {
  6068. var output = '';
  6069. if (value > 0xFFFF) {
  6070. value -= 0x10000;
  6071. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  6072. value = 0xDC00 | value & 0x3FF;
  6073. }
  6074. output += stringFromCharCode(value);
  6075. return output;
  6076. }).join('');
  6077. }
  6078. /**
  6079. * Converts a basic code point into a digit/integer.
  6080. * @see `digitToBasic()`
  6081. * @private
  6082. * @param {Number} codePoint The basic numeric code point value.
  6083. * @returns {Number} The numeric value of a basic code point (for use in
  6084. * representing integers) in the range `0` to `base - 1`, or `base` if
  6085. * the code point does not represent a value.
  6086. */
  6087. function basicToDigit(codePoint) {
  6088. if (codePoint - 48 < 10) {
  6089. return codePoint - 22;
  6090. }
  6091. if (codePoint - 65 < 26) {
  6092. return codePoint - 65;
  6093. }
  6094. if (codePoint - 97 < 26) {
  6095. return codePoint - 97;
  6096. }
  6097. return base;
  6098. }
  6099. /**
  6100. * Converts a digit/integer into a basic code point.
  6101. * @see `basicToDigit()`
  6102. * @private
  6103. * @param {Number} digit The numeric value of a basic code point.
  6104. * @returns {Number} The basic code point whose value (when used for
  6105. * representing integers) is `digit`, which needs to be in the range
  6106. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  6107. * used; else, the lowercase form is used. The behavior is undefined
  6108. * if `flag` is non-zero and `digit` has no uppercase form.
  6109. */
  6110. function digitToBasic(digit, flag) {
  6111. // 0..25 map to ASCII a..z or A..Z
  6112. // 26..35 map to ASCII 0..9
  6113. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  6114. }
  6115. /**
  6116. * Bias adaptation function as per section 3.4 of RFC 3492.
  6117. * https://tools.ietf.org/html/rfc3492#section-3.4
  6118. * @private
  6119. */
  6120. function adapt(delta, numPoints, firstTime) {
  6121. var k = 0;
  6122. delta = firstTime ? floor(delta / damp) : delta >> 1;
  6123. delta += floor(delta / numPoints);
  6124. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  6125. delta = floor(delta / baseMinusTMin);
  6126. }
  6127. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  6128. }
  6129. /**
  6130. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  6131. * symbols.
  6132. * @memberOf punycode
  6133. * @param {String} input The Punycode string of ASCII-only symbols.
  6134. * @returns {String} The resulting string of Unicode symbols.
  6135. */
  6136. function decode(input) {
  6137. // Don't use UCS-2
  6138. var output = [],
  6139. inputLength = input.length,
  6140. out,
  6141. i = 0,
  6142. n = initialN,
  6143. bias = initialBias,
  6144. basic,
  6145. j,
  6146. index,
  6147. oldi,
  6148. w,
  6149. k,
  6150. digit,
  6151. t,
  6152. /** Cached calculation results */
  6153. baseMinusT;
  6154. // Handle the basic code points: let `basic` be the number of input code
  6155. // points before the last delimiter, or `0` if there is none, then copy
  6156. // the first basic code points to the output.
  6157. basic = input.lastIndexOf(delimiter);
  6158. if (basic < 0) {
  6159. basic = 0;
  6160. }
  6161. for (j = 0; j < basic; ++j) {
  6162. // if it's not a basic code point
  6163. if (input.charCodeAt(j) >= 0x80) {
  6164. error('not-basic');
  6165. }
  6166. output.push(input.charCodeAt(j));
  6167. }
  6168. // Main decoding loop: start just after the last delimiter if any basic code
  6169. // points were copied; start at the beginning otherwise.
  6170. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  6171. // `index` is the index of the next character to be consumed.
  6172. // Decode a generalized variable-length integer into `delta`,
  6173. // which gets added to `i`. The overflow checking is easier
  6174. // if we increase `i` as we go, then subtract off its starting
  6175. // value at the end to obtain `delta`.
  6176. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  6177. if (index >= inputLength) {
  6178. error('invalid-input');
  6179. }
  6180. digit = basicToDigit(input.charCodeAt(index++));
  6181. if (digit >= base || digit > floor((maxInt - i) / w)) {
  6182. error('overflow');
  6183. }
  6184. i += digit * w;
  6185. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  6186. if (digit < t) {
  6187. break;
  6188. }
  6189. baseMinusT = base - t;
  6190. if (w > floor(maxInt / baseMinusT)) {
  6191. error('overflow');
  6192. }
  6193. w *= baseMinusT;
  6194. }
  6195. out = output.length + 1;
  6196. bias = adapt(i - oldi, out, oldi == 0);
  6197. // `i` was supposed to wrap around from `out` to `0`,
  6198. // incrementing `n` each time, so we'll fix that now:
  6199. if (floor(i / out) > maxInt - n) {
  6200. error('overflow');
  6201. }
  6202. n += floor(i / out);
  6203. i %= out;
  6204. // Insert `n` at position `i` of the output
  6205. output.splice(i++, 0, n);
  6206. }
  6207. return ucs2encode(output);
  6208. }
  6209. /**
  6210. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  6211. * Punycode string of ASCII-only symbols.
  6212. * @memberOf punycode
  6213. * @param {String} input The string of Unicode symbols.
  6214. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  6215. */
  6216. function encode(input) {
  6217. var n,
  6218. delta,
  6219. handledCPCount,
  6220. basicLength,
  6221. bias,
  6222. j,
  6223. m,
  6224. q,
  6225. k,
  6226. t,
  6227. currentValue,
  6228. output = [],
  6229. /** `inputLength` will hold the number of code points in `input`. */
  6230. inputLength,
  6231. /** Cached calculation results */
  6232. handledCPCountPlusOne,
  6233. baseMinusT,
  6234. qMinusT;
  6235. // Convert the input in UCS-2 to Unicode
  6236. input = ucs2decode(input);
  6237. // Cache the length
  6238. inputLength = input.length;
  6239. // Initialize the state
  6240. n = initialN;
  6241. delta = 0;
  6242. bias = initialBias;
  6243. // Handle the basic code points
  6244. for (j = 0; j < inputLength; ++j) {
  6245. currentValue = input[j];
  6246. if (currentValue < 0x80) {
  6247. output.push(stringFromCharCode(currentValue));
  6248. }
  6249. }
  6250. handledCPCount = basicLength = output.length;
  6251. // `handledCPCount` is the number of code points that have been handled;
  6252. // `basicLength` is the number of basic code points.
  6253. // Finish the basic string - if it is not empty - with a delimiter
  6254. if (basicLength) {
  6255. output.push(delimiter);
  6256. }
  6257. // Main encoding loop:
  6258. while (handledCPCount < inputLength) {
  6259. // All non-basic code points < n have been handled already. Find the next
  6260. // larger one:
  6261. for (m = maxInt, j = 0; j < inputLength; ++j) {
  6262. currentValue = input[j];
  6263. if (currentValue >= n && currentValue < m) {
  6264. m = currentValue;
  6265. }
  6266. }
  6267. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  6268. // but guard against overflow
  6269. handledCPCountPlusOne = handledCPCount + 1;
  6270. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  6271. error('overflow');
  6272. }
  6273. delta += (m - n) * handledCPCountPlusOne;
  6274. n = m;
  6275. for (j = 0; j < inputLength; ++j) {
  6276. currentValue = input[j];
  6277. if (currentValue < n && ++delta > maxInt) {
  6278. error('overflow');
  6279. }
  6280. if (currentValue == n) {
  6281. // Represent delta as a generalized variable-length integer
  6282. for (q = delta, k = base; /* no condition */; k += base) {
  6283. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  6284. if (q < t) {
  6285. break;
  6286. }
  6287. qMinusT = q - t;
  6288. baseMinusT = base - t;
  6289. output.push(
  6290. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  6291. );
  6292. q = floor(qMinusT / baseMinusT);
  6293. }
  6294. output.push(stringFromCharCode(digitToBasic(q, 0)));
  6295. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  6296. delta = 0;
  6297. ++handledCPCount;
  6298. }
  6299. }
  6300. ++delta;
  6301. ++n;
  6302. }
  6303. return output.join('');
  6304. }
  6305. /**
  6306. * Converts a Punycode string representing a domain name or an email address
  6307. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  6308. * it doesn't matter if you call it on a string that has already been
  6309. * converted to Unicode.
  6310. * @memberOf punycode
  6311. * @param {String} input The Punycoded domain name or email address to
  6312. * convert to Unicode.
  6313. * @returns {String} The Unicode representation of the given Punycode
  6314. * string.
  6315. */
  6316. function toUnicode(input) {
  6317. return mapDomain(input, function(string) {
  6318. return regexPunycode.test(string)
  6319. ? decode(string.slice(4).toLowerCase())
  6320. : string;
  6321. });
  6322. }
  6323. /**
  6324. * Converts a Unicode string representing a domain name or an email address to
  6325. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  6326. * i.e. it doesn't matter if you call it with a domain that's already in
  6327. * ASCII.
  6328. * @memberOf punycode
  6329. * @param {String} input The domain name or email address to convert, as a
  6330. * Unicode string.
  6331. * @returns {String} The Punycode representation of the given domain name or
  6332. * email address.
  6333. */
  6334. function toASCII(input) {
  6335. return mapDomain(input, function(string) {
  6336. return regexNonASCII.test(string)
  6337. ? 'xn--' + encode(string)
  6338. : string;
  6339. });
  6340. }
  6341. /*--------------------------------------------------------------------------*/
  6342. /** Define the public API */
  6343. punycode = {
  6344. /**
  6345. * A string representing the current Punycode.js version number.
  6346. * @memberOf punycode
  6347. * @type String
  6348. */
  6349. 'version': '1.4.1',
  6350. /**
  6351. * An object of methods to convert from JavaScript's internal character
  6352. * representation (UCS-2) to Unicode code points, and back.
  6353. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  6354. * @memberOf punycode
  6355. * @type Object
  6356. */
  6357. 'ucs2': {
  6358. 'decode': ucs2decode,
  6359. 'encode': ucs2encode
  6360. },
  6361. 'decode': decode,
  6362. 'encode': encode,
  6363. 'toASCII': toASCII,
  6364. 'toUnicode': toUnicode
  6365. };
  6366. /** Expose `punycode` */
  6367. // Some AMD build optimizers, like r.js, check for specific condition patterns
  6368. // like the following:
  6369. if (
  6370. typeof define == 'function' &&
  6371. typeof define.amd == 'object' &&
  6372. define.amd
  6373. ) {
  6374. define('punycode', function() {
  6375. return punycode;
  6376. });
  6377. } else if (freeExports && freeModule) {
  6378. if (module.exports == freeExports) {
  6379. // in Node.js, io.js, or RingoJS v0.8.0+
  6380. freeModule.exports = punycode;
  6381. } else {
  6382. // in Narwhal or RingoJS v0.7.0-
  6383. for (key in punycode) {
  6384. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  6385. }
  6386. }
  6387. } else {
  6388. // in Rhino or a web browser
  6389. root.punycode = punycode;
  6390. }
  6391. }(this));
  6392. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  6393. },{}],61:[function(require,module,exports){
  6394. module.exports=/[\0-\x1F\x7F-\x9F]/
  6395. },{}],62:[function(require,module,exports){
  6396. module.exports=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804\uDCBD|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/
  6397. },{}],63:[function(require,module,exports){
  6398. module.exports=/[!-#%-\*,-/:;\?@\[-\]_\{\}\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\u0AF0\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-\u2E49\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]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/
  6399. },{}],64:[function(require,module,exports){
  6400. module.exports=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/
  6401. },{}],65:[function(require,module,exports){
  6402. 'use strict';
  6403. exports.Any = require('./properties/Any/regex');
  6404. exports.Cc = require('./categories/Cc/regex');
  6405. exports.Cf = require('./categories/Cf/regex');
  6406. exports.P = require('./categories/P/regex');
  6407. exports.Z = require('./categories/Z/regex');
  6408. },{"./categories/Cc/regex":61,"./categories/Cf/regex":62,"./categories/P/regex":63,"./categories/Z/regex":64,"./properties/Any/regex":66}],66:[function(require,module,exports){
  6409. module.exports=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/
  6410. },{}],67:[function(require,module,exports){
  6411. 'use strict';
  6412. module.exports = require('./lib/');
  6413. },{"./lib/":9}]},{},[67])(67)
  6414. });