markdown-it.js 252 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968
  1. /*! markdown-it 8.3.1 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 e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. // 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. 'pre',
  63. 'section',
  64. 'source',
  65. 'title',
  66. 'summary',
  67. 'table',
  68. 'tbody',
  69. 'td',
  70. 'tfoot',
  71. 'th',
  72. 'thead',
  73. 'title',
  74. 'tr',
  75. 'track',
  76. 'ul'
  77. ];
  78. },{}],3:[function(require,module,exports){
  79. // Regexps to match html elements
  80. 'use strict';
  81. var attr_name = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
  82. var unquoted = '[^"\'=<>`\\x00-\\x20]+';
  83. var single_quoted = "'[^']*'";
  84. var double_quoted = '"[^"]*"';
  85. var attr_value = '(?:' + unquoted + '|' + single_quoted + '|' + double_quoted + ')';
  86. var attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)';
  87. var open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>';
  88. var close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>';
  89. var comment = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->';
  90. var processing = '<[?].*?[?]>';
  91. var declaration = '<![A-Z]+\\s+[^>]*>';
  92. var cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>';
  93. var HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment +
  94. '|' + processing + '|' + declaration + '|' + cdata + ')');
  95. var HTML_OPEN_CLOSE_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + ')');
  96. module.exports.HTML_TAG_RE = HTML_TAG_RE;
  97. module.exports.HTML_OPEN_CLOSE_TAG_RE = HTML_OPEN_CLOSE_TAG_RE;
  98. },{}],4:[function(require,module,exports){
  99. // Utilities
  100. //
  101. 'use strict';
  102. function _class(obj) { return Object.prototype.toString.call(obj); }
  103. function isString(obj) { return _class(obj) === '[object String]'; }
  104. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  105. function has(object, key) {
  106. return _hasOwnProperty.call(object, key);
  107. }
  108. // Merge objects
  109. //
  110. function assign(obj /*from1, from2, from3, ...*/) {
  111. var sources = Array.prototype.slice.call(arguments, 1);
  112. sources.forEach(function (source) {
  113. if (!source) { return; }
  114. if (typeof source !== 'object') {
  115. throw new TypeError(source + 'must be object');
  116. }
  117. Object.keys(source).forEach(function (key) {
  118. obj[key] = source[key];
  119. });
  120. });
  121. return obj;
  122. }
  123. // Remove element from array and put another array at those position.
  124. // Useful for some operations with tokens
  125. function arrayReplaceAt(src, pos, newElements) {
  126. return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1));
  127. }
  128. ////////////////////////////////////////////////////////////////////////////////
  129. function isValidEntityCode(c) {
  130. /*eslint no-bitwise:0*/
  131. // broken sequence
  132. if (c >= 0xD800 && c <= 0xDFFF) { return false; }
  133. // never used
  134. if (c >= 0xFDD0 && c <= 0xFDEF) { return false; }
  135. if ((c & 0xFFFF) === 0xFFFF || (c & 0xFFFF) === 0xFFFE) { return false; }
  136. // control codes
  137. if (c >= 0x00 && c <= 0x08) { return false; }
  138. if (c === 0x0B) { return false; }
  139. if (c >= 0x0E && c <= 0x1F) { return false; }
  140. if (c >= 0x7F && c <= 0x9F) { return false; }
  141. // out of range
  142. if (c > 0x10FFFF) { return false; }
  143. return true;
  144. }
  145. function fromCodePoint(c) {
  146. /*eslint no-bitwise:0*/
  147. if (c > 0xffff) {
  148. c -= 0x10000;
  149. var surrogate1 = 0xd800 + (c >> 10),
  150. surrogate2 = 0xdc00 + (c & 0x3ff);
  151. return String.fromCharCode(surrogate1, surrogate2);
  152. }
  153. return String.fromCharCode(c);
  154. }
  155. var UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g;
  156. var ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi;
  157. var UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + '|' + ENTITY_RE.source, 'gi');
  158. var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;
  159. var entities = require('./entities');
  160. function replaceEntityPattern(match, name) {
  161. var code = 0;
  162. if (has(entities, name)) {
  163. return entities[name];
  164. }
  165. if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {
  166. code = name[1].toLowerCase() === 'x' ?
  167. parseInt(name.slice(2), 16)
  168. :
  169. parseInt(name.slice(1), 10);
  170. if (isValidEntityCode(code)) {
  171. return fromCodePoint(code);
  172. }
  173. }
  174. return match;
  175. }
  176. /*function replaceEntities(str) {
  177. if (str.indexOf('&') < 0) { return str; }
  178. return str.replace(ENTITY_RE, replaceEntityPattern);
  179. }*/
  180. function unescapeMd(str) {
  181. if (str.indexOf('\\') < 0) { return str; }
  182. return str.replace(UNESCAPE_MD_RE, '$1');
  183. }
  184. function unescapeAll(str) {
  185. if (str.indexOf('\\') < 0 && str.indexOf('&') < 0) { return str; }
  186. return str.replace(UNESCAPE_ALL_RE, function (match, escaped, entity) {
  187. if (escaped) { return escaped; }
  188. return replaceEntityPattern(match, entity);
  189. });
  190. }
  191. ////////////////////////////////////////////////////////////////////////////////
  192. var HTML_ESCAPE_TEST_RE = /[&<>"]/;
  193. var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;
  194. var HTML_REPLACEMENTS = {
  195. '&': '&amp;',
  196. '<': '&lt;',
  197. '>': '&gt;',
  198. '"': '&quot;'
  199. };
  200. function replaceUnsafeChar(ch) {
  201. return HTML_REPLACEMENTS[ch];
  202. }
  203. function escapeHtml(str) {
  204. if (HTML_ESCAPE_TEST_RE.test(str)) {
  205. return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
  206. }
  207. return str;
  208. }
  209. ////////////////////////////////////////////////////////////////////////////////
  210. var REGEXP_ESCAPE_RE = /[.?*+^$[\]\\(){}|-]/g;
  211. function escapeRE(str) {
  212. return str.replace(REGEXP_ESCAPE_RE, '\\$&');
  213. }
  214. ////////////////////////////////////////////////////////////////////////////////
  215. function isSpace(code) {
  216. switch (code) {
  217. case 0x09:
  218. case 0x20:
  219. return true;
  220. }
  221. return false;
  222. }
  223. // Zs (unicode class) || [\t\f\v\r\n]
  224. function isWhiteSpace(code) {
  225. if (code >= 0x2000 && code <= 0x200A) { return true; }
  226. switch (code) {
  227. case 0x09: // \t
  228. case 0x0A: // \n
  229. case 0x0B: // \v
  230. case 0x0C: // \f
  231. case 0x0D: // \r
  232. case 0x20:
  233. case 0xA0:
  234. case 0x1680:
  235. case 0x202F:
  236. case 0x205F:
  237. case 0x3000:
  238. return true;
  239. }
  240. return false;
  241. }
  242. ////////////////////////////////////////////////////////////////////////////////
  243. /*eslint-disable max-len*/
  244. var UNICODE_PUNCT_RE = require('uc.micro/categories/P/regex');
  245. // Currently without astral characters support.
  246. function isPunctChar(ch) {
  247. return UNICODE_PUNCT_RE.test(ch);
  248. }
  249. // Markdown ASCII punctuation characters.
  250. //
  251. // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
  252. // http://spec.commonmark.org/0.15/#ascii-punctuation-character
  253. //
  254. // Don't confuse with unicode punctuation !!! It lacks some chars in ascii range.
  255. //
  256. function isMdAsciiPunct(ch) {
  257. switch (ch) {
  258. case 0x21/* ! */:
  259. case 0x22/* " */:
  260. case 0x23/* # */:
  261. case 0x24/* $ */:
  262. case 0x25/* % */:
  263. case 0x26/* & */:
  264. case 0x27/* ' */:
  265. case 0x28/* ( */:
  266. case 0x29/* ) */:
  267. case 0x2A/* * */:
  268. case 0x2B/* + */:
  269. case 0x2C/* , */:
  270. case 0x2D/* - */:
  271. case 0x2E/* . */:
  272. case 0x2F/* / */:
  273. case 0x3A/* : */:
  274. case 0x3B/* ; */:
  275. case 0x3C/* < */:
  276. case 0x3D/* = */:
  277. case 0x3E/* > */:
  278. case 0x3F/* ? */:
  279. case 0x40/* @ */:
  280. case 0x5B/* [ */:
  281. case 0x5C/* \ */:
  282. case 0x5D/* ] */:
  283. case 0x5E/* ^ */:
  284. case 0x5F/* _ */:
  285. case 0x60/* ` */:
  286. case 0x7B/* { */:
  287. case 0x7C/* | */:
  288. case 0x7D/* } */:
  289. case 0x7E/* ~ */:
  290. return true;
  291. default:
  292. return false;
  293. }
  294. }
  295. // Hepler to unify [reference labels].
  296. //
  297. function normalizeReference(str) {
  298. // use .toUpperCase() instead of .toLowerCase()
  299. // here to avoid a conflict with Object.prototype
  300. // members (most notably, `__proto__`)
  301. return str.trim().replace(/\s+/g, ' ').toUpperCase();
  302. }
  303. ////////////////////////////////////////////////////////////////////////////////
  304. // Re-export libraries commonly used in both markdown-it and its plugins,
  305. // so plugins won't have to depend on them explicitly, which reduces their
  306. // bundled size (e.g. a browser build).
  307. //
  308. exports.lib = {};
  309. exports.lib.mdurl = require('mdurl');
  310. exports.lib.ucmicro = require('uc.micro');
  311. exports.assign = assign;
  312. exports.isString = isString;
  313. exports.has = has;
  314. exports.unescapeMd = unescapeMd;
  315. exports.unescapeAll = unescapeAll;
  316. exports.isValidEntityCode = isValidEntityCode;
  317. exports.fromCodePoint = fromCodePoint;
  318. // exports.replaceEntities = replaceEntities;
  319. exports.escapeHtml = escapeHtml;
  320. exports.arrayReplaceAt = arrayReplaceAt;
  321. exports.isSpace = isSpace;
  322. exports.isWhiteSpace = isWhiteSpace;
  323. exports.isMdAsciiPunct = isMdAsciiPunct;
  324. exports.isPunctChar = isPunctChar;
  325. exports.escapeRE = escapeRE;
  326. exports.normalizeReference = normalizeReference;
  327. },{"./entities":1,"mdurl":58,"uc.micro":65,"uc.micro/categories/P/regex":63}],5:[function(require,module,exports){
  328. // Just a shortcut for bulk export
  329. 'use strict';
  330. exports.parseLinkLabel = require('./parse_link_label');
  331. exports.parseLinkDestination = require('./parse_link_destination');
  332. exports.parseLinkTitle = require('./parse_link_title');
  333. },{"./parse_link_destination":6,"./parse_link_label":7,"./parse_link_title":8}],6:[function(require,module,exports){
  334. // Parse link destination
  335. //
  336. 'use strict';
  337. var isSpace = require('../common/utils').isSpace;
  338. var unescapeAll = require('../common/utils').unescapeAll;
  339. module.exports = function parseLinkDestination(str, pos, max) {
  340. var code, level,
  341. lines = 0,
  342. start = pos,
  343. result = {
  344. ok: false,
  345. pos: 0,
  346. lines: 0,
  347. str: ''
  348. };
  349. if (str.charCodeAt(pos) === 0x3C /* < */) {
  350. pos++;
  351. while (pos < max) {
  352. code = str.charCodeAt(pos);
  353. if (code === 0x0A /* \n */ || isSpace(code)) { return result; }
  354. if (code === 0x3E /* > */) {
  355. result.pos = pos + 1;
  356. result.str = unescapeAll(str.slice(start + 1, pos));
  357. result.ok = true;
  358. return result;
  359. }
  360. if (code === 0x5C /* \ */ && pos + 1 < max) {
  361. pos += 2;
  362. continue;
  363. }
  364. pos++;
  365. }
  366. // no closing '>'
  367. return result;
  368. }
  369. // this should be ... } else { ... branch
  370. level = 0;
  371. while (pos < max) {
  372. code = str.charCodeAt(pos);
  373. if (code === 0x20) { break; }
  374. // ascii control characters
  375. if (code < 0x20 || code === 0x7F) { break; }
  376. if (code === 0x5C /* \ */ && pos + 1 < max) {
  377. pos += 2;
  378. continue;
  379. }
  380. if (code === 0x28 /* ( */) {
  381. level++;
  382. if (level > 1) { break; }
  383. }
  384. if (code === 0x29 /* ) */) {
  385. level--;
  386. if (level < 0) { break; }
  387. }
  388. pos++;
  389. }
  390. if (start === pos) { return result; }
  391. result.str = unescapeAll(str.slice(start, pos));
  392. result.lines = lines;
  393. result.pos = pos;
  394. result.ok = true;
  395. return result;
  396. };
  397. },{"../common/utils":4}],7:[function(require,module,exports){
  398. // Parse link label
  399. //
  400. // this function assumes that first character ("[") already matches;
  401. // returns the end of the label
  402. //
  403. 'use strict';
  404. module.exports = function parseLinkLabel(state, start, disableNested) {
  405. var level, found, marker, prevPos,
  406. labelEnd = -1,
  407. max = state.posMax,
  408. oldPos = state.pos;
  409. state.pos = start + 1;
  410. level = 1;
  411. while (state.pos < max) {
  412. marker = state.src.charCodeAt(state.pos);
  413. if (marker === 0x5D /* ] */) {
  414. level--;
  415. if (level === 0) {
  416. found = true;
  417. break;
  418. }
  419. }
  420. prevPos = state.pos;
  421. state.md.inline.skipToken(state);
  422. if (marker === 0x5B /* [ */) {
  423. if (prevPos === state.pos - 1) {
  424. // increase level if we find text `[`, which is not a part of any token
  425. level++;
  426. } else if (disableNested) {
  427. state.pos = oldPos;
  428. return -1;
  429. }
  430. }
  431. }
  432. if (found) {
  433. labelEnd = state.pos;
  434. }
  435. // restore old state
  436. state.pos = oldPos;
  437. return labelEnd;
  438. };
  439. },{}],8:[function(require,module,exports){
  440. // Parse link title
  441. //
  442. 'use strict';
  443. var unescapeAll = require('../common/utils').unescapeAll;
  444. module.exports = function parseLinkTitle(str, pos, max) {
  445. var code,
  446. marker,
  447. lines = 0,
  448. start = pos,
  449. result = {
  450. ok: false,
  451. pos: 0,
  452. lines: 0,
  453. str: ''
  454. };
  455. if (pos >= max) { return result; }
  456. marker = str.charCodeAt(pos);
  457. if (marker !== 0x22 /* " */ && marker !== 0x27 /* ' */ && marker !== 0x28 /* ( */) { return result; }
  458. pos++;
  459. // if opening marker is "(", switch it to closing marker ")"
  460. if (marker === 0x28) { marker = 0x29; }
  461. while (pos < max) {
  462. code = str.charCodeAt(pos);
  463. if (code === marker) {
  464. result.pos = pos + 1;
  465. result.lines = lines;
  466. result.str = unescapeAll(str.slice(start + 1, pos));
  467. result.ok = true;
  468. return result;
  469. } else if (code === 0x0A) {
  470. lines++;
  471. } else if (code === 0x5C /* \ */ && pos + 1 < max) {
  472. pos++;
  473. if (str.charCodeAt(pos) === 0x0A) {
  474. lines++;
  475. }
  476. }
  477. pos++;
  478. }
  479. return result;
  480. };
  481. },{"../common/utils":4}],9:[function(require,module,exports){
  482. // Main parser class
  483. 'use strict';
  484. var utils = require('./common/utils');
  485. var helpers = require('./helpers');
  486. var Renderer = require('./renderer');
  487. var ParserCore = require('./parser_core');
  488. var ParserBlock = require('./parser_block');
  489. var ParserInline = require('./parser_inline');
  490. var LinkifyIt = require('linkify-it');
  491. var mdurl = require('mdurl');
  492. var punycode = require('punycode');
  493. var config = {
  494. 'default': require('./presets/default'),
  495. zero: require('./presets/zero'),
  496. commonmark: require('./presets/commonmark')
  497. };
  498. ////////////////////////////////////////////////////////////////////////////////
  499. //
  500. // This validator can prohibit more than really needed to prevent XSS. It's a
  501. // tradeoff to keep code simple and to be secure by default.
  502. //
  503. // If you need different setup - override validator method as you wish. Or
  504. // replace it with dummy function and use external sanitizer.
  505. //
  506. var BAD_PROTO_RE = /^(vbscript|javascript|file|data):/;
  507. var GOOD_DATA_RE = /^data:image\/(gif|png|jpeg|webp);/;
  508. function validateLink(url) {
  509. // url should be normalized at this point, and existing entities are decoded
  510. var str = url.trim().toLowerCase();
  511. return BAD_PROTO_RE.test(str) ? (GOOD_DATA_RE.test(str) ? true : false) : true;
  512. }
  513. ////////////////////////////////////////////////////////////////////////////////
  514. var RECODE_HOSTNAME_FOR = [ 'http:', 'https:', 'mailto:' ];
  515. function normalizeLink(url) {
  516. var parsed = mdurl.parse(url, true);
  517. if (parsed.hostname) {
  518. // Encode hostnames in urls like:
  519. // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
  520. //
  521. // We don't encode unknown schemas, because it's likely that we encode
  522. // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
  523. //
  524. if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
  525. try {
  526. parsed.hostname = punycode.toASCII(parsed.hostname);
  527. } catch (er) { /**/ }
  528. }
  529. }
  530. return mdurl.encode(mdurl.format(parsed));
  531. }
  532. function normalizeLinkText(url) {
  533. var parsed = mdurl.parse(url, true);
  534. if (parsed.hostname) {
  535. // Encode hostnames in urls like:
  536. // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
  537. //
  538. // We don't encode unknown schemas, because it's likely that we encode
  539. // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
  540. //
  541. if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
  542. try {
  543. parsed.hostname = punycode.toUnicode(parsed.hostname);
  544. } catch (er) { /**/ }
  545. }
  546. }
  547. return mdurl.decode(mdurl.format(parsed));
  548. }
  549. /**
  550. * class MarkdownIt
  551. *
  552. * Main parser/renderer class.
  553. *
  554. * ##### Usage
  555. *
  556. * ```javascript
  557. * // node.js, "classic" way:
  558. * var MarkdownIt = require('markdown-it'),
  559. * md = new MarkdownIt();
  560. * var result = md.render('# markdown-it rulezz!');
  561. *
  562. * // node.js, the same, but with sugar:
  563. * var md = require('markdown-it')();
  564. * var result = md.render('# markdown-it rulezz!');
  565. *
  566. * // browser without AMD, added to "window" on script load
  567. * // Note, there are no dash.
  568. * var md = window.markdownit();
  569. * var result = md.render('# markdown-it rulezz!');
  570. * ```
  571. *
  572. * Single line rendering, without paragraph wrap:
  573. *
  574. * ```javascript
  575. * var md = require('markdown-it')();
  576. * var result = md.renderInline('__markdown-it__ rulezz!');
  577. * ```
  578. **/
  579. /**
  580. * new MarkdownIt([presetName, options])
  581. * - presetName (String): optional, `commonmark` / `zero`
  582. * - options (Object)
  583. *
  584. * Creates parser instanse with given config. Can be called without `new`.
  585. *
  586. * ##### presetName
  587. *
  588. * MarkdownIt provides named presets as a convenience to quickly
  589. * enable/disable active syntax rules and options for common use cases.
  590. *
  591. * - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js) -
  592. * configures parser to strict [CommonMark](http://commonmark.org/) mode.
  593. * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) -
  594. * similar to GFM, used when no preset name given. Enables all available rules,
  595. * but still without html, typographer & autolinker.
  596. * - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) -
  597. * all rules disabled. Useful to quickly setup your config via `.enable()`.
  598. * For example, when you need only `bold` and `italic` markup and nothing else.
  599. *
  600. * ##### options:
  601. *
  602. * - __html__ - `false`. Set `true` to enable HTML tags in source. Be careful!
  603. * That's not safe! You may need external sanitizer to protect output from XSS.
  604. * It's better to extend features via plugins, instead of enabling HTML.
  605. * - __xhtmlOut__ - `false`. Set `true` to add '/' when closing single tags
  606. * (`<br />`). This is needed only for full CommonMark compatibility. In real
  607. * world you will need HTML output.
  608. * - __breaks__ - `false`. Set `true` to convert `\n` in paragraphs into `<br>`.
  609. * - __langPrefix__ - `language-`. CSS language class prefix for fenced blocks.
  610. * Can be useful for external highlighters.
  611. * - __linkify__ - `false`. Set `true` to autoconvert URL-like text to links.
  612. * - __typographer__ - `false`. Set `true` to enable [some language-neutral
  613. * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +
  614. * quotes beautification (smartquotes).
  615. * - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement
  616. * pairs, when typographer enabled and smartquotes on. For example, you can
  617. * use `'«»„“'` for Russian, `'„“‚‘'` for German, and
  618. * `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).
  619. * - __highlight__ - `null`. Highlighter function for fenced code blocks.
  620. * Highlighter `function (str, lang)` should return escaped HTML. It can also
  621. * return empty string if the source was not changed and should be escaped
  622. * externaly. If result starts with <pre... internal wrapper is skipped.
  623. *
  624. * ##### Example
  625. *
  626. * ```javascript
  627. * // commonmark mode
  628. * var md = require('markdown-it')('commonmark');
  629. *
  630. * // default mode
  631. * var md = require('markdown-it')();
  632. *
  633. * // enable everything
  634. * var md = require('markdown-it')({
  635. * html: true,
  636. * linkify: true,
  637. * typographer: true
  638. * });
  639. * ```
  640. *
  641. * ##### Syntax highlighting
  642. *
  643. * ```js
  644. * var hljs = require('highlight.js') // https://highlightjs.org/
  645. *
  646. * var md = require('markdown-it')({
  647. * highlight: function (str, lang) {
  648. * if (lang && hljs.getLanguage(lang)) {
  649. * try {
  650. * return hljs.highlight(lang, str, true).value;
  651. * } catch (__) {}
  652. * }
  653. *
  654. * return ''; // use external default escaping
  655. * }
  656. * });
  657. * ```
  658. *
  659. * Or with full wrapper override (if you need assign class to `<pre>`):
  660. *
  661. * ```javascript
  662. * var hljs = require('highlight.js') // https://highlightjs.org/
  663. *
  664. * // Actual default values
  665. * var md = require('markdown-it')({
  666. * highlight: function (str, lang) {
  667. * if (lang && hljs.getLanguage(lang)) {
  668. * try {
  669. * return '<pre class="hljs"><code>' +
  670. * hljs.highlight(lang, str, true).value +
  671. * '</code></pre>';
  672. * } catch (__) {}
  673. * }
  674. *
  675. * return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
  676. * }
  677. * });
  678. * ```
  679. *
  680. **/
  681. function MarkdownIt(presetName, options) {
  682. if (!(this instanceof MarkdownIt)) {
  683. return new MarkdownIt(presetName, options);
  684. }
  685. if (!options) {
  686. if (!utils.isString(presetName)) {
  687. options = presetName || {};
  688. presetName = 'default';
  689. }
  690. }
  691. /**
  692. * MarkdownIt#inline -> ParserInline
  693. *
  694. * Instance of [[ParserInline]]. You may need it to add new rules when
  695. * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
  696. * [[MarkdownIt.enable]].
  697. **/
  698. this.inline = new ParserInline();
  699. /**
  700. * MarkdownIt#block -> ParserBlock
  701. *
  702. * Instance of [[ParserBlock]]. You may need it to add new rules when
  703. * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
  704. * [[MarkdownIt.enable]].
  705. **/
  706. this.block = new ParserBlock();
  707. /**
  708. * MarkdownIt#core -> Core
  709. *
  710. * Instance of [[Core]] chain executor. You may need it to add new rules when
  711. * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
  712. * [[MarkdownIt.enable]].
  713. **/
  714. this.core = new ParserCore();
  715. /**
  716. * MarkdownIt#renderer -> Renderer
  717. *
  718. * Instance of [[Renderer]]. Use it to modify output look. Or to add rendering
  719. * rules for new token types, generated by plugins.
  720. *
  721. * ##### Example
  722. *
  723. * ```javascript
  724. * var md = require('markdown-it')();
  725. *
  726. * function myToken(tokens, idx, options, env, self) {
  727. * //...
  728. * return result;
  729. * };
  730. *
  731. * md.renderer.rules['my_token'] = myToken
  732. * ```
  733. *
  734. * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js).
  735. **/
  736. this.renderer = new Renderer();
  737. /**
  738. * MarkdownIt#linkify -> LinkifyIt
  739. *
  740. * [linkify-it](https://github.com/markdown-it/linkify-it) instance.
  741. * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js)
  742. * rule.
  743. **/
  744. this.linkify = new LinkifyIt();
  745. /**
  746. * MarkdownIt#validateLink(url) -> Boolean
  747. *
  748. * Link validation function. CommonMark allows too much in links. By default
  749. * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas
  750. * except some embedded image types.
  751. *
  752. * You can change this behaviour:
  753. *
  754. * ```javascript
  755. * var md = require('markdown-it')();
  756. * // enable everything
  757. * md.validateLink = function () { return true; }
  758. * ```
  759. **/
  760. this.validateLink = validateLink;
  761. /**
  762. * MarkdownIt#normalizeLink(url) -> String
  763. *
  764. * Function used to encode link url to a machine-readable format,
  765. * which includes url-encoding, punycode, etc.
  766. **/
  767. this.normalizeLink = normalizeLink;
  768. /**
  769. * MarkdownIt#normalizeLinkText(url) -> String
  770. *
  771. * Function used to decode link url to a human-readable format`
  772. **/
  773. this.normalizeLinkText = normalizeLinkText;
  774. // Expose utils & helpers for easy acces from plugins
  775. /**
  776. * MarkdownIt#utils -> utils
  777. *
  778. * Assorted utility functions, useful to write plugins. See details
  779. * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.js).
  780. **/
  781. this.utils = utils;
  782. /**
  783. * MarkdownIt#helpers -> helpers
  784. *
  785. * Link components parser functions, useful to write plugins. See details
  786. * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/helpers).
  787. **/
  788. this.helpers = utils.assign({}, helpers);
  789. this.options = {};
  790. this.configure(presetName);
  791. if (options) { this.set(options); }
  792. }
  793. /** chainable
  794. * MarkdownIt.set(options)
  795. *
  796. * Set parser options (in the same format as in constructor). Probably, you
  797. * will never need it, but you can change options after constructor call.
  798. *
  799. * ##### Example
  800. *
  801. * ```javascript
  802. * var md = require('markdown-it')()
  803. * .set({ html: true, breaks: true })
  804. * .set({ typographer, true });
  805. * ```
  806. *
  807. * __Note:__ To achieve the best possible performance, don't modify a
  808. * `markdown-it` instance options on the fly. If you need multiple configurations
  809. * it's best to create multiple instances and initialize each with separate
  810. * config.
  811. **/
  812. MarkdownIt.prototype.set = function (options) {
  813. utils.assign(this.options, options);
  814. return this;
  815. };
  816. /** chainable, internal
  817. * MarkdownIt.configure(presets)
  818. *
  819. * Batch load of all options and compenent settings. This is internal method,
  820. * and you probably will not need it. But if you with - see available presets
  821. * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets)
  822. *
  823. * We strongly recommend to use presets instead of direct config loads. That
  824. * will give better compatibility with next versions.
  825. **/
  826. MarkdownIt.prototype.configure = function (presets) {
  827. var self = this, presetName;
  828. if (utils.isString(presets)) {
  829. presetName = presets;
  830. presets = config[presetName];
  831. if (!presets) { throw new Error('Wrong `markdown-it` preset "' + presetName + '", check name'); }
  832. }
  833. if (!presets) { throw new Error('Wrong `markdown-it` preset, can\'t be empty'); }
  834. if (presets.options) { self.set(presets.options); }
  835. if (presets.components) {
  836. Object.keys(presets.components).forEach(function (name) {
  837. if (presets.components[name].rules) {
  838. self[name].ruler.enableOnly(presets.components[name].rules);
  839. }
  840. if (presets.components[name].rules2) {
  841. self[name].ruler2.enableOnly(presets.components[name].rules2);
  842. }
  843. });
  844. }
  845. return this;
  846. };
  847. /** chainable
  848. * MarkdownIt.enable(list, ignoreInvalid)
  849. * - list (String|Array): rule name or list of rule names to enable
  850. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  851. *
  852. * Enable list or rules. It will automatically find appropriate components,
  853. * containing rules with given names. If rule not found, and `ignoreInvalid`
  854. * not set - throws exception.
  855. *
  856. * ##### Example
  857. *
  858. * ```javascript
  859. * var md = require('markdown-it')()
  860. * .enable(['sub', 'sup'])
  861. * .disable('smartquotes');
  862. * ```
  863. **/
  864. MarkdownIt.prototype.enable = function (list, ignoreInvalid) {
  865. var result = [];
  866. if (!Array.isArray(list)) { list = [ list ]; }
  867. [ 'core', 'block', 'inline' ].forEach(function (chain) {
  868. result = result.concat(this[chain].ruler.enable(list, true));
  869. }, this);
  870. result = result.concat(this.inline.ruler2.enable(list, true));
  871. var missed = list.filter(function (name) { return result.indexOf(name) < 0; });
  872. if (missed.length && !ignoreInvalid) {
  873. throw new Error('MarkdownIt. Failed to enable unknown rule(s): ' + missed);
  874. }
  875. return this;
  876. };
  877. /** chainable
  878. * MarkdownIt.disable(list, ignoreInvalid)
  879. * - list (String|Array): rule name or list of rule names to disable.
  880. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  881. *
  882. * The same as [[MarkdownIt.enable]], but turn specified rules off.
  883. **/
  884. MarkdownIt.prototype.disable = function (list, ignoreInvalid) {
  885. var result = [];
  886. if (!Array.isArray(list)) { list = [ list ]; }
  887. [ 'core', 'block', 'inline' ].forEach(function (chain) {
  888. result = result.concat(this[chain].ruler.disable(list, true));
  889. }, this);
  890. result = result.concat(this.inline.ruler2.disable(list, true));
  891. var missed = list.filter(function (name) { return result.indexOf(name) < 0; });
  892. if (missed.length && !ignoreInvalid) {
  893. throw new Error('MarkdownIt. Failed to disable unknown rule(s): ' + missed);
  894. }
  895. return this;
  896. };
  897. /** chainable
  898. * MarkdownIt.use(plugin, params)
  899. *
  900. * Load specified plugin with given params into current parser instance.
  901. * It's just a sugar to call `plugin(md, params)` with curring.
  902. *
  903. * ##### Example
  904. *
  905. * ```javascript
  906. * var iterator = require('markdown-it-for-inline');
  907. * var md = require('markdown-it')()
  908. * .use(iterator, 'foo_replace', 'text', function (tokens, idx) {
  909. * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');
  910. * });
  911. * ```
  912. **/
  913. MarkdownIt.prototype.use = function (plugin /*, params, ... */) {
  914. var args = [ this ].concat(Array.prototype.slice.call(arguments, 1));
  915. plugin.apply(plugin, args);
  916. return this;
  917. };
  918. /** internal
  919. * MarkdownIt.parse(src, env) -> Array
  920. * - src (String): source string
  921. * - env (Object): environment sandbox
  922. *
  923. * Parse input string and returns list of block tokens (special token type
  924. * "inline" will contain list of inline tokens). You should not call this
  925. * method directly, until you write custom renderer (for example, to produce
  926. * AST).
  927. *
  928. * `env` is used to pass data between "distributed" rules and return additional
  929. * metadata like reference info, needed for the renderer. It also can be used to
  930. * inject data in specific cases. Usually, you will be ok to pass `{}`,
  931. * and then pass updated object to renderer.
  932. **/
  933. MarkdownIt.prototype.parse = function (src, env) {
  934. if (typeof src !== 'string') {
  935. throw new Error('Input data should be a String');
  936. }
  937. var state = new this.core.State(src, this, env);
  938. this.core.process(state);
  939. return state.tokens;
  940. };
  941. /**
  942. * MarkdownIt.render(src [, env]) -> String
  943. * - src (String): source string
  944. * - env (Object): environment sandbox
  945. *
  946. * Render markdown string into html. It does all magic for you :).
  947. *
  948. * `env` can be used to inject additional metadata (`{}` by default).
  949. * But you will not need it with high probability. See also comment
  950. * in [[MarkdownIt.parse]].
  951. **/
  952. MarkdownIt.prototype.render = function (src, env) {
  953. env = env || {};
  954. return this.renderer.render(this.parse(src, env), this.options, env);
  955. };
  956. /** internal
  957. * MarkdownIt.parseInline(src, env) -> Array
  958. * - src (String): source string
  959. * - env (Object): environment sandbox
  960. *
  961. * The same as [[MarkdownIt.parse]] but skip all block rules. It returns the
  962. * block tokens list with the single `inline` element, containing parsed inline
  963. * tokens in `children` property. Also updates `env` object.
  964. **/
  965. MarkdownIt.prototype.parseInline = function (src, env) {
  966. var state = new this.core.State(src, this, env);
  967. state.inlineMode = true;
  968. this.core.process(state);
  969. return state.tokens;
  970. };
  971. /**
  972. * MarkdownIt.renderInline(src [, env]) -> String
  973. * - src (String): source string
  974. * - env (Object): environment sandbox
  975. *
  976. * Similar to [[MarkdownIt.render]] but for single paragraph content. Result
  977. * will NOT be wrapped into `<p>` tags.
  978. **/
  979. MarkdownIt.prototype.renderInline = function (src, env) {
  980. env = env || {};
  981. return this.renderer.render(this.parseInline(src, env), this.options, env);
  982. };
  983. module.exports = MarkdownIt;
  984. },{"./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){
  985. /** internal
  986. * class ParserBlock
  987. *
  988. * Block-level tokenizer.
  989. **/
  990. 'use strict';
  991. var Ruler = require('./ruler');
  992. var _rules = [
  993. // First 2 params - rule name & source. Secondary array - list of rules,
  994. // which can be terminated by this one.
  995. [ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ],
  996. [ 'code', require('./rules_block/code') ],
  997. [ 'fence', require('./rules_block/fence'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
  998. [ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'list' ] ],
  999. [ 'hr', require('./rules_block/hr'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
  1000. [ 'list', require('./rules_block/list'), [ 'paragraph', 'reference', 'blockquote' ] ],
  1001. [ 'reference', require('./rules_block/reference') ],
  1002. [ 'heading', require('./rules_block/heading'), [ 'paragraph', 'reference', 'blockquote' ] ],
  1003. [ 'lheading', require('./rules_block/lheading') ],
  1004. [ 'html_block', require('./rules_block/html_block'), [ 'paragraph', 'reference', 'blockquote' ] ],
  1005. [ 'paragraph', require('./rules_block/paragraph') ]
  1006. ];
  1007. /**
  1008. * new ParserBlock()
  1009. **/
  1010. function ParserBlock() {
  1011. /**
  1012. * ParserBlock#ruler -> Ruler
  1013. *
  1014. * [[Ruler]] instance. Keep configuration of block rules.
  1015. **/
  1016. this.ruler = new Ruler();
  1017. for (var i = 0; i < _rules.length; i++) {
  1018. this.ruler.push(_rules[i][0], _rules[i][1], { alt: (_rules[i][2] || []).slice() });
  1019. }
  1020. }
  1021. // Generate tokens for input range
  1022. //
  1023. ParserBlock.prototype.tokenize = function (state, startLine, endLine) {
  1024. var ok, i,
  1025. rules = this.ruler.getRules(''),
  1026. len = rules.length,
  1027. line = startLine,
  1028. hasEmptyLines = false,
  1029. maxNesting = state.md.options.maxNesting;
  1030. while (line < endLine) {
  1031. state.line = line = state.skipEmptyLines(line);
  1032. if (line >= endLine) { break; }
  1033. // Termination condition for nested calls.
  1034. // Nested calls currently used for blockquotes & lists
  1035. if (state.sCount[line] < state.blkIndent) { break; }
  1036. // If nesting level exceeded - skip tail to the end. That's not ordinary
  1037. // situation and we should not care about content.
  1038. if (state.level >= maxNesting) {
  1039. state.line = endLine;
  1040. break;
  1041. }
  1042. // Try all possible rules.
  1043. // On success, rule should:
  1044. //
  1045. // - update `state.line`
  1046. // - update `state.tokens`
  1047. // - return true
  1048. for (i = 0; i < len; i++) {
  1049. ok = rules[i](state, line, endLine, false);
  1050. if (ok) { break; }
  1051. }
  1052. // set state.tight iff we had an empty line before current tag
  1053. // i.e. latest empty line should not count
  1054. state.tight = !hasEmptyLines;
  1055. // paragraph might "eat" one newline after it in nested lists
  1056. if (state.isEmpty(state.line - 1)) {
  1057. hasEmptyLines = true;
  1058. }
  1059. line = state.line;
  1060. if (line < endLine && state.isEmpty(line)) {
  1061. hasEmptyLines = true;
  1062. line++;
  1063. state.line = line;
  1064. }
  1065. }
  1066. };
  1067. /**
  1068. * ParserBlock.parse(str, md, env, outTokens)
  1069. *
  1070. * Process input string and push block tokens into `outTokens`
  1071. **/
  1072. ParserBlock.prototype.parse = function (src, md, env, outTokens) {
  1073. var state;
  1074. if (!src) { return; }
  1075. state = new this.State(src, md, env, outTokens);
  1076. this.tokenize(state, state.line, state.lineMax);
  1077. };
  1078. ParserBlock.prototype.State = require('./rules_block/state_block');
  1079. module.exports = ParserBlock;
  1080. },{"./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){
  1081. /** internal
  1082. * class Core
  1083. *
  1084. * Top-level rules executor. Glues block/inline parsers and does intermediate
  1085. * transformations.
  1086. **/
  1087. 'use strict';
  1088. var Ruler = require('./ruler');
  1089. var _rules = [
  1090. [ 'normalize', require('./rules_core/normalize') ],
  1091. [ 'block', require('./rules_core/block') ],
  1092. [ 'inline', require('./rules_core/inline') ],
  1093. [ 'linkify', require('./rules_core/linkify') ],
  1094. [ 'replacements', require('./rules_core/replacements') ],
  1095. [ 'smartquotes', require('./rules_core/smartquotes') ]
  1096. ];
  1097. /**
  1098. * new Core()
  1099. **/
  1100. function Core() {
  1101. /**
  1102. * Core#ruler -> Ruler
  1103. *
  1104. * [[Ruler]] instance. Keep configuration of core rules.
  1105. **/
  1106. this.ruler = new Ruler();
  1107. for (var i = 0; i < _rules.length; i++) {
  1108. this.ruler.push(_rules[i][0], _rules[i][1]);
  1109. }
  1110. }
  1111. /**
  1112. * Core.process(state)
  1113. *
  1114. * Executes core chain rules.
  1115. **/
  1116. Core.prototype.process = function (state) {
  1117. var i, l, rules;
  1118. rules = this.ruler.getRules('');
  1119. for (i = 0, l = rules.length; i < l; i++) {
  1120. rules[i](state);
  1121. }
  1122. };
  1123. Core.prototype.State = require('./rules_core/state_core');
  1124. module.exports = Core;
  1125. },{"./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){
  1126. /** internal
  1127. * class ParserInline
  1128. *
  1129. * Tokenizes paragraph content.
  1130. **/
  1131. 'use strict';
  1132. var Ruler = require('./ruler');
  1133. ////////////////////////////////////////////////////////////////////////////////
  1134. // Parser rules
  1135. var _rules = [
  1136. [ 'text', require('./rules_inline/text') ],
  1137. [ 'newline', require('./rules_inline/newline') ],
  1138. [ 'escape', require('./rules_inline/escape') ],
  1139. [ 'backticks', require('./rules_inline/backticks') ],
  1140. [ 'strikethrough', require('./rules_inline/strikethrough').tokenize ],
  1141. [ 'emphasis', require('./rules_inline/emphasis').tokenize ],
  1142. [ 'link', require('./rules_inline/link') ],
  1143. [ 'image', require('./rules_inline/image') ],
  1144. [ 'autolink', require('./rules_inline/autolink') ],
  1145. [ 'html_inline', require('./rules_inline/html_inline') ],
  1146. [ 'entity', require('./rules_inline/entity') ]
  1147. ];
  1148. var _rules2 = [
  1149. [ 'balance_pairs', require('./rules_inline/balance_pairs') ],
  1150. [ 'strikethrough', require('./rules_inline/strikethrough').postProcess ],
  1151. [ 'emphasis', require('./rules_inline/emphasis').postProcess ],
  1152. [ 'text_collapse', require('./rules_inline/text_collapse') ]
  1153. ];
  1154. /**
  1155. * new ParserInline()
  1156. **/
  1157. function ParserInline() {
  1158. var i;
  1159. /**
  1160. * ParserInline#ruler -> Ruler
  1161. *
  1162. * [[Ruler]] instance. Keep configuration of inline rules.
  1163. **/
  1164. this.ruler = new Ruler();
  1165. for (i = 0; i < _rules.length; i++) {
  1166. this.ruler.push(_rules[i][0], _rules[i][1]);
  1167. }
  1168. /**
  1169. * ParserInline#ruler2 -> Ruler
  1170. *
  1171. * [[Ruler]] instance. Second ruler used for post-processing
  1172. * (e.g. in emphasis-like rules).
  1173. **/
  1174. this.ruler2 = new Ruler();
  1175. for (i = 0; i < _rules2.length; i++) {
  1176. this.ruler2.push(_rules2[i][0], _rules2[i][1]);
  1177. }
  1178. }
  1179. // Skip single token by running all rules in validation mode;
  1180. // returns `true` if any rule reported success
  1181. //
  1182. ParserInline.prototype.skipToken = function (state) {
  1183. var ok, i, pos = state.pos,
  1184. rules = this.ruler.getRules(''),
  1185. len = rules.length,
  1186. maxNesting = state.md.options.maxNesting,
  1187. cache = state.cache;
  1188. if (typeof cache[pos] !== 'undefined') {
  1189. state.pos = cache[pos];
  1190. return;
  1191. }
  1192. if (state.level < maxNesting) {
  1193. for (i = 0; i < len; i++) {
  1194. // Increment state.level and decrement it later to limit recursion.
  1195. // It's harmless to do here, because no tokens are created. But ideally,
  1196. // we'd need a separate private state variable for this purpose.
  1197. //
  1198. state.level++;
  1199. ok = rules[i](state, true);
  1200. state.level--;
  1201. if (ok) { break; }
  1202. }
  1203. } else {
  1204. // Too much nesting, just skip until the end of the paragraph.
  1205. //
  1206. // NOTE: this will cause links to behave incorrectly in the following case,
  1207. // when an amount of `[` is exactly equal to `maxNesting + 1`:
  1208. //
  1209. // [[[[[[[[[[[[[[[[[[[[[foo]()
  1210. //
  1211. // TODO: remove this workaround when CM standard will allow nested links
  1212. // (we can replace it by preventing links from being parsed in
  1213. // validation mode)
  1214. //
  1215. state.pos = state.posMax;
  1216. }
  1217. if (!ok) { state.pos++; }
  1218. cache[pos] = state.pos;
  1219. };
  1220. // Generate tokens for input range
  1221. //
  1222. ParserInline.prototype.tokenize = function (state) {
  1223. var ok, i,
  1224. rules = this.ruler.getRules(''),
  1225. len = rules.length,
  1226. end = state.posMax,
  1227. maxNesting = state.md.options.maxNesting;
  1228. while (state.pos < end) {
  1229. // Try all possible rules.
  1230. // On success, rule should:
  1231. //
  1232. // - update `state.pos`
  1233. // - update `state.tokens`
  1234. // - return true
  1235. if (state.level < maxNesting) {
  1236. for (i = 0; i < len; i++) {
  1237. ok = rules[i](state, false);
  1238. if (ok) { break; }
  1239. }
  1240. }
  1241. if (ok) {
  1242. if (state.pos >= end) { break; }
  1243. continue;
  1244. }
  1245. state.pending += state.src[state.pos++];
  1246. }
  1247. if (state.pending) {
  1248. state.pushPending();
  1249. }
  1250. };
  1251. /**
  1252. * ParserInline.parse(str, md, env, outTokens)
  1253. *
  1254. * Process input string and push inline tokens into `outTokens`
  1255. **/
  1256. ParserInline.prototype.parse = function (str, md, env, outTokens) {
  1257. var i, rules, len;
  1258. var state = new this.State(str, md, env, outTokens);
  1259. this.tokenize(state);
  1260. rules = this.ruler2.getRules('');
  1261. len = rules.length;
  1262. for (i = 0; i < len; i++) {
  1263. rules[i](state);
  1264. }
  1265. };
  1266. ParserInline.prototype.State = require('./rules_inline/state_inline');
  1267. module.exports = ParserInline;
  1268. },{"./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){
  1269. // Commonmark default options
  1270. 'use strict';
  1271. module.exports = {
  1272. options: {
  1273. html: true, // Enable HTML tags in source
  1274. xhtmlOut: true, // Use '/' to close single tags (<br />)
  1275. breaks: false, // Convert '\n' in paragraphs into <br>
  1276. langPrefix: 'language-', // CSS language prefix for fenced blocks
  1277. linkify: false, // autoconvert URL-like texts to links
  1278. // Enable some language-neutral replacements + quotes beautification
  1279. typographer: false,
  1280. // Double + single quotes replacement pairs, when typographer enabled,
  1281. // and smartquotes on. Could be either a String or an Array.
  1282. //
  1283. // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  1284. // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  1285. quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
  1286. // Highlighter function. Should return escaped HTML,
  1287. // or '' if the source string is not changed and should be escaped externaly.
  1288. // If result starts with <pre... internal wrapper is skipped.
  1289. //
  1290. // function (/*str, lang*/) { return ''; }
  1291. //
  1292. highlight: null,
  1293. maxNesting: 20 // Internal protection, recursion limit
  1294. },
  1295. components: {
  1296. core: {
  1297. rules: [
  1298. 'normalize',
  1299. 'block',
  1300. 'inline'
  1301. ]
  1302. },
  1303. block: {
  1304. rules: [
  1305. 'blockquote',
  1306. 'code',
  1307. 'fence',
  1308. 'heading',
  1309. 'hr',
  1310. 'html_block',
  1311. 'lheading',
  1312. 'list',
  1313. 'reference',
  1314. 'paragraph'
  1315. ]
  1316. },
  1317. inline: {
  1318. rules: [
  1319. 'autolink',
  1320. 'backticks',
  1321. 'emphasis',
  1322. 'entity',
  1323. 'escape',
  1324. 'html_inline',
  1325. 'image',
  1326. 'link',
  1327. 'newline',
  1328. 'text'
  1329. ],
  1330. rules2: [
  1331. 'balance_pairs',
  1332. 'emphasis',
  1333. 'text_collapse'
  1334. ]
  1335. }
  1336. }
  1337. };
  1338. },{}],14:[function(require,module,exports){
  1339. // markdown-it default options
  1340. 'use strict';
  1341. module.exports = {
  1342. options: {
  1343. html: false, // Enable HTML tags in source
  1344. xhtmlOut: false, // Use '/' to close single tags (<br />)
  1345. breaks: false, // Convert '\n' in paragraphs into <br>
  1346. langPrefix: 'language-', // CSS language prefix for fenced blocks
  1347. linkify: false, // autoconvert URL-like texts to links
  1348. // Enable some language-neutral replacements + quotes beautification
  1349. typographer: false,
  1350. // Double + single quotes replacement pairs, when typographer enabled,
  1351. // and smartquotes on. Could be either a String or an Array.
  1352. //
  1353. // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  1354. // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  1355. quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
  1356. // Highlighter function. Should return escaped HTML,
  1357. // or '' if the source string is not changed and should be escaped externaly.
  1358. // If result starts with <pre... internal wrapper is skipped.
  1359. //
  1360. // function (/*str, lang*/) { return ''; }
  1361. //
  1362. highlight: null,
  1363. maxNesting: 100 // Internal protection, recursion limit
  1364. },
  1365. components: {
  1366. core: {},
  1367. block: {},
  1368. inline: {}
  1369. }
  1370. };
  1371. },{}],15:[function(require,module,exports){
  1372. // "Zero" preset, with nothing enabled. Useful for manual configuring of simple
  1373. // modes. For example, to parse bold/italic only.
  1374. 'use strict';
  1375. module.exports = {
  1376. options: {
  1377. html: false, // Enable HTML tags in source
  1378. xhtmlOut: false, // Use '/' to close single tags (<br />)
  1379. breaks: false, // Convert '\n' in paragraphs into <br>
  1380. langPrefix: 'language-', // CSS language prefix for fenced blocks
  1381. linkify: false, // autoconvert URL-like texts to links
  1382. // Enable some language-neutral replacements + quotes beautification
  1383. typographer: false,
  1384. // Double + single quotes replacement pairs, when typographer enabled,
  1385. // and smartquotes on. Could be either a String or an Array.
  1386. //
  1387. // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  1388. // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  1389. quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
  1390. // Highlighter function. Should return escaped HTML,
  1391. // or '' if the source string is not changed and should be escaped externaly.
  1392. // If result starts with <pre... internal wrapper is skipped.
  1393. //
  1394. // function (/*str, lang*/) { return ''; }
  1395. //
  1396. highlight: null,
  1397. maxNesting: 20 // Internal protection, recursion limit
  1398. },
  1399. components: {
  1400. core: {
  1401. rules: [
  1402. 'normalize',
  1403. 'block',
  1404. 'inline'
  1405. ]
  1406. },
  1407. block: {
  1408. rules: [
  1409. 'paragraph'
  1410. ]
  1411. },
  1412. inline: {
  1413. rules: [
  1414. 'text'
  1415. ],
  1416. rules2: [
  1417. 'balance_pairs',
  1418. 'text_collapse'
  1419. ]
  1420. }
  1421. }
  1422. };
  1423. },{}],16:[function(require,module,exports){
  1424. /**
  1425. * class Renderer
  1426. *
  1427. * Generates HTML from parsed token stream. Each instance has independent
  1428. * copy of rules. Those can be rewritten with ease. Also, you can add new
  1429. * rules if you create plugin and adds new token types.
  1430. **/
  1431. 'use strict';
  1432. var assign = require('./common/utils').assign;
  1433. var unescapeAll = require('./common/utils').unescapeAll;
  1434. var escapeHtml = require('./common/utils').escapeHtml;
  1435. ////////////////////////////////////////////////////////////////////////////////
  1436. var default_rules = {};
  1437. default_rules.code_inline = function (tokens, idx, options, env, slf) {
  1438. var token = tokens[idx];
  1439. return '<code' + slf.renderAttrs(token) + '>' +
  1440. escapeHtml(tokens[idx].content) +
  1441. '</code>';
  1442. };
  1443. default_rules.code_block = function (tokens, idx, options, env, slf) {
  1444. var token = tokens[idx];
  1445. return '<pre' + slf.renderAttrs(token) + '><code>' +
  1446. escapeHtml(tokens[idx].content) +
  1447. '</code></pre>\n';
  1448. };
  1449. default_rules.fence = function (tokens, idx, options, env, slf) {
  1450. var token = tokens[idx],
  1451. info = token.info ? unescapeAll(token.info).trim() : '',
  1452. langName = '',
  1453. highlighted, i, tmpAttrs, tmpToken;
  1454. if (info) {
  1455. langName = info.split(/\s+/g)[0];
  1456. }
  1457. if (options.highlight) {
  1458. highlighted = options.highlight(token.content, langName) || escapeHtml(token.content);
  1459. } else {
  1460. highlighted = escapeHtml(token.content);
  1461. }
  1462. if (highlighted.indexOf('<pre') === 0) {
  1463. return highlighted + '\n';
  1464. }
  1465. // If language exists, inject class gently, without mudofying original token.
  1466. // May be, one day we will add .clone() for token and simplify this part, but
  1467. // now we prefer to keep things local.
  1468. if (info) {
  1469. i = token.attrIndex('class');
  1470. tmpAttrs = token.attrs ? token.attrs.slice() : [];
  1471. if (i < 0) {
  1472. tmpAttrs.push([ 'class', options.langPrefix + langName ]);
  1473. } else {
  1474. tmpAttrs[i][1] += ' ' + options.langPrefix + langName;
  1475. }
  1476. // Fake token just to render attributes
  1477. tmpToken = {
  1478. attrs: tmpAttrs
  1479. };
  1480. return '<pre><code' + slf.renderAttrs(tmpToken) + '>'
  1481. + highlighted
  1482. + '</code></pre>\n';
  1483. }
  1484. return '<pre><code' + slf.renderAttrs(token) + '>'
  1485. + highlighted
  1486. + '</code></pre>\n';
  1487. };
  1488. default_rules.image = function (tokens, idx, options, env, slf) {
  1489. var token = tokens[idx];
  1490. // "alt" attr MUST be set, even if empty. Because it's mandatory and
  1491. // should be placed on proper position for tests.
  1492. //
  1493. // Replace content with actual value
  1494. token.attrs[token.attrIndex('alt')][1] =
  1495. slf.renderInlineAsText(token.children, options, env);
  1496. return slf.renderToken(tokens, idx, options);
  1497. };
  1498. default_rules.hardbreak = function (tokens, idx, options /*, env */) {
  1499. return options.xhtmlOut ? '<br />\n' : '<br>\n';
  1500. };
  1501. default_rules.softbreak = function (tokens, idx, options /*, env */) {
  1502. return options.breaks ? (options.xhtmlOut ? '<br />\n' : '<br>\n') : '\n';
  1503. };
  1504. default_rules.text = function (tokens, idx /*, options, env */) {
  1505. return escapeHtml(tokens[idx].content);
  1506. };
  1507. default_rules.html_block = function (tokens, idx /*, options, env */) {
  1508. return tokens[idx].content;
  1509. };
  1510. default_rules.html_inline = function (tokens, idx /*, options, env */) {
  1511. return tokens[idx].content;
  1512. };
  1513. /**
  1514. * new Renderer()
  1515. *
  1516. * Creates new [[Renderer]] instance and fill [[Renderer#rules]] with defaults.
  1517. **/
  1518. function Renderer() {
  1519. /**
  1520. * Renderer#rules -> Object
  1521. *
  1522. * Contains render rules for tokens. Can be updated and extended.
  1523. *
  1524. * ##### Example
  1525. *
  1526. * ```javascript
  1527. * var md = require('markdown-it')();
  1528. *
  1529. * md.renderer.rules.strong_open = function () { return '<b>'; };
  1530. * md.renderer.rules.strong_close = function () { return '</b>'; };
  1531. *
  1532. * var result = md.renderInline(...);
  1533. * ```
  1534. *
  1535. * Each rule is called as independed static function with fixed signature:
  1536. *
  1537. * ```javascript
  1538. * function my_token_render(tokens, idx, options, env, renderer) {
  1539. * // ...
  1540. * return renderedHTML;
  1541. * }
  1542. * ```
  1543. *
  1544. * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js)
  1545. * for more details and examples.
  1546. **/
  1547. this.rules = assign({}, default_rules);
  1548. }
  1549. /**
  1550. * Renderer.renderAttrs(token) -> String
  1551. *
  1552. * Render token attributes to string.
  1553. **/
  1554. Renderer.prototype.renderAttrs = function renderAttrs(token) {
  1555. var i, l, result;
  1556. if (!token.attrs) { return ''; }
  1557. result = '';
  1558. for (i = 0, l = token.attrs.length; i < l; i++) {
  1559. result += ' ' + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
  1560. }
  1561. return result;
  1562. };
  1563. /**
  1564. * Renderer.renderToken(tokens, idx, options) -> String
  1565. * - tokens (Array): list of tokens
  1566. * - idx (Numbed): token index to render
  1567. * - options (Object): params of parser instance
  1568. *
  1569. * Default token renderer. Can be overriden by custom function
  1570. * in [[Renderer#rules]].
  1571. **/
  1572. Renderer.prototype.renderToken = function renderToken(tokens, idx, options) {
  1573. var nextToken,
  1574. result = '',
  1575. needLf = false,
  1576. token = tokens[idx];
  1577. // Tight list paragraphs
  1578. if (token.hidden) {
  1579. return '';
  1580. }
  1581. // Insert a newline between hidden paragraph and subsequent opening
  1582. // block-level tag.
  1583. //
  1584. // For example, here we should insert a newline before blockquote:
  1585. // - a
  1586. // >
  1587. //
  1588. if (token.block && token.nesting !== -1 && idx && tokens[idx - 1].hidden) {
  1589. result += '\n';
  1590. }
  1591. // Add token name, e.g. `<img`
  1592. result += (token.nesting === -1 ? '</' : '<') + token.tag;
  1593. // Encode attributes, e.g. `<img src="foo"`
  1594. result += this.renderAttrs(token);
  1595. // Add a slash for self-closing tags, e.g. `<img src="foo" /`
  1596. if (token.nesting === 0 && options.xhtmlOut) {
  1597. result += ' /';
  1598. }
  1599. // Check if we need to add a newline after this tag
  1600. if (token.block) {
  1601. needLf = true;
  1602. if (token.nesting === 1) {
  1603. if (idx + 1 < tokens.length) {
  1604. nextToken = tokens[idx + 1];
  1605. if (nextToken.type === 'inline' || nextToken.hidden) {
  1606. // Block-level tag containing an inline tag.
  1607. //
  1608. needLf = false;
  1609. } else if (nextToken.nesting === -1 && nextToken.tag === token.tag) {
  1610. // Opening tag + closing tag of the same type. E.g. `<li></li>`.
  1611. //
  1612. needLf = false;
  1613. }
  1614. }
  1615. }
  1616. }
  1617. result += needLf ? '>\n' : '>';
  1618. return result;
  1619. };
  1620. /**
  1621. * Renderer.renderInline(tokens, options, env) -> String
  1622. * - tokens (Array): list on block tokens to renter
  1623. * - options (Object): params of parser instance
  1624. * - env (Object): additional data from parsed input (references, for example)
  1625. *
  1626. * The same as [[Renderer.render]], but for single token of `inline` type.
  1627. **/
  1628. Renderer.prototype.renderInline = function (tokens, options, env) {
  1629. var type,
  1630. result = '',
  1631. rules = this.rules;
  1632. for (var i = 0, len = tokens.length; i < len; i++) {
  1633. type = tokens[i].type;
  1634. if (typeof rules[type] !== 'undefined') {
  1635. result += rules[type](tokens, i, options, env, this);
  1636. } else {
  1637. result += this.renderToken(tokens, i, options);
  1638. }
  1639. }
  1640. return result;
  1641. };
  1642. /** internal
  1643. * Renderer.renderInlineAsText(tokens, options, env) -> String
  1644. * - tokens (Array): list on block tokens to renter
  1645. * - options (Object): params of parser instance
  1646. * - env (Object): additional data from parsed input (references, for example)
  1647. *
  1648. * Special kludge for image `alt` attributes to conform CommonMark spec.
  1649. * Don't try to use it! Spec requires to show `alt` content with stripped markup,
  1650. * instead of simple escaping.
  1651. **/
  1652. Renderer.prototype.renderInlineAsText = function (tokens, options, env) {
  1653. var result = '';
  1654. for (var i = 0, len = tokens.length; i < len; i++) {
  1655. if (tokens[i].type === 'text') {
  1656. result += tokens[i].content;
  1657. } else if (tokens[i].type === 'image') {
  1658. result += this.renderInlineAsText(tokens[i].children, options, env);
  1659. }
  1660. }
  1661. return result;
  1662. };
  1663. /**
  1664. * Renderer.render(tokens, options, env) -> String
  1665. * - tokens (Array): list on block tokens to renter
  1666. * - options (Object): params of parser instance
  1667. * - env (Object): additional data from parsed input (references, for example)
  1668. *
  1669. * Takes token stream and generates HTML. Probably, you will never need to call
  1670. * this method directly.
  1671. **/
  1672. Renderer.prototype.render = function (tokens, options, env) {
  1673. var i, len, type,
  1674. result = '',
  1675. rules = this.rules;
  1676. for (i = 0, len = tokens.length; i < len; i++) {
  1677. type = tokens[i].type;
  1678. if (type === 'inline') {
  1679. result += this.renderInline(tokens[i].children, options, env);
  1680. } else if (typeof rules[type] !== 'undefined') {
  1681. result += rules[tokens[i].type](tokens, i, options, env, this);
  1682. } else {
  1683. result += this.renderToken(tokens, i, options, env);
  1684. }
  1685. }
  1686. return result;
  1687. };
  1688. module.exports = Renderer;
  1689. },{"./common/utils":4}],17:[function(require,module,exports){
  1690. /**
  1691. * class Ruler
  1692. *
  1693. * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and
  1694. * [[MarkdownIt#inline]] to manage sequences of functions (rules):
  1695. *
  1696. * - keep rules in defined order
  1697. * - assign the name to each rule
  1698. * - enable/disable rules
  1699. * - add/replace rules
  1700. * - allow assign rules to additional named chains (in the same)
  1701. * - cacheing lists of active rules
  1702. *
  1703. * You will not need use this class directly until write plugins. For simple
  1704. * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and
  1705. * [[MarkdownIt.use]].
  1706. **/
  1707. 'use strict';
  1708. /**
  1709. * new Ruler()
  1710. **/
  1711. function Ruler() {
  1712. // List of added rules. Each element is:
  1713. //
  1714. // {
  1715. // name: XXX,
  1716. // enabled: Boolean,
  1717. // fn: Function(),
  1718. // alt: [ name2, name3 ]
  1719. // }
  1720. //
  1721. this.__rules__ = [];
  1722. // Cached rule chains.
  1723. //
  1724. // First level - chain name, '' for default.
  1725. // Second level - diginal anchor for fast filtering by charcodes.
  1726. //
  1727. this.__cache__ = null;
  1728. }
  1729. ////////////////////////////////////////////////////////////////////////////////
  1730. // Helper methods, should not be used directly
  1731. // Find rule index by name
  1732. //
  1733. Ruler.prototype.__find__ = function (name) {
  1734. for (var i = 0; i < this.__rules__.length; i++) {
  1735. if (this.__rules__[i].name === name) {
  1736. return i;
  1737. }
  1738. }
  1739. return -1;
  1740. };
  1741. // Build rules lookup cache
  1742. //
  1743. Ruler.prototype.__compile__ = function () {
  1744. var self = this;
  1745. var chains = [ '' ];
  1746. // collect unique names
  1747. self.__rules__.forEach(function (rule) {
  1748. if (!rule.enabled) { return; }
  1749. rule.alt.forEach(function (altName) {
  1750. if (chains.indexOf(altName) < 0) {
  1751. chains.push(altName);
  1752. }
  1753. });
  1754. });
  1755. self.__cache__ = {};
  1756. chains.forEach(function (chain) {
  1757. self.__cache__[chain] = [];
  1758. self.__rules__.forEach(function (rule) {
  1759. if (!rule.enabled) { return; }
  1760. if (chain && rule.alt.indexOf(chain) < 0) { return; }
  1761. self.__cache__[chain].push(rule.fn);
  1762. });
  1763. });
  1764. };
  1765. /**
  1766. * Ruler.at(name, fn [, options])
  1767. * - name (String): rule name to replace.
  1768. * - fn (Function): new rule function.
  1769. * - options (Object): new rule options (not mandatory).
  1770. *
  1771. * Replace rule by name with new function & options. Throws error if name not
  1772. * found.
  1773. *
  1774. * ##### Options:
  1775. *
  1776. * - __alt__ - array with names of "alternate" chains.
  1777. *
  1778. * ##### Example
  1779. *
  1780. * Replace existing typorgapher replacement rule with new one:
  1781. *
  1782. * ```javascript
  1783. * var md = require('markdown-it')();
  1784. *
  1785. * md.core.ruler.at('replacements', function replace(state) {
  1786. * //...
  1787. * });
  1788. * ```
  1789. **/
  1790. Ruler.prototype.at = function (name, fn, options) {
  1791. var index = this.__find__(name);
  1792. var opt = options || {};
  1793. if (index === -1) { throw new Error('Parser rule not found: ' + name); }
  1794. this.__rules__[index].fn = fn;
  1795. this.__rules__[index].alt = opt.alt || [];
  1796. this.__cache__ = null;
  1797. };
  1798. /**
  1799. * Ruler.before(beforeName, ruleName, fn [, options])
  1800. * - beforeName (String): new rule will be added before this one.
  1801. * - ruleName (String): name of added rule.
  1802. * - fn (Function): rule function.
  1803. * - options (Object): rule options (not mandatory).
  1804. *
  1805. * Add new rule to chain before one with given name. See also
  1806. * [[Ruler.after]], [[Ruler.push]].
  1807. *
  1808. * ##### Options:
  1809. *
  1810. * - __alt__ - array with names of "alternate" chains.
  1811. *
  1812. * ##### Example
  1813. *
  1814. * ```javascript
  1815. * var md = require('markdown-it')();
  1816. *
  1817. * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {
  1818. * //...
  1819. * });
  1820. * ```
  1821. **/
  1822. Ruler.prototype.before = function (beforeName, ruleName, fn, options) {
  1823. var index = this.__find__(beforeName);
  1824. var opt = options || {};
  1825. if (index === -1) { throw new Error('Parser rule not found: ' + beforeName); }
  1826. this.__rules__.splice(index, 0, {
  1827. name: ruleName,
  1828. enabled: true,
  1829. fn: fn,
  1830. alt: opt.alt || []
  1831. });
  1832. this.__cache__ = null;
  1833. };
  1834. /**
  1835. * Ruler.after(afterName, ruleName, fn [, options])
  1836. * - afterName (String): new rule will be added after this one.
  1837. * - ruleName (String): name of added rule.
  1838. * - fn (Function): rule function.
  1839. * - options (Object): rule options (not mandatory).
  1840. *
  1841. * Add new rule to chain after one with given name. See also
  1842. * [[Ruler.before]], [[Ruler.push]].
  1843. *
  1844. * ##### Options:
  1845. *
  1846. * - __alt__ - array with names of "alternate" chains.
  1847. *
  1848. * ##### Example
  1849. *
  1850. * ```javascript
  1851. * var md = require('markdown-it')();
  1852. *
  1853. * md.inline.ruler.after('text', 'my_rule', function replace(state) {
  1854. * //...
  1855. * });
  1856. * ```
  1857. **/
  1858. Ruler.prototype.after = function (afterName, ruleName, fn, options) {
  1859. var index = this.__find__(afterName);
  1860. var opt = options || {};
  1861. if (index === -1) { throw new Error('Parser rule not found: ' + afterName); }
  1862. this.__rules__.splice(index + 1, 0, {
  1863. name: ruleName,
  1864. enabled: true,
  1865. fn: fn,
  1866. alt: opt.alt || []
  1867. });
  1868. this.__cache__ = null;
  1869. };
  1870. /**
  1871. * Ruler.push(ruleName, fn [, options])
  1872. * - ruleName (String): name of added rule.
  1873. * - fn (Function): rule function.
  1874. * - options (Object): rule options (not mandatory).
  1875. *
  1876. * Push new rule to the end of chain. See also
  1877. * [[Ruler.before]], [[Ruler.after]].
  1878. *
  1879. * ##### Options:
  1880. *
  1881. * - __alt__ - array with names of "alternate" chains.
  1882. *
  1883. * ##### Example
  1884. *
  1885. * ```javascript
  1886. * var md = require('markdown-it')();
  1887. *
  1888. * md.core.ruler.push('my_rule', function replace(state) {
  1889. * //...
  1890. * });
  1891. * ```
  1892. **/
  1893. Ruler.prototype.push = function (ruleName, fn, options) {
  1894. var opt = options || {};
  1895. this.__rules__.push({
  1896. name: ruleName,
  1897. enabled: true,
  1898. fn: fn,
  1899. alt: opt.alt || []
  1900. });
  1901. this.__cache__ = null;
  1902. };
  1903. /**
  1904. * Ruler.enable(list [, ignoreInvalid]) -> Array
  1905. * - list (String|Array): list of rule names to enable.
  1906. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  1907. *
  1908. * Enable rules with given names. If any rule name not found - throw Error.
  1909. * Errors can be disabled by second param.
  1910. *
  1911. * Returns list of found rule names (if no exception happened).
  1912. *
  1913. * See also [[Ruler.disable]], [[Ruler.enableOnly]].
  1914. **/
  1915. Ruler.prototype.enable = function (list, ignoreInvalid) {
  1916. if (!Array.isArray(list)) { list = [ list ]; }
  1917. var result = [];
  1918. // Search by name and enable
  1919. list.forEach(function (name) {
  1920. var idx = this.__find__(name);
  1921. if (idx < 0) {
  1922. if (ignoreInvalid) { return; }
  1923. throw new Error('Rules manager: invalid rule name ' + name);
  1924. }
  1925. this.__rules__[idx].enabled = true;
  1926. result.push(name);
  1927. }, this);
  1928. this.__cache__ = null;
  1929. return result;
  1930. };
  1931. /**
  1932. * Ruler.enableOnly(list [, ignoreInvalid])
  1933. * - list (String|Array): list of rule names to enable (whitelist).
  1934. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  1935. *
  1936. * Enable rules with given names, and disable everything else. If any rule name
  1937. * not found - throw Error. Errors can be disabled by second param.
  1938. *
  1939. * See also [[Ruler.disable]], [[Ruler.enable]].
  1940. **/
  1941. Ruler.prototype.enableOnly = function (list, ignoreInvalid) {
  1942. if (!Array.isArray(list)) { list = [ list ]; }
  1943. this.__rules__.forEach(function (rule) { rule.enabled = false; });
  1944. this.enable(list, ignoreInvalid);
  1945. };
  1946. /**
  1947. * Ruler.disable(list [, ignoreInvalid]) -> Array
  1948. * - list (String|Array): list of rule names to disable.
  1949. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  1950. *
  1951. * Disable rules with given names. If any rule name not found - throw Error.
  1952. * Errors can be disabled by second param.
  1953. *
  1954. * Returns list of found rule names (if no exception happened).
  1955. *
  1956. * See also [[Ruler.enable]], [[Ruler.enableOnly]].
  1957. **/
  1958. Ruler.prototype.disable = function (list, ignoreInvalid) {
  1959. if (!Array.isArray(list)) { list = [ list ]; }
  1960. var result = [];
  1961. // Search by name and disable
  1962. list.forEach(function (name) {
  1963. var idx = this.__find__(name);
  1964. if (idx < 0) {
  1965. if (ignoreInvalid) { return; }
  1966. throw new Error('Rules manager: invalid rule name ' + name);
  1967. }
  1968. this.__rules__[idx].enabled = false;
  1969. result.push(name);
  1970. }, this);
  1971. this.__cache__ = null;
  1972. return result;
  1973. };
  1974. /**
  1975. * Ruler.getRules(chainName) -> Array
  1976. *
  1977. * Return array of active functions (rules) for given chain name. It analyzes
  1978. * rules configuration, compiles caches if not exists and returns result.
  1979. *
  1980. * Default chain name is `''` (empty string). It can't be skipped. That's
  1981. * done intentionally, to keep signature monomorphic for high speed.
  1982. **/
  1983. Ruler.prototype.getRules = function (chainName) {
  1984. if (this.__cache__ === null) {
  1985. this.__compile__();
  1986. }
  1987. // Chain can be empty, if rules disabled. But we still have to return Array.
  1988. return this.__cache__[chainName] || [];
  1989. };
  1990. module.exports = Ruler;
  1991. },{}],18:[function(require,module,exports){
  1992. // Block quotes
  1993. 'use strict';
  1994. var isSpace = require('../common/utils').isSpace;
  1995. module.exports = function blockquote(state, startLine, endLine, silent) {
  1996. var adjustTab,
  1997. ch,
  1998. i,
  1999. initial,
  2000. isOutdented,
  2001. l,
  2002. lastLineEmpty,
  2003. lines,
  2004. nextLine,
  2005. offset,
  2006. oldBMarks,
  2007. oldBSCount,
  2008. oldIndent,
  2009. oldParentType,
  2010. oldSCount,
  2011. oldTShift,
  2012. spaceAfterMarker,
  2013. terminate,
  2014. terminatorRules,
  2015. token,
  2016. oldLineMax = state.lineMax,
  2017. pos = state.bMarks[startLine] + state.tShift[startLine],
  2018. max = state.eMarks[startLine];
  2019. // if it's indented more than 3 spaces, it should be a code block
  2020. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2021. // check the block quote marker
  2022. if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; }
  2023. // we know that it's going to be a valid blockquote,
  2024. // so no point trying to find the end of it in silent mode
  2025. if (silent) { return true; }
  2026. // skip spaces after ">" and re-calculate offset
  2027. initial = offset = state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]);
  2028. // skip one optional space after '>'
  2029. if (state.src.charCodeAt(pos) === 0x20 /* space */) {
  2030. // ' > test '
  2031. // ^ -- position start of line here:
  2032. pos++;
  2033. initial++;
  2034. offset++;
  2035. adjustTab = false;
  2036. spaceAfterMarker = true;
  2037. } else if (state.src.charCodeAt(pos) === 0x09 /* tab */) {
  2038. spaceAfterMarker = true;
  2039. if ((state.bsCount[startLine] + offset) % 4 === 3) {
  2040. // ' >\t test '
  2041. // ^ -- position start of line here (tab has width===1)
  2042. pos++;
  2043. initial++;
  2044. offset++;
  2045. adjustTab = false;
  2046. } else {
  2047. // ' >\t test '
  2048. // ^ -- position start of line here + shift bsCount slightly
  2049. // to make extra space appear
  2050. adjustTab = true;
  2051. }
  2052. } else {
  2053. spaceAfterMarker = false;
  2054. }
  2055. oldBMarks = [ state.bMarks[startLine] ];
  2056. state.bMarks[startLine] = pos;
  2057. while (pos < max) {
  2058. ch = state.src.charCodeAt(pos);
  2059. if (isSpace(ch)) {
  2060. if (ch === 0x09) {
  2061. offset += 4 - (offset + state.bsCount[startLine] + (adjustTab ? 1 : 0)) % 4;
  2062. } else {
  2063. offset++;
  2064. }
  2065. } else {
  2066. break;
  2067. }
  2068. pos++;
  2069. }
  2070. oldBSCount = [ state.bsCount[startLine] ];
  2071. state.bsCount[startLine] = state.sCount[startLine] + 1 + (spaceAfterMarker ? 1 : 0);
  2072. lastLineEmpty = pos >= max;
  2073. oldSCount = [ state.sCount[startLine] ];
  2074. state.sCount[startLine] = offset - initial;
  2075. oldTShift = [ state.tShift[startLine] ];
  2076. state.tShift[startLine] = pos - state.bMarks[startLine];
  2077. terminatorRules = state.md.block.ruler.getRules('blockquote');
  2078. oldParentType = state.parentType;
  2079. state.parentType = 'blockquote';
  2080. // Search the end of the block
  2081. //
  2082. // Block ends with either:
  2083. // 1. an empty line outside:
  2084. // ```
  2085. // > test
  2086. //
  2087. // ```
  2088. // 2. an empty line inside:
  2089. // ```
  2090. // >
  2091. // test
  2092. // ```
  2093. // 3. another tag:
  2094. // ```
  2095. // > test
  2096. // - - -
  2097. // ```
  2098. for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
  2099. // check if it's outdented, i.e. it's inside list item and indented
  2100. // less than said list item:
  2101. //
  2102. // ```
  2103. // 1. anything
  2104. // > current blockquote
  2105. // 2. checking this line
  2106. // ```
  2107. isOutdented = state.sCount[nextLine] < state.blkIndent;
  2108. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  2109. max = state.eMarks[nextLine];
  2110. if (pos >= max) {
  2111. // Case 1: line is not inside the blockquote, and this line is empty.
  2112. break;
  2113. }
  2114. if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !isOutdented) {
  2115. // This line is inside the blockquote.
  2116. // skip spaces after ">" and re-calculate offset
  2117. initial = offset = state.sCount[nextLine] + pos - (state.bMarks[nextLine] + state.tShift[nextLine]);
  2118. // skip one optional space after '>'
  2119. if (state.src.charCodeAt(pos) === 0x20 /* space */) {
  2120. // ' > test '
  2121. // ^ -- position start of line here:
  2122. pos++;
  2123. initial++;
  2124. offset++;
  2125. adjustTab = false;
  2126. spaceAfterMarker = true;
  2127. } else if (state.src.charCodeAt(pos) === 0x09 /* tab */) {
  2128. spaceAfterMarker = true;
  2129. if ((state.bsCount[nextLine] + offset) % 4 === 3) {
  2130. // ' >\t test '
  2131. // ^ -- position start of line here (tab has width===1)
  2132. pos++;
  2133. initial++;
  2134. offset++;
  2135. adjustTab = false;
  2136. } else {
  2137. // ' >\t test '
  2138. // ^ -- position start of line here + shift bsCount slightly
  2139. // to make extra space appear
  2140. adjustTab = true;
  2141. }
  2142. } else {
  2143. spaceAfterMarker = false;
  2144. }
  2145. oldBMarks.push(state.bMarks[nextLine]);
  2146. state.bMarks[nextLine] = pos;
  2147. while (pos < max) {
  2148. ch = state.src.charCodeAt(pos);
  2149. if (isSpace(ch)) {
  2150. if (ch === 0x09) {
  2151. offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4;
  2152. } else {
  2153. offset++;
  2154. }
  2155. } else {
  2156. break;
  2157. }
  2158. pos++;
  2159. }
  2160. lastLineEmpty = pos >= max;
  2161. oldBSCount.push(state.bsCount[nextLine]);
  2162. state.bsCount[nextLine] = state.sCount[nextLine] + 1 + (spaceAfterMarker ? 1 : 0);
  2163. oldSCount.push(state.sCount[nextLine]);
  2164. state.sCount[nextLine] = offset - initial;
  2165. oldTShift.push(state.tShift[nextLine]);
  2166. state.tShift[nextLine] = pos - state.bMarks[nextLine];
  2167. continue;
  2168. }
  2169. // Case 2: line is not inside the blockquote, and the last line was empty.
  2170. if (lastLineEmpty) { break; }
  2171. // Case 3: another tag found.
  2172. terminate = false;
  2173. for (i = 0, l = terminatorRules.length; i < l; i++) {
  2174. if (terminatorRules[i](state, nextLine, endLine, true)) {
  2175. terminate = true;
  2176. break;
  2177. }
  2178. }
  2179. if (terminate) {
  2180. // Quirk to enforce "hard termination mode" for paragraphs;
  2181. // normally if you call `tokenize(state, startLine, nextLine)`,
  2182. // paragraphs will look below nextLine for paragraph continuation,
  2183. // but if blockquote is terminated by another tag, they shouldn't
  2184. state.lineMax = nextLine;
  2185. if (state.blkIndent !== 0) {
  2186. // state.blkIndent was non-zero, we now set it to zero,
  2187. // so we need to re-calculate all offsets to appear as
  2188. // if indent wasn't changed
  2189. oldBMarks.push(state.bMarks[nextLine]);
  2190. oldBSCount.push(state.bsCount[nextLine]);
  2191. oldTShift.push(state.tShift[nextLine]);
  2192. oldSCount.push(state.sCount[nextLine]);
  2193. state.sCount[nextLine] -= state.blkIndent;
  2194. }
  2195. break;
  2196. }
  2197. if (isOutdented) break;
  2198. oldBMarks.push(state.bMarks[nextLine]);
  2199. oldBSCount.push(state.bsCount[nextLine]);
  2200. oldTShift.push(state.tShift[nextLine]);
  2201. oldSCount.push(state.sCount[nextLine]);
  2202. // A negative indentation means that this is a paragraph continuation
  2203. //
  2204. state.sCount[nextLine] = -1;
  2205. }
  2206. oldIndent = state.blkIndent;
  2207. state.blkIndent = 0;
  2208. token = state.push('blockquote_open', 'blockquote', 1);
  2209. token.markup = '>';
  2210. token.map = lines = [ startLine, 0 ];
  2211. state.md.block.tokenize(state, startLine, nextLine);
  2212. token = state.push('blockquote_close', 'blockquote', -1);
  2213. token.markup = '>';
  2214. state.lineMax = oldLineMax;
  2215. state.parentType = oldParentType;
  2216. lines[1] = state.line;
  2217. // Restore original tShift; this might not be necessary since the parser
  2218. // has already been here, but just to make sure we can do that.
  2219. for (i = 0; i < oldTShift.length; i++) {
  2220. state.bMarks[i + startLine] = oldBMarks[i];
  2221. state.tShift[i + startLine] = oldTShift[i];
  2222. state.sCount[i + startLine] = oldSCount[i];
  2223. state.bsCount[i + startLine] = oldBSCount[i];
  2224. }
  2225. state.blkIndent = oldIndent;
  2226. return true;
  2227. };
  2228. },{"../common/utils":4}],19:[function(require,module,exports){
  2229. // Code block (4 spaces padded)
  2230. 'use strict';
  2231. module.exports = function code(state, startLine, endLine/*, silent*/) {
  2232. var nextLine, last, token;
  2233. if (state.sCount[startLine] - state.blkIndent < 4) { return false; }
  2234. last = nextLine = startLine + 1;
  2235. while (nextLine < endLine) {
  2236. if (state.isEmpty(nextLine)) {
  2237. nextLine++;
  2238. continue;
  2239. }
  2240. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  2241. nextLine++;
  2242. last = nextLine;
  2243. continue;
  2244. }
  2245. break;
  2246. }
  2247. state.line = last;
  2248. token = state.push('code_block', 'code', 0);
  2249. token.content = state.getLines(startLine, last, 4 + state.blkIndent, true);
  2250. token.map = [ startLine, state.line ];
  2251. return true;
  2252. };
  2253. },{}],20:[function(require,module,exports){
  2254. // fences (``` lang, ~~~ lang)
  2255. 'use strict';
  2256. module.exports = function fence(state, startLine, endLine, silent) {
  2257. var marker, len, params, nextLine, mem, token, markup,
  2258. haveEndMarker = false,
  2259. pos = state.bMarks[startLine] + state.tShift[startLine],
  2260. max = state.eMarks[startLine];
  2261. // if it's indented more than 3 spaces, it should be a code block
  2262. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2263. if (pos + 3 > max) { return false; }
  2264. marker = state.src.charCodeAt(pos);
  2265. if (marker !== 0x7E/* ~ */ && marker !== 0x60 /* ` */) {
  2266. return false;
  2267. }
  2268. // scan marker length
  2269. mem = pos;
  2270. pos = state.skipChars(pos, marker);
  2271. len = pos - mem;
  2272. if (len < 3) { return false; }
  2273. markup = state.src.slice(mem, pos);
  2274. params = state.src.slice(pos, max);
  2275. if (params.indexOf(String.fromCharCode(marker)) >= 0) { return false; }
  2276. // Since start is found, we can report success here in validation mode
  2277. if (silent) { return true; }
  2278. // search end of block
  2279. nextLine = startLine;
  2280. for (;;) {
  2281. nextLine++;
  2282. if (nextLine >= endLine) {
  2283. // unclosed block should be autoclosed by end of document.
  2284. // also block seems to be autoclosed by end of parent
  2285. break;
  2286. }
  2287. pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
  2288. max = state.eMarks[nextLine];
  2289. if (pos < max && state.sCount[nextLine] < state.blkIndent) {
  2290. // non-empty line with negative indent should stop the list:
  2291. // - ```
  2292. // test
  2293. break;
  2294. }
  2295. if (state.src.charCodeAt(pos) !== marker) { continue; }
  2296. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  2297. // closing fence should be indented less than 4 spaces
  2298. continue;
  2299. }
  2300. pos = state.skipChars(pos, marker);
  2301. // closing code fence must be at least as long as the opening one
  2302. if (pos - mem < len) { continue; }
  2303. // make sure tail has spaces only
  2304. pos = state.skipSpaces(pos);
  2305. if (pos < max) { continue; }
  2306. haveEndMarker = true;
  2307. // found!
  2308. break;
  2309. }
  2310. // If a fence has heading spaces, they should be removed from its inner block
  2311. len = state.sCount[startLine];
  2312. state.line = nextLine + (haveEndMarker ? 1 : 0);
  2313. token = state.push('fence', 'code', 0);
  2314. token.info = params;
  2315. token.content = state.getLines(startLine + 1, nextLine, len, true);
  2316. token.markup = markup;
  2317. token.map = [ startLine, state.line ];
  2318. return true;
  2319. };
  2320. },{}],21:[function(require,module,exports){
  2321. // heading (#, ##, ...)
  2322. 'use strict';
  2323. var isSpace = require('../common/utils').isSpace;
  2324. module.exports = function heading(state, startLine, endLine, silent) {
  2325. var ch, level, tmp, token,
  2326. pos = state.bMarks[startLine] + state.tShift[startLine],
  2327. max = state.eMarks[startLine];
  2328. // if it's indented more than 3 spaces, it should be a code block
  2329. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2330. ch = state.src.charCodeAt(pos);
  2331. if (ch !== 0x23/* # */ || pos >= max) { return false; }
  2332. // count heading level
  2333. level = 1;
  2334. ch = state.src.charCodeAt(++pos);
  2335. while (ch === 0x23/* # */ && pos < max && level <= 6) {
  2336. level++;
  2337. ch = state.src.charCodeAt(++pos);
  2338. }
  2339. if (level > 6 || (pos < max && !isSpace(ch))) { return false; }
  2340. if (silent) { return true; }
  2341. // Let's cut tails like ' ### ' from the end of string
  2342. max = state.skipSpacesBack(max, pos);
  2343. tmp = state.skipCharsBack(max, 0x23, pos); // #
  2344. if (tmp > pos && isSpace(state.src.charCodeAt(tmp - 1))) {
  2345. max = tmp;
  2346. }
  2347. state.line = startLine + 1;
  2348. token = state.push('heading_open', 'h' + String(level), 1);
  2349. token.markup = '########'.slice(0, level);
  2350. token.map = [ startLine, state.line ];
  2351. token = state.push('inline', '', 0);
  2352. token.content = state.src.slice(pos, max).trim();
  2353. token.map = [ startLine, state.line ];
  2354. token.children = [];
  2355. token = state.push('heading_close', 'h' + String(level), -1);
  2356. token.markup = '########'.slice(0, level);
  2357. return true;
  2358. };
  2359. },{"../common/utils":4}],22:[function(require,module,exports){
  2360. // Horizontal rule
  2361. 'use strict';
  2362. var isSpace = require('../common/utils').isSpace;
  2363. module.exports = function hr(state, startLine, endLine, silent) {
  2364. var marker, cnt, ch, token,
  2365. pos = state.bMarks[startLine] + state.tShift[startLine],
  2366. max = state.eMarks[startLine];
  2367. // if it's indented more than 3 spaces, it should be a code block
  2368. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2369. marker = state.src.charCodeAt(pos++);
  2370. // Check hr marker
  2371. if (marker !== 0x2A/* * */ &&
  2372. marker !== 0x2D/* - */ &&
  2373. marker !== 0x5F/* _ */) {
  2374. return false;
  2375. }
  2376. // markers can be mixed with spaces, but there should be at least 3 of them
  2377. cnt = 1;
  2378. while (pos < max) {
  2379. ch = state.src.charCodeAt(pos++);
  2380. if (ch !== marker && !isSpace(ch)) { return false; }
  2381. if (ch === marker) { cnt++; }
  2382. }
  2383. if (cnt < 3) { return false; }
  2384. if (silent) { return true; }
  2385. state.line = startLine + 1;
  2386. token = state.push('hr', 'hr', 0);
  2387. token.map = [ startLine, state.line ];
  2388. token.markup = Array(cnt + 1).join(String.fromCharCode(marker));
  2389. return true;
  2390. };
  2391. },{"../common/utils":4}],23:[function(require,module,exports){
  2392. // HTML block
  2393. 'use strict';
  2394. var block_names = require('../common/html_blocks');
  2395. var HTML_OPEN_CLOSE_TAG_RE = require('../common/html_re').HTML_OPEN_CLOSE_TAG_RE;
  2396. // An array of opening and corresponding closing sequences for html tags,
  2397. // last argument defines whether it can terminate a paragraph or not
  2398. //
  2399. var HTML_SEQUENCES = [
  2400. [ /^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true ],
  2401. [ /^<!--/, /-->/, true ],
  2402. [ /^<\?/, /\?>/, true ],
  2403. [ /^<![A-Z]/, />/, true ],
  2404. [ /^<!\[CDATA\[/, /\]\]>/, true ],
  2405. [ new RegExp('^</?(' + block_names.join('|') + ')(?=(\\s|/?>|$))', 'i'), /^$/, true ],
  2406. [ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false ]
  2407. ];
  2408. module.exports = function html_block(state, startLine, endLine, silent) {
  2409. var i, nextLine, token, lineText,
  2410. pos = state.bMarks[startLine] + state.tShift[startLine],
  2411. max = state.eMarks[startLine];
  2412. // if it's indented more than 3 spaces, it should be a code block
  2413. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2414. if (!state.md.options.html) { return false; }
  2415. if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
  2416. lineText = state.src.slice(pos, max);
  2417. for (i = 0; i < HTML_SEQUENCES.length; i++) {
  2418. if (HTML_SEQUENCES[i][0].test(lineText)) { break; }
  2419. }
  2420. if (i === HTML_SEQUENCES.length) { return false; }
  2421. if (silent) {
  2422. // true if this sequence can be a terminator, false otherwise
  2423. return HTML_SEQUENCES[i][2];
  2424. }
  2425. nextLine = startLine + 1;
  2426. // If we are here - we detected HTML block.
  2427. // Let's roll down till block end.
  2428. if (!HTML_SEQUENCES[i][1].test(lineText)) {
  2429. for (; nextLine < endLine; nextLine++) {
  2430. if (state.sCount[nextLine] < state.blkIndent) { break; }
  2431. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  2432. max = state.eMarks[nextLine];
  2433. lineText = state.src.slice(pos, max);
  2434. if (HTML_SEQUENCES[i][1].test(lineText)) {
  2435. if (lineText.length !== 0) { nextLine++; }
  2436. break;
  2437. }
  2438. }
  2439. }
  2440. state.line = nextLine;
  2441. token = state.push('html_block', '', 0);
  2442. token.map = [ startLine, nextLine ];
  2443. token.content = state.getLines(startLine, nextLine, state.blkIndent, true);
  2444. return true;
  2445. };
  2446. },{"../common/html_blocks":2,"../common/html_re":3}],24:[function(require,module,exports){
  2447. // lheading (---, ===)
  2448. 'use strict';
  2449. module.exports = function lheading(state, startLine, endLine/*, silent*/) {
  2450. var content, terminate, i, l, token, pos, max, level, marker,
  2451. nextLine = startLine + 1, oldParentType,
  2452. terminatorRules = state.md.block.ruler.getRules('paragraph');
  2453. // if it's indented more than 3 spaces, it should be a code block
  2454. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2455. oldParentType = state.parentType;
  2456. state.parentType = 'paragraph'; // use paragraph to match terminatorRules
  2457. // jump line-by-line until empty one or EOF
  2458. for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
  2459. // this would be a code block normally, but after paragraph
  2460. // it's considered a lazy continuation regardless of what's there
  2461. if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
  2462. //
  2463. // Check for underline in setext header
  2464. //
  2465. if (state.sCount[nextLine] >= state.blkIndent) {
  2466. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  2467. max = state.eMarks[nextLine];
  2468. if (pos < max) {
  2469. marker = state.src.charCodeAt(pos);
  2470. if (marker === 0x2D/* - */ || marker === 0x3D/* = */) {
  2471. pos = state.skipChars(pos, marker);
  2472. pos = state.skipSpaces(pos);
  2473. if (pos >= max) {
  2474. level = (marker === 0x3D/* = */ ? 1 : 2);
  2475. break;
  2476. }
  2477. }
  2478. }
  2479. }
  2480. // quirk for blockquotes, this line should already be checked by that rule
  2481. if (state.sCount[nextLine] < 0) { continue; }
  2482. // Some tags can terminate paragraph without empty line.
  2483. terminate = false;
  2484. for (i = 0, l = terminatorRules.length; i < l; i++) {
  2485. if (terminatorRules[i](state, nextLine, endLine, true)) {
  2486. terminate = true;
  2487. break;
  2488. }
  2489. }
  2490. if (terminate) { break; }
  2491. }
  2492. if (!level) {
  2493. // Didn't find valid underline
  2494. return false;
  2495. }
  2496. content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
  2497. state.line = nextLine + 1;
  2498. token = state.push('heading_open', 'h' + String(level), 1);
  2499. token.markup = String.fromCharCode(marker);
  2500. token.map = [ startLine, state.line ];
  2501. token = state.push('inline', '', 0);
  2502. token.content = content;
  2503. token.map = [ startLine, state.line - 1 ];
  2504. token.children = [];
  2505. token = state.push('heading_close', 'h' + String(level), -1);
  2506. token.markup = String.fromCharCode(marker);
  2507. state.parentType = oldParentType;
  2508. return true;
  2509. };
  2510. },{}],25:[function(require,module,exports){
  2511. // Lists
  2512. 'use strict';
  2513. var isSpace = require('../common/utils').isSpace;
  2514. // Search `[-+*][\n ]`, returns next pos arter marker on success
  2515. // or -1 on fail.
  2516. function skipBulletListMarker(state, startLine) {
  2517. var marker, pos, max, ch;
  2518. pos = state.bMarks[startLine] + state.tShift[startLine];
  2519. max = state.eMarks[startLine];
  2520. marker = state.src.charCodeAt(pos++);
  2521. // Check bullet
  2522. if (marker !== 0x2A/* * */ &&
  2523. marker !== 0x2D/* - */ &&
  2524. marker !== 0x2B/* + */) {
  2525. return -1;
  2526. }
  2527. if (pos < max) {
  2528. ch = state.src.charCodeAt(pos);
  2529. if (!isSpace(ch)) {
  2530. // " -test " - is not a list item
  2531. return -1;
  2532. }
  2533. }
  2534. return pos;
  2535. }
  2536. // Search `\d+[.)][\n ]`, returns next pos arter marker on success
  2537. // or -1 on fail.
  2538. function skipOrderedListMarker(state, startLine) {
  2539. var ch,
  2540. start = state.bMarks[startLine] + state.tShift[startLine],
  2541. pos = start,
  2542. max = state.eMarks[startLine];
  2543. // List marker should have at least 2 chars (digit + dot)
  2544. if (pos + 1 >= max) { return -1; }
  2545. ch = state.src.charCodeAt(pos++);
  2546. if (ch < 0x30/* 0 */ || ch > 0x39/* 9 */) { return -1; }
  2547. for (;;) {
  2548. // EOL -> fail
  2549. if (pos >= max) { return -1; }
  2550. ch = state.src.charCodeAt(pos++);
  2551. if (ch >= 0x30/* 0 */ && ch <= 0x39/* 9 */) {
  2552. // List marker should have no more than 9 digits
  2553. // (prevents integer overflow in browsers)
  2554. if (pos - start >= 10) { return -1; }
  2555. continue;
  2556. }
  2557. // found valid marker
  2558. if (ch === 0x29/* ) */ || ch === 0x2e/* . */) {
  2559. break;
  2560. }
  2561. return -1;
  2562. }
  2563. if (pos < max) {
  2564. ch = state.src.charCodeAt(pos);
  2565. if (!isSpace(ch)) {
  2566. // " 1.test " - is not a list item
  2567. return -1;
  2568. }
  2569. }
  2570. return pos;
  2571. }
  2572. function markTightParagraphs(state, idx) {
  2573. var i, l,
  2574. level = state.level + 2;
  2575. for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
  2576. if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') {
  2577. state.tokens[i + 2].hidden = true;
  2578. state.tokens[i].hidden = true;
  2579. i += 2;
  2580. }
  2581. }
  2582. }
  2583. module.exports = function list(state, startLine, endLine, silent) {
  2584. var ch,
  2585. contentStart,
  2586. i,
  2587. indent,
  2588. indentAfterMarker,
  2589. initial,
  2590. isOrdered,
  2591. itemLines,
  2592. l,
  2593. listLines,
  2594. listTokIdx,
  2595. markerCharCode,
  2596. markerValue,
  2597. max,
  2598. nextLine,
  2599. offset,
  2600. oldIndent,
  2601. oldLIndent,
  2602. oldParentType,
  2603. oldTShift,
  2604. oldTight,
  2605. pos,
  2606. posAfterMarker,
  2607. prevEmptyEnd,
  2608. start,
  2609. terminate,
  2610. terminatorRules,
  2611. token,
  2612. isTerminatingParagraph = false,
  2613. tight = true;
  2614. // if it's indented more than 3 spaces, it should be a code block
  2615. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2616. // limit conditions when list can interrupt
  2617. // a paragraph (validation mode only)
  2618. if (silent && state.parentType === 'paragraph') {
  2619. // Next list item should still terminate previous list item;
  2620. //
  2621. // This code can fail if plugins use blkIndent as well as lists,
  2622. // but I hope the spec gets fixed long before that happens.
  2623. //
  2624. if (state.tShift[startLine] >= state.blkIndent) {
  2625. isTerminatingParagraph = true;
  2626. }
  2627. }
  2628. // Detect list type and position after marker
  2629. if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {
  2630. isOrdered = true;
  2631. start = state.bMarks[startLine] + state.tShift[startLine];
  2632. markerValue = Number(state.src.substr(start, posAfterMarker - start - 1));
  2633. // If we're starting a new ordered list right after
  2634. // a paragraph, it should start with 1.
  2635. if (isTerminatingParagraph && markerValue !== 1) return false;
  2636. } else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {
  2637. isOrdered = false;
  2638. } else {
  2639. return false;
  2640. }
  2641. // If we're starting a new unordered list right after
  2642. // a paragraph, first line should not be empty.
  2643. if (isTerminatingParagraph) {
  2644. if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine]) return false;
  2645. }
  2646. // We should terminate list on style change. Remember first one to compare.
  2647. markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
  2648. // For validation mode we can terminate immediately
  2649. if (silent) { return true; }
  2650. // Start list
  2651. listTokIdx = state.tokens.length;
  2652. if (isOrdered) {
  2653. token = state.push('ordered_list_open', 'ol', 1);
  2654. if (markerValue !== 1) {
  2655. token.attrs = [ [ 'start', markerValue ] ];
  2656. }
  2657. } else {
  2658. token = state.push('bullet_list_open', 'ul', 1);
  2659. }
  2660. token.map = listLines = [ startLine, 0 ];
  2661. token.markup = String.fromCharCode(markerCharCode);
  2662. //
  2663. // Iterate list items
  2664. //
  2665. nextLine = startLine;
  2666. prevEmptyEnd = false;
  2667. terminatorRules = state.md.block.ruler.getRules('list');
  2668. oldParentType = state.parentType;
  2669. state.parentType = 'list';
  2670. while (nextLine < endLine) {
  2671. pos = posAfterMarker;
  2672. max = state.eMarks[nextLine];
  2673. initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[startLine] + state.tShift[startLine]);
  2674. while (pos < max) {
  2675. ch = state.src.charCodeAt(pos);
  2676. if (isSpace(ch)) {
  2677. if (ch === 0x09) {
  2678. offset += 4 - (offset + state.bsCount[nextLine]) % 4;
  2679. } else {
  2680. offset++;
  2681. }
  2682. } else {
  2683. break;
  2684. }
  2685. pos++;
  2686. }
  2687. contentStart = pos;
  2688. if (contentStart >= max) {
  2689. // trimming space in "- \n 3" case, indent is 1 here
  2690. indentAfterMarker = 1;
  2691. } else {
  2692. indentAfterMarker = offset - initial;
  2693. }
  2694. // If we have more than 4 spaces, the indent is 1
  2695. // (the rest is just indented code block)
  2696. if (indentAfterMarker > 4) { indentAfterMarker = 1; }
  2697. // " - test"
  2698. // ^^^^^ - calculating total length of this thing
  2699. indent = initial + indentAfterMarker;
  2700. // Run subparser & write tokens
  2701. token = state.push('list_item_open', 'li', 1);
  2702. token.markup = String.fromCharCode(markerCharCode);
  2703. token.map = itemLines = [ startLine, 0 ];
  2704. oldIndent = state.blkIndent;
  2705. oldTight = state.tight;
  2706. oldTShift = state.tShift[startLine];
  2707. oldLIndent = state.sCount[startLine];
  2708. state.blkIndent = indent;
  2709. state.tight = true;
  2710. state.tShift[startLine] = contentStart - state.bMarks[startLine];
  2711. state.sCount[startLine] = offset;
  2712. if (contentStart >= max && state.isEmpty(startLine + 1)) {
  2713. // workaround for this case
  2714. // (list item is empty, list terminates before "foo"):
  2715. // ~~~~~~~~
  2716. // -
  2717. //
  2718. // foo
  2719. // ~~~~~~~~
  2720. state.line = Math.min(state.line + 2, endLine);
  2721. } else {
  2722. state.md.block.tokenize(state, startLine, endLine, true);
  2723. }
  2724. // If any of list item is tight, mark list as tight
  2725. if (!state.tight || prevEmptyEnd) {
  2726. tight = false;
  2727. }
  2728. // Item become loose if finish with empty line,
  2729. // but we should filter last element, because it means list finish
  2730. prevEmptyEnd = (state.line - startLine) > 1 && state.isEmpty(state.line - 1);
  2731. state.blkIndent = oldIndent;
  2732. state.tShift[startLine] = oldTShift;
  2733. state.sCount[startLine] = oldLIndent;
  2734. state.tight = oldTight;
  2735. token = state.push('list_item_close', 'li', -1);
  2736. token.markup = String.fromCharCode(markerCharCode);
  2737. nextLine = startLine = state.line;
  2738. itemLines[1] = nextLine;
  2739. contentStart = state.bMarks[startLine];
  2740. if (nextLine >= endLine) { break; }
  2741. //
  2742. // Try to check if list is terminated or continued.
  2743. //
  2744. if (state.sCount[nextLine] < state.blkIndent) { break; }
  2745. // fail if terminating block found
  2746. terminate = false;
  2747. for (i = 0, l = terminatorRules.length; i < l; i++) {
  2748. if (terminatorRules[i](state, nextLine, endLine, true)) {
  2749. terminate = true;
  2750. break;
  2751. }
  2752. }
  2753. if (terminate) { break; }
  2754. // fail if list has another type
  2755. if (isOrdered) {
  2756. posAfterMarker = skipOrderedListMarker(state, nextLine);
  2757. if (posAfterMarker < 0) { break; }
  2758. } else {
  2759. posAfterMarker = skipBulletListMarker(state, nextLine);
  2760. if (posAfterMarker < 0) { break; }
  2761. }
  2762. if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; }
  2763. }
  2764. // Finilize list
  2765. if (isOrdered) {
  2766. token = state.push('ordered_list_close', 'ol', -1);
  2767. } else {
  2768. token = state.push('bullet_list_close', 'ul', -1);
  2769. }
  2770. token.markup = String.fromCharCode(markerCharCode);
  2771. listLines[1] = nextLine;
  2772. state.line = nextLine;
  2773. state.parentType = oldParentType;
  2774. // mark paragraphs tight if needed
  2775. if (tight) {
  2776. markTightParagraphs(state, listTokIdx);
  2777. }
  2778. return true;
  2779. };
  2780. },{"../common/utils":4}],26:[function(require,module,exports){
  2781. // Paragraph
  2782. 'use strict';
  2783. module.exports = function paragraph(state, startLine/*, endLine*/) {
  2784. var content, terminate, i, l, token, oldParentType,
  2785. nextLine = startLine + 1,
  2786. terminatorRules = state.md.block.ruler.getRules('paragraph'),
  2787. endLine = state.lineMax;
  2788. oldParentType = state.parentType;
  2789. state.parentType = 'paragraph';
  2790. // jump line-by-line until empty one or EOF
  2791. for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
  2792. // this would be a code block normally, but after paragraph
  2793. // it's considered a lazy continuation regardless of what's there
  2794. if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
  2795. // quirk for blockquotes, this line should already be checked by that rule
  2796. if (state.sCount[nextLine] < 0) { continue; }
  2797. // Some tags can terminate paragraph without empty line.
  2798. terminate = false;
  2799. for (i = 0, l = terminatorRules.length; i < l; i++) {
  2800. if (terminatorRules[i](state, nextLine, endLine, true)) {
  2801. terminate = true;
  2802. break;
  2803. }
  2804. }
  2805. if (terminate) { break; }
  2806. }
  2807. content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
  2808. state.line = nextLine;
  2809. token = state.push('paragraph_open', 'p', 1);
  2810. token.map = [ startLine, state.line ];
  2811. token = state.push('inline', '', 0);
  2812. token.content = content;
  2813. token.map = [ startLine, state.line ];
  2814. token.children = [];
  2815. token = state.push('paragraph_close', 'p', -1);
  2816. state.parentType = oldParentType;
  2817. return true;
  2818. };
  2819. },{}],27:[function(require,module,exports){
  2820. 'use strict';
  2821. var normalizeReference = require('../common/utils').normalizeReference;
  2822. var isSpace = require('../common/utils').isSpace;
  2823. module.exports = function reference(state, startLine, _endLine, silent) {
  2824. var ch,
  2825. destEndPos,
  2826. destEndLineNo,
  2827. endLine,
  2828. href,
  2829. i,
  2830. l,
  2831. label,
  2832. labelEnd,
  2833. oldParentType,
  2834. res,
  2835. start,
  2836. str,
  2837. terminate,
  2838. terminatorRules,
  2839. title,
  2840. lines = 0,
  2841. pos = state.bMarks[startLine] + state.tShift[startLine],
  2842. max = state.eMarks[startLine],
  2843. nextLine = startLine + 1;
  2844. // if it's indented more than 3 spaces, it should be a code block
  2845. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  2846. if (state.src.charCodeAt(pos) !== 0x5B/* [ */) { return false; }
  2847. // Simple check to quickly interrupt scan on [link](url) at the start of line.
  2848. // Can be useful on practice: https://github.com/markdown-it/markdown-it/issues/54
  2849. while (++pos < max) {
  2850. if (state.src.charCodeAt(pos) === 0x5D /* ] */ &&
  2851. state.src.charCodeAt(pos - 1) !== 0x5C/* \ */) {
  2852. if (pos + 1 === max) { return false; }
  2853. if (state.src.charCodeAt(pos + 1) !== 0x3A/* : */) { return false; }
  2854. break;
  2855. }
  2856. }
  2857. endLine = state.lineMax;
  2858. // jump line-by-line until empty one or EOF
  2859. terminatorRules = state.md.block.ruler.getRules('reference');
  2860. oldParentType = state.parentType;
  2861. state.parentType = 'reference';
  2862. for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
  2863. // this would be a code block normally, but after paragraph
  2864. // it's considered a lazy continuation regardless of what's there
  2865. if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
  2866. // quirk for blockquotes, this line should already be checked by that rule
  2867. if (state.sCount[nextLine] < 0) { continue; }
  2868. // Some tags can terminate paragraph without empty line.
  2869. terminate = false;
  2870. for (i = 0, l = terminatorRules.length; i < l; i++) {
  2871. if (terminatorRules[i](state, nextLine, endLine, true)) {
  2872. terminate = true;
  2873. break;
  2874. }
  2875. }
  2876. if (terminate) { break; }
  2877. }
  2878. str = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
  2879. max = str.length;
  2880. for (pos = 1; pos < max; pos++) {
  2881. ch = str.charCodeAt(pos);
  2882. if (ch === 0x5B /* [ */) {
  2883. return false;
  2884. } else if (ch === 0x5D /* ] */) {
  2885. labelEnd = pos;
  2886. break;
  2887. } else if (ch === 0x0A /* \n */) {
  2888. lines++;
  2889. } else if (ch === 0x5C /* \ */) {
  2890. pos++;
  2891. if (pos < max && str.charCodeAt(pos) === 0x0A) {
  2892. lines++;
  2893. }
  2894. }
  2895. }
  2896. if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return false; }
  2897. // [label]: destination 'title'
  2898. // ^^^ skip optional whitespace here
  2899. for (pos = labelEnd + 2; pos < max; pos++) {
  2900. ch = str.charCodeAt(pos);
  2901. if (ch === 0x0A) {
  2902. lines++;
  2903. } else if (isSpace(ch)) {
  2904. /*eslint no-empty:0*/
  2905. } else {
  2906. break;
  2907. }
  2908. }
  2909. // [label]: destination 'title'
  2910. // ^^^^^^^^^^^ parse this
  2911. res = state.md.helpers.parseLinkDestination(str, pos, max);
  2912. if (!res.ok) { return false; }
  2913. href = state.md.normalizeLink(res.str);
  2914. if (!state.md.validateLink(href)) { return false; }
  2915. pos = res.pos;
  2916. lines += res.lines;
  2917. // save cursor state, we could require to rollback later
  2918. destEndPos = pos;
  2919. destEndLineNo = lines;
  2920. // [label]: destination 'title'
  2921. // ^^^ skipping those spaces
  2922. start = pos;
  2923. for (; pos < max; pos++) {
  2924. ch = str.charCodeAt(pos);
  2925. if (ch === 0x0A) {
  2926. lines++;
  2927. } else if (isSpace(ch)) {
  2928. /*eslint no-empty:0*/
  2929. } else {
  2930. break;
  2931. }
  2932. }
  2933. // [label]: destination 'title'
  2934. // ^^^^^^^ parse this
  2935. res = state.md.helpers.parseLinkTitle(str, pos, max);
  2936. if (pos < max && start !== pos && res.ok) {
  2937. title = res.str;
  2938. pos = res.pos;
  2939. lines += res.lines;
  2940. } else {
  2941. title = '';
  2942. pos = destEndPos;
  2943. lines = destEndLineNo;
  2944. }
  2945. // skip trailing spaces until the rest of the line
  2946. while (pos < max) {
  2947. ch = str.charCodeAt(pos);
  2948. if (!isSpace(ch)) { break; }
  2949. pos++;
  2950. }
  2951. if (pos < max && str.charCodeAt(pos) !== 0x0A) {
  2952. if (title) {
  2953. // garbage at the end of the line after title,
  2954. // but it could still be a valid reference if we roll back
  2955. title = '';
  2956. pos = destEndPos;
  2957. lines = destEndLineNo;
  2958. while (pos < max) {
  2959. ch = str.charCodeAt(pos);
  2960. if (!isSpace(ch)) { break; }
  2961. pos++;
  2962. }
  2963. }
  2964. }
  2965. if (pos < max && str.charCodeAt(pos) !== 0x0A) {
  2966. // garbage at the end of the line
  2967. return false;
  2968. }
  2969. label = normalizeReference(str.slice(1, labelEnd));
  2970. if (!label) {
  2971. // CommonMark 0.20 disallows empty labels
  2972. return false;
  2973. }
  2974. // Reference can not terminate anything. This check is for safety only.
  2975. /*istanbul ignore if*/
  2976. if (silent) { return true; }
  2977. if (typeof state.env.references === 'undefined') {
  2978. state.env.references = {};
  2979. }
  2980. if (typeof state.env.references[label] === 'undefined') {
  2981. state.env.references[label] = { title: title, href: href };
  2982. }
  2983. state.parentType = oldParentType;
  2984. state.line = startLine + lines + 1;
  2985. return true;
  2986. };
  2987. },{"../common/utils":4}],28:[function(require,module,exports){
  2988. // Parser state class
  2989. 'use strict';
  2990. var Token = require('../token');
  2991. var isSpace = require('../common/utils').isSpace;
  2992. function StateBlock(src, md, env, tokens) {
  2993. var ch, s, start, pos, len, indent, offset, indent_found;
  2994. this.src = src;
  2995. // link to parser instance
  2996. this.md = md;
  2997. this.env = env;
  2998. //
  2999. // Internal state vartiables
  3000. //
  3001. this.tokens = tokens;
  3002. this.bMarks = []; // line begin offsets for fast jumps
  3003. this.eMarks = []; // line end offsets for fast jumps
  3004. this.tShift = []; // offsets of the first non-space characters (tabs not expanded)
  3005. this.sCount = []; // indents for each line (tabs expanded)
  3006. // An amount of virtual spaces (tabs expanded) between beginning
  3007. // of each line (bMarks) and real beginning of that line.
  3008. //
  3009. // It exists only as a hack because blockquotes override bMarks
  3010. // losing information in the process.
  3011. //
  3012. // It's used only when expanding tabs, you can think about it as
  3013. // an initial tab length, e.g. bsCount=21 applied to string `\t123`
  3014. // means first tab should be expanded to 4-21%4 === 3 spaces.
  3015. //
  3016. this.bsCount = [];
  3017. // block parser variables
  3018. this.blkIndent = 0; // required block content indent
  3019. // (for example, if we are in list)
  3020. this.line = 0; // line index in src
  3021. this.lineMax = 0; // lines count
  3022. this.tight = false; // loose/tight mode for lists
  3023. this.ddIndent = -1; // indent of the current dd block (-1 if there isn't any)
  3024. // can be 'blockquote', 'list', 'root', 'paragraph' or 'reference'
  3025. // used in lists to determine if they interrupt a paragraph
  3026. this.parentType = 'root';
  3027. this.level = 0;
  3028. // renderer
  3029. this.result = '';
  3030. // Create caches
  3031. // Generate markers.
  3032. s = this.src;
  3033. indent_found = false;
  3034. for (start = pos = indent = offset = 0, len = s.length; pos < len; pos++) {
  3035. ch = s.charCodeAt(pos);
  3036. if (!indent_found) {
  3037. if (isSpace(ch)) {
  3038. indent++;
  3039. if (ch === 0x09) {
  3040. offset += 4 - offset % 4;
  3041. } else {
  3042. offset++;
  3043. }
  3044. continue;
  3045. } else {
  3046. indent_found = true;
  3047. }
  3048. }
  3049. if (ch === 0x0A || pos === len - 1) {
  3050. if (ch !== 0x0A) { pos++; }
  3051. this.bMarks.push(start);
  3052. this.eMarks.push(pos);
  3053. this.tShift.push(indent);
  3054. this.sCount.push(offset);
  3055. this.bsCount.push(0);
  3056. indent_found = false;
  3057. indent = 0;
  3058. offset = 0;
  3059. start = pos + 1;
  3060. }
  3061. }
  3062. // Push fake entry to simplify cache bounds checks
  3063. this.bMarks.push(s.length);
  3064. this.eMarks.push(s.length);
  3065. this.tShift.push(0);
  3066. this.sCount.push(0);
  3067. this.bsCount.push(0);
  3068. this.lineMax = this.bMarks.length - 1; // don't count last fake line
  3069. }
  3070. // Push new token to "stream".
  3071. //
  3072. StateBlock.prototype.push = function (type, tag, nesting) {
  3073. var token = new Token(type, tag, nesting);
  3074. token.block = true;
  3075. if (nesting < 0) { this.level--; }
  3076. token.level = this.level;
  3077. if (nesting > 0) { this.level++; }
  3078. this.tokens.push(token);
  3079. return token;
  3080. };
  3081. StateBlock.prototype.isEmpty = function isEmpty(line) {
  3082. return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];
  3083. };
  3084. StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {
  3085. for (var max = this.lineMax; from < max; from++) {
  3086. if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) {
  3087. break;
  3088. }
  3089. }
  3090. return from;
  3091. };
  3092. // Skip spaces from given position.
  3093. StateBlock.prototype.skipSpaces = function skipSpaces(pos) {
  3094. var ch;
  3095. for (var max = this.src.length; pos < max; pos++) {
  3096. ch = this.src.charCodeAt(pos);
  3097. if (!isSpace(ch)) { break; }
  3098. }
  3099. return pos;
  3100. };
  3101. // Skip spaces from given position in reverse.
  3102. StateBlock.prototype.skipSpacesBack = function skipSpacesBack(pos, min) {
  3103. if (pos <= min) { return pos; }
  3104. while (pos > min) {
  3105. if (!isSpace(this.src.charCodeAt(--pos))) { return pos + 1; }
  3106. }
  3107. return pos;
  3108. };
  3109. // Skip char codes from given position
  3110. StateBlock.prototype.skipChars = function skipChars(pos, code) {
  3111. for (var max = this.src.length; pos < max; pos++) {
  3112. if (this.src.charCodeAt(pos) !== code) { break; }
  3113. }
  3114. return pos;
  3115. };
  3116. // Skip char codes reverse from given position - 1
  3117. StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {
  3118. if (pos <= min) { return pos; }
  3119. while (pos > min) {
  3120. if (code !== this.src.charCodeAt(--pos)) { return pos + 1; }
  3121. }
  3122. return pos;
  3123. };
  3124. // cut lines range from source.
  3125. StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {
  3126. var i, lineIndent, ch, first, last, queue, lineStart,
  3127. line = begin;
  3128. if (begin >= end) {
  3129. return '';
  3130. }
  3131. queue = new Array(end - begin);
  3132. for (i = 0; line < end; line++, i++) {
  3133. lineIndent = 0;
  3134. lineStart = first = this.bMarks[line];
  3135. if (line + 1 < end || keepLastLF) {
  3136. // No need for bounds check because we have fake entry on tail.
  3137. last = this.eMarks[line] + 1;
  3138. } else {
  3139. last = this.eMarks[line];
  3140. }
  3141. while (first < last && lineIndent < indent) {
  3142. ch = this.src.charCodeAt(first);
  3143. if (isSpace(ch)) {
  3144. if (ch === 0x09) {
  3145. lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4;
  3146. } else {
  3147. lineIndent++;
  3148. }
  3149. } else if (first - lineStart < this.tShift[line]) {
  3150. // patched tShift masked characters to look like spaces (blockquotes, list markers)
  3151. lineIndent++;
  3152. } else {
  3153. break;
  3154. }
  3155. first++;
  3156. }
  3157. if (lineIndent > indent) {
  3158. // partially expanding tabs in code blocks, e.g '\t\tfoobar'
  3159. // with indent=2 becomes ' \tfoobar'
  3160. queue[i] = new Array(lineIndent - indent + 1).join(' ') + this.src.slice(first, last);
  3161. } else {
  3162. queue[i] = this.src.slice(first, last);
  3163. }
  3164. }
  3165. return queue.join('');
  3166. };
  3167. // re-export Token class to use in block rules
  3168. StateBlock.prototype.Token = Token;
  3169. module.exports = StateBlock;
  3170. },{"../common/utils":4,"../token":51}],29:[function(require,module,exports){
  3171. // GFM table, non-standard
  3172. 'use strict';
  3173. var isSpace = require('../common/utils').isSpace;
  3174. function getLine(state, line) {
  3175. var pos = state.bMarks[line] + state.blkIndent,
  3176. max = state.eMarks[line];
  3177. return state.src.substr(pos, max - pos);
  3178. }
  3179. function escapedSplit(str) {
  3180. var result = [],
  3181. pos = 0,
  3182. max = str.length,
  3183. ch,
  3184. escapes = 0,
  3185. lastPos = 0,
  3186. backTicked = false,
  3187. lastBackTick = 0;
  3188. ch = str.charCodeAt(pos);
  3189. while (pos < max) {
  3190. if (ch === 0x60/* ` */) {
  3191. if (backTicked) {
  3192. // make \` close code sequence, but not open it;
  3193. // the reason is: `\` is correct code block
  3194. backTicked = false;
  3195. lastBackTick = pos;
  3196. } else if (escapes % 2 === 0) {
  3197. backTicked = true;
  3198. lastBackTick = pos;
  3199. }
  3200. } else if (ch === 0x7c/* | */ && (escapes % 2 === 0) && !backTicked) {
  3201. result.push(str.substring(lastPos, pos));
  3202. lastPos = pos + 1;
  3203. }
  3204. if (ch === 0x5c/* \ */) {
  3205. escapes++;
  3206. } else {
  3207. escapes = 0;
  3208. }
  3209. pos++;
  3210. // If there was an un-closed backtick, go back to just after
  3211. // the last backtick, but as if it was a normal character
  3212. if (pos === max && backTicked) {
  3213. backTicked = false;
  3214. pos = lastBackTick + 1;
  3215. }
  3216. ch = str.charCodeAt(pos);
  3217. }
  3218. result.push(str.substring(lastPos));
  3219. return result;
  3220. }
  3221. module.exports = function table(state, startLine, endLine, silent) {
  3222. var ch, lineText, pos, i, nextLine, columns, columnCount, token,
  3223. aligns, t, tableLines, tbodyLines;
  3224. // should have at least two lines
  3225. if (startLine + 2 > endLine) { return false; }
  3226. nextLine = startLine + 1;
  3227. if (state.sCount[nextLine] < state.blkIndent) { return false; }
  3228. // if it's indented more than 3 spaces, it should be a code block
  3229. if (state.sCount[nextLine] - state.blkIndent >= 4) { return false; }
  3230. // first character of the second line should be '|', '-', ':',
  3231. // and no other characters are allowed but spaces;
  3232. // basically, this is the equivalent of /^[-:|][-:|\s]*$/ regexp
  3233. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  3234. if (pos >= state.eMarks[nextLine]) { return false; }
  3235. ch = state.src.charCodeAt(pos++);
  3236. if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */) { return false; }
  3237. while (pos < state.eMarks[nextLine]) {
  3238. ch = state.src.charCodeAt(pos);
  3239. if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */ && !isSpace(ch)) { return false; }
  3240. pos++;
  3241. }
  3242. lineText = getLine(state, startLine + 1);
  3243. columns = lineText.split('|');
  3244. aligns = [];
  3245. for (i = 0; i < columns.length; i++) {
  3246. t = columns[i].trim();
  3247. if (!t) {
  3248. // allow empty columns before and after table, but not in between columns;
  3249. // e.g. allow ` |---| `, disallow ` ---||--- `
  3250. if (i === 0 || i === columns.length - 1) {
  3251. continue;
  3252. } else {
  3253. return false;
  3254. }
  3255. }
  3256. if (!/^:?-+:?$/.test(t)) { return false; }
  3257. if (t.charCodeAt(t.length - 1) === 0x3A/* : */) {
  3258. aligns.push(t.charCodeAt(0) === 0x3A/* : */ ? 'center' : 'right');
  3259. } else if (t.charCodeAt(0) === 0x3A/* : */) {
  3260. aligns.push('left');
  3261. } else {
  3262. aligns.push('');
  3263. }
  3264. }
  3265. lineText = getLine(state, startLine).trim();
  3266. if (lineText.indexOf('|') === -1) { return false; }
  3267. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  3268. columns = escapedSplit(lineText.replace(/^\||\|$/g, ''));
  3269. // header row will define an amount of columns in the entire table,
  3270. // and align row shouldn't be smaller than that (the rest of the rows can)
  3271. columnCount = columns.length;
  3272. if (columnCount > aligns.length) { return false; }
  3273. if (silent) { return true; }
  3274. token = state.push('table_open', 'table', 1);
  3275. token.map = tableLines = [ startLine, 0 ];
  3276. token = state.push('thead_open', 'thead', 1);
  3277. token.map = [ startLine, startLine + 1 ];
  3278. token = state.push('tr_open', 'tr', 1);
  3279. token.map = [ startLine, startLine + 1 ];
  3280. for (i = 0; i < columns.length; i++) {
  3281. token = state.push('th_open', 'th', 1);
  3282. token.map = [ startLine, startLine + 1 ];
  3283. if (aligns[i]) {
  3284. token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];
  3285. }
  3286. token = state.push('inline', '', 0);
  3287. token.content = columns[i].trim();
  3288. token.map = [ startLine, startLine + 1 ];
  3289. token.children = [];
  3290. token = state.push('th_close', 'th', -1);
  3291. }
  3292. token = state.push('tr_close', 'tr', -1);
  3293. token = state.push('thead_close', 'thead', -1);
  3294. token = state.push('tbody_open', 'tbody', 1);
  3295. token.map = tbodyLines = [ startLine + 2, 0 ];
  3296. for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {
  3297. if (state.sCount[nextLine] < state.blkIndent) { break; }
  3298. lineText = getLine(state, nextLine).trim();
  3299. if (lineText.indexOf('|') === -1) { break; }
  3300. if (state.sCount[nextLine] - state.blkIndent >= 4) { break; }
  3301. columns = escapedSplit(lineText.replace(/^\||\|$/g, ''));
  3302. token = state.push('tr_open', 'tr', 1);
  3303. for (i = 0; i < columnCount; i++) {
  3304. token = state.push('td_open', 'td', 1);
  3305. if (aligns[i]) {
  3306. token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];
  3307. }
  3308. token = state.push('inline', '', 0);
  3309. token.content = columns[i] ? columns[i].trim() : '';
  3310. token.children = [];
  3311. token = state.push('td_close', 'td', -1);
  3312. }
  3313. token = state.push('tr_close', 'tr', -1);
  3314. }
  3315. token = state.push('tbody_close', 'tbody', -1);
  3316. token = state.push('table_close', 'table', -1);
  3317. tableLines[1] = tbodyLines[1] = nextLine;
  3318. state.line = nextLine;
  3319. return true;
  3320. };
  3321. },{"../common/utils":4}],30:[function(require,module,exports){
  3322. 'use strict';
  3323. module.exports = function block(state) {
  3324. var token;
  3325. if (state.inlineMode) {
  3326. token = new state.Token('inline', '', 0);
  3327. token.content = state.src;
  3328. token.map = [ 0, 1 ];
  3329. token.children = [];
  3330. state.tokens.push(token);
  3331. } else {
  3332. state.md.block.parse(state.src, state.md, state.env, state.tokens);
  3333. }
  3334. };
  3335. },{}],31:[function(require,module,exports){
  3336. 'use strict';
  3337. module.exports = function inline(state) {
  3338. var tokens = state.tokens, tok, i, l;
  3339. // Parse inlines
  3340. for (i = 0, l = tokens.length; i < l; i++) {
  3341. tok = tokens[i];
  3342. if (tok.type === 'inline') {
  3343. state.md.inline.parse(tok.content, state.md, state.env, tok.children);
  3344. }
  3345. }
  3346. };
  3347. },{}],32:[function(require,module,exports){
  3348. // Replace link-like texts with link nodes.
  3349. //
  3350. // Currently restricted by `md.validateLink()` to http/https/ftp
  3351. //
  3352. 'use strict';
  3353. var arrayReplaceAt = require('../common/utils').arrayReplaceAt;
  3354. function isLinkOpen(str) {
  3355. return /^<a[>\s]/i.test(str);
  3356. }
  3357. function isLinkClose(str) {
  3358. return /^<\/a\s*>/i.test(str);
  3359. }
  3360. module.exports = function linkify(state) {
  3361. var i, j, l, tokens, token, currentToken, nodes, ln, text, pos, lastPos,
  3362. level, htmlLinkLevel, url, fullUrl, urlText,
  3363. blockTokens = state.tokens,
  3364. links;
  3365. if (!state.md.options.linkify) { return; }
  3366. for (j = 0, l = blockTokens.length; j < l; j++) {
  3367. if (blockTokens[j].type !== 'inline' ||
  3368. !state.md.linkify.pretest(blockTokens[j].content)) {
  3369. continue;
  3370. }
  3371. tokens = blockTokens[j].children;
  3372. htmlLinkLevel = 0;
  3373. // We scan from the end, to keep position when new tags added.
  3374. // Use reversed logic in links start/end match
  3375. for (i = tokens.length - 1; i >= 0; i--) {
  3376. currentToken = tokens[i];
  3377. // Skip content of markdown links
  3378. if (currentToken.type === 'link_close') {
  3379. i--;
  3380. while (tokens[i].level !== currentToken.level && tokens[i].type !== 'link_open') {
  3381. i--;
  3382. }
  3383. continue;
  3384. }
  3385. // Skip content of html tag links
  3386. if (currentToken.type === 'html_inline') {
  3387. if (isLinkOpen(currentToken.content) && htmlLinkLevel > 0) {
  3388. htmlLinkLevel--;
  3389. }
  3390. if (isLinkClose(currentToken.content)) {
  3391. htmlLinkLevel++;
  3392. }
  3393. }
  3394. if (htmlLinkLevel > 0) { continue; }
  3395. if (currentToken.type === 'text' && state.md.linkify.test(currentToken.content)) {
  3396. text = currentToken.content;
  3397. links = state.md.linkify.match(text);
  3398. // Now split string to nodes
  3399. nodes = [];
  3400. level = currentToken.level;
  3401. lastPos = 0;
  3402. for (ln = 0; ln < links.length; ln++) {
  3403. url = links[ln].url;
  3404. fullUrl = state.md.normalizeLink(url);
  3405. if (!state.md.validateLink(fullUrl)) { continue; }
  3406. urlText = links[ln].text;
  3407. // Linkifier might send raw hostnames like "example.com", where url
  3408. // starts with domain name. So we prepend http:// in those cases,
  3409. // and remove it afterwards.
  3410. //
  3411. if (!links[ln].schema) {
  3412. urlText = state.md.normalizeLinkText('http://' + urlText).replace(/^http:\/\//, '');
  3413. } else if (links[ln].schema === 'mailto:' && !/^mailto:/i.test(urlText)) {
  3414. urlText = state.md.normalizeLinkText('mailto:' + urlText).replace(/^mailto:/, '');
  3415. } else {
  3416. urlText = state.md.normalizeLinkText(urlText);
  3417. }
  3418. pos = links[ln].index;
  3419. if (pos > lastPos) {
  3420. token = new state.Token('text', '', 0);
  3421. token.content = text.slice(lastPos, pos);
  3422. token.level = level;
  3423. nodes.push(token);
  3424. }
  3425. token = new state.Token('link_open', 'a', 1);
  3426. token.attrs = [ [ 'href', fullUrl ] ];
  3427. token.level = level++;
  3428. token.markup = 'linkify';
  3429. token.info = 'auto';
  3430. nodes.push(token);
  3431. token = new state.Token('text', '', 0);
  3432. token.content = urlText;
  3433. token.level = level;
  3434. nodes.push(token);
  3435. token = new state.Token('link_close', 'a', -1);
  3436. token.level = --level;
  3437. token.markup = 'linkify';
  3438. token.info = 'auto';
  3439. nodes.push(token);
  3440. lastPos = links[ln].lastIndex;
  3441. }
  3442. if (lastPos < text.length) {
  3443. token = new state.Token('text', '', 0);
  3444. token.content = text.slice(lastPos);
  3445. token.level = level;
  3446. nodes.push(token);
  3447. }
  3448. // replace current node
  3449. blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);
  3450. }
  3451. }
  3452. }
  3453. };
  3454. },{"../common/utils":4}],33:[function(require,module,exports){
  3455. // Normalize input string
  3456. 'use strict';
  3457. var NEWLINES_RE = /\r[\n\u0085]?|[\u2424\u2028\u0085]/g;
  3458. var NULL_RE = /\u0000/g;
  3459. module.exports = function inline(state) {
  3460. var str;
  3461. // Normalize newlines
  3462. str = state.src.replace(NEWLINES_RE, '\n');
  3463. // Replace NULL characters
  3464. str = str.replace(NULL_RE, '\uFFFD');
  3465. state.src = str;
  3466. };
  3467. },{}],34:[function(require,module,exports){
  3468. // Simple typographyc replacements
  3469. //
  3470. // (c) (C) → ©
  3471. // (tm) (TM) → ™
  3472. // (r) (R) → ®
  3473. // +- → ±
  3474. // (p) (P) -> §
  3475. // ... → … (also ?.... → ?.., !.... → !..)
  3476. // ???????? → ???, !!!!! → !!!, `,,` → `,`
  3477. // -- → &ndash;, --- → &mdash;
  3478. //
  3479. 'use strict';
  3480. // TODO:
  3481. // - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
  3482. // - miltiplication 2 x 4 -> 2 × 4
  3483. var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
  3484. // Workaround for phantomjs - need regex without /g flag,
  3485. // or root check will fail every second time
  3486. var SCOPED_ABBR_TEST_RE = /\((c|tm|r|p)\)/i;
  3487. var SCOPED_ABBR_RE = /\((c|tm|r|p)\)/ig;
  3488. var SCOPED_ABBR = {
  3489. c: '©',
  3490. r: '®',
  3491. p: '§',
  3492. tm: '™'
  3493. };
  3494. function replaceFn(match, name) {
  3495. return SCOPED_ABBR[name.toLowerCase()];
  3496. }
  3497. function replace_scoped(inlineTokens) {
  3498. var i, token, inside_autolink = 0;
  3499. for (i = inlineTokens.length - 1; i >= 0; i--) {
  3500. token = inlineTokens[i];
  3501. if (token.type === 'text' && !inside_autolink) {
  3502. token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn);
  3503. }
  3504. if (token.type === 'link_open' && token.info === 'auto') {
  3505. inside_autolink--;
  3506. }
  3507. if (token.type === 'link_close' && token.info === 'auto') {
  3508. inside_autolink++;
  3509. }
  3510. }
  3511. }
  3512. function replace_rare(inlineTokens) {
  3513. var i, token, inside_autolink = 0;
  3514. for (i = inlineTokens.length - 1; i >= 0; i--) {
  3515. token = inlineTokens[i];
  3516. if (token.type === 'text' && !inside_autolink) {
  3517. if (RARE_RE.test(token.content)) {
  3518. token.content = token.content
  3519. .replace(/\+-/g, '±')
  3520. // .., ..., ....... -> …
  3521. // but ?..... & !..... -> ?.. & !..
  3522. .replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..')
  3523. .replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',')
  3524. // em-dash
  3525. .replace(/(^|[^-])---([^-]|$)/mg, '$1\u2014$2')
  3526. // en-dash
  3527. .replace(/(^|\s)--(\s|$)/mg, '$1\u2013$2')
  3528. .replace(/(^|[^-\s])--([^-\s]|$)/mg, '$1\u2013$2');
  3529. }
  3530. }
  3531. if (token.type === 'link_open' && token.info === 'auto') {
  3532. inside_autolink--;
  3533. }
  3534. if (token.type === 'link_close' && token.info === 'auto') {
  3535. inside_autolink++;
  3536. }
  3537. }
  3538. }
  3539. module.exports = function replace(state) {
  3540. var blkIdx;
  3541. if (!state.md.options.typographer) { return; }
  3542. for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
  3543. if (state.tokens[blkIdx].type !== 'inline') { continue; }
  3544. if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {
  3545. replace_scoped(state.tokens[blkIdx].children);
  3546. }
  3547. if (RARE_RE.test(state.tokens[blkIdx].content)) {
  3548. replace_rare(state.tokens[blkIdx].children);
  3549. }
  3550. }
  3551. };
  3552. },{}],35:[function(require,module,exports){
  3553. // Convert straight quotation marks to typographic ones
  3554. //
  3555. 'use strict';
  3556. var isWhiteSpace = require('../common/utils').isWhiteSpace;
  3557. var isPunctChar = require('../common/utils').isPunctChar;
  3558. var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct;
  3559. var QUOTE_TEST_RE = /['"]/;
  3560. var QUOTE_RE = /['"]/g;
  3561. var APOSTROPHE = '\u2019'; /* ’ */
  3562. function replaceAt(str, index, ch) {
  3563. return str.substr(0, index) + ch + str.substr(index + 1);
  3564. }
  3565. function process_inlines(tokens, state) {
  3566. var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar,
  3567. isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace,
  3568. canOpen, canClose, j, isSingle, stack, openQuote, closeQuote;
  3569. stack = [];
  3570. for (i = 0; i < tokens.length; i++) {
  3571. token = tokens[i];
  3572. thisLevel = tokens[i].level;
  3573. for (j = stack.length - 1; j >= 0; j--) {
  3574. if (stack[j].level <= thisLevel) { break; }
  3575. }
  3576. stack.length = j + 1;
  3577. if (token.type !== 'text') { continue; }
  3578. text = token.content;
  3579. pos = 0;
  3580. max = text.length;
  3581. /*eslint no-labels:0,block-scoped-var:0*/
  3582. OUTER:
  3583. while (pos < max) {
  3584. QUOTE_RE.lastIndex = pos;
  3585. t = QUOTE_RE.exec(text);
  3586. if (!t) { break; }
  3587. canOpen = canClose = true;
  3588. pos = t.index + 1;
  3589. isSingle = (t[0] === "'");
  3590. // Find previous character,
  3591. // default to space if it's the beginning of the line
  3592. //
  3593. lastChar = 0x20;
  3594. if (t.index - 1 >= 0) {
  3595. lastChar = text.charCodeAt(t.index - 1);
  3596. } else {
  3597. for (j = i - 1; j >= 0; j--) {
  3598. if (tokens[j].type !== 'text') { continue; }
  3599. lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
  3600. break;
  3601. }
  3602. }
  3603. // Find next character,
  3604. // default to space if it's the end of the line
  3605. //
  3606. nextChar = 0x20;
  3607. if (pos < max) {
  3608. nextChar = text.charCodeAt(pos);
  3609. } else {
  3610. for (j = i + 1; j < tokens.length; j++) {
  3611. if (tokens[j].type !== 'text') { continue; }
  3612. nextChar = tokens[j].content.charCodeAt(0);
  3613. break;
  3614. }
  3615. }
  3616. isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
  3617. isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
  3618. isLastWhiteSpace = isWhiteSpace(lastChar);
  3619. isNextWhiteSpace = isWhiteSpace(nextChar);
  3620. if (isNextWhiteSpace) {
  3621. canOpen = false;
  3622. } else if (isNextPunctChar) {
  3623. if (!(isLastWhiteSpace || isLastPunctChar)) {
  3624. canOpen = false;
  3625. }
  3626. }
  3627. if (isLastWhiteSpace) {
  3628. canClose = false;
  3629. } else if (isLastPunctChar) {
  3630. if (!(isNextWhiteSpace || isNextPunctChar)) {
  3631. canClose = false;
  3632. }
  3633. }
  3634. if (nextChar === 0x22 /* " */ && t[0] === '"') {
  3635. if (lastChar >= 0x30 /* 0 */ && lastChar <= 0x39 /* 9 */) {
  3636. // special case: 1"" - count first quote as an inch
  3637. canClose = canOpen = false;
  3638. }
  3639. }
  3640. if (canOpen && canClose) {
  3641. // treat this as the middle of the word
  3642. canOpen = false;
  3643. canClose = isNextPunctChar;
  3644. }
  3645. if (!canOpen && !canClose) {
  3646. // middle of word
  3647. if (isSingle) {
  3648. token.content = replaceAt(token.content, t.index, APOSTROPHE);
  3649. }
  3650. continue;
  3651. }
  3652. if (canClose) {
  3653. // this could be a closing quote, rewind the stack to get a match
  3654. for (j = stack.length - 1; j >= 0; j--) {
  3655. item = stack[j];
  3656. if (stack[j].level < thisLevel) { break; }
  3657. if (item.single === isSingle && stack[j].level === thisLevel) {
  3658. item = stack[j];
  3659. if (isSingle) {
  3660. openQuote = state.md.options.quotes[2];
  3661. closeQuote = state.md.options.quotes[3];
  3662. } else {
  3663. openQuote = state.md.options.quotes[0];
  3664. closeQuote = state.md.options.quotes[1];
  3665. }
  3666. // replace token.content *before* tokens[item.token].content,
  3667. // because, if they are pointing at the same token, replaceAt
  3668. // could mess up indices when quote length != 1
  3669. token.content = replaceAt(token.content, t.index, closeQuote);
  3670. tokens[item.token].content = replaceAt(
  3671. tokens[item.token].content, item.pos, openQuote);
  3672. pos += closeQuote.length - 1;
  3673. if (item.token === i) { pos += openQuote.length - 1; }
  3674. text = token.content;
  3675. max = text.length;
  3676. stack.length = j;
  3677. continue OUTER;
  3678. }
  3679. }
  3680. }
  3681. if (canOpen) {
  3682. stack.push({
  3683. token: i,
  3684. pos: t.index,
  3685. single: isSingle,
  3686. level: thisLevel
  3687. });
  3688. } else if (canClose && isSingle) {
  3689. token.content = replaceAt(token.content, t.index, APOSTROPHE);
  3690. }
  3691. }
  3692. }
  3693. }
  3694. module.exports = function smartquotes(state) {
  3695. /*eslint max-depth:0*/
  3696. var blkIdx;
  3697. if (!state.md.options.typographer) { return; }
  3698. for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
  3699. if (state.tokens[blkIdx].type !== 'inline' ||
  3700. !QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) {
  3701. continue;
  3702. }
  3703. process_inlines(state.tokens[blkIdx].children, state);
  3704. }
  3705. };
  3706. },{"../common/utils":4}],36:[function(require,module,exports){
  3707. // Core state object
  3708. //
  3709. 'use strict';
  3710. var Token = require('../token');
  3711. function StateCore(src, md, env) {
  3712. this.src = src;
  3713. this.env = env;
  3714. this.tokens = [];
  3715. this.inlineMode = false;
  3716. this.md = md; // link to parser instance
  3717. }
  3718. // re-export Token class to use in core rules
  3719. StateCore.prototype.Token = Token;
  3720. module.exports = StateCore;
  3721. },{"../token":51}],37:[function(require,module,exports){
  3722. // Process autolinks '<protocol:...>'
  3723. 'use strict';
  3724. /*eslint max-len:0*/
  3725. 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])?)*)>/;
  3726. var AUTOLINK_RE = /^<([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)>/;
  3727. module.exports = function autolink(state, silent) {
  3728. var tail, linkMatch, emailMatch, url, fullUrl, token,
  3729. pos = state.pos;
  3730. if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
  3731. tail = state.src.slice(pos);
  3732. if (tail.indexOf('>') < 0) { return false; }
  3733. if (AUTOLINK_RE.test(tail)) {
  3734. linkMatch = tail.match(AUTOLINK_RE);
  3735. url = linkMatch[0].slice(1, -1);
  3736. fullUrl = state.md.normalizeLink(url);
  3737. if (!state.md.validateLink(fullUrl)) { return false; }
  3738. if (!silent) {
  3739. token = state.push('link_open', 'a', 1);
  3740. token.attrs = [ [ 'href', fullUrl ] ];
  3741. token.markup = 'autolink';
  3742. token.info = 'auto';
  3743. token = state.push('text', '', 0);
  3744. token.content = state.md.normalizeLinkText(url);
  3745. token = state.push('link_close', 'a', -1);
  3746. token.markup = 'autolink';
  3747. token.info = 'auto';
  3748. }
  3749. state.pos += linkMatch[0].length;
  3750. return true;
  3751. }
  3752. if (EMAIL_RE.test(tail)) {
  3753. emailMatch = tail.match(EMAIL_RE);
  3754. url = emailMatch[0].slice(1, -1);
  3755. fullUrl = state.md.normalizeLink('mailto:' + url);
  3756. if (!state.md.validateLink(fullUrl)) { return false; }
  3757. if (!silent) {
  3758. token = state.push('link_open', 'a', 1);
  3759. token.attrs = [ [ 'href', fullUrl ] ];
  3760. token.markup = 'autolink';
  3761. token.info = 'auto';
  3762. token = state.push('text', '', 0);
  3763. token.content = state.md.normalizeLinkText(url);
  3764. token = state.push('link_close', 'a', -1);
  3765. token.markup = 'autolink';
  3766. token.info = 'auto';
  3767. }
  3768. state.pos += emailMatch[0].length;
  3769. return true;
  3770. }
  3771. return false;
  3772. };
  3773. },{}],38:[function(require,module,exports){
  3774. // Parse backticks
  3775. 'use strict';
  3776. module.exports = function backtick(state, silent) {
  3777. var start, max, marker, matchStart, matchEnd, token,
  3778. pos = state.pos,
  3779. ch = state.src.charCodeAt(pos);
  3780. if (ch !== 0x60/* ` */) { return false; }
  3781. start = pos;
  3782. pos++;
  3783. max = state.posMax;
  3784. while (pos < max && state.src.charCodeAt(pos) === 0x60/* ` */) { pos++; }
  3785. marker = state.src.slice(start, pos);
  3786. matchStart = matchEnd = pos;
  3787. while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) {
  3788. matchEnd = matchStart + 1;
  3789. while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60/* ` */) { matchEnd++; }
  3790. if (matchEnd - matchStart === marker.length) {
  3791. if (!silent) {
  3792. token = state.push('code_inline', 'code', 0);
  3793. token.markup = marker;
  3794. token.content = state.src.slice(pos, matchStart)
  3795. .replace(/[ \n]+/g, ' ')
  3796. .trim();
  3797. }
  3798. state.pos = matchEnd;
  3799. return true;
  3800. }
  3801. }
  3802. if (!silent) { state.pending += marker; }
  3803. state.pos += marker.length;
  3804. return true;
  3805. };
  3806. },{}],39:[function(require,module,exports){
  3807. // For each opening emphasis-like marker find a matching closing one
  3808. //
  3809. 'use strict';
  3810. module.exports = function link_pairs(state) {
  3811. var i, j, lastDelim, currDelim,
  3812. delimiters = state.delimiters,
  3813. max = state.delimiters.length;
  3814. for (i = 0; i < max; i++) {
  3815. lastDelim = delimiters[i];
  3816. if (!lastDelim.close) { continue; }
  3817. j = i - lastDelim.jump - 1;
  3818. while (j >= 0) {
  3819. currDelim = delimiters[j];
  3820. if (currDelim.open &&
  3821. currDelim.marker === lastDelim.marker &&
  3822. currDelim.end < 0 &&
  3823. currDelim.level === lastDelim.level) {
  3824. // typeofs are for backward compatibility with plugins
  3825. var odd_match = (currDelim.close || lastDelim.open) &&
  3826. typeof currDelim.length !== 'undefined' &&
  3827. typeof lastDelim.length !== 'undefined' &&
  3828. (currDelim.length + lastDelim.length) % 3 === 0;
  3829. if (!odd_match) {
  3830. lastDelim.jump = i - j;
  3831. lastDelim.open = false;
  3832. currDelim.end = i;
  3833. currDelim.jump = 0;
  3834. break;
  3835. }
  3836. }
  3837. j -= currDelim.jump + 1;
  3838. }
  3839. }
  3840. };
  3841. },{}],40:[function(require,module,exports){
  3842. // Process *this* and _that_
  3843. //
  3844. 'use strict';
  3845. // Insert each marker as a separate text token, and add it to delimiter list
  3846. //
  3847. module.exports.tokenize = function emphasis(state, silent) {
  3848. var i, scanned, token,
  3849. start = state.pos,
  3850. marker = state.src.charCodeAt(start);
  3851. if (silent) { return false; }
  3852. if (marker !== 0x5F /* _ */ && marker !== 0x2A /* * */) { return false; }
  3853. scanned = state.scanDelims(state.pos, marker === 0x2A);
  3854. for (i = 0; i < scanned.length; i++) {
  3855. token = state.push('text', '', 0);
  3856. token.content = String.fromCharCode(marker);
  3857. state.delimiters.push({
  3858. // Char code of the starting marker (number).
  3859. //
  3860. marker: marker,
  3861. // Total length of these series of delimiters.
  3862. //
  3863. length: scanned.length,
  3864. // An amount of characters before this one that's equivalent to
  3865. // current one. In plain English: if this delimiter does not open
  3866. // an emphasis, neither do previous `jump` characters.
  3867. //
  3868. // Used to skip sequences like "*****" in one step, for 1st asterisk
  3869. // value will be 0, for 2nd it's 1 and so on.
  3870. //
  3871. jump: i,
  3872. // A position of the token this delimiter corresponds to.
  3873. //
  3874. token: state.tokens.length - 1,
  3875. // Token level.
  3876. //
  3877. level: state.level,
  3878. // If this delimiter is matched as a valid opener, `end` will be
  3879. // equal to its position, otherwise it's `-1`.
  3880. //
  3881. end: -1,
  3882. // Boolean flags that determine if this delimiter could open or close
  3883. // an emphasis.
  3884. //
  3885. open: scanned.can_open,
  3886. close: scanned.can_close
  3887. });
  3888. }
  3889. state.pos += scanned.length;
  3890. return true;
  3891. };
  3892. // Walk through delimiter list and replace text tokens with tags
  3893. //
  3894. module.exports.postProcess = function emphasis(state) {
  3895. var i,
  3896. startDelim,
  3897. endDelim,
  3898. token,
  3899. ch,
  3900. isStrong,
  3901. delimiters = state.delimiters,
  3902. max = state.delimiters.length;
  3903. for (i = 0; i < max; i++) {
  3904. startDelim = delimiters[i];
  3905. if (startDelim.marker !== 0x5F/* _ */ && startDelim.marker !== 0x2A/* * */) {
  3906. continue;
  3907. }
  3908. // Process only opening markers
  3909. if (startDelim.end === -1) {
  3910. continue;
  3911. }
  3912. endDelim = delimiters[startDelim.end];
  3913. // If the next delimiter has the same marker and is adjacent to this one,
  3914. // merge those into one strong delimiter.
  3915. //
  3916. // `<em><em>whatever</em></em>` -> `<strong>whatever</strong>`
  3917. //
  3918. isStrong = i + 1 < max &&
  3919. delimiters[i + 1].end === startDelim.end - 1 &&
  3920. delimiters[i + 1].token === startDelim.token + 1 &&
  3921. delimiters[startDelim.end - 1].token === endDelim.token - 1 &&
  3922. delimiters[i + 1].marker === startDelim.marker;
  3923. ch = String.fromCharCode(startDelim.marker);
  3924. token = state.tokens[startDelim.token];
  3925. token.type = isStrong ? 'strong_open' : 'em_open';
  3926. token.tag = isStrong ? 'strong' : 'em';
  3927. token.nesting = 1;
  3928. token.markup = isStrong ? ch + ch : ch;
  3929. token.content = '';
  3930. token = state.tokens[endDelim.token];
  3931. token.type = isStrong ? 'strong_close' : 'em_close';
  3932. token.tag = isStrong ? 'strong' : 'em';
  3933. token.nesting = -1;
  3934. token.markup = isStrong ? ch + ch : ch;
  3935. token.content = '';
  3936. if (isStrong) {
  3937. state.tokens[delimiters[i + 1].token].content = '';
  3938. state.tokens[delimiters[startDelim.end - 1].token].content = '';
  3939. i++;
  3940. }
  3941. }
  3942. };
  3943. },{}],41:[function(require,module,exports){
  3944. // Process html entity - &#123;, &#xAF;, &quot;, ...
  3945. 'use strict';
  3946. var entities = require('../common/entities');
  3947. var has = require('../common/utils').has;
  3948. var isValidEntityCode = require('../common/utils').isValidEntityCode;
  3949. var fromCodePoint = require('../common/utils').fromCodePoint;
  3950. var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i;
  3951. var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
  3952. module.exports = function entity(state, silent) {
  3953. var ch, code, match, pos = state.pos, max = state.posMax;
  3954. if (state.src.charCodeAt(pos) !== 0x26/* & */) { return false; }
  3955. if (pos + 1 < max) {
  3956. ch = state.src.charCodeAt(pos + 1);
  3957. if (ch === 0x23 /* # */) {
  3958. match = state.src.slice(pos).match(DIGITAL_RE);
  3959. if (match) {
  3960. if (!silent) {
  3961. code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10);
  3962. state.pending += isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD);
  3963. }
  3964. state.pos += match[0].length;
  3965. return true;
  3966. }
  3967. } else {
  3968. match = state.src.slice(pos).match(NAMED_RE);
  3969. if (match) {
  3970. if (has(entities, match[1])) {
  3971. if (!silent) { state.pending += entities[match[1]]; }
  3972. state.pos += match[0].length;
  3973. return true;
  3974. }
  3975. }
  3976. }
  3977. }
  3978. if (!silent) { state.pending += '&'; }
  3979. state.pos++;
  3980. return true;
  3981. };
  3982. },{"../common/entities":1,"../common/utils":4}],42:[function(require,module,exports){
  3983. // Proceess escaped chars and hardbreaks
  3984. 'use strict';
  3985. var isSpace = require('../common/utils').isSpace;
  3986. var ESCAPED = [];
  3987. for (var i = 0; i < 256; i++) { ESCAPED.push(0); }
  3988. '\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-'
  3989. .split('').forEach(function (ch) { ESCAPED[ch.charCodeAt(0)] = 1; });
  3990. module.exports = function escape(state, silent) {
  3991. var ch, pos = state.pos, max = state.posMax;
  3992. if (state.src.charCodeAt(pos) !== 0x5C/* \ */) { return false; }
  3993. pos++;
  3994. if (pos < max) {
  3995. ch = state.src.charCodeAt(pos);
  3996. if (ch < 256 && ESCAPED[ch] !== 0) {
  3997. if (!silent) { state.pending += state.src[pos]; }
  3998. state.pos += 2;
  3999. return true;
  4000. }
  4001. if (ch === 0x0A) {
  4002. if (!silent) {
  4003. state.push('hardbreak', 'br', 0);
  4004. }
  4005. pos++;
  4006. // skip leading whitespaces from next line
  4007. while (pos < max) {
  4008. ch = state.src.charCodeAt(pos);
  4009. if (!isSpace(ch)) { break; }
  4010. pos++;
  4011. }
  4012. state.pos = pos;
  4013. return true;
  4014. }
  4015. }
  4016. if (!silent) { state.pending += '\\'; }
  4017. state.pos++;
  4018. return true;
  4019. };
  4020. },{"../common/utils":4}],43:[function(require,module,exports){
  4021. // Process html tags
  4022. 'use strict';
  4023. var HTML_TAG_RE = require('../common/html_re').HTML_TAG_RE;
  4024. function isLetter(ch) {
  4025. /*eslint no-bitwise:0*/
  4026. var lc = ch | 0x20; // to lower case
  4027. return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */);
  4028. }
  4029. module.exports = function html_inline(state, silent) {
  4030. var ch, match, max, token,
  4031. pos = state.pos;
  4032. if (!state.md.options.html) { return false; }
  4033. // Check start
  4034. max = state.posMax;
  4035. if (state.src.charCodeAt(pos) !== 0x3C/* < */ ||
  4036. pos + 2 >= max) {
  4037. return false;
  4038. }
  4039. // Quick fail on second char
  4040. ch = state.src.charCodeAt(pos + 1);
  4041. if (ch !== 0x21/* ! */ &&
  4042. ch !== 0x3F/* ? */ &&
  4043. ch !== 0x2F/* / */ &&
  4044. !isLetter(ch)) {
  4045. return false;
  4046. }
  4047. match = state.src.slice(pos).match(HTML_TAG_RE);
  4048. if (!match) { return false; }
  4049. if (!silent) {
  4050. token = state.push('html_inline', '', 0);
  4051. token.content = state.src.slice(pos, pos + match[0].length);
  4052. }
  4053. state.pos += match[0].length;
  4054. return true;
  4055. };
  4056. },{"../common/html_re":3}],44:[function(require,module,exports){
  4057. // Process ![image](<src> "title")
  4058. 'use strict';
  4059. var normalizeReference = require('../common/utils').normalizeReference;
  4060. var isSpace = require('../common/utils').isSpace;
  4061. module.exports = function image(state, silent) {
  4062. var attrs,
  4063. code,
  4064. content,
  4065. label,
  4066. labelEnd,
  4067. labelStart,
  4068. pos,
  4069. ref,
  4070. res,
  4071. title,
  4072. token,
  4073. tokens,
  4074. start,
  4075. href = '',
  4076. oldPos = state.pos,
  4077. max = state.posMax;
  4078. if (state.src.charCodeAt(state.pos) !== 0x21/* ! */) { return false; }
  4079. if (state.src.charCodeAt(state.pos + 1) !== 0x5B/* [ */) { return false; }
  4080. labelStart = state.pos + 2;
  4081. labelEnd = state.md.helpers.parseLinkLabel(state, state.pos + 1, false);
  4082. // parser failed to find ']', so it's not a valid link
  4083. if (labelEnd < 0) { return false; }
  4084. pos = labelEnd + 1;
  4085. if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {
  4086. //
  4087. // Inline link
  4088. //
  4089. // [link]( <href> "title" )
  4090. // ^^ skipping these spaces
  4091. pos++;
  4092. for (; pos < max; pos++) {
  4093. code = state.src.charCodeAt(pos);
  4094. if (!isSpace(code) && code !== 0x0A) { break; }
  4095. }
  4096. if (pos >= max) { return false; }
  4097. // [link]( <href> "title" )
  4098. // ^^^^^^ parsing link destination
  4099. start = pos;
  4100. res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
  4101. if (res.ok) {
  4102. href = state.md.normalizeLink(res.str);
  4103. if (state.md.validateLink(href)) {
  4104. pos = res.pos;
  4105. } else {
  4106. href = '';
  4107. }
  4108. }
  4109. // [link]( <href> "title" )
  4110. // ^^ skipping these spaces
  4111. start = pos;
  4112. for (; pos < max; pos++) {
  4113. code = state.src.charCodeAt(pos);
  4114. if (!isSpace(code) && code !== 0x0A) { break; }
  4115. }
  4116. // [link]( <href> "title" )
  4117. // ^^^^^^^ parsing link title
  4118. res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
  4119. if (pos < max && start !== pos && res.ok) {
  4120. title = res.str;
  4121. pos = res.pos;
  4122. // [link]( <href> "title" )
  4123. // ^^ skipping these spaces
  4124. for (; pos < max; pos++) {
  4125. code = state.src.charCodeAt(pos);
  4126. if (!isSpace(code) && code !== 0x0A) { break; }
  4127. }
  4128. } else {
  4129. title = '';
  4130. }
  4131. if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
  4132. state.pos = oldPos;
  4133. return false;
  4134. }
  4135. pos++;
  4136. } else {
  4137. //
  4138. // Link reference
  4139. //
  4140. if (typeof state.env.references === 'undefined') { return false; }
  4141. if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
  4142. start = pos + 1;
  4143. pos = state.md.helpers.parseLinkLabel(state, pos);
  4144. if (pos >= 0) {
  4145. label = state.src.slice(start, pos++);
  4146. } else {
  4147. pos = labelEnd + 1;
  4148. }
  4149. } else {
  4150. pos = labelEnd + 1;
  4151. }
  4152. // covers label === '' and label === undefined
  4153. // (collapsed reference link and shortcut reference link respectively)
  4154. if (!label) { label = state.src.slice(labelStart, labelEnd); }
  4155. ref = state.env.references[normalizeReference(label)];
  4156. if (!ref) {
  4157. state.pos = oldPos;
  4158. return false;
  4159. }
  4160. href = ref.href;
  4161. title = ref.title;
  4162. }
  4163. //
  4164. // We found the end of the link, and know for a fact it's a valid link;
  4165. // so all that's left to do is to call tokenizer.
  4166. //
  4167. if (!silent) {
  4168. content = state.src.slice(labelStart, labelEnd);
  4169. state.md.inline.parse(
  4170. content,
  4171. state.md,
  4172. state.env,
  4173. tokens = []
  4174. );
  4175. token = state.push('image', 'img', 0);
  4176. token.attrs = attrs = [ [ 'src', href ], [ 'alt', '' ] ];
  4177. token.children = tokens;
  4178. token.content = content;
  4179. if (title) {
  4180. attrs.push([ 'title', title ]);
  4181. }
  4182. }
  4183. state.pos = pos;
  4184. state.posMax = max;
  4185. return true;
  4186. };
  4187. },{"../common/utils":4}],45:[function(require,module,exports){
  4188. // Process [link](<to> "stuff")
  4189. 'use strict';
  4190. var normalizeReference = require('../common/utils').normalizeReference;
  4191. var isSpace = require('../common/utils').isSpace;
  4192. module.exports = function link(state, silent) {
  4193. var attrs,
  4194. code,
  4195. label,
  4196. labelEnd,
  4197. labelStart,
  4198. pos,
  4199. res,
  4200. ref,
  4201. title,
  4202. token,
  4203. href = '',
  4204. oldPos = state.pos,
  4205. max = state.posMax,
  4206. start = state.pos,
  4207. parseReference = true;
  4208. if (state.src.charCodeAt(state.pos) !== 0x5B/* [ */) { return false; }
  4209. labelStart = state.pos + 1;
  4210. labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, true);
  4211. // parser failed to find ']', so it's not a valid link
  4212. if (labelEnd < 0) { return false; }
  4213. pos = labelEnd + 1;
  4214. if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {
  4215. //
  4216. // Inline link
  4217. //
  4218. // might have found a valid shortcut link, disable reference parsing
  4219. parseReference = false;
  4220. // [link]( <href> "title" )
  4221. // ^^ skipping these spaces
  4222. pos++;
  4223. for (; pos < max; pos++) {
  4224. code = state.src.charCodeAt(pos);
  4225. if (!isSpace(code) && code !== 0x0A) { break; }
  4226. }
  4227. if (pos >= max) { return false; }
  4228. // [link]( <href> "title" )
  4229. // ^^^^^^ parsing link destination
  4230. start = pos;
  4231. res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
  4232. if (res.ok) {
  4233. href = state.md.normalizeLink(res.str);
  4234. if (state.md.validateLink(href)) {
  4235. pos = res.pos;
  4236. } else {
  4237. href = '';
  4238. }
  4239. }
  4240. // [link]( <href> "title" )
  4241. // ^^ skipping these spaces
  4242. start = pos;
  4243. for (; pos < max; pos++) {
  4244. code = state.src.charCodeAt(pos);
  4245. if (!isSpace(code) && code !== 0x0A) { break; }
  4246. }
  4247. // [link]( <href> "title" )
  4248. // ^^^^^^^ parsing link title
  4249. res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
  4250. if (pos < max && start !== pos && res.ok) {
  4251. title = res.str;
  4252. pos = res.pos;
  4253. // [link]( <href> "title" )
  4254. // ^^ skipping these spaces
  4255. for (; pos < max; pos++) {
  4256. code = state.src.charCodeAt(pos);
  4257. if (!isSpace(code) && code !== 0x0A) { break; }
  4258. }
  4259. } else {
  4260. title = '';
  4261. }
  4262. if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
  4263. // parsing a valid shortcut link failed, fallback to reference
  4264. parseReference = true;
  4265. }
  4266. pos++;
  4267. }
  4268. if (parseReference) {
  4269. //
  4270. // Link reference
  4271. //
  4272. if (typeof state.env.references === 'undefined') { return false; }
  4273. if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
  4274. start = pos + 1;
  4275. pos = state.md.helpers.parseLinkLabel(state, pos);
  4276. if (pos >= 0) {
  4277. label = state.src.slice(start, pos++);
  4278. } else {
  4279. pos = labelEnd + 1;
  4280. }
  4281. } else {
  4282. pos = labelEnd + 1;
  4283. }
  4284. // covers label === '' and label === undefined
  4285. // (collapsed reference link and shortcut reference link respectively)
  4286. if (!label) { label = state.src.slice(labelStart, labelEnd); }
  4287. ref = state.env.references[normalizeReference(label)];
  4288. if (!ref) {
  4289. state.pos = oldPos;
  4290. return false;
  4291. }
  4292. href = ref.href;
  4293. title = ref.title;
  4294. }
  4295. //
  4296. // We found the end of the link, and know for a fact it's a valid link;
  4297. // so all that's left to do is to call tokenizer.
  4298. //
  4299. if (!silent) {
  4300. state.pos = labelStart;
  4301. state.posMax = labelEnd;
  4302. token = state.push('link_open', 'a', 1);
  4303. token.attrs = attrs = [ [ 'href', href ] ];
  4304. if (title) {
  4305. attrs.push([ 'title', title ]);
  4306. }
  4307. state.md.inline.tokenize(state);
  4308. token = state.push('link_close', 'a', -1);
  4309. }
  4310. state.pos = pos;
  4311. state.posMax = max;
  4312. return true;
  4313. };
  4314. },{"../common/utils":4}],46:[function(require,module,exports){
  4315. // Proceess '\n'
  4316. 'use strict';
  4317. var isSpace = require('../common/utils').isSpace;
  4318. module.exports = function newline(state, silent) {
  4319. var pmax, max, pos = state.pos;
  4320. if (state.src.charCodeAt(pos) !== 0x0A/* \n */) { return false; }
  4321. pmax = state.pending.length - 1;
  4322. max = state.posMax;
  4323. // ' \n' -> hardbreak
  4324. // Lookup in pending chars is bad practice! Don't copy to other rules!
  4325. // Pending string is stored in concat mode, indexed lookups will cause
  4326. // convertion to flat mode.
  4327. if (!silent) {
  4328. if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) {
  4329. if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) {
  4330. state.pending = state.pending.replace(/ +$/, '');
  4331. state.push('hardbreak', 'br', 0);
  4332. } else {
  4333. state.pending = state.pending.slice(0, -1);
  4334. state.push('softbreak', 'br', 0);
  4335. }
  4336. } else {
  4337. state.push('softbreak', 'br', 0);
  4338. }
  4339. }
  4340. pos++;
  4341. // skip heading spaces for next line
  4342. while (pos < max && isSpace(state.src.charCodeAt(pos))) { pos++; }
  4343. state.pos = pos;
  4344. return true;
  4345. };
  4346. },{"../common/utils":4}],47:[function(require,module,exports){
  4347. // Inline parser state
  4348. 'use strict';
  4349. var Token = require('../token');
  4350. var isWhiteSpace = require('../common/utils').isWhiteSpace;
  4351. var isPunctChar = require('../common/utils').isPunctChar;
  4352. var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct;
  4353. function StateInline(src, md, env, outTokens) {
  4354. this.src = src;
  4355. this.env = env;
  4356. this.md = md;
  4357. this.tokens = outTokens;
  4358. this.pos = 0;
  4359. this.posMax = this.src.length;
  4360. this.level = 0;
  4361. this.pending = '';
  4362. this.pendingLevel = 0;
  4363. this.cache = {}; // Stores { start: end } pairs. Useful for backtrack
  4364. // optimization of pairs parse (emphasis, strikes).
  4365. this.delimiters = []; // Emphasis-like delimiters
  4366. }
  4367. // Flush pending text
  4368. //
  4369. StateInline.prototype.pushPending = function () {
  4370. var token = new Token('text', '', 0);
  4371. token.content = this.pending;
  4372. token.level = this.pendingLevel;
  4373. this.tokens.push(token);
  4374. this.pending = '';
  4375. return token;
  4376. };
  4377. // Push new token to "stream".
  4378. // If pending text exists - flush it as text token
  4379. //
  4380. StateInline.prototype.push = function (type, tag, nesting) {
  4381. if (this.pending) {
  4382. this.pushPending();
  4383. }
  4384. var token = new Token(type, tag, nesting);
  4385. if (nesting < 0) { this.level--; }
  4386. token.level = this.level;
  4387. if (nesting > 0) { this.level++; }
  4388. this.pendingLevel = this.level;
  4389. this.tokens.push(token);
  4390. return token;
  4391. };
  4392. // Scan a sequence of emphasis-like markers, and determine whether
  4393. // it can start an emphasis sequence or end an emphasis sequence.
  4394. //
  4395. // - start - position to scan from (it should point at a valid marker);
  4396. // - canSplitWord - determine if these markers can be found inside a word
  4397. //
  4398. StateInline.prototype.scanDelims = function (start, canSplitWord) {
  4399. var pos = start, lastChar, nextChar, count, can_open, can_close,
  4400. isLastWhiteSpace, isLastPunctChar,
  4401. isNextWhiteSpace, isNextPunctChar,
  4402. left_flanking = true,
  4403. right_flanking = true,
  4404. max = this.posMax,
  4405. marker = this.src.charCodeAt(start);
  4406. // treat beginning of the line as a whitespace
  4407. lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 0x20;
  4408. while (pos < max && this.src.charCodeAt(pos) === marker) { pos++; }
  4409. count = pos - start;
  4410. // treat end of the line as a whitespace
  4411. nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20;
  4412. isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
  4413. isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
  4414. isLastWhiteSpace = isWhiteSpace(lastChar);
  4415. isNextWhiteSpace = isWhiteSpace(nextChar);
  4416. if (isNextWhiteSpace) {
  4417. left_flanking = false;
  4418. } else if (isNextPunctChar) {
  4419. if (!(isLastWhiteSpace || isLastPunctChar)) {
  4420. left_flanking = false;
  4421. }
  4422. }
  4423. if (isLastWhiteSpace) {
  4424. right_flanking = false;
  4425. } else if (isLastPunctChar) {
  4426. if (!(isNextWhiteSpace || isNextPunctChar)) {
  4427. right_flanking = false;
  4428. }
  4429. }
  4430. if (!canSplitWord) {
  4431. can_open = left_flanking && (!right_flanking || isLastPunctChar);
  4432. can_close = right_flanking && (!left_flanking || isNextPunctChar);
  4433. } else {
  4434. can_open = left_flanking;
  4435. can_close = right_flanking;
  4436. }
  4437. return {
  4438. can_open: can_open,
  4439. can_close: can_close,
  4440. length: count
  4441. };
  4442. };
  4443. // re-export Token class to use in block rules
  4444. StateInline.prototype.Token = Token;
  4445. module.exports = StateInline;
  4446. },{"../common/utils":4,"../token":51}],48:[function(require,module,exports){
  4447. // ~~strike through~~
  4448. //
  4449. 'use strict';
  4450. // Insert each marker as a separate text token, and add it to delimiter list
  4451. //
  4452. module.exports.tokenize = function strikethrough(state, silent) {
  4453. var i, scanned, token, len, ch,
  4454. start = state.pos,
  4455. marker = state.src.charCodeAt(start);
  4456. if (silent) { return false; }
  4457. if (marker !== 0x7E/* ~ */) { return false; }
  4458. scanned = state.scanDelims(state.pos, true);
  4459. len = scanned.length;
  4460. ch = String.fromCharCode(marker);
  4461. if (len < 2) { return false; }
  4462. if (len % 2) {
  4463. token = state.push('text', '', 0);
  4464. token.content = ch;
  4465. len--;
  4466. }
  4467. for (i = 0; i < len; i += 2) {
  4468. token = state.push('text', '', 0);
  4469. token.content = ch + ch;
  4470. state.delimiters.push({
  4471. marker: marker,
  4472. jump: i,
  4473. token: state.tokens.length - 1,
  4474. level: state.level,
  4475. end: -1,
  4476. open: scanned.can_open,
  4477. close: scanned.can_close
  4478. });
  4479. }
  4480. state.pos += scanned.length;
  4481. return true;
  4482. };
  4483. // Walk through delimiter list and replace text tokens with tags
  4484. //
  4485. module.exports.postProcess = function strikethrough(state) {
  4486. var i, j,
  4487. startDelim,
  4488. endDelim,
  4489. token,
  4490. loneMarkers = [],
  4491. delimiters = state.delimiters,
  4492. max = state.delimiters.length;
  4493. for (i = 0; i < max; i++) {
  4494. startDelim = delimiters[i];
  4495. if (startDelim.marker !== 0x7E/* ~ */) {
  4496. continue;
  4497. }
  4498. if (startDelim.end === -1) {
  4499. continue;
  4500. }
  4501. endDelim = delimiters[startDelim.end];
  4502. token = state.tokens[startDelim.token];
  4503. token.type = 's_open';
  4504. token.tag = 's';
  4505. token.nesting = 1;
  4506. token.markup = '~~';
  4507. token.content = '';
  4508. token = state.tokens[endDelim.token];
  4509. token.type = 's_close';
  4510. token.tag = 's';
  4511. token.nesting = -1;
  4512. token.markup = '~~';
  4513. token.content = '';
  4514. if (state.tokens[endDelim.token - 1].type === 'text' &&
  4515. state.tokens[endDelim.token - 1].content === '~') {
  4516. loneMarkers.push(endDelim.token - 1);
  4517. }
  4518. }
  4519. // If a marker sequence has an odd number of characters, it's splitted
  4520. // like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the
  4521. // start of the sequence.
  4522. //
  4523. // So, we have to move all those markers after subsequent s_close tags.
  4524. //
  4525. while (loneMarkers.length) {
  4526. i = loneMarkers.pop();
  4527. j = i + 1;
  4528. while (j < state.tokens.length && state.tokens[j].type === 's_close') {
  4529. j++;
  4530. }
  4531. j--;
  4532. if (i !== j) {
  4533. token = state.tokens[j];
  4534. state.tokens[j] = state.tokens[i];
  4535. state.tokens[i] = token;
  4536. }
  4537. }
  4538. };
  4539. },{}],49:[function(require,module,exports){
  4540. // Skip text characters for text token, place those to pending buffer
  4541. // and increment current pos
  4542. 'use strict';
  4543. // Rule to skip pure text
  4544. // '{}$%@~+=:' reserved for extentions
  4545. // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
  4546. // !!!! Don't confuse with "Markdown ASCII Punctuation" chars
  4547. // http://spec.commonmark.org/0.15/#ascii-punctuation-character
  4548. function isTerminatorChar(ch) {
  4549. switch (ch) {
  4550. case 0x0A/* \n */:
  4551. case 0x21/* ! */:
  4552. case 0x23/* # */:
  4553. case 0x24/* $ */:
  4554. case 0x25/* % */:
  4555. case 0x26/* & */:
  4556. case 0x2A/* * */:
  4557. case 0x2B/* + */:
  4558. case 0x2D/* - */:
  4559. case 0x3A/* : */:
  4560. case 0x3C/* < */:
  4561. case 0x3D/* = */:
  4562. case 0x3E/* > */:
  4563. case 0x40/* @ */:
  4564. case 0x5B/* [ */:
  4565. case 0x5C/* \ */:
  4566. case 0x5D/* ] */:
  4567. case 0x5E/* ^ */:
  4568. case 0x5F/* _ */:
  4569. case 0x60/* ` */:
  4570. case 0x7B/* { */:
  4571. case 0x7D/* } */:
  4572. case 0x7E/* ~ */:
  4573. return true;
  4574. default:
  4575. return false;
  4576. }
  4577. }
  4578. module.exports = function text(state, silent) {
  4579. var pos = state.pos;
  4580. while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) {
  4581. pos++;
  4582. }
  4583. if (pos === state.pos) { return false; }
  4584. if (!silent) { state.pending += state.src.slice(state.pos, pos); }
  4585. state.pos = pos;
  4586. return true;
  4587. };
  4588. // Alternative implementation, for memory.
  4589. //
  4590. // It costs 10% of performance, but allows extend terminators list, if place it
  4591. // to `ParcerInline` property. Probably, will switch to it sometime, such
  4592. // flexibility required.
  4593. /*
  4594. var TERMINATOR_RE = /[\n!#$%&*+\-:<=>@[\\\]^_`{}~]/;
  4595. module.exports = function text(state, silent) {
  4596. var pos = state.pos,
  4597. idx = state.src.slice(pos).search(TERMINATOR_RE);
  4598. // first char is terminator -> empty text
  4599. if (idx === 0) { return false; }
  4600. // no terminator -> text till end of string
  4601. if (idx < 0) {
  4602. if (!silent) { state.pending += state.src.slice(pos); }
  4603. state.pos = state.src.length;
  4604. return true;
  4605. }
  4606. if (!silent) { state.pending += state.src.slice(pos, pos + idx); }
  4607. state.pos += idx;
  4608. return true;
  4609. };*/
  4610. },{}],50:[function(require,module,exports){
  4611. // Merge adjacent text nodes into one, and re-calculate all token levels
  4612. //
  4613. 'use strict';
  4614. module.exports = function text_collapse(state) {
  4615. var curr, last,
  4616. level = 0,
  4617. tokens = state.tokens,
  4618. max = state.tokens.length;
  4619. for (curr = last = 0; curr < max; curr++) {
  4620. // re-calculate levels
  4621. level += tokens[curr].nesting;
  4622. tokens[curr].level = level;
  4623. if (tokens[curr].type === 'text' &&
  4624. curr + 1 < max &&
  4625. tokens[curr + 1].type === 'text') {
  4626. // collapse two adjacent text nodes
  4627. tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
  4628. } else {
  4629. if (curr !== last) { tokens[last] = tokens[curr]; }
  4630. last++;
  4631. }
  4632. }
  4633. if (curr !== last) {
  4634. tokens.length = last;
  4635. }
  4636. };
  4637. },{}],51:[function(require,module,exports){
  4638. // Token class
  4639. 'use strict';
  4640. /**
  4641. * class Token
  4642. **/
  4643. /**
  4644. * new Token(type, tag, nesting)
  4645. *
  4646. * Create new token and fill passed properties.
  4647. **/
  4648. function Token(type, tag, nesting) {
  4649. /**
  4650. * Token#type -> String
  4651. *
  4652. * Type of the token (string, e.g. "paragraph_open")
  4653. **/
  4654. this.type = type;
  4655. /**
  4656. * Token#tag -> String
  4657. *
  4658. * html tag name, e.g. "p"
  4659. **/
  4660. this.tag = tag;
  4661. /**
  4662. * Token#attrs -> Array
  4663. *
  4664. * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`
  4665. **/
  4666. this.attrs = null;
  4667. /**
  4668. * Token#map -> Array
  4669. *
  4670. * Source map info. Format: `[ line_begin, line_end ]`
  4671. **/
  4672. this.map = null;
  4673. /**
  4674. * Token#nesting -> Number
  4675. *
  4676. * Level change (number in {-1, 0, 1} set), where:
  4677. *
  4678. * - `1` means the tag is opening
  4679. * - `0` means the tag is self-closing
  4680. * - `-1` means the tag is closing
  4681. **/
  4682. this.nesting = nesting;
  4683. /**
  4684. * Token#level -> Number
  4685. *
  4686. * nesting level, the same as `state.level`
  4687. **/
  4688. this.level = 0;
  4689. /**
  4690. * Token#children -> Array
  4691. *
  4692. * An array of child nodes (inline and img tokens)
  4693. **/
  4694. this.children = null;
  4695. /**
  4696. * Token#content -> String
  4697. *
  4698. * In a case of self-closing tag (code, html, fence, etc.),
  4699. * it has contents of this tag.
  4700. **/
  4701. this.content = '';
  4702. /**
  4703. * Token#markup -> String
  4704. *
  4705. * '*' or '_' for emphasis, fence string for fence, etc.
  4706. **/
  4707. this.markup = '';
  4708. /**
  4709. * Token#info -> String
  4710. *
  4711. * fence infostring
  4712. **/
  4713. this.info = '';
  4714. /**
  4715. * Token#meta -> Object
  4716. *
  4717. * A place for plugins to store an arbitrary data
  4718. **/
  4719. this.meta = null;
  4720. /**
  4721. * Token#block -> Boolean
  4722. *
  4723. * True for block-level tokens, false for inline tokens.
  4724. * Used in renderer to calculate line breaks
  4725. **/
  4726. this.block = false;
  4727. /**
  4728. * Token#hidden -> Boolean
  4729. *
  4730. * If it's true, ignore this element when rendering. Used for tight lists
  4731. * to hide paragraphs.
  4732. **/
  4733. this.hidden = false;
  4734. }
  4735. /**
  4736. * Token.attrIndex(name) -> Number
  4737. *
  4738. * Search attribute index by name.
  4739. **/
  4740. Token.prototype.attrIndex = function attrIndex(name) {
  4741. var attrs, i, len;
  4742. if (!this.attrs) { return -1; }
  4743. attrs = this.attrs;
  4744. for (i = 0, len = attrs.length; i < len; i++) {
  4745. if (attrs[i][0] === name) { return i; }
  4746. }
  4747. return -1;
  4748. };
  4749. /**
  4750. * Token.attrPush(attrData)
  4751. *
  4752. * Add `[ name, value ]` attribute to list. Init attrs if necessary
  4753. **/
  4754. Token.prototype.attrPush = function attrPush(attrData) {
  4755. if (this.attrs) {
  4756. this.attrs.push(attrData);
  4757. } else {
  4758. this.attrs = [ attrData ];
  4759. }
  4760. };
  4761. /**
  4762. * Token.attrSet(name, value)
  4763. *
  4764. * Set `name` attribute to `value`. Override old value if exists.
  4765. **/
  4766. Token.prototype.attrSet = function attrSet(name, value) {
  4767. var idx = this.attrIndex(name),
  4768. attrData = [ name, value ];
  4769. if (idx < 0) {
  4770. this.attrPush(attrData);
  4771. } else {
  4772. this.attrs[idx] = attrData;
  4773. }
  4774. };
  4775. /**
  4776. * Token.attrGet(name)
  4777. *
  4778. * Get the value of attribute `name`, or null if it does not exist.
  4779. **/
  4780. Token.prototype.attrGet = function attrGet(name) {
  4781. var idx = this.attrIndex(name), value = null;
  4782. if (idx >= 0) {
  4783. value = this.attrs[idx][1];
  4784. }
  4785. return value;
  4786. };
  4787. /**
  4788. * Token.attrJoin(name, value)
  4789. *
  4790. * Join value to existing attribute via space. Or create new attribute if not
  4791. * exists. Useful to operate with token classes.
  4792. **/
  4793. Token.prototype.attrJoin = function attrJoin(name, value) {
  4794. var idx = this.attrIndex(name);
  4795. if (idx < 0) {
  4796. this.attrPush([ name, value ]);
  4797. } else {
  4798. this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value;
  4799. }
  4800. };
  4801. module.exports = Token;
  4802. },{}],52:[function(require,module,exports){
  4803. 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"}
  4804. },{}],53:[function(require,module,exports){
  4805. 'use strict';
  4806. ////////////////////////////////////////////////////////////////////////////////
  4807. // Helpers
  4808. // Merge objects
  4809. //
  4810. function assign(obj /*from1, from2, from3, ...*/) {
  4811. var sources = Array.prototype.slice.call(arguments, 1);
  4812. sources.forEach(function (source) {
  4813. if (!source) { return; }
  4814. Object.keys(source).forEach(function (key) {
  4815. obj[key] = source[key];
  4816. });
  4817. });
  4818. return obj;
  4819. }
  4820. function _class(obj) { return Object.prototype.toString.call(obj); }
  4821. function isString(obj) { return _class(obj) === '[object String]'; }
  4822. function isObject(obj) { return _class(obj) === '[object Object]'; }
  4823. function isRegExp(obj) { return _class(obj) === '[object RegExp]'; }
  4824. function isFunction(obj) { return _class(obj) === '[object Function]'; }
  4825. function escapeRE(str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&'); }
  4826. ////////////////////////////////////////////////////////////////////////////////
  4827. var defaultOptions = {
  4828. fuzzyLink: true,
  4829. fuzzyEmail: true,
  4830. fuzzyIP: false
  4831. };
  4832. function isOptionsObj(obj) {
  4833. return Object.keys(obj || {}).reduce(function (acc, k) {
  4834. return acc || defaultOptions.hasOwnProperty(k);
  4835. }, false);
  4836. }
  4837. var defaultSchemas = {
  4838. 'http:': {
  4839. validate: function (text, pos, self) {
  4840. var tail = text.slice(pos);
  4841. if (!self.re.http) {
  4842. // compile lazily, because "host"-containing variables can change on tlds update.
  4843. self.re.http = new RegExp(
  4844. '^\\/\\/' + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path, 'i'
  4845. );
  4846. }
  4847. if (self.re.http.test(tail)) {
  4848. return tail.match(self.re.http)[0].length;
  4849. }
  4850. return 0;
  4851. }
  4852. },
  4853. 'https:': 'http:',
  4854. 'ftp:': 'http:',
  4855. '//': {
  4856. validate: function (text, pos, self) {
  4857. var tail = text.slice(pos);
  4858. if (!self.re.no_http) {
  4859. // compile lazily, because "host"-containing variables can change on tlds update.
  4860. self.re.no_http = new RegExp(
  4861. '^' +
  4862. self.re.src_auth +
  4863. // Don't allow single-level domains, because of false positives like '//test'
  4864. // with code comments
  4865. '(?:localhost|(?:(?:' + self.re.src_domain + ')\\.)+' + self.re.src_domain_root + ')' +
  4866. self.re.src_port +
  4867. self.re.src_host_terminator +
  4868. self.re.src_path,
  4869. 'i'
  4870. );
  4871. }
  4872. if (self.re.no_http.test(tail)) {
  4873. // should not be `://` & `///`, that protects from errors in protocol name
  4874. if (pos >= 3 && text[pos - 3] === ':') { return 0; }
  4875. if (pos >= 3 && text[pos - 3] === '/') { return 0; }
  4876. return tail.match(self.re.no_http)[0].length;
  4877. }
  4878. return 0;
  4879. }
  4880. },
  4881. 'mailto:': {
  4882. validate: function (text, pos, self) {
  4883. var tail = text.slice(pos);
  4884. if (!self.re.mailto) {
  4885. self.re.mailto = new RegExp(
  4886. '^' + self.re.src_email_name + '@' + self.re.src_host_strict, 'i'
  4887. );
  4888. }
  4889. if (self.re.mailto.test(tail)) {
  4890. return tail.match(self.re.mailto)[0].length;
  4891. }
  4892. return 0;
  4893. }
  4894. }
  4895. };
  4896. /*eslint-disable max-len*/
  4897. // RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)
  4898. 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]';
  4899. // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
  4900. var tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
  4901. /*eslint-enable max-len*/
  4902. ////////////////////////////////////////////////////////////////////////////////
  4903. function resetScanCache(self) {
  4904. self.__index__ = -1;
  4905. self.__text_cache__ = '';
  4906. }
  4907. function createValidator(re) {
  4908. return function (text, pos) {
  4909. var tail = text.slice(pos);
  4910. if (re.test(tail)) {
  4911. return tail.match(re)[0].length;
  4912. }
  4913. return 0;
  4914. };
  4915. }
  4916. function createNormalizer() {
  4917. return function (match, self) {
  4918. self.normalize(match);
  4919. };
  4920. }
  4921. // Schemas compiler. Build regexps.
  4922. //
  4923. function compile(self) {
  4924. // Load & clone RE patterns.
  4925. var re = self.re = require('./lib/re')(self.__opts__);
  4926. // Define dynamic patterns
  4927. var tlds = self.__tlds__.slice();
  4928. self.onCompile();
  4929. if (!self.__tlds_replaced__) {
  4930. tlds.push(tlds_2ch_src_re);
  4931. }
  4932. tlds.push(re.src_xn);
  4933. re.src_tlds = tlds.join('|');
  4934. function untpl(tpl) { return tpl.replace('%TLDS%', re.src_tlds); }
  4935. re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');
  4936. re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');
  4937. re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i');
  4938. re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');
  4939. //
  4940. // Compile each schema
  4941. //
  4942. var aliases = [];
  4943. self.__compiled__ = {}; // Reset compiled data
  4944. function schemaError(name, val) {
  4945. throw new Error('(LinkifyIt) Invalid schema "' + name + '": ' + val);
  4946. }
  4947. Object.keys(self.__schemas__).forEach(function (name) {
  4948. var val = self.__schemas__[name];
  4949. // skip disabled methods
  4950. if (val === null) { return; }
  4951. var compiled = { validate: null, link: null };
  4952. self.__compiled__[name] = compiled;
  4953. if (isObject(val)) {
  4954. if (isRegExp(val.validate)) {
  4955. compiled.validate = createValidator(val.validate);
  4956. } else if (isFunction(val.validate)) {
  4957. compiled.validate = val.validate;
  4958. } else {
  4959. schemaError(name, val);
  4960. }
  4961. if (isFunction(val.normalize)) {
  4962. compiled.normalize = val.normalize;
  4963. } else if (!val.normalize) {
  4964. compiled.normalize = createNormalizer();
  4965. } else {
  4966. schemaError(name, val);
  4967. }
  4968. return;
  4969. }
  4970. if (isString(val)) {
  4971. aliases.push(name);
  4972. return;
  4973. }
  4974. schemaError(name, val);
  4975. });
  4976. //
  4977. // Compile postponed aliases
  4978. //
  4979. aliases.forEach(function (alias) {
  4980. if (!self.__compiled__[self.__schemas__[alias]]) {
  4981. // Silently fail on missed schemas to avoid errons on disable.
  4982. // schemaError(alias, self.__schemas__[alias]);
  4983. return;
  4984. }
  4985. self.__compiled__[alias].validate =
  4986. self.__compiled__[self.__schemas__[alias]].validate;
  4987. self.__compiled__[alias].normalize =
  4988. self.__compiled__[self.__schemas__[alias]].normalize;
  4989. });
  4990. //
  4991. // Fake record for guessed links
  4992. //
  4993. self.__compiled__[''] = { validate: null, normalize: createNormalizer() };
  4994. //
  4995. // Build schema condition
  4996. //
  4997. var slist = Object.keys(self.__compiled__)
  4998. .filter(function (name) {
  4999. // Filter disabled & fake schemas
  5000. return name.length > 0 && self.__compiled__[name];
  5001. })
  5002. .map(escapeRE)
  5003. .join('|');
  5004. // (?!_) cause 1.5x slowdown
  5005. self.re.schema_test = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'i');
  5006. self.re.schema_search = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'ig');
  5007. self.re.pretest = RegExp(
  5008. '(' + self.re.schema_test.source + ')|' +
  5009. '(' + self.re.host_fuzzy_test.source + ')|' +
  5010. '@',
  5011. 'i');
  5012. //
  5013. // Cleanup
  5014. //
  5015. resetScanCache(self);
  5016. }
  5017. /**
  5018. * class Match
  5019. *
  5020. * Match result. Single element of array, returned by [[LinkifyIt#match]]
  5021. **/
  5022. function Match(self, shift) {
  5023. var start = self.__index__,
  5024. end = self.__last_index__,
  5025. text = self.__text_cache__.slice(start, end);
  5026. /**
  5027. * Match#schema -> String
  5028. *
  5029. * Prefix (protocol) for matched string.
  5030. **/
  5031. this.schema = self.__schema__.toLowerCase();
  5032. /**
  5033. * Match#index -> Number
  5034. *
  5035. * First position of matched string.
  5036. **/
  5037. this.index = start + shift;
  5038. /**
  5039. * Match#lastIndex -> Number
  5040. *
  5041. * Next position after matched string.
  5042. **/
  5043. this.lastIndex = end + shift;
  5044. /**
  5045. * Match#raw -> String
  5046. *
  5047. * Matched string.
  5048. **/
  5049. this.raw = text;
  5050. /**
  5051. * Match#text -> String
  5052. *
  5053. * Notmalized text of matched string.
  5054. **/
  5055. this.text = text;
  5056. /**
  5057. * Match#url -> String
  5058. *
  5059. * Normalized url of matched string.
  5060. **/
  5061. this.url = text;
  5062. }
  5063. function createMatch(self, shift) {
  5064. var match = new Match(self, shift);
  5065. self.__compiled__[match.schema].normalize(match, self);
  5066. return match;
  5067. }
  5068. /**
  5069. * class LinkifyIt
  5070. **/
  5071. /**
  5072. * new LinkifyIt(schemas, options)
  5073. * - schemas (Object): Optional. Additional schemas to validate (prefix/validator)
  5074. * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
  5075. *
  5076. * Creates new linkifier instance with optional additional schemas.
  5077. * Can be called without `new` keyword for convenience.
  5078. *
  5079. * By default understands:
  5080. *
  5081. * - `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links
  5082. * - "fuzzy" links and emails (example.com, foo@bar.com).
  5083. *
  5084. * `schemas` is an object, where each key/value describes protocol/rule:
  5085. *
  5086. * - __key__ - link prefix (usually, protocol name with `:` at the end, `skype:`
  5087. * for example). `linkify-it` makes shure that prefix is not preceeded with
  5088. * alphanumeric char and symbols. Only whitespaces and punctuation allowed.
  5089. * - __value__ - rule to check tail after link prefix
  5090. * - _String_ - just alias to existing rule
  5091. * - _Object_
  5092. * - _validate_ - validator function (should return matched length on success),
  5093. * or `RegExp`.
  5094. * - _normalize_ - optional function to normalize text & url of matched result
  5095. * (for example, for @twitter mentions).
  5096. *
  5097. * `options`:
  5098. *
  5099. * - __fuzzyLink__ - recognige URL-s without `http(s):` prefix. Default `true`.
  5100. * - __fuzzyIP__ - allow IPs in fuzzy links above. Can conflict with some texts
  5101. * like version numbers. Default `false`.
  5102. * - __fuzzyEmail__ - recognize emails without `mailto:` prefix.
  5103. *
  5104. **/
  5105. function LinkifyIt(schemas, options) {
  5106. if (!(this instanceof LinkifyIt)) {
  5107. return new LinkifyIt(schemas, options);
  5108. }
  5109. if (!options) {
  5110. if (isOptionsObj(schemas)) {
  5111. options = schemas;
  5112. schemas = {};
  5113. }
  5114. }
  5115. this.__opts__ = assign({}, defaultOptions, options);
  5116. // Cache last tested result. Used to skip repeating steps on next `match` call.
  5117. this.__index__ = -1;
  5118. this.__last_index__ = -1; // Next scan position
  5119. this.__schema__ = '';
  5120. this.__text_cache__ = '';
  5121. this.__schemas__ = assign({}, defaultSchemas, schemas);
  5122. this.__compiled__ = {};
  5123. this.__tlds__ = tlds_default;
  5124. this.__tlds_replaced__ = false;
  5125. this.re = {};
  5126. compile(this);
  5127. }
  5128. /** chainable
  5129. * LinkifyIt#add(schema, definition)
  5130. * - schema (String): rule name (fixed pattern prefix)
  5131. * - definition (String|RegExp|Object): schema definition
  5132. *
  5133. * Add new rule definition. See constructor description for details.
  5134. **/
  5135. LinkifyIt.prototype.add = function add(schema, definition) {
  5136. this.__schemas__[schema] = definition;
  5137. compile(this);
  5138. return this;
  5139. };
  5140. /** chainable
  5141. * LinkifyIt#set(options)
  5142. * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
  5143. *
  5144. * Set recognition options for links without schema.
  5145. **/
  5146. LinkifyIt.prototype.set = function set(options) {
  5147. this.__opts__ = assign(this.__opts__, options);
  5148. return this;
  5149. };
  5150. /**
  5151. * LinkifyIt#test(text) -> Boolean
  5152. *
  5153. * Searches linkifiable pattern and returns `true` on success or `false` on fail.
  5154. **/
  5155. LinkifyIt.prototype.test = function test(text) {
  5156. // Reset scan cache
  5157. this.__text_cache__ = text;
  5158. this.__index__ = -1;
  5159. if (!text.length) { return false; }
  5160. var m, ml, me, len, shift, next, re, tld_pos, at_pos;
  5161. // try to scan for link with schema - that's the most simple rule
  5162. if (this.re.schema_test.test(text)) {
  5163. re = this.re.schema_search;
  5164. re.lastIndex = 0;
  5165. while ((m = re.exec(text)) !== null) {
  5166. len = this.testSchemaAt(text, m[2], re.lastIndex);
  5167. if (len) {
  5168. this.__schema__ = m[2];
  5169. this.__index__ = m.index + m[1].length;
  5170. this.__last_index__ = m.index + m[0].length + len;
  5171. break;
  5172. }
  5173. }
  5174. }
  5175. if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
  5176. // guess schemaless links
  5177. tld_pos = text.search(this.re.host_fuzzy_test);
  5178. if (tld_pos >= 0) {
  5179. // if tld is located after found link - no need to check fuzzy pattern
  5180. if (this.__index__ < 0 || tld_pos < this.__index__) {
  5181. if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
  5182. shift = ml.index + ml[1].length;
  5183. if (this.__index__ < 0 || shift < this.__index__) {
  5184. this.__schema__ = '';
  5185. this.__index__ = shift;
  5186. this.__last_index__ = ml.index + ml[0].length;
  5187. }
  5188. }
  5189. }
  5190. }
  5191. }
  5192. if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
  5193. // guess schemaless emails
  5194. at_pos = text.indexOf('@');
  5195. if (at_pos >= 0) {
  5196. // We can't skip this check, because this cases are possible:
  5197. // 192.168.1.1@gmail.com, my.in@example.com
  5198. if ((me = text.match(this.re.email_fuzzy)) !== null) {
  5199. shift = me.index + me[1].length;
  5200. next = me.index + me[0].length;
  5201. if (this.__index__ < 0 || shift < this.__index__ ||
  5202. (shift === this.__index__ && next > this.__last_index__)) {
  5203. this.__schema__ = 'mailto:';
  5204. this.__index__ = shift;
  5205. this.__last_index__ = next;
  5206. }
  5207. }
  5208. }
  5209. }
  5210. return this.__index__ >= 0;
  5211. };
  5212. /**
  5213. * LinkifyIt#pretest(text) -> Boolean
  5214. *
  5215. * Very quick check, that can give false positives. Returns true if link MAY BE
  5216. * can exists. Can be used for speed optimization, when you need to check that
  5217. * link NOT exists.
  5218. **/
  5219. LinkifyIt.prototype.pretest = function pretest(text) {
  5220. return this.re.pretest.test(text);
  5221. };
  5222. /**
  5223. * LinkifyIt#testSchemaAt(text, name, position) -> Number
  5224. * - text (String): text to scan
  5225. * - name (String): rule (schema) name
  5226. * - position (Number): text offset to check from
  5227. *
  5228. * Similar to [[LinkifyIt#test]] but checks only specific protocol tail exactly
  5229. * at given position. Returns length of found pattern (0 on fail).
  5230. **/
  5231. LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {
  5232. // If not supported schema check requested - terminate
  5233. if (!this.__compiled__[schema.toLowerCase()]) {
  5234. return 0;
  5235. }
  5236. return this.__compiled__[schema.toLowerCase()].validate(text, pos, this);
  5237. };
  5238. /**
  5239. * LinkifyIt#match(text) -> Array|null
  5240. *
  5241. * Returns array of found link descriptions or `null` on fail. We strongly
  5242. * recommend to use [[LinkifyIt#test]] first, for best speed.
  5243. *
  5244. * ##### Result match description
  5245. *
  5246. * - __schema__ - link schema, can be empty for fuzzy links, or `//` for
  5247. * protocol-neutral links.
  5248. * - __index__ - offset of matched text
  5249. * - __lastIndex__ - index of next char after mathch end
  5250. * - __raw__ - matched text
  5251. * - __text__ - normalized text
  5252. * - __url__ - link, generated from matched text
  5253. **/
  5254. LinkifyIt.prototype.match = function match(text) {
  5255. var shift = 0, result = [];
  5256. // Try to take previous element from cache, if .test() called before
  5257. if (this.__index__ >= 0 && this.__text_cache__ === text) {
  5258. result.push(createMatch(this, shift));
  5259. shift = this.__last_index__;
  5260. }
  5261. // Cut head if cache was used
  5262. var tail = shift ? text.slice(shift) : text;
  5263. // Scan string until end reached
  5264. while (this.test(tail)) {
  5265. result.push(createMatch(this, shift));
  5266. tail = tail.slice(this.__last_index__);
  5267. shift += this.__last_index__;
  5268. }
  5269. if (result.length) {
  5270. return result;
  5271. }
  5272. return null;
  5273. };
  5274. /** chainable
  5275. * LinkifyIt#tlds(list [, keepOld]) -> this
  5276. * - list (Array): list of tlds
  5277. * - keepOld (Boolean): merge with current list if `true` (`false` by default)
  5278. *
  5279. * Load (or merge) new tlds list. Those are user for fuzzy links (without prefix)
  5280. * to avoid false positives. By default this algorythm used:
  5281. *
  5282. * - hostname with any 2-letter root zones are ok.
  5283. * - biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф
  5284. * are ok.
  5285. * - encoded (`xn--...`) root zones are ok.
  5286. *
  5287. * If list is replaced, then exact match for 2-chars root zones will be checked.
  5288. **/
  5289. LinkifyIt.prototype.tlds = function tlds(list, keepOld) {
  5290. list = Array.isArray(list) ? list : [ list ];
  5291. if (!keepOld) {
  5292. this.__tlds__ = list.slice();
  5293. this.__tlds_replaced__ = true;
  5294. compile(this);
  5295. return this;
  5296. }
  5297. this.__tlds__ = this.__tlds__.concat(list)
  5298. .sort()
  5299. .filter(function (el, idx, arr) {
  5300. return el !== arr[idx - 1];
  5301. })
  5302. .reverse();
  5303. compile(this);
  5304. return this;
  5305. };
  5306. /**
  5307. * LinkifyIt#normalize(match)
  5308. *
  5309. * Default normalizer (if schema does not define it's own).
  5310. **/
  5311. LinkifyIt.prototype.normalize = function normalize(match) {
  5312. // Do minimal possible changes by default. Need to collect feedback prior
  5313. // to move forward https://github.com/markdown-it/linkify-it/issues/1
  5314. if (!match.schema) { match.url = 'http://' + match.url; }
  5315. if (match.schema === 'mailto:' && !/^mailto:/i.test(match.url)) {
  5316. match.url = 'mailto:' + match.url;
  5317. }
  5318. };
  5319. /**
  5320. * LinkifyIt#onCompile()
  5321. *
  5322. * Override to modify basic RegExp-s.
  5323. **/
  5324. LinkifyIt.prototype.onCompile = function onCompile() {
  5325. };
  5326. module.exports = LinkifyIt;
  5327. },{"./lib/re":54}],54:[function(require,module,exports){
  5328. 'use strict';
  5329. module.exports = function (opts) {
  5330. var re = {};
  5331. // Use direct extract instead of `regenerate` to reduse browserified size
  5332. re.src_Any = require('uc.micro/properties/Any/regex').source;
  5333. re.src_Cc = require('uc.micro/categories/Cc/regex').source;
  5334. re.src_Z = require('uc.micro/categories/Z/regex').source;
  5335. re.src_P = require('uc.micro/categories/P/regex').source;
  5336. // \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation)
  5337. re.src_ZPCc = [ re.src_Z, re.src_P, re.src_Cc ].join('|');
  5338. // \p{\Z\Cc} (white spaces + control)
  5339. re.src_ZCc = [ re.src_Z, re.src_Cc ].join('|');
  5340. // Experimental. List of chars, completely prohibited in links
  5341. // because can separate it from other part of text
  5342. var text_separators = '[><\uff5c]';
  5343. // All possible word characters (everything without punctuation, spaces & controls)
  5344. // Defined via punctuation & spaces to save space
  5345. // Should be something like \p{\L\N\S\M} (\w but without `_`)
  5346. re.src_pseudo_letter = '(?:(?!' + text_separators + '|' + re.src_ZPCc + ')' + re.src_Any + ')';
  5347. // The same as abothe but without [0-9]
  5348. // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
  5349. ////////////////////////////////////////////////////////////////////////////////
  5350. re.src_ip4 =
  5351. '(?:(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]?)';
  5352. // Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
  5353. re.src_auth = '(?:(?:(?!' + re.src_ZCc + '|[@/\\[\\]()]).)+@)?';
  5354. re.src_port =
  5355. '(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?';
  5356. re.src_host_terminator =
  5357. '(?=$|' + text_separators + '|' + re.src_ZPCc + ')(?!-|_|:\\d|\\.-|\\.(?!$|' + re.src_ZPCc + '))';
  5358. re.src_path =
  5359. '(?:' +
  5360. '[/?#]' +
  5361. '(?:' +
  5362. '(?!' + re.src_ZCc + '|' + text_separators + '|[()[\\]{}.,"\'?!\\-]).|' +
  5363. '\\[(?:(?!' + re.src_ZCc + '|\\]).)*\\]|' +
  5364. '\\((?:(?!' + re.src_ZCc + '|[)]).)*\\)|' +
  5365. '\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}|' +
  5366. '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' +
  5367. "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" +
  5368. "\\'(?=" + re.src_pseudo_letter + '|[-]).|' + // allow `I'm_king` if no pair found
  5369. '\\.{2,3}[a-zA-Z0-9%/]|' + // github has ... in commit range links. Restrict to
  5370. // - english
  5371. // - percent-encoded
  5372. // - parts of file path
  5373. // until more examples found.
  5374. '\\.(?!' + re.src_ZCc + '|[.]).|' +
  5375. (opts && opts['---'] ?
  5376. '\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate
  5377. :
  5378. '\\-+|'
  5379. ) +
  5380. '\\,(?!' + re.src_ZCc + ').|' + // allow `,,,` in paths
  5381. '\\!(?!' + re.src_ZCc + '|[!]).|' +
  5382. '\\?(?!' + re.src_ZCc + '|[?]).' +
  5383. ')+' +
  5384. '|\\/' +
  5385. ')?';
  5386. re.src_email_name =
  5387. '[\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]+';
  5388. re.src_xn =
  5389. 'xn--[a-z0-9\\-]{1,59}';
  5390. // More to read about domain names
  5391. // http://serverfault.com/questions/638260/
  5392. re.src_domain_root =
  5393. // Allow letters & digits (http://test1)
  5394. '(?:' +
  5395. re.src_xn +
  5396. '|' +
  5397. re.src_pseudo_letter + '{1,63}' +
  5398. ')';
  5399. re.src_domain =
  5400. '(?:' +
  5401. re.src_xn +
  5402. '|' +
  5403. '(?:' + re.src_pseudo_letter + ')' +
  5404. '|' +
  5405. // don't allow `--` in domain names, because:
  5406. // - that can conflict with markdown &mdash; / &ndash;
  5407. // - nobody use those anyway
  5408. '(?:' + re.src_pseudo_letter + '(?:-(?!-)|' + re.src_pseudo_letter + '){0,61}' + re.src_pseudo_letter + ')' +
  5409. ')';
  5410. re.src_host =
  5411. '(?:' +
  5412. // Don't need IP check, because digits are already allowed in normal domain names
  5413. // src_ip4 +
  5414. // '|' +
  5415. '(?:(?:(?:' + re.src_domain + ')\\.)*' + re.src_domain/*_root*/ + ')' +
  5416. ')';
  5417. re.tpl_host_fuzzy =
  5418. '(?:' +
  5419. re.src_ip4 +
  5420. '|' +
  5421. '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))' +
  5422. ')';
  5423. re.tpl_host_no_ip_fuzzy =
  5424. '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))';
  5425. re.src_host_strict =
  5426. re.src_host + re.src_host_terminator;
  5427. re.tpl_host_fuzzy_strict =
  5428. re.tpl_host_fuzzy + re.src_host_terminator;
  5429. re.src_host_port_strict =
  5430. re.src_host + re.src_port + re.src_host_terminator;
  5431. re.tpl_host_port_fuzzy_strict =
  5432. re.tpl_host_fuzzy + re.src_port + re.src_host_terminator;
  5433. re.tpl_host_port_no_ip_fuzzy_strict =
  5434. re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
  5435. ////////////////////////////////////////////////////////////////////////////////
  5436. // Main rules
  5437. // Rude test fuzzy links by host, for quick deny
  5438. re.tpl_host_fuzzy_test =
  5439. 'localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:' + re.src_ZPCc + '|>|$))';
  5440. re.tpl_email_fuzzy =
  5441. '(^|' + text_separators + '|\\(|' + re.src_ZCc + ')(' + re.src_email_name + '@' + re.tpl_host_fuzzy_strict + ')';
  5442. re.tpl_link_fuzzy =
  5443. // Fuzzy link can't be prepended with .:/\- and non punctuation.
  5444. // but can start with > (markdown blockquote)
  5445. '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
  5446. '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_fuzzy_strict + re.src_path + ')';
  5447. re.tpl_link_no_ip_fuzzy =
  5448. // Fuzzy link can't be prepended with .:/\- and non punctuation.
  5449. // but can start with > (markdown blockquote)
  5450. '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
  5451. '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ')';
  5452. return re;
  5453. };
  5454. },{"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){
  5455. 'use strict';
  5456. /* eslint-disable no-bitwise */
  5457. var decodeCache = {};
  5458. function getDecodeCache(exclude) {
  5459. var i, ch, cache = decodeCache[exclude];
  5460. if (cache) { return cache; }
  5461. cache = decodeCache[exclude] = [];
  5462. for (i = 0; i < 128; i++) {
  5463. ch = String.fromCharCode(i);
  5464. cache.push(ch);
  5465. }
  5466. for (i = 0; i < exclude.length; i++) {
  5467. ch = exclude.charCodeAt(i);
  5468. cache[ch] = '%' + ('0' + ch.toString(16).toUpperCase()).slice(-2);
  5469. }
  5470. return cache;
  5471. }
  5472. // Decode percent-encoded string.
  5473. //
  5474. function decode(string, exclude) {
  5475. var cache;
  5476. if (typeof exclude !== 'string') {
  5477. exclude = decode.defaultChars;
  5478. }
  5479. cache = getDecodeCache(exclude);
  5480. return string.replace(/(%[a-f0-9]{2})+/gi, function(seq) {
  5481. var i, l, b1, b2, b3, b4, chr,
  5482. result = '';
  5483. for (i = 0, l = seq.length; i < l; i += 3) {
  5484. b1 = parseInt(seq.slice(i + 1, i + 3), 16);
  5485. if (b1 < 0x80) {
  5486. result += cache[b1];
  5487. continue;
  5488. }
  5489. if ((b1 & 0xE0) === 0xC0 && (i + 3 < l)) {
  5490. // 110xxxxx 10xxxxxx
  5491. b2 = parseInt(seq.slice(i + 4, i + 6), 16);
  5492. if ((b2 & 0xC0) === 0x80) {
  5493. chr = ((b1 << 6) & 0x7C0) | (b2 & 0x3F);
  5494. if (chr < 0x80) {
  5495. result += '\ufffd\ufffd';
  5496. } else {
  5497. result += String.fromCharCode(chr);
  5498. }
  5499. i += 3;
  5500. continue;
  5501. }
  5502. }
  5503. if ((b1 & 0xF0) === 0xE0 && (i + 6 < l)) {
  5504. // 1110xxxx 10xxxxxx 10xxxxxx
  5505. b2 = parseInt(seq.slice(i + 4, i + 6), 16);
  5506. b3 = parseInt(seq.slice(i + 7, i + 9), 16);
  5507. if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {
  5508. chr = ((b1 << 12) & 0xF000) | ((b2 << 6) & 0xFC0) | (b3 & 0x3F);
  5509. if (chr < 0x800 || (chr >= 0xD800 && chr <= 0xDFFF)) {
  5510. result += '\ufffd\ufffd\ufffd';
  5511. } else {
  5512. result += String.fromCharCode(chr);
  5513. }
  5514. i += 6;
  5515. continue;
  5516. }
  5517. }
  5518. if ((b1 & 0xF8) === 0xF0 && (i + 9 < l)) {
  5519. // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx
  5520. b2 = parseInt(seq.slice(i + 4, i + 6), 16);
  5521. b3 = parseInt(seq.slice(i + 7, i + 9), 16);
  5522. b4 = parseInt(seq.slice(i + 10, i + 12), 16);
  5523. if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80 && (b4 & 0xC0) === 0x80) {
  5524. chr = ((b1 << 18) & 0x1C0000) | ((b2 << 12) & 0x3F000) | ((b3 << 6) & 0xFC0) | (b4 & 0x3F);
  5525. if (chr < 0x10000 || chr > 0x10FFFF) {
  5526. result += '\ufffd\ufffd\ufffd\ufffd';
  5527. } else {
  5528. chr -= 0x10000;
  5529. result += String.fromCharCode(0xD800 + (chr >> 10), 0xDC00 + (chr & 0x3FF));
  5530. }
  5531. i += 9;
  5532. continue;
  5533. }
  5534. }
  5535. result += '\ufffd';
  5536. }
  5537. return result;
  5538. });
  5539. }
  5540. decode.defaultChars = ';/?:@&=+$,#';
  5541. decode.componentChars = '';
  5542. module.exports = decode;
  5543. },{}],56:[function(require,module,exports){
  5544. 'use strict';
  5545. var encodeCache = {};
  5546. // Create a lookup array where anything but characters in `chars` string
  5547. // and alphanumeric chars is percent-encoded.
  5548. //
  5549. function getEncodeCache(exclude) {
  5550. var i, ch, cache = encodeCache[exclude];
  5551. if (cache) { return cache; }
  5552. cache = encodeCache[exclude] = [];
  5553. for (i = 0; i < 128; i++) {
  5554. ch = String.fromCharCode(i);
  5555. if (/^[0-9a-z]$/i.test(ch)) {
  5556. // always allow unencoded alphanumeric characters
  5557. cache.push(ch);
  5558. } else {
  5559. cache.push('%' + ('0' + i.toString(16).toUpperCase()).slice(-2));
  5560. }
  5561. }
  5562. for (i = 0; i < exclude.length; i++) {
  5563. cache[exclude.charCodeAt(i)] = exclude[i];
  5564. }
  5565. return cache;
  5566. }
  5567. // Encode unsafe characters with percent-encoding, skipping already
  5568. // encoded sequences.
  5569. //
  5570. // - string - string to encode
  5571. // - exclude - list of characters to ignore (in addition to a-zA-Z0-9)
  5572. // - keepEscaped - don't encode '%' in a correct escape sequence (default: true)
  5573. //
  5574. function encode(string, exclude, keepEscaped) {
  5575. var i, l, code, nextCode, cache,
  5576. result = '';
  5577. if (typeof exclude !== 'string') {
  5578. // encode(string, keepEscaped)
  5579. keepEscaped = exclude;
  5580. exclude = encode.defaultChars;
  5581. }
  5582. if (typeof keepEscaped === 'undefined') {
  5583. keepEscaped = true;
  5584. }
  5585. cache = getEncodeCache(exclude);
  5586. for (i = 0, l = string.length; i < l; i++) {
  5587. code = string.charCodeAt(i);
  5588. if (keepEscaped && code === 0x25 /* % */ && i + 2 < l) {
  5589. if (/^[0-9a-f]{2}$/i.test(string.slice(i + 1, i + 3))) {
  5590. result += string.slice(i, i + 3);
  5591. i += 2;
  5592. continue;
  5593. }
  5594. }
  5595. if (code < 128) {
  5596. result += cache[code];
  5597. continue;
  5598. }
  5599. if (code >= 0xD800 && code <= 0xDFFF) {
  5600. if (code >= 0xD800 && code <= 0xDBFF && i + 1 < l) {
  5601. nextCode = string.charCodeAt(i + 1);
  5602. if (nextCode >= 0xDC00 && nextCode <= 0xDFFF) {
  5603. result += encodeURIComponent(string[i] + string[i + 1]);
  5604. i++;
  5605. continue;
  5606. }
  5607. }
  5608. result += '%EF%BF%BD';
  5609. continue;
  5610. }
  5611. result += encodeURIComponent(string[i]);
  5612. }
  5613. return result;
  5614. }
  5615. encode.defaultChars = ";/?:@&=+$,-_.!~*'()#";
  5616. encode.componentChars = "-_.!~*'()";
  5617. module.exports = encode;
  5618. },{}],57:[function(require,module,exports){
  5619. 'use strict';
  5620. module.exports = function format(url) {
  5621. var result = '';
  5622. result += url.protocol || '';
  5623. result += url.slashes ? '//' : '';
  5624. result += url.auth ? url.auth + '@' : '';
  5625. if (url.hostname && url.hostname.indexOf(':') !== -1) {
  5626. // ipv6 address
  5627. result += '[' + url.hostname + ']';
  5628. } else {
  5629. result += url.hostname || '';
  5630. }
  5631. result += url.port ? ':' + url.port : '';
  5632. result += url.pathname || '';
  5633. result += url.search || '';
  5634. result += url.hash || '';
  5635. return result;
  5636. };
  5637. },{}],58:[function(require,module,exports){
  5638. 'use strict';
  5639. module.exports.encode = require('./encode');
  5640. module.exports.decode = require('./decode');
  5641. module.exports.format = require('./format');
  5642. module.exports.parse = require('./parse');
  5643. },{"./decode":55,"./encode":56,"./format":57,"./parse":59}],59:[function(require,module,exports){
  5644. // Copyright Joyent, Inc. and other Node contributors.
  5645. //
  5646. // Permission is hereby granted, free of charge, to any person obtaining a
  5647. // copy of this software and associated documentation files (the
  5648. // "Software"), to deal in the Software without restriction, including
  5649. // without limitation the rights to use, copy, modify, merge, publish,
  5650. // distribute, sublicense, and/or sell copies of the Software, and to permit
  5651. // persons to whom the Software is furnished to do so, subject to the
  5652. // following conditions:
  5653. //
  5654. // The above copyright notice and this permission notice shall be included
  5655. // in all copies or substantial portions of the Software.
  5656. //
  5657. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  5658. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  5659. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  5660. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  5661. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  5662. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  5663. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  5664. 'use strict';
  5665. //
  5666. // Changes from joyent/node:
  5667. //
  5668. // 1. No leading slash in paths,
  5669. // e.g. in `url.parse('http://foo?bar')` pathname is ``, not `/`
  5670. //
  5671. // 2. Backslashes are not replaced with slashes,
  5672. // so `http:\\example.org\` is treated like a relative path
  5673. //
  5674. // 3. Trailing colon is treated like a part of the path,
  5675. // i.e. in `http://example.org:foo` pathname is `:foo`
  5676. //
  5677. // 4. Nothing is URL-encoded in the resulting object,
  5678. // (in joyent/node some chars in auth and paths are encoded)
  5679. //
  5680. // 5. `url.parse()` does not have `parseQueryString` argument
  5681. //
  5682. // 6. Removed extraneous result properties: `host`, `path`, `query`, etc.,
  5683. // which can be constructed using other parts of the url.
  5684. //
  5685. function Url() {
  5686. this.protocol = null;
  5687. this.slashes = null;
  5688. this.auth = null;
  5689. this.port = null;
  5690. this.hostname = null;
  5691. this.hash = null;
  5692. this.search = null;
  5693. this.pathname = null;
  5694. }
  5695. // Reference: RFC 3986, RFC 1808, RFC 2396
  5696. // define these here so at least they only have to be
  5697. // compiled once on the first module load.
  5698. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  5699. portPattern = /:[0-9]*$/,
  5700. // Special case for a simple path URL
  5701. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  5702. // RFC 2396: characters reserved for delimiting URLs.
  5703. // We actually just auto-escape these.
  5704. delims = [ '<', '>', '"', '`', ' ', '\r', '\n', '\t' ],
  5705. // RFC 2396: characters not allowed for various reasons.
  5706. unwise = [ '{', '}', '|', '\\', '^', '`' ].concat(delims),
  5707. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  5708. autoEscape = [ '\'' ].concat(unwise),
  5709. // Characters that are never ever allowed in a hostname.
  5710. // Note that any invalid chars are also handled, but these
  5711. // are the ones that are *expected* to be seen, so we fast-path
  5712. // them.
  5713. nonHostChars = [ '%', '/', '?', ';', '#' ].concat(autoEscape),
  5714. hostEndingChars = [ '/', '?', '#' ],
  5715. hostnameMaxLen = 255,
  5716. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  5717. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  5718. // protocols that can allow "unsafe" and "unwise" chars.
  5719. /* eslint-disable no-script-url */
  5720. // protocols that never have a hostname.
  5721. hostlessProtocol = {
  5722. 'javascript': true,
  5723. 'javascript:': true
  5724. },
  5725. // protocols that always contain a // bit.
  5726. slashedProtocol = {
  5727. 'http': true,
  5728. 'https': true,
  5729. 'ftp': true,
  5730. 'gopher': true,
  5731. 'file': true,
  5732. 'http:': true,
  5733. 'https:': true,
  5734. 'ftp:': true,
  5735. 'gopher:': true,
  5736. 'file:': true
  5737. };
  5738. /* eslint-enable no-script-url */
  5739. function urlParse(url, slashesDenoteHost) {
  5740. if (url && url instanceof Url) { return url; }
  5741. var u = new Url();
  5742. u.parse(url, slashesDenoteHost);
  5743. return u;
  5744. }
  5745. Url.prototype.parse = function(url, slashesDenoteHost) {
  5746. var i, l, lowerProto, hec, slashes,
  5747. rest = url;
  5748. // trim before proceeding.
  5749. // This is to support parse stuff like " http://foo.com \n"
  5750. rest = rest.trim();
  5751. if (!slashesDenoteHost && url.split('#').length === 1) {
  5752. // Try fast path regexp
  5753. var simplePath = simplePathPattern.exec(rest);
  5754. if (simplePath) {
  5755. this.pathname = simplePath[1];
  5756. if (simplePath[2]) {
  5757. this.search = simplePath[2];
  5758. }
  5759. return this;
  5760. }
  5761. }
  5762. var proto = protocolPattern.exec(rest);
  5763. if (proto) {
  5764. proto = proto[0];
  5765. lowerProto = proto.toLowerCase();
  5766. this.protocol = proto;
  5767. rest = rest.substr(proto.length);
  5768. }
  5769. // figure out if it's got a host
  5770. // user@server is *always* interpreted as a hostname, and url
  5771. // resolution will treat //foo/bar as host=foo,path=bar because that's
  5772. // how the browser resolves relative URLs.
  5773. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  5774. slashes = rest.substr(0, 2) === '//';
  5775. if (slashes && !(proto && hostlessProtocol[proto])) {
  5776. rest = rest.substr(2);
  5777. this.slashes = true;
  5778. }
  5779. }
  5780. if (!hostlessProtocol[proto] &&
  5781. (slashes || (proto && !slashedProtocol[proto]))) {
  5782. // there's a hostname.
  5783. // the first instance of /, ?, ;, or # ends the host.
  5784. //
  5785. // If there is an @ in the hostname, then non-host chars *are* allowed
  5786. // to the left of the last @ sign, unless some host-ending character
  5787. // comes *before* the @-sign.
  5788. // URLs are obnoxious.
  5789. //
  5790. // ex:
  5791. // http://a@b@c/ => user:a@b host:c
  5792. // http://a@b?@c => user:a host:c path:/?@c
  5793. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  5794. // Review our test case against browsers more comprehensively.
  5795. // find the first instance of any hostEndingChars
  5796. var hostEnd = -1;
  5797. for (i = 0; i < hostEndingChars.length; i++) {
  5798. hec = rest.indexOf(hostEndingChars[i]);
  5799. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
  5800. hostEnd = hec;
  5801. }
  5802. }
  5803. // at this point, either we have an explicit point where the
  5804. // auth portion cannot go past, or the last @ char is the decider.
  5805. var auth, atSign;
  5806. if (hostEnd === -1) {
  5807. // atSign can be anywhere.
  5808. atSign = rest.lastIndexOf('@');
  5809. } else {
  5810. // atSign must be in auth portion.
  5811. // http://a@b/c@d => host:b auth:a path:/c@d
  5812. atSign = rest.lastIndexOf('@', hostEnd);
  5813. }
  5814. // Now we have a portion which is definitely the auth.
  5815. // Pull that off.
  5816. if (atSign !== -1) {
  5817. auth = rest.slice(0, atSign);
  5818. rest = rest.slice(atSign + 1);
  5819. this.auth = auth;
  5820. }
  5821. // the host is the remaining to the left of the first non-host char
  5822. hostEnd = -1;
  5823. for (i = 0; i < nonHostChars.length; i++) {
  5824. hec = rest.indexOf(nonHostChars[i]);
  5825. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
  5826. hostEnd = hec;
  5827. }
  5828. }
  5829. // if we still have not hit it, then the entire thing is a host.
  5830. if (hostEnd === -1) {
  5831. hostEnd = rest.length;
  5832. }
  5833. if (rest[hostEnd - 1] === ':') { hostEnd--; }
  5834. var host = rest.slice(0, hostEnd);
  5835. rest = rest.slice(hostEnd);
  5836. // pull out port.
  5837. this.parseHost(host);
  5838. // we've indicated that there is a hostname,
  5839. // so even if it's empty, it has to be present.
  5840. this.hostname = this.hostname || '';
  5841. // if hostname begins with [ and ends with ]
  5842. // assume that it's an IPv6 address.
  5843. var ipv6Hostname = this.hostname[0] === '[' &&
  5844. this.hostname[this.hostname.length - 1] === ']';
  5845. // validate a little.
  5846. if (!ipv6Hostname) {
  5847. var hostparts = this.hostname.split(/\./);
  5848. for (i = 0, l = hostparts.length; i < l; i++) {
  5849. var part = hostparts[i];
  5850. if (!part) { continue; }
  5851. if (!part.match(hostnamePartPattern)) {
  5852. var newpart = '';
  5853. for (var j = 0, k = part.length; j < k; j++) {
  5854. if (part.charCodeAt(j) > 127) {
  5855. // we replace non-ASCII char with a temporary placeholder
  5856. // we need this to make sure size of hostname is not
  5857. // broken by replacing non-ASCII by nothing
  5858. newpart += 'x';
  5859. } else {
  5860. newpart += part[j];
  5861. }
  5862. }
  5863. // we test again with ASCII char only
  5864. if (!newpart.match(hostnamePartPattern)) {
  5865. var validParts = hostparts.slice(0, i);
  5866. var notHost = hostparts.slice(i + 1);
  5867. var bit = part.match(hostnamePartStart);
  5868. if (bit) {
  5869. validParts.push(bit[1]);
  5870. notHost.unshift(bit[2]);
  5871. }
  5872. if (notHost.length) {
  5873. rest = notHost.join('.') + rest;
  5874. }
  5875. this.hostname = validParts.join('.');
  5876. break;
  5877. }
  5878. }
  5879. }
  5880. }
  5881. if (this.hostname.length > hostnameMaxLen) {
  5882. this.hostname = '';
  5883. }
  5884. // strip [ and ] from the hostname
  5885. // the host field still retains them, though
  5886. if (ipv6Hostname) {
  5887. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  5888. }
  5889. }
  5890. // chop off from the tail first.
  5891. var hash = rest.indexOf('#');
  5892. if (hash !== -1) {
  5893. // got a fragment string.
  5894. this.hash = rest.substr(hash);
  5895. rest = rest.slice(0, hash);
  5896. }
  5897. var qm = rest.indexOf('?');
  5898. if (qm !== -1) {
  5899. this.search = rest.substr(qm);
  5900. rest = rest.slice(0, qm);
  5901. }
  5902. if (rest) { this.pathname = rest; }
  5903. if (slashedProtocol[lowerProto] &&
  5904. this.hostname && !this.pathname) {
  5905. this.pathname = '';
  5906. }
  5907. return this;
  5908. };
  5909. Url.prototype.parseHost = function(host) {
  5910. var port = portPattern.exec(host);
  5911. if (port) {
  5912. port = port[0];
  5913. if (port !== ':') {
  5914. this.port = port.substr(1);
  5915. }
  5916. host = host.substr(0, host.length - port.length);
  5917. }
  5918. if (host) { this.hostname = host; }
  5919. };
  5920. module.exports = urlParse;
  5921. },{}],60:[function(require,module,exports){
  5922. (function (global){
  5923. /*! https://mths.be/punycode v1.4.1 by @mathias */
  5924. ;(function(root) {
  5925. /** Detect free variables */
  5926. var freeExports = typeof exports == 'object' && exports &&
  5927. !exports.nodeType && exports;
  5928. var freeModule = typeof module == 'object' && module &&
  5929. !module.nodeType && module;
  5930. var freeGlobal = typeof global == 'object' && global;
  5931. if (
  5932. freeGlobal.global === freeGlobal ||
  5933. freeGlobal.window === freeGlobal ||
  5934. freeGlobal.self === freeGlobal
  5935. ) {
  5936. root = freeGlobal;
  5937. }
  5938. /**
  5939. * The `punycode` object.
  5940. * @name punycode
  5941. * @type Object
  5942. */
  5943. var punycode,
  5944. /** Highest positive signed 32-bit float value */
  5945. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  5946. /** Bootstring parameters */
  5947. base = 36,
  5948. tMin = 1,
  5949. tMax = 26,
  5950. skew = 38,
  5951. damp = 700,
  5952. initialBias = 72,
  5953. initialN = 128, // 0x80
  5954. delimiter = '-', // '\x2D'
  5955. /** Regular expressions */
  5956. regexPunycode = /^xn--/,
  5957. regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
  5958. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
  5959. /** Error messages */
  5960. errors = {
  5961. 'overflow': 'Overflow: input needs wider integers to process',
  5962. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  5963. 'invalid-input': 'Invalid input'
  5964. },
  5965. /** Convenience shortcuts */
  5966. baseMinusTMin = base - tMin,
  5967. floor = Math.floor,
  5968. stringFromCharCode = String.fromCharCode,
  5969. /** Temporary variable */
  5970. key;
  5971. /*--------------------------------------------------------------------------*/
  5972. /**
  5973. * A generic error utility function.
  5974. * @private
  5975. * @param {String} type The error type.
  5976. * @returns {Error} Throws a `RangeError` with the applicable error message.
  5977. */
  5978. function error(type) {
  5979. throw new RangeError(errors[type]);
  5980. }
  5981. /**
  5982. * A generic `Array#map` utility function.
  5983. * @private
  5984. * @param {Array} array The array to iterate over.
  5985. * @param {Function} callback The function that gets called for every array
  5986. * item.
  5987. * @returns {Array} A new array of values returned by the callback function.
  5988. */
  5989. function map(array, fn) {
  5990. var length = array.length;
  5991. var result = [];
  5992. while (length--) {
  5993. result[length] = fn(array[length]);
  5994. }
  5995. return result;
  5996. }
  5997. /**
  5998. * A simple `Array#map`-like wrapper to work with domain name strings or email
  5999. * addresses.
  6000. * @private
  6001. * @param {String} domain The domain name or email address.
  6002. * @param {Function} callback The function that gets called for every
  6003. * character.
  6004. * @returns {Array} A new string of characters returned by the callback
  6005. * function.
  6006. */
  6007. function mapDomain(string, fn) {
  6008. var parts = string.split('@');
  6009. var result = '';
  6010. if (parts.length > 1) {
  6011. // In email addresses, only the domain name should be punycoded. Leave
  6012. // the local part (i.e. everything up to `@`) intact.
  6013. result = parts[0] + '@';
  6014. string = parts[1];
  6015. }
  6016. // Avoid `split(regex)` for IE8 compatibility. See #17.
  6017. string = string.replace(regexSeparators, '\x2E');
  6018. var labels = string.split('.');
  6019. var encoded = map(labels, fn).join('.');
  6020. return result + encoded;
  6021. }
  6022. /**
  6023. * Creates an array containing the numeric code points of each Unicode
  6024. * character in the string. While JavaScript uses UCS-2 internally,
  6025. * this function will convert a pair of surrogate halves (each of which
  6026. * UCS-2 exposes as separate characters) into a single code point,
  6027. * matching UTF-16.
  6028. * @see `punycode.ucs2.encode`
  6029. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  6030. * @memberOf punycode.ucs2
  6031. * @name decode
  6032. * @param {String} string The Unicode input string (UCS-2).
  6033. * @returns {Array} The new array of code points.
  6034. */
  6035. function ucs2decode(string) {
  6036. var output = [],
  6037. counter = 0,
  6038. length = string.length,
  6039. value,
  6040. extra;
  6041. while (counter < length) {
  6042. value = string.charCodeAt(counter++);
  6043. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  6044. // high surrogate, and there is a next character
  6045. extra = string.charCodeAt(counter++);
  6046. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  6047. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  6048. } else {
  6049. // unmatched surrogate; only append this code unit, in case the next
  6050. // code unit is the high surrogate of a surrogate pair
  6051. output.push(value);
  6052. counter--;
  6053. }
  6054. } else {
  6055. output.push(value);
  6056. }
  6057. }
  6058. return output;
  6059. }
  6060. /**
  6061. * Creates a string based on an array of numeric code points.
  6062. * @see `punycode.ucs2.decode`
  6063. * @memberOf punycode.ucs2
  6064. * @name encode
  6065. * @param {Array} codePoints The array of numeric code points.
  6066. * @returns {String} The new Unicode string (UCS-2).
  6067. */
  6068. function ucs2encode(array) {
  6069. return map(array, function(value) {
  6070. var output = '';
  6071. if (value > 0xFFFF) {
  6072. value -= 0x10000;
  6073. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  6074. value = 0xDC00 | value & 0x3FF;
  6075. }
  6076. output += stringFromCharCode(value);
  6077. return output;
  6078. }).join('');
  6079. }
  6080. /**
  6081. * Converts a basic code point into a digit/integer.
  6082. * @see `digitToBasic()`
  6083. * @private
  6084. * @param {Number} codePoint The basic numeric code point value.
  6085. * @returns {Number} The numeric value of a basic code point (for use in
  6086. * representing integers) in the range `0` to `base - 1`, or `base` if
  6087. * the code point does not represent a value.
  6088. */
  6089. function basicToDigit(codePoint) {
  6090. if (codePoint - 48 < 10) {
  6091. return codePoint - 22;
  6092. }
  6093. if (codePoint - 65 < 26) {
  6094. return codePoint - 65;
  6095. }
  6096. if (codePoint - 97 < 26) {
  6097. return codePoint - 97;
  6098. }
  6099. return base;
  6100. }
  6101. /**
  6102. * Converts a digit/integer into a basic code point.
  6103. * @see `basicToDigit()`
  6104. * @private
  6105. * @param {Number} digit The numeric value of a basic code point.
  6106. * @returns {Number} The basic code point whose value (when used for
  6107. * representing integers) is `digit`, which needs to be in the range
  6108. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  6109. * used; else, the lowercase form is used. The behavior is undefined
  6110. * if `flag` is non-zero and `digit` has no uppercase form.
  6111. */
  6112. function digitToBasic(digit, flag) {
  6113. // 0..25 map to ASCII a..z or A..Z
  6114. // 26..35 map to ASCII 0..9
  6115. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  6116. }
  6117. /**
  6118. * Bias adaptation function as per section 3.4 of RFC 3492.
  6119. * https://tools.ietf.org/html/rfc3492#section-3.4
  6120. * @private
  6121. */
  6122. function adapt(delta, numPoints, firstTime) {
  6123. var k = 0;
  6124. delta = firstTime ? floor(delta / damp) : delta >> 1;
  6125. delta += floor(delta / numPoints);
  6126. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  6127. delta = floor(delta / baseMinusTMin);
  6128. }
  6129. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  6130. }
  6131. /**
  6132. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  6133. * symbols.
  6134. * @memberOf punycode
  6135. * @param {String} input The Punycode string of ASCII-only symbols.
  6136. * @returns {String} The resulting string of Unicode symbols.
  6137. */
  6138. function decode(input) {
  6139. // Don't use UCS-2
  6140. var output = [],
  6141. inputLength = input.length,
  6142. out,
  6143. i = 0,
  6144. n = initialN,
  6145. bias = initialBias,
  6146. basic,
  6147. j,
  6148. index,
  6149. oldi,
  6150. w,
  6151. k,
  6152. digit,
  6153. t,
  6154. /** Cached calculation results */
  6155. baseMinusT;
  6156. // Handle the basic code points: let `basic` be the number of input code
  6157. // points before the last delimiter, or `0` if there is none, then copy
  6158. // the first basic code points to the output.
  6159. basic = input.lastIndexOf(delimiter);
  6160. if (basic < 0) {
  6161. basic = 0;
  6162. }
  6163. for (j = 0; j < basic; ++j) {
  6164. // if it's not a basic code point
  6165. if (input.charCodeAt(j) >= 0x80) {
  6166. error('not-basic');
  6167. }
  6168. output.push(input.charCodeAt(j));
  6169. }
  6170. // Main decoding loop: start just after the last delimiter if any basic code
  6171. // points were copied; start at the beginning otherwise.
  6172. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  6173. // `index` is the index of the next character to be consumed.
  6174. // Decode a generalized variable-length integer into `delta`,
  6175. // which gets added to `i`. The overflow checking is easier
  6176. // if we increase `i` as we go, then subtract off its starting
  6177. // value at the end to obtain `delta`.
  6178. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  6179. if (index >= inputLength) {
  6180. error('invalid-input');
  6181. }
  6182. digit = basicToDigit(input.charCodeAt(index++));
  6183. if (digit >= base || digit > floor((maxInt - i) / w)) {
  6184. error('overflow');
  6185. }
  6186. i += digit * w;
  6187. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  6188. if (digit < t) {
  6189. break;
  6190. }
  6191. baseMinusT = base - t;
  6192. if (w > floor(maxInt / baseMinusT)) {
  6193. error('overflow');
  6194. }
  6195. w *= baseMinusT;
  6196. }
  6197. out = output.length + 1;
  6198. bias = adapt(i - oldi, out, oldi == 0);
  6199. // `i` was supposed to wrap around from `out` to `0`,
  6200. // incrementing `n` each time, so we'll fix that now:
  6201. if (floor(i / out) > maxInt - n) {
  6202. error('overflow');
  6203. }
  6204. n += floor(i / out);
  6205. i %= out;
  6206. // Insert `n` at position `i` of the output
  6207. output.splice(i++, 0, n);
  6208. }
  6209. return ucs2encode(output);
  6210. }
  6211. /**
  6212. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  6213. * Punycode string of ASCII-only symbols.
  6214. * @memberOf punycode
  6215. * @param {String} input The string of Unicode symbols.
  6216. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  6217. */
  6218. function encode(input) {
  6219. var n,
  6220. delta,
  6221. handledCPCount,
  6222. basicLength,
  6223. bias,
  6224. j,
  6225. m,
  6226. q,
  6227. k,
  6228. t,
  6229. currentValue,
  6230. output = [],
  6231. /** `inputLength` will hold the number of code points in `input`. */
  6232. inputLength,
  6233. /** Cached calculation results */
  6234. handledCPCountPlusOne,
  6235. baseMinusT,
  6236. qMinusT;
  6237. // Convert the input in UCS-2 to Unicode
  6238. input = ucs2decode(input);
  6239. // Cache the length
  6240. inputLength = input.length;
  6241. // Initialize the state
  6242. n = initialN;
  6243. delta = 0;
  6244. bias = initialBias;
  6245. // Handle the basic code points
  6246. for (j = 0; j < inputLength; ++j) {
  6247. currentValue = input[j];
  6248. if (currentValue < 0x80) {
  6249. output.push(stringFromCharCode(currentValue));
  6250. }
  6251. }
  6252. handledCPCount = basicLength = output.length;
  6253. // `handledCPCount` is the number of code points that have been handled;
  6254. // `basicLength` is the number of basic code points.
  6255. // Finish the basic string - if it is not empty - with a delimiter
  6256. if (basicLength) {
  6257. output.push(delimiter);
  6258. }
  6259. // Main encoding loop:
  6260. while (handledCPCount < inputLength) {
  6261. // All non-basic code points < n have been handled already. Find the next
  6262. // larger one:
  6263. for (m = maxInt, j = 0; j < inputLength; ++j) {
  6264. currentValue = input[j];
  6265. if (currentValue >= n && currentValue < m) {
  6266. m = currentValue;
  6267. }
  6268. }
  6269. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  6270. // but guard against overflow
  6271. handledCPCountPlusOne = handledCPCount + 1;
  6272. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  6273. error('overflow');
  6274. }
  6275. delta += (m - n) * handledCPCountPlusOne;
  6276. n = m;
  6277. for (j = 0; j < inputLength; ++j) {
  6278. currentValue = input[j];
  6279. if (currentValue < n && ++delta > maxInt) {
  6280. error('overflow');
  6281. }
  6282. if (currentValue == n) {
  6283. // Represent delta as a generalized variable-length integer
  6284. for (q = delta, k = base; /* no condition */; k += base) {
  6285. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  6286. if (q < t) {
  6287. break;
  6288. }
  6289. qMinusT = q - t;
  6290. baseMinusT = base - t;
  6291. output.push(
  6292. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  6293. );
  6294. q = floor(qMinusT / baseMinusT);
  6295. }
  6296. output.push(stringFromCharCode(digitToBasic(q, 0)));
  6297. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  6298. delta = 0;
  6299. ++handledCPCount;
  6300. }
  6301. }
  6302. ++delta;
  6303. ++n;
  6304. }
  6305. return output.join('');
  6306. }
  6307. /**
  6308. * Converts a Punycode string representing a domain name or an email address
  6309. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  6310. * it doesn't matter if you call it on a string that has already been
  6311. * converted to Unicode.
  6312. * @memberOf punycode
  6313. * @param {String} input The Punycoded domain name or email address to
  6314. * convert to Unicode.
  6315. * @returns {String} The Unicode representation of the given Punycode
  6316. * string.
  6317. */
  6318. function toUnicode(input) {
  6319. return mapDomain(input, function(string) {
  6320. return regexPunycode.test(string)
  6321. ? decode(string.slice(4).toLowerCase())
  6322. : string;
  6323. });
  6324. }
  6325. /**
  6326. * Converts a Unicode string representing a domain name or an email address to
  6327. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  6328. * i.e. it doesn't matter if you call it with a domain that's already in
  6329. * ASCII.
  6330. * @memberOf punycode
  6331. * @param {String} input The domain name or email address to convert, as a
  6332. * Unicode string.
  6333. * @returns {String} The Punycode representation of the given domain name or
  6334. * email address.
  6335. */
  6336. function toASCII(input) {
  6337. return mapDomain(input, function(string) {
  6338. return regexNonASCII.test(string)
  6339. ? 'xn--' + encode(string)
  6340. : string;
  6341. });
  6342. }
  6343. /*--------------------------------------------------------------------------*/
  6344. /** Define the public API */
  6345. punycode = {
  6346. /**
  6347. * A string representing the current Punycode.js version number.
  6348. * @memberOf punycode
  6349. * @type String
  6350. */
  6351. 'version': '1.4.1',
  6352. /**
  6353. * An object of methods to convert from JavaScript's internal character
  6354. * representation (UCS-2) to Unicode code points, and back.
  6355. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  6356. * @memberOf punycode
  6357. * @type Object
  6358. */
  6359. 'ucs2': {
  6360. 'decode': ucs2decode,
  6361. 'encode': ucs2encode
  6362. },
  6363. 'decode': decode,
  6364. 'encode': encode,
  6365. 'toASCII': toASCII,
  6366. 'toUnicode': toUnicode
  6367. };
  6368. /** Expose `punycode` */
  6369. // Some AMD build optimizers, like r.js, check for specific condition patterns
  6370. // like the following:
  6371. if (
  6372. typeof define == 'function' &&
  6373. typeof define.amd == 'object' &&
  6374. define.amd
  6375. ) {
  6376. define('punycode', function() {
  6377. return punycode;
  6378. });
  6379. } else if (freeExports && freeModule) {
  6380. if (module.exports == freeExports) {
  6381. // in Node.js, io.js, or RingoJS v0.8.0+
  6382. freeModule.exports = punycode;
  6383. } else {
  6384. // in Narwhal or RingoJS v0.7.0-
  6385. for (key in punycode) {
  6386. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  6387. }
  6388. }
  6389. } else {
  6390. // in Rhino or a web browser
  6391. root.punycode = punycode;
  6392. }
  6393. }(this));
  6394. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  6395. },{}],61:[function(require,module,exports){
  6396. module.exports=/[\0-\x1F\x7F-\x9F]/
  6397. },{}],62:[function(require,module,exports){
  6398. 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]/
  6399. },{}],63:[function(require,module,exports){
  6400. 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\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-\u2E44\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]|\uD807[\uDC41-\uDC45\uDC70\uDC71]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/
  6401. },{}],64:[function(require,module,exports){
  6402. module.exports=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/
  6403. },{}],65:[function(require,module,exports){
  6404. 'use strict';
  6405. exports.Any = require('./properties/Any/regex');
  6406. exports.Cc = require('./categories/Cc/regex');
  6407. exports.Cf = require('./categories/Cf/regex');
  6408. exports.P = require('./categories/P/regex');
  6409. exports.Z = require('./categories/Z/regex');
  6410. },{"./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){
  6411. module.exports=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/
  6412. },{}],67:[function(require,module,exports){
  6413. 'use strict';
  6414. module.exports = require('./lib/');
  6415. },{"./lib/":9}]},{},[67])(67)
  6416. });