showdown.js 161 KB

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