transform.js 173 KB

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