markdown-it.js 270 KB

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