showdown.js 156 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157
  1. ;/*! showdown v 2.1.0 - 21-04-2022 */
  2. (function(){
  3. /**
  4. * Created by Tivie on 13-07-2015.
  5. */
  6. function getDefaultOpts (simple) {
  7. 'use strict';
  8. var defaultOptions = {
  9. omitExtraWLInCodeBlocks: {
  10. defaultValue: false,
  11. describe: 'Omit the default extra whiteline added to code blocks',
  12. type: 'boolean'
  13. },
  14. noHeaderId: {
  15. defaultValue: false,
  16. describe: 'Turn on/off generated header id',
  17. type: 'boolean'
  18. },
  19. prefixHeaderId: {
  20. defaultValue: false,
  21. describe: 'Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to true will add a generic \'section-\' prefix',
  22. type: 'string'
  23. },
  24. rawPrefixHeaderId: {
  25. defaultValue: false,
  26. describe: 'Setting this option to true will prevent showdown from modifying the prefix. This might result in malformed IDs (if, for instance, the " char is used in the prefix)',
  27. type: 'boolean'
  28. },
  29. ghCompatibleHeaderId: {
  30. defaultValue: false,
  31. describe: 'Generate header ids compatible with github style (spaces are replaced with dashes, a bunch of non alphanumeric chars are removed)',
  32. type: 'boolean'
  33. },
  34. rawHeaderId: {
  35. defaultValue: false,
  36. describe: 'Remove only spaces, \' and " from generated header ids (including prefixes), replacing them with dashes (-). WARNING: This might result in malformed ids',
  37. type: 'boolean'
  38. },
  39. headerLevelStart: {
  40. defaultValue: false,
  41. describe: 'The header blocks level start',
  42. type: 'integer'
  43. },
  44. parseImgDimensions: {
  45. defaultValue: false,
  46. describe: 'Turn on/off image dimension parsing',
  47. type: 'boolean'
  48. },
  49. simplifiedAutoLink: {
  50. defaultValue: false,
  51. describe: 'Turn on/off GFM autolink style',
  52. type: 'boolean'
  53. },
  54. excludeTrailingPunctuationFromURLs: {
  55. defaultValue: false,
  56. describe: 'Excludes trailing punctuation from links generated with autoLinking',
  57. type: 'boolean'
  58. },
  59. literalMidWordUnderscores: {
  60. defaultValue: false,
  61. describe: 'Parse midword underscores as literal underscores',
  62. type: 'boolean'
  63. },
  64. literalMidWordAsterisks: {
  65. defaultValue: false,
  66. describe: 'Parse midword asterisks as literal asterisks',
  67. type: 'boolean'
  68. },
  69. strikethrough: {
  70. defaultValue: false,
  71. describe: 'Turn on/off strikethrough support',
  72. type: 'boolean'
  73. },
  74. tables: {
  75. defaultValue: false,
  76. describe: 'Turn on/off tables support',
  77. type: 'boolean'
  78. },
  79. tablesHeaderId: {
  80. defaultValue: false,
  81. describe: 'Add an id to table headers',
  82. type: 'boolean'
  83. },
  84. ghCodeBlocks: {
  85. defaultValue: true,
  86. describe: 'Turn on/off GFM fenced code blocks support',
  87. type: 'boolean'
  88. },
  89. tasklists: {
  90. defaultValue: false,
  91. describe: 'Turn on/off GFM tasklist support',
  92. type: 'boolean'
  93. },
  94. smoothLivePreview: {
  95. defaultValue: false,
  96. describe: 'Prevents weird effects in live previews due to incomplete input',
  97. type: 'boolean'
  98. },
  99. smartIndentationFix: {
  100. defaultValue: false,
  101. describe: 'Tries to smartly fix indentation in es6 strings',
  102. type: 'boolean'
  103. },
  104. disableForced4SpacesIndentedSublists: {
  105. defaultValue: false,
  106. describe: 'Disables the requirement of indenting nested sublists by 4 spaces',
  107. type: 'boolean'
  108. },
  109. simpleLineBreaks: {
  110. defaultValue: false,
  111. describe: 'Parses simple line breaks as <br> (GFM Style)',
  112. type: 'boolean'
  113. },
  114. requireSpaceBeforeHeadingText: {
  115. defaultValue: false,
  116. describe: 'Makes adding a space between `#` and the header text mandatory (GFM Style)',
  117. type: 'boolean'
  118. },
  119. ghMentions: {
  120. defaultValue: false,
  121. describe: 'Enables github @mentions',
  122. type: 'boolean'
  123. },
  124. ghMentionsLink: {
  125. defaultValue: 'https://github.com/{u}',
  126. describe: 'Changes the link generated by @mentions. Only applies if ghMentions option is enabled.',
  127. type: 'string'
  128. },
  129. encodeEmails: {
  130. defaultValue: true,
  131. describe: 'Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities',
  132. type: 'boolean'
  133. },
  134. openLinksInNewWindow: {
  135. defaultValue: false,
  136. describe: 'Open all links in new windows',
  137. type: 'boolean'
  138. },
  139. backslashEscapesHTMLTags: {
  140. defaultValue: false,
  141. describe: 'Support for HTML Tag escaping. ex: \<div>foo\</div>',
  142. type: 'boolean'
  143. },
  144. emoji: {
  145. defaultValue: false,
  146. describe: 'Enable emoji support. Ex: `this is a :smile: emoji`',
  147. type: 'boolean'
  148. },
  149. underline: {
  150. defaultValue: false,
  151. describe: 'Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `<em>` and `<strong>`',
  152. type: 'boolean'
  153. },
  154. ellipsis: {
  155. defaultValue: true,
  156. describe: 'Replaces three dots with the ellipsis unicode character',
  157. type: 'boolean'
  158. },
  159. completeHTMLDocument: {
  160. defaultValue: false,
  161. describe: 'Outputs a complete html document, including `<html>`, `<head>` and `<body>` tags',
  162. type: 'boolean'
  163. },
  164. metadata: {
  165. defaultValue: false,
  166. describe: 'Enable support for document metadata (defined at the top of the document between `«««` and `»»»` or between `---` and `---`).',
  167. type: 'boolean'
  168. },
  169. splitAdjacentBlockquotes: {
  170. defaultValue: false,
  171. describe: 'Split adjacent blockquote blocks',
  172. type: 'boolean'
  173. }
  174. };
  175. if (simple === false) {
  176. return JSON.parse(JSON.stringify(defaultOptions));
  177. }
  178. var ret = {};
  179. for (var opt in defaultOptions) {
  180. if (defaultOptions.hasOwnProperty(opt)) {
  181. ret[opt] = defaultOptions[opt].defaultValue;
  182. }
  183. }
  184. return ret;
  185. }
  186. function allOptionsOn () {
  187. 'use strict';
  188. var options = getDefaultOpts(true),
  189. ret = {};
  190. for (var opt in options) {
  191. if (options.hasOwnProperty(opt)) {
  192. ret[opt] = true;
  193. }
  194. }
  195. return ret;
  196. }
  197. /**
  198. * Created by Tivie on 06-01-2015.
  199. */
  200. // Private properties
  201. var showdown = {},
  202. parsers = {},
  203. extensions = {},
  204. globalOptions = getDefaultOpts(true),
  205. setFlavor = 'vanilla',
  206. flavor = {
  207. github: {
  208. omitExtraWLInCodeBlocks: true,
  209. simplifiedAutoLink: true,
  210. excludeTrailingPunctuationFromURLs: true,
  211. literalMidWordUnderscores: true,
  212. strikethrough: true,
  213. tables: true,
  214. tablesHeaderId: true,
  215. ghCodeBlocks: true,
  216. tasklists: true,
  217. disableForced4SpacesIndentedSublists: true,
  218. simpleLineBreaks: true,
  219. requireSpaceBeforeHeadingText: true,
  220. ghCompatibleHeaderId: true,
  221. ghMentions: true,
  222. backslashEscapesHTMLTags: true,
  223. emoji: true,
  224. splitAdjacentBlockquotes: true
  225. },
  226. original: {
  227. noHeaderId: true,
  228. ghCodeBlocks: false
  229. },
  230. ghost: {
  231. omitExtraWLInCodeBlocks: true,
  232. parseImgDimensions: true,
  233. simplifiedAutoLink: true,
  234. excludeTrailingPunctuationFromURLs: true,
  235. literalMidWordUnderscores: true,
  236. strikethrough: true,
  237. tables: true,
  238. tablesHeaderId: true,
  239. ghCodeBlocks: true,
  240. tasklists: true,
  241. smoothLivePreview: true,
  242. simpleLineBreaks: true,
  243. requireSpaceBeforeHeadingText: true,
  244. ghMentions: false,
  245. encodeEmails: true
  246. },
  247. vanilla: getDefaultOpts(true),
  248. allOn: allOptionsOn()
  249. };
  250. /**
  251. * helper namespace
  252. * @type {{}}
  253. */
  254. showdown.helper = {};
  255. /**
  256. * TODO LEGACY SUPPORT CODE
  257. * @type {{}}
  258. */
  259. showdown.extensions = {};
  260. /**
  261. * Set a global option
  262. * @static
  263. * @param {string} key
  264. * @param {*} value
  265. * @returns {showdown}
  266. */
  267. showdown.setOption = function (key, value) {
  268. 'use strict';
  269. globalOptions[key] = value;
  270. return this;
  271. };
  272. /**
  273. * Get a global option
  274. * @static
  275. * @param {string} key
  276. * @returns {*}
  277. */
  278. showdown.getOption = function (key) {
  279. 'use strict';
  280. return globalOptions[key];
  281. };
  282. /**
  283. * Get the global options
  284. * @static
  285. * @returns {{}}
  286. */
  287. showdown.getOptions = function () {
  288. 'use strict';
  289. return globalOptions;
  290. };
  291. /**
  292. * Reset global options to the default values
  293. * @static
  294. */
  295. showdown.resetOptions = function () {
  296. 'use strict';
  297. globalOptions = getDefaultOpts(true);
  298. };
  299. /**
  300. * Set the flavor showdown should use as default
  301. * @param {string} name
  302. */
  303. showdown.setFlavor = function (name) {
  304. 'use strict';
  305. if (!flavor.hasOwnProperty(name)) {
  306. throw Error(name + ' flavor was not found');
  307. }
  308. showdown.resetOptions();
  309. var preset = flavor[name];
  310. setFlavor = name;
  311. for (var option in preset) {
  312. if (preset.hasOwnProperty(option)) {
  313. globalOptions[option] = preset[option];
  314. }
  315. }
  316. };
  317. /**
  318. * Get the currently set flavor
  319. * @returns {string}
  320. */
  321. showdown.getFlavor = function () {
  322. 'use strict';
  323. return setFlavor;
  324. };
  325. /**
  326. * Get the options of a specified flavor. Returns undefined if the flavor was not found
  327. * @param {string} name Name of the flavor
  328. * @returns {{}|undefined}
  329. */
  330. showdown.getFlavorOptions = function (name) {
  331. 'use strict';
  332. if (flavor.hasOwnProperty(name)) {
  333. return flavor[name];
  334. }
  335. };
  336. /**
  337. * Get the default options
  338. * @static
  339. * @param {boolean} [simple=true]
  340. * @returns {{}}
  341. */
  342. showdown.getDefaultOptions = function (simple) {
  343. 'use strict';
  344. return getDefaultOpts(simple);
  345. };
  346. /**
  347. * Get or set a subParser
  348. *
  349. * subParser(name) - Get a registered subParser
  350. * subParser(name, func) - Register a subParser
  351. * @static
  352. * @param {string} name
  353. * @param {function} [func]
  354. * @returns {*}
  355. */
  356. showdown.subParser = function (name, func) {
  357. 'use strict';
  358. if (showdown.helper.isString(name)) {
  359. if (typeof func !== 'undefined') {
  360. parsers[name] = func;
  361. } else {
  362. if (parsers.hasOwnProperty(name)) {
  363. return parsers[name];
  364. } else {
  365. throw Error('SubParser named ' + name + ' not registered!');
  366. }
  367. }
  368. }
  369. };
  370. /**
  371. * Gets or registers an extension
  372. * @static
  373. * @param {string} name
  374. * @param {object|object[]|function=} ext
  375. * @returns {*}
  376. */
  377. showdown.extension = function (name, ext) {
  378. 'use strict';
  379. if (!showdown.helper.isString(name)) {
  380. throw Error('Extension \'name\' must be a string');
  381. }
  382. name = showdown.helper.stdExtName(name);
  383. // Getter
  384. if (showdown.helper.isUndefined(ext)) {
  385. if (!extensions.hasOwnProperty(name)) {
  386. throw Error('Extension named ' + name + ' is not registered!');
  387. }
  388. return extensions[name];
  389. // Setter
  390. } else {
  391. // Expand extension if it's wrapped in a function
  392. if (typeof ext === 'function') {
  393. ext = ext();
  394. }
  395. // Ensure extension is an array
  396. if (!showdown.helper.isArray(ext)) {
  397. ext = [ext];
  398. }
  399. var validExtension = validate(ext, name);
  400. if (validExtension.valid) {
  401. extensions[name] = ext;
  402. } else {
  403. throw Error(validExtension.error);
  404. }
  405. }
  406. };
  407. /**
  408. * Gets all extensions registered
  409. * @returns {{}}
  410. */
  411. showdown.getAllExtensions = function () {
  412. 'use strict';
  413. return extensions;
  414. };
  415. /**
  416. * Remove an extension
  417. * @param {string} name
  418. */
  419. showdown.removeExtension = function (name) {
  420. 'use strict';
  421. delete extensions[name];
  422. };
  423. /**
  424. * Removes all extensions
  425. */
  426. showdown.resetExtensions = function () {
  427. 'use strict';
  428. extensions = {};
  429. };
  430. /**
  431. * Validate extension
  432. * @param {array} extension
  433. * @param {string} name
  434. * @returns {{valid: boolean, error: string}}
  435. */
  436. function validate (extension, name) {
  437. 'use strict';
  438. var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension',
  439. ret = {
  440. valid: true,
  441. error: ''
  442. };
  443. if (!showdown.helper.isArray(extension)) {
  444. extension = [extension];
  445. }
  446. for (var i = 0; i < extension.length; ++i) {
  447. var baseMsg = errMsg + ' sub-extension ' + i + ': ',
  448. ext = extension[i];
  449. if (typeof ext !== 'object') {
  450. ret.valid = false;
  451. ret.error = baseMsg + 'must be an object, but ' + typeof ext + ' given';
  452. return ret;
  453. }
  454. if (!showdown.helper.isString(ext.type)) {
  455. ret.valid = false;
  456. ret.error = baseMsg + 'property "type" must be a string, but ' + typeof ext.type + ' given';
  457. return ret;
  458. }
  459. var type = ext.type = ext.type.toLowerCase();
  460. // normalize extension type
  461. if (type === 'language') {
  462. type = ext.type = 'lang';
  463. }
  464. if (type === 'html') {
  465. type = ext.type = 'output';
  466. }
  467. if (type !== 'lang' && type !== 'output' && type !== 'listener') {
  468. ret.valid = false;
  469. ret.error = baseMsg + 'type ' + type + ' is not recognized. Valid values: "lang/language", "output/html" or "listener"';
  470. return ret;
  471. }
  472. if (type === 'listener') {
  473. if (showdown.helper.isUndefined(ext.listeners)) {
  474. ret.valid = false;
  475. ret.error = baseMsg + '. Extensions of type "listener" must have a property called "listeners"';
  476. return ret;
  477. }
  478. } else {
  479. if (showdown.helper.isUndefined(ext.filter) && showdown.helper.isUndefined(ext.regex)) {
  480. ret.valid = false;
  481. ret.error = baseMsg + type + ' extensions must define either a "regex" property or a "filter" method';
  482. return ret;
  483. }
  484. }
  485. if (ext.listeners) {
  486. if (typeof ext.listeners !== 'object') {
  487. ret.valid = false;
  488. ret.error = baseMsg + '"listeners" property must be an object but ' + typeof ext.listeners + ' given';
  489. return ret;
  490. }
  491. for (var ln in ext.listeners) {
  492. if (ext.listeners.hasOwnProperty(ln)) {
  493. if (typeof ext.listeners[ln] !== 'function') {
  494. ret.valid = false;
  495. ret.error = baseMsg + '"listeners" property must be an hash of [event name]: [callback]. listeners.' + ln +
  496. ' must be a function but ' + typeof ext.listeners[ln] + ' given';
  497. return ret;
  498. }
  499. }
  500. }
  501. }
  502. if (ext.filter) {
  503. if (typeof ext.filter !== 'function') {
  504. ret.valid = false;
  505. ret.error = baseMsg + '"filter" must be a function, but ' + typeof ext.filter + ' given';
  506. return ret;
  507. }
  508. } else if (ext.regex) {
  509. if (showdown.helper.isString(ext.regex)) {
  510. ext.regex = new RegExp(ext.regex, 'g');
  511. }
  512. if (!(ext.regex instanceof RegExp)) {
  513. ret.valid = false;
  514. ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given';
  515. return ret;
  516. }
  517. if (showdown.helper.isUndefined(ext.replace)) {
  518. ret.valid = false;
  519. ret.error = baseMsg + '"regex" extensions must implement a replace string or function';
  520. return ret;
  521. }
  522. }
  523. }
  524. return ret;
  525. }
  526. /**
  527. * Validate extension
  528. * @param {object} ext
  529. * @returns {boolean}
  530. */
  531. showdown.validateExtension = function (ext) {
  532. 'use strict';
  533. var validateExtension = validate(ext, null);
  534. if (!validateExtension.valid) {
  535. console.warn(validateExtension.error);
  536. return false;
  537. }
  538. return true;
  539. };
  540. /**
  541. * showdownjs helper functions
  542. */
  543. if (!showdown.hasOwnProperty('helper')) {
  544. showdown.helper = {};
  545. }
  546. /**
  547. * Check if var is string
  548. * @static
  549. * @param {string} a
  550. * @returns {boolean}
  551. */
  552. showdown.helper.isString = function (a) {
  553. 'use strict';
  554. return (typeof a === 'string' || a instanceof String);
  555. };
  556. /**
  557. * Check if var is a function
  558. * @static
  559. * @param {*} a
  560. * @returns {boolean}
  561. */
  562. showdown.helper.isFunction = function (a) {
  563. 'use strict';
  564. var getType = {};
  565. return a && getType.toString.call(a) === '[object Function]';
  566. };
  567. /**
  568. * isArray helper function
  569. * @static
  570. * @param {*} a
  571. * @returns {boolean}
  572. */
  573. showdown.helper.isArray = function (a) {
  574. 'use strict';
  575. return Array.isArray(a);
  576. };
  577. /**
  578. * Check if value is undefined
  579. * @static
  580. * @param {*} value The value to check.
  581. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  582. */
  583. showdown.helper.isUndefined = function (value) {
  584. 'use strict';
  585. return typeof value === 'undefined';
  586. };
  587. /**
  588. * ForEach helper function
  589. * Iterates over Arrays and Objects (own properties only)
  590. * @static
  591. * @param {*} obj
  592. * @param {function} callback Accepts 3 params: 1. value, 2. key, 3. the original array/object
  593. */
  594. showdown.helper.forEach = function (obj, callback) {
  595. 'use strict';
  596. // check if obj is defined
  597. if (showdown.helper.isUndefined(obj)) {
  598. throw new Error('obj param is required');
  599. }
  600. if (showdown.helper.isUndefined(callback)) {
  601. throw new Error('callback param is required');
  602. }
  603. if (!showdown.helper.isFunction(callback)) {
  604. throw new Error('callback param must be a function/closure');
  605. }
  606. if (typeof obj.forEach === 'function') {
  607. obj.forEach(callback);
  608. } else if (showdown.helper.isArray(obj)) {
  609. for (var i = 0; i < obj.length; i++) {
  610. callback(obj[i], i, obj);
  611. }
  612. } else if (typeof (obj) === 'object') {
  613. for (var prop in obj) {
  614. if (obj.hasOwnProperty(prop)) {
  615. callback(obj[prop], prop, obj);
  616. }
  617. }
  618. } else {
  619. throw new Error('obj does not seem to be an array or an iterable object');
  620. }
  621. };
  622. /**
  623. * Standardidize extension name
  624. * @static
  625. * @param {string} s extension name
  626. * @returns {string}
  627. */
  628. showdown.helper.stdExtName = function (s) {
  629. 'use strict';
  630. return s.replace(/[_?*+\/\\.^-]/g, '').replace(/\s/g, '').toLowerCase();
  631. };
  632. function escapeCharactersCallback (wholeMatch, m1) {
  633. 'use strict';
  634. var charCodeToEscape = m1.charCodeAt(0);
  635. return '¨E' + charCodeToEscape + 'E';
  636. }
  637. /**
  638. * Callback used to escape characters when passing through String.replace
  639. * @static
  640. * @param {string} wholeMatch
  641. * @param {string} m1
  642. * @returns {string}
  643. */
  644. showdown.helper.escapeCharactersCallback = escapeCharactersCallback;
  645. /**
  646. * Escape characters in a string
  647. * @static
  648. * @param {string} text
  649. * @param {string} charsToEscape
  650. * @param {boolean} afterBackslash
  651. * @returns {XML|string|void|*}
  652. */
  653. showdown.helper.escapeCharacters = function (text, charsToEscape, afterBackslash) {
  654. 'use strict';
  655. // First we have to escape the escape characters so that
  656. // we can build a character class out of them
  657. var regexString = '([' + charsToEscape.replace(/([\[\]\\])/g, '\\$1') + '])';
  658. if (afterBackslash) {
  659. regexString = '\\\\' + regexString;
  660. }
  661. var regex = new RegExp(regexString, 'g');
  662. text = text.replace(regex, escapeCharactersCallback);
  663. return text;
  664. };
  665. /**
  666. * Unescape HTML entities
  667. * @param txt
  668. * @returns {string}
  669. */
  670. showdown.helper.unescapeHTMLEntities = function (txt) {
  671. 'use strict';
  672. return txt
  673. .replace(/&quot;/g, '"')
  674. .replace(/&lt;/g, '<')
  675. .replace(/&gt;/g, '>')
  676. .replace(/&amp;/g, '&');
  677. };
  678. var rgxFindMatchPos = function (str, left, right, flags) {
  679. 'use strict';
  680. var f = flags || '',
  681. g = f.indexOf('g') > -1,
  682. x = new RegExp(left + '|' + right, 'g' + f.replace(/g/g, '')),
  683. l = new RegExp(left, f.replace(/g/g, '')),
  684. pos = [],
  685. t, s, m, start, end;
  686. do {
  687. t = 0;
  688. while ((m = x.exec(str))) {
  689. if (l.test(m[0])) {
  690. if (!(t++)) {
  691. s = x.lastIndex;
  692. start = s - m[0].length;
  693. }
  694. } else if (t) {
  695. if (!--t) {
  696. end = m.index + m[0].length;
  697. var obj = {
  698. left: {start: start, end: s},
  699. match: {start: s, end: m.index},
  700. right: {start: m.index, end: end},
  701. wholeMatch: {start: start, end: end}
  702. };
  703. pos.push(obj);
  704. if (!g) {
  705. return pos;
  706. }
  707. }
  708. }
  709. }
  710. } while (t && (x.lastIndex = s));
  711. return pos;
  712. };
  713. /**
  714. * matchRecursiveRegExp
  715. *
  716. * (c) 2007 Steven Levithan <stevenlevithan.com>
  717. * MIT License
  718. *
  719. * Accepts a string to search, a left and right format delimiter
  720. * as regex patterns, and optional regex flags. Returns an array
  721. * of matches, allowing nested instances of left/right delimiters.
  722. * Use the "g" flag to return all matches, otherwise only the
  723. * first is returned. Be careful to ensure that the left and
  724. * right format delimiters produce mutually exclusive matches.
  725. * Backreferences are not supported within the right delimiter
  726. * due to how it is internally combined with the left delimiter.
  727. * When matching strings whose format delimiters are unbalanced
  728. * to the left or right, the output is intentionally as a
  729. * conventional regex library with recursion support would
  730. * produce, e.g. "<<x>" and "<x>>" both produce ["x"] when using
  731. * "<" and ">" as the delimiters (both strings contain a single,
  732. * balanced instance of "<x>").
  733. *
  734. * examples:
  735. * matchRecursiveRegExp("test", "\\(", "\\)")
  736. * returns: []
  737. * matchRecursiveRegExp("<t<<e>><s>>t<>", "<", ">", "g")
  738. * returns: ["t<<e>><s>", ""]
  739. * matchRecursiveRegExp("<div id=\"x\">test</div>", "<div\\b[^>]*>", "</div>", "gi")
  740. * returns: ["test"]
  741. */
  742. showdown.helper.matchRecursiveRegExp = function (str, left, right, flags) {
  743. 'use strict';
  744. var matchPos = rgxFindMatchPos (str, left, right, flags),
  745. results = [];
  746. for (var i = 0; i < matchPos.length; ++i) {
  747. results.push([
  748. str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end),
  749. str.slice(matchPos[i].match.start, matchPos[i].match.end),
  750. str.slice(matchPos[i].left.start, matchPos[i].left.end),
  751. str.slice(matchPos[i].right.start, matchPos[i].right.end)
  752. ]);
  753. }
  754. return results;
  755. };
  756. /**
  757. *
  758. * @param {string} str
  759. * @param {string|function} replacement
  760. * @param {string} left
  761. * @param {string} right
  762. * @param {string} flags
  763. * @returns {string}
  764. */
  765. showdown.helper.replaceRecursiveRegExp = function (str, replacement, left, right, flags) {
  766. 'use strict';
  767. if (!showdown.helper.isFunction(replacement)) {
  768. var repStr = replacement;
  769. replacement = function () {
  770. return repStr;
  771. };
  772. }
  773. var matchPos = rgxFindMatchPos(str, left, right, flags),
  774. finalStr = str,
  775. lng = matchPos.length;
  776. if (lng > 0) {
  777. var bits = [];
  778. if (matchPos[0].wholeMatch.start !== 0) {
  779. bits.push(str.slice(0, matchPos[0].wholeMatch.start));
  780. }
  781. for (var i = 0; i < lng; ++i) {
  782. bits.push(
  783. replacement(
  784. str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end),
  785. str.slice(matchPos[i].match.start, matchPos[i].match.end),
  786. str.slice(matchPos[i].left.start, matchPos[i].left.end),
  787. str.slice(matchPos[i].right.start, matchPos[i].right.end)
  788. )
  789. );
  790. if (i < lng - 1) {
  791. bits.push(str.slice(matchPos[i].wholeMatch.end, matchPos[i + 1].wholeMatch.start));
  792. }
  793. }
  794. if (matchPos[lng - 1].wholeMatch.end < str.length) {
  795. bits.push(str.slice(matchPos[lng - 1].wholeMatch.end));
  796. }
  797. finalStr = bits.join('');
  798. }
  799. return finalStr;
  800. };
  801. /**
  802. * Returns the index within the passed String object of the first occurrence of the specified regex,
  803. * starting the search at fromIndex. Returns -1 if the value is not found.
  804. *
  805. * @param {string} str string to search
  806. * @param {RegExp} regex Regular expression to search
  807. * @param {int} [fromIndex = 0] Index to start the search
  808. * @returns {Number}
  809. * @throws InvalidArgumentError
  810. */
  811. showdown.helper.regexIndexOf = function (str, regex, fromIndex) {
  812. 'use strict';
  813. if (!showdown.helper.isString(str)) {
  814. throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string';
  815. }
  816. if (regex instanceof RegExp === false) {
  817. throw 'InvalidArgumentError: second parameter of showdown.helper.regexIndexOf function must be an instance of RegExp';
  818. }
  819. var indexOf = str.substring(fromIndex || 0).search(regex);
  820. return (indexOf >= 0) ? (indexOf + (fromIndex || 0)) : indexOf;
  821. };
  822. /**
  823. * Splits the passed string object at the defined index, and returns an array composed of the two substrings
  824. * @param {string} str string to split
  825. * @param {int} index index to split string at
  826. * @returns {[string,string]}
  827. * @throws InvalidArgumentError
  828. */
  829. showdown.helper.splitAtIndex = function (str, index) {
  830. 'use strict';
  831. if (!showdown.helper.isString(str)) {
  832. throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string';
  833. }
  834. return [str.substring(0, index), str.substring(index)];
  835. };
  836. /**
  837. * Obfuscate an e-mail address through the use of Character Entities,
  838. * transforming ASCII characters into their equivalent decimal or hex entities.
  839. *
  840. * Since it has a random component, subsequent calls to this function produce different results
  841. *
  842. * @param {string} mail
  843. * @returns {string}
  844. */
  845. showdown.helper.encodeEmailAddress = function (mail) {
  846. 'use strict';
  847. var encode = [
  848. function (ch) {
  849. return '&#' + ch.charCodeAt(0) + ';';
  850. },
  851. function (ch) {
  852. return '&#x' + ch.charCodeAt(0).toString(16) + ';';
  853. },
  854. function (ch) {
  855. return ch;
  856. }
  857. ];
  858. mail = mail.replace(/./g, function (ch) {
  859. if (ch === '@') {
  860. // this *must* be encoded. I insist.
  861. ch = encode[Math.floor(Math.random() * 2)](ch);
  862. } else {
  863. var r = Math.random();
  864. // roughly 10% raw, 45% hex, 45% dec
  865. ch = (
  866. r > 0.9 ? encode[2](ch) : r > 0.45 ? encode[1](ch) : encode[0](ch)
  867. );
  868. }
  869. return ch;
  870. });
  871. return mail;
  872. };
  873. /**
  874. *
  875. * @param str
  876. * @param targetLength
  877. * @param padString
  878. * @returns {string}
  879. */
  880. showdown.helper.padEnd = function padEnd (str, targetLength, padString) {
  881. 'use strict';
  882. /*jshint bitwise: false*/
  883. // eslint-disable-next-line space-infix-ops
  884. targetLength = targetLength>>0; //floor if number or convert non-number to 0;
  885. /*jshint bitwise: true*/
  886. padString = String(padString || ' ');
  887. if (str.length > targetLength) {
  888. return String(str);
  889. } else {
  890. targetLength = targetLength - str.length;
  891. if (targetLength > padString.length) {
  892. padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed
  893. }
  894. return String(str) + padString.slice(0,targetLength);
  895. }
  896. };
  897. /**
  898. * POLYFILLS
  899. */
  900. // use this instead of builtin is undefined for IE8 compatibility
  901. if (typeof (console) === 'undefined') {
  902. console = {
  903. warn: function (msg) {
  904. 'use strict';
  905. alert(msg);
  906. },
  907. log: function (msg) {
  908. 'use strict';
  909. alert(msg);
  910. },
  911. error: function (msg) {
  912. 'use strict';
  913. throw msg;
  914. }
  915. };
  916. }
  917. /**
  918. * Common regexes.
  919. * We declare some common regexes to improve performance
  920. */
  921. showdown.helper.regexes = {
  922. asteriskDashAndColon: /([*_:~])/g
  923. };
  924. /**
  925. * EMOJIS LIST
  926. */
  927. showdown.helper.emojis = {
  928. '+1':'\ud83d\udc4d',
  929. '-1':'\ud83d\udc4e',
  930. '100':'\ud83d\udcaf',
  931. '1234':'\ud83d\udd22',
  932. '1st_place_medal':'\ud83e\udd47',
  933. '2nd_place_medal':'\ud83e\udd48',
  934. '3rd_place_medal':'\ud83e\udd49',
  935. '8ball':'\ud83c\udfb1',
  936. 'a':'\ud83c\udd70\ufe0f',
  937. 'ab':'\ud83c\udd8e',
  938. 'abc':'\ud83d\udd24',
  939. 'abcd':'\ud83d\udd21',
  940. 'accept':'\ud83c\ude51',
  941. 'aerial_tramway':'\ud83d\udea1',
  942. 'airplane':'\u2708\ufe0f',
  943. 'alarm_clock':'\u23f0',
  944. 'alembic':'\u2697\ufe0f',
  945. 'alien':'\ud83d\udc7d',
  946. 'ambulance':'\ud83d\ude91',
  947. 'amphora':'\ud83c\udffa',
  948. 'anchor':'\u2693\ufe0f',
  949. 'angel':'\ud83d\udc7c',
  950. 'anger':'\ud83d\udca2',
  951. 'angry':'\ud83d\ude20',
  952. 'anguished':'\ud83d\ude27',
  953. 'ant':'\ud83d\udc1c',
  954. 'apple':'\ud83c\udf4e',
  955. 'aquarius':'\u2652\ufe0f',
  956. 'aries':'\u2648\ufe0f',
  957. 'arrow_backward':'\u25c0\ufe0f',
  958. 'arrow_double_down':'\u23ec',
  959. 'arrow_double_up':'\u23eb',
  960. 'arrow_down':'\u2b07\ufe0f',
  961. 'arrow_down_small':'\ud83d\udd3d',
  962. 'arrow_forward':'\u25b6\ufe0f',
  963. 'arrow_heading_down':'\u2935\ufe0f',
  964. 'arrow_heading_up':'\u2934\ufe0f',
  965. 'arrow_left':'\u2b05\ufe0f',
  966. 'arrow_lower_left':'\u2199\ufe0f',
  967. 'arrow_lower_right':'\u2198\ufe0f',
  968. 'arrow_right':'\u27a1\ufe0f',
  969. 'arrow_right_hook':'\u21aa\ufe0f',
  970. 'arrow_up':'\u2b06\ufe0f',
  971. 'arrow_up_down':'\u2195\ufe0f',
  972. 'arrow_up_small':'\ud83d\udd3c',
  973. 'arrow_upper_left':'\u2196\ufe0f',
  974. 'arrow_upper_right':'\u2197\ufe0f',
  975. 'arrows_clockwise':'\ud83d\udd03',
  976. 'arrows_counterclockwise':'\ud83d\udd04',
  977. 'art':'\ud83c\udfa8',
  978. 'articulated_lorry':'\ud83d\ude9b',
  979. 'artificial_satellite':'\ud83d\udef0',
  980. 'astonished':'\ud83d\ude32',
  981. 'athletic_shoe':'\ud83d\udc5f',
  982. 'atm':'\ud83c\udfe7',
  983. 'atom_symbol':'\u269b\ufe0f',
  984. 'avocado':'\ud83e\udd51',
  985. 'b':'\ud83c\udd71\ufe0f',
  986. 'baby':'\ud83d\udc76',
  987. 'baby_bottle':'\ud83c\udf7c',
  988. 'baby_chick':'\ud83d\udc24',
  989. 'baby_symbol':'\ud83d\udebc',
  990. 'back':'\ud83d\udd19',
  991. 'bacon':'\ud83e\udd53',
  992. 'badminton':'\ud83c\udff8',
  993. 'baggage_claim':'\ud83d\udec4',
  994. 'baguette_bread':'\ud83e\udd56',
  995. 'balance_scale':'\u2696\ufe0f',
  996. 'balloon':'\ud83c\udf88',
  997. 'ballot_box':'\ud83d\uddf3',
  998. 'ballot_box_with_check':'\u2611\ufe0f',
  999. 'bamboo':'\ud83c\udf8d',
  1000. 'banana':'\ud83c\udf4c',
  1001. 'bangbang':'\u203c\ufe0f',
  1002. 'bank':'\ud83c\udfe6',
  1003. 'bar_chart':'\ud83d\udcca',
  1004. 'barber':'\ud83d\udc88',
  1005. 'baseball':'\u26be\ufe0f',
  1006. 'basketball':'\ud83c\udfc0',
  1007. 'basketball_man':'\u26f9\ufe0f',
  1008. 'basketball_woman':'\u26f9\ufe0f&zwj;\u2640\ufe0f',
  1009. 'bat':'\ud83e\udd87',
  1010. 'bath':'\ud83d\udec0',
  1011. 'bathtub':'\ud83d\udec1',
  1012. 'battery':'\ud83d\udd0b',
  1013. 'beach_umbrella':'\ud83c\udfd6',
  1014. 'bear':'\ud83d\udc3b',
  1015. 'bed':'\ud83d\udecf',
  1016. 'bee':'\ud83d\udc1d',
  1017. 'beer':'\ud83c\udf7a',
  1018. 'beers':'\ud83c\udf7b',
  1019. 'beetle':'\ud83d\udc1e',
  1020. 'beginner':'\ud83d\udd30',
  1021. 'bell':'\ud83d\udd14',
  1022. 'bellhop_bell':'\ud83d\udece',
  1023. 'bento':'\ud83c\udf71',
  1024. 'biking_man':'\ud83d\udeb4',
  1025. 'bike':'\ud83d\udeb2',
  1026. 'biking_woman':'\ud83d\udeb4&zwj;\u2640\ufe0f',
  1027. 'bikini':'\ud83d\udc59',
  1028. 'biohazard':'\u2623\ufe0f',
  1029. 'bird':'\ud83d\udc26',
  1030. 'birthday':'\ud83c\udf82',
  1031. 'black_circle':'\u26ab\ufe0f',
  1032. 'black_flag':'\ud83c\udff4',
  1033. 'black_heart':'\ud83d\udda4',
  1034. 'black_joker':'\ud83c\udccf',
  1035. 'black_large_square':'\u2b1b\ufe0f',
  1036. 'black_medium_small_square':'\u25fe\ufe0f',
  1037. 'black_medium_square':'\u25fc\ufe0f',
  1038. 'black_nib':'\u2712\ufe0f',
  1039. 'black_small_square':'\u25aa\ufe0f',
  1040. 'black_square_button':'\ud83d\udd32',
  1041. 'blonde_man':'\ud83d\udc71',
  1042. 'blonde_woman':'\ud83d\udc71&zwj;\u2640\ufe0f',
  1043. 'blossom':'\ud83c\udf3c',
  1044. 'blowfish':'\ud83d\udc21',
  1045. 'blue_book':'\ud83d\udcd8',
  1046. 'blue_car':'\ud83d\ude99',
  1047. 'blue_heart':'\ud83d\udc99',
  1048. 'blush':'\ud83d\ude0a',
  1049. 'boar':'\ud83d\udc17',
  1050. 'boat':'\u26f5\ufe0f',
  1051. 'bomb':'\ud83d\udca3',
  1052. 'book':'\ud83d\udcd6',
  1053. 'bookmark':'\ud83d\udd16',
  1054. 'bookmark_tabs':'\ud83d\udcd1',
  1055. 'books':'\ud83d\udcda',
  1056. 'boom':'\ud83d\udca5',
  1057. 'boot':'\ud83d\udc62',
  1058. 'bouquet':'\ud83d\udc90',
  1059. 'bowing_man':'\ud83d\ude47',
  1060. 'bow_and_arrow':'\ud83c\udff9',
  1061. 'bowing_woman':'\ud83d\ude47&zwj;\u2640\ufe0f',
  1062. 'bowling':'\ud83c\udfb3',
  1063. 'boxing_glove':'\ud83e\udd4a',
  1064. 'boy':'\ud83d\udc66',
  1065. 'bread':'\ud83c\udf5e',
  1066. 'bride_with_veil':'\ud83d\udc70',
  1067. 'bridge_at_night':'\ud83c\udf09',
  1068. 'briefcase':'\ud83d\udcbc',
  1069. 'broken_heart':'\ud83d\udc94',
  1070. 'bug':'\ud83d\udc1b',
  1071. 'building_construction':'\ud83c\udfd7',
  1072. 'bulb':'\ud83d\udca1',
  1073. 'bullettrain_front':'\ud83d\ude85',
  1074. 'bullettrain_side':'\ud83d\ude84',
  1075. 'burrito':'\ud83c\udf2f',
  1076. 'bus':'\ud83d\ude8c',
  1077. 'business_suit_levitating':'\ud83d\udd74',
  1078. 'busstop':'\ud83d\ude8f',
  1079. 'bust_in_silhouette':'\ud83d\udc64',
  1080. 'busts_in_silhouette':'\ud83d\udc65',
  1081. 'butterfly':'\ud83e\udd8b',
  1082. 'cactus':'\ud83c\udf35',
  1083. 'cake':'\ud83c\udf70',
  1084. 'calendar':'\ud83d\udcc6',
  1085. 'call_me_hand':'\ud83e\udd19',
  1086. 'calling':'\ud83d\udcf2',
  1087. 'camel':'\ud83d\udc2b',
  1088. 'camera':'\ud83d\udcf7',
  1089. 'camera_flash':'\ud83d\udcf8',
  1090. 'camping':'\ud83c\udfd5',
  1091. 'cancer':'\u264b\ufe0f',
  1092. 'candle':'\ud83d\udd6f',
  1093. 'candy':'\ud83c\udf6c',
  1094. 'canoe':'\ud83d\udef6',
  1095. 'capital_abcd':'\ud83d\udd20',
  1096. 'capricorn':'\u2651\ufe0f',
  1097. 'car':'\ud83d\ude97',
  1098. 'card_file_box':'\ud83d\uddc3',
  1099. 'card_index':'\ud83d\udcc7',
  1100. 'card_index_dividers':'\ud83d\uddc2',
  1101. 'carousel_horse':'\ud83c\udfa0',
  1102. 'carrot':'\ud83e\udd55',
  1103. 'cat':'\ud83d\udc31',
  1104. 'cat2':'\ud83d\udc08',
  1105. 'cd':'\ud83d\udcbf',
  1106. 'chains':'\u26d3',
  1107. 'champagne':'\ud83c\udf7e',
  1108. 'chart':'\ud83d\udcb9',
  1109. 'chart_with_downwards_trend':'\ud83d\udcc9',
  1110. 'chart_with_upwards_trend':'\ud83d\udcc8',
  1111. 'checkered_flag':'\ud83c\udfc1',
  1112. 'cheese':'\ud83e\uddc0',
  1113. 'cherries':'\ud83c\udf52',
  1114. 'cherry_blossom':'\ud83c\udf38',
  1115. 'chestnut':'\ud83c\udf30',
  1116. 'chicken':'\ud83d\udc14',
  1117. 'children_crossing':'\ud83d\udeb8',
  1118. 'chipmunk':'\ud83d\udc3f',
  1119. 'chocolate_bar':'\ud83c\udf6b',
  1120. 'christmas_tree':'\ud83c\udf84',
  1121. 'church':'\u26ea\ufe0f',
  1122. 'cinema':'\ud83c\udfa6',
  1123. 'circus_tent':'\ud83c\udfaa',
  1124. 'city_sunrise':'\ud83c\udf07',
  1125. 'city_sunset':'\ud83c\udf06',
  1126. 'cityscape':'\ud83c\udfd9',
  1127. 'cl':'\ud83c\udd91',
  1128. 'clamp':'\ud83d\udddc',
  1129. 'clap':'\ud83d\udc4f',
  1130. 'clapper':'\ud83c\udfac',
  1131. 'classical_building':'\ud83c\udfdb',
  1132. 'clinking_glasses':'\ud83e\udd42',
  1133. 'clipboard':'\ud83d\udccb',
  1134. 'clock1':'\ud83d\udd50',
  1135. 'clock10':'\ud83d\udd59',
  1136. 'clock1030':'\ud83d\udd65',
  1137. 'clock11':'\ud83d\udd5a',
  1138. 'clock1130':'\ud83d\udd66',
  1139. 'clock12':'\ud83d\udd5b',
  1140. 'clock1230':'\ud83d\udd67',
  1141. 'clock130':'\ud83d\udd5c',
  1142. 'clock2':'\ud83d\udd51',
  1143. 'clock230':'\ud83d\udd5d',
  1144. 'clock3':'\ud83d\udd52',
  1145. 'clock330':'\ud83d\udd5e',
  1146. 'clock4':'\ud83d\udd53',
  1147. 'clock430':'\ud83d\udd5f',
  1148. 'clock5':'\ud83d\udd54',
  1149. 'clock530':'\ud83d\udd60',
  1150. 'clock6':'\ud83d\udd55',
  1151. 'clock630':'\ud83d\udd61',
  1152. 'clock7':'\ud83d\udd56',
  1153. 'clock730':'\ud83d\udd62',
  1154. 'clock8':'\ud83d\udd57',
  1155. 'clock830':'\ud83d\udd63',
  1156. 'clock9':'\ud83d\udd58',
  1157. 'clock930':'\ud83d\udd64',
  1158. 'closed_book':'\ud83d\udcd5',
  1159. 'closed_lock_with_key':'\ud83d\udd10',
  1160. 'closed_umbrella':'\ud83c\udf02',
  1161. 'cloud':'\u2601\ufe0f',
  1162. 'cloud_with_lightning':'\ud83c\udf29',
  1163. 'cloud_with_lightning_and_rain':'\u26c8',
  1164. 'cloud_with_rain':'\ud83c\udf27',
  1165. 'cloud_with_snow':'\ud83c\udf28',
  1166. 'clown_face':'\ud83e\udd21',
  1167. 'clubs':'\u2663\ufe0f',
  1168. 'cocktail':'\ud83c\udf78',
  1169. 'coffee':'\u2615\ufe0f',
  1170. 'coffin':'\u26b0\ufe0f',
  1171. 'cold_sweat':'\ud83d\ude30',
  1172. 'comet':'\u2604\ufe0f',
  1173. 'computer':'\ud83d\udcbb',
  1174. 'computer_mouse':'\ud83d\uddb1',
  1175. 'confetti_ball':'\ud83c\udf8a',
  1176. 'confounded':'\ud83d\ude16',
  1177. 'confused':'\ud83d\ude15',
  1178. 'congratulations':'\u3297\ufe0f',
  1179. 'construction':'\ud83d\udea7',
  1180. 'construction_worker_man':'\ud83d\udc77',
  1181. 'construction_worker_woman':'\ud83d\udc77&zwj;\u2640\ufe0f',
  1182. 'control_knobs':'\ud83c\udf9b',
  1183. 'convenience_store':'\ud83c\udfea',
  1184. 'cookie':'\ud83c\udf6a',
  1185. 'cool':'\ud83c\udd92',
  1186. 'policeman':'\ud83d\udc6e',
  1187. 'copyright':'\u00a9\ufe0f',
  1188. 'corn':'\ud83c\udf3d',
  1189. 'couch_and_lamp':'\ud83d\udecb',
  1190. 'couple':'\ud83d\udc6b',
  1191. 'couple_with_heart_woman_man':'\ud83d\udc91',
  1192. 'couple_with_heart_man_man':'\ud83d\udc68&zwj;\u2764\ufe0f&zwj;\ud83d\udc68',
  1193. 'couple_with_heart_woman_woman':'\ud83d\udc69&zwj;\u2764\ufe0f&zwj;\ud83d\udc69',
  1194. 'couplekiss_man_man':'\ud83d\udc68&zwj;\u2764\ufe0f&zwj;\ud83d\udc8b&zwj;\ud83d\udc68',
  1195. 'couplekiss_man_woman':'\ud83d\udc8f',
  1196. 'couplekiss_woman_woman':'\ud83d\udc69&zwj;\u2764\ufe0f&zwj;\ud83d\udc8b&zwj;\ud83d\udc69',
  1197. 'cow':'\ud83d\udc2e',
  1198. 'cow2':'\ud83d\udc04',
  1199. 'cowboy_hat_face':'\ud83e\udd20',
  1200. 'crab':'\ud83e\udd80',
  1201. 'crayon':'\ud83d\udd8d',
  1202. 'credit_card':'\ud83d\udcb3',
  1203. 'crescent_moon':'\ud83c\udf19',
  1204. 'cricket':'\ud83c\udfcf',
  1205. 'crocodile':'\ud83d\udc0a',
  1206. 'croissant':'\ud83e\udd50',
  1207. 'crossed_fingers':'\ud83e\udd1e',
  1208. 'crossed_flags':'\ud83c\udf8c',
  1209. 'crossed_swords':'\u2694\ufe0f',
  1210. 'crown':'\ud83d\udc51',
  1211. 'cry':'\ud83d\ude22',
  1212. 'crying_cat_face':'\ud83d\ude3f',
  1213. 'crystal_ball':'\ud83d\udd2e',
  1214. 'cucumber':'\ud83e\udd52',
  1215. 'cupid':'\ud83d\udc98',
  1216. 'curly_loop':'\u27b0',
  1217. 'currency_exchange':'\ud83d\udcb1',
  1218. 'curry':'\ud83c\udf5b',
  1219. 'custard':'\ud83c\udf6e',
  1220. 'customs':'\ud83d\udec3',
  1221. 'cyclone':'\ud83c\udf00',
  1222. 'dagger':'\ud83d\udde1',
  1223. 'dancer':'\ud83d\udc83',
  1224. 'dancing_women':'\ud83d\udc6f',
  1225. 'dancing_men':'\ud83d\udc6f&zwj;\u2642\ufe0f',
  1226. 'dango':'\ud83c\udf61',
  1227. 'dark_sunglasses':'\ud83d\udd76',
  1228. 'dart':'\ud83c\udfaf',
  1229. 'dash':'\ud83d\udca8',
  1230. 'date':'\ud83d\udcc5',
  1231. 'deciduous_tree':'\ud83c\udf33',
  1232. 'deer':'\ud83e\udd8c',
  1233. 'department_store':'\ud83c\udfec',
  1234. 'derelict_house':'\ud83c\udfda',
  1235. 'desert':'\ud83c\udfdc',
  1236. 'desert_island':'\ud83c\udfdd',
  1237. 'desktop_computer':'\ud83d\udda5',
  1238. 'male_detective':'\ud83d\udd75\ufe0f',
  1239. 'diamond_shape_with_a_dot_inside':'\ud83d\udca0',
  1240. 'diamonds':'\u2666\ufe0f',
  1241. 'disappointed':'\ud83d\ude1e',
  1242. 'disappointed_relieved':'\ud83d\ude25',
  1243. 'dizzy':'\ud83d\udcab',
  1244. 'dizzy_face':'\ud83d\ude35',
  1245. 'do_not_litter':'\ud83d\udeaf',
  1246. 'dog':'\ud83d\udc36',
  1247. 'dog2':'\ud83d\udc15',
  1248. 'dollar':'\ud83d\udcb5',
  1249. 'dolls':'\ud83c\udf8e',
  1250. 'dolphin':'\ud83d\udc2c',
  1251. 'door':'\ud83d\udeaa',
  1252. 'doughnut':'\ud83c\udf69',
  1253. 'dove':'\ud83d\udd4a',
  1254. 'dragon':'\ud83d\udc09',
  1255. 'dragon_face':'\ud83d\udc32',
  1256. 'dress':'\ud83d\udc57',
  1257. 'dromedary_camel':'\ud83d\udc2a',
  1258. 'drooling_face':'\ud83e\udd24',
  1259. 'droplet':'\ud83d\udca7',
  1260. 'drum':'\ud83e\udd41',
  1261. 'duck':'\ud83e\udd86',
  1262. 'dvd':'\ud83d\udcc0',
  1263. 'e-mail':'\ud83d\udce7',
  1264. 'eagle':'\ud83e\udd85',
  1265. 'ear':'\ud83d\udc42',
  1266. 'ear_of_rice':'\ud83c\udf3e',
  1267. 'earth_africa':'\ud83c\udf0d',
  1268. 'earth_americas':'\ud83c\udf0e',
  1269. 'earth_asia':'\ud83c\udf0f',
  1270. 'egg':'\ud83e\udd5a',
  1271. 'eggplant':'\ud83c\udf46',
  1272. 'eight_pointed_black_star':'\u2734\ufe0f',
  1273. 'eight_spoked_asterisk':'\u2733\ufe0f',
  1274. 'electric_plug':'\ud83d\udd0c',
  1275. 'elephant':'\ud83d\udc18',
  1276. 'email':'\u2709\ufe0f',
  1277. 'end':'\ud83d\udd1a',
  1278. 'envelope_with_arrow':'\ud83d\udce9',
  1279. 'euro':'\ud83d\udcb6',
  1280. 'european_castle':'\ud83c\udff0',
  1281. 'european_post_office':'\ud83c\udfe4',
  1282. 'evergreen_tree':'\ud83c\udf32',
  1283. 'exclamation':'\u2757\ufe0f',
  1284. 'expressionless':'\ud83d\ude11',
  1285. 'eye':'\ud83d\udc41',
  1286. 'eye_speech_bubble':'\ud83d\udc41&zwj;\ud83d\udde8',
  1287. 'eyeglasses':'\ud83d\udc53',
  1288. 'eyes':'\ud83d\udc40',
  1289. 'face_with_head_bandage':'\ud83e\udd15',
  1290. 'face_with_thermometer':'\ud83e\udd12',
  1291. 'fist_oncoming':'\ud83d\udc4a',
  1292. 'factory':'\ud83c\udfed',
  1293. 'fallen_leaf':'\ud83c\udf42',
  1294. 'family_man_woman_boy':'\ud83d\udc6a',
  1295. 'family_man_boy':'\ud83d\udc68&zwj;\ud83d\udc66',
  1296. 'family_man_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1297. 'family_man_girl':'\ud83d\udc68&zwj;\ud83d\udc67',
  1298. 'family_man_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1299. 'family_man_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1300. 'family_man_man_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc66',
  1301. 'family_man_man_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1302. 'family_man_man_girl':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67',
  1303. 'family_man_man_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1304. 'family_man_man_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1305. 'family_man_woman_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1306. 'family_man_woman_girl':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67',
  1307. 'family_man_woman_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1308. 'family_man_woman_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1309. 'family_woman_boy':'\ud83d\udc69&zwj;\ud83d\udc66',
  1310. 'family_woman_boy_boy':'\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1311. 'family_woman_girl':'\ud83d\udc69&zwj;\ud83d\udc67',
  1312. 'family_woman_girl_boy':'\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1313. 'family_woman_girl_girl':'\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1314. 'family_woman_woman_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc66',
  1315. 'family_woman_woman_boy_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1316. 'family_woman_woman_girl':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67',
  1317. 'family_woman_woman_girl_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1318. 'family_woman_woman_girl_girl':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1319. 'fast_forward':'\u23e9',
  1320. 'fax':'\ud83d\udce0',
  1321. 'fearful':'\ud83d\ude28',
  1322. 'feet':'\ud83d\udc3e',
  1323. 'female_detective':'\ud83d\udd75\ufe0f&zwj;\u2640\ufe0f',
  1324. 'ferris_wheel':'\ud83c\udfa1',
  1325. 'ferry':'\u26f4',
  1326. 'field_hockey':'\ud83c\udfd1',
  1327. 'file_cabinet':'\ud83d\uddc4',
  1328. 'file_folder':'\ud83d\udcc1',
  1329. 'film_projector':'\ud83d\udcfd',
  1330. 'film_strip':'\ud83c\udf9e',
  1331. 'fire':'\ud83d\udd25',
  1332. 'fire_engine':'\ud83d\ude92',
  1333. 'fireworks':'\ud83c\udf86',
  1334. 'first_quarter_moon':'\ud83c\udf13',
  1335. 'first_quarter_moon_with_face':'\ud83c\udf1b',
  1336. 'fish':'\ud83d\udc1f',
  1337. 'fish_cake':'\ud83c\udf65',
  1338. 'fishing_pole_and_fish':'\ud83c\udfa3',
  1339. 'fist_raised':'\u270a',
  1340. 'fist_left':'\ud83e\udd1b',
  1341. 'fist_right':'\ud83e\udd1c',
  1342. 'flags':'\ud83c\udf8f',
  1343. 'flashlight':'\ud83d\udd26',
  1344. 'fleur_de_lis':'\u269c\ufe0f',
  1345. 'flight_arrival':'\ud83d\udeec',
  1346. 'flight_departure':'\ud83d\udeeb',
  1347. 'floppy_disk':'\ud83d\udcbe',
  1348. 'flower_playing_cards':'\ud83c\udfb4',
  1349. 'flushed':'\ud83d\ude33',
  1350. 'fog':'\ud83c\udf2b',
  1351. 'foggy':'\ud83c\udf01',
  1352. 'football':'\ud83c\udfc8',
  1353. 'footprints':'\ud83d\udc63',
  1354. 'fork_and_knife':'\ud83c\udf74',
  1355. 'fountain':'\u26f2\ufe0f',
  1356. 'fountain_pen':'\ud83d\udd8b',
  1357. 'four_leaf_clover':'\ud83c\udf40',
  1358. 'fox_face':'\ud83e\udd8a',
  1359. 'framed_picture':'\ud83d\uddbc',
  1360. 'free':'\ud83c\udd93',
  1361. 'fried_egg':'\ud83c\udf73',
  1362. 'fried_shrimp':'\ud83c\udf64',
  1363. 'fries':'\ud83c\udf5f',
  1364. 'frog':'\ud83d\udc38',
  1365. 'frowning':'\ud83d\ude26',
  1366. 'frowning_face':'\u2639\ufe0f',
  1367. 'frowning_man':'\ud83d\ude4d&zwj;\u2642\ufe0f',
  1368. 'frowning_woman':'\ud83d\ude4d',
  1369. 'middle_finger':'\ud83d\udd95',
  1370. 'fuelpump':'\u26fd\ufe0f',
  1371. 'full_moon':'\ud83c\udf15',
  1372. 'full_moon_with_face':'\ud83c\udf1d',
  1373. 'funeral_urn':'\u26b1\ufe0f',
  1374. 'game_die':'\ud83c\udfb2',
  1375. 'gear':'\u2699\ufe0f',
  1376. 'gem':'\ud83d\udc8e',
  1377. 'gemini':'\u264a\ufe0f',
  1378. 'ghost':'\ud83d\udc7b',
  1379. 'gift':'\ud83c\udf81',
  1380. 'gift_heart':'\ud83d\udc9d',
  1381. 'girl':'\ud83d\udc67',
  1382. 'globe_with_meridians':'\ud83c\udf10',
  1383. 'goal_net':'\ud83e\udd45',
  1384. 'goat':'\ud83d\udc10',
  1385. 'golf':'\u26f3\ufe0f',
  1386. 'golfing_man':'\ud83c\udfcc\ufe0f',
  1387. 'golfing_woman':'\ud83c\udfcc\ufe0f&zwj;\u2640\ufe0f',
  1388. 'gorilla':'\ud83e\udd8d',
  1389. 'grapes':'\ud83c\udf47',
  1390. 'green_apple':'\ud83c\udf4f',
  1391. 'green_book':'\ud83d\udcd7',
  1392. 'green_heart':'\ud83d\udc9a',
  1393. 'green_salad':'\ud83e\udd57',
  1394. 'grey_exclamation':'\u2755',
  1395. 'grey_question':'\u2754',
  1396. 'grimacing':'\ud83d\ude2c',
  1397. 'grin':'\ud83d\ude01',
  1398. 'grinning':'\ud83d\ude00',
  1399. 'guardsman':'\ud83d\udc82',
  1400. 'guardswoman':'\ud83d\udc82&zwj;\u2640\ufe0f',
  1401. 'guitar':'\ud83c\udfb8',
  1402. 'gun':'\ud83d\udd2b',
  1403. 'haircut_woman':'\ud83d\udc87',
  1404. 'haircut_man':'\ud83d\udc87&zwj;\u2642\ufe0f',
  1405. 'hamburger':'\ud83c\udf54',
  1406. 'hammer':'\ud83d\udd28',
  1407. 'hammer_and_pick':'\u2692',
  1408. 'hammer_and_wrench':'\ud83d\udee0',
  1409. 'hamster':'\ud83d\udc39',
  1410. 'hand':'\u270b',
  1411. 'handbag':'\ud83d\udc5c',
  1412. 'handshake':'\ud83e\udd1d',
  1413. 'hankey':'\ud83d\udca9',
  1414. 'hatched_chick':'\ud83d\udc25',
  1415. 'hatching_chick':'\ud83d\udc23',
  1416. 'headphones':'\ud83c\udfa7',
  1417. 'hear_no_evil':'\ud83d\ude49',
  1418. 'heart':'\u2764\ufe0f',
  1419. 'heart_decoration':'\ud83d\udc9f',
  1420. 'heart_eyes':'\ud83d\ude0d',
  1421. 'heart_eyes_cat':'\ud83d\ude3b',
  1422. 'heartbeat':'\ud83d\udc93',
  1423. 'heartpulse':'\ud83d\udc97',
  1424. 'hearts':'\u2665\ufe0f',
  1425. 'heavy_check_mark':'\u2714\ufe0f',
  1426. 'heavy_division_sign':'\u2797',
  1427. 'heavy_dollar_sign':'\ud83d\udcb2',
  1428. 'heavy_heart_exclamation':'\u2763\ufe0f',
  1429. 'heavy_minus_sign':'\u2796',
  1430. 'heavy_multiplication_x':'\u2716\ufe0f',
  1431. 'heavy_plus_sign':'\u2795',
  1432. 'helicopter':'\ud83d\ude81',
  1433. 'herb':'\ud83c\udf3f',
  1434. 'hibiscus':'\ud83c\udf3a',
  1435. 'high_brightness':'\ud83d\udd06',
  1436. 'high_heel':'\ud83d\udc60',
  1437. 'hocho':'\ud83d\udd2a',
  1438. 'hole':'\ud83d\udd73',
  1439. 'honey_pot':'\ud83c\udf6f',
  1440. 'horse':'\ud83d\udc34',
  1441. 'horse_racing':'\ud83c\udfc7',
  1442. 'hospital':'\ud83c\udfe5',
  1443. 'hot_pepper':'\ud83c\udf36',
  1444. 'hotdog':'\ud83c\udf2d',
  1445. 'hotel':'\ud83c\udfe8',
  1446. 'hotsprings':'\u2668\ufe0f',
  1447. 'hourglass':'\u231b\ufe0f',
  1448. 'hourglass_flowing_sand':'\u23f3',
  1449. 'house':'\ud83c\udfe0',
  1450. 'house_with_garden':'\ud83c\udfe1',
  1451. 'houses':'\ud83c\udfd8',
  1452. 'hugs':'\ud83e\udd17',
  1453. 'hushed':'\ud83d\ude2f',
  1454. 'ice_cream':'\ud83c\udf68',
  1455. 'ice_hockey':'\ud83c\udfd2',
  1456. 'ice_skate':'\u26f8',
  1457. 'icecream':'\ud83c\udf66',
  1458. 'id':'\ud83c\udd94',
  1459. 'ideograph_advantage':'\ud83c\ude50',
  1460. 'imp':'\ud83d\udc7f',
  1461. 'inbox_tray':'\ud83d\udce5',
  1462. 'incoming_envelope':'\ud83d\udce8',
  1463. 'tipping_hand_woman':'\ud83d\udc81',
  1464. 'information_source':'\u2139\ufe0f',
  1465. 'innocent':'\ud83d\ude07',
  1466. 'interrobang':'\u2049\ufe0f',
  1467. 'iphone':'\ud83d\udcf1',
  1468. 'izakaya_lantern':'\ud83c\udfee',
  1469. 'jack_o_lantern':'\ud83c\udf83',
  1470. 'japan':'\ud83d\uddfe',
  1471. 'japanese_castle':'\ud83c\udfef',
  1472. 'japanese_goblin':'\ud83d\udc7a',
  1473. 'japanese_ogre':'\ud83d\udc79',
  1474. 'jeans':'\ud83d\udc56',
  1475. 'joy':'\ud83d\ude02',
  1476. 'joy_cat':'\ud83d\ude39',
  1477. 'joystick':'\ud83d\udd79',
  1478. 'kaaba':'\ud83d\udd4b',
  1479. 'key':'\ud83d\udd11',
  1480. 'keyboard':'\u2328\ufe0f',
  1481. 'keycap_ten':'\ud83d\udd1f',
  1482. 'kick_scooter':'\ud83d\udef4',
  1483. 'kimono':'\ud83d\udc58',
  1484. 'kiss':'\ud83d\udc8b',
  1485. 'kissing':'\ud83d\ude17',
  1486. 'kissing_cat':'\ud83d\ude3d',
  1487. 'kissing_closed_eyes':'\ud83d\ude1a',
  1488. 'kissing_heart':'\ud83d\ude18',
  1489. 'kissing_smiling_eyes':'\ud83d\ude19',
  1490. 'kiwi_fruit':'\ud83e\udd5d',
  1491. 'koala':'\ud83d\udc28',
  1492. 'koko':'\ud83c\ude01',
  1493. 'label':'\ud83c\udff7',
  1494. 'large_blue_circle':'\ud83d\udd35',
  1495. 'large_blue_diamond':'\ud83d\udd37',
  1496. 'large_orange_diamond':'\ud83d\udd36',
  1497. 'last_quarter_moon':'\ud83c\udf17',
  1498. 'last_quarter_moon_with_face':'\ud83c\udf1c',
  1499. 'latin_cross':'\u271d\ufe0f',
  1500. 'laughing':'\ud83d\ude06',
  1501. 'leaves':'\ud83c\udf43',
  1502. 'ledger':'\ud83d\udcd2',
  1503. 'left_luggage':'\ud83d\udec5',
  1504. 'left_right_arrow':'\u2194\ufe0f',
  1505. 'leftwards_arrow_with_hook':'\u21a9\ufe0f',
  1506. 'lemon':'\ud83c\udf4b',
  1507. 'leo':'\u264c\ufe0f',
  1508. 'leopard':'\ud83d\udc06',
  1509. 'level_slider':'\ud83c\udf9a',
  1510. 'libra':'\u264e\ufe0f',
  1511. 'light_rail':'\ud83d\ude88',
  1512. 'link':'\ud83d\udd17',
  1513. 'lion':'\ud83e\udd81',
  1514. 'lips':'\ud83d\udc44',
  1515. 'lipstick':'\ud83d\udc84',
  1516. 'lizard':'\ud83e\udd8e',
  1517. 'lock':'\ud83d\udd12',
  1518. 'lock_with_ink_pen':'\ud83d\udd0f',
  1519. 'lollipop':'\ud83c\udf6d',
  1520. 'loop':'\u27bf',
  1521. 'loud_sound':'\ud83d\udd0a',
  1522. 'loudspeaker':'\ud83d\udce2',
  1523. 'love_hotel':'\ud83c\udfe9',
  1524. 'love_letter':'\ud83d\udc8c',
  1525. 'low_brightness':'\ud83d\udd05',
  1526. 'lying_face':'\ud83e\udd25',
  1527. 'm':'\u24c2\ufe0f',
  1528. 'mag':'\ud83d\udd0d',
  1529. 'mag_right':'\ud83d\udd0e',
  1530. 'mahjong':'\ud83c\udc04\ufe0f',
  1531. 'mailbox':'\ud83d\udceb',
  1532. 'mailbox_closed':'\ud83d\udcea',
  1533. 'mailbox_with_mail':'\ud83d\udcec',
  1534. 'mailbox_with_no_mail':'\ud83d\udced',
  1535. 'man':'\ud83d\udc68',
  1536. 'man_artist':'\ud83d\udc68&zwj;\ud83c\udfa8',
  1537. 'man_astronaut':'\ud83d\udc68&zwj;\ud83d\ude80',
  1538. 'man_cartwheeling':'\ud83e\udd38&zwj;\u2642\ufe0f',
  1539. 'man_cook':'\ud83d\udc68&zwj;\ud83c\udf73',
  1540. 'man_dancing':'\ud83d\udd7a',
  1541. 'man_facepalming':'\ud83e\udd26&zwj;\u2642\ufe0f',
  1542. 'man_factory_worker':'\ud83d\udc68&zwj;\ud83c\udfed',
  1543. 'man_farmer':'\ud83d\udc68&zwj;\ud83c\udf3e',
  1544. 'man_firefighter':'\ud83d\udc68&zwj;\ud83d\ude92',
  1545. 'man_health_worker':'\ud83d\udc68&zwj;\u2695\ufe0f',
  1546. 'man_in_tuxedo':'\ud83e\udd35',
  1547. 'man_judge':'\ud83d\udc68&zwj;\u2696\ufe0f',
  1548. 'man_juggling':'\ud83e\udd39&zwj;\u2642\ufe0f',
  1549. 'man_mechanic':'\ud83d\udc68&zwj;\ud83d\udd27',
  1550. 'man_office_worker':'\ud83d\udc68&zwj;\ud83d\udcbc',
  1551. 'man_pilot':'\ud83d\udc68&zwj;\u2708\ufe0f',
  1552. 'man_playing_handball':'\ud83e\udd3e&zwj;\u2642\ufe0f',
  1553. 'man_playing_water_polo':'\ud83e\udd3d&zwj;\u2642\ufe0f',
  1554. 'man_scientist':'\ud83d\udc68&zwj;\ud83d\udd2c',
  1555. 'man_shrugging':'\ud83e\udd37&zwj;\u2642\ufe0f',
  1556. 'man_singer':'\ud83d\udc68&zwj;\ud83c\udfa4',
  1557. 'man_student':'\ud83d\udc68&zwj;\ud83c\udf93',
  1558. 'man_teacher':'\ud83d\udc68&zwj;\ud83c\udfeb',
  1559. 'man_technologist':'\ud83d\udc68&zwj;\ud83d\udcbb',
  1560. 'man_with_gua_pi_mao':'\ud83d\udc72',
  1561. 'man_with_turban':'\ud83d\udc73',
  1562. 'tangerine':'\ud83c\udf4a',
  1563. 'mans_shoe':'\ud83d\udc5e',
  1564. 'mantelpiece_clock':'\ud83d\udd70',
  1565. 'maple_leaf':'\ud83c\udf41',
  1566. 'martial_arts_uniform':'\ud83e\udd4b',
  1567. 'mask':'\ud83d\ude37',
  1568. 'massage_woman':'\ud83d\udc86',
  1569. 'massage_man':'\ud83d\udc86&zwj;\u2642\ufe0f',
  1570. 'meat_on_bone':'\ud83c\udf56',
  1571. 'medal_military':'\ud83c\udf96',
  1572. 'medal_sports':'\ud83c\udfc5',
  1573. 'mega':'\ud83d\udce3',
  1574. 'melon':'\ud83c\udf48',
  1575. 'memo':'\ud83d\udcdd',
  1576. 'men_wrestling':'\ud83e\udd3c&zwj;\u2642\ufe0f',
  1577. 'menorah':'\ud83d\udd4e',
  1578. 'mens':'\ud83d\udeb9',
  1579. 'metal':'\ud83e\udd18',
  1580. 'metro':'\ud83d\ude87',
  1581. 'microphone':'\ud83c\udfa4',
  1582. 'microscope':'\ud83d\udd2c',
  1583. 'milk_glass':'\ud83e\udd5b',
  1584. 'milky_way':'\ud83c\udf0c',
  1585. 'minibus':'\ud83d\ude90',
  1586. 'minidisc':'\ud83d\udcbd',
  1587. 'mobile_phone_off':'\ud83d\udcf4',
  1588. 'money_mouth_face':'\ud83e\udd11',
  1589. 'money_with_wings':'\ud83d\udcb8',
  1590. 'moneybag':'\ud83d\udcb0',
  1591. 'monkey':'\ud83d\udc12',
  1592. 'monkey_face':'\ud83d\udc35',
  1593. 'monorail':'\ud83d\ude9d',
  1594. 'moon':'\ud83c\udf14',
  1595. 'mortar_board':'\ud83c\udf93',
  1596. 'mosque':'\ud83d\udd4c',
  1597. 'motor_boat':'\ud83d\udee5',
  1598. 'motor_scooter':'\ud83d\udef5',
  1599. 'motorcycle':'\ud83c\udfcd',
  1600. 'motorway':'\ud83d\udee3',
  1601. 'mount_fuji':'\ud83d\uddfb',
  1602. 'mountain':'\u26f0',
  1603. 'mountain_biking_man':'\ud83d\udeb5',
  1604. 'mountain_biking_woman':'\ud83d\udeb5&zwj;\u2640\ufe0f',
  1605. 'mountain_cableway':'\ud83d\udea0',
  1606. 'mountain_railway':'\ud83d\ude9e',
  1607. 'mountain_snow':'\ud83c\udfd4',
  1608. 'mouse':'\ud83d\udc2d',
  1609. 'mouse2':'\ud83d\udc01',
  1610. 'movie_camera':'\ud83c\udfa5',
  1611. 'moyai':'\ud83d\uddff',
  1612. 'mrs_claus':'\ud83e\udd36',
  1613. 'muscle':'\ud83d\udcaa',
  1614. 'mushroom':'\ud83c\udf44',
  1615. 'musical_keyboard':'\ud83c\udfb9',
  1616. 'musical_note':'\ud83c\udfb5',
  1617. 'musical_score':'\ud83c\udfbc',
  1618. 'mute':'\ud83d\udd07',
  1619. 'nail_care':'\ud83d\udc85',
  1620. 'name_badge':'\ud83d\udcdb',
  1621. 'national_park':'\ud83c\udfde',
  1622. 'nauseated_face':'\ud83e\udd22',
  1623. 'necktie':'\ud83d\udc54',
  1624. 'negative_squared_cross_mark':'\u274e',
  1625. 'nerd_face':'\ud83e\udd13',
  1626. 'neutral_face':'\ud83d\ude10',
  1627. 'new':'\ud83c\udd95',
  1628. 'new_moon':'\ud83c\udf11',
  1629. 'new_moon_with_face':'\ud83c\udf1a',
  1630. 'newspaper':'\ud83d\udcf0',
  1631. 'newspaper_roll':'\ud83d\uddde',
  1632. 'next_track_button':'\u23ed',
  1633. 'ng':'\ud83c\udd96',
  1634. 'no_good_man':'\ud83d\ude45&zwj;\u2642\ufe0f',
  1635. 'no_good_woman':'\ud83d\ude45',
  1636. 'night_with_stars':'\ud83c\udf03',
  1637. 'no_bell':'\ud83d\udd15',
  1638. 'no_bicycles':'\ud83d\udeb3',
  1639. 'no_entry':'\u26d4\ufe0f',
  1640. 'no_entry_sign':'\ud83d\udeab',
  1641. 'no_mobile_phones':'\ud83d\udcf5',
  1642. 'no_mouth':'\ud83d\ude36',
  1643. 'no_pedestrians':'\ud83d\udeb7',
  1644. 'no_smoking':'\ud83d\udead',
  1645. 'non-potable_water':'\ud83d\udeb1',
  1646. 'nose':'\ud83d\udc43',
  1647. 'notebook':'\ud83d\udcd3',
  1648. 'notebook_with_decorative_cover':'\ud83d\udcd4',
  1649. 'notes':'\ud83c\udfb6',
  1650. 'nut_and_bolt':'\ud83d\udd29',
  1651. 'o':'\u2b55\ufe0f',
  1652. 'o2':'\ud83c\udd7e\ufe0f',
  1653. 'ocean':'\ud83c\udf0a',
  1654. 'octopus':'\ud83d\udc19',
  1655. 'oden':'\ud83c\udf62',
  1656. 'office':'\ud83c\udfe2',
  1657. 'oil_drum':'\ud83d\udee2',
  1658. 'ok':'\ud83c\udd97',
  1659. 'ok_hand':'\ud83d\udc4c',
  1660. 'ok_man':'\ud83d\ude46&zwj;\u2642\ufe0f',
  1661. 'ok_woman':'\ud83d\ude46',
  1662. 'old_key':'\ud83d\udddd',
  1663. 'older_man':'\ud83d\udc74',
  1664. 'older_woman':'\ud83d\udc75',
  1665. 'om':'\ud83d\udd49',
  1666. 'on':'\ud83d\udd1b',
  1667. 'oncoming_automobile':'\ud83d\ude98',
  1668. 'oncoming_bus':'\ud83d\ude8d',
  1669. 'oncoming_police_car':'\ud83d\ude94',
  1670. 'oncoming_taxi':'\ud83d\ude96',
  1671. 'open_file_folder':'\ud83d\udcc2',
  1672. 'open_hands':'\ud83d\udc50',
  1673. 'open_mouth':'\ud83d\ude2e',
  1674. 'open_umbrella':'\u2602\ufe0f',
  1675. 'ophiuchus':'\u26ce',
  1676. 'orange_book':'\ud83d\udcd9',
  1677. 'orthodox_cross':'\u2626\ufe0f',
  1678. 'outbox_tray':'\ud83d\udce4',
  1679. 'owl':'\ud83e\udd89',
  1680. 'ox':'\ud83d\udc02',
  1681. 'package':'\ud83d\udce6',
  1682. 'page_facing_up':'\ud83d\udcc4',
  1683. 'page_with_curl':'\ud83d\udcc3',
  1684. 'pager':'\ud83d\udcdf',
  1685. 'paintbrush':'\ud83d\udd8c',
  1686. 'palm_tree':'\ud83c\udf34',
  1687. 'pancakes':'\ud83e\udd5e',
  1688. 'panda_face':'\ud83d\udc3c',
  1689. 'paperclip':'\ud83d\udcce',
  1690. 'paperclips':'\ud83d\udd87',
  1691. 'parasol_on_ground':'\u26f1',
  1692. 'parking':'\ud83c\udd7f\ufe0f',
  1693. 'part_alternation_mark':'\u303d\ufe0f',
  1694. 'partly_sunny':'\u26c5\ufe0f',
  1695. 'passenger_ship':'\ud83d\udef3',
  1696. 'passport_control':'\ud83d\udec2',
  1697. 'pause_button':'\u23f8',
  1698. 'peace_symbol':'\u262e\ufe0f',
  1699. 'peach':'\ud83c\udf51',
  1700. 'peanuts':'\ud83e\udd5c',
  1701. 'pear':'\ud83c\udf50',
  1702. 'pen':'\ud83d\udd8a',
  1703. 'pencil2':'\u270f\ufe0f',
  1704. 'penguin':'\ud83d\udc27',
  1705. 'pensive':'\ud83d\ude14',
  1706. 'performing_arts':'\ud83c\udfad',
  1707. 'persevere':'\ud83d\ude23',
  1708. 'person_fencing':'\ud83e\udd3a',
  1709. 'pouting_woman':'\ud83d\ude4e',
  1710. 'phone':'\u260e\ufe0f',
  1711. 'pick':'\u26cf',
  1712. 'pig':'\ud83d\udc37',
  1713. 'pig2':'\ud83d\udc16',
  1714. 'pig_nose':'\ud83d\udc3d',
  1715. 'pill':'\ud83d\udc8a',
  1716. 'pineapple':'\ud83c\udf4d',
  1717. 'ping_pong':'\ud83c\udfd3',
  1718. 'pisces':'\u2653\ufe0f',
  1719. 'pizza':'\ud83c\udf55',
  1720. 'place_of_worship':'\ud83d\uded0',
  1721. 'plate_with_cutlery':'\ud83c\udf7d',
  1722. 'play_or_pause_button':'\u23ef',
  1723. 'point_down':'\ud83d\udc47',
  1724. 'point_left':'\ud83d\udc48',
  1725. 'point_right':'\ud83d\udc49',
  1726. 'point_up':'\u261d\ufe0f',
  1727. 'point_up_2':'\ud83d\udc46',
  1728. 'police_car':'\ud83d\ude93',
  1729. 'policewoman':'\ud83d\udc6e&zwj;\u2640\ufe0f',
  1730. 'poodle':'\ud83d\udc29',
  1731. 'popcorn':'\ud83c\udf7f',
  1732. 'post_office':'\ud83c\udfe3',
  1733. 'postal_horn':'\ud83d\udcef',
  1734. 'postbox':'\ud83d\udcee',
  1735. 'potable_water':'\ud83d\udeb0',
  1736. 'potato':'\ud83e\udd54',
  1737. 'pouch':'\ud83d\udc5d',
  1738. 'poultry_leg':'\ud83c\udf57',
  1739. 'pound':'\ud83d\udcb7',
  1740. 'rage':'\ud83d\ude21',
  1741. 'pouting_cat':'\ud83d\ude3e',
  1742. 'pouting_man':'\ud83d\ude4e&zwj;\u2642\ufe0f',
  1743. 'pray':'\ud83d\ude4f',
  1744. 'prayer_beads':'\ud83d\udcff',
  1745. 'pregnant_woman':'\ud83e\udd30',
  1746. 'previous_track_button':'\u23ee',
  1747. 'prince':'\ud83e\udd34',
  1748. 'princess':'\ud83d\udc78',
  1749. 'printer':'\ud83d\udda8',
  1750. 'purple_heart':'\ud83d\udc9c',
  1751. 'purse':'\ud83d\udc5b',
  1752. 'pushpin':'\ud83d\udccc',
  1753. 'put_litter_in_its_place':'\ud83d\udeae',
  1754. 'question':'\u2753',
  1755. 'rabbit':'\ud83d\udc30',
  1756. 'rabbit2':'\ud83d\udc07',
  1757. 'racehorse':'\ud83d\udc0e',
  1758. 'racing_car':'\ud83c\udfce',
  1759. 'radio':'\ud83d\udcfb',
  1760. 'radio_button':'\ud83d\udd18',
  1761. 'radioactive':'\u2622\ufe0f',
  1762. 'railway_car':'\ud83d\ude83',
  1763. 'railway_track':'\ud83d\udee4',
  1764. 'rainbow':'\ud83c\udf08',
  1765. 'rainbow_flag':'\ud83c\udff3\ufe0f&zwj;\ud83c\udf08',
  1766. 'raised_back_of_hand':'\ud83e\udd1a',
  1767. 'raised_hand_with_fingers_splayed':'\ud83d\udd90',
  1768. 'raised_hands':'\ud83d\ude4c',
  1769. 'raising_hand_woman':'\ud83d\ude4b',
  1770. 'raising_hand_man':'\ud83d\ude4b&zwj;\u2642\ufe0f',
  1771. 'ram':'\ud83d\udc0f',
  1772. 'ramen':'\ud83c\udf5c',
  1773. 'rat':'\ud83d\udc00',
  1774. 'record_button':'\u23fa',
  1775. 'recycle':'\u267b\ufe0f',
  1776. 'red_circle':'\ud83d\udd34',
  1777. 'registered':'\u00ae\ufe0f',
  1778. 'relaxed':'\u263a\ufe0f',
  1779. 'relieved':'\ud83d\ude0c',
  1780. 'reminder_ribbon':'\ud83c\udf97',
  1781. 'repeat':'\ud83d\udd01',
  1782. 'repeat_one':'\ud83d\udd02',
  1783. 'rescue_worker_helmet':'\u26d1',
  1784. 'restroom':'\ud83d\udebb',
  1785. 'revolving_hearts':'\ud83d\udc9e',
  1786. 'rewind':'\u23ea',
  1787. 'rhinoceros':'\ud83e\udd8f',
  1788. 'ribbon':'\ud83c\udf80',
  1789. 'rice':'\ud83c\udf5a',
  1790. 'rice_ball':'\ud83c\udf59',
  1791. 'rice_cracker':'\ud83c\udf58',
  1792. 'rice_scene':'\ud83c\udf91',
  1793. 'right_anger_bubble':'\ud83d\uddef',
  1794. 'ring':'\ud83d\udc8d',
  1795. 'robot':'\ud83e\udd16',
  1796. 'rocket':'\ud83d\ude80',
  1797. 'rofl':'\ud83e\udd23',
  1798. 'roll_eyes':'\ud83d\ude44',
  1799. 'roller_coaster':'\ud83c\udfa2',
  1800. 'rooster':'\ud83d\udc13',
  1801. 'rose':'\ud83c\udf39',
  1802. 'rosette':'\ud83c\udff5',
  1803. 'rotating_light':'\ud83d\udea8',
  1804. 'round_pushpin':'\ud83d\udccd',
  1805. 'rowing_man':'\ud83d\udea3',
  1806. 'rowing_woman':'\ud83d\udea3&zwj;\u2640\ufe0f',
  1807. 'rugby_football':'\ud83c\udfc9',
  1808. 'running_man':'\ud83c\udfc3',
  1809. 'running_shirt_with_sash':'\ud83c\udfbd',
  1810. 'running_woman':'\ud83c\udfc3&zwj;\u2640\ufe0f',
  1811. 'sa':'\ud83c\ude02\ufe0f',
  1812. 'sagittarius':'\u2650\ufe0f',
  1813. 'sake':'\ud83c\udf76',
  1814. 'sandal':'\ud83d\udc61',
  1815. 'santa':'\ud83c\udf85',
  1816. 'satellite':'\ud83d\udce1',
  1817. 'saxophone':'\ud83c\udfb7',
  1818. 'school':'\ud83c\udfeb',
  1819. 'school_satchel':'\ud83c\udf92',
  1820. 'scissors':'\u2702\ufe0f',
  1821. 'scorpion':'\ud83e\udd82',
  1822. 'scorpius':'\u264f\ufe0f',
  1823. 'scream':'\ud83d\ude31',
  1824. 'scream_cat':'\ud83d\ude40',
  1825. 'scroll':'\ud83d\udcdc',
  1826. 'seat':'\ud83d\udcba',
  1827. 'secret':'\u3299\ufe0f',
  1828. 'see_no_evil':'\ud83d\ude48',
  1829. 'seedling':'\ud83c\udf31',
  1830. 'selfie':'\ud83e\udd33',
  1831. 'shallow_pan_of_food':'\ud83e\udd58',
  1832. 'shamrock':'\u2618\ufe0f',
  1833. 'shark':'\ud83e\udd88',
  1834. 'shaved_ice':'\ud83c\udf67',
  1835. 'sheep':'\ud83d\udc11',
  1836. 'shell':'\ud83d\udc1a',
  1837. 'shield':'\ud83d\udee1',
  1838. 'shinto_shrine':'\u26e9',
  1839. 'ship':'\ud83d\udea2',
  1840. 'shirt':'\ud83d\udc55',
  1841. 'shopping':'\ud83d\udecd',
  1842. 'shopping_cart':'\ud83d\uded2',
  1843. 'shower':'\ud83d\udebf',
  1844. 'shrimp':'\ud83e\udd90',
  1845. 'signal_strength':'\ud83d\udcf6',
  1846. 'six_pointed_star':'\ud83d\udd2f',
  1847. 'ski':'\ud83c\udfbf',
  1848. 'skier':'\u26f7',
  1849. 'skull':'\ud83d\udc80',
  1850. 'skull_and_crossbones':'\u2620\ufe0f',
  1851. 'sleeping':'\ud83d\ude34',
  1852. 'sleeping_bed':'\ud83d\udecc',
  1853. 'sleepy':'\ud83d\ude2a',
  1854. 'slightly_frowning_face':'\ud83d\ude41',
  1855. 'slightly_smiling_face':'\ud83d\ude42',
  1856. 'slot_machine':'\ud83c\udfb0',
  1857. 'small_airplane':'\ud83d\udee9',
  1858. 'small_blue_diamond':'\ud83d\udd39',
  1859. 'small_orange_diamond':'\ud83d\udd38',
  1860. 'small_red_triangle':'\ud83d\udd3a',
  1861. 'small_red_triangle_down':'\ud83d\udd3b',
  1862. 'smile':'\ud83d\ude04',
  1863. 'smile_cat':'\ud83d\ude38',
  1864. 'smiley':'\ud83d\ude03',
  1865. 'smiley_cat':'\ud83d\ude3a',
  1866. 'smiling_imp':'\ud83d\ude08',
  1867. 'smirk':'\ud83d\ude0f',
  1868. 'smirk_cat':'\ud83d\ude3c',
  1869. 'smoking':'\ud83d\udeac',
  1870. 'snail':'\ud83d\udc0c',
  1871. 'snake':'\ud83d\udc0d',
  1872. 'sneezing_face':'\ud83e\udd27',
  1873. 'snowboarder':'\ud83c\udfc2',
  1874. 'snowflake':'\u2744\ufe0f',
  1875. 'snowman':'\u26c4\ufe0f',
  1876. 'snowman_with_snow':'\u2603\ufe0f',
  1877. 'sob':'\ud83d\ude2d',
  1878. 'soccer':'\u26bd\ufe0f',
  1879. 'soon':'\ud83d\udd1c',
  1880. 'sos':'\ud83c\udd98',
  1881. 'sound':'\ud83d\udd09',
  1882. 'space_invader':'\ud83d\udc7e',
  1883. 'spades':'\u2660\ufe0f',
  1884. 'spaghetti':'\ud83c\udf5d',
  1885. 'sparkle':'\u2747\ufe0f',
  1886. 'sparkler':'\ud83c\udf87',
  1887. 'sparkles':'\u2728',
  1888. 'sparkling_heart':'\ud83d\udc96',
  1889. 'speak_no_evil':'\ud83d\ude4a',
  1890. 'speaker':'\ud83d\udd08',
  1891. 'speaking_head':'\ud83d\udde3',
  1892. 'speech_balloon':'\ud83d\udcac',
  1893. 'speedboat':'\ud83d\udea4',
  1894. 'spider':'\ud83d\udd77',
  1895. 'spider_web':'\ud83d\udd78',
  1896. 'spiral_calendar':'\ud83d\uddd3',
  1897. 'spiral_notepad':'\ud83d\uddd2',
  1898. 'spoon':'\ud83e\udd44',
  1899. 'squid':'\ud83e\udd91',
  1900. 'stadium':'\ud83c\udfdf',
  1901. 'star':'\u2b50\ufe0f',
  1902. 'star2':'\ud83c\udf1f',
  1903. 'star_and_crescent':'\u262a\ufe0f',
  1904. 'star_of_david':'\u2721\ufe0f',
  1905. 'stars':'\ud83c\udf20',
  1906. 'station':'\ud83d\ude89',
  1907. 'statue_of_liberty':'\ud83d\uddfd',
  1908. 'steam_locomotive':'\ud83d\ude82',
  1909. 'stew':'\ud83c\udf72',
  1910. 'stop_button':'\u23f9',
  1911. 'stop_sign':'\ud83d\uded1',
  1912. 'stopwatch':'\u23f1',
  1913. 'straight_ruler':'\ud83d\udccf',
  1914. 'strawberry':'\ud83c\udf53',
  1915. 'stuck_out_tongue':'\ud83d\ude1b',
  1916. 'stuck_out_tongue_closed_eyes':'\ud83d\ude1d',
  1917. 'stuck_out_tongue_winking_eye':'\ud83d\ude1c',
  1918. 'studio_microphone':'\ud83c\udf99',
  1919. 'stuffed_flatbread':'\ud83e\udd59',
  1920. 'sun_behind_large_cloud':'\ud83c\udf25',
  1921. 'sun_behind_rain_cloud':'\ud83c\udf26',
  1922. 'sun_behind_small_cloud':'\ud83c\udf24',
  1923. 'sun_with_face':'\ud83c\udf1e',
  1924. 'sunflower':'\ud83c\udf3b',
  1925. 'sunglasses':'\ud83d\ude0e',
  1926. 'sunny':'\u2600\ufe0f',
  1927. 'sunrise':'\ud83c\udf05',
  1928. 'sunrise_over_mountains':'\ud83c\udf04',
  1929. 'surfing_man':'\ud83c\udfc4',
  1930. 'surfing_woman':'\ud83c\udfc4&zwj;\u2640\ufe0f',
  1931. 'sushi':'\ud83c\udf63',
  1932. 'suspension_railway':'\ud83d\ude9f',
  1933. 'sweat':'\ud83d\ude13',
  1934. 'sweat_drops':'\ud83d\udca6',
  1935. 'sweat_smile':'\ud83d\ude05',
  1936. 'sweet_potato':'\ud83c\udf60',
  1937. 'swimming_man':'\ud83c\udfca',
  1938. 'swimming_woman':'\ud83c\udfca&zwj;\u2640\ufe0f',
  1939. 'symbols':'\ud83d\udd23',
  1940. 'synagogue':'\ud83d\udd4d',
  1941. 'syringe':'\ud83d\udc89',
  1942. 'taco':'\ud83c\udf2e',
  1943. 'tada':'\ud83c\udf89',
  1944. 'tanabata_tree':'\ud83c\udf8b',
  1945. 'taurus':'\u2649\ufe0f',
  1946. 'taxi':'\ud83d\ude95',
  1947. 'tea':'\ud83c\udf75',
  1948. 'telephone_receiver':'\ud83d\udcde',
  1949. 'telescope':'\ud83d\udd2d',
  1950. 'tennis':'\ud83c\udfbe',
  1951. 'tent':'\u26fa\ufe0f',
  1952. 'thermometer':'\ud83c\udf21',
  1953. 'thinking':'\ud83e\udd14',
  1954. 'thought_balloon':'\ud83d\udcad',
  1955. 'ticket':'\ud83c\udfab',
  1956. 'tickets':'\ud83c\udf9f',
  1957. 'tiger':'\ud83d\udc2f',
  1958. 'tiger2':'\ud83d\udc05',
  1959. 'timer_clock':'\u23f2',
  1960. 'tipping_hand_man':'\ud83d\udc81&zwj;\u2642\ufe0f',
  1961. 'tired_face':'\ud83d\ude2b',
  1962. 'tm':'\u2122\ufe0f',
  1963. 'toilet':'\ud83d\udebd',
  1964. 'tokyo_tower':'\ud83d\uddfc',
  1965. 'tomato':'\ud83c\udf45',
  1966. 'tongue':'\ud83d\udc45',
  1967. 'top':'\ud83d\udd1d',
  1968. 'tophat':'\ud83c\udfa9',
  1969. 'tornado':'\ud83c\udf2a',
  1970. 'trackball':'\ud83d\uddb2',
  1971. 'tractor':'\ud83d\ude9c',
  1972. 'traffic_light':'\ud83d\udea5',
  1973. 'train':'\ud83d\ude8b',
  1974. 'train2':'\ud83d\ude86',
  1975. 'tram':'\ud83d\ude8a',
  1976. 'triangular_flag_on_post':'\ud83d\udea9',
  1977. 'triangular_ruler':'\ud83d\udcd0',
  1978. 'trident':'\ud83d\udd31',
  1979. 'triumph':'\ud83d\ude24',
  1980. 'trolleybus':'\ud83d\ude8e',
  1981. 'trophy':'\ud83c\udfc6',
  1982. 'tropical_drink':'\ud83c\udf79',
  1983. 'tropical_fish':'\ud83d\udc20',
  1984. 'truck':'\ud83d\ude9a',
  1985. 'trumpet':'\ud83c\udfba',
  1986. 'tulip':'\ud83c\udf37',
  1987. 'tumbler_glass':'\ud83e\udd43',
  1988. 'turkey':'\ud83e\udd83',
  1989. 'turtle':'\ud83d\udc22',
  1990. 'tv':'\ud83d\udcfa',
  1991. 'twisted_rightwards_arrows':'\ud83d\udd00',
  1992. 'two_hearts':'\ud83d\udc95',
  1993. 'two_men_holding_hands':'\ud83d\udc6c',
  1994. 'two_women_holding_hands':'\ud83d\udc6d',
  1995. 'u5272':'\ud83c\ude39',
  1996. 'u5408':'\ud83c\ude34',
  1997. 'u55b6':'\ud83c\ude3a',
  1998. 'u6307':'\ud83c\ude2f\ufe0f',
  1999. 'u6708':'\ud83c\ude37\ufe0f',
  2000. 'u6709':'\ud83c\ude36',
  2001. 'u6e80':'\ud83c\ude35',
  2002. 'u7121':'\ud83c\ude1a\ufe0f',
  2003. 'u7533':'\ud83c\ude38',
  2004. 'u7981':'\ud83c\ude32',
  2005. 'u7a7a':'\ud83c\ude33',
  2006. 'umbrella':'\u2614\ufe0f',
  2007. 'unamused':'\ud83d\ude12',
  2008. 'underage':'\ud83d\udd1e',
  2009. 'unicorn':'\ud83e\udd84',
  2010. 'unlock':'\ud83d\udd13',
  2011. 'up':'\ud83c\udd99',
  2012. 'upside_down_face':'\ud83d\ude43',
  2013. 'v':'\u270c\ufe0f',
  2014. 'vertical_traffic_light':'\ud83d\udea6',
  2015. 'vhs':'\ud83d\udcfc',
  2016. 'vibration_mode':'\ud83d\udcf3',
  2017. 'video_camera':'\ud83d\udcf9',
  2018. 'video_game':'\ud83c\udfae',
  2019. 'violin':'\ud83c\udfbb',
  2020. 'virgo':'\u264d\ufe0f',
  2021. 'volcano':'\ud83c\udf0b',
  2022. 'volleyball':'\ud83c\udfd0',
  2023. 'vs':'\ud83c\udd9a',
  2024. 'vulcan_salute':'\ud83d\udd96',
  2025. 'walking_man':'\ud83d\udeb6',
  2026. 'walking_woman':'\ud83d\udeb6&zwj;\u2640\ufe0f',
  2027. 'waning_crescent_moon':'\ud83c\udf18',
  2028. 'waning_gibbous_moon':'\ud83c\udf16',
  2029. 'warning':'\u26a0\ufe0f',
  2030. 'wastebasket':'\ud83d\uddd1',
  2031. 'watch':'\u231a\ufe0f',
  2032. 'water_buffalo':'\ud83d\udc03',
  2033. 'watermelon':'\ud83c\udf49',
  2034. 'wave':'\ud83d\udc4b',
  2035. 'wavy_dash':'\u3030\ufe0f',
  2036. 'waxing_crescent_moon':'\ud83c\udf12',
  2037. 'wc':'\ud83d\udebe',
  2038. 'weary':'\ud83d\ude29',
  2039. 'wedding':'\ud83d\udc92',
  2040. 'weight_lifting_man':'\ud83c\udfcb\ufe0f',
  2041. 'weight_lifting_woman':'\ud83c\udfcb\ufe0f&zwj;\u2640\ufe0f',
  2042. 'whale':'\ud83d\udc33',
  2043. 'whale2':'\ud83d\udc0b',
  2044. 'wheel_of_dharma':'\u2638\ufe0f',
  2045. 'wheelchair':'\u267f\ufe0f',
  2046. 'white_check_mark':'\u2705',
  2047. 'white_circle':'\u26aa\ufe0f',
  2048. 'white_flag':'\ud83c\udff3\ufe0f',
  2049. 'white_flower':'\ud83d\udcae',
  2050. 'white_large_square':'\u2b1c\ufe0f',
  2051. 'white_medium_small_square':'\u25fd\ufe0f',
  2052. 'white_medium_square':'\u25fb\ufe0f',
  2053. 'white_small_square':'\u25ab\ufe0f',
  2054. 'white_square_button':'\ud83d\udd33',
  2055. 'wilted_flower':'\ud83e\udd40',
  2056. 'wind_chime':'\ud83c\udf90',
  2057. 'wind_face':'\ud83c\udf2c',
  2058. 'wine_glass':'\ud83c\udf77',
  2059. 'wink':'\ud83d\ude09',
  2060. 'wolf':'\ud83d\udc3a',
  2061. 'woman':'\ud83d\udc69',
  2062. 'woman_artist':'\ud83d\udc69&zwj;\ud83c\udfa8',
  2063. 'woman_astronaut':'\ud83d\udc69&zwj;\ud83d\ude80',
  2064. 'woman_cartwheeling':'\ud83e\udd38&zwj;\u2640\ufe0f',
  2065. 'woman_cook':'\ud83d\udc69&zwj;\ud83c\udf73',
  2066. 'woman_facepalming':'\ud83e\udd26&zwj;\u2640\ufe0f',
  2067. 'woman_factory_worker':'\ud83d\udc69&zwj;\ud83c\udfed',
  2068. 'woman_farmer':'\ud83d\udc69&zwj;\ud83c\udf3e',
  2069. 'woman_firefighter':'\ud83d\udc69&zwj;\ud83d\ude92',
  2070. 'woman_health_worker':'\ud83d\udc69&zwj;\u2695\ufe0f',
  2071. 'woman_judge':'\ud83d\udc69&zwj;\u2696\ufe0f',
  2072. 'woman_juggling':'\ud83e\udd39&zwj;\u2640\ufe0f',
  2073. 'woman_mechanic':'\ud83d\udc69&zwj;\ud83d\udd27',
  2074. 'woman_office_worker':'\ud83d\udc69&zwj;\ud83d\udcbc',
  2075. 'woman_pilot':'\ud83d\udc69&zwj;\u2708\ufe0f',
  2076. 'woman_playing_handball':'\ud83e\udd3e&zwj;\u2640\ufe0f',
  2077. 'woman_playing_water_polo':'\ud83e\udd3d&zwj;\u2640\ufe0f',
  2078. 'woman_scientist':'\ud83d\udc69&zwj;\ud83d\udd2c',
  2079. 'woman_shrugging':'\ud83e\udd37&zwj;\u2640\ufe0f',
  2080. 'woman_singer':'\ud83d\udc69&zwj;\ud83c\udfa4',
  2081. 'woman_student':'\ud83d\udc69&zwj;\ud83c\udf93',
  2082. 'woman_teacher':'\ud83d\udc69&zwj;\ud83c\udfeb',
  2083. 'woman_technologist':'\ud83d\udc69&zwj;\ud83d\udcbb',
  2084. 'woman_with_turban':'\ud83d\udc73&zwj;\u2640\ufe0f',
  2085. 'womans_clothes':'\ud83d\udc5a',
  2086. 'womans_hat':'\ud83d\udc52',
  2087. 'women_wrestling':'\ud83e\udd3c&zwj;\u2640\ufe0f',
  2088. 'womens':'\ud83d\udeba',
  2089. 'world_map':'\ud83d\uddfa',
  2090. 'worried':'\ud83d\ude1f',
  2091. 'wrench':'\ud83d\udd27',
  2092. 'writing_hand':'\u270d\ufe0f',
  2093. 'x':'\u274c',
  2094. 'yellow_heart':'\ud83d\udc9b',
  2095. 'yen':'\ud83d\udcb4',
  2096. 'yin_yang':'\u262f\ufe0f',
  2097. 'yum':'\ud83d\ude0b',
  2098. 'zap':'\u26a1\ufe0f',
  2099. 'zipper_mouth_face':'\ud83e\udd10',
  2100. 'zzz':'\ud83d\udca4',
  2101. /* special emojis :P */
  2102. 'octocat': '<img alt=":octocat:" height="20" width="20" align="absmiddle" src="https://assets-cdn.github.com/images/icons/emoji/octocat.png">',
  2103. 'showdown': '<span style="font-family: \'Anonymous Pro\', monospace; text-decoration: underline; text-decoration-style: dashed; text-decoration-color: #3e8b8a;text-underline-position: under;">S</span>'
  2104. };
  2105. /**
  2106. * Created by Estevao on 31-05-2015.
  2107. */
  2108. /**
  2109. * Showdown Converter class
  2110. * @class
  2111. * @param {object} [converterOptions]
  2112. * @returns {Converter}
  2113. */
  2114. showdown.Converter = function (converterOptions) {
  2115. 'use strict';
  2116. var
  2117. /**
  2118. * Options used by this converter
  2119. * @private
  2120. * @type {{}}
  2121. */
  2122. options = {},
  2123. /**
  2124. * Language extensions used by this converter
  2125. * @private
  2126. * @type {Array}
  2127. */
  2128. langExtensions = [],
  2129. /**
  2130. * Output modifiers extensions used by this converter
  2131. * @private
  2132. * @type {Array}
  2133. */
  2134. outputModifiers = [],
  2135. /**
  2136. * Event listeners
  2137. * @private
  2138. * @type {{}}
  2139. */
  2140. listeners = {},
  2141. /**
  2142. * The flavor set in this converter
  2143. */
  2144. setConvFlavor = setFlavor,
  2145. /**
  2146. * Metadata of the document
  2147. * @type {{parsed: {}, raw: string, format: string}}
  2148. */
  2149. metadata = {
  2150. parsed: {},
  2151. raw: '',
  2152. format: ''
  2153. };
  2154. _constructor();
  2155. /**
  2156. * Converter constructor
  2157. * @private
  2158. */
  2159. function _constructor () {
  2160. converterOptions = converterOptions || {};
  2161. for (var gOpt in globalOptions) {
  2162. if (globalOptions.hasOwnProperty(gOpt)) {
  2163. options[gOpt] = globalOptions[gOpt];
  2164. }
  2165. }
  2166. // Merge options
  2167. if (typeof converterOptions === 'object') {
  2168. for (var opt in converterOptions) {
  2169. if (converterOptions.hasOwnProperty(opt)) {
  2170. options[opt] = converterOptions[opt];
  2171. }
  2172. }
  2173. } else {
  2174. throw Error('Converter expects the passed parameter to be an object, but ' + typeof converterOptions +
  2175. ' was passed instead.');
  2176. }
  2177. if (options.extensions) {
  2178. showdown.helper.forEach(options.extensions, _parseExtension);
  2179. }
  2180. }
  2181. /**
  2182. * Parse extension
  2183. * @param {*} ext
  2184. * @param {string} [name='']
  2185. * @private
  2186. */
  2187. function _parseExtension (ext, name) {
  2188. name = name || null;
  2189. // If it's a string, the extension was previously loaded
  2190. if (showdown.helper.isString(ext)) {
  2191. ext = showdown.helper.stdExtName(ext);
  2192. name = ext;
  2193. // LEGACY_SUPPORT CODE
  2194. if (showdown.extensions[ext]) {
  2195. console.warn('DEPRECATION WARNING: ' + ext + ' is an old extension that uses a deprecated loading method.' +
  2196. 'Please inform the developer that the extension should be updated!');
  2197. legacyExtensionLoading(showdown.extensions[ext], ext);
  2198. return;
  2199. // END LEGACY SUPPORT CODE
  2200. } else if (!showdown.helper.isUndefined(extensions[ext])) {
  2201. ext = extensions[ext];
  2202. } else {
  2203. throw Error('Extension "' + ext + '" could not be loaded. It was either not found or is not a valid extension.');
  2204. }
  2205. }
  2206. if (typeof ext === 'function') {
  2207. ext = ext();
  2208. }
  2209. if (!showdown.helper.isArray(ext)) {
  2210. ext = [ext];
  2211. }
  2212. var validExt = validate(ext, name);
  2213. if (!validExt.valid) {
  2214. throw Error(validExt.error);
  2215. }
  2216. for (var i = 0; i < ext.length; ++i) {
  2217. switch (ext[i].type) {
  2218. case 'lang':
  2219. langExtensions.push(ext[i]);
  2220. break;
  2221. case 'output':
  2222. outputModifiers.push(ext[i]);
  2223. break;
  2224. }
  2225. if (ext[i].hasOwnProperty('listeners')) {
  2226. for (var ln in ext[i].listeners) {
  2227. if (ext[i].listeners.hasOwnProperty(ln)) {
  2228. listen(ln, ext[i].listeners[ln]);
  2229. }
  2230. }
  2231. }
  2232. }
  2233. }
  2234. /**
  2235. * LEGACY_SUPPORT
  2236. * @param {*} ext
  2237. * @param {string} name
  2238. */
  2239. function legacyExtensionLoading (ext, name) {
  2240. if (typeof ext === 'function') {
  2241. ext = ext(new showdown.Converter());
  2242. }
  2243. if (!showdown.helper.isArray(ext)) {
  2244. ext = [ext];
  2245. }
  2246. var valid = validate(ext, name);
  2247. if (!valid.valid) {
  2248. throw Error(valid.error);
  2249. }
  2250. for (var i = 0; i < ext.length; ++i) {
  2251. switch (ext[i].type) {
  2252. case 'lang':
  2253. langExtensions.push(ext[i]);
  2254. break;
  2255. case 'output':
  2256. outputModifiers.push(ext[i]);
  2257. break;
  2258. default:// should never reach here
  2259. throw Error('Extension loader error: Type unrecognized!!!');
  2260. }
  2261. }
  2262. }
  2263. /**
  2264. * Listen to an event
  2265. * @param {string} name
  2266. * @param {function} callback
  2267. */
  2268. function listen (name, callback) {
  2269. if (!showdown.helper.isString(name)) {
  2270. throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given');
  2271. }
  2272. if (typeof callback !== 'function') {
  2273. throw Error('Invalid argument in converter.listen() method: callback must be a function, but ' + typeof callback + ' given');
  2274. }
  2275. if (!listeners.hasOwnProperty(name)) {
  2276. listeners[name] = [];
  2277. }
  2278. listeners[name].push(callback);
  2279. }
  2280. function rTrimInputText (text) {
  2281. var rsp = text.match(/^\s*/)[0].length,
  2282. rgx = new RegExp('^\\s{0,' + rsp + '}', 'gm');
  2283. return text.replace(rgx, '');
  2284. }
  2285. /**
  2286. * Dispatch an event
  2287. * @private
  2288. * @param {string} evtName Event name
  2289. * @param {string} text Text
  2290. * @param {{}} options Converter Options
  2291. * @param {{}} globals
  2292. * @returns {string}
  2293. */
  2294. this._dispatch = function dispatch (evtName, text, options, globals) {
  2295. if (listeners.hasOwnProperty(evtName)) {
  2296. for (var ei = 0; ei < listeners[evtName].length; ++ei) {
  2297. var nText = listeners[evtName][ei](evtName, text, this, options, globals);
  2298. if (nText && typeof nText !== 'undefined') {
  2299. text = nText;
  2300. }
  2301. }
  2302. }
  2303. return text;
  2304. };
  2305. /**
  2306. * Listen to an event
  2307. * @param {string} name
  2308. * @param {function} callback
  2309. * @returns {showdown.Converter}
  2310. */
  2311. this.listen = function (name, callback) {
  2312. listen(name, callback);
  2313. return this;
  2314. };
  2315. /**
  2316. * Converts a markdown string into HTML
  2317. * @param {string} text
  2318. * @returns {*}
  2319. */
  2320. this.makeHtml = function (text) {
  2321. //check if text is not falsy
  2322. if (!text) {
  2323. return text;
  2324. }
  2325. var globals = {
  2326. gHtmlBlocks: [],
  2327. gHtmlMdBlocks: [],
  2328. gHtmlSpans: [],
  2329. gUrls: {},
  2330. gTitles: {},
  2331. gDimensions: {},
  2332. gListLevel: 0,
  2333. hashLinkCounts: {},
  2334. langExtensions: langExtensions,
  2335. outputModifiers: outputModifiers,
  2336. converter: this,
  2337. ghCodeBlocks: [],
  2338. metadata: {
  2339. parsed: {},
  2340. raw: '',
  2341. format: ''
  2342. }
  2343. };
  2344. // This lets us use ¨ trema as an escape char to avoid md5 hashes
  2345. // The choice of character is arbitrary; anything that isn't
  2346. // magic in Markdown will work.
  2347. text = text.replace(/¨/g, '¨T');
  2348. // Replace $ with ¨D
  2349. // RegExp interprets $ as a special character
  2350. // when it's in a replacement string
  2351. text = text.replace(/\$/g, '¨D');
  2352. // Standardize line endings
  2353. text = text.replace(/\r\n/g, '\n'); // DOS to Unix
  2354. text = text.replace(/\r/g, '\n'); // Mac to Unix
  2355. // Stardardize line spaces
  2356. text = text.replace(/\u00A0/g, '&nbsp;');
  2357. if (options.smartIndentationFix) {
  2358. text = rTrimInputText(text);
  2359. }
  2360. // Make sure text begins and ends with a couple of newlines:
  2361. text = '\n\n' + text + '\n\n';
  2362. // detab
  2363. text = showdown.subParser('detab')(text, options, globals);
  2364. /**
  2365. * Strip any lines consisting only of spaces and tabs.
  2366. * This makes subsequent regexs easier to write, because we can
  2367. * match consecutive blank lines with /\n+/ instead of something
  2368. * contorted like /[ \t]*\n+/
  2369. */
  2370. text = text.replace(/^[ \t]+$/mg, '');
  2371. //run languageExtensions
  2372. showdown.helper.forEach(langExtensions, function (ext) {
  2373. text = showdown.subParser('runExtension')(ext, text, options, globals);
  2374. });
  2375. // run the sub parsers
  2376. text = showdown.subParser('metadata')(text, options, globals);
  2377. text = showdown.subParser('hashPreCodeTags')(text, options, globals);
  2378. text = showdown.subParser('githubCodeBlocks')(text, options, globals);
  2379. text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
  2380. text = showdown.subParser('hashCodeTags')(text, options, globals);
  2381. text = showdown.subParser('stripLinkDefinitions')(text, options, globals);
  2382. text = showdown.subParser('blockGamut')(text, options, globals);
  2383. text = showdown.subParser('unhashHTMLSpans')(text, options, globals);
  2384. text = showdown.subParser('unescapeSpecialChars')(text, options, globals);
  2385. // attacklab: Restore dollar signs
  2386. text = text.replace(/¨D/g, '$$');
  2387. // attacklab: Restore tremas
  2388. text = text.replace(/¨T/g, '¨');
  2389. // render a complete html document instead of a partial if the option is enabled
  2390. text = showdown.subParser('completeHTMLDocument')(text, options, globals);
  2391. // Run output modifiers
  2392. showdown.helper.forEach(outputModifiers, function (ext) {
  2393. text = showdown.subParser('runExtension')(ext, text, options, globals);
  2394. });
  2395. // update metadata
  2396. metadata = globals.metadata;
  2397. return text;
  2398. };
  2399. /**
  2400. * Converts an HTML string into a markdown string
  2401. * @param src
  2402. * @param [HTMLParser] A WHATWG DOM and HTML parser, such as JSDOM. If none is supplied, window.document will be used.
  2403. * @returns {string}
  2404. */
  2405. this.makeMarkdown = this.makeMd = function (src, HTMLParser) {
  2406. // replace \r\n with \n
  2407. src = src.replace(/\r\n/g, '\n');
  2408. src = src.replace(/\r/g, '\n'); // old macs
  2409. // due to an edge case, we need to find this: > <
  2410. // to prevent removing of non silent white spaces
  2411. // ex: <em>this is</em> <strong>sparta</strong>
  2412. src = src.replace(/>[ \t]+</, '>¨NBSP;<');
  2413. if (!HTMLParser) {
  2414. if (window && window.document) {
  2415. HTMLParser = window.document;
  2416. } else {
  2417. throw new Error('HTMLParser is undefined. If in a webworker or nodejs environment, you need to provide a WHATWG DOM and HTML such as JSDOM');
  2418. }
  2419. }
  2420. var doc = HTMLParser.createElement('div');
  2421. doc.innerHTML = src;
  2422. var globals = {
  2423. preList: substitutePreCodeTags(doc)
  2424. };
  2425. // remove all newlines and collapse spaces
  2426. clean(doc);
  2427. // some stuff, like accidental reference links must now be escaped
  2428. // TODO
  2429. // doc.innerHTML = doc.innerHTML.replace(/\[[\S\t ]]/);
  2430. var nodes = doc.childNodes,
  2431. mdDoc = '';
  2432. for (var i = 0; i < nodes.length; i++) {
  2433. mdDoc += showdown.subParser('makeMarkdown.node')(nodes[i], globals);
  2434. }
  2435. function clean (node) {
  2436. for (var n = 0; n < node.childNodes.length; ++n) {
  2437. var child = node.childNodes[n];
  2438. if (child.nodeType === 3) {
  2439. if (!/\S/.test(child.nodeValue) && !/^[ ]+$/.test(child.nodeValue)) {
  2440. node.removeChild(child);
  2441. --n;
  2442. } else {
  2443. child.nodeValue = child.nodeValue.split('\n').join(' ');
  2444. child.nodeValue = child.nodeValue.replace(/(\s)+/g, '$1');
  2445. }
  2446. } else if (child.nodeType === 1) {
  2447. clean(child);
  2448. }
  2449. }
  2450. }
  2451. // find all pre tags and replace contents with placeholder
  2452. // we need this so that we can remove all indentation from html
  2453. // to ease up parsing
  2454. function substitutePreCodeTags (doc) {
  2455. var pres = doc.querySelectorAll('pre'),
  2456. presPH = [];
  2457. for (var i = 0; i < pres.length; ++i) {
  2458. if (pres[i].childElementCount === 1 && pres[i].firstChild.tagName.toLowerCase() === 'code') {
  2459. var content = pres[i].firstChild.innerHTML.trim(),
  2460. language = pres[i].firstChild.getAttribute('data-language') || '';
  2461. // if data-language attribute is not defined, then we look for class language-*
  2462. if (language === '') {
  2463. var classes = pres[i].firstChild.className.split(' ');
  2464. for (var c = 0; c < classes.length; ++c) {
  2465. var matches = classes[c].match(/^language-(.+)$/);
  2466. if (matches !== null) {
  2467. language = matches[1];
  2468. break;
  2469. }
  2470. }
  2471. }
  2472. // unescape html entities in content
  2473. content = showdown.helper.unescapeHTMLEntities(content);
  2474. presPH.push(content);
  2475. pres[i].outerHTML = '<precode language="' + language + '" precodenum="' + i.toString() + '"></precode>';
  2476. } else {
  2477. presPH.push(pres[i].innerHTML);
  2478. pres[i].innerHTML = '';
  2479. pres[i].setAttribute('prenum', i.toString());
  2480. }
  2481. }
  2482. return presPH;
  2483. }
  2484. return mdDoc;
  2485. };
  2486. /**
  2487. * Set an option of this Converter instance
  2488. * @param {string} key
  2489. * @param {*} value
  2490. */
  2491. this.setOption = function (key, value) {
  2492. options[key] = value;
  2493. };
  2494. /**
  2495. * Get the option of this Converter instance
  2496. * @param {string} key
  2497. * @returns {*}
  2498. */
  2499. this.getOption = function (key) {
  2500. return options[key];
  2501. };
  2502. /**
  2503. * Get the options of this Converter instance
  2504. * @returns {{}}
  2505. */
  2506. this.getOptions = function () {
  2507. return options;
  2508. };
  2509. /**
  2510. * Add extension to THIS converter
  2511. * @param {{}} extension
  2512. * @param {string} [name=null]
  2513. */
  2514. this.addExtension = function (extension, name) {
  2515. name = name || null;
  2516. _parseExtension(extension, name);
  2517. };
  2518. /**
  2519. * Use a global registered extension with THIS converter
  2520. * @param {string} extensionName Name of the previously registered extension
  2521. */
  2522. this.useExtension = function (extensionName) {
  2523. _parseExtension(extensionName);
  2524. };
  2525. /**
  2526. * Set the flavor THIS converter should use
  2527. * @param {string} name
  2528. */
  2529. this.setFlavor = function (name) {
  2530. if (!flavor.hasOwnProperty(name)) {
  2531. throw Error(name + ' flavor was not found');
  2532. }
  2533. var preset = flavor[name];
  2534. setConvFlavor = name;
  2535. for (var option in preset) {
  2536. if (preset.hasOwnProperty(option)) {
  2537. options[option] = preset[option];
  2538. }
  2539. }
  2540. };
  2541. /**
  2542. * Get the currently set flavor of this converter
  2543. * @returns {string}
  2544. */
  2545. this.getFlavor = function () {
  2546. return setConvFlavor;
  2547. };
  2548. /**
  2549. * Remove an extension from THIS converter.
  2550. * Note: This is a costly operation. It's better to initialize a new converter
  2551. * and specify the extensions you wish to use
  2552. * @param {Array} extension
  2553. */
  2554. this.removeExtension = function (extension) {
  2555. if (!showdown.helper.isArray(extension)) {
  2556. extension = [extension];
  2557. }
  2558. for (var a = 0; a < extension.length; ++a) {
  2559. var ext = extension[a];
  2560. for (var i = 0; i < langExtensions.length; ++i) {
  2561. if (langExtensions[i] === ext) {
  2562. langExtensions.splice(i, 1);
  2563. }
  2564. }
  2565. for (var ii = 0; ii < outputModifiers.length; ++ii) {
  2566. if (outputModifiers[ii] === ext) {
  2567. outputModifiers.splice(ii, 1);
  2568. }
  2569. }
  2570. }
  2571. };
  2572. /**
  2573. * Get all extension of THIS converter
  2574. * @returns {{language: Array, output: Array}}
  2575. */
  2576. this.getAllExtensions = function () {
  2577. return {
  2578. language: langExtensions,
  2579. output: outputModifiers
  2580. };
  2581. };
  2582. /**
  2583. * Get the metadata of the previously parsed document
  2584. * @param raw
  2585. * @returns {string|{}}
  2586. */
  2587. this.getMetadata = function (raw) {
  2588. if (raw) {
  2589. return metadata.raw;
  2590. } else {
  2591. return metadata.parsed;
  2592. }
  2593. };
  2594. /**
  2595. * Get the metadata format of the previously parsed document
  2596. * @returns {string}
  2597. */
  2598. this.getMetadataFormat = function () {
  2599. return metadata.format;
  2600. };
  2601. /**
  2602. * Private: set a single key, value metadata pair
  2603. * @param {string} key
  2604. * @param {string} value
  2605. */
  2606. this._setMetadataPair = function (key, value) {
  2607. metadata.parsed[key] = value;
  2608. };
  2609. /**
  2610. * Private: set metadata format
  2611. * @param {string} format
  2612. */
  2613. this._setMetadataFormat = function (format) {
  2614. metadata.format = format;
  2615. };
  2616. /**
  2617. * Private: set metadata raw text
  2618. * @param {string} raw
  2619. */
  2620. this._setMetadataRaw = function (raw) {
  2621. metadata.raw = raw;
  2622. };
  2623. };
  2624. /**
  2625. * Turn Markdown link shortcuts into XHTML <a> tags.
  2626. */
  2627. showdown.subParser('anchors', function (text, options, globals) {
  2628. 'use strict';
  2629. text = globals.converter._dispatch('anchors.before', text, options, globals);
  2630. var writeAnchorTag = function (wholeMatch, linkText, linkId, url, m5, m6, title) {
  2631. if (showdown.helper.isUndefined(title)) {
  2632. title = '';
  2633. }
  2634. linkId = linkId.toLowerCase();
  2635. // Special case for explicit empty url
  2636. if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) {
  2637. url = '';
  2638. } else if (!url) {
  2639. if (!linkId) {
  2640. // lower-case and turn embedded newlines into spaces
  2641. linkId = linkText.toLowerCase().replace(/ ?\n/g, ' ');
  2642. }
  2643. url = '#' + linkId;
  2644. if (!showdown.helper.isUndefined(globals.gUrls[linkId])) {
  2645. url = globals.gUrls[linkId];
  2646. if (!showdown.helper.isUndefined(globals.gTitles[linkId])) {
  2647. title = globals.gTitles[linkId];
  2648. }
  2649. } else {
  2650. return wholeMatch;
  2651. }
  2652. }
  2653. //url = showdown.helper.escapeCharacters(url, '*_', false); // replaced line to improve performance
  2654. url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  2655. var result = '<a href="' + url + '"';
  2656. if (title !== '' && title !== null) {
  2657. title = title.replace(/"/g, '&quot;');
  2658. //title = showdown.helper.escapeCharacters(title, '*_', false); // replaced line to improve performance
  2659. title = title.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  2660. result += ' title="' + title + '"';
  2661. }
  2662. // optionLinksInNewWindow only applies
  2663. // to external links. Hash links (#) open in same page
  2664. if (options.openLinksInNewWindow && !/^#/.test(url)) {
  2665. // escaped _
  2666. result += ' rel="noopener noreferrer" target="¨E95Eblank"';
  2667. }
  2668. result += '>' + linkText + '</a>';
  2669. return result;
  2670. };
  2671. // First, handle reference-style links: [link text] [id]
  2672. text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)] ?(?:\n *)?\[(.*?)]()()()()/g, writeAnchorTag);
  2673. // Next, inline-style links: [link text](url "optional title")
  2674. // cases with crazy urls like ./image/cat1).png
  2675. text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<([^>]*)>(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,
  2676. writeAnchorTag);
  2677. // normal cases
  2678. text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,
  2679. writeAnchorTag);
  2680. // handle reference-style shortcuts: [link text]
  2681. // These must come last in case you've also got [link test][1]
  2682. // or [link test](/foo)
  2683. text = text.replace(/\[([^\[\]]+)]()()()()()/g, writeAnchorTag);
  2684. // Lastly handle GithubMentions if option is enabled
  2685. if (options.ghMentions) {
  2686. text = text.replace(/(^|\s)(\\)?(@([a-z\d]+(?:[a-z\d.-]+?[a-z\d]+)*))/gmi, function (wm, st, escape, mentions, username) {
  2687. if (escape === '\\') {
  2688. return st + mentions;
  2689. }
  2690. //check if options.ghMentionsLink is a string
  2691. if (!showdown.helper.isString(options.ghMentionsLink)) {
  2692. throw new Error('ghMentionsLink option must be a string');
  2693. }
  2694. var lnk = options.ghMentionsLink.replace(/\{u}/g, username),
  2695. target = '';
  2696. if (options.openLinksInNewWindow) {
  2697. target = ' rel="noopener noreferrer" target="¨E95Eblank"';
  2698. }
  2699. return st + '<a href="' + lnk + '"' + target + '>' + mentions + '</a>';
  2700. });
  2701. }
  2702. text = globals.converter._dispatch('anchors.after', text, options, globals);
  2703. return text;
  2704. });
  2705. // url allowed chars [a-z\d_.~:/?#[]@!$&'()*+,;=-]
  2706. var simpleURLRegex = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+?\.[^'">\s]+?)()(\1)?(?=\s|$)(?!["<>])/gi,
  2707. simpleURLRegex2 = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+?)([.!?,()\[\]])?(\1)?(?=\s|$)(?!["<>])/gi,
  2708. delimUrlRegex = /()<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)()>()/gi,
  2709. simpleMailRegex = /(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gmi,
  2710. delimMailRegex = /<()(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
  2711. replaceLink = function (options) {
  2712. 'use strict';
  2713. return function (wm, leadingMagicChars, link, m2, m3, trailingPunctuation, trailingMagicChars) {
  2714. link = link.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  2715. var lnkTxt = link,
  2716. append = '',
  2717. target = '',
  2718. lmc = leadingMagicChars || '',
  2719. tmc = trailingMagicChars || '';
  2720. if (/^www\./i.test(link)) {
  2721. link = link.replace(/^www\./i, 'http://www.');
  2722. }
  2723. if (options.excludeTrailingPunctuationFromURLs && trailingPunctuation) {
  2724. append = trailingPunctuation;
  2725. }
  2726. if (options.openLinksInNewWindow) {
  2727. target = ' rel="noopener noreferrer" target="¨E95Eblank"';
  2728. }
  2729. return lmc + '<a href="' + link + '"' + target + '>' + lnkTxt + '</a>' + append + tmc;
  2730. };
  2731. },
  2732. replaceMail = function (options, globals) {
  2733. 'use strict';
  2734. return function (wholeMatch, b, mail) {
  2735. var href = 'mailto:';
  2736. b = b || '';
  2737. mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals);
  2738. if (options.encodeEmails) {
  2739. href = showdown.helper.encodeEmailAddress(href + mail);
  2740. mail = showdown.helper.encodeEmailAddress(mail);
  2741. } else {
  2742. href = href + mail;
  2743. }
  2744. return b + '<a href="' + href + '">' + mail + '</a>';
  2745. };
  2746. };
  2747. showdown.subParser('autoLinks', function (text, options, globals) {
  2748. 'use strict';
  2749. text = globals.converter._dispatch('autoLinks.before', text, options, globals);
  2750. text = text.replace(delimUrlRegex, replaceLink(options));
  2751. text = text.replace(delimMailRegex, replaceMail(options, globals));
  2752. text = globals.converter._dispatch('autoLinks.after', text, options, globals);
  2753. return text;
  2754. });
  2755. showdown.subParser('simplifiedAutoLinks', function (text, options, globals) {
  2756. 'use strict';
  2757. if (!options.simplifiedAutoLink) {
  2758. return text;
  2759. }
  2760. text = globals.converter._dispatch('simplifiedAutoLinks.before', text, options, globals);
  2761. if (options.excludeTrailingPunctuationFromURLs) {
  2762. text = text.replace(simpleURLRegex2, replaceLink(options));
  2763. } else {
  2764. text = text.replace(simpleURLRegex, replaceLink(options));
  2765. }
  2766. text = text.replace(simpleMailRegex, replaceMail(options, globals));
  2767. text = globals.converter._dispatch('simplifiedAutoLinks.after', text, options, globals);
  2768. return text;
  2769. });
  2770. /**
  2771. * These are all the transformations that form block-level
  2772. * tags like paragraphs, headers, and list items.
  2773. */
  2774. showdown.subParser('blockGamut', function (text, options, globals) {
  2775. 'use strict';
  2776. text = globals.converter._dispatch('blockGamut.before', text, options, globals);
  2777. // we parse blockquotes first so that we can have headings and hrs
  2778. // inside blockquotes
  2779. text = showdown.subParser('blockQuotes')(text, options, globals);
  2780. text = showdown.subParser('headers')(text, options, globals);
  2781. // Do Horizontal Rules:
  2782. text = showdown.subParser('horizontalRule')(text, options, globals);
  2783. text = showdown.subParser('lists')(text, options, globals);
  2784. text = showdown.subParser('codeBlocks')(text, options, globals);
  2785. text = showdown.subParser('tables')(text, options, globals);
  2786. // We already ran _HashHTMLBlocks() before, in Markdown(), but that
  2787. // was to escape raw HTML in the original Markdown source. This time,
  2788. // we're escaping the markup we've just created, so that we don't wrap
  2789. // <p> tags around block-level tags.
  2790. text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
  2791. text = showdown.subParser('paragraphs')(text, options, globals);
  2792. text = globals.converter._dispatch('blockGamut.after', text, options, globals);
  2793. return text;
  2794. });
  2795. showdown.subParser('blockQuotes', function (text, options, globals) {
  2796. 'use strict';
  2797. text = globals.converter._dispatch('blockQuotes.before', text, options, globals);
  2798. // add a couple extra lines after the text and endtext mark
  2799. text = text + '\n\n';
  2800. var rgx = /(^ {0,3}>[ \t]?.+\n(.+\n)*\n*)+/gm;
  2801. if (options.splitAdjacentBlockquotes) {
  2802. rgx = /^ {0,3}>[\s\S]*?(?:\n\n)/gm;
  2803. }
  2804. text = text.replace(rgx, function (bq) {
  2805. // attacklab: hack around Konqueror 3.5.4 bug:
  2806. // "----------bug".replace(/^-/g,"") == "bug"
  2807. bq = bq.replace(/^[ \t]*>[ \t]?/gm, ''); // trim one level of quoting
  2808. // attacklab: clean up hack
  2809. bq = bq.replace(/¨0/g, '');
  2810. bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines
  2811. bq = showdown.subParser('githubCodeBlocks')(bq, options, globals);
  2812. bq = showdown.subParser('blockGamut')(bq, options, globals); // recurse
  2813. bq = bq.replace(/(^|\n)/g, '$1 ');
  2814. // These leading spaces screw with <pre> content, so we need to fix that:
  2815. bq = bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm, function (wholeMatch, m1) {
  2816. var pre = m1;
  2817. // attacklab: hack around Konqueror 3.5.4 bug:
  2818. pre = pre.replace(/^ /mg, '¨0');
  2819. pre = pre.replace(/¨0/g, '');
  2820. return pre;
  2821. });
  2822. return showdown.subParser('hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals);
  2823. });
  2824. text = globals.converter._dispatch('blockQuotes.after', text, options, globals);
  2825. return text;
  2826. });
  2827. /**
  2828. * Process Markdown `<pre><code>` blocks.
  2829. */
  2830. showdown.subParser('codeBlocks', function (text, options, globals) {
  2831. 'use strict';
  2832. text = globals.converter._dispatch('codeBlocks.before', text, options, globals);
  2833. // sentinel workarounds for lack of \A and \Z, safari\khtml bug
  2834. text += '¨0';
  2835. var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=¨0))/g;
  2836. text = text.replace(pattern, function (wholeMatch, m1, m2) {
  2837. var codeblock = m1,
  2838. nextChar = m2,
  2839. end = '\n';
  2840. codeblock = showdown.subParser('outdent')(codeblock, options, globals);
  2841. codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
  2842. codeblock = showdown.subParser('detab')(codeblock, options, globals);
  2843. codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
  2844. codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines
  2845. if (options.omitExtraWLInCodeBlocks) {
  2846. end = '';
  2847. }
  2848. codeblock = '<pre><code>' + codeblock + end + '</code></pre>';
  2849. return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
  2850. });
  2851. // strip sentinel
  2852. text = text.replace(/¨0/, '');
  2853. text = globals.converter._dispatch('codeBlocks.after', text, options, globals);
  2854. return text;
  2855. });
  2856. /**
  2857. *
  2858. * * Backtick quotes are used for <code></code> spans.
  2859. *
  2860. * * You can use multiple backticks as the delimiters if you want to
  2861. * include literal backticks in the code span. So, this input:
  2862. *
  2863. * Just type ``foo `bar` baz`` at the prompt.
  2864. *
  2865. * Will translate to:
  2866. *
  2867. * <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
  2868. *
  2869. * There's no arbitrary limit to the number of backticks you
  2870. * can use as delimters. If you need three consecutive backticks
  2871. * in your code, use four for delimiters, etc.
  2872. *
  2873. * * You can use spaces to get literal backticks at the edges:
  2874. *
  2875. * ... type `` `bar` `` ...
  2876. *
  2877. * Turns to:
  2878. *
  2879. * ... type <code>`bar`</code> ...
  2880. */
  2881. showdown.subParser('codeSpans', function (text, options, globals) {
  2882. 'use strict';
  2883. text = globals.converter._dispatch('codeSpans.before', text, options, globals);
  2884. if (typeof (text) === 'undefined') {
  2885. text = '';
  2886. }
  2887. text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
  2888. function (wholeMatch, m1, m2, m3) {
  2889. var c = m3;
  2890. c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
  2891. c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
  2892. c = showdown.subParser('encodeCode')(c, options, globals);
  2893. c = m1 + '<code>' + c + '</code>';
  2894. c = showdown.subParser('hashHTMLSpans')(c, options, globals);
  2895. return c;
  2896. }
  2897. );
  2898. text = globals.converter._dispatch('codeSpans.after', text, options, globals);
  2899. return text;
  2900. });
  2901. /**
  2902. * Create a full HTML document from the processed markdown
  2903. */
  2904. showdown.subParser('completeHTMLDocument', function (text, options, globals) {
  2905. 'use strict';
  2906. if (!options.completeHTMLDocument) {
  2907. return text;
  2908. }
  2909. text = globals.converter._dispatch('completeHTMLDocument.before', text, options, globals);
  2910. var doctype = 'html',
  2911. doctypeParsed = '<!DOCTYPE HTML>\n',
  2912. title = '',
  2913. charset = '<meta charset="utf-8">\n',
  2914. lang = '',
  2915. metadata = '';
  2916. if (typeof globals.metadata.parsed.doctype !== 'undefined') {
  2917. doctypeParsed = '<!DOCTYPE ' + globals.metadata.parsed.doctype + '>\n';
  2918. doctype = globals.metadata.parsed.doctype.toString().toLowerCase();
  2919. if (doctype === 'html' || doctype === 'html5') {
  2920. charset = '<meta charset="utf-8">';
  2921. }
  2922. }
  2923. for (var meta in globals.metadata.parsed) {
  2924. if (globals.metadata.parsed.hasOwnProperty(meta)) {
  2925. switch (meta.toLowerCase()) {
  2926. case 'doctype':
  2927. break;
  2928. case 'title':
  2929. title = '<title>' + globals.metadata.parsed.title + '</title>\n';
  2930. break;
  2931. case 'charset':
  2932. if (doctype === 'html' || doctype === 'html5') {
  2933. charset = '<meta charset="' + globals.metadata.parsed.charset + '">\n';
  2934. } else {
  2935. charset = '<meta name="charset" content="' + globals.metadata.parsed.charset + '">\n';
  2936. }
  2937. break;
  2938. case 'language':
  2939. case 'lang':
  2940. lang = ' lang="' + globals.metadata.parsed[meta] + '"';
  2941. metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n';
  2942. break;
  2943. default:
  2944. metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n';
  2945. }
  2946. }
  2947. }
  2948. text = doctypeParsed + '<html' + lang + '>\n<head>\n' + title + charset + metadata + '</head>\n<body>\n' + text.trim() + '\n</body>\n</html>';
  2949. text = globals.converter._dispatch('completeHTMLDocument.after', text, options, globals);
  2950. return text;
  2951. });
  2952. /**
  2953. * Convert all tabs to spaces
  2954. */
  2955. showdown.subParser('detab', function (text, options, globals) {
  2956. 'use strict';
  2957. text = globals.converter._dispatch('detab.before', text, options, globals);
  2958. // expand first n-1 tabs
  2959. text = text.replace(/\t(?=\t)/g, ' '); // g_tab_width
  2960. // replace the nth with two sentinels
  2961. text = text.replace(/\t/g, '¨A¨B');
  2962. // use the sentinel to anchor our regex so it doesn't explode
  2963. text = text.replace(/¨B(.+?)¨A/g, function (wholeMatch, m1) {
  2964. var leadingText = m1,
  2965. numSpaces = 4 - leadingText.length % 4; // g_tab_width
  2966. // there *must* be a better way to do this:
  2967. for (var i = 0; i < numSpaces; i++) {
  2968. leadingText += ' ';
  2969. }
  2970. return leadingText;
  2971. });
  2972. // clean up sentinels
  2973. text = text.replace(/¨A/g, ' '); // g_tab_width
  2974. text = text.replace(/¨B/g, '');
  2975. text = globals.converter._dispatch('detab.after', text, options, globals);
  2976. return text;
  2977. });
  2978. showdown.subParser('ellipsis', function (text, options, globals) {
  2979. 'use strict';
  2980. if (!options.ellipsis) {
  2981. return text;
  2982. }
  2983. text = globals.converter._dispatch('ellipsis.before', text, options, globals);
  2984. text = text.replace(/\.\.\./g, '…');
  2985. text = globals.converter._dispatch('ellipsis.after', text, options, globals);
  2986. return text;
  2987. });
  2988. /**
  2989. * Turn emoji codes into emojis
  2990. *
  2991. * List of supported emojis: https://github.com/showdownjs/showdown/wiki/Emojis
  2992. */
  2993. showdown.subParser('emoji', function (text, options, globals) {
  2994. 'use strict';
  2995. if (!options.emoji) {
  2996. return text;
  2997. }
  2998. text = globals.converter._dispatch('emoji.before', text, options, globals);
  2999. var emojiRgx = /:([\S]+?):/g;
  3000. text = text.replace(emojiRgx, function (wm, emojiCode) {
  3001. if (showdown.helper.emojis.hasOwnProperty(emojiCode)) {
  3002. return showdown.helper.emojis[emojiCode];
  3003. }
  3004. return wm;
  3005. });
  3006. text = globals.converter._dispatch('emoji.after', text, options, globals);
  3007. return text;
  3008. });
  3009. /**
  3010. * Smart processing for ampersands and angle brackets that need to be encoded.
  3011. */
  3012. showdown.subParser('encodeAmpsAndAngles', function (text, options, globals) {
  3013. 'use strict';
  3014. text = globals.converter._dispatch('encodeAmpsAndAngles.before', text, options, globals);
  3015. // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
  3016. // http://bumppo.net/projects/amputator/
  3017. text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, '&amp;');
  3018. // Encode naked <'s
  3019. text = text.replace(/<(?![a-z\/?$!])/gi, '&lt;');
  3020. // Encode <
  3021. text = text.replace(/</g, '&lt;');
  3022. // Encode >
  3023. text = text.replace(/>/g, '&gt;');
  3024. text = globals.converter._dispatch('encodeAmpsAndAngles.after', text, options, globals);
  3025. return text;
  3026. });
  3027. /**
  3028. * Returns the string, with after processing the following backslash escape sequences.
  3029. *
  3030. * attacklab: The polite way to do this is with the new escapeCharacters() function:
  3031. *
  3032. * text = escapeCharacters(text,"\\",true);
  3033. * text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
  3034. *
  3035. * ...but we're sidestepping its use of the (slow) RegExp constructor
  3036. * as an optimization for Firefox. This function gets called a LOT.
  3037. */
  3038. showdown.subParser('encodeBackslashEscapes', function (text, options, globals) {
  3039. 'use strict';
  3040. text = globals.converter._dispatch('encodeBackslashEscapes.before', text, options, globals);
  3041. text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback);
  3042. text = text.replace(/\\([`*_{}\[\]()>#+.!~=|:-])/g, showdown.helper.escapeCharactersCallback);
  3043. text = globals.converter._dispatch('encodeBackslashEscapes.after', text, options, globals);
  3044. return text;
  3045. });
  3046. /**
  3047. * Encode/escape certain characters inside Markdown code runs.
  3048. * The point is that in code, these characters are literals,
  3049. * and lose their special Markdown meanings.
  3050. */
  3051. showdown.subParser('encodeCode', function (text, options, globals) {
  3052. 'use strict';
  3053. text = globals.converter._dispatch('encodeCode.before', text, options, globals);
  3054. // Encode all ampersands; HTML entities are not
  3055. // entities within a Markdown code span.
  3056. text = text
  3057. .replace(/&/g, '&amp;')
  3058. // Do the angle bracket song and dance:
  3059. .replace(/</g, '&lt;')
  3060. .replace(/>/g, '&gt;')
  3061. // Now, escape characters that are magic in Markdown:
  3062. .replace(/([*_{}\[\]\\=~-])/g, showdown.helper.escapeCharactersCallback);
  3063. text = globals.converter._dispatch('encodeCode.after', text, options, globals);
  3064. return text;
  3065. });
  3066. /**
  3067. * Within tags -- meaning between < and > -- encode [\ ` * _ ~ =] so they
  3068. * don't conflict with their use in Markdown for code, italics and strong.
  3069. */
  3070. showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text, options, globals) {
  3071. 'use strict';
  3072. text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.before', text, options, globals);
  3073. // Build a regex to find HTML tags.
  3074. var tags = /<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi,
  3075. comments = /<!(--(?:(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>/gi;
  3076. text = text.replace(tags, function (wholeMatch) {
  3077. return wholeMatch
  3078. .replace(/(.)<\/?code>(?=.)/g, '$1`')
  3079. .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
  3080. });
  3081. text = text.replace(comments, function (wholeMatch) {
  3082. return wholeMatch
  3083. .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
  3084. });
  3085. text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.after', text, options, globals);
  3086. return text;
  3087. });
  3088. /**
  3089. * Handle github codeblocks prior to running HashHTML so that
  3090. * HTML contained within the codeblock gets escaped properly
  3091. * Example:
  3092. * ```ruby
  3093. * def hello_world(x)
  3094. * puts "Hello, #{x}"
  3095. * end
  3096. * ```
  3097. */
  3098. showdown.subParser('githubCodeBlocks', function (text, options, globals) {
  3099. 'use strict';
  3100. // early exit if option is not enabled
  3101. if (!options.ghCodeBlocks) {
  3102. return text;
  3103. }
  3104. text = globals.converter._dispatch('githubCodeBlocks.before', text, options, globals);
  3105. text += '¨0';
  3106. text = text.replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g, function (wholeMatch, delim, language, codeblock) {
  3107. var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
  3108. // First parse the github code block
  3109. codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
  3110. codeblock = showdown.subParser('detab')(codeblock, options, globals);
  3111. codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
  3112. codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
  3113. codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>';
  3114. codeblock = showdown.subParser('hashBlock')(codeblock, options, globals);
  3115. // Since GHCodeblocks can be false positives, we need to
  3116. // store the primitive text and the parsed text in a global var,
  3117. // and then return a token
  3118. return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
  3119. });
  3120. // attacklab: strip sentinel
  3121. text = text.replace(/¨0/, '');
  3122. return globals.converter._dispatch('githubCodeBlocks.after', text, options, globals);
  3123. });
  3124. showdown.subParser('hashBlock', function (text, options, globals) {
  3125. 'use strict';
  3126. text = globals.converter._dispatch('hashBlock.before', text, options, globals);
  3127. text = text.replace(/(^\n+|\n+$)/g, '');
  3128. text = '\n\n¨K' + (globals.gHtmlBlocks.push(text) - 1) + 'K\n\n';
  3129. text = globals.converter._dispatch('hashBlock.after', text, options, globals);
  3130. return text;
  3131. });
  3132. /**
  3133. * Hash and escape <code> elements that should not be parsed as markdown
  3134. */
  3135. showdown.subParser('hashCodeTags', function (text, options, globals) {
  3136. 'use strict';
  3137. text = globals.converter._dispatch('hashCodeTags.before', text, options, globals);
  3138. var repFunc = function (wholeMatch, match, left, right) {
  3139. var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right;
  3140. return '¨C' + (globals.gHtmlSpans.push(codeblock) - 1) + 'C';
  3141. };
  3142. // Hash naked <code>
  3143. text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '<code\\b[^>]*>', '</code>', 'gim');
  3144. text = globals.converter._dispatch('hashCodeTags.after', text, options, globals);
  3145. return text;
  3146. });
  3147. showdown.subParser('hashElement', function (text, options, globals) {
  3148. 'use strict';
  3149. return function (wholeMatch, m1) {
  3150. var blockText = m1;
  3151. // Undo double lines
  3152. blockText = blockText.replace(/\n\n/g, '\n');
  3153. blockText = blockText.replace(/^\n/, '');
  3154. // strip trailing blank lines
  3155. blockText = blockText.replace(/\n+$/g, '');
  3156. // Replace the element text with a marker ("¨KxK" where x is its key)
  3157. blockText = '\n\n¨K' + (globals.gHtmlBlocks.push(blockText) - 1) + 'K\n\n';
  3158. return blockText;
  3159. };
  3160. });
  3161. showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
  3162. 'use strict';
  3163. text = globals.converter._dispatch('hashHTMLBlocks.before', text, options, globals);
  3164. var blockTags = [
  3165. 'pre',
  3166. 'div',
  3167. 'h1',
  3168. 'h2',
  3169. 'h3',
  3170. 'h4',
  3171. 'h5',
  3172. 'h6',
  3173. 'blockquote',
  3174. 'table',
  3175. 'dl',
  3176. 'ol',
  3177. 'ul',
  3178. 'script',
  3179. 'noscript',
  3180. 'form',
  3181. 'fieldset',
  3182. 'iframe',
  3183. 'math',
  3184. 'style',
  3185. 'section',
  3186. 'header',
  3187. 'footer',
  3188. 'nav',
  3189. 'article',
  3190. 'aside',
  3191. 'address',
  3192. 'audio',
  3193. 'canvas',
  3194. 'figure',
  3195. 'hgroup',
  3196. 'output',
  3197. 'video',
  3198. 'p'
  3199. ],
  3200. repFunc = function (wholeMatch, match, left, right) {
  3201. var txt = wholeMatch;
  3202. // check if this html element is marked as markdown
  3203. // if so, it's contents should be parsed as markdown
  3204. if (left.search(/\bmarkdown\b/) !== -1) {
  3205. txt = left + globals.converter.makeHtml(match) + right;
  3206. }
  3207. return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
  3208. };
  3209. if (options.backslashEscapesHTMLTags) {
  3210. // encode backslash escaped HTML tags
  3211. text = text.replace(/\\<(\/?[^>]+?)>/g, function (wm, inside) {
  3212. return '&lt;' + inside + '&gt;';
  3213. });
  3214. }
  3215. // hash HTML Blocks
  3216. for (var i = 0; i < blockTags.length; ++i) {
  3217. var opTagPos,
  3218. rgx1 = new RegExp('^ {0,3}(<' + blockTags[i] + '\\b[^>]*>)', 'im'),
  3219. patLeft = '<' + blockTags[i] + '\\b[^>]*>',
  3220. patRight = '</' + blockTags[i] + '>';
  3221. // 1. Look for the first position of the first opening HTML tag in the text
  3222. while ((opTagPos = showdown.helper.regexIndexOf(text, rgx1)) !== -1) {
  3223. // if the HTML tag is \ escaped, we need to escape it and break
  3224. //2. Split the text in that position
  3225. var subTexts = showdown.helper.splitAtIndex(text, opTagPos),
  3226. //3. Match recursively
  3227. newSubText1 = showdown.helper.replaceRecursiveRegExp(subTexts[1], repFunc, patLeft, patRight, 'im');
  3228. // prevent an infinite loop
  3229. if (newSubText1 === subTexts[1]) {
  3230. break;
  3231. }
  3232. text = subTexts[0].concat(newSubText1);
  3233. }
  3234. }
  3235. // HR SPECIAL CASE
  3236. text = text.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,
  3237. showdown.subParser('hashElement')(text, options, globals));
  3238. // Special case for standalone HTML comments
  3239. text = showdown.helper.replaceRecursiveRegExp(text, function (txt) {
  3240. return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
  3241. }, '^ {0,3}<!--', '-->', 'gm');
  3242. // PHP and ASP-style processor instructions (<?...?> and <%...%>)
  3243. text = text.replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,
  3244. showdown.subParser('hashElement')(text, options, globals));
  3245. text = globals.converter._dispatch('hashHTMLBlocks.after', text, options, globals);
  3246. return text;
  3247. });
  3248. /**
  3249. * Hash span elements that should not be parsed as markdown
  3250. */
  3251. showdown.subParser('hashHTMLSpans', function (text, options, globals) {
  3252. 'use strict';
  3253. text = globals.converter._dispatch('hashHTMLSpans.before', text, options, globals);
  3254. function hashHTMLSpan (html) {
  3255. return '¨C' + (globals.gHtmlSpans.push(html) - 1) + 'C';
  3256. }
  3257. // Hash Self Closing tags
  3258. text = text.replace(/<[^>]+?\/>/gi, function (wm) {
  3259. return hashHTMLSpan(wm);
  3260. });
  3261. // Hash tags without properties
  3262. text = text.replace(/<([^>]+?)>[\s\S]*?<\/\1>/g, function (wm) {
  3263. return hashHTMLSpan(wm);
  3264. });
  3265. // Hash tags with properties
  3266. text = text.replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g, function (wm) {
  3267. return hashHTMLSpan(wm);
  3268. });
  3269. // Hash self closing tags without />
  3270. text = text.replace(/<[^>]+?>/gi, function (wm) {
  3271. return hashHTMLSpan(wm);
  3272. });
  3273. /*showdown.helper.matchRecursiveRegExp(text, '<code\\b[^>]*>', '</code>', 'gi');*/
  3274. text = globals.converter._dispatch('hashHTMLSpans.after', text, options, globals);
  3275. return text;
  3276. });
  3277. /**
  3278. * Unhash HTML spans
  3279. */
  3280. showdown.subParser('unhashHTMLSpans', function (text, options, globals) {
  3281. 'use strict';
  3282. text = globals.converter._dispatch('unhashHTMLSpans.before', text, options, globals);
  3283. for (var i = 0; i < globals.gHtmlSpans.length; ++i) {
  3284. var repText = globals.gHtmlSpans[i],
  3285. // limiter to prevent infinite loop (assume 10 as limit for recurse)
  3286. limit = 0;
  3287. while (/¨C(\d+)C/.test(repText)) {
  3288. var num = RegExp.$1;
  3289. repText = repText.replace('¨C' + num + 'C', globals.gHtmlSpans[num]);
  3290. if (limit === 10) {
  3291. console.error('maximum nesting of 10 spans reached!!!');
  3292. break;
  3293. }
  3294. ++limit;
  3295. }
  3296. text = text.replace('¨C' + i + 'C', repText);
  3297. }
  3298. text = globals.converter._dispatch('unhashHTMLSpans.after', text, options, globals);
  3299. return text;
  3300. });
  3301. /**
  3302. * Hash and escape <pre><code> elements that should not be parsed as markdown
  3303. */
  3304. showdown.subParser('hashPreCodeTags', function (text, options, globals) {
  3305. 'use strict';
  3306. text = globals.converter._dispatch('hashPreCodeTags.before', text, options, globals);
  3307. var repFunc = function (wholeMatch, match, left, right) {
  3308. // encode html entities
  3309. var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right;
  3310. return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
  3311. };
  3312. // Hash <pre><code>
  3313. text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^ {0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>', '^ {0,3}</code>\\s*</pre>', 'gim');
  3314. text = globals.converter._dispatch('hashPreCodeTags.after', text, options, globals);
  3315. return text;
  3316. });
  3317. showdown.subParser('headers', function (text, options, globals) {
  3318. 'use strict';
  3319. text = globals.converter._dispatch('headers.before', text, options, globals);
  3320. var headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart),
  3321. // Set text-style headers:
  3322. // Header 1
  3323. // ========
  3324. //
  3325. // Header 2
  3326. // --------
  3327. //
  3328. setextRegexH1 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm,
  3329. setextRegexH2 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm;
  3330. text = text.replace(setextRegexH1, function (wholeMatch, m1) {
  3331. var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
  3332. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
  3333. hLevel = headerLevelStart,
  3334. hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
  3335. return showdown.subParser('hashBlock')(hashBlock, options, globals);
  3336. });
  3337. text = text.replace(setextRegexH2, function (matchFound, m1) {
  3338. var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
  3339. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
  3340. hLevel = headerLevelStart + 1,
  3341. hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
  3342. return showdown.subParser('hashBlock')(hashBlock, options, globals);
  3343. });
  3344. // atx-style headers:
  3345. // # Header 1
  3346. // ## Header 2
  3347. // ## Header 2 with closing hashes ##
  3348. // ...
  3349. // ###### Header 6
  3350. //
  3351. var atxStyle = (options.requireSpaceBeforeHeadingText) ? /^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm : /^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm;
  3352. text = text.replace(atxStyle, function (wholeMatch, m1, m2) {
  3353. var hText = m2;
  3354. if (options.customizedHeaderId) {
  3355. hText = m2.replace(/\s?\{([^{]+?)}\s*$/, '');
  3356. }
  3357. var span = showdown.subParser('spanGamut')(hText, options, globals),
  3358. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
  3359. hLevel = headerLevelStart - 1 + m1.length,
  3360. header = '<h' + hLevel + hID + '>' + span + '</h' + hLevel + '>';
  3361. return showdown.subParser('hashBlock')(header, options, globals);
  3362. });
  3363. function headerId (m) {
  3364. var title,
  3365. prefix;
  3366. // It is separate from other options to allow combining prefix and customized
  3367. if (options.customizedHeaderId) {
  3368. var match = m.match(/\{([^{]+?)}\s*$/);
  3369. if (match && match[1]) {
  3370. m = match[1];
  3371. }
  3372. }
  3373. title = m;
  3374. // Prefix id to prevent causing inadvertent pre-existing style matches.
  3375. if (showdown.helper.isString(options.prefixHeaderId)) {
  3376. prefix = options.prefixHeaderId;
  3377. } else if (options.prefixHeaderId === true) {
  3378. prefix = 'section-';
  3379. } else {
  3380. prefix = '';
  3381. }
  3382. if (!options.rawPrefixHeaderId) {
  3383. title = prefix + title;
  3384. }
  3385. if (options.ghCompatibleHeaderId) {
  3386. title = title
  3387. .replace(/ /g, '-')
  3388. // replace previously escaped chars (&, ¨ and $)
  3389. .replace(/&amp;/g, '')
  3390. .replace(/¨T/g, '')
  3391. .replace(/¨D/g, '')
  3392. // replace rest of the chars (&~$ are repeated as they might have been escaped)
  3393. // borrowed from github's redcarpet (some they should produce similar results)
  3394. .replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, '')
  3395. .toLowerCase();
  3396. } else if (options.rawHeaderId) {
  3397. title = title
  3398. .replace(/ /g, '-')
  3399. // replace previously escaped chars (&, ¨ and $)
  3400. .replace(/&amp;/g, '&')
  3401. .replace(/¨T/g, '¨')
  3402. .replace(/¨D/g, '$')
  3403. // replace " and '
  3404. .replace(/["']/g, '-')
  3405. .toLowerCase();
  3406. } else {
  3407. title = title
  3408. .replace(/[^\w]/g, '')
  3409. .toLowerCase();
  3410. }
  3411. if (options.rawPrefixHeaderId) {
  3412. title = prefix + title;
  3413. }
  3414. if (globals.hashLinkCounts[title]) {
  3415. title = title + '-' + (globals.hashLinkCounts[title]++);
  3416. } else {
  3417. globals.hashLinkCounts[title] = 1;
  3418. }
  3419. return title;
  3420. }
  3421. text = globals.converter._dispatch('headers.after', text, options, globals);
  3422. return text;
  3423. });
  3424. /**
  3425. * Turn Markdown link shortcuts into XHTML <a> tags.
  3426. */
  3427. showdown.subParser('horizontalRule', function (text, options, globals) {
  3428. 'use strict';
  3429. text = globals.converter._dispatch('horizontalRule.before', text, options, globals);
  3430. var key = showdown.subParser('hashBlock')('<hr />', options, globals);
  3431. text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, key);
  3432. text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, key);
  3433. text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, key);
  3434. text = globals.converter._dispatch('horizontalRule.after', text, options, globals);
  3435. return text;
  3436. });
  3437. /**
  3438. * Turn Markdown image shortcuts into <img> tags.
  3439. */
  3440. showdown.subParser('images', function (text, options, globals) {
  3441. 'use strict';
  3442. text = globals.converter._dispatch('images.before', text, options, globals);
  3443. var inlineRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
  3444. crazyRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g,
  3445. base64RegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
  3446. referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g,
  3447. refShortcutRegExp = /!\[([^\[\]]+)]()()()()()/g;
  3448. function writeImageTagBase64 (wholeMatch, altText, linkId, url, width, height, m5, title) {
  3449. url = url.replace(/\s/g, '');
  3450. return writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title);
  3451. }
  3452. function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) {
  3453. var gUrls = globals.gUrls,
  3454. gTitles = globals.gTitles,
  3455. gDims = globals.gDimensions;
  3456. linkId = linkId.toLowerCase();
  3457. if (!title) {
  3458. title = '';
  3459. }
  3460. // Special case for explicit empty url
  3461. if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) {
  3462. url = '';
  3463. } else if (url === '' || url === null) {
  3464. if (linkId === '' || linkId === null) {
  3465. // lower-case and turn embedded newlines into spaces
  3466. linkId = altText.toLowerCase().replace(/ ?\n/g, ' ');
  3467. }
  3468. url = '#' + linkId;
  3469. if (!showdown.helper.isUndefined(gUrls[linkId])) {
  3470. url = gUrls[linkId];
  3471. if (!showdown.helper.isUndefined(gTitles[linkId])) {
  3472. title = gTitles[linkId];
  3473. }
  3474. if (!showdown.helper.isUndefined(gDims[linkId])) {
  3475. width = gDims[linkId].width;
  3476. height = gDims[linkId].height;
  3477. }
  3478. } else {
  3479. return wholeMatch;
  3480. }
  3481. }
  3482. altText = altText
  3483. .replace(/"/g, '&quot;')
  3484. //altText = showdown.helper.escapeCharacters(altText, '*_', false);
  3485. .replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  3486. //url = showdown.helper.escapeCharacters(url, '*_', false);
  3487. url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  3488. var result = '<img src="' + url + '" alt="' + altText + '"';
  3489. if (title && showdown.helper.isString(title)) {
  3490. title = title
  3491. .replace(/"/g, '&quot;')
  3492. //title = showdown.helper.escapeCharacters(title, '*_', false);
  3493. .replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  3494. result += ' title="' + title + '"';
  3495. }
  3496. if (width && height) {
  3497. width = (width === '*') ? 'auto' : width;
  3498. height = (height === '*') ? 'auto' : height;
  3499. result += ' width="' + width + '"';
  3500. result += ' height="' + height + '"';
  3501. }
  3502. result += ' />';
  3503. return result;
  3504. }
  3505. // First, handle reference-style labeled images: ![alt text][id]
  3506. text = text.replace(referenceRegExp, writeImageTag);
  3507. // Next, handle inline images: ![alt text](url =<width>x<height> "optional title")
  3508. // base64 encoded images
  3509. text = text.replace(base64RegExp, writeImageTagBase64);
  3510. // cases with crazy urls like ./image/cat1).png
  3511. text = text.replace(crazyRegExp, writeImageTag);
  3512. // normal cases
  3513. text = text.replace(inlineRegExp, writeImageTag);
  3514. // handle reference-style shortcuts: ![img text]
  3515. text = text.replace(refShortcutRegExp, writeImageTag);
  3516. text = globals.converter._dispatch('images.after', text, options, globals);
  3517. return text;
  3518. });
  3519. showdown.subParser('italicsAndBold', function (text, options, globals) {
  3520. 'use strict';
  3521. text = globals.converter._dispatch('italicsAndBold.before', text, options, globals);
  3522. // it's faster to have 3 separate regexes for each case than have just one
  3523. // because of backtracing, in some cases, it could lead to an exponential effect
  3524. // called "catastrophic backtrace". Ominous!
  3525. function parseInside (txt, left, right) {
  3526. /*
  3527. if (options.simplifiedAutoLink) {
  3528. txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
  3529. }
  3530. */
  3531. return left + txt + right;
  3532. }
  3533. // Parse underscores
  3534. if (options.literalMidWordUnderscores) {
  3535. text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
  3536. return parseInside (txt, '<strong><em>', '</em></strong>');
  3537. });
  3538. text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
  3539. return parseInside (txt, '<strong>', '</strong>');
  3540. });
  3541. text = text.replace(/\b_(\S[\s\S]*?)_\b/g, function (wm, txt) {
  3542. return parseInside (txt, '<em>', '</em>');
  3543. });
  3544. } else {
  3545. text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
  3546. return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
  3547. });
  3548. text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
  3549. return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
  3550. });
  3551. text = text.replace(/_([^\s_][\s\S]*?)_/g, function (wm, m) {
  3552. // !/^_[^_]/.test(m) - test if it doesn't start with __ (since it seems redundant, we removed it)
  3553. return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
  3554. });
  3555. }
  3556. // Now parse asterisks
  3557. if (options.literalMidWordAsterisks) {
  3558. text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]*?)\*\*\*\B(?!\*)/g, function (wm, lead, txt) {
  3559. return parseInside (txt, lead + '<strong><em>', '</em></strong>');
  3560. });
  3561. text = text.replace(/([^*]|^)\B\*\*(\S[\s\S]*?)\*\*\B(?!\*)/g, function (wm, lead, txt) {
  3562. return parseInside (txt, lead + '<strong>', '</strong>');
  3563. });
  3564. text = text.replace(/([^*]|^)\B\*(\S[\s\S]*?)\*\B(?!\*)/g, function (wm, lead, txt) {
  3565. return parseInside (txt, lead + '<em>', '</em>');
  3566. });
  3567. } else {
  3568. text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
  3569. return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
  3570. });
  3571. text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
  3572. return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
  3573. });
  3574. text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function (wm, m) {
  3575. // !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it)
  3576. return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
  3577. });
  3578. }
  3579. text = globals.converter._dispatch('italicsAndBold.after', text, options, globals);
  3580. return text;
  3581. });
  3582. /**
  3583. * Form HTML ordered (numbered) and unordered (bulleted) lists.
  3584. */
  3585. showdown.subParser('lists', function (text, options, globals) {
  3586. 'use strict';
  3587. /**
  3588. * Process the contents of a single ordered or unordered list, splitting it
  3589. * into individual list items.
  3590. * @param {string} listStr
  3591. * @param {boolean} trimTrailing
  3592. * @returns {string}
  3593. */
  3594. function processListItems (listStr, trimTrailing) {
  3595. // The $g_list_level global keeps track of when we're inside a list.
  3596. // Each time we enter a list, we increment it; when we leave a list,
  3597. // we decrement. If it's zero, we're not in a list anymore.
  3598. //
  3599. // We do this because when we're not inside a list, we want to treat
  3600. // something like this:
  3601. //
  3602. // I recommend upgrading to version
  3603. // 8. Oops, now this line is treated
  3604. // as a sub-list.
  3605. //
  3606. // As a single paragraph, despite the fact that the second line starts
  3607. // with a digit-period-space sequence.
  3608. //
  3609. // Whereas when we're inside a list (or sub-list), that line will be
  3610. // treated as the start of a sub-list. What a kludge, huh? This is
  3611. // an aspect of Markdown's syntax that's hard to parse perfectly
  3612. // without resorting to mind-reading. Perhaps the solution is to
  3613. // change the syntax rules such that sub-lists must start with a
  3614. // starting cardinal number; e.g. "1." or "a.".
  3615. globals.gListLevel++;
  3616. // trim trailing blank lines:
  3617. listStr = listStr.replace(/\n{2,}$/, '\n');
  3618. // attacklab: add sentinel to emulate \z
  3619. listStr += '¨0';
  3620. var rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm,
  3621. isParagraphed = (/\n[ \t]*\n(?!¨0)/.test(listStr));
  3622. // Since version 1.5, nesting sublists requires 4 spaces (or 1 tab) indentation,
  3623. // which is a syntax breaking change
  3624. // activating this option reverts to old behavior
  3625. if (options.disableForced4SpacesIndentedSublists) {
  3626. rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm;
  3627. }
  3628. listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
  3629. checked = (checked && checked.trim() !== '');
  3630. var item = showdown.subParser('outdent')(m4, options, globals),
  3631. bulletStyle = '';
  3632. // Support for github tasklists
  3633. if (taskbtn && options.tasklists) {
  3634. bulletStyle = ' class="task-list-item" style="list-style-type: none;"';
  3635. item = item.replace(/^[ \t]*\[(x|X| )?]/m, function () {
  3636. var otp = '<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';
  3637. if (checked) {
  3638. otp += ' checked';
  3639. }
  3640. otp += '>';
  3641. return otp;
  3642. });
  3643. }
  3644. // ISSUE #312
  3645. // This input: - - - a
  3646. // causes trouble to the parser, since it interprets it as:
  3647. // <ul><li><li><li>a</li></li></li></ul>
  3648. // instead of:
  3649. // <ul><li>- - a</li></ul>
  3650. // So, to prevent it, we will put a marker (¨A)in the beginning of the line
  3651. // Kind of hackish/monkey patching, but seems more effective than overcomplicating the list parser
  3652. item = item.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g, function (wm2) {
  3653. return '¨A' + wm2;
  3654. });
  3655. // m1 - Leading line or
  3656. // Has a double return (multi paragraph) or
  3657. // Has sublist
  3658. if (m1 || (item.search(/\n{2,}/) > -1)) {
  3659. item = showdown.subParser('githubCodeBlocks')(item, options, globals);
  3660. item = showdown.subParser('blockGamut')(item, options, globals);
  3661. } else {
  3662. // Recursion for sub-lists:
  3663. item = showdown.subParser('lists')(item, options, globals);
  3664. item = item.replace(/\n$/, ''); // chomp(item)
  3665. item = showdown.subParser('hashHTMLBlocks')(item, options, globals);
  3666. // Colapse double linebreaks
  3667. item = item.replace(/\n\n+/g, '\n\n');
  3668. if (isParagraphed) {
  3669. item = showdown.subParser('paragraphs')(item, options, globals);
  3670. } else {
  3671. item = showdown.subParser('spanGamut')(item, options, globals);
  3672. }
  3673. }
  3674. // now we need to remove the marker (¨A)
  3675. item = item.replace('¨A', '');
  3676. // we can finally wrap the line in list item tags
  3677. item = '<li' + bulletStyle + '>' + item + '</li>\n';
  3678. return item;
  3679. });
  3680. // attacklab: strip sentinel
  3681. listStr = listStr.replace(/¨0/g, '');
  3682. globals.gListLevel--;
  3683. if (trimTrailing) {
  3684. listStr = listStr.replace(/\s+$/, '');
  3685. }
  3686. return listStr;
  3687. }
  3688. function styleStartNumber (list, listType) {
  3689. // check if ol and starts by a number different than 1
  3690. if (listType === 'ol') {
  3691. var res = list.match(/^ *(\d+)\./);
  3692. if (res && res[1] !== '1') {
  3693. return ' start="' + res[1] + '"';
  3694. }
  3695. }
  3696. return '';
  3697. }
  3698. /**
  3699. * Check and parse consecutive lists (better fix for issue #142)
  3700. * @param {string} list
  3701. * @param {string} listType
  3702. * @param {boolean} trimTrailing
  3703. * @returns {string}
  3704. */
  3705. function parseConsecutiveLists (list, listType, trimTrailing) {
  3706. // check if we caught 2 or more consecutive lists by mistake
  3707. // we use the counterRgx, meaning if listType is UL we look for OL and vice versa
  3708. var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm,
  3709. ulRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?[*+-][ \t]/gm : /^ {0,3}[*+-][ \t]/gm,
  3710. counterRxg = (listType === 'ul') ? olRgx : ulRgx,
  3711. result = '';
  3712. if (list.search(counterRxg) !== -1) {
  3713. (function parseCL (txt) {
  3714. var pos = txt.search(counterRxg),
  3715. style = styleStartNumber(list, listType);
  3716. if (pos !== -1) {
  3717. // slice
  3718. result += '\n\n<' + listType + style + '>\n' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n';
  3719. // invert counterType and listType
  3720. listType = (listType === 'ul') ? 'ol' : 'ul';
  3721. counterRxg = (listType === 'ul') ? olRgx : ulRgx;
  3722. //recurse
  3723. parseCL(txt.slice(pos));
  3724. } else {
  3725. result += '\n\n<' + listType + style + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
  3726. }
  3727. })(list);
  3728. } else {
  3729. var style = styleStartNumber(list, listType);
  3730. result = '\n\n<' + listType + style + '>\n' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n';
  3731. }
  3732. return result;
  3733. }
  3734. /** Start of list parsing **/
  3735. text = globals.converter._dispatch('lists.before', text, options, globals);
  3736. // add sentinel to hack around khtml/safari bug:
  3737. // http://bugs.webkit.org/show_bug.cgi?id=11231
  3738. text += '¨0';
  3739. if (globals.gListLevel) {
  3740. text = text.replace(/^(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
  3741. function (wholeMatch, list, m2) {
  3742. var listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
  3743. return parseConsecutiveLists(list, listType, true);
  3744. }
  3745. );
  3746. } else {
  3747. text = text.replace(/(\n\n|^\n?)(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
  3748. function (wholeMatch, m1, list, m3) {
  3749. var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
  3750. return parseConsecutiveLists(list, listType, false);
  3751. }
  3752. );
  3753. }
  3754. // strip sentinel
  3755. text = text.replace(/¨0/, '');
  3756. text = globals.converter._dispatch('lists.after', text, options, globals);
  3757. return text;
  3758. });
  3759. /**
  3760. * Parse metadata at the top of the document
  3761. */
  3762. showdown.subParser('metadata', function (text, options, globals) {
  3763. 'use strict';
  3764. if (!options.metadata) {
  3765. return text;
  3766. }
  3767. text = globals.converter._dispatch('metadata.before', text, options, globals);
  3768. function parseMetadataContents (content) {
  3769. // raw is raw so it's not changed in any way
  3770. globals.metadata.raw = content;
  3771. // escape chars forbidden in html attributes
  3772. // double quotes
  3773. content = content
  3774. // ampersand first
  3775. .replace(/&/g, '&amp;')
  3776. // double quotes
  3777. .replace(/"/g, '&quot;');
  3778. content = content.replace(/\n {4}/g, ' ');
  3779. content.replace(/^([\S ]+): +([\s\S]+?)$/gm, function (wm, key, value) {
  3780. globals.metadata.parsed[key] = value;
  3781. return '';
  3782. });
  3783. }
  3784. text = text.replace(/^\s*«««+(\S*?)\n([\s\S]+?)\n»»»+\n/, function (wholematch, format, content) {
  3785. parseMetadataContents(content);
  3786. return '¨M';
  3787. });
  3788. text = text.replace(/^\s*---+(\S*?)\n([\s\S]+?)\n---+\n/, function (wholematch, format, content) {
  3789. if (format) {
  3790. globals.metadata.format = format;
  3791. }
  3792. parseMetadataContents(content);
  3793. return '¨M';
  3794. });
  3795. text = text.replace(/¨M/g, '');
  3796. text = globals.converter._dispatch('metadata.after', text, options, globals);
  3797. return text;
  3798. });
  3799. /**
  3800. * Remove one level of line-leading tabs or spaces
  3801. */
  3802. showdown.subParser('outdent', function (text, options, globals) {
  3803. 'use strict';
  3804. text = globals.converter._dispatch('outdent.before', text, options, globals);
  3805. // attacklab: hack around Konqueror 3.5.4 bug:
  3806. // "----------bug".replace(/^-/g,"") == "bug"
  3807. text = text.replace(/^(\t|[ ]{1,4})/gm, '¨0'); // attacklab: g_tab_width
  3808. // attacklab: clean up hack
  3809. text = text.replace(/¨0/g, '');
  3810. text = globals.converter._dispatch('outdent.after', text, options, globals);
  3811. return text;
  3812. });
  3813. /**
  3814. *
  3815. */
  3816. showdown.subParser('paragraphs', function (text, options, globals) {
  3817. 'use strict';
  3818. text = globals.converter._dispatch('paragraphs.before', text, options, globals);
  3819. // Strip leading and trailing lines:
  3820. text = text.replace(/^\n+/g, '');
  3821. text = text.replace(/\n+$/g, '');
  3822. var grafs = text.split(/\n{2,}/g),
  3823. grafsOut = [],
  3824. end = grafs.length; // Wrap <p> tags
  3825. for (var i = 0; i < end; i++) {
  3826. var str = grafs[i];
  3827. // if this is an HTML marker, copy it
  3828. if (str.search(/¨(K|G)(\d+)\1/g) >= 0) {
  3829. grafsOut.push(str);
  3830. // test for presence of characters to prevent empty lines being parsed
  3831. // as paragraphs (resulting in undesired extra empty paragraphs)
  3832. } else if (str.search(/\S/) >= 0) {
  3833. str = showdown.subParser('spanGamut')(str, options, globals);
  3834. str = str.replace(/^([ \t]*)/g, '<p>');
  3835. str += '</p>';
  3836. grafsOut.push(str);
  3837. }
  3838. }
  3839. /** Unhashify HTML blocks */
  3840. end = grafsOut.length;
  3841. for (i = 0; i < end; i++) {
  3842. var blockText = '',
  3843. grafsOutIt = grafsOut[i],
  3844. codeFlag = false;
  3845. // if this is a marker for an html block...
  3846. // use RegExp.test instead of string.search because of QML bug
  3847. while (/¨(K|G)(\d+)\1/.test(grafsOutIt)) {
  3848. var delim = RegExp.$1,
  3849. num = RegExp.$2;
  3850. if (delim === 'K') {
  3851. blockText = globals.gHtmlBlocks[num];
  3852. } else {
  3853. // we need to check if ghBlock is a false positive
  3854. if (codeFlag) {
  3855. // use encoded version of all text
  3856. blockText = showdown.subParser('encodeCode')(globals.ghCodeBlocks[num].text, options, globals);
  3857. } else {
  3858. blockText = globals.ghCodeBlocks[num].codeblock;
  3859. }
  3860. }
  3861. blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs
  3862. grafsOutIt = grafsOutIt.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/, blockText);
  3863. // Check if grafsOutIt is a pre->code
  3864. if (/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(grafsOutIt)) {
  3865. codeFlag = true;
  3866. }
  3867. }
  3868. grafsOut[i] = grafsOutIt;
  3869. }
  3870. text = grafsOut.join('\n');
  3871. // Strip leading and trailing lines:
  3872. text = text.replace(/^\n+/g, '');
  3873. text = text.replace(/\n+$/g, '');
  3874. return globals.converter._dispatch('paragraphs.after', text, options, globals);
  3875. });
  3876. /**
  3877. * Run extension
  3878. */
  3879. showdown.subParser('runExtension', function (ext, text, options, globals) {
  3880. 'use strict';
  3881. if (ext.filter) {
  3882. text = ext.filter(text, globals.converter, options);
  3883. } else if (ext.regex) {
  3884. // TODO remove this when old extension loading mechanism is deprecated
  3885. var re = ext.regex;
  3886. if (!(re instanceof RegExp)) {
  3887. re = new RegExp(re, 'g');
  3888. }
  3889. text = text.replace(re, ext.replace);
  3890. }
  3891. return text;
  3892. });
  3893. /**
  3894. * These are all the transformations that occur *within* block-level
  3895. * tags like paragraphs, headers, and list items.
  3896. */
  3897. showdown.subParser('spanGamut', function (text, options, globals) {
  3898. 'use strict';
  3899. text = globals.converter._dispatch('spanGamut.before', text, options, globals);
  3900. text = showdown.subParser('codeSpans')(text, options, globals);
  3901. text = showdown.subParser('escapeSpecialCharsWithinTagAttributes')(text, options, globals);
  3902. text = showdown.subParser('encodeBackslashEscapes')(text, options, globals);
  3903. // Process anchor and image tags. Images must come first,
  3904. // because ![foo][f] looks like an anchor.
  3905. text = showdown.subParser('images')(text, options, globals);
  3906. text = showdown.subParser('anchors')(text, options, globals);
  3907. // Make links out of things like `<http://example.com/>`
  3908. // Must come after anchors, because you can use < and >
  3909. // delimiters in inline links like [this](<url>).
  3910. text = showdown.subParser('autoLinks')(text, options, globals);
  3911. text = showdown.subParser('simplifiedAutoLinks')(text, options, globals);
  3912. text = showdown.subParser('emoji')(text, options, globals);
  3913. text = showdown.subParser('underline')(text, options, globals);
  3914. text = showdown.subParser('italicsAndBold')(text, options, globals);
  3915. text = showdown.subParser('strikethrough')(text, options, globals);
  3916. text = showdown.subParser('ellipsis')(text, options, globals);
  3917. // we need to hash HTML tags inside spans
  3918. text = showdown.subParser('hashHTMLSpans')(text, options, globals);
  3919. // now we encode amps and angles
  3920. text = showdown.subParser('encodeAmpsAndAngles')(text, options, globals);
  3921. // Do hard breaks
  3922. if (options.simpleLineBreaks) {
  3923. // GFM style hard breaks
  3924. // only add line breaks if the text does not contain a block (special case for lists)
  3925. if (!/\n\n¨K/.test(text)) {
  3926. text = text.replace(/\n+/g, '<br />\n');
  3927. }
  3928. } else {
  3929. // Vanilla hard breaks
  3930. text = text.replace(/ +\n/g, '<br />\n');
  3931. }
  3932. text = globals.converter._dispatch('spanGamut.after', text, options, globals);
  3933. return text;
  3934. });
  3935. showdown.subParser('strikethrough', function (text, options, globals) {
  3936. 'use strict';
  3937. function parseInside (txt) {
  3938. if (options.simplifiedAutoLink) {
  3939. txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
  3940. }
  3941. return '<del>' + txt + '</del>';
  3942. }
  3943. if (options.strikethrough) {
  3944. text = globals.converter._dispatch('strikethrough.before', text, options, globals);
  3945. text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return parseInside(txt); });
  3946. text = globals.converter._dispatch('strikethrough.after', text, options, globals);
  3947. }
  3948. return text;
  3949. });
  3950. /**
  3951. * Strips link definitions from text, stores the URLs and titles in
  3952. * hash references.
  3953. * Link defs are in the form: ^[id]: url "optional title"
  3954. */
  3955. showdown.subParser('stripLinkDefinitions', function (text, options, globals) {
  3956. 'use strict';
  3957. var regex = /^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm,
  3958. base64Regex = /^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm;
  3959. // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
  3960. text += '¨0';
  3961. var replaceFunc = function (wholeMatch, linkId, url, width, height, blankLines, title) {
  3962. // if there aren't two instances of linkId it must not be a reference link so back out
  3963. linkId = linkId.toLowerCase();
  3964. if (text.toLowerCase().split(linkId).length - 1 < 2) {
  3965. return wholeMatch;
  3966. }
  3967. if (url.match(/^data:.+?\/.+?;base64,/)) {
  3968. // remove newlines
  3969. globals.gUrls[linkId] = url.replace(/\s/g, '');
  3970. } else {
  3971. globals.gUrls[linkId] = showdown.subParser('encodeAmpsAndAngles')(url, options, globals); // Link IDs are case-insensitive
  3972. }
  3973. if (blankLines) {
  3974. // Oops, found blank lines, so it's not a title.
  3975. // Put back the parenthetical statement we stole.
  3976. return blankLines + title;
  3977. } else {
  3978. if (title) {
  3979. globals.gTitles[linkId] = title.replace(/"|'/g, '&quot;');
  3980. }
  3981. if (options.parseImgDimensions && width && height) {
  3982. globals.gDimensions[linkId] = {
  3983. width: width,
  3984. height: height
  3985. };
  3986. }
  3987. }
  3988. // Completely remove the definition from the text
  3989. return '';
  3990. };
  3991. // first we try to find base64 link references
  3992. text = text.replace(base64Regex, replaceFunc);
  3993. text = text.replace(regex, replaceFunc);
  3994. // attacklab: strip sentinel
  3995. text = text.replace(/¨0/, '');
  3996. return text;
  3997. });
  3998. showdown.subParser('tables', function (text, options, globals) {
  3999. 'use strict';
  4000. if (!options.tables) {
  4001. return text;
  4002. }
  4003. var tableRgx = /^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm,
  4004. //singeColTblRgx = /^ {0,3}\|.+\|\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n(?: {0,3}\|.+\|\n)+(?:\n\n|¨0)/gm;
  4005. singeColTblRgx = /^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm;
  4006. function parseStyles (sLine) {
  4007. if (/^:[ \t]*--*$/.test(sLine)) {
  4008. return ' style="text-align:left;"';
  4009. } else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
  4010. return ' style="text-align:right;"';
  4011. } else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) {
  4012. return ' style="text-align:center;"';
  4013. } else {
  4014. return '';
  4015. }
  4016. }
  4017. function parseHeaders (header, style) {
  4018. var id = '';
  4019. header = header.trim();
  4020. // support both tablesHeaderId and tableHeaderId due to error in documentation so we don't break backwards compatibility
  4021. if (options.tablesHeaderId || options.tableHeaderId) {
  4022. id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"';
  4023. }
  4024. header = showdown.subParser('spanGamut')(header, options, globals);
  4025. return '<th' + id + style + '>' + header + '</th>\n';
  4026. }
  4027. function parseCells (cell, style) {
  4028. var subText = showdown.subParser('spanGamut')(cell, options, globals);
  4029. return '<td' + style + '>' + subText + '</td>\n';
  4030. }
  4031. function buildTable (headers, cells) {
  4032. var tb = '<table>\n<thead>\n<tr>\n',
  4033. tblLgn = headers.length;
  4034. for (var i = 0; i < tblLgn; ++i) {
  4035. tb += headers[i];
  4036. }
  4037. tb += '</tr>\n</thead>\n<tbody>\n';
  4038. for (i = 0; i < cells.length; ++i) {
  4039. tb += '<tr>\n';
  4040. for (var ii = 0; ii < tblLgn; ++ii) {
  4041. tb += cells[i][ii];
  4042. }
  4043. tb += '</tr>\n';
  4044. }
  4045. tb += '</tbody>\n</table>\n';
  4046. return tb;
  4047. }
  4048. function parseTable (rawTable) {
  4049. var i, tableLines = rawTable.split('\n');
  4050. for (i = 0; i < tableLines.length; ++i) {
  4051. // strip wrong first and last column if wrapped tables are used
  4052. if (/^ {0,3}\|/.test(tableLines[i])) {
  4053. tableLines[i] = tableLines[i].replace(/^ {0,3}\|/, '');
  4054. }
  4055. if (/\|[ \t]*$/.test(tableLines[i])) {
  4056. tableLines[i] = tableLines[i].replace(/\|[ \t]*$/, '');
  4057. }
  4058. // parse code spans first, but we only support one line code spans
  4059. tableLines[i] = showdown.subParser('codeSpans')(tableLines[i], options, globals);
  4060. }
  4061. var rawHeaders = tableLines[0].split('|').map(function (s) { return s.trim();}),
  4062. rawStyles = tableLines[1].split('|').map(function (s) { return s.trim();}),
  4063. rawCells = [],
  4064. headers = [],
  4065. styles = [],
  4066. cells = [];
  4067. tableLines.shift();
  4068. tableLines.shift();
  4069. for (i = 0; i < tableLines.length; ++i) {
  4070. if (tableLines[i].trim() === '') {
  4071. continue;
  4072. }
  4073. rawCells.push(
  4074. tableLines[i]
  4075. .split('|')
  4076. .map(function (s) {
  4077. return s.trim();
  4078. })
  4079. );
  4080. }
  4081. if (rawHeaders.length < rawStyles.length) {
  4082. return rawTable;
  4083. }
  4084. for (i = 0; i < rawStyles.length; ++i) {
  4085. styles.push(parseStyles(rawStyles[i]));
  4086. }
  4087. for (i = 0; i < rawHeaders.length; ++i) {
  4088. if (showdown.helper.isUndefined(styles[i])) {
  4089. styles[i] = '';
  4090. }
  4091. headers.push(parseHeaders(rawHeaders[i], styles[i]));
  4092. }
  4093. for (i = 0; i < rawCells.length; ++i) {
  4094. var row = [];
  4095. for (var ii = 0; ii < headers.length; ++ii) {
  4096. if (showdown.helper.isUndefined(rawCells[i][ii])) {
  4097. }
  4098. row.push(parseCells(rawCells[i][ii], styles[ii]));
  4099. }
  4100. cells.push(row);
  4101. }
  4102. return buildTable(headers, cells);
  4103. }
  4104. text = globals.converter._dispatch('tables.before', text, options, globals);
  4105. // find escaped pipe characters
  4106. text = text.replace(/\\(\|)/g, showdown.helper.escapeCharactersCallback);
  4107. // parse multi column tables
  4108. text = text.replace(tableRgx, parseTable);
  4109. // parse one column tables
  4110. text = text.replace(singeColTblRgx, parseTable);
  4111. text = globals.converter._dispatch('tables.after', text, options, globals);
  4112. return text;
  4113. });
  4114. showdown.subParser('underline', function (text, options, globals) {
  4115. 'use strict';
  4116. if (!options.underline) {
  4117. return text;
  4118. }
  4119. text = globals.converter._dispatch('underline.before', text, options, globals);
  4120. if (options.literalMidWordUnderscores) {
  4121. text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
  4122. return '<u>' + txt + '</u>';
  4123. });
  4124. text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
  4125. return '<u>' + txt + '</u>';
  4126. });
  4127. } else {
  4128. text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
  4129. return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
  4130. });
  4131. text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
  4132. return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
  4133. });
  4134. }
  4135. // escape remaining underscores to prevent them being parsed by italic and bold
  4136. text = text.replace(/(_)/g, showdown.helper.escapeCharactersCallback);
  4137. text = globals.converter._dispatch('underline.after', text, options, globals);
  4138. return text;
  4139. });
  4140. /**
  4141. * Swap back in all the special characters we've hidden.
  4142. */
  4143. showdown.subParser('unescapeSpecialChars', function (text, options, globals) {
  4144. 'use strict';
  4145. text = globals.converter._dispatch('unescapeSpecialChars.before', text, options, globals);
  4146. text = text.replace(/¨E(\d+)E/g, function (wholeMatch, m1) {
  4147. var charCodeToReplace = parseInt(m1);
  4148. return String.fromCharCode(charCodeToReplace);
  4149. });
  4150. text = globals.converter._dispatch('unescapeSpecialChars.after', text, options, globals);
  4151. return text;
  4152. });
  4153. showdown.subParser('makeMarkdown.blockquote', function (node, globals) {
  4154. 'use strict';
  4155. var txt = '';
  4156. if (node.hasChildNodes()) {
  4157. var children = node.childNodes,
  4158. childrenLength = children.length;
  4159. for (var i = 0; i < childrenLength; ++i) {
  4160. var innerTxt = showdown.subParser('makeMarkdown.node')(children[i], globals);
  4161. if (innerTxt === '') {
  4162. continue;
  4163. }
  4164. txt += innerTxt;
  4165. }
  4166. }
  4167. // cleanup
  4168. txt = txt.trim();
  4169. txt = '> ' + txt.split('\n').join('\n> ');
  4170. return txt;
  4171. });
  4172. showdown.subParser('makeMarkdown.codeBlock', function (node, globals) {
  4173. 'use strict';
  4174. var lang = node.getAttribute('language'),
  4175. num = node.getAttribute('precodenum');
  4176. return '```' + lang + '\n' + globals.preList[num] + '\n```';
  4177. });
  4178. showdown.subParser('makeMarkdown.codeSpan', function (node) {
  4179. 'use strict';
  4180. return '`' + node.innerHTML + '`';
  4181. });
  4182. showdown.subParser('makeMarkdown.emphasis', function (node, globals) {
  4183. 'use strict';
  4184. var txt = '';
  4185. if (node.hasChildNodes()) {
  4186. txt += '*';
  4187. var children = node.childNodes,
  4188. childrenLength = children.length;
  4189. for (var i = 0; i < childrenLength; ++i) {
  4190. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4191. }
  4192. txt += '*';
  4193. }
  4194. return txt;
  4195. });
  4196. showdown.subParser('makeMarkdown.header', function (node, globals, headerLevel) {
  4197. 'use strict';
  4198. var headerMark = new Array(headerLevel + 1).join('#'),
  4199. txt = '';
  4200. if (node.hasChildNodes()) {
  4201. txt = headerMark + ' ';
  4202. var children = node.childNodes,
  4203. childrenLength = children.length;
  4204. for (var i = 0; i < childrenLength; ++i) {
  4205. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4206. }
  4207. }
  4208. return txt;
  4209. });
  4210. showdown.subParser('makeMarkdown.hr', function () {
  4211. 'use strict';
  4212. return '---';
  4213. });
  4214. showdown.subParser('makeMarkdown.image', function (node) {
  4215. 'use strict';
  4216. var txt = '';
  4217. if (node.hasAttribute('src')) {
  4218. txt += '![' + node.getAttribute('alt') + '](';
  4219. txt += '<' + node.getAttribute('src') + '>';
  4220. if (node.hasAttribute('width') && node.hasAttribute('height')) {
  4221. txt += ' =' + node.getAttribute('width') + 'x' + node.getAttribute('height');
  4222. }
  4223. if (node.hasAttribute('title')) {
  4224. txt += ' "' + node.getAttribute('title') + '"';
  4225. }
  4226. txt += ')';
  4227. }
  4228. return txt;
  4229. });
  4230. showdown.subParser('makeMarkdown.links', function (node, globals) {
  4231. 'use strict';
  4232. var txt = '';
  4233. if (node.hasChildNodes() && node.hasAttribute('href')) {
  4234. var children = node.childNodes,
  4235. childrenLength = children.length;
  4236. txt = '[';
  4237. for (var i = 0; i < childrenLength; ++i) {
  4238. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4239. }
  4240. txt += '](';
  4241. txt += '<' + node.getAttribute('href') + '>';
  4242. if (node.hasAttribute('title')) {
  4243. txt += ' "' + node.getAttribute('title') + '"';
  4244. }
  4245. txt += ')';
  4246. }
  4247. return txt;
  4248. });
  4249. showdown.subParser('makeMarkdown.list', function (node, globals, type) {
  4250. 'use strict';
  4251. var txt = '';
  4252. if (!node.hasChildNodes()) {
  4253. return '';
  4254. }
  4255. var listItems = node.childNodes,
  4256. listItemsLenght = listItems.length,
  4257. listNum = node.getAttribute('start') || 1;
  4258. for (var i = 0; i < listItemsLenght; ++i) {
  4259. if (typeof listItems[i].tagName === 'undefined' || listItems[i].tagName.toLowerCase() !== 'li') {
  4260. continue;
  4261. }
  4262. // define the bullet to use in list
  4263. var bullet = '';
  4264. if (type === 'ol') {
  4265. bullet = listNum.toString() + '. ';
  4266. } else {
  4267. bullet = '- ';
  4268. }
  4269. // parse list item
  4270. txt += bullet + showdown.subParser('makeMarkdown.listItem')(listItems[i], globals);
  4271. ++listNum;
  4272. }
  4273. // add comment at the end to prevent consecutive lists to be parsed as one
  4274. txt += '\n<!-- -->\n';
  4275. return txt.trim();
  4276. });
  4277. showdown.subParser('makeMarkdown.listItem', function (node, globals) {
  4278. 'use strict';
  4279. var listItemTxt = '';
  4280. var children = node.childNodes,
  4281. childrenLenght = children.length;
  4282. for (var i = 0; i < childrenLenght; ++i) {
  4283. listItemTxt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4284. }
  4285. // if it's only one liner, we need to add a newline at the end
  4286. if (!/\n$/.test(listItemTxt)) {
  4287. listItemTxt += '\n';
  4288. } else {
  4289. // it's multiparagraph, so we need to indent
  4290. listItemTxt = listItemTxt
  4291. .split('\n')
  4292. .join('\n ')
  4293. .replace(/^ {4}$/gm, '')
  4294. .replace(/\n\n+/g, '\n\n');
  4295. }
  4296. return listItemTxt;
  4297. });
  4298. showdown.subParser('makeMarkdown.node', function (node, globals, spansOnly) {
  4299. 'use strict';
  4300. spansOnly = spansOnly || false;
  4301. var txt = '';
  4302. // edge case of text without wrapper paragraph
  4303. if (node.nodeType === 3) {
  4304. return showdown.subParser('makeMarkdown.txt')(node, globals);
  4305. }
  4306. // HTML comment
  4307. if (node.nodeType === 8) {
  4308. return '<!--' + node.data + '-->\n\n';
  4309. }
  4310. // process only node elements
  4311. if (node.nodeType !== 1) {
  4312. return '';
  4313. }
  4314. var tagName = node.tagName.toLowerCase();
  4315. switch (tagName) {
  4316. //
  4317. // BLOCKS
  4318. //
  4319. case 'h1':
  4320. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 1) + '\n\n'; }
  4321. break;
  4322. case 'h2':
  4323. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 2) + '\n\n'; }
  4324. break;
  4325. case 'h3':
  4326. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 3) + '\n\n'; }
  4327. break;
  4328. case 'h4':
  4329. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 4) + '\n\n'; }
  4330. break;
  4331. case 'h5':
  4332. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 5) + '\n\n'; }
  4333. break;
  4334. case 'h6':
  4335. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 6) + '\n\n'; }
  4336. break;
  4337. case 'p':
  4338. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.paragraph')(node, globals) + '\n\n'; }
  4339. break;
  4340. case 'blockquote':
  4341. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.blockquote')(node, globals) + '\n\n'; }
  4342. break;
  4343. case 'hr':
  4344. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.hr')(node, globals) + '\n\n'; }
  4345. break;
  4346. case 'ol':
  4347. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ol') + '\n\n'; }
  4348. break;
  4349. case 'ul':
  4350. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ul') + '\n\n'; }
  4351. break;
  4352. case 'precode':
  4353. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.codeBlock')(node, globals) + '\n\n'; }
  4354. break;
  4355. case 'pre':
  4356. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.pre')(node, globals) + '\n\n'; }
  4357. break;
  4358. case 'table':
  4359. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.table')(node, globals) + '\n\n'; }
  4360. break;
  4361. //
  4362. // SPANS
  4363. //
  4364. case 'code':
  4365. txt = showdown.subParser('makeMarkdown.codeSpan')(node, globals);
  4366. break;
  4367. case 'em':
  4368. case 'i':
  4369. txt = showdown.subParser('makeMarkdown.emphasis')(node, globals);
  4370. break;
  4371. case 'strong':
  4372. case 'b':
  4373. txt = showdown.subParser('makeMarkdown.strong')(node, globals);
  4374. break;
  4375. case 'del':
  4376. txt = showdown.subParser('makeMarkdown.strikethrough')(node, globals);
  4377. break;
  4378. case 'a':
  4379. txt = showdown.subParser('makeMarkdown.links')(node, globals);
  4380. break;
  4381. case 'img':
  4382. txt = showdown.subParser('makeMarkdown.image')(node, globals);
  4383. break;
  4384. default:
  4385. txt = node.outerHTML + '\n\n';
  4386. }
  4387. // common normalization
  4388. // TODO eventually
  4389. return txt;
  4390. });
  4391. showdown.subParser('makeMarkdown.paragraph', function (node, globals) {
  4392. 'use strict';
  4393. var txt = '';
  4394. if (node.hasChildNodes()) {
  4395. var children = node.childNodes,
  4396. childrenLength = children.length;
  4397. for (var i = 0; i < childrenLength; ++i) {
  4398. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4399. }
  4400. }
  4401. // some text normalization
  4402. txt = txt.trim();
  4403. return txt;
  4404. });
  4405. showdown.subParser('makeMarkdown.pre', function (node, globals) {
  4406. 'use strict';
  4407. var num = node.getAttribute('prenum');
  4408. return '<pre>' + globals.preList[num] + '</pre>';
  4409. });
  4410. showdown.subParser('makeMarkdown.strikethrough', function (node, globals) {
  4411. 'use strict';
  4412. var txt = '';
  4413. if (node.hasChildNodes()) {
  4414. txt += '~~';
  4415. var children = node.childNodes,
  4416. childrenLength = children.length;
  4417. for (var i = 0; i < childrenLength; ++i) {
  4418. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4419. }
  4420. txt += '~~';
  4421. }
  4422. return txt;
  4423. });
  4424. showdown.subParser('makeMarkdown.strong', function (node, globals) {
  4425. 'use strict';
  4426. var txt = '';
  4427. if (node.hasChildNodes()) {
  4428. txt += '**';
  4429. var children = node.childNodes,
  4430. childrenLength = children.length;
  4431. for (var i = 0; i < childrenLength; ++i) {
  4432. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4433. }
  4434. txt += '**';
  4435. }
  4436. return txt;
  4437. });
  4438. showdown.subParser('makeMarkdown.table', function (node, globals) {
  4439. 'use strict';
  4440. var txt = '',
  4441. tableArray = [[], []],
  4442. headings = node.querySelectorAll('thead>tr>th'),
  4443. rows = node.querySelectorAll('tbody>tr'),
  4444. i, ii;
  4445. for (i = 0; i < headings.length; ++i) {
  4446. var headContent = showdown.subParser('makeMarkdown.tableCell')(headings[i], globals),
  4447. allign = '---';
  4448. if (headings[i].hasAttribute('style')) {
  4449. var style = headings[i].getAttribute('style').toLowerCase().replace(/\s/g, '');
  4450. switch (style) {
  4451. case 'text-align:left;':
  4452. allign = ':---';
  4453. break;
  4454. case 'text-align:right;':
  4455. allign = '---:';
  4456. break;
  4457. case 'text-align:center;':
  4458. allign = ':---:';
  4459. break;
  4460. }
  4461. }
  4462. tableArray[0][i] = headContent.trim();
  4463. tableArray[1][i] = allign;
  4464. }
  4465. for (i = 0; i < rows.length; ++i) {
  4466. var r = tableArray.push([]) - 1,
  4467. cols = rows[i].getElementsByTagName('td');
  4468. for (ii = 0; ii < headings.length; ++ii) {
  4469. var cellContent = ' ';
  4470. if (typeof cols[ii] !== 'undefined') {
  4471. cellContent = showdown.subParser('makeMarkdown.tableCell')(cols[ii], globals);
  4472. }
  4473. tableArray[r].push(cellContent);
  4474. }
  4475. }
  4476. var cellSpacesCount = 3;
  4477. for (i = 0; i < tableArray.length; ++i) {
  4478. for (ii = 0; ii < tableArray[i].length; ++ii) {
  4479. var strLen = tableArray[i][ii].length;
  4480. if (strLen > cellSpacesCount) {
  4481. cellSpacesCount = strLen;
  4482. }
  4483. }
  4484. }
  4485. for (i = 0; i < tableArray.length; ++i) {
  4486. for (ii = 0; ii < tableArray[i].length; ++ii) {
  4487. if (i === 1) {
  4488. if (tableArray[i][ii].slice(-1) === ':') {
  4489. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii].slice(-1), cellSpacesCount - 1, '-') + ':';
  4490. } else {
  4491. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount, '-');
  4492. }
  4493. } else {
  4494. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount);
  4495. }
  4496. }
  4497. txt += '| ' + tableArray[i].join(' | ') + ' |\n';
  4498. }
  4499. return txt.trim();
  4500. });
  4501. showdown.subParser('makeMarkdown.tableCell', function (node, globals) {
  4502. 'use strict';
  4503. var txt = '';
  4504. if (!node.hasChildNodes()) {
  4505. return '';
  4506. }
  4507. var children = node.childNodes,
  4508. childrenLength = children.length;
  4509. for (var i = 0; i < childrenLength; ++i) {
  4510. txt += showdown.subParser('makeMarkdown.node')(children[i], globals, true);
  4511. }
  4512. return txt.trim();
  4513. });
  4514. showdown.subParser('makeMarkdown.txt', function (node) {
  4515. 'use strict';
  4516. var txt = node.nodeValue;
  4517. // multiple spaces are collapsed
  4518. txt = txt.replace(/ +/g, ' ');
  4519. // replace the custom ¨NBSP; with a space
  4520. txt = txt.replace(/¨NBSP;/g, ' ');
  4521. // ", <, > and & should replace escaped html entities
  4522. txt = showdown.helper.unescapeHTMLEntities(txt);
  4523. // escape markdown magic characters
  4524. // emphasis, strong and strikethrough - can appear everywhere
  4525. // we also escape pipe (|) because of tables
  4526. // and escape ` because of code blocks and spans
  4527. txt = txt.replace(/([*_~|`])/g, '\\$1');
  4528. // escape > because of blockquotes
  4529. txt = txt.replace(/^(\s*)>/g, '\\$1>');
  4530. // hash character, only troublesome at the beginning of a line because of headers
  4531. txt = txt.replace(/^#/gm, '\\#');
  4532. // horizontal rules
  4533. txt = txt.replace(/^(\s*)([-=]{3,})(\s*)$/, '$1\\$2$3');
  4534. // dot, because of ordered lists, only troublesome at the beginning of a line when preceded by an integer
  4535. txt = txt.replace(/^( {0,3}\d+)\./gm, '$1\\.');
  4536. // +, * and -, at the beginning of a line becomes a list, so we need to escape them also (asterisk was already escaped)
  4537. txt = txt.replace(/^( {0,3})([+-])/gm, '$1\\$2');
  4538. // images and links, ] followed by ( is problematic, so we escape it
  4539. txt = txt.replace(/]([\s]*)\(/g, '\\]$1\\(');
  4540. // reference URIs must also be escaped
  4541. txt = txt.replace(/^ {0,3}\[([\S \t]*?)]:/gm, '\\[$1]:');
  4542. return txt;
  4543. });
  4544. var root = this;
  4545. // AMD Loader
  4546. if (typeof define === 'function' && define.amd) {
  4547. define(function () {
  4548. 'use strict';
  4549. return showdown;
  4550. });
  4551. // CommonJS/nodeJS Loader
  4552. } else if (typeof module !== 'undefined' && module.exports) {
  4553. module.exports = showdown;
  4554. // Regular Browser loader
  4555. } else {
  4556. root.showdown = showdown;
  4557. }
  4558. }).call(this);
  4559. //# sourceMappingURL=showdown.js.map