marked.js 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056
  1. /**
  2. * marked - a markdown parser
  3. * Copyright (c) 2011-2020, Christopher Jeffrey. (MIT Licensed)
  4. * https://github.com/markedjs/marked
  5. */
  6. function createCommonjsModule(fn, module) {
  7. return module = { exports: {} }, fn(module, module.exports), module.exports;
  8. }
  9. var defaults = createCommonjsModule(function (module) {
  10. function getDefaults() {
  11. return {
  12. baseUrl: null,
  13. breaks: false,
  14. gfm: true,
  15. headerIds: true,
  16. headerPrefix: '',
  17. highlight: null,
  18. langPrefix: 'language-',
  19. mangle: true,
  20. pedantic: false,
  21. renderer: null,
  22. sanitize: false,
  23. sanitizer: null,
  24. silent: false,
  25. smartLists: false,
  26. smartypants: false,
  27. xhtml: false
  28. };
  29. }
  30. function changeDefaults(newDefaults) {
  31. module.exports.defaults = newDefaults;
  32. }
  33. module.exports = {
  34. defaults: getDefaults(),
  35. getDefaults,
  36. changeDefaults
  37. };
  38. });
  39. var defaults_1 = defaults.defaults;
  40. var defaults_2 = defaults.getDefaults;
  41. var defaults_3 = defaults.changeDefaults;
  42. /**
  43. * Helpers
  44. */
  45. const escapeTest = /[&<>"']/;
  46. const escapeReplace = /[&<>"']/g;
  47. const escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
  48. const escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
  49. const escapeReplacements = {
  50. '&': '&amp;',
  51. '<': '&lt;',
  52. '>': '&gt;',
  53. '"': '&quot;',
  54. "'": '&#39;'
  55. };
  56. const getEscapeReplacement = (ch) => escapeReplacements[ch];
  57. function escape(html, encode) {
  58. if (encode) {
  59. if (escapeTest.test(html)) {
  60. return html.replace(escapeReplace, getEscapeReplacement);
  61. }
  62. } else {
  63. if (escapeTestNoEncode.test(html)) {
  64. return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
  65. }
  66. }
  67. return html;
  68. }
  69. const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
  70. function unescape(html) {
  71. // explicitly match decimal, hex, and named HTML entities
  72. return html.replace(unescapeTest, (_, n) => {
  73. n = n.toLowerCase();
  74. if (n === 'colon') return ':';
  75. if (n.charAt(0) === '#') {
  76. return n.charAt(1) === 'x'
  77. ? String.fromCharCode(parseInt(n.substring(2), 16))
  78. : String.fromCharCode(+n.substring(1));
  79. }
  80. return '';
  81. });
  82. }
  83. const caret = /(^|[^\[])\^/g;
  84. function edit(regex, opt) {
  85. regex = regex.source || regex;
  86. opt = opt || '';
  87. const obj = {
  88. replace: (name, val) => {
  89. val = val.source || val;
  90. val = val.replace(caret, '$1');
  91. regex = regex.replace(name, val);
  92. return obj;
  93. },
  94. getRegex: () => {
  95. return new RegExp(regex, opt);
  96. }
  97. };
  98. return obj;
  99. }
  100. const nonWordAndColonTest = /[^\w:]/g;
  101. const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
  102. function cleanUrl(sanitize, base, href) {
  103. if (sanitize) {
  104. let prot;
  105. try {
  106. prot = decodeURIComponent(unescape(href))
  107. .replace(nonWordAndColonTest, '')
  108. .toLowerCase();
  109. } catch (e) {
  110. return null;
  111. }
  112. if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
  113. return null;
  114. }
  115. }
  116. if (base && !originIndependentUrl.test(href)) {
  117. href = resolveUrl(base, href);
  118. }
  119. try {
  120. href = encodeURI(href).replace(/%25/g, '%');
  121. } catch (e) {
  122. return null;
  123. }
  124. return href;
  125. }
  126. const baseUrls = {};
  127. const justDomain = /^[^:]+:\/*[^/]*$/;
  128. const protocol = /^([^:]+:)[\s\S]*$/;
  129. const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
  130. function resolveUrl(base, href) {
  131. if (!baseUrls[' ' + base]) {
  132. // we can ignore everything in base after the last slash of its path component,
  133. // but we might need to add _that_
  134. // https://tools.ietf.org/html/rfc3986#section-3
  135. if (justDomain.test(base)) {
  136. baseUrls[' ' + base] = base + '/';
  137. } else {
  138. baseUrls[' ' + base] = rtrim(base, '/', true);
  139. }
  140. }
  141. base = baseUrls[' ' + base];
  142. const relativeBase = base.indexOf(':') === -1;
  143. if (href.substring(0, 2) === '//') {
  144. if (relativeBase) {
  145. return href;
  146. }
  147. return base.replace(protocol, '$1') + href;
  148. } else if (href.charAt(0) === '/') {
  149. if (relativeBase) {
  150. return href;
  151. }
  152. return base.replace(domain, '$1') + href;
  153. } else {
  154. return base + href;
  155. }
  156. }
  157. const noopTest = { exec: function noopTest() {} };
  158. function merge(obj) {
  159. let i = 1,
  160. target,
  161. key;
  162. for (; i < arguments.length; i++) {
  163. target = arguments[i];
  164. for (key in target) {
  165. if (Object.prototype.hasOwnProperty.call(target, key)) {
  166. obj[key] = target[key];
  167. }
  168. }
  169. }
  170. return obj;
  171. }
  172. function splitCells(tableRow, count) {
  173. // ensure that every cell-delimiting pipe has a space
  174. // before it to distinguish it from an escaped pipe
  175. const row = tableRow.replace(/\|/g, (match, offset, str) => {
  176. let escaped = false,
  177. curr = offset;
  178. while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
  179. if (escaped) {
  180. // odd number of slashes means | is escaped
  181. // so we leave it alone
  182. return '|';
  183. } else {
  184. // add space before unescaped |
  185. return ' |';
  186. }
  187. }),
  188. cells = row.split(/ \|/);
  189. let i = 0;
  190. if (cells.length > count) {
  191. cells.splice(count);
  192. } else {
  193. while (cells.length < count) cells.push('');
  194. }
  195. for (; i < cells.length; i++) {
  196. // leading or trailing whitespace is ignored per the gfm spec
  197. cells[i] = cells[i].trim().replace(/\\\|/g, '|');
  198. }
  199. return cells;
  200. }
  201. // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
  202. // /c*$/ is vulnerable to REDOS.
  203. // invert: Remove suffix of non-c chars instead. Default falsey.
  204. function rtrim(str, c, invert) {
  205. const l = str.length;
  206. if (l === 0) {
  207. return '';
  208. }
  209. // Length of suffix matching the invert condition.
  210. let suffLen = 0;
  211. // Step left until we fail to match the invert condition.
  212. while (suffLen < l) {
  213. const currChar = str.charAt(l - suffLen - 1);
  214. if (currChar === c && !invert) {
  215. suffLen++;
  216. } else if (currChar !== c && invert) {
  217. suffLen++;
  218. } else {
  219. break;
  220. }
  221. }
  222. return str.substr(0, l - suffLen);
  223. }
  224. function findClosingBracket(str, b) {
  225. if (str.indexOf(b[1]) === -1) {
  226. return -1;
  227. }
  228. const l = str.length;
  229. let level = 0,
  230. i = 0;
  231. for (; i < l; i++) {
  232. if (str[i] === '\\') {
  233. i++;
  234. } else if (str[i] === b[0]) {
  235. level++;
  236. } else if (str[i] === b[1]) {
  237. level--;
  238. if (level < 0) {
  239. return i;
  240. }
  241. }
  242. }
  243. return -1;
  244. }
  245. function checkSanitizeDeprecation(opt) {
  246. if (opt && opt.sanitize && !opt.silent) {
  247. console.warn('marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
  248. }
  249. }
  250. var helpers = {
  251. escape,
  252. unescape,
  253. edit,
  254. cleanUrl,
  255. resolveUrl,
  256. noopTest,
  257. merge,
  258. splitCells,
  259. rtrim,
  260. findClosingBracket,
  261. checkSanitizeDeprecation
  262. };
  263. const {
  264. noopTest: noopTest$1,
  265. edit: edit$1,
  266. merge: merge$1
  267. } = helpers;
  268. /**
  269. * Block-Level Grammar
  270. */
  271. const block = {
  272. newline: /^\n+/,
  273. code: /^( {4}[^\n]+\n*)+/,
  274. fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
  275. hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
  276. heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,
  277. blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
  278. list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
  279. html: '^ {0,3}(?:' // optional indentation
  280. + '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
  281. + '|comment[^\\n]*(\\n+|$)' // (2)
  282. + '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
  283. + '|<![A-Z][\\s\\S]*?>\\n*' // (4)
  284. + '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
  285. + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
  286. + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
  287. + '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
  288. + ')',
  289. def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
  290. nptable: noopTest$1,
  291. table: noopTest$1,
  292. lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
  293. // regex template, placeholders will be replaced according to different paragraph
  294. // interruption rules of commonmark and the original markdown spec:
  295. _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,
  296. text: /^[^\n]+/
  297. };
  298. block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
  299. block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
  300. block.def = edit$1(block.def)
  301. .replace('label', block._label)
  302. .replace('title', block._title)
  303. .getRegex();
  304. block.bullet = /(?:[*+-]|\d{1,9}\.)/;
  305. block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
  306. block.item = edit$1(block.item, 'gm')
  307. .replace(/bull/g, block.bullet)
  308. .getRegex();
  309. block.list = edit$1(block.list)
  310. .replace(/bull/g, block.bullet)
  311. .replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
  312. .replace('def', '\\n+(?=' + block.def.source + ')')
  313. .getRegex();
  314. block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
  315. + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
  316. + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
  317. + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
  318. + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
  319. + '|track|ul';
  320. block._comment = /<!--(?!-?>)[\s\S]*?-->/;
  321. block.html = edit$1(block.html, 'i')
  322. .replace('comment', block._comment)
  323. .replace('tag', block._tag)
  324. .replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
  325. .getRegex();
  326. block.paragraph = edit$1(block._paragraph)
  327. .replace('hr', block.hr)
  328. .replace('heading', ' {0,3}#{1,6} ')
  329. .replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
  330. .replace('blockquote', ' {0,3}>')
  331. .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
  332. .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
  333. .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
  334. .replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
  335. .getRegex();
  336. block.blockquote = edit$1(block.blockquote)
  337. .replace('paragraph', block.paragraph)
  338. .getRegex();
  339. /**
  340. * Normal Block Grammar
  341. */
  342. block.normal = merge$1({}, block);
  343. /**
  344. * GFM Block Grammar
  345. */
  346. block.gfm = merge$1({}, block.normal, {
  347. nptable: '^ *([^|\\n ].*\\|.*)\\n' // Header
  348. + ' *([-:]+ *\\|[-| :]*)' // Align
  349. + '(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)', // Cells
  350. table: '^ *\\|(.+)\\n' // Header
  351. + ' *\\|?( *[-:]+[-| :]*)' // Align
  352. + '(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
  353. });
  354. block.gfm.nptable = edit$1(block.gfm.nptable)
  355. .replace('hr', block.hr)
  356. .replace('heading', ' {0,3}#{1,6} ')
  357. .replace('blockquote', ' {0,3}>')
  358. .replace('code', ' {4}[^\\n]')
  359. .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
  360. .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
  361. .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
  362. .replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
  363. .getRegex();
  364. block.gfm.table = edit$1(block.gfm.table)
  365. .replace('hr', block.hr)
  366. .replace('heading', ' {0,3}#{1,6} ')
  367. .replace('blockquote', ' {0,3}>')
  368. .replace('code', ' {4}[^\\n]')
  369. .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
  370. .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
  371. .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
  372. .replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
  373. .getRegex();
  374. /**
  375. * Pedantic grammar (original John Gruber's loose markdown specification)
  376. */
  377. block.pedantic = merge$1({}, block.normal, {
  378. html: edit$1(
  379. '^ *(?:comment *(?:\\n|\\s*$)'
  380. + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
  381. + '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
  382. .replace('comment', block._comment)
  383. .replace(/tag/g, '(?!(?:'
  384. + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
  385. + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
  386. + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
  387. .getRegex(),
  388. def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
  389. heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
  390. fences: noopTest$1, // fences not supported
  391. paragraph: edit$1(block.normal._paragraph)
  392. .replace('hr', block.hr)
  393. .replace('heading', ' *#{1,6} *[^\n]')
  394. .replace('lheading', block.lheading)
  395. .replace('blockquote', ' {0,3}>')
  396. .replace('|fences', '')
  397. .replace('|list', '')
  398. .replace('|html', '')
  399. .getRegex()
  400. });
  401. /**
  402. * Inline-Level Grammar
  403. */
  404. const inline = {
  405. escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
  406. autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
  407. url: noopTest$1,
  408. tag: '^comment'
  409. + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
  410. + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
  411. + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
  412. + '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
  413. + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
  414. link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
  415. reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
  416. nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
  417. strong: /^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
  418. em: /^_([^\s_])_(?!_)|^_([^\s_<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s*<\[])\*(?!\*)|^\*([^\s<"][\s\S]*?[^\s\[\*])\*(?![\]`punctuation])|^\*([^\s*"<\[][\s\S]*[^\s])\*(?!\*)/,
  419. code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
  420. br: /^( {2,}|\\)\n(?!\s*$)/,
  421. del: noopTest$1,
  422. text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/
  423. };
  424. // list of punctuation marks from common mark spec
  425. // without ` and ] to workaround Rule 17 (inline code blocks/links)
  426. inline._punctuation = '!"#$%&\'()*+\\-./:;<=>?@\\[^_{|}~';
  427. inline.em = edit$1(inline.em).replace(/punctuation/g, inline._punctuation).getRegex();
  428. inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
  429. inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
  430. inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
  431. inline.autolink = edit$1(inline.autolink)
  432. .replace('scheme', inline._scheme)
  433. .replace('email', inline._email)
  434. .getRegex();
  435. inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
  436. inline.tag = edit$1(inline.tag)
  437. .replace('comment', block._comment)
  438. .replace('attribute', inline._attribute)
  439. .getRegex();
  440. inline._label = /(?:\[[^\[\]]*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
  441. inline._href = /<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/;
  442. inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
  443. inline.link = edit$1(inline.link)
  444. .replace('label', inline._label)
  445. .replace('href', inline._href)
  446. .replace('title', inline._title)
  447. .getRegex();
  448. inline.reflink = edit$1(inline.reflink)
  449. .replace('label', inline._label)
  450. .getRegex();
  451. /**
  452. * Normal Inline Grammar
  453. */
  454. inline.normal = merge$1({}, inline);
  455. /**
  456. * Pedantic Inline Grammar
  457. */
  458. inline.pedantic = merge$1({}, inline.normal, {
  459. strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
  460. em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
  461. link: edit$1(/^!?\[(label)\]\((.*?)\)/)
  462. .replace('label', inline._label)
  463. .getRegex(),
  464. reflink: edit$1(/^!?\[(label)\]\s*\[([^\]]*)\]/)
  465. .replace('label', inline._label)
  466. .getRegex()
  467. });
  468. /**
  469. * GFM Inline Grammar
  470. */
  471. inline.gfm = merge$1({}, inline.normal, {
  472. escape: edit$1(inline.escape).replace('])', '~|])').getRegex(),
  473. _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
  474. url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
  475. _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
  476. del: /^~+(?=\S)([\s\S]*?\S)~+/,
  477. text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
  478. });
  479. inline.gfm.url = edit$1(inline.gfm.url, 'i')
  480. .replace('email', inline.gfm._extended_email)
  481. .getRegex();
  482. /**
  483. * GFM + Line Breaks Inline Grammar
  484. */
  485. inline.breaks = merge$1({}, inline.gfm, {
  486. br: edit$1(inline.br).replace('{2,}', '*').getRegex(),
  487. text: edit$1(inline.gfm.text)
  488. .replace('\\b_', '\\b_| {2,}\\n')
  489. .replace(/\{2,\}/g, '*')
  490. .getRegex()
  491. });
  492. var rules = {
  493. block,
  494. inline
  495. };
  496. const { defaults: defaults$1 } = defaults;
  497. const { block: block$1, inline: inline$1 } = rules;
  498. const {
  499. rtrim: rtrim$1,
  500. splitCells: splitCells$1,
  501. escape: escape$1,
  502. findClosingBracket: findClosingBracket$1
  503. } = helpers;
  504. /**
  505. * Block Lexer
  506. */
  507. var Lexer_1 = class Lexer {
  508. constructor(options) {
  509. this.tokens = [];
  510. this.tokens.links = Object.create(null);
  511. this.options = options || defaults$1;
  512. this.rules = {
  513. block: block$1.normal,
  514. inline: inline$1.normal
  515. };
  516. if (this.options.pedantic) {
  517. this.rules.block = block$1.pedantic;
  518. this.rules.inline = inline$1.pedantic;
  519. } else if (this.options.gfm) {
  520. this.rules.block = block$1.gfm;
  521. if (this.options.breaks) {
  522. this.rules.inline = inline$1.breaks;
  523. } else {
  524. this.rules.inline = inline$1.gfm;
  525. }
  526. }
  527. }
  528. /**
  529. * Expose Block Rules
  530. */
  531. static get rules() {
  532. return {
  533. block: block$1,
  534. inline: inline$1
  535. };
  536. }
  537. /**
  538. * Static Lex Method
  539. */
  540. static lex(src, options) {
  541. const lexer = new Lexer(options);
  542. return lexer.lex(src);
  543. }
  544. /**
  545. * Preprocessing
  546. */
  547. lex(src) {
  548. src = src
  549. .replace(/\r\n|\r/g, '\n')
  550. .replace(/\t/g, ' ');
  551. this.blockTokens(src, this.tokens);
  552. this.inline(this.tokens);
  553. return this.tokens;
  554. }
  555. /**
  556. * Lexing
  557. */
  558. blockTokens(src, tokens, top = true) {
  559. src = src.replace(/^ +$/gm, '');
  560. let next,
  561. loose,
  562. cap,
  563. bull,
  564. b,
  565. item,
  566. list,
  567. space,
  568. i,
  569. tag,
  570. l,
  571. isordered,
  572. istask,
  573. ischecked,
  574. lastToken,
  575. addBack,
  576. raw;
  577. while (src) {
  578. // newline
  579. if (cap = this.rules.block.newline.exec(src)) {
  580. src = src.substring(cap[0].length);
  581. raw = cap[0];
  582. if (cap[0].length > 1) {
  583. tokens.push({
  584. type: 'space',
  585. raw
  586. });
  587. }
  588. }
  589. // code
  590. if (cap = this.rules.block.code.exec(src)) {
  591. lastToken = tokens[tokens.length - 1];
  592. src = src.substring(cap[0].length);
  593. raw = cap[0];
  594. // An indented code block cannot interrupt a paragraph.
  595. if (lastToken && lastToken.type === 'paragraph') {
  596. lastToken.text += '\n' + cap[0].trimRight();
  597. lastToken.raw += '\n' + raw;
  598. } else {
  599. cap = cap[0].replace(/^ {4}/gm, '');
  600. tokens.push({
  601. type: 'code',
  602. raw,
  603. codeBlockStyle: 'indented',
  604. text: !this.options.pedantic
  605. ? rtrim$1(cap, '\n')
  606. : cap
  607. });
  608. }
  609. continue;
  610. }
  611. // fences
  612. if (cap = this.rules.block.fences.exec(src)) {
  613. src = src.substring(cap[0].length);
  614. raw = cap[0];
  615. tokens.push({
  616. type: 'code',
  617. raw,
  618. lang: cap[2] ? cap[2].trim() : cap[2],
  619. text: cap[3] || ''
  620. });
  621. continue;
  622. }
  623. // heading
  624. if (cap = this.rules.block.heading.exec(src)) {
  625. src = src.substring(cap[0].length);
  626. raw = cap[0];
  627. tokens.push({
  628. type: 'heading',
  629. raw,
  630. depth: cap[1].length,
  631. text: cap[2]
  632. });
  633. continue;
  634. }
  635. // table no leading pipe (gfm)
  636. if (cap = this.rules.block.nptable.exec(src)) {
  637. item = {
  638. type: 'table',
  639. header: splitCells$1(cap[1].replace(/^ *| *\| *$/g, '')),
  640. align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
  641. cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
  642. };
  643. if (item.header.length === item.align.length) {
  644. src = src.substring(cap[0].length);
  645. raw = cap[0];
  646. item.raw = raw;
  647. l = item.align.length;
  648. for (i = 0; i < l; i++) {
  649. if (/^ *-+: *$/.test(item.align[i])) {
  650. item.align[i] = 'right';
  651. } else if (/^ *:-+: *$/.test(item.align[i])) {
  652. item.align[i] = 'center';
  653. } else if (/^ *:-+ *$/.test(item.align[i])) {
  654. item.align[i] = 'left';
  655. } else {
  656. item.align[i] = null;
  657. }
  658. }
  659. l = item.cells.length;
  660. for (i = 0; i < l; i++) {
  661. item.cells[i] = splitCells$1(item.cells[i], item.header.length);
  662. }
  663. tokens.push(item);
  664. continue;
  665. }
  666. }
  667. // hr
  668. if (cap = this.rules.block.hr.exec(src)) {
  669. src = src.substring(cap[0].length);
  670. raw = cap[0];
  671. tokens.push({
  672. type: 'hr',
  673. raw
  674. });
  675. continue;
  676. }
  677. // blockquote
  678. if (cap = this.rules.block.blockquote.exec(src)) {
  679. src = src.substring(cap[0].length);
  680. raw = cap[0];
  681. cap = cap[0].replace(/^ *> ?/gm, '');
  682. tokens.push({
  683. type: 'blockquote',
  684. raw,
  685. tokens: this.blockTokens(cap, [], top)
  686. });
  687. continue;
  688. }
  689. // list
  690. if (cap = this.rules.block.list.exec(src)) {
  691. src = src.substring(cap[0].length);
  692. raw = cap[0];
  693. bull = cap[2];
  694. isordered = bull.length > 1;
  695. list = {
  696. type: 'list',
  697. raw,
  698. ordered: isordered,
  699. start: isordered ? +bull : '',
  700. loose: false,
  701. items: []
  702. };
  703. tokens.push(list);
  704. // Get each top-level item.
  705. cap = cap[0].match(this.rules.block.item);
  706. next = false;
  707. l = cap.length;
  708. for (i = 0; i < l; i++) {
  709. item = cap[i];
  710. raw = item.trim();
  711. // Remove the list item's bullet
  712. // so it is seen as the next token.
  713. space = item.length;
  714. item = item.replace(/^ *([*+-]|\d+\.) */, '');
  715. // Outdent whatever the
  716. // list item contains. Hacky.
  717. if (~item.indexOf('\n ')) {
  718. space -= item.length;
  719. item = !this.options.pedantic
  720. ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
  721. : item.replace(/^ {1,4}/gm, '');
  722. }
  723. // Determine whether the next list item belongs here.
  724. // Backpedal if it does not belong in this list.
  725. if (i !== l - 1) {
  726. b = block$1.bullet.exec(cap[i + 1])[0];
  727. if (bull.length > 1 ? b.length === 1
  728. : (b.length > 1 || (this.options.smartLists && b !== bull))) {
  729. addBack = cap.slice(i + 1).join('\n');
  730. src = addBack + src;
  731. list.raw = list.raw.substring(list.raw.length - addBack.length);
  732. i = l - 1;
  733. }
  734. }
  735. // Determine whether item is loose or not.
  736. // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
  737. // for discount behavior.
  738. loose = next || /\n\n(?!\s*$)/.test(item);
  739. if (i !== l - 1) {
  740. next = item.charAt(item.length - 1) === '\n';
  741. if (!loose) loose = next;
  742. }
  743. if (loose) {
  744. list.loose = true;
  745. }
  746. // Check for task list items
  747. istask = /^\[[ xX]\] /.test(item);
  748. ischecked = undefined;
  749. if (istask) {
  750. ischecked = item[1] !== ' ';
  751. item = item.replace(/^\[[ xX]\] +/, '');
  752. }
  753. list.items.push({
  754. raw,
  755. task: istask,
  756. checked: ischecked,
  757. loose: loose,
  758. tokens: this.blockTokens(item, [], false)
  759. });
  760. }
  761. continue;
  762. }
  763. // html
  764. if (cap = this.rules.block.html.exec(src)) {
  765. src = src.substring(cap[0].length);
  766. raw = cap[0];
  767. tokens.push({
  768. type: this.options.sanitize
  769. ? 'paragraph'
  770. : 'html',
  771. raw,
  772. pre: !this.options.sanitizer
  773. && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
  774. text: this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape$1(cap[0])) : cap[0]
  775. });
  776. continue;
  777. }
  778. // def
  779. if (top && (cap = this.rules.block.def.exec(src))) {
  780. src = src.substring(cap[0].length);
  781. if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
  782. tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
  783. if (!this.tokens.links[tag]) {
  784. this.tokens.links[tag] = {
  785. href: cap[2],
  786. title: cap[3]
  787. };
  788. }
  789. continue;
  790. }
  791. // table (gfm)
  792. if (cap = this.rules.block.table.exec(src)) {
  793. item = {
  794. type: 'table',
  795. header: splitCells$1(cap[1].replace(/^ *| *\| *$/g, '')),
  796. align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
  797. cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
  798. };
  799. if (item.header.length === item.align.length) {
  800. src = src.substring(cap[0].length);
  801. item.raw = cap[0];
  802. l = item.align.length;
  803. for (i = 0; i < l; i++) {
  804. if (/^ *-+: *$/.test(item.align[i])) {
  805. item.align[i] = 'right';
  806. } else if (/^ *:-+: *$/.test(item.align[i])) {
  807. item.align[i] = 'center';
  808. } else if (/^ *:-+ *$/.test(item.align[i])) {
  809. item.align[i] = 'left';
  810. } else {
  811. item.align[i] = null;
  812. }
  813. }
  814. l = item.cells.length;
  815. for (i = 0; i < l; i++) {
  816. item.cells[i] = splitCells$1(
  817. item.cells[i].replace(/^ *\| *| *\| *$/g, ''),
  818. item.header.length);
  819. }
  820. tokens.push(item);
  821. continue;
  822. }
  823. }
  824. // lheading
  825. if (cap = this.rules.block.lheading.exec(src)) {
  826. src = src.substring(cap[0].length);
  827. raw = cap[0];
  828. tokens.push({
  829. type: 'heading',
  830. raw,
  831. depth: cap[2].charAt(0) === '=' ? 1 : 2,
  832. text: cap[1]
  833. });
  834. continue;
  835. }
  836. // top-level paragraph
  837. if (top && (cap = this.rules.block.paragraph.exec(src))) {
  838. src = src.substring(cap[0].length);
  839. raw = cap[0];
  840. tokens.push({
  841. type: 'paragraph',
  842. raw,
  843. text: cap[1].charAt(cap[1].length - 1) === '\n'
  844. ? cap[1].slice(0, -1)
  845. : cap[1]
  846. });
  847. continue;
  848. }
  849. // text
  850. if (cap = this.rules.block.text.exec(src)) {
  851. // Top-level should never reach here.
  852. src = src.substring(cap[0].length);
  853. raw = cap[0];
  854. tokens.push({
  855. type: 'text',
  856. raw,
  857. text: cap[0]
  858. });
  859. continue;
  860. }
  861. if (src) {
  862. const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
  863. if (this.options.silent) {
  864. console.error(errMsg);
  865. } else {
  866. throw new Error(errMsg);
  867. }
  868. }
  869. }
  870. return tokens;
  871. }
  872. inline(tokens) {
  873. let i,
  874. j,
  875. k,
  876. l2,
  877. row,
  878. token;
  879. const l = tokens.length;
  880. for (i = 0; i < l; i++) {
  881. token = tokens[i];
  882. switch (token.type) {
  883. case 'paragraph':
  884. case 'text':
  885. case 'heading': {
  886. token.tokens = [];
  887. this.inlineTokens(token.text, token.tokens);
  888. break;
  889. }
  890. case 'table': {
  891. token.tokens = {
  892. header: [],
  893. cells: []
  894. };
  895. // header
  896. l2 = token.header.length;
  897. for (j = 0; j < l2; j++) {
  898. token.tokens.header[j] = [];
  899. this.inlineTokens(token.header[j], token.tokens.header[j]);
  900. }
  901. // cells
  902. l2 = token.cells.length;
  903. for (j = 0; j < l2; j++) {
  904. row = token.cells[j];
  905. token.tokens.cells[j] = [];
  906. for (k = 0; k < row.length; k++) {
  907. token.tokens.cells[j][k] = [];
  908. this.inlineTokens(row[k], token.tokens.cells[j][k]);
  909. }
  910. }
  911. break;
  912. }
  913. case 'blockquote': {
  914. this.inline(token.tokens);
  915. break;
  916. }
  917. case 'list': {
  918. l2 = token.items.length;
  919. for (j = 0; j < l2; j++) {
  920. this.inline(token.items[j].tokens);
  921. }
  922. break;
  923. }
  924. }
  925. }
  926. return tokens;
  927. }
  928. /**
  929. * Lexing/Compiling
  930. */
  931. inlineTokens(src, tokens) {
  932. let out = '',
  933. link,
  934. text,
  935. newTokens,
  936. href,
  937. title,
  938. cap,
  939. prevCapZero,
  940. lastParenIndex,
  941. start,
  942. linkLen,
  943. raw;
  944. while (src) {
  945. // escape
  946. if (cap = this.rules.inline.escape.exec(src)) {
  947. src = src.substring(cap[0].length);
  948. raw = cap[0];
  949. text = escape$1(cap[1]);
  950. out += text;
  951. tokens.push({
  952. type: 'escape',
  953. raw,
  954. text
  955. });
  956. continue;
  957. }
  958. // tag
  959. if (cap = this.rules.inline.tag.exec(src)) {
  960. if (!this.inLink && /^<a /i.test(cap[0])) {
  961. this.inLink = true;
  962. } else if (this.inLink && /^<\/a>/i.test(cap[0])) {
  963. this.inLink = false;
  964. }
  965. if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
  966. this.inRawBlock = true;
  967. } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
  968. this.inRawBlock = false;
  969. }
  970. src = src.substring(cap[0].length);
  971. raw = cap[0];
  972. text = this.options.sanitize
  973. ? (this.options.sanitizer
  974. ? this.options.sanitizer(cap[0])
  975. : escape$1(cap[0]))
  976. : cap[0];
  977. tokens.push({
  978. type: this.options.sanitize
  979. ? 'text'
  980. : 'html',
  981. raw,
  982. text
  983. });
  984. out += text;
  985. continue;
  986. }
  987. // link
  988. if (cap = this.rules.inline.link.exec(src)) {
  989. lastParenIndex = findClosingBracket$1(cap[2], '()');
  990. if (lastParenIndex > -1) {
  991. start = cap[0].indexOf('!') === 0 ? 5 : 4;
  992. linkLen = start + cap[1].length + lastParenIndex;
  993. cap[2] = cap[2].substring(0, lastParenIndex);
  994. cap[0] = cap[0].substring(0, linkLen).trim();
  995. cap[3] = '';
  996. }
  997. src = src.substring(cap[0].length);
  998. raw = cap[0];
  999. this.inLink = true;
  1000. href = cap[2];
  1001. if (this.options.pedantic) {
  1002. link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
  1003. if (link) {
  1004. href = link[1];
  1005. title = link[3];
  1006. } else {
  1007. title = '';
  1008. }
  1009. } else {
  1010. title = cap[3] ? cap[3].slice(1, -1) : '';
  1011. }
  1012. href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
  1013. out += this.outputLink(cap, {
  1014. href: this.escapes(href),
  1015. title: this.escapes(title)
  1016. }, tokens, raw);
  1017. this.inLink = false;
  1018. continue;
  1019. }
  1020. // reflink, nolink
  1021. if ((cap = this.rules.inline.reflink.exec(src))
  1022. || (cap = this.rules.inline.nolink.exec(src))) {
  1023. src = src.substring(cap[0].length);
  1024. raw = cap[0];
  1025. link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
  1026. link = this.tokens.links[link.toLowerCase()];
  1027. if (!link || !link.href) {
  1028. text = cap[0].charAt(0);
  1029. out += text;
  1030. tokens.push({
  1031. type: 'text',
  1032. raw: text,
  1033. text
  1034. });
  1035. src = cap[0].substring(1) + src;
  1036. continue;
  1037. }
  1038. this.inLink = true;
  1039. out += this.outputLink(cap, link, tokens, raw);
  1040. this.inLink = false;
  1041. continue;
  1042. }
  1043. // strong
  1044. if (cap = this.rules.inline.strong.exec(src)) {
  1045. src = src.substring(cap[0].length);
  1046. raw = cap[0];
  1047. newTokens = tokens ? [] : null;
  1048. text = this.inlineTokens(cap[4] || cap[3] || cap[2] || cap[1], newTokens);
  1049. tokens.push({
  1050. type: 'strong',
  1051. raw,
  1052. text,
  1053. tokens: newTokens
  1054. });
  1055. out += text;
  1056. continue;
  1057. }
  1058. // em
  1059. if (cap = this.rules.inline.em.exec(src)) {
  1060. src = src.substring(cap[0].length);
  1061. raw = cap[0];
  1062. newTokens = tokens ? [] : null;
  1063. text = this.inlineTokens(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1], newTokens);
  1064. tokens.push({
  1065. type: 'em',
  1066. raw,
  1067. text,
  1068. tokens: newTokens
  1069. });
  1070. out += text;
  1071. continue;
  1072. }
  1073. // code
  1074. if (cap = this.rules.inline.code.exec(src)) {
  1075. src = src.substring(cap[0].length);
  1076. raw = cap[0];
  1077. text = escape$1(cap[2].trim(), true);
  1078. tokens.push({
  1079. type: 'codespan',
  1080. raw,
  1081. text
  1082. });
  1083. out += text;
  1084. continue;
  1085. }
  1086. // br
  1087. if (cap = this.rules.inline.br.exec(src)) {
  1088. src = src.substring(cap[0].length);
  1089. raw = cap[0];
  1090. tokens.push({
  1091. type: 'br',
  1092. raw
  1093. });
  1094. out += '\n';
  1095. continue;
  1096. }
  1097. // del (gfm)
  1098. if (cap = this.rules.inline.del.exec(src)) {
  1099. src = src.substring(cap[0].length);
  1100. raw = cap[0];
  1101. newTokens = tokens ? [] : null;
  1102. text = this.inlineTokens(cap[1], newTokens);
  1103. tokens.push({
  1104. type: 'del',
  1105. raw,
  1106. text,
  1107. tokens: newTokens
  1108. });
  1109. out += text;
  1110. continue;
  1111. }
  1112. // autolink
  1113. if (cap = this.rules.inline.autolink.exec(src)) {
  1114. src = src.substring(cap[0].length);
  1115. raw = cap[0];
  1116. if (cap[2] === '@') {
  1117. text = escape$1(this.options.mangle ? this.mangle(cap[1]) : cap[1]);
  1118. href = 'mailto:' + text;
  1119. } else {
  1120. text = escape$1(cap[1]);
  1121. href = text;
  1122. }
  1123. tokens.push({
  1124. type: 'link',
  1125. raw,
  1126. text,
  1127. href,
  1128. tokens: [
  1129. {
  1130. type: 'text',
  1131. raw: text,
  1132. text
  1133. }
  1134. ]
  1135. });
  1136. out += text;
  1137. continue;
  1138. }
  1139. // url (gfm)
  1140. if (!this.inLink && (cap = this.rules.inline.url.exec(src))) {
  1141. if (cap[2] === '@') {
  1142. text = escape$1(this.options.mangle ? this.mangle(cap[0]) : cap[0]);
  1143. href = 'mailto:' + text;
  1144. } else {
  1145. // do extended autolink path validation
  1146. do {
  1147. prevCapZero = cap[0];
  1148. cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
  1149. } while (prevCapZero !== cap[0]);
  1150. text = escape$1(cap[0]);
  1151. if (cap[1] === 'www.') {
  1152. href = 'http://' + text;
  1153. } else {
  1154. href = text;
  1155. }
  1156. }
  1157. src = src.substring(cap[0].length);
  1158. raw = cap[0];
  1159. tokens.push({
  1160. type: 'link',
  1161. raw,
  1162. text,
  1163. href,
  1164. tokens: [
  1165. {
  1166. type: 'text',
  1167. raw: text,
  1168. text
  1169. }
  1170. ]
  1171. });
  1172. out += text;
  1173. continue;
  1174. }
  1175. // text
  1176. if (cap = this.rules.inline.text.exec(src)) {
  1177. src = src.substring(cap[0].length);
  1178. raw = cap[0];
  1179. if (this.inRawBlock) {
  1180. text = this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape$1(cap[0])) : cap[0];
  1181. } else {
  1182. text = escape$1(this.options.smartypants ? this.smartypants(cap[0]) : cap[0]);
  1183. }
  1184. tokens.push({
  1185. type: 'text',
  1186. raw,
  1187. text
  1188. });
  1189. out += text;
  1190. continue;
  1191. }
  1192. if (src) {
  1193. const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
  1194. if (this.options.silent) {
  1195. console.error(errMsg);
  1196. } else {
  1197. throw new Error(errMsg);
  1198. }
  1199. }
  1200. }
  1201. return out;
  1202. }
  1203. escapes(text) {
  1204. return text ? text.replace(inline$1._escapes, '$1') : text;
  1205. }
  1206. /**
  1207. * tokenize Link
  1208. */
  1209. outputLink(cap, link, tokens, raw) {
  1210. const href = link.href;
  1211. const title = link.title ? escape$1(link.title) : null;
  1212. const newTokens = tokens ? [] : null;
  1213. if (cap[0].charAt(0) !== '!') {
  1214. const text = this.inlineTokens(cap[1], newTokens);
  1215. tokens.push({
  1216. type: 'link',
  1217. raw,
  1218. text,
  1219. href,
  1220. title,
  1221. tokens: newTokens
  1222. });
  1223. return text;
  1224. } else {
  1225. const text = escape$1(cap[1]);
  1226. tokens.push({
  1227. type: 'image',
  1228. raw,
  1229. text,
  1230. href,
  1231. title
  1232. });
  1233. return text;
  1234. }
  1235. }
  1236. /**
  1237. * Smartypants Transformations
  1238. */
  1239. smartypants(text) {
  1240. return text
  1241. // em-dashes
  1242. .replace(/---/g, '\u2014')
  1243. // en-dashes
  1244. .replace(/--/g, '\u2013')
  1245. // opening singles
  1246. .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
  1247. // closing singles & apostrophes
  1248. .replace(/'/g, '\u2019')
  1249. // opening doubles
  1250. .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
  1251. // closing doubles
  1252. .replace(/"/g, '\u201d')
  1253. // ellipses
  1254. .replace(/\.{3}/g, '\u2026');
  1255. }
  1256. /**
  1257. * Mangle Links
  1258. */
  1259. mangle(text) {
  1260. let out = '',
  1261. i,
  1262. ch;
  1263. const l = text.length;
  1264. for (i = 0; i < l; i++) {
  1265. ch = text.charCodeAt(i);
  1266. if (Math.random() > 0.5) {
  1267. ch = 'x' + ch.toString(16);
  1268. }
  1269. out += '&#' + ch + ';';
  1270. }
  1271. return out;
  1272. }
  1273. };
  1274. const { defaults: defaults$2 } = defaults;
  1275. const {
  1276. cleanUrl: cleanUrl$1,
  1277. escape: escape$2
  1278. } = helpers;
  1279. /**
  1280. * Renderer
  1281. */
  1282. var Renderer_1 = class Renderer {
  1283. constructor(options) {
  1284. this.options = options || defaults$2;
  1285. }
  1286. code(code, infostring, escaped) {
  1287. const lang = (infostring || '').match(/\S*/)[0];
  1288. if (this.options.highlight) {
  1289. const out = this.options.highlight(code, lang);
  1290. if (out != null && out !== code) {
  1291. escaped = true;
  1292. code = out;
  1293. }
  1294. }
  1295. if (!lang) {
  1296. return '<pre><code>'
  1297. + (escaped ? code : escape$2(code, true))
  1298. + '</code></pre>';
  1299. }
  1300. return '<pre><code class="'
  1301. + this.options.langPrefix
  1302. + escape$2(lang, true)
  1303. + '">'
  1304. + (escaped ? code : escape$2(code, true))
  1305. + '</code></pre>\n';
  1306. }
  1307. blockquote(quote) {
  1308. return '<blockquote>\n' + quote + '</blockquote>\n';
  1309. }
  1310. html(html) {
  1311. return html;
  1312. }
  1313. heading(text, level, raw, slugger) {
  1314. if (this.options.headerIds) {
  1315. return '<h'
  1316. + level
  1317. + ' id="'
  1318. + this.options.headerPrefix
  1319. + slugger.slug(raw)
  1320. + '">'
  1321. + text
  1322. + '</h'
  1323. + level
  1324. + '>\n';
  1325. }
  1326. // ignore IDs
  1327. return '<h' + level + '>' + text + '</h' + level + '>\n';
  1328. }
  1329. hr() {
  1330. return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
  1331. }
  1332. list(body, ordered, start) {
  1333. const type = ordered ? 'ol' : 'ul',
  1334. startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
  1335. return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
  1336. }
  1337. listitem(text) {
  1338. return '<li>' + text + '</li>\n';
  1339. }
  1340. checkbox(checked) {
  1341. return '<input '
  1342. + (checked ? 'checked="" ' : '')
  1343. + 'disabled="" type="checkbox"'
  1344. + (this.options.xhtml ? ' /' : '')
  1345. + '> ';
  1346. }
  1347. paragraph(text) {
  1348. return '<p>' + text + '</p>\n';
  1349. }
  1350. table(header, body) {
  1351. if (body) body = '<tbody>' + body + '</tbody>';
  1352. return '<table>\n'
  1353. + '<thead>\n'
  1354. + header
  1355. + '</thead>\n'
  1356. + body
  1357. + '</table>\n';
  1358. }
  1359. tablerow(content) {
  1360. return '<tr>\n' + content + '</tr>\n';
  1361. }
  1362. tablecell(content, flags) {
  1363. const type = flags.header ? 'th' : 'td';
  1364. const tag = flags.align
  1365. ? '<' + type + ' align="' + flags.align + '">'
  1366. : '<' + type + '>';
  1367. return tag + content + '</' + type + '>\n';
  1368. }
  1369. // span level renderer
  1370. strong(text) {
  1371. return '<strong>' + text + '</strong>';
  1372. }
  1373. em(text) {
  1374. return '<em>' + text + '</em>';
  1375. }
  1376. codespan(text) {
  1377. return '<code>' + text + '</code>';
  1378. }
  1379. br() {
  1380. return this.options.xhtml ? '<br/>' : '<br>';
  1381. }
  1382. del(text) {
  1383. return '<del>' + text + '</del>';
  1384. }
  1385. link(href, title, text) {
  1386. href = cleanUrl$1(this.options.sanitize, this.options.baseUrl, href);
  1387. if (href === null) {
  1388. return text;
  1389. }
  1390. let out = '<a href="' + escape$2(href) + '"';
  1391. if (title) {
  1392. out += ' title="' + title + '"';
  1393. }
  1394. out += '>' + text + '</a>';
  1395. return out;
  1396. }
  1397. image(href, title, text) {
  1398. href = cleanUrl$1(this.options.sanitize, this.options.baseUrl, href);
  1399. if (href === null) {
  1400. return text;
  1401. }
  1402. let out = '<img src="' + href + '" alt="' + text + '"';
  1403. if (title) {
  1404. out += ' title="' + title + '"';
  1405. }
  1406. out += this.options.xhtml ? '/>' : '>';
  1407. return out;
  1408. }
  1409. text(text) {
  1410. return text;
  1411. }
  1412. };
  1413. /**
  1414. * TextRenderer
  1415. * returns only the textual part of the token
  1416. */
  1417. var TextRenderer_1 = class TextRenderer {
  1418. // no need for block level renderers
  1419. strong(text) {
  1420. return text;
  1421. }
  1422. em(text) {
  1423. return text;
  1424. }
  1425. codespan(text) {
  1426. return text;
  1427. }
  1428. del(text) {
  1429. return text;
  1430. }
  1431. html(text) {
  1432. return text;
  1433. }
  1434. text(text) {
  1435. return text;
  1436. }
  1437. link(href, title, text) {
  1438. return '' + text;
  1439. }
  1440. image(href, title, text) {
  1441. return '' + text;
  1442. }
  1443. br() {
  1444. return '';
  1445. }
  1446. };
  1447. /**
  1448. * Slugger generates header id
  1449. */
  1450. var Slugger_1 = class Slugger {
  1451. constructor() {
  1452. this.seen = {};
  1453. }
  1454. /**
  1455. * Convert string to unique id
  1456. */
  1457. slug(value) {
  1458. let slug = value
  1459. .toLowerCase()
  1460. .trim()
  1461. // remove html tags
  1462. .replace(/<[!\/a-z].*?>/ig, '')
  1463. // remove unwanted chars
  1464. .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
  1465. .replace(/\s/g, '-');
  1466. if (this.seen.hasOwnProperty(slug)) {
  1467. const originalSlug = slug;
  1468. do {
  1469. this.seen[originalSlug]++;
  1470. slug = originalSlug + '-' + this.seen[originalSlug];
  1471. } while (this.seen.hasOwnProperty(slug));
  1472. }
  1473. this.seen[slug] = 0;
  1474. return slug;
  1475. }
  1476. };
  1477. const { defaults: defaults$3 } = defaults;
  1478. const {
  1479. unescape: unescape$1
  1480. } = helpers;
  1481. /**
  1482. * Parsing & Compiling
  1483. */
  1484. var Parser_1 = class Parser {
  1485. constructor(options) {
  1486. this.options = options || defaults$3;
  1487. this.options.renderer = this.options.renderer || new Renderer_1();
  1488. this.renderer = this.options.renderer;
  1489. this.renderer.options = this.options;
  1490. this.textRenderer = new TextRenderer_1();
  1491. this.slugger = new Slugger_1();
  1492. }
  1493. /**
  1494. * Static Parse Method
  1495. */
  1496. static parse(tokens, options) {
  1497. const parser = new Parser(options);
  1498. return parser.parse(tokens);
  1499. }
  1500. /**
  1501. * Parse Loop
  1502. */
  1503. parse(tokens, top = true) {
  1504. let out = '',
  1505. i,
  1506. j,
  1507. k,
  1508. l2,
  1509. l3,
  1510. row,
  1511. cell,
  1512. header,
  1513. body,
  1514. token,
  1515. ordered,
  1516. start,
  1517. loose,
  1518. itemBody,
  1519. item,
  1520. checked,
  1521. task,
  1522. checkbox;
  1523. const l = tokens.length;
  1524. for (i = 0; i < l; i++) {
  1525. token = tokens[i];
  1526. switch (token.type) {
  1527. case 'space': {
  1528. continue;
  1529. }
  1530. case 'hr': {
  1531. out += this.renderer.hr();
  1532. continue;
  1533. }
  1534. case 'heading': {
  1535. out += this.renderer.heading(
  1536. this.parseInline(token.tokens),
  1537. token.depth,
  1538. unescape$1(this.parseInline(token.tokens, this.textRenderer)),
  1539. this.slugger);
  1540. continue;
  1541. }
  1542. case 'code': {
  1543. out += this.renderer.code(token.text,
  1544. token.lang,
  1545. token.escaped);
  1546. continue;
  1547. }
  1548. case 'table': {
  1549. header = '';
  1550. // header
  1551. cell = '';
  1552. l2 = token.header.length;
  1553. for (j = 0; j < l2; j++) {
  1554. cell += this.renderer.tablecell(
  1555. this.parseInline(token.tokens.header[j]),
  1556. { header: true, align: token.align[j] }
  1557. );
  1558. }
  1559. header += this.renderer.tablerow(cell);
  1560. body = '';
  1561. l2 = token.cells.length;
  1562. for (j = 0; j < l2; j++) {
  1563. row = token.tokens.cells[j];
  1564. cell = '';
  1565. l3 = row.length;
  1566. for (k = 0; k < l3; k++) {
  1567. cell += this.renderer.tablecell(
  1568. this.parseInline(row[k]),
  1569. { header: false, align: token.align[k] }
  1570. );
  1571. }
  1572. body += this.renderer.tablerow(cell);
  1573. }
  1574. out += this.renderer.table(header, body);
  1575. continue;
  1576. }
  1577. case 'blockquote': {
  1578. body = this.parse(token.tokens);
  1579. out += this.renderer.blockquote(body);
  1580. continue;
  1581. }
  1582. case 'list': {
  1583. ordered = token.ordered;
  1584. start = token.start;
  1585. loose = token.loose;
  1586. l2 = token.items.length;
  1587. body = '';
  1588. for (j = 0; j < l2; j++) {
  1589. item = token.items[j];
  1590. checked = item.checked;
  1591. task = item.task;
  1592. itemBody = '';
  1593. if (item.task) {
  1594. checkbox = this.renderer.checkbox(checked);
  1595. if (loose) {
  1596. if (item.tokens[0].type === 'text') {
  1597. item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
  1598. if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
  1599. item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
  1600. }
  1601. } else {
  1602. item.tokens.unshift({
  1603. type: 'text',
  1604. text: checkbox
  1605. });
  1606. }
  1607. } else {
  1608. itemBody += checkbox;
  1609. }
  1610. }
  1611. itemBody += this.parse(item.tokens, loose);
  1612. body += this.renderer.listitem(itemBody, task, checked);
  1613. }
  1614. out += this.renderer.list(body, ordered, start);
  1615. continue;
  1616. }
  1617. case 'html': {
  1618. // TODO parse inline content if parameter markdown=1
  1619. out += this.renderer.html(token.text);
  1620. continue;
  1621. }
  1622. case 'paragraph': {
  1623. out += this.renderer.paragraph(this.parseInline(token.tokens));
  1624. continue;
  1625. }
  1626. case 'text': {
  1627. body = token.tokens ? this.parseInline(token.tokens) : token.text;
  1628. while (i + 1 < l && tokens[i + 1].type === 'text') {
  1629. token = tokens[++i];
  1630. body += '\n' + (token.tokens ? this.parseInline(token.tokens) : token.text);
  1631. }
  1632. out += top ? this.renderer.paragraph(body) : body;
  1633. continue;
  1634. }
  1635. default: {
  1636. const errMsg = 'Token with "' + token.type + '" type was not found.';
  1637. if (this.options.silent) {
  1638. console.error(errMsg);
  1639. return;
  1640. } else {
  1641. throw new Error(errMsg);
  1642. }
  1643. }
  1644. }
  1645. }
  1646. return out;
  1647. }
  1648. /**
  1649. * Parse Inline Tokens
  1650. */
  1651. parseInline(tokens, renderer) {
  1652. renderer = renderer || this.renderer;
  1653. let out = '',
  1654. i,
  1655. token;
  1656. const l = tokens.length;
  1657. for (i = 0; i < l; i++) {
  1658. token = tokens[i];
  1659. switch (token.type) {
  1660. case 'escape': {
  1661. out += renderer.text(token.text);
  1662. break;
  1663. }
  1664. case 'html': {
  1665. out += renderer.html(token.text);
  1666. break;
  1667. }
  1668. case 'link': {
  1669. out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
  1670. break;
  1671. }
  1672. case 'image': {
  1673. out += renderer.image(token.href, token.title, token.text);
  1674. break;
  1675. }
  1676. case 'strong': {
  1677. out += renderer.strong(this.parseInline(token.tokens, renderer));
  1678. break;
  1679. }
  1680. case 'em': {
  1681. out += renderer.em(this.parseInline(token.tokens, renderer));
  1682. break;
  1683. }
  1684. case 'codespan': {
  1685. out += renderer.codespan(token.text);
  1686. break;
  1687. }
  1688. case 'br': {
  1689. out += renderer.br();
  1690. break;
  1691. }
  1692. case 'del': {
  1693. out += renderer.del(this.parseInline(token.tokens, renderer));
  1694. break;
  1695. }
  1696. case 'text': {
  1697. out += renderer.text(token.text);
  1698. break;
  1699. }
  1700. default: {
  1701. const errMsg = 'Token with "' + token.type + '" type was not found.';
  1702. if (this.options.silent) {
  1703. console.error(errMsg);
  1704. return;
  1705. } else {
  1706. throw new Error(errMsg);
  1707. }
  1708. }
  1709. }
  1710. }
  1711. return out;
  1712. }
  1713. };
  1714. const {
  1715. merge: merge$2,
  1716. checkSanitizeDeprecation: checkSanitizeDeprecation$1,
  1717. escape: escape$3
  1718. } = helpers;
  1719. const {
  1720. getDefaults,
  1721. changeDefaults,
  1722. defaults: defaults$4
  1723. } = defaults;
  1724. /**
  1725. * Marked
  1726. */
  1727. function marked(src, opt, callback) {
  1728. // throw error in case of non string input
  1729. if (typeof src === 'undefined' || src === null) {
  1730. throw new Error('marked(): input parameter is undefined or null');
  1731. }
  1732. if (typeof src !== 'string') {
  1733. throw new Error('marked(): input parameter is of type '
  1734. + Object.prototype.toString.call(src) + ', string expected');
  1735. }
  1736. if (callback || typeof opt === 'function') {
  1737. if (!callback) {
  1738. callback = opt;
  1739. opt = null;
  1740. }
  1741. opt = merge$2({}, marked.defaults, opt || {});
  1742. checkSanitizeDeprecation$1(opt);
  1743. const highlight = opt.highlight;
  1744. let tokens,
  1745. pending,
  1746. i = 0;
  1747. try {
  1748. tokens = Lexer_1.lex(src, opt);
  1749. } catch (e) {
  1750. return callback(e);
  1751. }
  1752. pending = tokens.length;
  1753. const done = function(err) {
  1754. if (err) {
  1755. opt.highlight = highlight;
  1756. return callback(err);
  1757. }
  1758. let out;
  1759. try {
  1760. out = Parser_1.parse(tokens, opt);
  1761. } catch (e) {
  1762. err = e;
  1763. }
  1764. opt.highlight = highlight;
  1765. return err
  1766. ? callback(err)
  1767. : callback(null, out);
  1768. };
  1769. if (!highlight || highlight.length < 3) {
  1770. return done();
  1771. }
  1772. delete opt.highlight;
  1773. if (!pending) return done();
  1774. for (; i < tokens.length; i++) {
  1775. (function(token) {
  1776. if (token.type !== 'code') {
  1777. return --pending || done();
  1778. }
  1779. return highlight(token.text, token.lang, function(err, code) {
  1780. if (err) return done(err);
  1781. if (code == null || code === token.text) {
  1782. return --pending || done();
  1783. }
  1784. token.text = code;
  1785. token.escaped = true;
  1786. --pending || done();
  1787. });
  1788. })(tokens[i]);
  1789. }
  1790. return;
  1791. }
  1792. try {
  1793. opt = merge$2({}, marked.defaults, opt || {});
  1794. checkSanitizeDeprecation$1(opt);
  1795. return Parser_1.parse(Lexer_1.lex(src, opt), opt);
  1796. } catch (e) {
  1797. e.message += '\nPlease report this to https://github.com/markedjs/marked.';
  1798. if ((opt || marked.defaults).silent) {
  1799. return '<p>An error occurred:</p><pre>'
  1800. + escape$3(e.message + '', true)
  1801. + '</pre>';
  1802. }
  1803. throw e;
  1804. }
  1805. }
  1806. /**
  1807. * Options
  1808. */
  1809. marked.options =
  1810. marked.setOptions = function(opt) {
  1811. merge$2(marked.defaults, opt);
  1812. changeDefaults(marked.defaults);
  1813. return marked;
  1814. };
  1815. marked.getDefaults = getDefaults;
  1816. marked.defaults = defaults$4;
  1817. /**
  1818. * Expose
  1819. */
  1820. marked.Parser = Parser_1;
  1821. marked.parser = Parser_1.parse;
  1822. marked.Renderer = Renderer_1;
  1823. marked.TextRenderer = TextRenderer_1;
  1824. marked.Lexer = Lexer_1;
  1825. marked.lexer = Lexer_1.lex;
  1826. marked.Slugger = Slugger_1;
  1827. marked.parse = marked;
  1828. var marked_1 = marked;
  1829. export default marked_1;