@caplets/pi 0.8.0 → 0.8.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 (2) hide show
  1. package/dist/index.js +1129 -1425
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -682,7 +682,7 @@ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
682
682
  return 1;
683
683
  }
684
684
  //#endregion
685
- //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.78.0/node_modules/@earendil-works/pi-tui/dist/utils.js
685
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.79.8/node_modules/@earendil-works/pi-tui/dist/utils.js
686
686
  const graphemeSegmenter$1 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
687
687
  new Intl.Segmenter(void 0, { granularity: "word" });
688
688
  /**
@@ -700,6 +700,7 @@ const leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p
700
700
  const rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
701
701
  const WIDTH_CACHE_SIZE = 512;
702
702
  const widthCache = /* @__PURE__ */ new Map();
703
+ const cjkBreakRegex = /[\p{Script_Extensions=Han}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}\p{Script_Extensions=Hangul}\p{Script_Extensions=Bopomofo}]/u;
703
704
  function isPrintableAscii(str) {
704
705
  for (let i = 0; i < str.length; i++) {
705
706
  const code = str.charCodeAt(i);
@@ -796,6 +797,7 @@ function finalizeTruncatedResult(prefix, prefixWidth, ellipsis, ellipsisWidth, m
796
797
  * check to avoid running the RGI_Emoji regex unnecessarily.
797
798
  */
798
799
  function graphemeWidth(segment) {
800
+ if (segment === " ") return 3;
799
801
  if (zeroWidthRegex.test(segment)) return 0;
800
802
  if (couldBeEmoji(segment) && rgiEmojiRegex.test(segment)) return 2;
801
803
  const cp = segment.replace(leadingNonPrintingRegex, "").codePointAt(0);
@@ -1091,8 +1093,14 @@ function splitIntoTokensWithAnsi(text) {
1091
1093
  const tokens = [];
1092
1094
  let current = "";
1093
1095
  let pendingAnsi = "";
1094
- let inWhitespace = false;
1096
+ let currentKind = null;
1095
1097
  let i = 0;
1098
+ const flushCurrent = () => {
1099
+ if (!current) return;
1100
+ tokens.push(current);
1101
+ current = "";
1102
+ currentKind = null;
1103
+ };
1096
1104
  while (i < text.length) {
1097
1105
  const ansiResult = extractAnsiCode(text, i);
1098
1106
  if (ansiResult) {
@@ -1100,21 +1108,31 @@ function splitIntoTokensWithAnsi(text) {
1100
1108
  i += ansiResult.length;
1101
1109
  continue;
1102
1110
  }
1103
- const char = text[i];
1104
- const charIsSpace = char === " ";
1105
- if (charIsSpace !== inWhitespace && current) {
1106
- tokens.push(current);
1107
- current = "";
1108
- }
1109
- if (pendingAnsi) {
1110
- current += pendingAnsi;
1111
- pendingAnsi = "";
1111
+ let end = i;
1112
+ while (end < text.length && !extractAnsiCode(text, end)) end++;
1113
+ for (const { segment } of graphemeSegmenter$1.segment(text.slice(i, end))) {
1114
+ const segmentIsSpace = segment === " ";
1115
+ if (!segmentIsSpace && cjkBreakRegex.test(segment)) {
1116
+ flushCurrent();
1117
+ const token = pendingAnsi + segment;
1118
+ pendingAnsi = "";
1119
+ tokens.push(token);
1120
+ continue;
1121
+ }
1122
+ const segmentKind = segmentIsSpace ? "space" : "word";
1123
+ if (current && currentKind !== segmentKind) flushCurrent();
1124
+ if (pendingAnsi) {
1125
+ current += pendingAnsi;
1126
+ pendingAnsi = "";
1127
+ }
1128
+ currentKind = segmentKind;
1129
+ current += segment;
1112
1130
  }
1113
- inWhitespace = charIsSpace;
1114
- current += char;
1115
- i++;
1131
+ i = end;
1116
1132
  }
1117
- if (pendingAnsi) current += pendingAnsi;
1133
+ if (pendingAnsi) if (current) current += pendingAnsi;
1134
+ else if (tokens.length > 0) tokens[tokens.length - 1] += pendingAnsi;
1135
+ else current = pendingAnsi;
1118
1136
  if (current) tokens.push(current);
1119
1137
  return tokens;
1120
1138
  }
@@ -1364,7 +1382,7 @@ function truncateToWidth(text, maxWidth, ellipsis = "...", pad = false) {
1364
1382
  }
1365
1383
  new AnsiCodeTracker();
1366
1384
  //#endregion
1367
- //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.78.0/node_modules/@earendil-works/pi-tui/dist/keys.js
1385
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.79.8/node_modules/@earendil-works/pi-tui/dist/keys.js
1368
1386
  const MODIFIERS = {
1369
1387
  shift: 1,
1370
1388
  alt: 2,
@@ -1386,38 +1404,10 @@ const FUNCTIONAL_CODEPOINTS = {
1386
1404
  home: -14,
1387
1405
  end: -15
1388
1406
  };
1389
- new Map([
1390
- [57399, 48],
1391
- [57400, 49],
1392
- [57401, 50],
1393
- [57402, 51],
1394
- [57403, 52],
1395
- [57404, 53],
1396
- [57405, 54],
1397
- [57406, 55],
1398
- [57407, 56],
1399
- [57408, 57],
1400
- [57409, 46],
1401
- [57410, 47],
1402
- [57411, 42],
1403
- [57412, 45],
1404
- [57413, 43],
1405
- [57415, 61],
1406
- [57416, 44],
1407
- [57417, ARROW_CODEPOINTS.left],
1408
- [57418, ARROW_CODEPOINTS.right],
1409
- [57419, ARROW_CODEPOINTS.up],
1410
- [57420, ARROW_CODEPOINTS.down],
1411
- [57421, FUNCTIONAL_CODEPOINTS.pageUp],
1412
- [57422, FUNCTIONAL_CODEPOINTS.pageDown],
1413
- [57423, FUNCTIONAL_CODEPOINTS.home],
1414
- [57424, FUNCTIONAL_CODEPOINTS.end],
1415
- [57425, FUNCTIONAL_CODEPOINTS.insert],
1416
- [57426, FUNCTIONAL_CODEPOINTS.delete]
1417
- ]);
1407
+ ARROW_CODEPOINTS.left, ARROW_CODEPOINTS.right, ARROW_CODEPOINTS.up, ARROW_CODEPOINTS.down, FUNCTIONAL_CODEPOINTS.pageUp, FUNCTIONAL_CODEPOINTS.pageDown, FUNCTIONAL_CODEPOINTS.home, FUNCTIONAL_CODEPOINTS.end, FUNCTIONAL_CODEPOINTS.insert, FUNCTIONAL_CODEPOINTS.delete;
1418
1408
  MODIFIERS.shift | LOCK_MASK;
1419
1409
  //#endregion
1420
- //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.78.0/node_modules/@earendil-works/pi-tui/dist/components/text.js
1410
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.79.8/node_modules/@earendil-works/pi-tui/dist/components/text.js
1421
1411
  /**
1422
1412
  * Text component - displays multi-line text with word wrapping
1423
1413
  */
@@ -1492,51 +1482,60 @@ var Text = class {
1492
1482
  }
1493
1483
  };
1494
1484
  //#endregion
1495
- //#region ../../node_modules/.pnpm/marked@15.0.12/node_modules/marked/lib/marked.esm.js
1485
+ //#region ../../node_modules/.pnpm/marked@18.0.5/node_modules/marked/lib/marked.esm.js
1496
1486
  /**
1497
- * marked v15.0.12 - a markdown parser
1498
- * Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed)
1487
+ * marked v18.0.5 - a markdown parser
1488
+ * Copyright (c) 2018-2026, MarkedJS. (MIT License)
1489
+ * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
1499
1490
  * https://github.com/markedjs/marked
1500
1491
  */
1501
1492
  /**
1502
1493
  * DO NOT EDIT THIS FILE
1503
1494
  * The code in this file is generated from files in ./src/
1504
1495
  */
1505
- function _getDefaults() {
1496
+ function M() {
1506
1497
  return {
1507
- async: false,
1508
- breaks: false,
1498
+ async: !1,
1499
+ breaks: !1,
1509
1500
  extensions: null,
1510
- gfm: true,
1501
+ gfm: !0,
1511
1502
  hooks: null,
1512
- pedantic: false,
1503
+ pedantic: !1,
1513
1504
  renderer: null,
1514
- silent: false,
1505
+ silent: !1,
1515
1506
  tokenizer: null,
1516
1507
  walkTokens: null
1517
1508
  };
1518
1509
  }
1519
- var _defaults = _getDefaults();
1520
- function changeDefaults(newDefaults) {
1521
- _defaults = newDefaults;
1522
- }
1523
- var noopTest = { exec: () => null };
1524
- function edit(regex, opt = "") {
1525
- let source = typeof regex === "string" ? regex : regex.source;
1526
- const obj = {
1527
- replace: (name, val) => {
1528
- let valSource = typeof val === "string" ? val : val.source;
1529
- valSource = valSource.replace(other.caret, "$1");
1530
- source = source.replace(name, valSource);
1531
- return obj;
1510
+ var T = M();
1511
+ function N(l) {
1512
+ T = l;
1513
+ }
1514
+ var _ = { exec: () => null };
1515
+ function E(l) {
1516
+ let e = [];
1517
+ return (t) => {
1518
+ let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
1519
+ return s || (s = l(n), e[n] = s), s;
1520
+ };
1521
+ }
1522
+ function d(l, e = "") {
1523
+ let t = typeof l == "string" ? l : l.source, n = {
1524
+ replace: (s, r) => {
1525
+ let i = typeof r == "string" ? r : r.source;
1526
+ return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
1532
1527
  },
1533
- getRegex: () => {
1534
- return new RegExp(source, opt);
1535
- }
1528
+ getRegex: () => new RegExp(t, e)
1536
1529
  };
1537
- return obj;
1530
+ return n;
1538
1531
  }
1539
- var other = {
1532
+ var Te = ((l = "") => {
1533
+ try {
1534
+ return !!new RegExp("(?<=1)(?<!1)" + l);
1535
+ } catch {
1536
+ return !1;
1537
+ }
1538
+ })(), m = {
1540
1539
  codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
1541
1540
  outputLinkReplace: /\\([\[\]])/g,
1542
1541
  indentCodeCompensation: /^(\s+)(?:```)/,
@@ -1553,10 +1552,10 @@ var other = {
1553
1552
  blockquoteStart: /^ {0,3}>/,
1554
1553
  blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
1555
1554
  blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
1556
- listReplaceTabs: /^\t+/,
1557
1555
  listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
1558
- listIsTask: /^\[[ xX]\] /,
1556
+ listIsTask: /^\[[ xX]\] +\S/,
1559
1557
  listReplaceTask: /^\[[ xX]\] +/,
1558
+ listTaskCheckbox: /\[[ xX]\]/,
1560
1559
  anyLine: /\n.*\n/,
1561
1560
  hrefBrackets: /^<(.*)>$/,
1562
1561
  tableDelimiter: /[:|]/,
@@ -1577,7 +1576,6 @@ var other = {
1577
1576
  escapeReplace: /[&<>"']/g,
1578
1577
  escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
1579
1578
  escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
1580
- unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,
1581
1579
  caret: /(^|[^\[])\^/g,
1582
1580
  percentDecode: /%25/g,
1583
1581
  findPipe: /\|/g,
@@ -1587,1303 +1585,1073 @@ var other = {
1587
1585
  spaceLine: /^ +$/gm,
1588
1586
  notSpaceStart: /^\S*/,
1589
1587
  endingNewline: /\n$/,
1590
- listItemRegex: (bull) => new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`),
1591
- nextBulletRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
1592
- hrRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
1593
- fencesBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`),
1594
- headingBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`),
1595
- htmlBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}<(?:[a-z].*>|!--)`, "i")
1596
- };
1597
- var newline = /^(?:[ \t]*(?:\n|$))+/;
1598
- var blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
1599
- var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
1600
- var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
1601
- var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
1602
- var bullet = /(?:[*+-]|\d{1,9}[.)])/;
1603
- var lheadingCore = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
1604
- 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();
1605
- 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();
1606
- var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
1607
- var blockText = /^[^\n]+/;
1608
- var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
1609
- 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();
1610
- var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
1611
- 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";
1612
- var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
1613
- var html = 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();
1614
- 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();
1615
- var blockNormal = {
1616
- blockquote: edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex(),
1617
- code: blockCode,
1618
- def,
1619
- fences,
1620
- heading,
1621
- hr,
1622
- html,
1623
- lheading,
1624
- list,
1625
- newline,
1626
- paragraph,
1627
- table: noopTest,
1628
- text: blockText
1629
- };
1630
- 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}| {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();
1631
- var blockGfm = {
1632
- ...blockNormal,
1633
- lheading: lheadingGfm,
1634
- table: gfmTable,
1635
- 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()
1636
- };
1637
- var blockPedantic = {
1638
- ...blockNormal,
1639
- 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(),
1588
+ listItemRegex: (l) => new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`),
1589
+ nextBulletRegex: E((l) => new RegExp(`^ {0,${l}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),
1590
+ hrRegex: E((l) => new RegExp(`^ {0,${l}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),
1591
+ fencesBeginRegex: E((l) => new RegExp(`^ {0,${l}}(?:\`\`\`|~~~)`)),
1592
+ headingBeginRegex: E((l) => new RegExp(`^ {0,${l}}#`)),
1593
+ htmlBeginRegex: E((l) => new RegExp(`^ {0,${l}}<(?:[a-z].*>|!--)`, "i")),
1594
+ blockquoteBeginRegex: E((l) => new RegExp(`^ {0,${l}}>`))
1595
+ }, Oe = /^(?:[ \t]*(?:\n|$))+/, we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, B = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, j = / {0,3}(?:[*+-]|\d{1,9}[.)])/, oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, ae = d(oe).replace(/bull/g, j).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(), Se = d(oe).replace(/bull/g, j).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(), F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, $e = /^[^\n]+/, U = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, Le = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", U).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), _e = d(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, j).getRegex(), H = "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", K = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, ze = d("^ {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", K).replace("tag", H).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), le = d(F).replace("hr", B).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[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex(), W = {
1596
+ blockquote: d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", le).getRegex(),
1597
+ code: we,
1598
+ def: Le,
1599
+ fences: ye,
1600
+ heading: Pe,
1601
+ hr: B,
1602
+ html: ze,
1603
+ lheading: ae,
1604
+ list: _e,
1605
+ newline: Oe,
1606
+ paragraph: le,
1607
+ table: _,
1608
+ text: $e
1609
+ }, se = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", B).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[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex(), Ee = {
1610
+ ...W,
1611
+ lheading: Se,
1612
+ table: se,
1613
+ paragraph: d(F).replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex()
1614
+ }, Ie = {
1615
+ ...W,
1616
+ html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", K).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(),
1640
1617
  def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
1641
1618
  heading: /^(#{1,6})(.*)(?:\n+|$)/,
1642
- fences: noopTest,
1619
+ fences: _,
1643
1620
  lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
1644
- 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()
1645
- };
1646
- var escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
1647
- var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
1648
- var br = /^( {2,}|\\)\n(?!\s*$)/;
1649
- var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
1650
- var _punctuation = /[\p{P}\p{S}]/u;
1651
- var _punctuationOrSpace = /[\s\p{P}\p{S}]/u;
1652
- var _notPunctuationOrSpace = /[^\s\p{P}\p{S}]/u;
1653
- var punctuation = edit(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, _punctuationOrSpace).getRegex();
1654
- var _punctuationGfmStrongEm = /(?!~)[\p{P}\p{S}]/u;
1655
- var _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u;
1656
- var _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u;
1657
- var blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
1658
- var emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
1659
- var emStrongLDelim = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuation).getRegex();
1660
- var emStrongLDelimGfm = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuationGfmStrongEm).getRegex();
1661
- var emStrongRDelimAstCore = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
1662
- var emStrongRDelimAst = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
1663
- var emStrongRDelimAstGfm = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmStrongEm).replace(/punctSpace/g, _punctuationOrSpaceGfmStrongEm).replace(/punct/g, _punctuationGfmStrongEm).getRegex();
1664
- var emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
1665
- var anyPunctuation = edit(/\\(punct)/, "gu").replace(/punct/g, _punctuation).getRegex();
1666
- 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();
1667
- var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
1668
- 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();
1669
- var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
1670
- var link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
1671
- var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
1672
- var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
1673
- var inlineNormal = {
1674
- _backpedal: noopTest,
1675
- anyPunctuation,
1676
- autolink,
1677
- blockSkip,
1678
- br,
1679
- code: inlineCode,
1680
- del: noopTest,
1681
- emStrongLDelim,
1682
- emStrongRDelimAst,
1683
- emStrongRDelimUnd,
1684
- escape,
1685
- link,
1686
- nolink,
1687
- punctuation,
1688
- reflink,
1689
- reflinkSearch: edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex(),
1690
- tag,
1691
- text: inlineText,
1692
- url: noopTest
1693
- };
1694
- var inlinePedantic = {
1695
- ...inlineNormal,
1696
- link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
1697
- reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
1698
- };
1699
- var inlineGfm = {
1700
- ...inlineNormal,
1701
- emStrongRDelimAst: emStrongRDelimAstGfm,
1702
- emStrongLDelim: emStrongLDelimGfm,
1703
- 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(),
1621
+ paragraph: d(F).replace("hr", B).replace("heading", ` *#{1,6} *[^
1622
+ ]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
1623
+ }, Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ue = /^( {2,}|\\)\n(?!\s*$)/, Be = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, I = /[\p{P}\p{S}]/u, Z = /[\s\p{P}\p{S}]/u, X = /[^\s\p{P}\p{S}]/u, De = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Z).getRegex(), pe = /(?!~)[\p{P}\p{S}]/u, qe = /(?!~)[\s\p{P}\p{S}]/u, ve = /(?:[^\s\p{P}\p{S}]|~)/u, He = d(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Te ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, Ze = d(ce, "u").replace(/punct/g, I).getRegex(), Ge = d(ce, "u").replace(/punct/g, pe).getRegex(), he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", Ne = d(he, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex(), Qe = d(he, "gu").replace(/notPunctSpace/g, ve).replace(/punctSpace/g, qe).replace(/punct/g, pe).getRegex(), je = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex(), Fe = d(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, I).getRegex(), Ke = d("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex(), We = d(/\\(punct)/, "gu").replace(/punct/g, I).getRegex(), Xe = d(/^<(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(), Je = d(K).replace("(?:-->|$)", "-->").getRegex(), Ve = d("^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", Je).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), v = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/, Ye = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", v).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), ke = d(/^!?\[(label)\]\[(ref)\]/).replace("label", v).replace("ref", U).getRegex(), de = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", U).getRegex(), et = d("reflink|nolink(?!\\()", "g").replace("reflink", ke).replace("nolink", de).getRegex(), ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, J = {
1624
+ _backpedal: _,
1625
+ anyPunctuation: We,
1626
+ autolink: Xe,
1627
+ blockSkip: He,
1628
+ br: ue,
1629
+ code: Ce,
1630
+ del: _,
1631
+ delLDelim: _,
1632
+ delRDelim: _,
1633
+ emStrongLDelim: Ze,
1634
+ emStrongRDelimAst: Ne,
1635
+ emStrongRDelimUnd: je,
1636
+ escape: Ae,
1637
+ link: Ye,
1638
+ nolink: de,
1639
+ punctuation: De,
1640
+ reflink: ke,
1641
+ reflinkSearch: et,
1642
+ tag: Ve,
1643
+ text: Be,
1644
+ url: _
1645
+ }, tt = {
1646
+ ...J,
1647
+ link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", v).getRegex(),
1648
+ reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", v).getRegex()
1649
+ }, Q = {
1650
+ ...J,
1651
+ emStrongRDelimAst: Qe,
1652
+ emStrongLDelim: Ge,
1653
+ delLDelim: Fe,
1654
+ delRDelim: Ke,
1655
+ url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
1704
1656
  _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
1705
- del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
1706
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
1707
- };
1708
- var inlineBreaks = {
1709
- ...inlineGfm,
1710
- br: edit(br).replace("{2,}", "*").getRegex(),
1711
- text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
1712
- };
1713
- var block = {
1714
- normal: blockNormal,
1715
- gfm: blockGfm,
1716
- pedantic: blockPedantic
1717
- };
1718
- var inline = {
1719
- normal: inlineNormal,
1720
- gfm: inlineGfm,
1721
- breaks: inlineBreaks,
1722
- pedantic: inlinePedantic
1657
+ del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
1658
+ text: d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ie).getRegex()
1659
+ }, nt = {
1660
+ ...Q,
1661
+ br: d(ue).replace("{2,}", "*").getRegex(),
1662
+ text: d(Q.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
1663
+ }, D = {
1664
+ normal: W,
1665
+ gfm: Ee,
1666
+ pedantic: Ie
1667
+ }, A = {
1668
+ normal: J,
1669
+ gfm: Q,
1670
+ breaks: nt,
1671
+ pedantic: tt
1723
1672
  };
1724
- var escapeReplacements = {
1673
+ var rt = {
1725
1674
  "&": "&amp;",
1726
1675
  "<": "&lt;",
1727
1676
  ">": "&gt;",
1728
1677
  "\"": "&quot;",
1729
1678
  "'": "&#39;"
1730
- };
1731
- var getEscapeReplacement = (ch) => escapeReplacements[ch];
1732
- function escape2(html2, encode) {
1733
- if (encode) {
1734
- if (other.escapeTest.test(html2)) return html2.replace(other.escapeReplace, getEscapeReplacement);
1735
- } else if (other.escapeTestNoEncode.test(html2)) return html2.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
1736
- return html2;
1737
- }
1738
- function cleanUrl(href) {
1679
+ }, ge = (l) => rt[l];
1680
+ function O(l, e) {
1681
+ if (e) {
1682
+ if (m.escapeTest.test(l)) return l.replace(m.escapeReplace, ge);
1683
+ } else if (m.escapeTestNoEncode.test(l)) return l.replace(m.escapeReplaceNoEncode, ge);
1684
+ return l;
1685
+ }
1686
+ function V(l) {
1739
1687
  try {
1740
- href = encodeURI(href).replace(other.percentDecode, "%");
1688
+ l = encodeURI(l).replace(m.percentDecode, "%");
1741
1689
  } catch {
1742
1690
  return null;
1743
1691
  }
1744
- return href;
1745
- }
1746
- function splitCells(tableRow, count) {
1747
- const cells = tableRow.replace(other.findPipe, (match, offset, str) => {
1748
- let escaped = false;
1749
- let curr = offset;
1750
- while (--curr >= 0 && str[curr] === "\\") escaped = !escaped;
1751
- if (escaped) return "|";
1752
- else return " |";
1753
- }).split(other.splitPipe);
1754
- let i = 0;
1755
- if (!cells[0].trim()) cells.shift();
1756
- if (cells.length > 0 && !cells.at(-1)?.trim()) cells.pop();
1757
- if (count) if (cells.length > count) cells.splice(count);
1758
- else while (cells.length < count) cells.push("");
1759
- for (; i < cells.length; i++) cells[i] = cells[i].trim().replace(other.slashPipe, "|");
1760
- return cells;
1761
- }
1762
- function rtrim(str, c, invert) {
1763
- const l = str.length;
1764
- if (l === 0) return "";
1765
- let suffLen = 0;
1766
- while (suffLen < l) {
1767
- const currChar = str.charAt(l - suffLen - 1);
1768
- if (currChar === c && !invert) suffLen++;
1769
- else if (currChar !== c && invert) suffLen++;
1692
+ return l;
1693
+ }
1694
+ function Y(l, e) {
1695
+ let n = l.replace(m.findPipe, (r, i, o) => {
1696
+ let u = !1, a = i;
1697
+ for (; --a >= 0 && o[a] === "\\";) u = !u;
1698
+ return u ? "|" : " |";
1699
+ }).split(m.splitPipe), s = 0;
1700
+ if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
1701
+ else for (; n.length < e;) n.push("");
1702
+ for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
1703
+ return n;
1704
+ }
1705
+ function $(l, e, t) {
1706
+ let n = l.length;
1707
+ if (n === 0) return "";
1708
+ let s = 0;
1709
+ for (; s < n;) {
1710
+ let r = l.charAt(n - s - 1);
1711
+ if (r === e && !t) s++;
1712
+ else if (r !== e && t) s++;
1770
1713
  else break;
1771
1714
  }
1772
- return str.slice(0, l - suffLen);
1773
- }
1774
- function findClosingBracket(str, b) {
1775
- if (str.indexOf(b[1]) === -1) return -1;
1776
- let level = 0;
1777
- for (let i = 0; i < str.length; i++) if (str[i] === "\\") i++;
1778
- else if (str[i] === b[0]) level++;
1779
- else if (str[i] === b[1]) {
1780
- level--;
1781
- if (level < 0) return i;
1782
- }
1783
- if (level > 0) return -2;
1784
- return -1;
1785
- }
1786
- function outputLink(cap, link2, raw, lexer2, rules) {
1787
- const href = link2.href;
1788
- const title = link2.title || null;
1789
- const text = cap[1].replace(rules.other.outputLinkReplace, "$1");
1790
- lexer2.state.inLink = true;
1791
- const token = {
1792
- type: cap[0].charAt(0) === "!" ? "image" : "link",
1793
- raw,
1794
- href,
1795
- title,
1796
- text,
1797
- tokens: lexer2.inlineTokens(text)
1715
+ return l.slice(0, n - s);
1716
+ }
1717
+ function ee(l) {
1718
+ let e = l.split(`
1719
+ `), t = e.length - 1;
1720
+ for (; t >= 0 && m.blankLine.test(e[t]);) t--;
1721
+ return e.length - t <= 2 ? l : e.slice(0, t + 1).join(`
1722
+ `);
1723
+ }
1724
+ function fe(l, e) {
1725
+ if (l.indexOf(e[1]) === -1) return -1;
1726
+ let t = 0;
1727
+ for (let n = 0; n < l.length; n++) if (l[n] === "\\") n++;
1728
+ else if (l[n] === e[0]) t++;
1729
+ else if (l[n] === e[1] && (t--, t < 0)) return n;
1730
+ return t > 0 ? -2 : -1;
1731
+ }
1732
+ function me(l, e = 0) {
1733
+ let t = e, n = "";
1734
+ for (let s of l) if (s === " ") {
1735
+ let r = 4 - t % 4;
1736
+ n += " ".repeat(r), t += r;
1737
+ } else n += s, t++;
1738
+ return n;
1739
+ }
1740
+ function xe(l, e, t, n, s) {
1741
+ let r = e.href, i = e.title || null, o = l[1].replace(s.other.outputLinkReplace, "$1");
1742
+ n.state.inLink = !0;
1743
+ let u = {
1744
+ type: l[0].charAt(0) === "!" ? "image" : "link",
1745
+ raw: t,
1746
+ href: r,
1747
+ title: i,
1748
+ text: o,
1749
+ tokens: n.inlineTokens(o)
1798
1750
  };
1799
- lexer2.state.inLink = false;
1800
- return token;
1801
- }
1802
- function indentCodeCompensation(raw, text, rules) {
1803
- const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
1804
- if (matchIndentToCode === null) return text;
1805
- const indentToCode = matchIndentToCode[1];
1806
- return text.split("\n").map((node) => {
1807
- const matchIndentInNode = node.match(rules.other.beginningSpace);
1808
- if (matchIndentInNode === null) return node;
1809
- const [indentInNode] = matchIndentInNode;
1810
- if (indentInNode.length >= indentToCode.length) return node.slice(indentToCode.length);
1811
- return node;
1812
- }).join("\n");
1813
- }
1814
- var _Tokenizer = class {
1751
+ return n.state.inLink = !1, u;
1752
+ }
1753
+ function st(l, e, t) {
1754
+ let n = l.match(t.other.indentCodeCompensation);
1755
+ if (n === null) return e;
1756
+ let s = n[1];
1757
+ return e.split(`
1758
+ `).map((r) => {
1759
+ let i = r.match(t.other.beginningSpace);
1760
+ if (i === null) return r;
1761
+ let [o] = i;
1762
+ return o.length >= s.length ? r.slice(s.length) : r;
1763
+ }).join(`
1764
+ `);
1765
+ }
1766
+ var w = class {
1815
1767
  options;
1816
1768
  rules;
1817
1769
  lexer;
1818
- constructor(options2) {
1819
- this.options = options2 || _defaults;
1770
+ constructor(e) {
1771
+ this.options = e || T;
1820
1772
  }
1821
- space(src) {
1822
- const cap = this.rules.block.newline.exec(src);
1823
- if (cap && cap[0].length > 0) return {
1773
+ space(e) {
1774
+ let t = this.rules.block.newline.exec(e);
1775
+ if (t && t[0].length > 0) return {
1824
1776
  type: "space",
1825
- raw: cap[0]
1777
+ raw: t[0]
1826
1778
  };
1827
1779
  }
1828
- code(src) {
1829
- const cap = this.rules.block.code.exec(src);
1830
- if (cap) {
1831
- const text = cap[0].replace(this.rules.other.codeRemoveIndent, "");
1780
+ code(e) {
1781
+ let t = this.rules.block.code.exec(e);
1782
+ if (t) {
1783
+ let n = this.options.pedantic ? t[0] : ee(t[0]);
1832
1784
  return {
1833
1785
  type: "code",
1834
- raw: cap[0],
1786
+ raw: n,
1835
1787
  codeBlockStyle: "indented",
1836
- text: !this.options.pedantic ? rtrim(text, "\n") : text
1788
+ text: n.replace(this.rules.other.codeRemoveIndent, "")
1837
1789
  };
1838
1790
  }
1839
1791
  }
1840
- fences(src) {
1841
- const cap = this.rules.block.fences.exec(src);
1842
- if (cap) {
1843
- const raw = cap[0];
1844
- const text = indentCodeCompensation(raw, cap[3] || "", this.rules);
1792
+ fences(e) {
1793
+ let t = this.rules.block.fences.exec(e);
1794
+ if (t) {
1795
+ let n = t[0], s = st(n, t[3] || "", this.rules);
1845
1796
  return {
1846
1797
  type: "code",
1847
- raw,
1848
- lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
1849
- text
1798
+ raw: n,
1799
+ lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
1800
+ text: s
1850
1801
  };
1851
1802
  }
1852
1803
  }
1853
- heading(src) {
1854
- const cap = this.rules.block.heading.exec(src);
1855
- if (cap) {
1856
- let text = cap[2].trim();
1857
- if (this.rules.other.endingHash.test(text)) {
1858
- const trimmed = rtrim(text, "#");
1859
- if (this.options.pedantic) text = trimmed.trim();
1860
- else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) text = trimmed.trim();
1804
+ heading(e) {
1805
+ let t = this.rules.block.heading.exec(e);
1806
+ if (t) {
1807
+ let n = t[2].trim();
1808
+ if (this.rules.other.endingHash.test(n)) {
1809
+ let s = $(n, "#");
1810
+ (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
1861
1811
  }
1862
1812
  return {
1863
1813
  type: "heading",
1864
- raw: cap[0],
1865
- depth: cap[1].length,
1866
- text,
1867
- tokens: this.lexer.inline(text)
1814
+ raw: $(t[0], `
1815
+ `),
1816
+ depth: t[1].length,
1817
+ text: n,
1818
+ tokens: this.lexer.inline(n)
1868
1819
  };
1869
1820
  }
1870
1821
  }
1871
- hr(src) {
1872
- const cap = this.rules.block.hr.exec(src);
1873
- if (cap) return {
1822
+ hr(e) {
1823
+ let t = this.rules.block.hr.exec(e);
1824
+ if (t) return {
1874
1825
  type: "hr",
1875
- raw: rtrim(cap[0], "\n")
1826
+ raw: $(t[0], `
1827
+ `)
1876
1828
  };
1877
1829
  }
1878
- blockquote(src) {
1879
- const cap = this.rules.block.blockquote.exec(src);
1880
- if (cap) {
1881
- let lines = rtrim(cap[0], "\n").split("\n");
1882
- let raw = "";
1883
- let text = "";
1884
- const tokens = [];
1885
- while (lines.length > 0) {
1886
- let inBlockquote = false;
1887
- const currentLines = [];
1888
- let i;
1889
- for (i = 0; i < lines.length; i++) if (this.rules.other.blockquoteStart.test(lines[i])) {
1890
- currentLines.push(lines[i]);
1891
- inBlockquote = true;
1892
- } else if (!inBlockquote) currentLines.push(lines[i]);
1830
+ blockquote(e) {
1831
+ let t = this.rules.block.blockquote.exec(e);
1832
+ if (t) {
1833
+ let n = $(t[0], `
1834
+ `).split(`
1835
+ `), s = "", r = "", i = [];
1836
+ for (; n.length > 0;) {
1837
+ let o = !1, u = [], a;
1838
+ for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) u.push(n[a]), o = !0;
1839
+ else if (!o) u.push(n[a]);
1893
1840
  else break;
1894
- lines = lines.slice(i);
1895
- const currentRaw = currentLines.join("\n");
1896
- const currentText = currentRaw.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
1897
- raw = raw ? `${raw}
1898
- ${currentRaw}` : currentRaw;
1899
- text = text ? `${text}
1900
- ${currentText}` : currentText;
1901
- const top = this.lexer.state.top;
1902
- this.lexer.state.top = true;
1903
- this.lexer.blockTokens(currentText, tokens, true);
1904
- this.lexer.state.top = top;
1905
- if (lines.length === 0) break;
1906
- const lastToken = tokens.at(-1);
1907
- if (lastToken?.type === "code") break;
1908
- else if (lastToken?.type === "blockquote") {
1909
- const oldToken = lastToken;
1910
- const newText = oldToken.raw + "\n" + lines.join("\n");
1911
- const newToken = this.blockquote(newText);
1912
- tokens[tokens.length - 1] = newToken;
1913
- raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
1914
- text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
1841
+ n = n.slice(a);
1842
+ let c = u.join(`
1843
+ `), p = c.replace(this.rules.other.blockquoteSetextReplace, `
1844
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
1845
+ s = s ? `${s}
1846
+ ${c}` : c, r = r ? `${r}
1847
+ ${p}` : p;
1848
+ let k = this.lexer.state.top;
1849
+ if (this.lexer.state.top = !0, this.lexer.blockTokens(p, i, !0), this.lexer.state.top = k, n.length === 0) break;
1850
+ let h = i.at(-1);
1851
+ if (h?.type === "code") break;
1852
+ if (h?.type === "blockquote") {
1853
+ let R = h, f = R.raw + `
1854
+ ` + n.join(`
1855
+ `), S = this.blockquote(f);
1856
+ i[i.length - 1] = S, s = s.substring(0, s.length - R.raw.length) + S.raw, r = r.substring(0, r.length - R.text.length) + S.text;
1915
1857
  break;
1916
- } else if (lastToken?.type === "list") {
1917
- const oldToken = lastToken;
1918
- const newText = oldToken.raw + "\n" + lines.join("\n");
1919
- const newToken = this.list(newText);
1920
- tokens[tokens.length - 1] = newToken;
1921
- raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
1922
- text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
1923
- lines = newText.substring(tokens.at(-1).raw.length).split("\n");
1858
+ } else if (h?.type === "list") {
1859
+ let R = h, f = R.raw + `
1860
+ ` + n.join(`
1861
+ `), S = this.list(f);
1862
+ i[i.length - 1] = S, s = s.substring(0, s.length - h.raw.length) + S.raw, r = r.substring(0, r.length - R.raw.length) + S.raw, n = f.substring(i.at(-1).raw.length).split(`
1863
+ `);
1924
1864
  continue;
1925
1865
  }
1926
1866
  }
1927
1867
  return {
1928
1868
  type: "blockquote",
1929
- raw,
1930
- tokens,
1931
- text
1869
+ raw: s,
1870
+ tokens: i,
1871
+ text: r
1932
1872
  };
1933
1873
  }
1934
1874
  }
1935
- list(src) {
1936
- let cap = this.rules.block.list.exec(src);
1937
- if (cap) {
1938
- let bull = cap[1].trim();
1939
- const isordered = bull.length > 1;
1940
- const list2 = {
1875
+ list(e) {
1876
+ let t = this.rules.block.list.exec(e);
1877
+ if (t) {
1878
+ let n = t[1].trim(), s = n.length > 1, r = {
1941
1879
  type: "list",
1942
1880
  raw: "",
1943
- ordered: isordered,
1944
- start: isordered ? +bull.slice(0, -1) : "",
1945
- loose: false,
1881
+ ordered: s,
1882
+ start: s ? +n.slice(0, -1) : "",
1883
+ loose: !1,
1946
1884
  items: []
1947
1885
  };
1948
- bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
1949
- if (this.options.pedantic) bull = isordered ? bull : "[*+-]";
1950
- const itemRegex = this.rules.other.listItemRegex(bull);
1951
- let endsWithBlankLine = false;
1952
- while (src) {
1953
- let endEarly = false;
1954
- let raw = "";
1955
- let itemContents = "";
1956
- if (!(cap = itemRegex.exec(src))) break;
1957
- if (this.rules.block.hr.test(src)) break;
1958
- raw = cap[0];
1959
- src = src.substring(raw.length);
1960
- let line = cap[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (t) => " ".repeat(3 * t.length));
1961
- let nextLine = src.split("\n", 1)[0];
1962
- let blankLine = !line.trim();
1963
- let indent = 0;
1964
- if (this.options.pedantic) {
1965
- indent = 2;
1966
- itemContents = line.trimStart();
1967
- } else if (blankLine) indent = cap[1].length + 1;
1968
- else {
1969
- indent = cap[2].search(this.rules.other.nonSpaceChar);
1970
- indent = indent > 4 ? 1 : indent;
1971
- itemContents = line.slice(indent);
1972
- indent += cap[1].length;
1973
- }
1974
- if (blankLine && this.rules.other.blankLine.test(nextLine)) {
1975
- raw += nextLine + "\n";
1976
- src = src.substring(nextLine.length + 1);
1977
- endEarly = true;
1978
- }
1979
- if (!endEarly) {
1980
- const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
1981
- const hrRegex = this.rules.other.hrRegex(indent);
1982
- const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
1983
- const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
1984
- const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
1985
- while (src) {
1986
- const rawLine = src.split("\n", 1)[0];
1987
- let nextLineWithoutTabs;
1988
- nextLine = rawLine;
1989
- if (this.options.pedantic) {
1990
- nextLine = nextLine.replace(this.rules.other.listReplaceNesting, " ");
1991
- nextLineWithoutTabs = nextLine;
1992
- } else nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, " ");
1993
- if (fencesBeginRegex.test(nextLine)) break;
1994
- if (headingBeginRegex.test(nextLine)) break;
1995
- if (htmlBeginRegex.test(nextLine)) break;
1996
- if (nextBulletRegex.test(nextLine)) break;
1997
- if (hrRegex.test(nextLine)) break;
1998
- if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) itemContents += "\n" + nextLineWithoutTabs.slice(indent);
1886
+ n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
1887
+ let i = this.rules.other.listItemRegex(n), o = !1;
1888
+ for (; e;) {
1889
+ let a = !1, c = "", p = "";
1890
+ if (!(t = i.exec(e)) || this.rules.block.hr.test(e)) break;
1891
+ c = t[0], e = e.substring(c.length);
1892
+ let k = me(t[2].split(`
1893
+ `, 1)[0], t[1].length), h = e.split(`
1894
+ `, 1)[0], R = !k.trim(), f = 0;
1895
+ if (this.options.pedantic ? (f = 2, p = k.trimStart()) : R ? f = t[1].length + 1 : (f = k.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, p = k.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (c += h + `
1896
+ `, e = e.substring(h.length + 1), a = !0), !a) {
1897
+ let S = this.rules.other.nextBulletRegex(f), te = this.rules.other.hrRegex(f), ne = this.rules.other.fencesBeginRegex(f), re = this.rules.other.headingBeginRegex(f), be = this.rules.other.htmlBeginRegex(f), Re = this.rules.other.blockquoteBeginRegex(f);
1898
+ for (; e;) {
1899
+ let G = e.split(`
1900
+ `, 1)[0], C;
1901
+ if (h = G, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), C = h) : C = h.replace(this.rules.other.tabCharGlobal, " "), ne.test(h) || re.test(h) || be.test(h) || Re.test(h) || S.test(h) || te.test(h)) break;
1902
+ if (C.search(this.rules.other.nonSpaceChar) >= f || !h.trim()) p += `
1903
+ ` + C.slice(f);
1999
1904
  else {
2000
- if (blankLine) break;
2001
- if (line.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4) break;
2002
- if (fencesBeginRegex.test(line)) break;
2003
- if (headingBeginRegex.test(line)) break;
2004
- if (hrRegex.test(line)) break;
2005
- itemContents += "\n" + nextLine;
1905
+ if (R || k.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(k) || re.test(k) || te.test(k)) break;
1906
+ p += `
1907
+ ` + h;
2006
1908
  }
2007
- if (!blankLine && !nextLine.trim()) blankLine = true;
2008
- raw += rawLine + "\n";
2009
- src = src.substring(rawLine.length + 1);
2010
- line = nextLineWithoutTabs.slice(indent);
2011
- }
2012
- }
2013
- if (!list2.loose) {
2014
- if (endsWithBlankLine) list2.loose = true;
2015
- else if (this.rules.other.doubleBlankLine.test(raw)) endsWithBlankLine = true;
2016
- }
2017
- let istask = null;
2018
- let ischecked;
2019
- if (this.options.gfm) {
2020
- istask = this.rules.other.listIsTask.exec(itemContents);
2021
- if (istask) {
2022
- ischecked = istask[0] !== "[ ] ";
2023
- itemContents = itemContents.replace(this.rules.other.listReplaceTask, "");
1909
+ R = !h.trim(), c += G + `
1910
+ `, e = e.substring(G.length + 1), k = C.slice(f);
2024
1911
  }
2025
1912
  }
2026
- list2.items.push({
1913
+ r.loose || (o ? r.loose = !0 : this.rules.other.doubleBlankLine.test(c) && (o = !0)), r.items.push({
2027
1914
  type: "list_item",
2028
- raw,
2029
- task: !!istask,
2030
- checked: ischecked,
2031
- loose: false,
2032
- text: itemContents,
1915
+ raw: c,
1916
+ task: !!this.options.gfm && this.rules.other.listIsTask.test(p),
1917
+ loose: !1,
1918
+ text: p,
2033
1919
  tokens: []
2034
- });
2035
- list2.raw += raw;
2036
- }
2037
- const lastItem = list2.items.at(-1);
2038
- if (lastItem) {
2039
- lastItem.raw = lastItem.raw.trimEnd();
2040
- lastItem.text = lastItem.text.trimEnd();
2041
- } else return;
2042
- list2.raw = list2.raw.trimEnd();
2043
- for (let i = 0; i < list2.items.length; i++) {
2044
- this.lexer.state.top = false;
2045
- list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);
2046
- if (!list2.loose) {
2047
- const spacers = list2.items[i].tokens.filter((t) => t.type === "space");
2048
- list2.loose = spacers.length > 0 && spacers.some((t) => this.rules.other.anyLine.test(t.raw));
1920
+ }), r.raw += c;
1921
+ }
1922
+ let u = r.items.at(-1);
1923
+ if (u) u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
1924
+ else return;
1925
+ r.raw = r.raw.trimEnd();
1926
+ for (let a of r.items) {
1927
+ this.lexer.state.top = !1, a.tokens = this.lexer.blockTokens(a.text, []);
1928
+ let c = a.tokens[0];
1929
+ if (a.task && (c?.type === "text" || c?.type === "paragraph")) {
1930
+ a.text = a.text.replace(this.rules.other.listReplaceTask, ""), c.raw = c.raw.replace(this.rules.other.listReplaceTask, ""), c.text = c.text.replace(this.rules.other.listReplaceTask, "");
1931
+ for (let k = this.lexer.inlineQueue.length - 1; k >= 0; k--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[k].src)) {
1932
+ this.lexer.inlineQueue[k].src = this.lexer.inlineQueue[k].src.replace(this.rules.other.listReplaceTask, "");
1933
+ break;
1934
+ }
1935
+ let p = this.rules.other.listTaskCheckbox.exec(a.raw);
1936
+ if (p) {
1937
+ let k = {
1938
+ type: "checkbox",
1939
+ raw: p[0] + " ",
1940
+ checked: p[0] !== "[ ]"
1941
+ };
1942
+ a.checked = k.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = k.raw + a.tokens[0].raw, a.tokens[0].text = k.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(k)) : a.tokens.unshift({
1943
+ type: "paragraph",
1944
+ raw: k.raw,
1945
+ text: k.raw,
1946
+ tokens: [k]
1947
+ }) : a.tokens.unshift(k);
1948
+ }
1949
+ } else a.task && (a.task = !1);
1950
+ if (!r.loose) {
1951
+ let p = a.tokens.filter((h) => h.type === "space");
1952
+ r.loose = p.length > 0 && p.some((h) => this.rules.other.anyLine.test(h.raw));
2049
1953
  }
2050
1954
  }
2051
- if (list2.loose) for (let i = 0; i < list2.items.length; i++) list2.items[i].loose = true;
2052
- return list2;
1955
+ if (r.loose) for (let a of r.items) {
1956
+ a.loose = !0;
1957
+ for (let c of a.tokens) c.type === "text" && (c.type = "paragraph");
1958
+ }
1959
+ return r;
2053
1960
  }
2054
1961
  }
2055
- html(src) {
2056
- const cap = this.rules.block.html.exec(src);
2057
- if (cap) return {
2058
- type: "html",
2059
- block: true,
2060
- raw: cap[0],
2061
- pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
2062
- text: cap[0]
2063
- };
1962
+ html(e) {
1963
+ let t = this.rules.block.html.exec(e);
1964
+ if (t) {
1965
+ let n = ee(t[0]);
1966
+ return {
1967
+ type: "html",
1968
+ block: !0,
1969
+ raw: n,
1970
+ pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
1971
+ text: n
1972
+ };
1973
+ }
2064
1974
  }
2065
- def(src) {
2066
- const cap = this.rules.block.def.exec(src);
2067
- if (cap) {
2068
- const tag2 = cap[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " ");
2069
- const href = cap[2] ? cap[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
2070
- const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
1975
+ def(e) {
1976
+ let t = this.rules.block.def.exec(e);
1977
+ if (t) {
1978
+ let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
2071
1979
  return {
2072
1980
  type: "def",
2073
- tag: tag2,
2074
- raw: cap[0],
2075
- href,
2076
- title
1981
+ tag: n,
1982
+ raw: $(t[0], `
1983
+ `),
1984
+ href: s,
1985
+ title: r
2077
1986
  };
2078
1987
  }
2079
1988
  }
2080
- table(src) {
2081
- const cap = this.rules.block.table.exec(src);
2082
- if (!cap) return;
2083
- if (!this.rules.other.tableDelimiter.test(cap[2])) return;
2084
- const headers = splitCells(cap[1]);
2085
- const aligns = cap[2].replace(this.rules.other.tableAlignChars, "").split("|");
2086
- const rows = cap[3]?.trim() ? cap[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [];
2087
- const item = {
1989
+ table(e) {
1990
+ let t = this.rules.block.table.exec(e);
1991
+ if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
1992
+ let n = Y(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
1993
+ `) : [], i = {
2088
1994
  type: "table",
2089
- raw: cap[0],
1995
+ raw: $(t[0], `
1996
+ `),
2090
1997
  header: [],
2091
1998
  align: [],
2092
1999
  rows: []
2093
2000
  };
2094
- if (headers.length !== aligns.length) return;
2095
- for (const align of aligns) if (this.rules.other.tableAlignRight.test(align)) item.align.push("right");
2096
- else if (this.rules.other.tableAlignCenter.test(align)) item.align.push("center");
2097
- else if (this.rules.other.tableAlignLeft.test(align)) item.align.push("left");
2098
- else item.align.push(null);
2099
- for (let i = 0; i < headers.length; i++) item.header.push({
2100
- text: headers[i],
2101
- tokens: this.lexer.inline(headers[i]),
2102
- header: true,
2103
- align: item.align[i]
2104
- });
2105
- for (const row of rows) item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
2001
+ if (n.length === s.length) {
2002
+ for (let o of s) this.rules.other.tableAlignRight.test(o) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? i.align.push("left") : i.align.push(null);
2003
+ for (let o = 0; o < n.length; o++) i.header.push({
2004
+ text: n[o],
2005
+ tokens: this.lexer.inline(n[o]),
2006
+ header: !0,
2007
+ align: i.align[o]
2008
+ });
2009
+ for (let o of r) i.rows.push(Y(o, i.header.length).map((u, a) => ({
2010
+ text: u,
2011
+ tokens: this.lexer.inline(u),
2012
+ header: !1,
2013
+ align: i.align[a]
2014
+ })));
2015
+ return i;
2016
+ }
2017
+ }
2018
+ lheading(e) {
2019
+ let t = this.rules.block.lheading.exec(e);
2020
+ if (t) {
2021
+ let n = t[1].trim();
2106
2022
  return {
2107
- text: cell,
2108
- tokens: this.lexer.inline(cell),
2109
- header: false,
2110
- align: item.align[i]
2023
+ type: "heading",
2024
+ raw: $(t[0], `
2025
+ `),
2026
+ depth: t[2].charAt(0) === "=" ? 1 : 2,
2027
+ text: n,
2028
+ tokens: this.lexer.inline(n)
2111
2029
  };
2112
- }));
2113
- return item;
2114
- }
2115
- lheading(src) {
2116
- const cap = this.rules.block.lheading.exec(src);
2117
- if (cap) return {
2118
- type: "heading",
2119
- raw: cap[0],
2120
- depth: cap[2].charAt(0) === "=" ? 1 : 2,
2121
- text: cap[1],
2122
- tokens: this.lexer.inline(cap[1])
2123
- };
2030
+ }
2124
2031
  }
2125
- paragraph(src) {
2126
- const cap = this.rules.block.paragraph.exec(src);
2127
- if (cap) {
2128
- const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
2032
+ paragraph(e) {
2033
+ let t = this.rules.block.paragraph.exec(e);
2034
+ if (t) {
2035
+ let n = t[1].charAt(t[1].length - 1) === `
2036
+ ` ? t[1].slice(0, -1) : t[1];
2129
2037
  return {
2130
2038
  type: "paragraph",
2131
- raw: cap[0],
2132
- text,
2133
- tokens: this.lexer.inline(text)
2039
+ raw: t[0],
2040
+ text: n,
2041
+ tokens: this.lexer.inline(n)
2134
2042
  };
2135
2043
  }
2136
2044
  }
2137
- text(src) {
2138
- const cap = this.rules.block.text.exec(src);
2139
- if (cap) return {
2045
+ text(e) {
2046
+ let t = this.rules.block.text.exec(e);
2047
+ if (t) return {
2140
2048
  type: "text",
2141
- raw: cap[0],
2142
- text: cap[0],
2143
- tokens: this.lexer.inline(cap[0])
2049
+ raw: t[0],
2050
+ text: t[0],
2051
+ tokens: this.lexer.inline(t[0])
2144
2052
  };
2145
2053
  }
2146
- escape(src) {
2147
- const cap = this.rules.inline.escape.exec(src);
2148
- if (cap) return {
2054
+ escape(e) {
2055
+ let t = this.rules.inline.escape.exec(e);
2056
+ if (t) return {
2149
2057
  type: "escape",
2150
- raw: cap[0],
2151
- text: cap[1]
2058
+ raw: t[0],
2059
+ text: t[1]
2152
2060
  };
2153
2061
  }
2154
- tag(src) {
2155
- const cap = this.rules.inline.tag.exec(src);
2156
- if (cap) {
2157
- if (!this.lexer.state.inLink && this.rules.other.startATag.test(cap[0])) this.lexer.state.inLink = true;
2158
- else if (this.lexer.state.inLink && this.rules.other.endATag.test(cap[0])) this.lexer.state.inLink = false;
2159
- if (!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(cap[0])) this.lexer.state.inRawBlock = true;
2160
- else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) this.lexer.state.inRawBlock = false;
2161
- return {
2162
- type: "html",
2163
- raw: cap[0],
2164
- inLink: this.lexer.state.inLink,
2165
- inRawBlock: this.lexer.state.inRawBlock,
2166
- block: false,
2167
- text: cap[0]
2168
- };
2169
- }
2062
+ tag(e) {
2063
+ let t = this.rules.inline.tag.exec(e);
2064
+ if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = !1), {
2065
+ type: "html",
2066
+ raw: t[0],
2067
+ inLink: this.lexer.state.inLink,
2068
+ inRawBlock: this.lexer.state.inRawBlock,
2069
+ block: !1,
2070
+ text: t[0]
2071
+ };
2170
2072
  }
2171
- link(src) {
2172
- const cap = this.rules.inline.link.exec(src);
2173
- if (cap) {
2174
- const trimmedUrl = cap[2].trim();
2175
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(trimmedUrl)) {
2176
- if (!this.rules.other.endAngleBracket.test(trimmedUrl)) return;
2177
- const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
2178
- if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) return;
2073
+ link(e) {
2074
+ let t = this.rules.inline.link.exec(e);
2075
+ if (t) {
2076
+ let n = t[2].trim();
2077
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
2078
+ if (!this.rules.other.endAngleBracket.test(n)) return;
2079
+ let i = $(n.slice(0, -1), "\\");
2080
+ if ((n.length - i.length) % 2 === 0) return;
2179
2081
  } else {
2180
- const lastParenIndex = findClosingBracket(cap[2], "()");
2181
- if (lastParenIndex === -2) return;
2182
- if (lastParenIndex > -1) {
2183
- const linkLen = (cap[0].indexOf("!") === 0 ? 5 : 4) + cap[1].length + lastParenIndex;
2184
- cap[2] = cap[2].substring(0, lastParenIndex);
2185
- cap[0] = cap[0].substring(0, linkLen).trim();
2186
- cap[3] = "";
2082
+ let i = fe(t[2], "()");
2083
+ if (i === -2) return;
2084
+ if (i > -1) {
2085
+ let u = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
2086
+ t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, u).trim(), t[3] = "";
2187
2087
  }
2188
2088
  }
2189
- let href = cap[2];
2190
- let title = "";
2089
+ let s = t[2], r = "";
2191
2090
  if (this.options.pedantic) {
2192
- const link2 = this.rules.other.pedanticHrefTitle.exec(href);
2193
- if (link2) {
2194
- href = link2[1];
2195
- title = link2[3];
2196
- }
2197
- } else title = cap[3] ? cap[3].slice(1, -1) : "";
2198
- href = href.trim();
2199
- if (this.rules.other.startAngleBracket.test(href)) if (this.options.pedantic && !this.rules.other.endAngleBracket.test(trimmedUrl)) href = href.slice(1);
2200
- else href = href.slice(1, -1);
2201
- return outputLink(cap, {
2202
- href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
2203
- title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
2204
- }, cap[0], this.lexer, this.rules);
2091
+ let i = this.rules.other.pedanticHrefTitle.exec(s);
2092
+ i && (s = i[1], r = i[3]);
2093
+ } else r = t[3] ? t[3].slice(1, -1) : "";
2094
+ return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), xe(t, {
2095
+ href: s && s.replace(this.rules.inline.anyPunctuation, "$1"),
2096
+ title: r && r.replace(this.rules.inline.anyPunctuation, "$1")
2097
+ }, t[0], this.lexer, this.rules);
2205
2098
  }
2206
2099
  }
2207
- reflink(src, links) {
2208
- let cap;
2209
- if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
2210
- const link2 = links[(cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ").toLowerCase()];
2211
- if (!link2) {
2212
- const text = cap[0].charAt(0);
2100
+ reflink(e, t) {
2101
+ let n;
2102
+ if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
2103
+ let r = t[(n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " ").toLowerCase()];
2104
+ if (!r) {
2105
+ let i = n[0].charAt(0);
2213
2106
  return {
2214
2107
  type: "text",
2215
- raw: text,
2216
- text
2108
+ raw: i,
2109
+ text: i
2217
2110
  };
2218
2111
  }
2219
- return outputLink(cap, link2, cap[0], this.lexer, this.rules);
2112
+ return xe(n, r, n[0], this.lexer, this.rules);
2220
2113
  }
2221
2114
  }
2222
- emStrong(src, maskedSrc, prevChar = "") {
2223
- let match = this.rules.inline.emStrongLDelim.exec(src);
2224
- if (!match) return;
2225
- if (match[3] && prevChar.match(this.rules.other.unicodeAlphaNumeric)) return;
2226
- if (!(match[1] || match[2] || "") || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
2227
- const lLength = [...match[0]].length - 1;
2228
- let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
2229
- const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
2230
- endReg.lastIndex = 0;
2231
- maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
2232
- while ((match = endReg.exec(maskedSrc)) != null) {
2233
- rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
2234
- if (!rDelim) continue;
2235
- rLength = [...rDelim].length;
2236
- if (match[3] || match[4]) {
2237
- delimTotal += rLength;
2115
+ emStrong(e, t, n = "") {
2116
+ let s = this.rules.inline.emStrongLDelim.exec(e);
2117
+ if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
2118
+ if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
2119
+ let i = [...s[0]].length - 1, o, u, a = i, c = 0, p = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
2120
+ for (p.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = p.exec(t)) !== null;) {
2121
+ if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
2122
+ if (u = [...o].length, s[3] || s[4]) {
2123
+ a += u;
2124
+ continue;
2125
+ } else if ((s[5] || s[6]) && i % 3 && !((i + u) % 3)) {
2126
+ c += u;
2238
2127
  continue;
2239
- } else if (match[5] || match[6]) {
2240
- if (lLength % 3 && !((lLength + rLength) % 3)) {
2241
- midDelimTotal += rLength;
2242
- continue;
2243
- }
2244
2128
  }
2245
- delimTotal -= rLength;
2246
- if (delimTotal > 0) continue;
2247
- rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
2248
- const lastCharLength = [...match[0]][0].length;
2249
- const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
2250
- if (Math.min(lLength, rLength) % 2) {
2251
- const text2 = raw.slice(1, -1);
2129
+ if (a -= u, a > 0) continue;
2130
+ u = Math.min(u, u + a + c);
2131
+ let k = [...s[0]][0].length, h = e.slice(0, i + s.index + k + u);
2132
+ if (Math.min(i, u) % 2) {
2133
+ let f = h.slice(1, -1);
2252
2134
  return {
2253
2135
  type: "em",
2254
- raw,
2255
- text: text2,
2256
- tokens: this.lexer.inlineTokens(text2)
2136
+ raw: h,
2137
+ text: f,
2138
+ tokens: this.lexer.inlineTokens(f)
2257
2139
  };
2258
2140
  }
2259
- const text = raw.slice(2, -2);
2141
+ let R = h.slice(2, -2);
2260
2142
  return {
2261
2143
  type: "strong",
2262
- raw,
2263
- text,
2264
- tokens: this.lexer.inlineTokens(text)
2144
+ raw: h,
2145
+ text: R,
2146
+ tokens: this.lexer.inlineTokens(R)
2265
2147
  };
2266
2148
  }
2267
2149
  }
2268
2150
  }
2269
- codespan(src) {
2270
- const cap = this.rules.inline.code.exec(src);
2271
- if (cap) {
2272
- let text = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
2273
- const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);
2274
- const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);
2275
- if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) text = text.substring(1, text.length - 1);
2276
- return {
2151
+ codespan(e) {
2152
+ let t = this.rules.inline.code.exec(e);
2153
+ if (t) {
2154
+ let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
2155
+ return s && r && (n = n.substring(1, n.length - 1)), {
2277
2156
  type: "codespan",
2278
- raw: cap[0],
2279
- text
2157
+ raw: t[0],
2158
+ text: n
2280
2159
  };
2281
2160
  }
2282
2161
  }
2283
- br(src) {
2284
- const cap = this.rules.inline.br.exec(src);
2285
- if (cap) return {
2162
+ br(e) {
2163
+ let t = this.rules.inline.br.exec(e);
2164
+ if (t) return {
2286
2165
  type: "br",
2287
- raw: cap[0]
2166
+ raw: t[0]
2288
2167
  };
2289
2168
  }
2290
- del(src) {
2291
- const cap = this.rules.inline.del.exec(src);
2292
- if (cap) return {
2293
- type: "del",
2294
- raw: cap[0],
2295
- text: cap[2],
2296
- tokens: this.lexer.inlineTokens(cap[2])
2297
- };
2298
- }
2299
- autolink(src) {
2300
- const cap = this.rules.inline.autolink.exec(src);
2301
- if (cap) {
2302
- let text, href;
2303
- if (cap[2] === "@") {
2304
- text = cap[1];
2305
- href = "mailto:" + text;
2306
- } else {
2307
- text = cap[1];
2308
- href = text;
2169
+ del(e, t, n = "") {
2170
+ let s = this.rules.inline.delLDelim.exec(e);
2171
+ if (!s) return;
2172
+ if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
2173
+ let i = [...s[0]].length - 1, o, u, a = i, c = this.rules.inline.delRDelim;
2174
+ for (c.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = c.exec(t)) !== null;) {
2175
+ if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (u = [...o].length, u !== i)) continue;
2176
+ if (s[3] || s[4]) {
2177
+ a += u;
2178
+ continue;
2179
+ }
2180
+ if (a -= u, a > 0) continue;
2181
+ u = Math.min(u, u + a);
2182
+ let p = [...s[0]][0].length, k = e.slice(0, i + s.index + p + u), h = k.slice(i, -i);
2183
+ return {
2184
+ type: "del",
2185
+ raw: k,
2186
+ text: h,
2187
+ tokens: this.lexer.inlineTokens(h)
2188
+ };
2309
2189
  }
2310
- return {
2190
+ }
2191
+ }
2192
+ autolink(e) {
2193
+ let t = this.rules.inline.autolink.exec(e);
2194
+ if (t) {
2195
+ let n, s;
2196
+ return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), {
2311
2197
  type: "link",
2312
- raw: cap[0],
2313
- text,
2314
- href,
2198
+ raw: t[0],
2199
+ text: n,
2200
+ href: s,
2315
2201
  tokens: [{
2316
2202
  type: "text",
2317
- raw: text,
2318
- text
2203
+ raw: n,
2204
+ text: n
2319
2205
  }]
2320
2206
  };
2321
2207
  }
2322
2208
  }
2323
- url(src) {
2324
- let cap;
2325
- if (cap = this.rules.inline.url.exec(src)) {
2326
- let text, href;
2327
- if (cap[2] === "@") {
2328
- text = cap[0];
2329
- href = "mailto:" + text;
2330
- } else {
2331
- let prevCapZero;
2332
- do {
2333
- prevCapZero = cap[0];
2334
- cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? "";
2335
- } while (prevCapZero !== cap[0]);
2336
- text = cap[0];
2337
- if (cap[1] === "www.") href = "http://" + cap[0];
2338
- else href = cap[0];
2209
+ url(e) {
2210
+ let t;
2211
+ if (t = this.rules.inline.url.exec(e)) {
2212
+ let n, s;
2213
+ if (t[2] === "@") n = t[0], s = "mailto:" + n;
2214
+ else {
2215
+ let r;
2216
+ do
2217
+ r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
2218
+ while (r !== t[0]);
2219
+ n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
2339
2220
  }
2340
2221
  return {
2341
2222
  type: "link",
2342
- raw: cap[0],
2343
- text,
2344
- href,
2223
+ raw: t[0],
2224
+ text: n,
2225
+ href: s,
2345
2226
  tokens: [{
2346
2227
  type: "text",
2347
- raw: text,
2348
- text
2228
+ raw: n,
2229
+ text: n
2349
2230
  }]
2350
2231
  };
2351
2232
  }
2352
2233
  }
2353
- inlineText(src) {
2354
- const cap = this.rules.inline.text.exec(src);
2355
- if (cap) {
2356
- const escaped = this.lexer.state.inRawBlock;
2234
+ inlineText(e) {
2235
+ let t = this.rules.inline.text.exec(e);
2236
+ if (t) {
2237
+ let n = this.lexer.state.inRawBlock;
2357
2238
  return {
2358
2239
  type: "text",
2359
- raw: cap[0],
2360
- text: cap[0],
2361
- escaped
2240
+ raw: t[0],
2241
+ text: t[0],
2242
+ escaped: n
2362
2243
  };
2363
2244
  }
2364
2245
  }
2365
2246
  };
2366
- var _Lexer = class __Lexer {
2247
+ var x = class l {
2367
2248
  tokens;
2368
2249
  options;
2369
2250
  state;
2370
- tokenizer;
2371
2251
  inlineQueue;
2372
- constructor(options2) {
2373
- this.tokens = [];
2374
- this.tokens.links = /* @__PURE__ */ Object.create(null);
2375
- this.options = options2 || _defaults;
2376
- this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
2377
- this.tokenizer = this.options.tokenizer;
2378
- this.tokenizer.options = this.options;
2379
- this.tokenizer.lexer = this;
2380
- this.inlineQueue = [];
2381
- this.state = {
2382
- inLink: false,
2383
- inRawBlock: false,
2384
- top: true
2252
+ tokenizer;
2253
+ constructor(e) {
2254
+ this.tokens = [], this.tokens.links = Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new w(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
2255
+ inLink: !1,
2256
+ inRawBlock: !1,
2257
+ top: !0
2385
2258
  };
2386
- const rules = {
2387
- other,
2388
- block: block.normal,
2389
- inline: inline.normal
2259
+ let t = {
2260
+ other: m,
2261
+ block: D.normal,
2262
+ inline: A.normal
2390
2263
  };
2391
- if (this.options.pedantic) {
2392
- rules.block = block.pedantic;
2393
- rules.inline = inline.pedantic;
2394
- } else if (this.options.gfm) {
2395
- rules.block = block.gfm;
2396
- if (this.options.breaks) rules.inline = inline.breaks;
2397
- else rules.inline = inline.gfm;
2398
- }
2399
- this.tokenizer.rules = rules;
2264
+ this.options.pedantic ? (t.block = D.pedantic, t.inline = A.pedantic) : this.options.gfm && (t.block = D.gfm, this.options.breaks ? t.inline = A.breaks : t.inline = A.gfm), this.tokenizer.rules = t;
2400
2265
  }
2401
- /**
2402
- * Expose Rules
2403
- */
2404
2266
  static get rules() {
2405
2267
  return {
2406
- block,
2407
- inline
2268
+ block: D,
2269
+ inline: A
2408
2270
  };
2409
2271
  }
2410
- /**
2411
- * Static Lex Method
2412
- */
2413
- static lex(src, options2) {
2414
- return new __Lexer(options2).lex(src);
2272
+ static lex(e, t) {
2273
+ return new l(t).lex(e);
2415
2274
  }
2416
- /**
2417
- * Static Lex Inline Method
2418
- */
2419
- static lexInline(src, options2) {
2420
- return new __Lexer(options2).inlineTokens(src);
2275
+ static lexInline(e, t) {
2276
+ return new l(t).inlineTokens(e);
2421
2277
  }
2422
- /**
2423
- * Preprocessing
2424
- */
2425
- lex(src) {
2426
- src = src.replace(other.carriageReturn, "\n");
2427
- this.blockTokens(src, this.tokens);
2428
- for (let i = 0; i < this.inlineQueue.length; i++) {
2429
- const next = this.inlineQueue[i];
2430
- this.inlineTokens(next.src, next.tokens);
2278
+ lex(e) {
2279
+ e = e.replace(m.carriageReturn, `
2280
+ `), this.blockTokens(e, this.tokens);
2281
+ for (let t = 0; t < this.inlineQueue.length; t++) {
2282
+ let n = this.inlineQueue[t];
2283
+ this.inlineTokens(n.src, n.tokens);
2431
2284
  }
2432
- this.inlineQueue = [];
2433
- return this.tokens;
2434
- }
2435
- blockTokens(src, tokens = [], lastParagraphClipped = false) {
2436
- if (this.options.pedantic) src = src.replace(other.tabCharGlobal, " ").replace(other.spaceLine, "");
2437
- while (src) {
2438
- let token;
2439
- if (this.options.extensions?.block?.some((extTokenizer) => {
2440
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
2441
- src = src.substring(token.raw.length);
2442
- tokens.push(token);
2443
- return true;
2444
- }
2445
- return false;
2446
- })) continue;
2447
- if (token = this.tokenizer.space(src)) {
2448
- src = src.substring(token.raw.length);
2449
- const lastToken = tokens.at(-1);
2450
- if (token.raw.length === 1 && lastToken !== void 0) lastToken.raw += "\n";
2451
- else tokens.push(token);
2285
+ return this.inlineQueue = [], this.tokens;
2286
+ }
2287
+ blockTokens(e, t = [], n = !1) {
2288
+ this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
2289
+ let s = Infinity;
2290
+ for (; e;) {
2291
+ if (e.length < s) s = e.length;
2292
+ else {
2293
+ this.infiniteLoopError(e.charCodeAt(0));
2294
+ break;
2295
+ }
2296
+ let r;
2297
+ if (this.options.extensions?.block?.some((o) => (r = o.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), !0) : !1)) continue;
2298
+ if (r = this.tokenizer.space(e)) {
2299
+ e = e.substring(r.raw.length);
2300
+ let o = t.at(-1);
2301
+ r.raw.length === 1 && o !== void 0 ? o.raw += `
2302
+ ` : t.push(r);
2452
2303
  continue;
2453
2304
  }
2454
- if (token = this.tokenizer.code(src)) {
2455
- src = src.substring(token.raw.length);
2456
- const lastToken = tokens.at(-1);
2457
- if (lastToken?.type === "paragraph" || lastToken?.type === "text") {
2458
- lastToken.raw += "\n" + token.raw;
2459
- lastToken.text += "\n" + token.text;
2460
- this.inlineQueue.at(-1).src = lastToken.text;
2461
- } else tokens.push(token);
2305
+ if (r = this.tokenizer.code(e)) {
2306
+ e = e.substring(r.raw.length);
2307
+ let o = t.at(-1);
2308
+ o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
2309
+ `) ? "" : `
2310
+ `) + r.raw, o.text += `
2311
+ ` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
2462
2312
  continue;
2463
2313
  }
2464
- if (token = this.tokenizer.fences(src)) {
2465
- src = src.substring(token.raw.length);
2466
- tokens.push(token);
2314
+ if (r = this.tokenizer.fences(e)) {
2315
+ e = e.substring(r.raw.length), t.push(r);
2467
2316
  continue;
2468
2317
  }
2469
- if (token = this.tokenizer.heading(src)) {
2470
- src = src.substring(token.raw.length);
2471
- tokens.push(token);
2318
+ if (r = this.tokenizer.heading(e)) {
2319
+ e = e.substring(r.raw.length), t.push(r);
2472
2320
  continue;
2473
2321
  }
2474
- if (token = this.tokenizer.hr(src)) {
2475
- src = src.substring(token.raw.length);
2476
- tokens.push(token);
2322
+ if (r = this.tokenizer.hr(e)) {
2323
+ e = e.substring(r.raw.length), t.push(r);
2477
2324
  continue;
2478
2325
  }
2479
- if (token = this.tokenizer.blockquote(src)) {
2480
- src = src.substring(token.raw.length);
2481
- tokens.push(token);
2326
+ if (r = this.tokenizer.blockquote(e)) {
2327
+ e = e.substring(r.raw.length), t.push(r);
2482
2328
  continue;
2483
2329
  }
2484
- if (token = this.tokenizer.list(src)) {
2485
- src = src.substring(token.raw.length);
2486
- tokens.push(token);
2330
+ if (r = this.tokenizer.list(e)) {
2331
+ e = e.substring(r.raw.length), t.push(r);
2487
2332
  continue;
2488
2333
  }
2489
- if (token = this.tokenizer.html(src)) {
2490
- src = src.substring(token.raw.length);
2491
- tokens.push(token);
2334
+ if (r = this.tokenizer.html(e)) {
2335
+ e = e.substring(r.raw.length), t.push(r);
2492
2336
  continue;
2493
2337
  }
2494
- if (token = this.tokenizer.def(src)) {
2495
- src = src.substring(token.raw.length);
2496
- const lastToken = tokens.at(-1);
2497
- if (lastToken?.type === "paragraph" || lastToken?.type === "text") {
2498
- lastToken.raw += "\n" + token.raw;
2499
- lastToken.text += "\n" + token.raw;
2500
- this.inlineQueue.at(-1).src = lastToken.text;
2501
- } else if (!this.tokens.links[token.tag]) this.tokens.links[token.tag] = {
2502
- href: token.href,
2503
- title: token.title
2504
- };
2338
+ if (r = this.tokenizer.def(e)) {
2339
+ e = e.substring(r.raw.length);
2340
+ let o = t.at(-1);
2341
+ o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
2342
+ `) ? "" : `
2343
+ `) + r.raw, o.text += `
2344
+ ` + r.raw, this.inlineQueue.at(-1).src = o.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = {
2345
+ href: r.href,
2346
+ title: r.title
2347
+ }, t.push(r));
2505
2348
  continue;
2506
2349
  }
2507
- if (token = this.tokenizer.table(src)) {
2508
- src = src.substring(token.raw.length);
2509
- tokens.push(token);
2350
+ if (r = this.tokenizer.table(e)) {
2351
+ e = e.substring(r.raw.length), t.push(r);
2510
2352
  continue;
2511
2353
  }
2512
- if (token = this.tokenizer.lheading(src)) {
2513
- src = src.substring(token.raw.length);
2514
- tokens.push(token);
2354
+ if (r = this.tokenizer.lheading(e)) {
2355
+ e = e.substring(r.raw.length), t.push(r);
2515
2356
  continue;
2516
2357
  }
2517
- let cutSrc = src;
2358
+ let i = e;
2518
2359
  if (this.options.extensions?.startBlock) {
2519
- let startIndex = Infinity;
2520
- const tempSrc = src.slice(1);
2521
- let tempStart;
2522
- this.options.extensions.startBlock.forEach((getStartIndex) => {
2523
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
2524
- if (typeof tempStart === "number" && tempStart >= 0) startIndex = Math.min(startIndex, tempStart);
2525
- });
2526
- if (startIndex < Infinity && startIndex >= 0) cutSrc = src.substring(0, startIndex + 1);
2527
- }
2528
- if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
2529
- const lastToken = tokens.at(-1);
2530
- if (lastParagraphClipped && lastToken?.type === "paragraph") {
2531
- lastToken.raw += "\n" + token.raw;
2532
- lastToken.text += "\n" + token.text;
2533
- this.inlineQueue.pop();
2534
- this.inlineQueue.at(-1).src = lastToken.text;
2535
- } else tokens.push(token);
2536
- lastParagraphClipped = cutSrc.length !== src.length;
2537
- src = src.substring(token.raw.length);
2360
+ let o = Infinity, u = e.slice(1), a;
2361
+ this.options.extensions.startBlock.forEach((c) => {
2362
+ a = c.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
2363
+ }), o < Infinity && o >= 0 && (i = e.substring(0, o + 1));
2364
+ }
2365
+ if (this.state.top && (r = this.tokenizer.paragraph(i))) {
2366
+ let o = t.at(-1);
2367
+ n && o?.type === "paragraph" ? (o.raw += (o.raw.endsWith(`
2368
+ `) ? "" : `
2369
+ `) + r.raw, o.text += `
2370
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
2538
2371
  continue;
2539
2372
  }
2540
- if (token = this.tokenizer.text(src)) {
2541
- src = src.substring(token.raw.length);
2542
- const lastToken = tokens.at(-1);
2543
- if (lastToken?.type === "text") {
2544
- lastToken.raw += "\n" + token.raw;
2545
- lastToken.text += "\n" + token.text;
2546
- this.inlineQueue.pop();
2547
- this.inlineQueue.at(-1).src = lastToken.text;
2548
- } else tokens.push(token);
2373
+ if (r = this.tokenizer.text(e)) {
2374
+ e = e.substring(r.raw.length);
2375
+ let o = t.at(-1);
2376
+ o?.type === "text" ? (o.raw += (o.raw.endsWith(`
2377
+ `) ? "" : `
2378
+ `) + r.raw, o.text += `
2379
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
2549
2380
  continue;
2550
2381
  }
2551
- if (src) {
2552
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
2553
- if (this.options.silent) {
2554
- console.error(errMsg);
2555
- break;
2556
- } else throw new Error(errMsg);
2382
+ if (e) {
2383
+ this.infiniteLoopError(e.charCodeAt(0));
2384
+ break;
2557
2385
  }
2558
2386
  }
2559
- this.state.top = true;
2560
- return tokens;
2387
+ return this.state.top = !0, t;
2561
2388
  }
2562
- inline(src, tokens = []) {
2563
- this.inlineQueue.push({
2564
- src,
2565
- tokens
2566
- });
2567
- return tokens;
2389
+ inline(e, t = []) {
2390
+ return this.inlineQueue.push({
2391
+ src: e,
2392
+ tokens: t
2393
+ }), t;
2568
2394
  }
2569
- /**
2570
- * Lexing/Compiling
2571
- */
2572
- inlineTokens(src, tokens = []) {
2573
- let maskedSrc = src;
2574
- let match = null;
2395
+ inlineTokens(e, t = []) {
2396
+ this.tokenizer.lexer = this;
2397
+ let n = e, s = null;
2575
2398
  if (this.tokens.links) {
2576
- const links = Object.keys(this.tokens.links);
2577
- if (links.length > 0) {
2578
- while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
2579
- }
2399
+ let a = Object.keys(this.tokens.links);
2400
+ if (a.length > 0) for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) !== null;) a.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
2580
2401
  }
2581
- while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
2582
- while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
2583
- let keepPrevChar = false;
2584
- let prevChar = "";
2585
- while (src) {
2586
- if (!keepPrevChar) prevChar = "";
2587
- keepPrevChar = false;
2588
- let token;
2589
- if (this.options.extensions?.inline?.some((extTokenizer) => {
2590
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
2591
- src = src.substring(token.raw.length);
2592
- tokens.push(token);
2593
- return true;
2594
- }
2595
- return false;
2596
- })) continue;
2597
- if (token = this.tokenizer.escape(src)) {
2598
- src = src.substring(token.raw.length);
2599
- tokens.push(token);
2402
+ for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) !== null;) n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
2403
+ let r;
2404
+ for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) !== null;) r = s[2] ? s[2].length : 0, n = n.slice(0, s.index + r) + "[" + "a".repeat(s[0].length - r - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
2405
+ n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
2406
+ let i = !1, o = "", u = Infinity;
2407
+ for (; e;) {
2408
+ if (e.length < u) u = e.length;
2409
+ else {
2410
+ this.infiniteLoopError(e.charCodeAt(0));
2411
+ break;
2412
+ }
2413
+ i || (o = ""), i = !1;
2414
+ let a;
2415
+ if (this.options.extensions?.inline?.some((p) => (a = p.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), !0) : !1)) continue;
2416
+ if (a = this.tokenizer.escape(e)) {
2417
+ e = e.substring(a.raw.length), t.push(a);
2600
2418
  continue;
2601
2419
  }
2602
- if (token = this.tokenizer.tag(src)) {
2603
- src = src.substring(token.raw.length);
2604
- tokens.push(token);
2420
+ if (a = this.tokenizer.tag(e)) {
2421
+ e = e.substring(a.raw.length), t.push(a);
2605
2422
  continue;
2606
2423
  }
2607
- if (token = this.tokenizer.link(src)) {
2608
- src = src.substring(token.raw.length);
2609
- tokens.push(token);
2424
+ if (a = this.tokenizer.link(e)) {
2425
+ e = e.substring(a.raw.length), t.push(a);
2610
2426
  continue;
2611
2427
  }
2612
- if (token = this.tokenizer.reflink(src, this.tokens.links)) {
2613
- src = src.substring(token.raw.length);
2614
- const lastToken = tokens.at(-1);
2615
- if (token.type === "text" && lastToken?.type === "text") {
2616
- lastToken.raw += token.raw;
2617
- lastToken.text += token.text;
2618
- } else tokens.push(token);
2428
+ if (a = this.tokenizer.reflink(e, this.tokens.links)) {
2429
+ e = e.substring(a.raw.length);
2430
+ let p = t.at(-1);
2431
+ a.type === "text" && p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
2619
2432
  continue;
2620
2433
  }
2621
- if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
2622
- src = src.substring(token.raw.length);
2623
- tokens.push(token);
2434
+ if (a = this.tokenizer.emStrong(e, n, o)) {
2435
+ e = e.substring(a.raw.length), t.push(a);
2624
2436
  continue;
2625
2437
  }
2626
- if (token = this.tokenizer.codespan(src)) {
2627
- src = src.substring(token.raw.length);
2628
- tokens.push(token);
2438
+ if (a = this.tokenizer.codespan(e)) {
2439
+ e = e.substring(a.raw.length), t.push(a);
2629
2440
  continue;
2630
2441
  }
2631
- if (token = this.tokenizer.br(src)) {
2632
- src = src.substring(token.raw.length);
2633
- tokens.push(token);
2442
+ if (a = this.tokenizer.br(e)) {
2443
+ e = e.substring(a.raw.length), t.push(a);
2634
2444
  continue;
2635
2445
  }
2636
- if (token = this.tokenizer.del(src)) {
2637
- src = src.substring(token.raw.length);
2638
- tokens.push(token);
2446
+ if (a = this.tokenizer.del(e, n, o)) {
2447
+ e = e.substring(a.raw.length), t.push(a);
2639
2448
  continue;
2640
2449
  }
2641
- if (token = this.tokenizer.autolink(src)) {
2642
- src = src.substring(token.raw.length);
2643
- tokens.push(token);
2450
+ if (a = this.tokenizer.autolink(e)) {
2451
+ e = e.substring(a.raw.length), t.push(a);
2644
2452
  continue;
2645
2453
  }
2646
- if (!this.state.inLink && (token = this.tokenizer.url(src))) {
2647
- src = src.substring(token.raw.length);
2648
- tokens.push(token);
2454
+ if (!this.state.inLink && (a = this.tokenizer.url(e))) {
2455
+ e = e.substring(a.raw.length), t.push(a);
2649
2456
  continue;
2650
2457
  }
2651
- let cutSrc = src;
2458
+ let c = e;
2652
2459
  if (this.options.extensions?.startInline) {
2653
- let startIndex = Infinity;
2654
- const tempSrc = src.slice(1);
2655
- let tempStart;
2656
- this.options.extensions.startInline.forEach((getStartIndex) => {
2657
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
2658
- if (typeof tempStart === "number" && tempStart >= 0) startIndex = Math.min(startIndex, tempStart);
2659
- });
2660
- if (startIndex < Infinity && startIndex >= 0) cutSrc = src.substring(0, startIndex + 1);
2661
- }
2662
- if (token = this.tokenizer.inlineText(cutSrc)) {
2663
- src = src.substring(token.raw.length);
2664
- if (token.raw.slice(-1) !== "_") prevChar = token.raw.slice(-1);
2665
- keepPrevChar = true;
2666
- const lastToken = tokens.at(-1);
2667
- if (lastToken?.type === "text") {
2668
- lastToken.raw += token.raw;
2669
- lastToken.text += token.text;
2670
- } else tokens.push(token);
2460
+ let p = Infinity, k = e.slice(1), h;
2461
+ this.options.extensions.startInline.forEach((R) => {
2462
+ h = R.call({ lexer: this }, k), typeof h == "number" && h >= 0 && (p = Math.min(p, h));
2463
+ }), p < Infinity && p >= 0 && (c = e.substring(0, p + 1));
2464
+ }
2465
+ if (a = this.tokenizer.inlineText(c)) {
2466
+ e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (o = a.raw.slice(-1)), i = !0;
2467
+ let p = t.at(-1);
2468
+ p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
2671
2469
  continue;
2672
2470
  }
2673
- if (src) {
2674
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
2675
- if (this.options.silent) {
2676
- console.error(errMsg);
2677
- break;
2678
- } else throw new Error(errMsg);
2471
+ if (e) {
2472
+ this.infiniteLoopError(e.charCodeAt(0));
2473
+ break;
2679
2474
  }
2680
2475
  }
2681
- return tokens;
2476
+ return t;
2477
+ }
2478
+ infiniteLoopError(e) {
2479
+ let t = "Infinite loop on byte: " + e;
2480
+ if (this.options.silent) console.error(t);
2481
+ else throw new Error(t);
2682
2482
  }
2683
2483
  };
2684
- var _Renderer = class {
2484
+ var y = class {
2685
2485
  options;
2686
2486
  parser;
2687
- constructor(options2) {
2688
- this.options = options2 || _defaults;
2487
+ constructor(e) {
2488
+ this.options = e || T;
2689
2489
  }
2690
- space(token) {
2490
+ space(e) {
2691
2491
  return "";
2692
2492
  }
2693
- code({ text, lang, escaped }) {
2694
- const langString = (lang || "").match(other.notSpaceStart)?.[0];
2695
- const code = text.replace(other.endingNewline, "") + "\n";
2696
- if (!langString) return "<pre><code>" + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
2697
- return "<pre><code class=\"language-" + escape2(langString) + "\">" + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
2493
+ code({ text: e, lang: t, escaped: n }) {
2494
+ let s = (t || "").match(m.notSpaceStart)?.[0], r = e.replace(m.endingNewline, "") + `
2495
+ `;
2496
+ return s ? "<pre><code class=\"language-" + O(s) + "\">" + (n ? r : O(r, !0)) + `</code></pre>
2497
+ ` : "<pre><code>" + (n ? r : O(r, !0)) + `</code></pre>
2498
+ `;
2698
2499
  }
2699
- blockquote({ tokens }) {
2500
+ blockquote({ tokens: e }) {
2700
2501
  return `<blockquote>
2701
- ${this.parser.parse(tokens)}</blockquote>
2502
+ ${this.parser.parse(e)}</blockquote>
2702
2503
  `;
2703
2504
  }
2704
- html({ text }) {
2705
- return text;
2505
+ html({ text: e }) {
2506
+ return e;
2706
2507
  }
2707
- heading({ tokens, depth }) {
2708
- return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
2508
+ def(e) {
2509
+ return "";
2510
+ }
2511
+ heading({ tokens: e, depth: t }) {
2512
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
2709
2513
  `;
2710
2514
  }
2711
- hr(token) {
2712
- return "<hr>\n";
2515
+ hr(e) {
2516
+ return `<hr>
2517
+ `;
2713
2518
  }
2714
- list(token) {
2715
- const ordered = token.ordered;
2716
- const start = token.start;
2717
- let body = "";
2718
- for (let j = 0; j < token.items.length; j++) {
2719
- const item = token.items[j];
2720
- body += this.listitem(item);
2721
- }
2722
- const type = ordered ? "ol" : "ul";
2723
- const startAttr = ordered && start !== 1 ? " start=\"" + start + "\"" : "";
2724
- return "<" + type + startAttr + ">\n" + body + "</" + type + ">\n";
2725
- }
2726
- listitem(item) {
2727
- let itemBody = "";
2728
- if (item.task) {
2729
- const checkbox = this.checkbox({ checked: !!item.checked });
2730
- if (item.loose) if (item.tokens[0]?.type === "paragraph") {
2731
- item.tokens[0].text = checkbox + " " + item.tokens[0].text;
2732
- if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
2733
- item.tokens[0].tokens[0].text = checkbox + " " + escape2(item.tokens[0].tokens[0].text);
2734
- item.tokens[0].tokens[0].escaped = true;
2735
- }
2736
- } else item.tokens.unshift({
2737
- type: "text",
2738
- raw: checkbox + " ",
2739
- text: checkbox + " ",
2740
- escaped: true
2741
- });
2742
- else itemBody += checkbox + " ";
2519
+ list(e) {
2520
+ let t = e.ordered, n = e.start, s = "";
2521
+ for (let o = 0; o < e.items.length; o++) {
2522
+ let u = e.items[o];
2523
+ s += this.listitem(u);
2743
2524
  }
2744
- itemBody += this.parser.parse(item.tokens, !!item.loose);
2745
- return `<li>${itemBody}</li>
2525
+ let r = t ? "ol" : "ul", i = t && n !== 1 ? " start=\"" + n + "\"" : "";
2526
+ return "<" + r + i + `>
2527
+ ` + s + "</" + r + `>
2746
2528
  `;
2747
2529
  }
2748
- checkbox({ checked }) {
2749
- return "<input " + (checked ? "checked=\"\" " : "") + "disabled=\"\" type=\"checkbox\">";
2530
+ listitem(e) {
2531
+ return `<li>${this.parser.parse(e.tokens)}</li>
2532
+ `;
2750
2533
  }
2751
- paragraph({ tokens }) {
2752
- return `<p>${this.parser.parseInline(tokens)}</p>
2534
+ checkbox({ checked: e }) {
2535
+ return "<input " + (e ? "checked=\"\" " : "") + "disabled=\"\" type=\"checkbox\"> ";
2536
+ }
2537
+ paragraph({ tokens: e }) {
2538
+ return `<p>${this.parser.parseInline(e)}</p>
2753
2539
  `;
2754
2540
  }
2755
- table(token) {
2756
- let header = "";
2757
- let cell = "";
2758
- for (let j = 0; j < token.header.length; j++) cell += this.tablecell(token.header[j]);
2759
- header += this.tablerow({ text: cell });
2760
- let body = "";
2761
- for (let j = 0; j < token.rows.length; j++) {
2762
- const row = token.rows[j];
2763
- cell = "";
2764
- for (let k = 0; k < row.length; k++) cell += this.tablecell(row[k]);
2765
- body += this.tablerow({ text: cell });
2541
+ table(e) {
2542
+ let t = "", n = "";
2543
+ for (let r = 0; r < e.header.length; r++) n += this.tablecell(e.header[r]);
2544
+ t += this.tablerow({ text: n });
2545
+ let s = "";
2546
+ for (let r = 0; r < e.rows.length; r++) {
2547
+ let i = e.rows[r];
2548
+ n = "";
2549
+ for (let o = 0; o < i.length; o++) n += this.tablecell(i[o]);
2550
+ s += this.tablerow({ text: n });
2766
2551
  }
2767
- if (body) body = `<tbody>${body}</tbody>`;
2768
- return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
2552
+ return s && (s = `<tbody>${s}</tbody>`), `<table>
2553
+ <thead>
2554
+ ` + t + `</thead>
2555
+ ` + s + `</table>
2556
+ `;
2769
2557
  }
2770
- tablerow({ text }) {
2558
+ tablerow({ text: e }) {
2771
2559
  return `<tr>
2772
- ${text}</tr>
2560
+ ${e}</tr>
2773
2561
  `;
2774
2562
  }
2775
- tablecell(token) {
2776
- const content = this.parser.parseInline(token.tokens);
2777
- const type = token.header ? "th" : "td";
2778
- return (token.align ? `<${type} align="${token.align}">` : `<${type}>`) + content + `</${type}>
2563
+ tablecell(e) {
2564
+ let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
2565
+ return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
2779
2566
  `;
2780
2567
  }
2781
- /**
2782
- * span level renderer
2783
- */
2784
- strong({ tokens }) {
2785
- return `<strong>${this.parser.parseInline(tokens)}</strong>`;
2568
+ strong({ tokens: e }) {
2569
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
2786
2570
  }
2787
- em({ tokens }) {
2788
- return `<em>${this.parser.parseInline(tokens)}</em>`;
2571
+ em({ tokens: e }) {
2572
+ return `<em>${this.parser.parseInline(e)}</em>`;
2789
2573
  }
2790
- codespan({ text }) {
2791
- return `<code>${escape2(text, true)}</code>`;
2574
+ codespan({ text: e }) {
2575
+ return `<code>${O(e, !0)}</code>`;
2792
2576
  }
2793
- br(token) {
2577
+ br(e) {
2794
2578
  return "<br>";
2795
2579
  }
2796
- del({ tokens }) {
2797
- return `<del>${this.parser.parseInline(tokens)}</del>`;
2798
- }
2799
- link({ href, title, tokens }) {
2800
- const text = this.parser.parseInline(tokens);
2801
- const cleanHref = cleanUrl(href);
2802
- if (cleanHref === null) return text;
2803
- href = cleanHref;
2804
- let out = "<a href=\"" + href + "\"";
2805
- if (title) out += " title=\"" + escape2(title) + "\"";
2806
- out += ">" + text + "</a>";
2807
- return out;
2808
- }
2809
- image({ href, title, text, tokens }) {
2810
- if (tokens) text = this.parser.parseInline(tokens, this.parser.textRenderer);
2811
- const cleanHref = cleanUrl(href);
2812
- if (cleanHref === null) return escape2(text);
2813
- href = cleanHref;
2814
- let out = `<img src="${href}" alt="${text}"`;
2815
- if (title) out += ` title="${escape2(title)}"`;
2816
- out += ">";
2817
- return out;
2818
- }
2819
- text(token) {
2820
- return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : "escaped" in token && token.escaped ? token.text : escape2(token.text);
2580
+ del({ tokens: e }) {
2581
+ return `<del>${this.parser.parseInline(e)}</del>`;
2582
+ }
2583
+ link({ href: e, title: t, tokens: n }) {
2584
+ let s = this.parser.parseInline(n), r = V(e);
2585
+ if (r === null) return s;
2586
+ e = r;
2587
+ let i = "<a href=\"" + e + "\"";
2588
+ return t && (i += " title=\"" + O(t) + "\""), i += ">" + s + "</a>", i;
2589
+ }
2590
+ image({ href: e, title: t, text: n, tokens: s }) {
2591
+ s && (n = this.parser.parseInline(s, this.parser.textRenderer));
2592
+ let r = V(e);
2593
+ if (r === null) return O(n);
2594
+ e = r;
2595
+ let i = `<img src="${e}" alt="${O(n)}"`;
2596
+ return t && (i += ` title="${O(t)}"`), i += ">", i;
2597
+ }
2598
+ text(e) {
2599
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : O(e.text);
2821
2600
  }
2822
2601
  };
2823
- var _TextRenderer = class {
2824
- strong({ text }) {
2825
- return text;
2602
+ var L = class {
2603
+ strong({ text: e }) {
2604
+ return e;
2826
2605
  }
2827
- em({ text }) {
2828
- return text;
2606
+ em({ text: e }) {
2607
+ return e;
2829
2608
  }
2830
- codespan({ text }) {
2831
- return text;
2609
+ codespan({ text: e }) {
2610
+ return e;
2832
2611
  }
2833
- del({ text }) {
2834
- return text;
2612
+ del({ text: e }) {
2613
+ return e;
2835
2614
  }
2836
- html({ text }) {
2837
- return text;
2615
+ html({ text: e }) {
2616
+ return e;
2838
2617
  }
2839
- text({ text }) {
2840
- return text;
2618
+ text({ text: e }) {
2619
+ return e;
2841
2620
  }
2842
- link({ text }) {
2843
- return "" + text;
2621
+ link({ text: e }) {
2622
+ return "" + e;
2844
2623
  }
2845
- image({ text }) {
2846
- return "" + text;
2624
+ image({ text: e }) {
2625
+ return "" + e;
2847
2626
  }
2848
2627
  br() {
2849
2628
  return "";
2850
2629
  }
2630
+ checkbox({ raw: e }) {
2631
+ return e;
2632
+ }
2851
2633
  };
2852
- var _Parser = class __Parser {
2634
+ var b = class l {
2853
2635
  options;
2854
2636
  renderer;
2855
2637
  textRenderer;
2856
- constructor(options2) {
2857
- this.options = options2 || _defaults;
2858
- this.options.renderer = this.options.renderer || new _Renderer();
2859
- this.renderer = this.options.renderer;
2860
- this.renderer.options = this.options;
2861
- this.renderer.parser = this;
2862
- this.textRenderer = new _TextRenderer();
2638
+ constructor(e) {
2639
+ this.options = e || T, this.options.renderer = this.options.renderer || new y(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L();
2863
2640
  }
2864
- /**
2865
- * Static Parse Method
2866
- */
2867
- static parse(tokens, options2) {
2868
- return new __Parser(options2).parse(tokens);
2641
+ static parse(e, t) {
2642
+ return new l(t).parse(e);
2869
2643
  }
2870
- /**
2871
- * Static Parse Inline Method
2872
- */
2873
- static parseInline(tokens, options2) {
2874
- return new __Parser(options2).parseInline(tokens);
2644
+ static parseInline(e, t) {
2645
+ return new l(t).parseInline(e);
2875
2646
  }
2876
- /**
2877
- * Parse Loop
2878
- */
2879
- parse(tokens, top = true) {
2880
- let out = "";
2881
- for (let i = 0; i < tokens.length; i++) {
2882
- const anyToken = tokens[i];
2883
- if (this.options.extensions?.renderers?.[anyToken.type]) {
2884
- const genericToken = anyToken;
2885
- const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
2886
- if (ret !== false || ![
2647
+ parse(e) {
2648
+ this.renderer.parser = this;
2649
+ let t = "";
2650
+ for (let n = 0; n < e.length; n++) {
2651
+ let s = e[n];
2652
+ if (this.options.extensions?.renderers?.[s.type]) {
2653
+ let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
2654
+ if (o !== !1 || ![
2887
2655
  "space",
2888
2656
  "hr",
2889
2657
  "heading",
@@ -2892,84 +2660,69 @@ var _Parser = class __Parser {
2892
2660
  "blockquote",
2893
2661
  "list",
2894
2662
  "html",
2663
+ "def",
2895
2664
  "paragraph",
2896
2665
  "text"
2897
- ].includes(genericToken.type)) {
2898
- out += ret || "";
2666
+ ].includes(i.type)) {
2667
+ t += o || "";
2899
2668
  continue;
2900
2669
  }
2901
2670
  }
2902
- const token = anyToken;
2903
- switch (token.type) {
2671
+ let r = s;
2672
+ switch (r.type) {
2904
2673
  case "space":
2905
- out += this.renderer.space(token);
2906
- continue;
2674
+ t += this.renderer.space(r);
2675
+ break;
2907
2676
  case "hr":
2908
- out += this.renderer.hr(token);
2909
- continue;
2677
+ t += this.renderer.hr(r);
2678
+ break;
2910
2679
  case "heading":
2911
- out += this.renderer.heading(token);
2912
- continue;
2680
+ t += this.renderer.heading(r);
2681
+ break;
2913
2682
  case "code":
2914
- out += this.renderer.code(token);
2915
- continue;
2683
+ t += this.renderer.code(r);
2684
+ break;
2916
2685
  case "table":
2917
- out += this.renderer.table(token);
2918
- continue;
2686
+ t += this.renderer.table(r);
2687
+ break;
2919
2688
  case "blockquote":
2920
- out += this.renderer.blockquote(token);
2921
- continue;
2689
+ t += this.renderer.blockquote(r);
2690
+ break;
2922
2691
  case "list":
2923
- out += this.renderer.list(token);
2924
- continue;
2692
+ t += this.renderer.list(r);
2693
+ break;
2694
+ case "checkbox":
2695
+ t += this.renderer.checkbox(r);
2696
+ break;
2925
2697
  case "html":
2926
- out += this.renderer.html(token);
2927
- continue;
2698
+ t += this.renderer.html(r);
2699
+ break;
2700
+ case "def":
2701
+ t += this.renderer.def(r);
2702
+ break;
2928
2703
  case "paragraph":
2929
- out += this.renderer.paragraph(token);
2930
- continue;
2931
- case "text": {
2932
- let textToken = token;
2933
- let body = this.renderer.text(textToken);
2934
- while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
2935
- textToken = tokens[++i];
2936
- body += "\n" + this.renderer.text(textToken);
2937
- }
2938
- if (top) out += this.renderer.paragraph({
2939
- type: "paragraph",
2940
- raw: body,
2941
- text: body,
2942
- tokens: [{
2943
- type: "text",
2944
- raw: body,
2945
- text: body,
2946
- escaped: true
2947
- }]
2948
- });
2949
- else out += body;
2950
- continue;
2951
- }
2704
+ t += this.renderer.paragraph(r);
2705
+ break;
2706
+ case "text":
2707
+ t += this.renderer.text(r);
2708
+ break;
2952
2709
  default: {
2953
- const errMsg = "Token with \"" + token.type + "\" type was not found.";
2954
- if (this.options.silent) {
2955
- console.error(errMsg);
2956
- return "";
2957
- } else throw new Error(errMsg);
2710
+ let i = "Token with \"" + r.type + "\" type was not found.";
2711
+ if (this.options.silent) return console.error(i), "";
2712
+ throw new Error(i);
2958
2713
  }
2959
2714
  }
2960
2715
  }
2961
- return out;
2716
+ return t;
2962
2717
  }
2963
- /**
2964
- * Parse Inline Tokens
2965
- */
2966
- parseInline(tokens, renderer = this.renderer) {
2967
- let out = "";
2968
- for (let i = 0; i < tokens.length; i++) {
2969
- const anyToken = tokens[i];
2970
- if (this.options.extensions?.renderers?.[anyToken.type]) {
2971
- const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
2972
- if (ret !== false || ![
2718
+ parseInline(e, t = this.renderer) {
2719
+ this.renderer.parser = this;
2720
+ let n = "";
2721
+ for (let s = 0; s < e.length; s++) {
2722
+ let r = e[s];
2723
+ if (this.options.extensions?.renderers?.[r.type]) {
2724
+ let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
2725
+ if (o !== !1 || ![
2973
2726
  "escape",
2974
2727
  "html",
2975
2728
  "link",
@@ -2980,354 +2733,305 @@ var _Parser = class __Parser {
2980
2733
  "br",
2981
2734
  "del",
2982
2735
  "text"
2983
- ].includes(anyToken.type)) {
2984
- out += ret || "";
2736
+ ].includes(r.type)) {
2737
+ n += o || "";
2985
2738
  continue;
2986
2739
  }
2987
2740
  }
2988
- const token = anyToken;
2989
- switch (token.type) {
2741
+ let i = r;
2742
+ switch (i.type) {
2990
2743
  case "escape":
2991
- out += renderer.text(token);
2744
+ n += t.text(i);
2992
2745
  break;
2993
2746
  case "html":
2994
- out += renderer.html(token);
2747
+ n += t.html(i);
2995
2748
  break;
2996
2749
  case "link":
2997
- out += renderer.link(token);
2750
+ n += t.link(i);
2998
2751
  break;
2999
2752
  case "image":
3000
- out += renderer.image(token);
2753
+ n += t.image(i);
2754
+ break;
2755
+ case "checkbox":
2756
+ n += t.checkbox(i);
3001
2757
  break;
3002
2758
  case "strong":
3003
- out += renderer.strong(token);
2759
+ n += t.strong(i);
3004
2760
  break;
3005
2761
  case "em":
3006
- out += renderer.em(token);
2762
+ n += t.em(i);
3007
2763
  break;
3008
2764
  case "codespan":
3009
- out += renderer.codespan(token);
2765
+ n += t.codespan(i);
3010
2766
  break;
3011
2767
  case "br":
3012
- out += renderer.br(token);
2768
+ n += t.br(i);
3013
2769
  break;
3014
2770
  case "del":
3015
- out += renderer.del(token);
2771
+ n += t.del(i);
3016
2772
  break;
3017
2773
  case "text":
3018
- out += renderer.text(token);
2774
+ n += t.text(i);
3019
2775
  break;
3020
2776
  default: {
3021
- const errMsg = "Token with \"" + token.type + "\" type was not found.";
3022
- if (this.options.silent) {
3023
- console.error(errMsg);
3024
- return "";
3025
- } else throw new Error(errMsg);
2777
+ let o = "Token with \"" + i.type + "\" type was not found.";
2778
+ if (this.options.silent) return console.error(o), "";
2779
+ throw new Error(o);
3026
2780
  }
3027
2781
  }
3028
2782
  }
3029
- return out;
2783
+ return n;
3030
2784
  }
3031
2785
  };
3032
- var _Hooks = class {
2786
+ var P = class {
3033
2787
  options;
3034
2788
  block;
3035
- constructor(options2) {
3036
- this.options = options2 || _defaults;
2789
+ constructor(e) {
2790
+ this.options = e || T;
3037
2791
  }
3038
2792
  static passThroughHooks = /* @__PURE__ */ new Set([
2793
+ "preprocess",
2794
+ "postprocess",
2795
+ "processAllTokens",
2796
+ "emStrongMask"
2797
+ ]);
2798
+ static passThroughHooksRespectAsync = /* @__PURE__ */ new Set([
3039
2799
  "preprocess",
3040
2800
  "postprocess",
3041
2801
  "processAllTokens"
3042
2802
  ]);
3043
- /**
3044
- * Process markdown before marked
3045
- */
3046
- preprocess(markdown) {
3047
- return markdown;
2803
+ preprocess(e) {
2804
+ return e;
3048
2805
  }
3049
- /**
3050
- * Process HTML after marked is finished
3051
- */
3052
- postprocess(html2) {
3053
- return html2;
2806
+ postprocess(e) {
2807
+ return e;
3054
2808
  }
3055
- /**
3056
- * Process all tokens before walk tokens
3057
- */
3058
- processAllTokens(tokens) {
3059
- return tokens;
2809
+ processAllTokens(e) {
2810
+ return e;
3060
2811
  }
3061
- /**
3062
- * Provide function to tokenize markdown
3063
- */
3064
- provideLexer() {
3065
- return this.block ? _Lexer.lex : _Lexer.lexInline;
2812
+ emStrongMask(e) {
2813
+ return e;
3066
2814
  }
3067
- /**
3068
- * Provide function to parse tokens
3069
- */
3070
- provideParser() {
3071
- return this.block ? _Parser.parse : _Parser.parseInline;
2815
+ provideLexer(e = this.block) {
2816
+ return e ? x.lex : x.lexInline;
2817
+ }
2818
+ provideParser(e = this.block) {
2819
+ return e ? b.parse : b.parseInline;
3072
2820
  }
3073
2821
  };
3074
- var Marked = class {
3075
- defaults = _getDefaults();
2822
+ var q = class {
2823
+ defaults = M();
3076
2824
  options = this.setOptions;
3077
- parse = this.parseMarkdown(true);
3078
- parseInline = this.parseMarkdown(false);
3079
- Parser = _Parser;
3080
- Renderer = _Renderer;
3081
- TextRenderer = _TextRenderer;
3082
- Lexer = _Lexer;
3083
- Tokenizer = _Tokenizer;
3084
- Hooks = _Hooks;
3085
- constructor(...args) {
3086
- this.use(...args);
3087
- }
3088
- /**
3089
- * Run callback for every token
3090
- */
3091
- walkTokens(tokens, callback) {
3092
- let values = [];
3093
- for (const token of tokens) {
3094
- values = values.concat(callback.call(this, token));
3095
- switch (token.type) {
3096
- case "table": {
3097
- const tableToken = token;
3098
- for (const cell of tableToken.header) values = values.concat(this.walkTokens(cell.tokens, callback));
3099
- for (const row of tableToken.rows) for (const cell of row) values = values.concat(this.walkTokens(cell.tokens, callback));
3100
- break;
3101
- }
3102
- case "list": {
3103
- const listToken = token;
3104
- values = values.concat(this.walkTokens(listToken.items, callback));
3105
- break;
3106
- }
3107
- default: {
3108
- const genericToken = token;
3109
- if (this.defaults.extensions?.childTokens?.[genericToken.type]) this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
3110
- const tokens2 = genericToken[childTokens].flat(Infinity);
3111
- values = values.concat(this.walkTokens(tokens2, callback));
3112
- });
3113
- else if (genericToken.tokens) values = values.concat(this.walkTokens(genericToken.tokens, callback));
3114
- }
2825
+ parse = this.parseMarkdown(!0);
2826
+ parseInline = this.parseMarkdown(!1);
2827
+ Parser = b;
2828
+ Renderer = y;
2829
+ TextRenderer = L;
2830
+ Lexer = x;
2831
+ Tokenizer = w;
2832
+ Hooks = P;
2833
+ constructor(...e) {
2834
+ this.use(...e);
2835
+ }
2836
+ walkTokens(e, t) {
2837
+ let n = [];
2838
+ for (let s of e) switch (n = n.concat(t.call(this, s)), s.type) {
2839
+ case "table": {
2840
+ let r = s;
2841
+ for (let i of r.header) n = n.concat(this.walkTokens(i.tokens, t));
2842
+ for (let i of r.rows) for (let o of i) n = n.concat(this.walkTokens(o.tokens, t));
2843
+ break;
2844
+ }
2845
+ case "list": {
2846
+ let r = s;
2847
+ n = n.concat(this.walkTokens(r.items, t));
2848
+ break;
2849
+ }
2850
+ default: {
2851
+ let r = s;
2852
+ this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
2853
+ let o = r[i].flat(Infinity);
2854
+ n = n.concat(this.walkTokens(o, t));
2855
+ }) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
3115
2856
  }
3116
2857
  }
3117
- return values;
2858
+ return n;
3118
2859
  }
3119
- use(...args) {
3120
- const extensions = this.defaults.extensions || {
2860
+ use(...e) {
2861
+ let t = this.defaults.extensions || {
3121
2862
  renderers: {},
3122
2863
  childTokens: {}
3123
2864
  };
3124
- args.forEach((pack) => {
3125
- const opts = { ...pack };
3126
- opts.async = this.defaults.async || opts.async || false;
3127
- if (pack.extensions) {
3128
- pack.extensions.forEach((ext) => {
3129
- if (!ext.name) throw new Error("extension name required");
3130
- if ("renderer" in ext) {
3131
- const prevRenderer = extensions.renderers[ext.name];
3132
- if (prevRenderer) extensions.renderers[ext.name] = function(...args2) {
3133
- let ret = ext.renderer.apply(this, args2);
3134
- if (ret === false) ret = prevRenderer.apply(this, args2);
3135
- return ret;
3136
- };
3137
- else extensions.renderers[ext.name] = ext.renderer;
3138
- }
3139
- if ("tokenizer" in ext) {
3140
- if (!ext.level || ext.level !== "block" && ext.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
3141
- const extLevel = extensions[ext.level];
3142
- if (extLevel) extLevel.unshift(ext.tokenizer);
3143
- else extensions[ext.level] = [ext.tokenizer];
3144
- if (ext.start) {
3145
- if (ext.level === "block") if (extensions.startBlock) extensions.startBlock.push(ext.start);
3146
- else extensions.startBlock = [ext.start];
3147
- else if (ext.level === "inline") if (extensions.startInline) extensions.startInline.push(ext.start);
3148
- else extensions.startInline = [ext.start];
3149
- }
3150
- }
3151
- if ("childTokens" in ext && ext.childTokens) extensions.childTokens[ext.name] = ext.childTokens;
3152
- });
3153
- opts.extensions = extensions;
3154
- }
3155
- if (pack.renderer) {
3156
- const renderer = this.defaults.renderer || new _Renderer(this.defaults);
3157
- for (const prop in pack.renderer) {
3158
- if (!(prop in renderer)) throw new Error(`renderer '${prop}' does not exist`);
3159
- if (["options", "parser"].includes(prop)) continue;
3160
- const rendererProp = prop;
3161
- const rendererFunc = pack.renderer[rendererProp];
3162
- const prevRenderer = renderer[rendererProp];
3163
- renderer[rendererProp] = (...args2) => {
3164
- let ret = rendererFunc.apply(renderer, args2);
3165
- if (ret === false) ret = prevRenderer.apply(renderer, args2);
3166
- return ret || "";
2865
+ return e.forEach((n) => {
2866
+ let s = { ...n };
2867
+ if (s.async = this.defaults.async || s.async || !1, n.extensions && (n.extensions.forEach((r) => {
2868
+ if (!r.name) throw new Error("extension name required");
2869
+ if ("renderer" in r) {
2870
+ let i = t.renderers[r.name];
2871
+ i ? t.renderers[r.name] = function(...o) {
2872
+ let u = r.renderer.apply(this, o);
2873
+ return u === !1 && (u = i.apply(this, o)), u;
2874
+ } : t.renderers[r.name] = r.renderer;
2875
+ }
2876
+ if ("tokenizer" in r) {
2877
+ if (!r.level || r.level !== "block" && r.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
2878
+ let i = t[r.level];
2879
+ i ? i.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
2880
+ }
2881
+ "childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
2882
+ }), s.extensions = t), n.renderer) {
2883
+ let r = this.defaults.renderer || new y(this.defaults);
2884
+ for (let i in n.renderer) {
2885
+ if (!(i in r)) throw new Error(`renderer '${i}' does not exist`);
2886
+ if (["options", "parser"].includes(i)) continue;
2887
+ let o = i, u = n.renderer[o], a = r[o];
2888
+ r[o] = (...c) => {
2889
+ let p = u.apply(r, c);
2890
+ return p === !1 && (p = a.apply(r, c)), p || "";
3167
2891
  };
3168
2892
  }
3169
- opts.renderer = renderer;
2893
+ s.renderer = r;
3170
2894
  }
3171
- if (pack.tokenizer) {
3172
- const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
3173
- for (const prop in pack.tokenizer) {
3174
- if (!(prop in tokenizer)) throw new Error(`tokenizer '${prop}' does not exist`);
2895
+ if (n.tokenizer) {
2896
+ let r = this.defaults.tokenizer || new w(this.defaults);
2897
+ for (let i in n.tokenizer) {
2898
+ if (!(i in r)) throw new Error(`tokenizer '${i}' does not exist`);
3175
2899
  if ([
3176
2900
  "options",
3177
2901
  "rules",
3178
2902
  "lexer"
3179
- ].includes(prop)) continue;
3180
- const tokenizerProp = prop;
3181
- const tokenizerFunc = pack.tokenizer[tokenizerProp];
3182
- const prevTokenizer = tokenizer[tokenizerProp];
3183
- tokenizer[tokenizerProp] = (...args2) => {
3184
- let ret = tokenizerFunc.apply(tokenizer, args2);
3185
- if (ret === false) ret = prevTokenizer.apply(tokenizer, args2);
3186
- return ret;
2903
+ ].includes(i)) continue;
2904
+ let o = i, u = n.tokenizer[o], a = r[o];
2905
+ r[o] = (...c) => {
2906
+ let p = u.apply(r, c);
2907
+ return p === !1 && (p = a.apply(r, c)), p;
3187
2908
  };
3188
2909
  }
3189
- opts.tokenizer = tokenizer;
3190
- }
3191
- if (pack.hooks) {
3192
- const hooks = this.defaults.hooks || new _Hooks();
3193
- for (const prop in pack.hooks) {
3194
- if (!(prop in hooks)) throw new Error(`hook '${prop}' does not exist`);
3195
- if (["options", "block"].includes(prop)) continue;
3196
- const hooksProp = prop;
3197
- const hooksFunc = pack.hooks[hooksProp];
3198
- const prevHook = hooks[hooksProp];
3199
- if (_Hooks.passThroughHooks.has(prop)) hooks[hooksProp] = (arg) => {
3200
- if (this.defaults.async) return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
3201
- return prevHook.call(hooks, ret2);
3202
- });
3203
- const ret = hooksFunc.call(hooks, arg);
3204
- return prevHook.call(hooks, ret);
3205
- };
3206
- else hooks[hooksProp] = (...args2) => {
3207
- let ret = hooksFunc.apply(hooks, args2);
3208
- if (ret === false) ret = prevHook.apply(hooks, args2);
3209
- return ret;
2910
+ s.tokenizer = r;
2911
+ }
2912
+ if (n.hooks) {
2913
+ let r = this.defaults.hooks || new P();
2914
+ for (let i in n.hooks) {
2915
+ if (!(i in r)) throw new Error(`hook '${i}' does not exist`);
2916
+ if (["options", "block"].includes(i)) continue;
2917
+ let o = i, u = n.hooks[o], a = r[o];
2918
+ P.passThroughHooks.has(i) ? r[o] = (c) => {
2919
+ if (this.defaults.async && P.passThroughHooksRespectAsync.has(i)) return (async () => {
2920
+ let k = await u.call(r, c);
2921
+ return a.call(r, k);
2922
+ })();
2923
+ let p = u.call(r, c);
2924
+ return a.call(r, p);
2925
+ } : r[o] = (...c) => {
2926
+ if (this.defaults.async) return (async () => {
2927
+ let k = await u.apply(r, c);
2928
+ return k === !1 && (k = await a.apply(r, c)), k;
2929
+ })();
2930
+ let p = u.apply(r, c);
2931
+ return p === !1 && (p = a.apply(r, c)), p;
3210
2932
  };
3211
2933
  }
3212
- opts.hooks = hooks;
3213
- }
3214
- if (pack.walkTokens) {
3215
- const walkTokens2 = this.defaults.walkTokens;
3216
- const packWalktokens = pack.walkTokens;
3217
- opts.walkTokens = function(token) {
3218
- let values = [];
3219
- values.push(packWalktokens.call(this, token));
3220
- if (walkTokens2) values = values.concat(walkTokens2.call(this, token));
3221
- return values;
2934
+ s.hooks = r;
2935
+ }
2936
+ if (n.walkTokens) {
2937
+ let r = this.defaults.walkTokens, i = n.walkTokens;
2938
+ s.walkTokens = function(o) {
2939
+ let u = [];
2940
+ return u.push(i.call(this, o)), r && (u = u.concat(r.call(this, o))), u;
3222
2941
  };
3223
2942
  }
3224
2943
  this.defaults = {
3225
2944
  ...this.defaults,
3226
- ...opts
2945
+ ...s
3227
2946
  };
3228
- });
3229
- return this;
2947
+ }), this;
3230
2948
  }
3231
- setOptions(opt) {
3232
- this.defaults = {
2949
+ setOptions(e) {
2950
+ return this.defaults = {
3233
2951
  ...this.defaults,
3234
- ...opt
3235
- };
3236
- return this;
2952
+ ...e
2953
+ }, this;
3237
2954
  }
3238
- lexer(src, options2) {
3239
- return _Lexer.lex(src, options2 ?? this.defaults);
2955
+ lexer(e, t) {
2956
+ return x.lex(e, t ?? this.defaults);
3240
2957
  }
3241
- parser(tokens, options2) {
3242
- return _Parser.parse(tokens, options2 ?? this.defaults);
2958
+ parser(e, t) {
2959
+ return b.parse(e, t ?? this.defaults);
3243
2960
  }
3244
- parseMarkdown(blockType) {
3245
- const parse2 = (src, options2) => {
3246
- const origOpt = { ...options2 };
3247
- const opt = {
2961
+ parseMarkdown(e) {
2962
+ return (n, s) => {
2963
+ let r = { ...s }, i = {
3248
2964
  ...this.defaults,
3249
- ...origOpt
3250
- };
3251
- const throwError = this.onError(!!opt.silent, !!opt.async);
3252
- if (this.defaults.async === true && origOpt.async === false) return throwError(/* @__PURE__ */ 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."));
3253
- if (typeof src === "undefined" || src === null) return throwError(/* @__PURE__ */ new Error("marked(): input parameter is undefined or null"));
3254
- if (typeof src !== "string") return throwError(/* @__PURE__ */ new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
3255
- if (opt.hooks) {
3256
- opt.hooks.options = opt;
3257
- opt.hooks.block = blockType;
3258
- }
3259
- const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
3260
- const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
3261
- if (opt.async) 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((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError);
2965
+ ...r
2966
+ }, o = this.onError(!!i.silent, !!i.async);
2967
+ if (this.defaults.async === !0 && r.async === !1) return o(/* @__PURE__ */ 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."));
2968
+ if (typeof n > "u" || n === null) return o(/* @__PURE__ */ new Error("marked(): input parameter is undefined or null"));
2969
+ if (typeof n != "string") return o(/* @__PURE__ */ new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
2970
+ if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
2971
+ let u = i.hooks ? await i.hooks.preprocess(n) : n, c = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(u, i), p = i.hooks ? await i.hooks.processAllTokens(c) : c;
2972
+ i.walkTokens && await Promise.all(this.walkTokens(p, i.walkTokens));
2973
+ let h = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(p, i);
2974
+ return i.hooks ? await i.hooks.postprocess(h) : h;
2975
+ })().catch(o);
3262
2976
  try {
3263
- if (opt.hooks) src = opt.hooks.preprocess(src);
3264
- let tokens = lexer2(src, opt);
3265
- if (opt.hooks) tokens = opt.hooks.processAllTokens(tokens);
3266
- if (opt.walkTokens) this.walkTokens(tokens, opt.walkTokens);
3267
- let html2 = parser2(tokens, opt);
3268
- if (opt.hooks) html2 = opt.hooks.postprocess(html2);
3269
- return html2;
3270
- } catch (e) {
3271
- return throwError(e);
2977
+ i.hooks && (n = i.hooks.preprocess(n));
2978
+ let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
2979
+ i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
2980
+ let p = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
2981
+ return i.hooks && (p = i.hooks.postprocess(p)), p;
2982
+ } catch (u) {
2983
+ return o(u);
3272
2984
  }
3273
2985
  };
3274
- return parse2;
3275
- }
3276
- onError(silent, async) {
3277
- return (e) => {
3278
- e.message += "\nPlease report this to https://github.com/markedjs/marked.";
3279
- if (silent) {
3280
- const msg = "<p>An error occurred:</p><pre>" + escape2(e.message + "", true) + "</pre>";
3281
- if (async) return Promise.resolve(msg);
3282
- return msg;
3283
- }
3284
- if (async) return Promise.reject(e);
3285
- throw e;
2986
+ }
2987
+ onError(e, t) {
2988
+ return (n) => {
2989
+ if (n.message += `
2990
+ Please report this to https://github.com/markedjs/marked.`, e) {
2991
+ let s = "<p>An error occurred:</p><pre>" + O(n.message + "", !0) + "</pre>";
2992
+ return t ? Promise.resolve(s) : s;
2993
+ }
2994
+ if (t) return Promise.reject(n);
2995
+ throw n;
3286
2996
  };
3287
2997
  }
3288
2998
  };
3289
- var markedInstance = new Marked();
3290
- function marked(src, opt) {
3291
- return markedInstance.parse(src, opt);
3292
- }
3293
- marked.options = marked.setOptions = function(options2) {
3294
- markedInstance.setOptions(options2);
3295
- marked.defaults = markedInstance.defaults;
3296
- changeDefaults(marked.defaults);
3297
- return marked;
2999
+ var z = new q();
3000
+ function g(l, e) {
3001
+ return z.parse(l, e);
3002
+ }
3003
+ g.options = g.setOptions = function(l) {
3004
+ return z.setOptions(l), g.defaults = z.defaults, N(g.defaults), g;
3298
3005
  };
3299
- marked.getDefaults = _getDefaults;
3300
- marked.defaults = _defaults;
3301
- marked.use = function(...args) {
3302
- markedInstance.use(...args);
3303
- marked.defaults = markedInstance.defaults;
3304
- changeDefaults(marked.defaults);
3305
- return marked;
3006
+ g.getDefaults = M;
3007
+ g.defaults = T;
3008
+ g.use = function(...l) {
3009
+ return z.use(...l), g.defaults = z.defaults, N(g.defaults), g;
3306
3010
  };
3307
- marked.walkTokens = function(tokens, callback) {
3308
- return markedInstance.walkTokens(tokens, callback);
3011
+ g.walkTokens = function(l, e) {
3012
+ return z.walkTokens(l, e);
3309
3013
  };
3310
- marked.parseInline = markedInstance.parseInline;
3311
- marked.Parser = _Parser;
3312
- marked.parser = _Parser.parse;
3313
- marked.Renderer = _Renderer;
3314
- marked.TextRenderer = _TextRenderer;
3315
- marked.Lexer = _Lexer;
3316
- marked.lexer = _Lexer.lex;
3317
- marked.Tokenizer = _Tokenizer;
3318
- marked.Hooks = _Hooks;
3319
- marked.parse = marked;
3320
- marked.options;
3321
- marked.setOptions;
3322
- marked.use;
3323
- marked.walkTokens;
3324
- marked.parseInline;
3325
- _Parser.parse;
3326
- _Lexer.lex;
3014
+ g.parseInline = z.parseInline;
3015
+ g.Parser = b;
3016
+ g.parser = b.parse;
3017
+ g.Renderer = y;
3018
+ g.TextRenderer = L;
3019
+ g.Lexer = x;
3020
+ g.lexer = x.lex;
3021
+ g.Tokenizer = w;
3022
+ g.Hooks = P;
3023
+ g.parse = g;
3024
+ g.options;
3025
+ g.setOptions;
3026
+ g.use;
3027
+ g.walkTokens;
3028
+ g.parseInline;
3029
+ b.parse;
3030
+ x.lex;
3327
3031
  //#endregion
3328
- //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.78.0/node_modules/@earendil-works/pi-tui/dist/components/markdown.js
3032
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.79.8/node_modules/@earendil-works/pi-tui/dist/components/markdown.js
3329
3033
  const STRICT_STRIKETHROUGH_REGEX = /^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/;
3330
- var StrictStrikethroughTokenizer = class extends _Tokenizer {
3034
+ var StrictStrikethroughTokenizer = class extends w {
3331
3035
  del(src) {
3332
3036
  const match = STRICT_STRIKETHROUGH_REGEX.exec(src);
3333
3037
  if (!match) return;
@@ -3340,7 +3044,7 @@ var StrictStrikethroughTokenizer = class extends _Tokenizer {
3340
3044
  };
3341
3045
  }
3342
3046
  };
3343
- new Marked().setOptions({ tokenizer: new StrictStrikethroughTokenizer() });
3047
+ new q().setOptions({ tokenizer: new StrictStrikethroughTokenizer() });
3344
3048
  createRequire(import.meta.url);
3345
3049
  createRequire(import.meta.url);
3346
3050
  //#endregion