showdown.js 161 KB

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