reasonix 0.24.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dashboard/dist/app.js +618 -491
  2. package/dashboard/dist/app.js.map +1 -1
  3. package/dist/cli/{banner-demo-QKOPDSTL.js → banner-demo-C3FJP4R6.js} +2 -2
  4. package/dist/cli/{card-demo-5TVXJISK.js → card-demo-OEFBRAJP.js} +2 -2
  5. package/dist/cli/{chunk-BGTXZKNY.js → chunk-2K5D5J3I.js} +2 -2
  6. package/dist/cli/{chunk-JHXQDL7B.js → chunk-V3DLUJY6.js} +15 -5
  7. package/dist/cli/chunk-V3DLUJY6.js.map +1 -0
  8. package/dist/cli/{flicker-demo-MOB6GAW4.js → flicker-demo-YCYC5AR7.js} +3 -3
  9. package/dist/cli/index.js +616 -489
  10. package/dist/cli/index.js.map +1 -1
  11. package/dist/cli/{preview-4FOEEE5G.js → preview-7BGTDC65.js} +2 -2
  12. package/dist/cli/{renderer-demo-2BIGEV2T.js → renderer-demo-262TD7PU.js} +2 -2
  13. package/dist/cli/{select-demo-OA5N34BJ.js → select-demo-3QMFXV5D.js} +2 -2
  14. package/dist/cli/{stress-demo-I7XRPQMM.js → stress-demo-W3AU6PUZ.js} +2 -2
  15. package/package.json +2 -2
  16. package/dist/cli/chunk-JHXQDL7B.js.map +0 -1
  17. /package/dist/cli/{banner-demo-QKOPDSTL.js.map → banner-demo-C3FJP4R6.js.map} +0 -0
  18. /package/dist/cli/{card-demo-5TVXJISK.js.map → card-demo-OEFBRAJP.js.map} +0 -0
  19. /package/dist/cli/{chunk-BGTXZKNY.js.map → chunk-2K5D5J3I.js.map} +0 -0
  20. /package/dist/cli/{flicker-demo-MOB6GAW4.js.map → flicker-demo-YCYC5AR7.js.map} +0 -0
  21. /package/dist/cli/{preview-4FOEEE5G.js.map → preview-7BGTDC65.js.map} +0 -0
  22. /package/dist/cli/{renderer-demo-2BIGEV2T.js.map → renderer-demo-262TD7PU.js.map} +0 -0
  23. /package/dist/cli/{select-demo-OA5N34BJ.js.map → select-demo-3QMFXV5D.js.map} +0 -0
  24. /package/dist/cli/{stress-demo-I7XRPQMM.js.map → stress-demo-W3AU6PUZ.js.map} +0 -0
@@ -928,7 +928,7 @@ var require_core = __commonJS({
928
928
  this.html = html6;
929
929
  }
930
930
  };
931
- var escape2 = escapeHTML;
931
+ var escape3 = escapeHTML;
932
932
  var inherit = inherit$1;
933
933
  var NO_MATCH = /* @__PURE__ */ Symbol("nomatch");
934
934
  var MAX_KEYWORD_HITS = 7;
