showdown.js 156 KB

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