@@ -1294,7 +1294,7 @@ var require_core = __commonJS({
1294
1294
  if (err.message && err.message.includes("Illegal")) {
1295
1295
  return {
1296
1296
  language: languageName,
1297
- value: escape2(codeToHighlight),
1297
+ value: escape3(codeToHighlight),
1298
1298
  illegal: true,
1299
1299
  relevance: 0,
1300
1300
  _illegalBy: {
@@ -1309,7 +1309,7 @@ var require_core = __commonJS({
1309
1309
  } else if (SAFE_MODE) {
1310
1310
  return {
1311
1311
  language: languageName,
1312
- value: escape2(codeToHighlight),
1312
+ value: escape3(codeToHighlight),
1313
1313
  illegal: false,
1314
1314
  relevance: 0,
1315
1315
  errorRaised: err,
@@ -1323,7 +1323,7 @@ var require_core = __commonJS({
1323
1323
  }
1324
1324
  function justTextHighlightResult(code) {
1325
1325
  const result = {
1326
- value: escape2(code),
1326
+ value: escape3(code),
1327
1327
  illegal: false,
1328
1328
  relevance: 0,
1329
1329
  _top: PLAINTEXT_LANGUAGE,
@@ -19743,10 +19743,223 @@ var _defaults = _getDefaults();
19743
19743
  function changeDefaults(newDefaults) {
19744
19744
  _defaults = newDefaults;
19745
19745
  }
19746
- var escapeTest = /[&<>"']/;
19747
- var escapeReplace = new RegExp(escapeTest.source, "g");
19748
- var escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
19749
- var escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
19746
+ var noopTest = { exec: () => null };
19747
+ function edit(regex, opt = "") {
19748
+ let source = typeof regex === "string" ? regex : regex.source;
19749
+ const obj = {
19750
+ replace: (name, val) => {
19751
+ let valSource = typeof val === "string" ? val : val.source;
19752
+ valSource = valSource.replace(other.caret, "$1");
19753
+ source = source.replace(name, valSource);
19754
+ return obj;
19755
+ },
19756
+ getRegex: () => {
19757
+ return new RegExp(source, opt);
19758
+ }
19759
+ };
19760
+ return obj;
19761
+ }
19762
+ var other = {
19763
+ codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
19764
+ outputLinkReplace: /\\([\[\]])/g,
19765
+ indentCodeCompensation: /^(\s+)(?:```)/,
19766
+ beginningSpace: /^\s+/,
19767
+ endingHash: /#$/,
19768
+ startingSpaceChar: /^ /,
19769
+ endingSpaceChar: / $/,
19770
+ nonSpaceChar: /[^ ]/,
19771
+ newLineCharGlobal: /\n/g,
19772
+ tabCharGlobal: /\t/g,
19773
+ multipleSpaceGlobal: /\s+/g,
19774
+ blankLine: /^[ \t]*$/,
19775
+ doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
19776
+ blockquoteStart: /^ {0,3}>/,
19777
+ blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
19778
+ blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
19779
+ listReplaceTabs: /^\t+/,
19780
+ listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
19781
+ listIsTask: /^\[[ xX]\] /,
19782
+ listReplaceTask: /^\[[ xX]\] +/,
19783
+ anyLine: /\n.*\n/,
19784
+ hrefBrackets: /^<(.*)>$/,
19785
+ tableDelimiter: /[:|]/,
19786
+ tableAlignChars: /^\||\| *$/g,
19787
+ tableRowBlankLine: /\n[ \t]*$/,
19788
+ tableAlignRight: /^ *-+: *$/,
19789
+ tableAlignCenter: /^ *:-+: *$/,
19790
+ tableAlignLeft: /^ *:-+ *$/,
19791
+ startATag: /^<a /i,
19792
+ endATag: /^<\/a>/i,
19793
+ startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
19794
+ endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
19795
+ startAngleBracket: /^</,
19796
+ endAngleBracket: />$/,
19797
+ pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
19798
+ unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
19799
+ escapeTest: /[&<>"']/,
19800
+ escapeReplace: /[&<>"']/g,
19801
+ escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
19802
+ escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
19803
+ unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
19804
+ caret: /(^|[^\[])\^/g,
19805
+ percentDecode: /%25/g,
19806
+ findPipe: /\|/g,
19807
+ splitPipe: / \|/,
19808
+ slashPipe: /\\\|/g,
19809
+ carriageReturn: /\r\n|\r/g,
19810
+ spaceLine: /^ +$/gm,
19811
+ notSpaceStart: /^\S*/,
19812
+ endingNewline: /\n$/,
19813
+ listItemRegex: (bull) => new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`),
19814
+ nextBulletRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
19815
+ hrRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
19816
+ fencesBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`),
19817
+ headingBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`),
19818
+ htmlBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}<(?:[a-z].*>|!--)`, "i")
19819
+ };
19820
+ var newline = /^(?:[ \t]*(?:\n|$))+/;
19821
+ var blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
19822
+ var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
19823
+ var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
19824
+ var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
19825
+ var bullet = /(?:[*+-]|\d{1,9}[.)])/;
19826
+ var lheadingCore = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
19827
+ var lheading = edit(lheadingCore).replace(/bull/g, bullet).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
19828
+ var lheadingGfm = edit(lheadingCore).replace(/bull/g, bullet).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
19829
+ var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
19830
+ var blockText = /^[^\n]+/;
19831
+ var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
19832
+ var def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
19833
+ var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
19834
+ var _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
19835
+ var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
19836
+ var html3 = edit(
19837
+ "^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))",
19838
+ "i"
19839
+ ).replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
19840
+ var paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
19841
+ var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
19842
+ var blockNormal = {
19843
+ blockquote,
19844
+ code: blockCode,
19845
+ def,
19846
+ fences,
19847
+ heading,
19848
+ hr,
19849
+ html: html3,
19850
+ lheading,
19851
+ list,
19852
+ newline,
19853
+ paragraph,
19854
+ table: noopTest,
19855
+ text: blockText
19856
+ };
19857
+ var gfmTable = edit(
19858
+ "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
19859
+ ).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
19860
+ var blockGfm = {
19861
+ ...blockNormal,
19862
+ lheading: lheadingGfm,
19863
+ table: gfmTable,
19864
+ paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
19865
+ };
19866
+ var blockPedantic = {
19867
+ ...blockNormal,
19868
+ html: edit(
19869
+ `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
19870
+ ).replace("comment", _comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
19871
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
19872
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
19873
+ fences: noopTest,
19874
+ // fences not supported
19875
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
19876
+ paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
19877
+ };
19878
+ var escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
19879
+ var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
19880
+ var br = /^( {2,}|\\)\n(?!\s*$)/;
19881
+ var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
19882
+ var _punctuation = /[\p{P}\p{S}]/u;
19883
+ var _punctuationOrSpace = /[\s\p{P}\p{S}]/u;
19884
+ var _notPunctuationOrSpace = /[^\s\p{P}\p{S}]/u;
19885
+ var punctuation = edit(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, _punctuationOrSpace).getRegex();
19886
+ var _punctuationGfmStrongEm = /(?!~)[\p{P}\p{S}]/u;
19887
+ var _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u;
19888
+ var _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u;
19889
+ var blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
19890
+ var emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
19891
+ var emStrongLDelim = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuation).getRegex();
19892
+ var emStrongLDelimGfm = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuationGfmStrongEm).getRegex();
19893
+ var emStrongRDelimAstCore = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
19894
+ var emStrongRDelimAst = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
19895
+ var emStrongRDelimAstGfm = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmStrongEm).replace(/punctSpace/g, _punctuationOrSpaceGfmStrongEm).replace(/punct/g, _punctuationGfmStrongEm).getRegex();
19896
+ var emStrongRDelimUnd = edit(
19897
+ "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
19898
+ "gu"
19899
+ ).replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
19900
+ var anyPunctuation = edit(/\\(punct)/, "gu").replace(/punct/g, _punctuation).getRegex();
19901
+ var autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("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])?)+(?![-_])/).getRegex();
19902
+ var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
19903
+ var tag = edit(
19904
+ "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
19905
+ ).replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
19906
+ var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
19907
+ var link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
19908
+ var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
19909
+ var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
19910
+ var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
19911
+ var inlineNormal = {
19912
+ _backpedal: noopTest,
19913
+ // only used for GFM url
19914
+ anyPunctuation,
19915
+ autolink,
19916
+ blockSkip,
19917
+ br,
19918
+ code: inlineCode,
19919
+ del: noopTest,
19920
+ emStrongLDelim,
19921
+ emStrongRDelimAst,
19922
+ emStrongRDelimUnd,
19923
+ escape,
19924
+ link,
19925
+ nolink,
19926
+ punctuation,
19927
+ reflink,
19928
+ reflinkSearch,
19929
+ tag,
19930
+ text: inlineText,
19931
+ url: noopTest
19932
+ };
19933
+ var inlinePedantic = {
19934
+ ...inlineNormal,
19935
+ link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
19936
+ reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
19937
+ };
19938
+ var inlineGfm = {
19939
+ ...inlineNormal,
19940
+ emStrongRDelimAst: emStrongRDelimAstGfm,
19941
+ emStrongLDelim: emStrongLDelimGfm,
19942
+ url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
19943
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
19944
+ del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
19945
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
19946
+ };
19947
+ var inlineBreaks = {
19948
+ ...inlineGfm,
19949
+ br: edit(br).replace("{2,}", "*").getRegex(),
19950
+ text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
19951
+ };
19952
+ var block = {
19953
+ normal: blockNormal,
19954
+ gfm: blockGfm,
19955
+ pedantic: blockPedantic
19956
+ };
19957
+ var inline = {
19958
+ normal: inlineNormal,
19959
+ gfm: inlineGfm,
19960
+ breaks: inlineBreaks,
19961
+ pedantic: inlinePedantic
19962
+ };
19750
19963
  var escapeReplacements = {
19751
19964
  "&": "&amp;",
19752
19965
  "<": "&lt;",
@@ -19755,85 +19968,53 @@ var escapeReplacements = {
19755
19968
  "'": "&#39;"
19756
19969
  };
19757
19970
  var getEscapeReplacement = (ch) => escapeReplacements[ch];
19758
- function escape$1(html6, encode) {
19971
+ function escape2(html22, encode) {
19759
19972
  if (encode) {
19760
- if (escapeTest.test(html6)) {
19761
- return html6.replace(escapeReplace, getEscapeReplacement);
19973
+ if (other.escapeTest.test(html22)) {
19974
+ return html22.replace(other.escapeReplace, getEscapeReplacement);
19762
19975
  }
19763
19976
  } else {
19764
- if (escapeTestNoEncode.test(html6)) {
19765
- return html6.replace(escapeReplaceNoEncode, getEscapeReplacement);
19977
+ if (other.escapeTestNoEncode.test(html22)) {
19978
+ return html22.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
19766
19979
  }
19767
19980
  }
19768
- return html6;
19769
- }
19770
- var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
19771
- function unescape(html6) {
19772
- return html6.replace(unescapeTest, (_4, n3) => {
19773
- n3 = n3.toLowerCase();
19774
- if (n3 === "colon")
19775
- return ":";
19776
- if (n3.charAt(0) === "#") {
19777
- return n3.charAt(1) === "x" ? String.fromCharCode(parseInt(n3.substring(2), 16)) : String.fromCharCode(+n3.substring(1));
19778
- }
19779
- return "";
19780
- });
19781
- }
19782
- var caret = /(^|[^\[])\^/g;
19783
- function edit(regex, opt) {
19784
- let source = typeof regex === "string" ? regex : regex.source;
19785
- opt = opt || "";
19786
- const obj = {
19787
- replace: (name, val) => {
19788
- let valSource = typeof val === "string" ? val : val.source;
19789
- valSource = valSource.replace(caret, "$1");
19790
- source = source.replace(name, valSource);
19791
- return obj;
19792
- },
19793
- getRegex: () => {
19794
- return new RegExp(source, opt);
19795
- }
19796
- };
19797
- return obj;
19981
+ return html22;
19798
19982
  }
19799
19983
  function cleanUrl(href) {
19800
19984
  try {
19801
- href = encodeURI(href).replace(/%25/g, "%");
19802
- } catch (e3) {
19985
+ href = encodeURI(href).replace(other.percentDecode, "%");
19986
+ } catch {
19803
19987
  return null;
19804
19988
  }
19805
19989
  return href;
19806
19990
  }
19807
- var noopTest = { exec: () => null };
19808
19991
  function splitCells(tableRow, count) {
19809
- const row = tableRow.replace(/\|/g, (match, offset, str) => {
19992
+ const row = tableRow.replace(other.findPipe, (match, offset, str) => {
19810
19993
  let escaped = false;
19811
19994
  let curr = offset;
19812
- while (--curr >= 0 && str[curr] === "\\")
19813
- escaped = !escaped;
19995
+ while (--curr >= 0 && str[curr] === "\\") escaped = !escaped;
19814
19996
  if (escaped) {
19815
19997
  return "|";
19816
19998
  } else {
19817
19999
  return " |";
19818
20000
  }
19819
- }), cells = row.split(/ \|/);
20001
+ }), cells = row.split(other.splitPipe);
19820
20002
  let i3 = 0;
19821
20003
  if (!cells[0].trim()) {
19822
20004
  cells.shift();
19823
20005
  }
19824
- if (cells.length > 0 && !cells[cells.length - 1].trim()) {
20006
+ if (cells.length > 0 && !cells.at(-1)?.trim()) {
19825
20007
  cells.pop();
19826
20008
  }
19827
20009
  if (count) {
19828
20010
  if (cells.length > count) {
19829
20011
  cells.splice(count);
19830
20012
  } else {
19831
- while (cells.length < count)
19832
- cells.push("");
20013
+ while (cells.length < count) cells.push("");
19833
20014
  }
19834
20015
  }
19835
20016
  for (; i3 < cells.length; i3++) {
19836
- cells[i3] = cells[i3].trim().replace(/\\\|/g, "|");
20017
+ cells[i3] = cells[i3].trim().replace(other.slashPipe, "|");
19837
20018
  }
19838
20019
  return cells;
19839
20020
  }
@@ -19872,41 +20053,35 @@ function findClosingBracket(str, b2) {
19872
20053
  }
19873
20054
  }
19874
20055
  }
20056
+ if (level > 0) {
20057
+ return -2;
20058
+ }
19875
20059
  return -1;
19876
20060
  }
19877
- function outputLink(cap, link2, raw, lexer2) {
20061
+ function outputLink(cap, link2, raw, lexer2, rules) {
19878
20062
  const href = link2.href;
19879
- const title = link2.title ? escape$1(link2.title) : null;
19880
- const text = cap[1].replace(/\\([\[\]])/g, "$1");
19881
- if (cap[0].charAt(0) !== "!") {
19882
- lexer2.state.inLink = true;
19883
- const token = {
19884
- type: "link",
19885
- raw,
19886
- href,
19887
- title,
19888
- text,
19889
- tokens: lexer2.inlineTokens(text)
19890
- };
19891
- lexer2.state.inLink = false;
19892
- return token;
19893
- }
19894
- return {
19895
- type: "image",
20063
+ const title = link2.title || null;
20064
+ const text = cap[1].replace(rules.other.outputLinkReplace, "$1");
20065
+ lexer2.state.inLink = true;
20066
+ const token = {
20067
+ type: cap[0].charAt(0) === "!" ? "image" : "link",
19896
20068
  raw,
19897
20069
  href,
19898
20070
  title,
19899
- text: escape$1(text)
20071
+ text,
20072
+ tokens: lexer2.inlineTokens(text)
19900
20073
  };
20074
+ lexer2.state.inLink = false;
20075
+ return token;
19901
20076
  }
19902
- function indentCodeCompensation(raw, text) {
19903
- const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
20077
+ function indentCodeCompensation(raw, text, rules) {
20078
+ const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
19904
20079
  if (matchIndentToCode === null) {
19905
20080
  return text;
19906
20081
  }
19907
20082
  const indentToCode = matchIndentToCode[1];
19908
20083
  return text.split("\n").map((node) => {
19909
- const matchIndentInNode = node.match(/^\s+/);
20084
+ const matchIndentInNode = node.match(rules.other.beginningSpace);
19910
20085
  if (matchIndentInNode === null) {
19911
20086
  return node;
19912
20087
  }
@@ -19938,7 +20113,7 @@ var _Tokenizer = class {
19938
20113
  code(src) {
19939
20114
  const cap = this.rules.block.code.exec(src);
19940
20115
  if (cap) {
19941
- const text = cap[0].replace(/^ {1,4}/gm, "");
20116
+ const text = cap[0].replace(this.rules.other.codeRemoveIndent, "");
19942
20117
  return {
19943
20118
  type: "code",
19944
20119
  raw: cap[0],
@@ -19951,7 +20126,7 @@ var _Tokenizer = class {
19951
20126
  const cap = this.rules.block.fences.exec(src);
19952
20127
  if (cap) {
19953
20128
  const raw = cap[0];
19954
- const text = indentCodeCompensation(raw, cap[3] || "");
20129
+ const text = indentCodeCompensation(raw, cap[3] || "", this.rules);
19955
20130
  return {
19956
20131
  type: "code",
19957
20132
  raw,
@@ -19964,11 +20139,11 @@ var _Tokenizer = class {
19964
20139
  const cap = this.rules.block.heading.exec(src);
19965
20140
  if (cap) {
19966
20141
  let text = cap[2].trim();
19967
- if (/#$/.test(text)) {
20142
+ if (this.rules.other.endingHash.test(text)) {
19968
20143
  const trimmed = rtrim(text, "#");
19969
20144
  if (this.options.pedantic) {
19970
20145
  text = trimmed.trim();
19971
- } else if (!trimmed || / $/.test(trimmed)) {
20146
+ } else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
19972
20147
  text = trimmed.trim();
19973
20148
  }
19974
20149
  }
@@ -19986,22 +20161,70 @@ var _Tokenizer = class {
19986
20161
  if (cap) {
19987
20162
  return {
19988
20163
  type: "hr",
19989
- raw: cap[0]
20164
+ raw: rtrim(cap[0], "\n")
19990
20165
  };
19991
20166
  }
19992
20167
  }
19993
20168
  blockquote(src) {
19994
20169
  const cap = this.rules.block.blockquote.exec(src);
19995
20170
  if (cap) {
19996
- let text = cap[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, "\n $1");
19997
- text = rtrim(text.replace(/^ *>[ \t]?/gm, ""), "\n");
19998
- const top = this.lexer.state.top;
19999
- this.lexer.state.top = true;
20000
- const tokens = this.lexer.blockTokens(text);
20001
- this.lexer.state.top = top;
20171
+ let lines = rtrim(cap[0], "\n").split("\n");
20172
+ let raw = "";
20173
+ let text = "";
20174
+ const tokens = [];
20175
+ while (lines.length > 0) {
20176
+ let inBlockquote = false;
20177
+ const currentLines = [];
20178
+ let i3;
20179
+ for (i3 = 0; i3 < lines.length; i3++) {
20180
+ if (this.rules.other.blockquoteStart.test(lines[i3])) {
20181
+ currentLines.push(lines[i3]);
20182
+ inBlockquote = true;
20183
+ } else if (!inBlockquote) {
20184
+ currentLines.push(lines[i3]);
20185
+ } else {
20186
+ break;
20187
+ }
20188
+ }
20189
+ lines = lines.slice(i3);
20190
+ const currentRaw = currentLines.join("\n");
20191
+ const currentText = currentRaw.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
20192
+ raw = raw ? `${raw}
20193
+ ${currentRaw}` : currentRaw;
20194
+ text = text ? `${text}
20195
+ ${currentText}` : currentText;
20196
+ const top = this.lexer.state.top;
20197
+ this.lexer.state.top = true;
20198
+ this.lexer.blockTokens(currentText, tokens, true);
20199
+ this.lexer.state.top = top;
20200
+ if (lines.length === 0) {
20201
+ break;
20202
+ }
20203
+ const lastToken = tokens.at(-1);
20204
+ if (lastToken?.type === "code") {
20205
+ break;
20206
+ } else if (lastToken?.type === "blockquote") {
20207
+ const oldToken = lastToken;
20208
+ const newText = oldToken.raw + "\n" + lines.join("\n");
20209
+ const newToken = this.blockquote(newText);
20210
+ tokens[tokens.length - 1] = newToken;
20211
+ raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
20212
+ text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
20213
+ break;
20214
+ } else if (lastToken?.type === "list") {
20215
+ const oldToken = lastToken;
20216
+ const newText = oldToken.raw + "\n" + lines.join("\n");
20217
+ const newToken = this.list(newText);
20218
+ tokens[tokens.length - 1] = newToken;
20219
+ raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
20220
+ text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
20221
+ lines = newText.substring(tokens.at(-1).raw.length).split("\n");
20222
+ continue;
20223
+ }
20224
+ }
20002
20225
  return {
20003
20226
  type: "blockquote",
20004
- raw: cap[0],
20227
+ raw,
20005
20228
  tokens,
20006
20229
  text
20007
20230
  };
@@ -20024,12 +20247,12 @@ var _Tokenizer = class {
20024
20247
  if (this.options.pedantic) {
20025
20248
  bull = isordered ? bull : "[*+-]";
20026
20249
  }
20027
- const itemRegex = new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`);
20028
- let raw = "";
20029
- let itemContents = "";
20250
+ const itemRegex = this.rules.other.listItemRegex(bull);
20030
20251
  let endsWithBlankLine = false;
20031
20252
  while (src) {
20032
20253
  let endEarly = false;
20254
+ let raw = "";
20255
+ let itemContents = "";
20033
20256
  if (!(cap = itemRegex.exec(src))) {
20034
20257
  break;
20035
20258
  }
@@ -20038,34 +20261,41 @@ var _Tokenizer = class {
20038
20261
  }
20039
20262
  raw = cap[0];
20040
20263
  src = src.substring(raw.length);
20041
- let line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t5) => " ".repeat(3 * t5.length));
20264
+ let line = cap[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (t5) => " ".repeat(3 * t5.length));
20042
20265
  let nextLine = src.split("\n", 1)[0];
20266
+ let blankLine = !line.trim();
20043
20267
  let indent = 0;
20044
20268
  if (this.options.pedantic) {
20045
20269
  indent = 2;
20046
20270
  itemContents = line.trimStart();
20271
+ } else if (blankLine) {
20272
+ indent = cap[1].length + 1;
20047
20273
  } else {
20048
- indent = cap[2].search(/[^ ]/);
20274
+ indent = cap[2].search(this.rules.other.nonSpaceChar);
20049
20275
  indent = indent > 4 ? 1 : indent;
20050
20276
  itemContents = line.slice(indent);
20051
20277
  indent += cap[1].length;
20052
20278
  }
20053
- let blankLine = false;
20054
- if (!line && /^ *$/.test(nextLine)) {
20279
+ if (blankLine && this.rules.other.blankLine.test(nextLine)) {
20055
20280
  raw += nextLine + "\n";
20056
20281
  src = src.substring(nextLine.length + 1);
20057
20282
  endEarly = true;
20058
20283
  }
20059
20284
  if (!endEarly) {
20060
- const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`);
20061
- const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
20062
- const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
20063
- const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
20285
+ const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
20286
+ const hrRegex = this.rules.other.hrRegex(indent);
20287
+ const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
20288
+ const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
20289
+ const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
20064
20290
  while (src) {
20065
20291
  const rawLine = src.split("\n", 1)[0];
20292
+ let nextLineWithoutTabs;
20066
20293
  nextLine = rawLine;
20067
20294
  if (this.options.pedantic) {
20068
- nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
20295
+ nextLine = nextLine.replace(this.rules.other.listReplaceNesting, " ");
20296
+ nextLineWithoutTabs = nextLine;
20297
+ } else {
20298
+ nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, " ");
20069
20299
  }
20070
20300
  if (fencesBeginRegex.test(nextLine)) {
20071
20301
  break;
@@ -20073,19 +20303,22 @@ var _Tokenizer = class {
20073
20303
  if (headingBeginRegex.test(nextLine)) {
20074
20304
  break;
20075
20305
  }
20306
+ if (htmlBeginRegex.test(nextLine)) {
20307
+ break;
20308
+ }
20076
20309
  if (nextBulletRegex.test(nextLine)) {
20077
20310
  break;
20078
20311
  }
20079
- if (hrRegex.test(src)) {
20312
+ if (hrRegex.test(nextLine)) {
20080
20313
  break;
20081
20314
  }
20082
- if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) {
20083
- itemContents += "\n" + nextLine.slice(indent);
20315
+ if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) {
20316
+ itemContents += "\n" + nextLineWithoutTabs.slice(indent);
20084
20317
  } else {
20085
20318
  if (blankLine) {
20086
20319
  break;
20087
20320
  }
20088
- if (line.search(/[^ ]/) >= 4) {
20321
+ if (line.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4) {
20089
20322
  break;
20090
20323
  }
20091
20324
  if (fencesBeginRegex.test(line)) {
@@ -20104,23 +20337,23 @@ var _Tokenizer = class {
20104
20337
  }
20105
20338
  raw += rawLine + "\n";
20106
20339
  src = src.substring(rawLine.length + 1);
20107
- line = nextLine.slice(indent);
20340
+ line = nextLineWithoutTabs.slice(indent);
20108
20341
  }
20109
20342
  }
20110
20343
  if (!list2.loose) {
20111
20344
  if (endsWithBlankLine) {
20112
20345
  list2.loose = true;
20113
- } else if (/\n *\n *$/.test(raw)) {
20346
+ } else if (this.rules.other.doubleBlankLine.test(raw)) {
20114
20347
  endsWithBlankLine = true;
20115
20348
  }
20116
20349
  }
20117
20350
  let istask = null;
20118
20351
  let ischecked;
20119
20352
  if (this.options.gfm) {
20120
- istask = /^\[[ xX]\] /.exec(itemContents);
20353
+ istask = this.rules.other.listIsTask.exec(itemContents);
20121
20354
  if (istask) {
20122
20355
  ischecked = istask[0] !== "[ ] ";
20123
- itemContents = itemContents.replace(/^\[[ xX]\] +/, "");
20356
+ itemContents = itemContents.replace(this.rules.other.listReplaceTask, "");
20124
20357
  }
20125
20358
  }
20126
20359
  list2.items.push({
@@ -20134,15 +20367,20 @@ var _Tokenizer = class {
20134
20367
  });
20135
20368
  list2.raw += raw;
20136
20369
  }
20137
- list2.items[list2.items.length - 1].raw = raw.trimEnd();
20138
- list2.items[list2.items.length - 1].text = itemContents.trimEnd();
20370
+ const lastItem = list2.items.at(-1);
20371
+ if (lastItem) {
20372
+ lastItem.raw = lastItem.raw.trimEnd();
20373
+ lastItem.text = lastItem.text.trimEnd();
20374
+ } else {
20375
+ return;
20376
+ }
20139
20377
  list2.raw = list2.raw.trimEnd();
20140
20378
  for (let i3 = 0; i3 < list2.items.length; i3++) {
20141
20379
  this.lexer.state.top = false;
20142
20380
  list2.items[i3].tokens = this.lexer.blockTokens(list2.items[i3].text, []);
20143
20381
  if (!list2.loose) {
20144
20382
  const spacers = list2.items[i3].tokens.filter((t5) => t5.type === "space");
20145
- const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t5) => /\n.*\n/.test(t5.raw));
20383
+ const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t5) => this.rules.other.anyLine.test(t5.raw));
20146
20384
  list2.loose = hasMultipleLineBreaks;
20147
20385
  }
20148
20386
  }
@@ -20170,8 +20408,8 @@ var _Tokenizer = class {
20170
20408
  def(src) {
20171
20409
  const cap = this.rules.block.def.exec(src);
20172
20410
  if (cap) {
20173
- const tag2 = cap[1].toLowerCase().replace(/\s+/g, " ");
20174
- const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
20411
+ const tag2 = cap[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " ");
20412
+ const href = cap[2] ? cap[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
20175
20413
  const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
20176
20414
  return {
20177
20415
  type: "def",
@@ -20187,12 +20425,12 @@ var _Tokenizer = class {
20187
20425
  if (!cap) {
20188
20426
  return;
20189
20427
  }
20190
- if (!/[:|]/.test(cap[2])) {
20428
+ if (!this.rules.other.tableDelimiter.test(cap[2])) {
20191
20429
  return;
20192
20430
  }
20193
20431
  const headers = splitCells(cap[1]);
20194
- const aligns = cap[2].replace(/^\||\| *$/g, "").split("|");
20195
- const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : [];
20432
+ const aligns = cap[2].replace(this.rules.other.tableAlignChars, "").split("|");
20433
+ const rows = cap[3]?.trim() ? cap[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [];
20196
20434
  const item = {
20197
20435
  type: "table",
20198
20436
  raw: cap[0],
@@ -20204,27 +20442,31 @@ var _Tokenizer = class {
20204
20442
  return;
20205
20443
  }
20206
20444
  for (const align of aligns) {
20207
- if (/^ *-+: *$/.test(align)) {
20445
+ if (this.rules.other.tableAlignRight.test(align)) {
20208
20446
  item.align.push("right");
20209
- } else if (/^ *:-+: *$/.test(align)) {
20447
+ } else if (this.rules.other.tableAlignCenter.test(align)) {
20210
20448
  item.align.push("center");
20211
- } else if (/^ *:-+ *$/.test(align)) {
20449
+ } else if (this.rules.other.tableAlignLeft.test(align)) {
20212
20450
  item.align.push("left");
20213
20451
  } else {
20214
20452
  item.align.push(null);
20215
20453
  }
20216
20454
  }
20217
- for (const header of headers) {
20455
+ for (let i3 = 0; i3 < headers.length; i3++) {
20218
20456
  item.header.push({
20219
- text: header,
20220
- tokens: this.lexer.inline(header)
20457
+ text: headers[i3],
20458
+ tokens: this.lexer.inline(headers[i3]),
20459
+ header: true,
20460
+ align: item.align[i3]
20221
20461
  });
20222
20462
  }
20223
20463
  for (const row of rows) {
20224
- item.rows.push(splitCells(row, item.header.length).map((cell) => {
20464
+ item.rows.push(splitCells(row, item.header.length).map((cell, i3) => {
20225
20465
  return {
20226
20466
  text: cell,
20227
- tokens: this.lexer.inline(cell)
20467
+ tokens: this.lexer.inline(cell),
20468
+ header: false,
20469
+ align: item.align[i3]
20228
20470
  };
20229
20471
  }));
20230
20472
  }
@@ -20271,21 +20513,21 @@ var _Tokenizer = class {
20271
20513
  return {
20272
20514
  type: "escape",
20273
20515
  raw: cap[0],
20274
- text: escape$1(cap[1])
20516
+ text: cap[1]
20275
20517
  };
20276
20518
  }
20277
20519
  }
20278
20520
  tag(src) {
20279
20521
  const cap = this.rules.inline.tag.exec(src);
20280
20522
  if (cap) {
20281
- if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
20523
+ if (!this.lexer.state.inLink && this.rules.other.startATag.test(cap[0])) {
20282
20524
  this.lexer.state.inLink = true;
20283
- } else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
20525
+ } else if (this.lexer.state.inLink && this.rules.other.endATag.test(cap[0])) {
20284
20526
  this.lexer.state.inLink = false;
20285
20527
  }
20286
- if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
20528
+ if (!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(cap[0])) {
20287
20529
  this.lexer.state.inRawBlock = true;
20288
- } else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
20530
+ } else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) {
20289
20531
  this.lexer.state.inRawBlock = false;
20290
20532
  }
20291
20533
  return {
@@ -20302,8 +20544,8 @@ var _Tokenizer = class {
20302
20544
  const cap = this.rules.inline.link.exec(src);
20303
20545
  if (cap) {
20304
20546
  const trimmedUrl = cap[2].trim();
20305
- if (!this.options.pedantic && /^</.test(trimmedUrl)) {
20306
- if (!/>$/.test(trimmedUrl)) {
20547
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(trimmedUrl)) {
20548
+ if (!this.rules.other.endAngleBracket.test(trimmedUrl)) {
20307
20549
  return;
20308
20550
  }
20309
20551
  const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
@@ -20312,6 +20554,9 @@ var _Tokenizer = class {
20312
20554
  }
20313
20555
  } else {
20314
20556
  const lastParenIndex = findClosingBracket(cap[2], "()");
20557
+ if (lastParenIndex === -2) {
20558
+ return;
20559
+ }
20315
20560
  if (lastParenIndex > -1) {
20316
20561
  const start = cap[0].indexOf("!") === 0 ? 5 : 4;
20317
20562
  const linkLen = start + cap[1].length + lastParenIndex;
@@ -20323,7 +20568,7 @@ var _Tokenizer = class {
20323
20568
  let href = cap[2];
20324
20569
  let title = "";
20325
20570
  if (this.options.pedantic) {
20326
- const link2 = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
20571
+ const link2 = this.rules.other.pedanticHrefTitle.exec(href);
20327
20572
  if (link2) {
20328
20573
  href = link2[1];
20329
20574
  title = link2[3];
@@ -20332,8 +20577,8 @@ var _Tokenizer = class {
20332
20577
  title = cap[3] ? cap[3].slice(1, -1) : "";
20333
20578
  }
20334
20579
  href = href.trim();
20335
- if (/^</.test(href)) {
20336
- if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
20580
+ if (this.rules.other.startAngleBracket.test(href)) {
20581
+ if (this.options.pedantic && !this.rules.other.endAngleBracket.test(trimmedUrl)) {
20337
20582
  href = href.slice(1);
20338
20583
  } else {
20339
20584
  href = href.slice(1, -1);
@@ -20342,13 +20587,13 @@ var _Tokenizer = class {
20342
20587
  return outputLink(cap, {
20343
20588
  href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
20344
20589
  title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
20345
- }, cap[0], this.lexer);
20590
+ }, cap[0], this.lexer, this.rules);
20346
20591
  }
20347
20592
  }
20348
20593
  reflink(src, links) {
20349
20594
  let cap;
20350
20595
  if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
20351
- const linkString = (cap[2] || cap[1]).replace(/\s+/g, " ");
20596
+ const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ");
20352
20597
  const link2 = links[linkString.toLowerCase()];
20353
20598
  if (!link2) {
20354
20599
  const text = cap[0].charAt(0);
@@ -20358,15 +20603,13 @@ var _Tokenizer = class {
20358
20603
  text
20359
20604
  };
20360
20605
  }
20361
- return outputLink(cap, link2, cap[0], this.lexer);
20606
+ return outputLink(cap, link2, cap[0], this.lexer, this.rules);
20362
20607
  }
20363
20608
  }
20364
20609
  emStrong(src, maskedSrc, prevChar = "") {
20365
20610
  let match = this.rules.inline.emStrongLDelim.exec(src);
20366
- if (!match)
20367
- return;
20368
- if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
20369
- return;
20611
+ if (!match) return;
20612
+ if (match[3] && prevChar.match(this.rules.other.unicodeAlphaNumeric)) return;
20370
20613
  const nextChar = match[1] || match[2] || "";
20371
20614
  if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
20372
20615
  const lLength = [...match[0]].length - 1;
@@ -20376,8 +20619,7 @@ var _Tokenizer = class {
20376
20619
  maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
20377
20620
  while ((match = endReg.exec(maskedSrc)) != null) {
20378
20621
  rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
20379
- if (!rDelim)
20380
- continue;
20622
+ if (!rDelim) continue;
20381
20623
  rLength = [...rDelim].length;
20382
20624
  if (match[3] || match[4]) {
20383
20625
  delimTotal += rLength;
@@ -20389,8 +20631,7 @@ var _Tokenizer = class {
20389
20631
  }
20390
20632
  }
20391
20633
  delimTotal -= rLength;
20392
- if (delimTotal > 0)
20393
- continue;
20634
+ if (delimTotal > 0) continue;
20394
20635
  rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
20395
20636
  const lastCharLength = [...match[0]][0].length;
20396
20637
  const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
@@ -20416,13 +20657,12 @@ var _Tokenizer = class {
20416
20657
  codespan(src) {
20417
20658
  const cap = this.rules.inline.code.exec(src);
20418
20659
  if (cap) {
20419
- let text = cap[2].replace(/\n/g, " ");
20420
- const hasNonSpaceChars = /[^ ]/.test(text);
20421
- const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
20660
+ let text = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
20661
+ const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);
20662
+ const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);
20422
20663
  if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
20423
20664
  text = text.substring(1, text.length - 1);
20424
20665
  }
20425
- text = escape$1(text, true);
20426
20666
  return {
20427
20667
  type: "codespan",
20428
20668
  raw: cap[0],
@@ -20455,10 +20695,10 @@ var _Tokenizer = class {
20455
20695
  if (cap) {
20456
20696
  let text, href;
20457
20697
  if (cap[2] === "@") {
20458
- text = escape$1(cap[1]);
20698
+ text = cap[1];
20459
20699
  href = "mailto:" + text;
20460
20700
  } else {
20461
- text = escape$1(cap[1]);
20701
+ text = cap[1];
20462
20702
  href = text;
20463
20703
  }
20464
20704
  return {
@@ -20481,7 +20721,7 @@ var _Tokenizer = class {
20481
20721
  if (cap = this.rules.inline.url.exec(src)) {
20482
20722
  let text, href;
20483
20723
  if (cap[2] === "@") {
20484
- text = escape$1(cap[0]);
20724
+ text = cap[0];
20485
20725
  href = "mailto:" + text;
20486
20726
  } else {
20487
20727
  let prevCapZero;
@@ -20489,7 +20729,7 @@ var _Tokenizer = class {
20489
20729
  prevCapZero = cap[0];
20490
20730
  cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? "";
20491
20731
  } while (prevCapZero !== cap[0]);
20492
- text = escape$1(cap[0]);
20732
+ text = cap[0];
20493
20733
  if (cap[1] === "www.") {
20494
20734
  href = "http://" + cap[0];
20495
20735
  } else {
@@ -20514,138 +20754,16 @@ var _Tokenizer = class {
20514
20754
  inlineText(src) {
20515
20755
  const cap = this.rules.inline.text.exec(src);
20516
20756
  if (cap) {
20517
- let text;
20518
- if (this.lexer.state.inRawBlock) {
20519
- text = cap[0];
20520
- } else {
20521
- text = escape$1(cap[0]);
20522
- }
20757
+ const escaped = this.lexer.state.inRawBlock;
20523
20758
  return {
20524
20759
  type: "text",
20525
20760
  raw: cap[0],
20526
- text
20761
+ text: cap[0],
20762
+ escaped
20527
20763
  };
20528
20764
  }
20529
20765
  }
20530
20766
  };
20531
- var newline = /^(?: *(?:\n|$))+/;
20532
- var blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/;
20533
- var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
20534
- var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
20535
- var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
20536
- var bullet = /(?:[*+-]|\d{1,9}[.)])/;
20537
- var lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).replace(/blockCode/g, / {4}/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).getRegex();
20538
- var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
20539
- var blockText = /^[^\n]+/;
20540
- var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
20541
- var def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
20542
- var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
20543
- var _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
20544
- var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
20545
- var html3 = edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))", "i").replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
20546
- var paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
20547
- var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
20548
- var blockNormal = {
20549
- blockquote,
20550
- code: blockCode,
20551
- def,
20552
- fences,
20553
- heading,
20554
- hr,
20555
- html: html3,
20556
- lheading,
20557
- list,
20558
- newline,
20559
- paragraph,
20560
- table: noopTest,
20561
- text: blockText
20562
- };
20563
- var gfmTable = edit("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
20564
- var blockGfm = {
20565
- ...blockNormal,
20566
- table: gfmTable,
20567
- paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
20568
- };
20569
- var blockPedantic = {
20570
- ...blockNormal,
20571
- html: edit(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", _comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
20572
- def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
20573
- heading: /^(#{1,6})(.*)(?:\n+|$)/,
20574
- fences: noopTest,
20575
- // fences not supported
20576
- lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
20577
- paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
20578
- };
20579
- var escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
20580
- var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
20581
- var br = /^( {2,}|\\)\n(?!\s*$)/;
20582
- var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
20583
- var _punctuation = "\\p{P}\\p{S}";
20584
- var punctuation = edit(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, _punctuation).getRegex();
20585
- var blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
20586
- var emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, _punctuation).getRegex();
20587
- var emStrongRDelimAst = edit("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, _punctuation).getRegex();
20588
- var emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, _punctuation).getRegex();
20589
- var anyPunctuation = edit(/\\([punct])/, "gu").replace(/punct/g, _punctuation).getRegex();
20590
- var autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("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])?)+(?![-_])/).getRegex();
20591
- var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
20592
- var tag = edit("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
20593
- var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
20594
- var link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
20595
- var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
20596
- var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
20597
- var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
20598
- var inlineNormal = {
20599
- _backpedal: noopTest,
20600
- // only used for GFM url
20601
- anyPunctuation,
20602
- autolink,
20603
- blockSkip,
20604
- br,
20605
- code: inlineCode,
20606
- del: noopTest,
20607
- emStrongLDelim,
20608
- emStrongRDelimAst,
20609
- emStrongRDelimUnd,
20610
- escape,
20611
- link,
20612
- nolink,
20613
- punctuation,
20614
- reflink,
20615
- reflinkSearch,
20616
- tag,
20617
- text: inlineText,
20618
- url: noopTest
20619
- };
20620
- var inlinePedantic = {
20621
- ...inlineNormal,
20622
- link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
20623
- reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
20624
- };
20625
- var inlineGfm = {
20626
- ...inlineNormal,
20627
- escape: edit(escape).replace("])", "~|])").getRegex(),
20628
- url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
20629
- _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
20630
- del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
20631
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
20632
- };
20633
- var inlineBreaks = {
20634
- ...inlineGfm,
20635
- br: edit(br).replace("{2,}", "*").getRegex(),
20636
- text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
20637
- };
20638
- var block = {
20639
- normal: blockNormal,
20640
- gfm: blockGfm,
20641
- pedantic: blockPedantic
20642
- };
20643
- var inline = {
20644
- normal: inlineNormal,
20645
- gfm: inlineGfm,
20646
- breaks: inlineBreaks,
20647
- pedantic: inlinePedantic
20648
- };
20649
20767
  var _Lexer = class __Lexer {
20650
20768
  tokens;
20651
20769
  options;
@@ -20667,6 +20785,7 @@ var _Lexer = class __Lexer {
20667
20785
  top: true
20668
20786
  };
20669
20787
  const rules = {
20788
+ other,
20670
20789
  block: block.normal,
20671
20790
  inline: inline.normal
20672
20791
  };
@@ -20710,7 +20829,7 @@ var _Lexer = class __Lexer {
20710
20829
  * Preprocessing
20711
20830
  */
20712
20831
  lex(src) {
20713
- src = src.replace(/\r\n|\r/g, "\n");
20832
+ src = src.replace(other.carriageReturn, "\n");
20714
20833
  this.blockTokens(src, this.tokens);
20715
20834
  for (let i3 = 0; i3 < this.inlineQueue.length; i3++) {
20716
20835
  const next = this.inlineQueue[i3];
@@ -20719,20 +20838,13 @@ var _Lexer = class __Lexer {
20719
20838
  this.inlineQueue = [];
20720
20839
  return this.tokens;
20721
20840
  }
20722
- blockTokens(src, tokens = []) {
20841
+ blockTokens(src, tokens = [], lastParagraphClipped = false) {
20723
20842
  if (this.options.pedantic) {
20724
- src = src.replace(/\t/g, " ").replace(/^ +$/gm, "");
20725
- } else {
20726
- src = src.replace(/^( *)(\t+)/gm, (_4, leading, tabs) => {
20727
- return leading + " ".repeat(tabs.length);
20728
- });
20843
+ src = src.replace(other.tabCharGlobal, " ").replace(other.spaceLine, "");
20729
20844
  }
20730
- let token;
20731
- let lastToken;
20732
- let cutSrc;
20733
- let lastParagraphClipped;
20734
20845
  while (src) {
20735
- if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
20846
+ let token;
20847
+ if (this.options.extensions?.block?.some((extTokenizer) => {
20736
20848
  if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
20737
20849
  src = src.substring(token.raw.length);
20738
20850
  tokens.push(token);
@@ -20744,8 +20856,9 @@ var _Lexer = class __Lexer {
20744
20856
  }
20745
20857
  if (token = this.tokenizer.space(src)) {
20746
20858
  src = src.substring(token.raw.length);
20747
- if (token.raw.length === 1 && tokens.length > 0) {
20748
- tokens[tokens.length - 1].raw += "\n";
20859
+ const lastToken = tokens.at(-1);
20860
+ if (token.raw.length === 1 && lastToken !== void 0) {
20861
+ lastToken.raw += "\n";
20749
20862
  } else {
20750
20863
  tokens.push(token);
20751
20864
  }
@@ -20753,11 +20866,11 @@ var _Lexer = class __Lexer {
20753
20866
  }
20754
20867
  if (token = this.tokenizer.code(src)) {
20755
20868
  src = src.substring(token.raw.length);
20756
- lastToken = tokens[tokens.length - 1];
20757
- if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
20869
+ const lastToken = tokens.at(-1);
20870
+ if (lastToken?.type === "paragraph" || lastToken?.type === "text") {
20758
20871
  lastToken.raw += "\n" + token.raw;
20759
20872
  lastToken.text += "\n" + token.text;
20760
- this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
20873
+ this.inlineQueue.at(-1).src = lastToken.text;
20761
20874
  } else {
20762
20875
  tokens.push(token);
20763
20876
  }
@@ -20795,11 +20908,11 @@ var _Lexer = class __Lexer {
20795
20908
  }
20796
20909
  if (token = this.tokenizer.def(src)) {
20797
20910
  src = src.substring(token.raw.length);
20798
- lastToken = tokens[tokens.length - 1];
20799
- if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
20911
+ const lastToken = tokens.at(-1);
20912
+ if (lastToken?.type === "paragraph" || lastToken?.type === "text") {
20800
20913
  lastToken.raw += "\n" + token.raw;
20801
20914
  lastToken.text += "\n" + token.raw;
20802
- this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
20915
+ this.inlineQueue.at(-1).src = lastToken.text;
20803
20916
  } else if (!this.tokens.links[token.tag]) {
20804
20917
  this.tokens.links[token.tag] = {
20805
20918
  href: token.href,
@@ -20818,8 +20931,8 @@ var _Lexer = class __Lexer {
20818
20931
  tokens.push(token);
20819
20932
  continue;
20820
20933
  }
20821
- cutSrc = src;
20822
- if (this.options.extensions && this.options.extensions.startBlock) {
20934
+ let cutSrc = src;
20935
+ if (this.options.extensions?.startBlock) {
20823
20936
  let startIndex = Infinity;
20824
20937
  const tempSrc = src.slice(1);
20825
20938
  let tempStart;
@@ -20834,12 +20947,12 @@ var _Lexer = class __Lexer {
20834
20947
  }
20835
20948
  }
20836
20949
  if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
20837
- lastToken = tokens[tokens.length - 1];
20838
- if (lastParagraphClipped && lastToken.type === "paragraph") {
20950
+ const lastToken = tokens.at(-1);
20951
+ if (lastParagraphClipped && lastToken?.type === "paragraph") {
20839
20952
  lastToken.raw += "\n" + token.raw;
20840
20953
  lastToken.text += "\n" + token.text;
20841
20954
  this.inlineQueue.pop();
20842
- this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
20955
+ this.inlineQueue.at(-1).src = lastToken.text;
20843
20956
  } else {
20844
20957
  tokens.push(token);
20845
20958
  }
@@ -20849,12 +20962,12 @@ var _Lexer = class __Lexer {
20849
20962
  }
20850
20963
  if (token = this.tokenizer.text(src)) {
20851
20964
  src = src.substring(token.raw.length);
20852
- lastToken = tokens[tokens.length - 1];
20853
- if (lastToken && lastToken.type === "text") {
20965
+ const lastToken = tokens.at(-1);
20966
+ if (lastToken?.type === "text") {
20854
20967
  lastToken.raw += "\n" + token.raw;
20855
20968
  lastToken.text += "\n" + token.text;
20856
20969
  this.inlineQueue.pop();
20857
- this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
20970
+ this.inlineQueue.at(-1).src = lastToken.text;
20858
20971
  } else {
20859
20972
  tokens.push(token);
20860
20973
  }
@@ -20881,10 +20994,8 @@ var _Lexer = class __Lexer {
20881
20994
  * Lexing/Compiling
20882
20995
  */
20883
20996
  inlineTokens(src, tokens = []) {
20884
- let token, lastToken, cutSrc;
20885
20997
  let maskedSrc = src;
20886
- let match;
20887
- let keepPrevChar, prevChar;
20998
+ let match = null;
20888
20999
  if (this.tokens.links) {
20889
21000
  const links = Object.keys(this.tokens.links);
20890
21001
  if (links.length > 0) {
@@ -20895,18 +21006,21 @@ var _Lexer = class __Lexer {
20895
21006
  }
20896
21007
  }
20897
21008
  }
20898
- while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
20899
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
20900
- }
20901
21009
  while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
20902
21010
  maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
20903
21011
  }
21012
+ while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
21013
+ maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
21014
+ }
21015
+ let keepPrevChar = false;
21016
+ let prevChar = "";
20904
21017
  while (src) {
20905
21018
  if (!keepPrevChar) {
20906
21019
  prevChar = "";
20907
21020
  }
20908
21021
  keepPrevChar = false;
20909
- if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((extTokenizer) => {
21022
+ let token;
21023
+ if (this.options.extensions?.inline?.some((extTokenizer) => {
20910
21024
  if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
20911
21025
  src = src.substring(token.raw.length);
20912
21026
  tokens.push(token);
@@ -20923,13 +21037,7 @@ var _Lexer = class __Lexer {
20923
21037
  }
20924
21038
  if (token = this.tokenizer.tag(src)) {
20925
21039
  src = src.substring(token.raw.length);
20926
- lastToken = tokens[tokens.length - 1];
20927
- if (lastToken && token.type === "text" && lastToken.type === "text") {
20928
- lastToken.raw += token.raw;
20929
- lastToken.text += token.text;
20930
- } else {
20931
- tokens.push(token);
20932
- }
21040
+ tokens.push(token);
20933
21041
  continue;
20934
21042
  }
20935
21043
  if (token = this.tokenizer.link(src)) {
@@ -20939,8 +21047,8 @@ var _Lexer = class __Lexer {
20939
21047
  }
20940
21048
  if (token = this.tokenizer.reflink(src, this.tokens.links)) {
20941
21049
  src = src.substring(token.raw.length);
20942
- lastToken = tokens[tokens.length - 1];
20943
- if (lastToken && token.type === "text" && lastToken.type === "text") {
21050
+ const lastToken = tokens.at(-1);
21051
+ if (token.type === "text" && lastToken?.type === "text") {
20944
21052
  lastToken.raw += token.raw;
20945
21053
  lastToken.text += token.text;
20946
21054
  } else {
@@ -20978,8 +21086,8 @@ var _Lexer = class __Lexer {
20978
21086
  tokens.push(token);
20979
21087
  continue;
20980
21088
  }
20981
- cutSrc = src;
20982
- if (this.options.extensions && this.options.extensions.startInline) {
21089
+ let cutSrc = src;
21090
+ if (this.options.extensions?.startInline) {
20983
21091
  let startIndex = Infinity;
20984
21092
  const tempSrc = src.slice(1);
20985
21093
  let tempStart;
@@ -20999,8 +21107,8 @@ var _Lexer = class __Lexer {
20999
21107
  prevChar = token.raw.slice(-1);
21000
21108
  }
21001
21109
  keepPrevChar = true;
21002
- lastToken = tokens[tokens.length - 1];
21003
- if (lastToken && lastToken.type === "text") {
21110
+ const lastToken = tokens.at(-1);
21111
+ if (lastToken?.type === "text") {
21004
21112
  lastToken.raw += token.raw;
21005
21113
  lastToken.text += token.text;
21006
21114
  } else {
@@ -21023,83 +21131,135 @@ var _Lexer = class __Lexer {
21023
21131
  };
21024
21132
  var _Renderer = class {
21025
21133
  options;
21134
+ parser;
21135
+ // set by the parser
21026
21136
  constructor(options2) {
21027
21137
  this.options = options2 || _defaults;
21028
21138
  }
21029
- code(code, infostring, escaped) {
21030
- const lang = (infostring || "").match(/^\S*/)?.[0];
21031
- code = code.replace(/\n$/, "") + "\n";
21032
- if (!lang) {
21033
- return "<pre><code>" + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
21139
+ space(token) {
21140
+ return "";
21141
+ }
21142
+ code({ text, lang, escaped }) {
21143
+ const langString = (lang || "").match(other.notSpaceStart)?.[0];
21144
+ const code = text.replace(other.endingNewline, "") + "\n";
21145
+ if (!langString) {
21146
+ return "<pre><code>" + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
21034
21147
  }
21035
- return '<pre><code class="language-' + escape$1(lang) + '">' + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
21148
+ return '<pre><code class="language-' + escape2(langString) + '">' + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
21036
21149
  }
21037
- blockquote(quote) {
21150
+ blockquote({ tokens }) {
21151
+ const body = this.parser.parse(tokens);
21038
21152
  return `<blockquote>
21039
- ${quote}</blockquote>
21153
+ ${body}</blockquote>
21040
21154
  `;
21041
21155
  }
21042
- html(html6, block2) {
21043
- return html6;
21156
+ html({ text }) {
21157
+ return text;
21044
21158
  }
21045
- heading(text, level, raw) {
21046
- return `<h${level}>${text}</h${level}>
21159
+ heading({ tokens, depth }) {
21160
+ return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
21047
21161
  `;
21048
21162
  }
21049
- hr() {
21163
+ hr(token) {
21050
21164
  return "<hr>\n";
21051
21165
  }
21052
- list(body, ordered, start) {
21166
+ list(token) {
21167
+ const ordered = token.ordered;
21168
+ const start = token.start;
21169
+ let body = "";
21170
+ for (let j3 = 0; j3 < token.items.length; j3++) {
21171
+ const item = token.items[j3];
21172
+ body += this.listitem(item);
21173
+ }
21053
21174
  const type = ordered ? "ol" : "ul";
21054
- const startatt = ordered && start !== 1 ? ' start="' + start + '"' : "";
21055
- return "<" + type + startatt + ">\n" + body + "</" + type + ">\n";
21056
- }
21057
- listitem(text, task, checked) {
21058
- return `<li>${text}</li>
21175
+ const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : "";
21176
+ return "<" + type + startAttr + ">\n" + body + "</" + type + ">\n";
21177
+ }
21178
+ listitem(item) {
21179
+ let itemBody = "";
21180
+ if (item.task) {
21181
+ const checkbox = this.checkbox({ checked: !!item.checked });
21182
+ if (item.loose) {
21183
+ if (item.tokens[0]?.type === "paragraph") {
21184
+ item.tokens[0].text = checkbox + " " + item.tokens[0].text;
21185
+ if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
21186
+ item.tokens[0].tokens[0].text = checkbox + " " + escape2(item.tokens[0].tokens[0].text);
21187
+ item.tokens[0].tokens[0].escaped = true;
21188
+ }
21189
+ } else {
21190
+ item.tokens.unshift({
21191
+ type: "text",
21192
+ raw: checkbox + " ",
21193
+ text: checkbox + " ",
21194
+ escaped: true
21195
+ });
21196
+ }
21197
+ } else {
21198
+ itemBody += checkbox + " ";
21199
+ }
21200
+ }
21201
+ itemBody += this.parser.parse(item.tokens, !!item.loose);
21202
+ return `<li>${itemBody}</li>
21059
21203
  `;
21060
21204
  }
21061
- checkbox(checked) {
21205
+ checkbox({ checked }) {
21062
21206
  return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
21063
21207
  }
21064
- paragraph(text) {
21065
- return `<p>${text}</p>
21208
+ paragraph({ tokens }) {
21209
+ return `<p>${this.parser.parseInline(tokens)}</p>
21066
21210
  `;
21067
21211
  }
21068
- table(header, body) {
21069
- if (body)
21070
- body = `<tbody>${body}</tbody>`;
21212
+ table(token) {
21213
+ let header = "";
21214
+ let cell = "";
21215
+ for (let j3 = 0; j3 < token.header.length; j3++) {
21216
+ cell += this.tablecell(token.header[j3]);
21217
+ }
21218
+ header += this.tablerow({ text: cell });
21219
+ let body = "";
21220
+ for (let j3 = 0; j3 < token.rows.length; j3++) {
21221
+ const row = token.rows[j3];
21222
+ cell = "";
21223
+ for (let k3 = 0; k3 < row.length; k3++) {
21224
+ cell += this.tablecell(row[k3]);
21225
+ }
21226
+ body += this.tablerow({ text: cell });
21227
+ }
21228
+ if (body) body = `<tbody>${body}</tbody>`;
21071
21229
  return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
21072
21230
  }
21073
- tablerow(content) {
21231
+ tablerow({ text }) {
21074
21232
  return `<tr>
21075
- ${content}</tr>
21233
+ ${text}</tr>
21076
21234
  `;
21077
21235
  }
21078
- tablecell(content, flags) {
21079
- const type = flags.header ? "th" : "td";
21080
- const tag2 = flags.align ? `<${type} align="${flags.align}">` : `<${type}>`;
21236
+ tablecell(token) {
21237
+ const content = this.parser.parseInline(token.tokens);
21238
+ const type = token.header ? "th" : "td";
21239
+ const tag2 = token.align ? `<${type} align="${token.align}">` : `<${type}>`;
21081
21240
  return tag2 + content + `</${type}>
21082
21241
  `;
21083
21242
  }
21084
21243
  /**
21085
21244
  * span level renderer
21086
21245
  */
21087
- strong(text) {
21088
- return `<strong>${text}</strong>`;
21246
+ strong({ tokens }) {
21247
+ return `<strong>${this.parser.parseInline(tokens)}</strong>`;
21089
21248
  }
21090
- em(text) {
21091
- return `<em>${text}</em>`;
21249
+ em({ tokens }) {
21250
+ return `<em>${this.parser.parseInline(tokens)}</em>`;
21092
21251
  }
21093
- codespan(text) {
21094
- return `<code>${text}</code>`;
21252
+ codespan({ text }) {
21253
+ return `<code>${escape2(text, true)}</code>`;
21095
21254
  }
21096
- br() {
21255
+ br(token) {
21097
21256
  return "<br>";
21098
21257
  }
21099
- del(text) {
21100
- return `<del>${text}</del>`;
21258
+ del({ tokens }) {
21259
+ return `<del>${this.parser.parseInline(tokens)}</del>`;
21101
21260
  }
21102
- link(href, title, text) {
21261
+ link({ href, title, tokens }) {
21262
+ const text = this.parser.parseInline(tokens);
21103
21263
  const cleanHref = cleanUrl(href);
21104
21264
  if (cleanHref === null) {
21105
21265
  return text;
@@ -21107,52 +21267,55 @@ ${content}</tr>
21107
21267
  href = cleanHref;
21108
21268
  let out = '<a href="' + href + '"';
21109
21269
  if (title) {
21110
- out += ' title="' + title + '"';
21270
+ out += ' title="' + escape2(title) + '"';
21111
21271
  }
21112
21272
  out += ">" + text + "</a>";
21113
21273
  return out;
21114
21274
  }
21115
- image(href, title, text) {
21275
+ image({ href, title, text, tokens }) {
21276
+ if (tokens) {
21277
+ text = this.parser.parseInline(tokens, this.parser.textRenderer);
21278
+ }
21116
21279
  const cleanHref = cleanUrl(href);
21117
21280
  if (cleanHref === null) {
21118
- return text;
21281
+ return escape2(text);
21119
21282
  }
21120
21283
  href = cleanHref;
21121
21284
  let out = `<img src="${href}" alt="${text}"`;
21122
21285
  if (title) {
21123
- out += ` title="${title}"`;
21286
+ out += ` title="${escape2(title)}"`;
21124
21287
  }
21125
21288
  out += ">";
21126
21289
  return out;
21127
21290
  }
21128
- text(text) {
21129
- return text;
21291
+ text(token) {
21292
+ return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : "escaped" in token && token.escaped ? token.text : escape2(token.text);
21130
21293
  }
21131
21294
  };
21132
21295
  var _TextRenderer = class {
21133
21296
  // no need for block level renderers
21134
- strong(text) {
21297
+ strong({ text }) {
21135
21298
  return text;
21136
21299
  }
21137
- em(text) {
21300
+ em({ text }) {
21138
21301
  return text;
21139
21302
  }
21140
- codespan(text) {
21303
+ codespan({ text }) {
21141
21304
  return text;
21142
21305
  }
21143
- del(text) {
21306
+ del({ text }) {
21144
21307
  return text;
21145
21308
  }
21146
- html(text) {
21309
+ html({ text }) {
21147
21310
  return text;
21148
21311
  }
21149
- text(text) {
21312
+ text({ text }) {
21150
21313
  return text;
21151
21314
  }
21152
- link(href, title, text) {
21315
+ link({ text }) {
21153
21316
  return "" + text;
21154
21317
  }
21155
- image(href, title, text) {
21318
+ image({ text }) {
21156
21319
  return "" + text;
21157
21320
  }
21158
21321
  br() {
@@ -21168,6 +21331,7 @@ var _Parser = class __Parser {
21168
21331
  this.options.renderer = this.options.renderer || new _Renderer();
21169
21332
  this.renderer = this.options.renderer;
21170
21333
  this.renderer.options = this.options;
21334
+ this.renderer.parser = this;
21171
21335
  this.textRenderer = new _TextRenderer();
21172
21336
  }
21173
21337
  /**
@@ -21190,112 +21354,70 @@ var _Parser = class __Parser {
21190
21354
  parse(tokens, top = true) {
21191
21355
  let out = "";
21192
21356
  for (let i3 = 0; i3 < tokens.length; i3++) {
21193
- const token = tokens[i3];
21194
- if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
21195
- const genericToken = token;
21357
+ const anyToken = tokens[i3];
21358
+ if (this.options.extensions?.renderers?.[anyToken.type]) {
21359
+ const genericToken = anyToken;
21196
21360
  const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
21197
21361
  if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
21198
21362
  out += ret || "";
21199
21363
  continue;
21200
21364
  }
21201
21365
  }
21366
+ const token = anyToken;
21202
21367
  switch (token.type) {
21203
21368
  case "space": {
21369
+ out += this.renderer.space(token);
21204
21370
  continue;
21205
21371
  }
21206
21372
  case "hr": {
21207
- out += this.renderer.hr();
21373
+ out += this.renderer.hr(token);
21208
21374
  continue;
21209
21375
  }
21210
21376
  case "heading": {
21211
- const headingToken = token;
21212
- out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape(this.parseInline(headingToken.tokens, this.textRenderer)));
21377
+ out += this.renderer.heading(token);
21213
21378
  continue;
21214
21379
  }
21215
21380
  case "code": {
21216
- const codeToken = token;
21217
- out += this.renderer.code(codeToken.text, codeToken.lang, !!codeToken.escaped);
21381
+ out += this.renderer.code(token);
21218
21382
  continue;
21219
21383
  }
21220
21384
  case "table": {
21221
- const tableToken = token;
21222
- let header = "";
21223
- let cell = "";
21224
- for (let j3 = 0; j3 < tableToken.header.length; j3++) {
21225
- cell += this.renderer.tablecell(this.parseInline(tableToken.header[j3].tokens), { header: true, align: tableToken.align[j3] });
21226
- }
21227
- header += this.renderer.tablerow(cell);
21228
- let body = "";
21229
- for (let j3 = 0; j3 < tableToken.rows.length; j3++) {
21230
- const row = tableToken.rows[j3];
21231
- cell = "";
21232
- for (let k3 = 0; k3 < row.length; k3++) {
21233
- cell += this.renderer.tablecell(this.parseInline(row[k3].tokens), { header: false, align: tableToken.align[k3] });
21234
- }
21235
- body += this.renderer.tablerow(cell);
21236
- }
21237
- out += this.renderer.table(header, body);
21385
+ out += this.renderer.table(token);
21238
21386
  continue;
21239
21387
  }
21240
21388
  case "blockquote": {
21241
- const blockquoteToken = token;
21242
- const body = this.parse(blockquoteToken.tokens);
21243
- out += this.renderer.blockquote(body);
21389
+ out += this.renderer.blockquote(token);
21244
21390
  continue;
21245
21391
  }
21246
21392
  case "list": {
21247
- const listToken = token;
21248
- const ordered = listToken.ordered;
21249
- const start = listToken.start;
21250
- const loose = listToken.loose;
21251
- let body = "";
21252
- for (let j3 = 0; j3 < listToken.items.length; j3++) {
21253
- const item = listToken.items[j3];
21254
- const checked = item.checked;
21255
- const task = item.task;
21256
- let itemBody = "";
21257
- if (item.task) {
21258
- const checkbox = this.renderer.checkbox(!!checked);
21259
- if (loose) {
21260
- if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
21261
- item.tokens[0].text = checkbox + " " + item.tokens[0].text;
21262
- if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
21263
- item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
21264
- }
21265
- } else {
21266
- item.tokens.unshift({
21267
- type: "text",
21268
- text: checkbox + " "
21269
- });
21270
- }
21271
- } else {
21272
- itemBody += checkbox + " ";
21273
- }
21274
- }
21275
- itemBody += this.parse(item.tokens, loose);
21276
- body += this.renderer.listitem(itemBody, task, !!checked);
21277
- }
21278
- out += this.renderer.list(body, ordered, start);
21393
+ out += this.renderer.list(token);
21279
21394
  continue;
21280
21395
  }
21281
21396
  case "html": {
21282
- const htmlToken = token;
21283
- out += this.renderer.html(htmlToken.text, htmlToken.block);
21397
+ out += this.renderer.html(token);
21284
21398
  continue;
21285
21399
  }
21286
21400
  case "paragraph": {
21287
- const paragraphToken = token;
21288
- out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens));
21401
+ out += this.renderer.paragraph(token);
21289
21402
  continue;
21290
21403
  }
21291
21404
  case "text": {
21292
21405
  let textToken = token;
21293
- let body = textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text;
21406
+ let body = this.renderer.text(textToken);
21294
21407
  while (i3 + 1 < tokens.length && tokens[i3 + 1].type === "text") {
21295
21408
  textToken = tokens[++i3];
21296
- body += "\n" + (textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text);
21409
+ body += "\n" + this.renderer.text(textToken);
21410
+ }
21411
+ if (top) {
21412
+ out += this.renderer.paragraph({
21413
+ type: "paragraph",
21414
+ raw: body,
21415
+ text: body,
21416
+ tokens: [{ type: "text", raw: body, text: body, escaped: true }]
21417
+ });
21418
+ } else {
21419
+ out += body;
21297
21420
  }
21298
- out += top ? this.renderer.paragraph(body) : body;
21299
21421
  continue;
21300
21422
  }
21301
21423
  default: {
@@ -21314,66 +21436,57 @@ var _Parser = class __Parser {
21314
21436
  /**
21315
21437
  * Parse Inline Tokens
21316
21438
  */
21317
- parseInline(tokens, renderer2) {
21318
- renderer2 = renderer2 || this.renderer;
21439
+ parseInline(tokens, renderer2 = this.renderer) {
21319
21440
  let out = "";
21320
21441
  for (let i3 = 0; i3 < tokens.length; i3++) {
21321
- const token = tokens[i3];
21322
- if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
21323
- const ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
21324
- if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) {
21442
+ const anyToken = tokens[i3];
21443
+ if (this.options.extensions?.renderers?.[anyToken.type]) {
21444
+ const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
21445
+ if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
21325
21446
  out += ret || "";
21326
21447
  continue;
21327
21448
  }
21328
21449
  }
21450
+ const token = anyToken;
21329
21451
  switch (token.type) {
21330
21452
  case "escape": {
21331
- const escapeToken = token;
21332
- out += renderer2.text(escapeToken.text);
21453
+ out += renderer2.text(token);
21333
21454
  break;
21334
21455
  }
21335
21456
  case "html": {
21336
- const tagToken = token;
21337
- out += renderer2.html(tagToken.text);
21457
+ out += renderer2.html(token);
21338
21458
  break;
21339
21459
  }
21340
21460
  case "link": {
21341
- const linkToken = token;
21342
- out += renderer2.link(linkToken.href, linkToken.title, this.parseInline(linkToken.tokens, renderer2));
21461
+ out += renderer2.link(token);
21343
21462
  break;
21344
21463
  }
21345
21464
  case "image": {
21346
- const imageToken = token;
21347
- out += renderer2.image(imageToken.href, imageToken.title, imageToken.text);
21465
+ out += renderer2.image(token);
21348
21466
  break;
21349
21467
  }
21350
21468
  case "strong": {
21351
- const strongToken = token;
21352
- out += renderer2.strong(this.parseInline(strongToken.tokens, renderer2));
21469
+ out += renderer2.strong(token);
21353
21470
  break;
21354
21471
  }
21355
21472
  case "em": {
21356
- const emToken = token;
21357
- out += renderer2.em(this.parseInline(emToken.tokens, renderer2));
21473
+ out += renderer2.em(token);
21358
21474
  break;
21359
21475
  }
21360
21476
  case "codespan": {
21361
- const codespanToken = token;
21362
- out += renderer2.codespan(codespanToken.text);
21477
+ out += renderer2.codespan(token);
21363
21478
  break;
21364
21479
  }
21365
21480
  case "br": {
21366
- out += renderer2.br();
21481
+ out += renderer2.br(token);
21367
21482
  break;
21368
21483
  }
21369
21484
  case "del": {
21370
- const delToken = token;
21371
- out += renderer2.del(this.parseInline(delToken.tokens, renderer2));
21485
+ out += renderer2.del(token);
21372
21486
  break;
21373
21487
  }
21374
21488
  case "text": {
21375
- const textToken = token;
21376
- out += renderer2.text(textToken.text);
21489
+ out += renderer2.text(token);
21377
21490
  break;
21378
21491
  }
21379
21492
  default: {
@@ -21392,6 +21505,7 @@ var _Parser = class __Parser {
21392
21505
  };
21393
21506
  var _Hooks = class {
21394
21507
  options;
21508
+ block;
21395
21509
  constructor(options2) {
21396
21510
  this.options = options2 || _defaults;
21397
21511
  }
@@ -21409,8 +21523,8 @@ var _Hooks = class {
21409
21523
  /**
21410
21524
  * Process HTML after marked is finished
21411
21525
  */
21412
- postprocess(html6) {
21413
- return html6;
21526
+ postprocess(html22) {
21527
+ return html22;
21414
21528
  }
21415
21529
  /**
21416
21530
  * Process all tokens before walk tokens
@@ -21418,12 +21532,24 @@ var _Hooks = class {
21418
21532
  processAllTokens(tokens) {
21419
21533
  return tokens;
21420
21534
  }
21535
+ /**
21536
+ * Provide function to tokenize markdown
21537
+ */
21538
+ provideLexer() {
21539
+ return this.block ? _Lexer.lex : _Lexer.lexInline;
21540
+ }
21541
+ /**
21542
+ * Provide function to parse tokens
21543
+ */
21544
+ provideParser() {
21545
+ return this.block ? _Parser.parse : _Parser.parseInline;
21546
+ }
21421
21547
  };
21422
21548
  var Marked = class {
21423
21549
  defaults = _getDefaults();
21424
21550
  options = this.setOptions;
21425
- parse = this.#parseMarkdown(_Lexer.lex, _Parser.parse);
21426
- parseInline = this.#parseMarkdown(_Lexer.lexInline, _Parser.parseInline);
21551
+ parse = this.parseMarkdown(true);
21552
+ parseInline = this.parseMarkdown(false);
21427
21553
  Parser = _Parser;
21428
21554
  Renderer = _Renderer;
21429
21555
  TextRenderer = _TextRenderer;
@@ -21535,7 +21661,7 @@ var Marked = class {
21535
21661
  if (!(prop in renderer2)) {
21536
21662
  throw new Error(`renderer '${prop}' does not exist`);
21537
21663
  }
21538
- if (prop === "options") {
21664
+ if (["options", "parser"].includes(prop)) {
21539
21665
  continue;
21540
21666
  }
21541
21667
  const rendererProp = prop;
@@ -21579,7 +21705,7 @@ var Marked = class {
21579
21705
  if (!(prop in hooks)) {
21580
21706
  throw new Error(`hook '${prop}' does not exist`);
21581
21707
  }
21582
- if (prop === "options") {
21708
+ if (["options", "block"].includes(prop)) {
21583
21709
  continue;
21584
21710
  }
21585
21711
  const hooksProp = prop;
@@ -21633,17 +21759,14 @@ var Marked = class {
21633
21759
  parser(tokens, options2) {
21634
21760
  return _Parser.parse(tokens, options2 ?? this.defaults);
21635
21761
  }
21636
- #parseMarkdown(lexer2, parser2) {
21637
- return (src, options2) => {
21762
+ parseMarkdown(blockType) {
21763
+ const parse2 = (src, options2) => {
21638
21764
  const origOpt = { ...options2 };
21639
21765
  const opt = { ...this.defaults, ...origOpt };
21766
+ const throwError = this.onError(!!opt.silent, !!opt.async);
21640
21767
  if (this.defaults.async === true && origOpt.async === false) {
21641
- if (!opt.silent) {
21642
- console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.");
21643
- }
21644
- opt.async = true;
21768
+ return throwError(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
21645
21769
  }
21646
- const throwError = this.#onError(!!opt.silent, !!opt.async);
21647
21770
  if (typeof src === "undefined" || src === null) {
21648
21771
  return throwError(new Error("marked(): input parameter is undefined or null"));
21649
21772
  }
@@ -21652,9 +21775,12 @@ var Marked = class {
21652
21775
  }
21653
21776
  if (opt.hooks) {
21654
21777
  opt.hooks.options = opt;
21778
+ opt.hooks.block = blockType;
21655
21779
  }
21780
+ const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
21781
+ const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
21656
21782
  if (opt.async) {
21657
- return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html6) => opt.hooks ? opt.hooks.postprocess(html6) : html6).catch(throwError);
21783
+ return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html22) => opt.hooks ? opt.hooks.postprocess(html22) : html22).catch(throwError);
21658
21784
  }
21659
21785
  try {
21660
21786
  if (opt.hooks) {
@@ -21667,21 +21793,22 @@ var Marked = class {
21667
21793
  if (opt.walkTokens) {
21668
21794
  this.walkTokens(tokens, opt.walkTokens);
21669
21795
  }
21670
- let html6 = parser2(tokens, opt);
21796
+ let html22 = parser2(tokens, opt);
21671
21797
  if (opt.hooks) {
21672
- html6 = opt.hooks.postprocess(html6);
21798
+ html22 = opt.hooks.postprocess(html22);
21673
21799
  }
21674
- return html6;
21800
+ return html22;
21675
21801
  } catch (e3) {
21676
21802
  return throwError(e3);
21677
21803
  }
21678
21804
  };
21805
+ return parse2;
21679
21806
  }
21680
- #onError(silent, async) {
21807
+ onError(silent, async) {
21681
21808
  return (e3) => {
21682
21809
  e3.message += "\nPlease report this to https://github.com/markedjs/marked.";
21683
21810
  if (silent) {
21684
- const msg = "<p>An error occurred:</p><pre>" + escape$1(e3.message + "", true) + "</pre>";
21811
+ const msg = "<p>An error occurred:</p><pre>" + escape2(e3.message + "", true) + "</pre>";
21685
21812
  if (async) {
21686
21813
  return Promise.resolve(msg);
21687
21814
  }