artalk 2.5.5 → 2.6.0

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.
package/dist/Artalk.es.js CHANGED
@@ -21,6 +21,19 @@ var __publicField = (obj, key, value) => {
21
21
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
22
  return value;
23
23
  };
24
+ var __accessCheck = (obj, member, msg) => {
25
+ if (!member.has(obj))
26
+ throw TypeError("Cannot " + msg);
27
+ };
28
+ var __privateAdd = (obj, member, value) => {
29
+ if (member.has(obj))
30
+ throw TypeError("Cannot add the same private member more than once");
31
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
32
+ };
33
+ var __privateMethod = (obj, member, method) => {
34
+ __accessCheck(obj, member, "access private method");
35
+ return method;
36
+ };
24
37
  var __async = (__this, __arguments, generator) => {
25
38
  return new Promise((resolve, reject) => {
26
39
  var fulfilled = (value) => {
@@ -41,6 +54,7 @@ var __async = (__this, __arguments, generator) => {
41
54
  step((generator = generator.apply(__this, __arguments)).next());
42
55
  });
43
56
  };
57
+ var _parseMarkdown, parseMarkdown_fn, _onError, onError_fn;
44
58
  const main = "";
45
59
  function createElement(htmlStr = "") {
46
60
  const div = document.createElement("div");
@@ -368,7 +382,7 @@ function getScrollBarWidth() {
368
382
  document.body.removeChild(outer);
369
383
  return w1 - w2;
370
384
  }
371
- const _Layer = class extends Component {
385
+ const _Layer = class _Layer extends Component {
372
386
  constructor(ctx, name, el) {
373
387
  super(ctx);
374
388
  __publicField(this, "name");
@@ -475,11 +489,11 @@ const _Layer = class extends Component {
475
489
  }
476
490
  }
477
491
  };
478
- let Layer = _Layer;
479
- __publicField(Layer, "BodyOrgOverflow");
480
- __publicField(Layer, "BodyOrgPaddingRight");
492
+ __publicField(_Layer, "BodyOrgOverflow");
493
+ __publicField(_Layer, "BodyOrgPaddingRight");
481
494
  // Timers
482
- __publicField(Layer, "actionTimers", []);
495
+ __publicField(_Layer, "actionTimers", []);
496
+ let Layer = _Layer;
483
497
  function getLayerWrap() {
484
498
  let $wrap = document.querySelector(`.atk-layer-wrap`);
485
499
  if (!$wrap) {
@@ -531,19 +545,19 @@ function updateClassName(ctx, darkMode) {
531
545
  $layerWrap.classList.remove(DarkModeClassName);
532
546
  }
533
547
  }
534
- function getDefaults() {
548
+ function _getDefaults() {
535
549
  return {
536
550
  async: false,
537
551
  baseUrl: null,
538
552
  breaks: false,
539
553
  extensions: null,
540
554
  gfm: true,
541
- headerIds: true,
555
+ headerIds: false,
542
556
  headerPrefix: "",
543
557
  highlight: null,
544
558
  hooks: null,
545
559
  langPrefix: "language-",
546
- mangle: true,
560
+ mangle: false,
547
561
  pedantic: false,
548
562
  renderer: null,
549
563
  sanitize: false,
@@ -555,9 +569,9 @@ function getDefaults() {
555
569
  xhtml: false
556
570
  };
557
571
  }
558
- let defaults$3 = getDefaults();
572
+ let _defaults = _getDefaults();
559
573
  function changeDefaults(newDefaults) {
560
- defaults$3 = newDefaults;
574
+ _defaults = newDefaults;
561
575
  }
562
576
  const escapeTest = /[&<>"']/;
563
577
  const escapeReplace = new RegExp(escapeTest.source, "g");
@@ -601,7 +615,7 @@ function edit$1(regex, opt) {
601
615
  opt = opt || "";
602
616
  const obj = {
603
617
  replace: (name, val) => {
604
- val = val.source || val;
618
+ val = typeof val === "object" && "source" in val ? val.source : val;
605
619
  val = val.replace(caret, "$1");
606
620
  regex = regex.replace(name, val);
607
621
  return obj;
@@ -664,11 +678,11 @@ function resolveUrl(base, href) {
664
678
  return base + href;
665
679
  }
666
680
  }
667
- const noopTest = { exec: function noopTest2() {
668
- } };
681
+ const noopTest = { exec: () => null };
669
682
  function splitCells(tableRow, count) {
670
683
  const row = tableRow.replace(/\|/g, (match, offset, str) => {
671
- let escaped = false, curr = offset;
684
+ let escaped = false;
685
+ let curr = offset;
672
686
  while (--curr >= 0 && str[curr] === "\\")
673
687
  escaped = !escaped;
674
688
  if (escaped) {
@@ -684,11 +698,13 @@ function splitCells(tableRow, count) {
684
698
  if (cells.length > 0 && !cells[cells.length - 1].trim()) {
685
699
  cells.pop();
686
700
  }
687
- if (cells.length > count) {
688
- cells.splice(count);
689
- } else {
690
- while (cells.length < count)
691
- cells.push("");
701
+ if (count) {
702
+ if (cells.length > count) {
703
+ cells.splice(count);
704
+ } else {
705
+ while (cells.length < count)
706
+ cells.push("");
707
+ }
692
708
  }
693
709
  for (; i < cells.length; i++) {
694
710
  cells[i] = cells[i].trim().replace(/\\\|/g, "|");
@@ -717,9 +733,8 @@ function findClosingBracket(str, b) {
717
733
  if (str.indexOf(b[1]) === -1) {
718
734
  return -1;
719
735
  }
720
- const l = str.length;
721
- let level = 0, i = 0;
722
- for (; i < l; i++) {
736
+ let level = 0;
737
+ for (let i = 0; i < str.length; i++) {
723
738
  if (str[i] === "\\") {
724
739
  i++;
725
740
  } else if (str[i] === b[0]) {
@@ -747,7 +762,7 @@ function checkDeprecations(opt, callback) {
747
762
  console.warn("marked(): highlight and langPrefix parameters are deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-highlight.");
748
763
  }
749
764
  if (opt.mangle) {
750
- console.warn("marked(): mangle parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-mangle.");
765
+ console.warn("marked(): mangle parameter is enabled by default, but is deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-mangle, or disable by setting `{mangle: false}`.");
751
766
  }
752
767
  if (opt.baseUrl) {
753
768
  console.warn("marked(): baseUrl parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-base-url.");
@@ -759,22 +774,8 @@ function checkDeprecations(opt, callback) {
759
774
  console.warn("marked(): xhtml parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-xhtml.");
760
775
  }
761
776
  if (opt.headerIds || opt.headerPrefix) {
762
- console.warn("marked(): headerIds and headerPrefix parameters are deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-gfm-heading-id.");
763
- }
764
- }
765
- function repeatString(pattern, count) {
766
- if (count < 1) {
767
- return "";
768
- }
769
- let result = "";
770
- while (count > 1) {
771
- if (count & 1) {
772
- result += pattern;
773
- }
774
- count >>= 1;
775
- pattern += pattern;
777
+ console.warn("marked(): headerIds and headerPrefix parameters enabled by default, but are deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-gfm-heading-id, or disable by setting `{headerIds: false}`.");
776
778
  }
777
- return result + pattern;
778
779
  }
779
780
  function outputLink(cap, link, raw, lexer) {
780
781
  const href = link.href;
@@ -819,9 +820,13 @@ function indentCodeCompensation(raw, text) {
819
820
  return node;
820
821
  }).join("\n");
821
822
  }
822
- class Tokenizer {
823
+ class _Tokenizer {
823
824
  constructor(options) {
824
- this.options = options || defaults$3;
825
+ __publicField(this, "options");
826
+ // TODO: Fix this rules type
827
+ __publicField(this, "rules");
828
+ __publicField(this, "lexer");
829
+ this.options = options || _defaults;
825
830
  }
826
831
  space(src) {
827
832
  const cap = this.rules.block.newline.exec(src);
@@ -906,7 +911,6 @@ class Tokenizer {
906
911
  list(src) {
907
912
  let cap = this.rules.block.list.exec(src);
908
913
  if (cap) {
909
- let raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine, line, nextLine, rawLine, itemContents, endEarly;
910
914
  let bull = cap[1].trim();
911
915
  const isordered = bull.length > 1;
912
916
  const list = {
@@ -922,8 +926,11 @@ class Tokenizer {
922
926
  bull = isordered ? bull : "[*+-]";
923
927
  }
924
928
  const itemRegex = new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`);
929
+ let raw = "";
930
+ let itemContents = "";
931
+ let endsWithBlankLine = false;
925
932
  while (src) {
926
- endEarly = false;
933
+ let endEarly = false;
927
934
  if (!(cap = itemRegex.exec(src))) {
928
935
  break;
929
936
  }
@@ -932,8 +939,9 @@ class Tokenizer {
932
939
  }
933
940
  raw = cap[0];
934
941
  src = src.substring(raw.length);
935
- line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t2) => " ".repeat(3 * t2.length));
936
- nextLine = src.split("\n", 1)[0];
942
+ let line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t2) => " ".repeat(3 * t2.length));
943
+ let nextLine = src.split("\n", 1)[0];
944
+ let indent = 0;
937
945
  if (this.options.pedantic) {
938
946
  indent = 2;
939
947
  itemContents = line.trimLeft();
@@ -943,7 +951,7 @@ class Tokenizer {
943
951
  itemContents = line.slice(indent);
944
952
  indent += cap[1].length;
945
953
  }
946
- blankLine = false;
954
+ let blankLine = false;
947
955
  if (!line && /^ *$/.test(nextLine)) {
948
956
  raw += nextLine + "\n";
949
957
  src = src.substring(nextLine.length + 1);
@@ -955,7 +963,7 @@ class Tokenizer {
955
963
  const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
956
964
  const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
957
965
  while (src) {
958
- rawLine = src.split("\n", 1)[0];
966
+ const rawLine = src.split("\n", 1)[0];
959
967
  nextLine = rawLine;
960
968
  if (this.options.pedantic) {
961
969
  nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
@@ -1007,6 +1015,8 @@ class Tokenizer {
1007
1015
  endsWithBlankLine = true;
1008
1016
  }
1009
1017
  }
1018
+ let istask = null;
1019
+ let ischecked;
1010
1020
  if (this.options.gfm) {
1011
1021
  istask = /^\[[ xX]\] /.exec(itemContents);
1012
1022
  if (istask) {
@@ -1020,15 +1030,15 @@ class Tokenizer {
1020
1030
  task: !!istask,
1021
1031
  checked: ischecked,
1022
1032
  loose: false,
1023
- text: itemContents
1033
+ text: itemContents,
1034
+ tokens: []
1024
1035
  });
1025
1036
  list.raw += raw;
1026
1037
  }
1027
1038
  list.items[list.items.length - 1].raw = raw.trimRight();
1028
1039
  list.items[list.items.length - 1].text = itemContents.trimRight();
1029
1040
  list.raw = list.raw.trimRight();
1030
- const l = list.items.length;
1031
- for (i = 0; i < l; i++) {
1041
+ for (let i = 0; i < list.items.length; i++) {
1032
1042
  this.lexer.state.top = false;
1033
1043
  list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
1034
1044
  if (!list.loose) {
@@ -1038,7 +1048,7 @@ class Tokenizer {
1038
1048
  }
1039
1049
  }
1040
1050
  if (list.loose) {
1041
- for (i = 0; i < l; i++) {
1051
+ for (let i = 0; i < list.items.length; i++) {
1042
1052
  list.items[i].loose = true;
1043
1053
  }
1044
1054
  }
@@ -1057,9 +1067,10 @@ class Tokenizer {
1057
1067
  };
1058
1068
  if (this.options.sanitize) {
1059
1069
  const text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
1060
- token.type = "paragraph";
1061
- token.text = text;
1062
- token.tokens = this.lexer.inline(text);
1070
+ const paragraph = token;
1071
+ paragraph.type = "paragraph";
1072
+ paragraph.text = text;
1073
+ paragraph.tokens = this.lexer.inline(text);
1063
1074
  }
1064
1075
  return token;
1065
1076
  }
@@ -1084,31 +1095,34 @@ class Tokenizer {
1084
1095
  if (cap) {
1085
1096
  const item = {
1086
1097
  type: "table",
1098
+ raw: cap[0],
1087
1099
  header: splitCells(cap[1]).map((c) => {
1088
- return { text: c };
1100
+ return { text: c, tokens: [] };
1089
1101
  }),
1090
1102
  align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
1091
1103
  rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : []
1092
1104
  };
1093
1105
  if (item.header.length === item.align.length) {
1094
- item.raw = cap[0];
1095
1106
  let l = item.align.length;
1096
1107
  let i, j, k, row;
1097
1108
  for (i = 0; i < l; i++) {
1098
- if (/^ *-+: *$/.test(item.align[i])) {
1099
- item.align[i] = "right";
1100
- } else if (/^ *:-+: *$/.test(item.align[i])) {
1101
- item.align[i] = "center";
1102
- } else if (/^ *:-+ *$/.test(item.align[i])) {
1103
- item.align[i] = "left";
1104
- } else {
1105
- item.align[i] = null;
1109
+ const align = item.align[i];
1110
+ if (align) {
1111
+ if (/^ *-+: *$/.test(align)) {
1112
+ item.align[i] = "right";
1113
+ } else if (/^ *:-+: *$/.test(align)) {
1114
+ item.align[i] = "center";
1115
+ } else if (/^ *:-+ *$/.test(align)) {
1116
+ item.align[i] = "left";
1117
+ } else {
1118
+ item.align[i] = null;
1119
+ }
1106
1120
  }
1107
1121
  }
1108
1122
  l = item.rows.length;
1109
1123
  for (i = 0; i < l; i++) {
1110
1124
  item.rows[i] = splitCells(item.rows[i], item.header.length).map((c) => {
1111
- return { text: c };
1125
+ return { text: c, tokens: [] };
1112
1126
  });
1113
1127
  }
1114
1128
  l = item.header.length;
@@ -1264,8 +1278,8 @@ class Tokenizer {
1264
1278
  if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
1265
1279
  return;
1266
1280
  const nextChar = match[1] || match[2] || "";
1267
- if (!nextChar || nextChar && (prevChar === "" || this.rules.inline.punctuation.exec(prevChar))) {
1268
- const lLength = match[0].length - 1;
1281
+ if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
1282
+ const lLength = [...match[0]].length - 1;
1269
1283
  let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
1270
1284
  const endReg = match[0][0] === "*" ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
1271
1285
  endReg.lastIndex = 0;
@@ -1274,7 +1288,7 @@ class Tokenizer {
1274
1288
  rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
1275
1289
  if (!rDelim)
1276
1290
  continue;
1277
- rLength = rDelim.length;
1291
+ rLength = [...rDelim].length;
1278
1292
  if (match[3] || match[4]) {
1279
1293
  delimTotal += rLength;
1280
1294
  continue;
@@ -1288,7 +1302,7 @@ class Tokenizer {
1288
1302
  if (delimTotal > 0)
1289
1303
  continue;
1290
1304
  rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
1291
- const raw = src.slice(0, lLength + match.index + (match[0].length - rDelim.length) + rLength);
1305
+ const raw = [...src].slice(0, lLength + match.index + rLength + 1).join("");
1292
1306
  if (Math.min(lLength, rLength) % 2) {
1293
1307
  const text2 = raw.slice(1, -1);
1294
1308
  return {
@@ -1434,7 +1448,7 @@ const block = {
1434
1448
  html: "^ {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|$))",
1435
1449
  def: /^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
1436
1450
  table: noopTest,
1437
- lheading: /^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
1451
+ lheading: /^((?:(?!^bull ).|\n(?!\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
1438
1452
  // regex template, placeholders will be replaced according to different paragraph
1439
1453
  // interruption rules of commonmark and the original markdown spec:
1440
1454
  _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
@@ -1449,6 +1463,7 @@ block.list = edit$1(block.list).replace(/bull/g, block.bullet).replace("hr", "\\
1449
1463
  block._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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
1450
1464
  block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
1451
1465
  block.html = edit$1(block.html, "i").replace("comment", block._comment).replace("tag", block._tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
1466
+ block.lheading = edit$1(block.lheading).replace(/bull/g, block.bullet).getRegex();
1452
1467
  block.paragraph = edit$1(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").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", block._tag).getRegex();
1453
1468
  block.blockquote = edit$1(block.blockquote).replace("paragraph", block.paragraph).getRegex();
1454
1469
  block.normal = __spreadValues({}, block);
@@ -1459,13 +1474,10 @@ block.gfm = __spreadProps(__spreadValues({}, block.normal), {
1459
1474
  block.gfm.table = edit$1(block.gfm.table).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
1460
1475
  block.gfm.paragraph = edit$1(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("table", block.gfm.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", block._tag).getRegex();
1461
1476
  block.pedantic = __spreadProps(__spreadValues({}, block.normal), {
1462
- html: edit$1(
1463
- `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
1464
- ).replace("comment", block._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(),
1477
+ html: edit$1(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", block._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(),
1465
1478
  def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
1466
1479
  heading: /^(#{1,6})(.*)(?:\n+|$)/,
1467
1480
  fences: noopTest,
1468
- // fences not supported
1469
1481
  lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
1470
1482
  paragraph: edit$1(block.normal._paragraph).replace("hr", block.hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", block.lheading).replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").getRegex()
1471
1483
  });
@@ -1474,34 +1486,35 @@ const inline = {
1474
1486
  autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
1475
1487
  url: noopTest,
1476
1488
  tag: "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",
1477
- // CDATA section
1478
1489
  link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
1479
1490
  reflink: /^!?\[(label)\]\[(ref)\]/,
1480
1491
  nolink: /^!?\[(ref)\](?:\[\])?/,
1481
1492
  reflinkSearch: "reflink|nolink(?!\\()",
1482
1493
  emStrong: {
1483
- lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
1484
- // (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left. (5) and (6) can be either Left or Right.
1485
- // () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
1486
- rDelimAst: /^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,
1487
- rDelimUnd: /^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/
1494
+ lDelim: /^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,
1495
+ // (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left. (5) and (6) can be either Left or Right.
1496
+ // | Skip orphan inside strong | Consume to delim | (1) #*** | (2) a***#, a*** | (3) #***a, ***a | (4) ***# | (5) #***# | (6) a***a
1497
+ rDelimAst: /^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/,
1498
+ rDelimUnd: /^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/
1488
1499
  // ^- Not allowed for _
1489
1500
  },
1490
1501
  code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
1491
1502
  br: /^( {2,}|\\)\n(?!\s*$)/,
1492
1503
  del: noopTest,
1493
1504
  text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
1494
- punctuation: /^([\spunctuation])/
1505
+ punctuation: /^((?![*_])[\spunctuation])/
1495
1506
  };
1496
- inline._punctuation = "!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~";
1497
- inline.punctuation = edit$1(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex();
1498
- inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
1499
- inline.escapedEmSt = /(?:^|[^\\])(?:\\\\)*\\[*_]/g;
1507
+ inline._punctuation = "\\p{P}$+<=>`^|~";
1508
+ inline.punctuation = edit$1(inline.punctuation, "u").replace(/punctuation/g, inline._punctuation).getRegex();
1509
+ inline.blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
1510
+ inline.anyPunctuation = /\\[punct]/g;
1511
+ inline._escapes = /\\([punct])/g;
1500
1512
  inline._comment = edit$1(block._comment).replace("(?:-->|$)", "-->").getRegex();
1501
- inline.emStrong.lDelim = edit$1(inline.emStrong.lDelim).replace(/punct/g, inline._punctuation).getRegex();
1502
- inline.emStrong.rDelimAst = edit$1(inline.emStrong.rDelimAst, "g").replace(/punct/g, inline._punctuation).getRegex();
1503
- inline.emStrong.rDelimUnd = edit$1(inline.emStrong.rDelimUnd, "g").replace(/punct/g, inline._punctuation).getRegex();
1504
- inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
1513
+ inline.emStrong.lDelim = edit$1(inline.emStrong.lDelim, "u").replace(/punct/g, inline._punctuation).getRegex();
1514
+ inline.emStrong.rDelimAst = edit$1(inline.emStrong.rDelimAst, "gu").replace(/punct/g, inline._punctuation).getRegex();
1515
+ inline.emStrong.rDelimUnd = edit$1(inline.emStrong.rDelimUnd, "gu").replace(/punct/g, inline._punctuation).getRegex();
1516
+ inline.anyPunctuation = edit$1(inline.anyPunctuation, "gu").replace(/punct/g, inline._punctuation).getRegex();
1517
+ inline._escapes = edit$1(inline._escapes, "gu").replace(/punct/g, inline._punctuation).getRegex();
1505
1518
  inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
1506
1519
  inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
1507
1520
  inline.autolink = edit$1(inline.autolink).replace("scheme", inline._scheme).replace("email", inline._email).getRegex();
@@ -1548,23 +1561,24 @@ function smartypants(text) {
1548
1561
  return text.replace(/---/g, "—").replace(/--/g, "–").replace(/(^|[-\u2014/(\[{"\s])'/g, "$1‘").replace(/'/g, "’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1“").replace(/"/g, "”").replace(/\.{3}/g, "…");
1549
1562
  }
1550
1563
  function mangle(text) {
1551
- let out = "", i, ch;
1552
- const l = text.length;
1553
- for (i = 0; i < l; i++) {
1554
- ch = text.charCodeAt(i);
1555
- if (Math.random() > 0.5) {
1556
- ch = "x" + ch.toString(16);
1557
- }
1564
+ let out = "";
1565
+ for (let i = 0; i < text.length; i++) {
1566
+ const ch = Math.random() > 0.5 ? "x" + text.charCodeAt(i).toString(16) : text.charCodeAt(i).toString();
1558
1567
  out += "&#" + ch + ";";
1559
1568
  }
1560
1569
  return out;
1561
1570
  }
1562
- class Lexer {
1571
+ class _Lexer {
1563
1572
  constructor(options) {
1573
+ __publicField(this, "tokens");
1574
+ __publicField(this, "options");
1575
+ __publicField(this, "state");
1576
+ __publicField(this, "tokenizer");
1577
+ __publicField(this, "inlineQueue");
1564
1578
  this.tokens = [];
1565
1579
  this.tokens.links = /* @__PURE__ */ Object.create(null);
1566
- this.options = options || defaults$3;
1567
- this.options.tokenizer = this.options.tokenizer || new Tokenizer();
1580
+ this.options = options || _defaults;
1581
+ this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
1568
1582
  this.tokenizer = this.options.tokenizer;
1569
1583
  this.tokenizer.options = this.options;
1570
1584
  this.tokenizer.lexer = this;
@@ -1604,14 +1618,14 @@ class Lexer {
1604
1618
  * Static Lex Method
1605
1619
  */
1606
1620
  static lex(src, options) {
1607
- const lexer = new Lexer(options);
1621
+ const lexer = new _Lexer(options);
1608
1622
  return lexer.lex(src);
1609
1623
  }
1610
1624
  /**
1611
1625
  * Static Lex Inline Method
1612
1626
  */
1613
1627
  static lexInline(src, options) {
1614
- const lexer = new Lexer(options);
1628
+ const lexer = new _Lexer(options);
1615
1629
  return lexer.inlineTokens(src);
1616
1630
  }
1617
1631
  /**
@@ -1626,9 +1640,6 @@ class Lexer {
1626
1640
  }
1627
1641
  return this.tokens;
1628
1642
  }
1629
- /**
1630
- * Lexing
1631
- */
1632
1643
  blockTokens(src, tokens = []) {
1633
1644
  if (this.options.pedantic) {
1634
1645
  src = src.replace(/\t/g, " ").replace(/^ +$/gm, "");
@@ -1637,7 +1648,10 @@ class Lexer {
1637
1648
  return leading + " ".repeat(tabs.length);
1638
1649
  });
1639
1650
  }
1640
- let token, lastToken, cutSrc, lastParagraphClipped;
1651
+ let token;
1652
+ let lastToken;
1653
+ let cutSrc;
1654
+ let lastParagraphClipped;
1641
1655
  while (src) {
1642
1656
  if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
1643
1657
  if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
@@ -1730,7 +1744,7 @@ class Lexer {
1730
1744
  let startIndex = Infinity;
1731
1745
  const tempSrc = src.slice(1);
1732
1746
  let tempStart;
1733
- this.options.extensions.startBlock.forEach(function(getStartIndex) {
1747
+ this.options.extensions.startBlock.forEach((getStartIndex) => {
1734
1748
  tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1735
1749
  if (typeof tempStart === "number" && tempStart >= 0) {
1736
1750
  startIndex = Math.min(startIndex, tempStart);
@@ -1797,17 +1811,16 @@ class Lexer {
1797
1811
  if (links.length > 0) {
1798
1812
  while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
1799
1813
  if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
1800
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + repeatString("a", match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
1814
+ maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
1801
1815
  }
1802
1816
  }
1803
1817
  }
1804
1818
  }
1805
1819
  while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
1806
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + repeatString("a", match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1820
+ maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1807
1821
  }
1808
- while ((match = this.tokenizer.rules.inline.escapedEmSt.exec(maskedSrc)) != null) {
1809
- maskedSrc = maskedSrc.slice(0, match.index + match[0].length - 2) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);
1810
- this.tokenizer.rules.inline.escapedEmSt.lastIndex--;
1822
+ while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
1823
+ maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1811
1824
  }
1812
1825
  while (src) {
1813
1826
  if (!keepPrevChar) {
@@ -1891,7 +1904,7 @@ class Lexer {
1891
1904
  let startIndex = Infinity;
1892
1905
  const tempSrc = src.slice(1);
1893
1906
  let tempStart;
1894
- this.options.extensions.startInline.forEach(function(getStartIndex) {
1907
+ this.options.extensions.startInline.forEach((getStartIndex) => {
1895
1908
  tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1896
1909
  if (typeof tempStart === "number" && tempStart >= 0) {
1897
1910
  startIndex = Math.min(startIndex, tempStart);
@@ -1929,12 +1942,14 @@ class Lexer {
1929
1942
  return tokens;
1930
1943
  }
1931
1944
  }
1932
- class Renderer {
1945
+ class _Renderer {
1933
1946
  constructor(options) {
1934
- this.options = options || defaults$3;
1947
+ __publicField(this, "options");
1948
+ this.options = options || _defaults;
1935
1949
  }
1936
1950
  code(code, infostring, escaped) {
1937
- const lang = (infostring || "").match(/\S*/)[0];
1951
+ var _a;
1952
+ const lang = (_a = (infostring || "").match(/^\S*/)) == null ? void 0 : _a[0];
1938
1953
  if (this.options.highlight) {
1939
1954
  const out = this.options.highlight(code, lang);
1940
1955
  if (out != null && out !== code) {
@@ -1948,9 +1963,6 @@ class Renderer {
1948
1963
  }
1949
1964
  return '<pre><code class="' + this.options.langPrefix + escape(lang) + '">' + (escaped ? code : escape(code, true)) + "</code></pre>\n";
1950
1965
  }
1951
- /**
1952
- * @param {string} quote
1953
- */
1954
1966
  blockquote(quote) {
1955
1967
  return `<blockquote>
1956
1968
  ${quote}</blockquote>
@@ -1959,12 +1971,6 @@ ${quote}</blockquote>
1959
1971
  html(html, block2) {
1960
1972
  return html;
1961
1973
  }
1962
- /**
1963
- * @param {string} text
1964
- * @param {string} level
1965
- * @param {string} raw
1966
- * @param {any} slugger
1967
- */
1968
1974
  heading(text, level, raw, slugger) {
1969
1975
  if (this.options.headerIds) {
1970
1976
  const id = this.options.headerPrefix + slugger.slug(raw);
@@ -1978,38 +1984,26 @@ ${quote}</blockquote>
1978
1984
  return this.options.xhtml ? "<hr/>\n" : "<hr>\n";
1979
1985
  }
1980
1986
  list(body, ordered, start) {
1981
- const type = ordered ? "ol" : "ul", startatt = ordered && start !== 1 ? ' start="' + start + '"' : "";
1987
+ const type = ordered ? "ol" : "ul";
1988
+ const startatt = ordered && start !== 1 ? ' start="' + start + '"' : "";
1982
1989
  return "<" + type + startatt + ">\n" + body + "</" + type + ">\n";
1983
1990
  }
1984
- /**
1985
- * @param {string} text
1986
- */
1987
- listitem(text) {
1991
+ listitem(text, task, checked) {
1988
1992
  return `<li>${text}</li>
1989
1993
  `;
1990
1994
  }
1991
1995
  checkbox(checked) {
1992
1996
  return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox"' + (this.options.xhtml ? " /" : "") + "> ";
1993
1997
  }
1994
- /**
1995
- * @param {string} text
1996
- */
1997
1998
  paragraph(text) {
1998
1999
  return `<p>${text}</p>
1999
2000
  `;
2000
2001
  }
2001
- /**
2002
- * @param {string} header
2003
- * @param {string} body
2004
- */
2005
2002
  table(header2, body) {
2006
2003
  if (body)
2007
2004
  body = `<tbody>${body}</tbody>`;
2008
2005
  return "<table>\n<thead>\n" + header2 + "</thead>\n" + body + "</table>\n";
2009
2006
  }
2010
- /**
2011
- * @param {string} content
2012
- */
2013
2007
  tablerow(content) {
2014
2008
  return `<tr>
2015
2009
  ${content}</tr>
@@ -2023,42 +2017,28 @@ ${content}</tr>
2023
2017
  }
2024
2018
  /**
2025
2019
  * span level renderer
2026
- * @param {string} text
2027
2020
  */
2028
2021
  strong(text) {
2029
2022
  return `<strong>${text}</strong>`;
2030
2023
  }
2031
- /**
2032
- * @param {string} text
2033
- */
2034
2024
  em(text) {
2035
2025
  return `<em>${text}</em>`;
2036
2026
  }
2037
- /**
2038
- * @param {string} text
2039
- */
2040
2027
  codespan(text) {
2041
2028
  return `<code>${text}</code>`;
2042
2029
  }
2043
2030
  br() {
2044
2031
  return this.options.xhtml ? "<br/>" : "<br>";
2045
2032
  }
2046
- /**
2047
- * @param {string} text
2048
- */
2049
2033
  del(text) {
2050
2034
  return `<del>${text}</del>`;
2051
2035
  }
2052
- /**
2053
- * @param {string} href
2054
- * @param {string} title
2055
- * @param {string} text
2056
- */
2057
2036
  link(href, title, text) {
2058
- href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
2059
- if (href === null) {
2037
+ const cleanHref = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
2038
+ if (cleanHref === null) {
2060
2039
  return text;
2061
2040
  }
2041
+ href = cleanHref;
2062
2042
  let out = '<a href="' + href + '"';
2063
2043
  if (title) {
2064
2044
  out += ' title="' + title + '"';
@@ -2066,16 +2046,12 @@ ${content}</tr>
2066
2046
  out += ">" + text + "</a>";
2067
2047
  return out;
2068
2048
  }
2069
- /**
2070
- * @param {string} href
2071
- * @param {string} title
2072
- * @param {string} text
2073
- */
2074
2049
  image(href, title, text) {
2075
- href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
2076
- if (href === null) {
2050
+ const cleanHref = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
2051
+ if (cleanHref === null) {
2077
2052
  return text;
2078
2053
  }
2054
+ href = cleanHref;
2079
2055
  let out = `<img src="${href}" alt="${text}"`;
2080
2056
  if (title) {
2081
2057
  out += ` title="${title}"`;
@@ -2087,7 +2063,7 @@ ${content}</tr>
2087
2063
  return text;
2088
2064
  }
2089
2065
  }
2090
- class TextRenderer {
2066
+ class _TextRenderer {
2091
2067
  // no need for block level renderers
2092
2068
  strong(text) {
2093
2069
  return text;
@@ -2117,20 +2093,16 @@ class TextRenderer {
2117
2093
  return "";
2118
2094
  }
2119
2095
  }
2120
- class Slugger {
2096
+ class _Slugger {
2121
2097
  constructor() {
2098
+ __publicField(this, "seen");
2122
2099
  this.seen = {};
2123
2100
  }
2124
- /**
2125
- * @param {string} value
2126
- */
2127
2101
  serialize(value) {
2128
2102
  return value.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig, "").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "").replace(/\s/g, "-");
2129
2103
  }
2130
2104
  /**
2131
2105
  * Finds the next safe (unique) slug to use
2132
- * @param {string} originalSlug
2133
- * @param {boolean} isDryRun
2134
2106
  */
2135
2107
  getNextSafeSlug(originalSlug, isDryRun) {
2136
2108
  let slug = originalSlug;
@@ -2150,49 +2122,50 @@ class Slugger {
2150
2122
  }
2151
2123
  /**
2152
2124
  * Convert string to unique id
2153
- * @param {object} [options]
2154
- * @param {boolean} [options.dryrun] Generates the next unique slug without
2155
- * updating the internal accumulator.
2156
2125
  */
2157
2126
  slug(value, options = {}) {
2158
2127
  const slug = this.serialize(value);
2159
2128
  return this.getNextSafeSlug(slug, options.dryrun);
2160
2129
  }
2161
2130
  }
2162
- class Parser {
2131
+ class _Parser {
2163
2132
  constructor(options) {
2164
- this.options = options || defaults$3;
2165
- this.options.renderer = this.options.renderer || new Renderer();
2133
+ __publicField(this, "options");
2134
+ __publicField(this, "renderer");
2135
+ __publicField(this, "textRenderer");
2136
+ __publicField(this, "slugger");
2137
+ this.options = options || _defaults;
2138
+ this.options.renderer = this.options.renderer || new _Renderer();
2166
2139
  this.renderer = this.options.renderer;
2167
2140
  this.renderer.options = this.options;
2168
- this.textRenderer = new TextRenderer();
2169
- this.slugger = new Slugger();
2141
+ this.textRenderer = new _TextRenderer();
2142
+ this.slugger = new _Slugger();
2170
2143
  }
2171
2144
  /**
2172
2145
  * Static Parse Method
2173
2146
  */
2174
2147
  static parse(tokens, options) {
2175
- const parser2 = new Parser(options);
2148
+ const parser2 = new _Parser(options);
2176
2149
  return parser2.parse(tokens);
2177
2150
  }
2178
2151
  /**
2179
2152
  * Static Parse Inline Method
2180
2153
  */
2181
2154
  static parseInline(tokens, options) {
2182
- const parser2 = new Parser(options);
2155
+ const parser2 = new _Parser(options);
2183
2156
  return parser2.parseInline(tokens);
2184
2157
  }
2185
2158
  /**
2186
2159
  * Parse Loop
2187
2160
  */
2188
2161
  parse(tokens, top = true) {
2189
- let out = "", i, j, k, l2, l3, row, cell, header2, body, token, ordered, start, loose, itemBody, item, checked, task, checkbox, ret;
2190
- const l = tokens.length;
2191
- for (i = 0; i < l; i++) {
2192
- token = tokens[i];
2162
+ let out = "";
2163
+ for (let i = 0; i < tokens.length; i++) {
2164
+ const token = tokens[i];
2193
2165
  if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
2194
- ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
2195
- if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(token.type)) {
2166
+ const genericToken = token;
2167
+ const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
2168
+ if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
2196
2169
  out += ret || "";
2197
2170
  continue;
2198
2171
  }
@@ -2206,44 +2179,29 @@ class Parser {
2206
2179
  continue;
2207
2180
  }
2208
2181
  case "heading": {
2209
- out += this.renderer.heading(
2210
- this.parseInline(token.tokens),
2211
- token.depth,
2212
- unescape(this.parseInline(token.tokens, this.textRenderer)),
2213
- this.slugger
2214
- );
2182
+ const headingToken = token;
2183
+ out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape(this.parseInline(headingToken.tokens, this.textRenderer)), this.slugger);
2215
2184
  continue;
2216
2185
  }
2217
2186
  case "code": {
2218
- out += this.renderer.code(
2219
- token.text,
2220
- token.lang,
2221
- token.escaped
2222
- );
2187
+ const codeToken = token;
2188
+ out += this.renderer.code(codeToken.text, codeToken.lang, !!codeToken.escaped);
2223
2189
  continue;
2224
2190
  }
2225
2191
  case "table": {
2226
- header2 = "";
2227
- cell = "";
2228
- l2 = token.header.length;
2229
- for (j = 0; j < l2; j++) {
2230
- cell += this.renderer.tablecell(
2231
- this.parseInline(token.header[j].tokens),
2232
- { header: true, align: token.align[j] }
2233
- );
2192
+ const tableToken = token;
2193
+ let header2 = "";
2194
+ let cell = "";
2195
+ for (let j = 0; j < tableToken.header.length; j++) {
2196
+ cell += this.renderer.tablecell(this.parseInline(tableToken.header[j].tokens), { header: true, align: tableToken.align[j] });
2234
2197
  }
2235
2198
  header2 += this.renderer.tablerow(cell);
2236
- body = "";
2237
- l2 = token.rows.length;
2238
- for (j = 0; j < l2; j++) {
2239
- row = token.rows[j];
2199
+ let body = "";
2200
+ for (let j = 0; j < tableToken.rows.length; j++) {
2201
+ const row = tableToken.rows[j];
2240
2202
  cell = "";
2241
- l3 = row.length;
2242
- for (k = 0; k < l3; k++) {
2243
- cell += this.renderer.tablecell(
2244
- this.parseInline(row[k].tokens),
2245
- { header: false, align: token.align[k] }
2246
- );
2203
+ for (let k = 0; k < row.length; k++) {
2204
+ cell += this.renderer.tablecell(this.parseInline(row[k].tokens), { header: false, align: tableToken.align[k] });
2247
2205
  }
2248
2206
  body += this.renderer.tablerow(cell);
2249
2207
  }
@@ -2251,23 +2209,24 @@ class Parser {
2251
2209
  continue;
2252
2210
  }
2253
2211
  case "blockquote": {
2254
- body = this.parse(token.tokens);
2212
+ const blockquoteToken = token;
2213
+ const body = this.parse(blockquoteToken.tokens);
2255
2214
  out += this.renderer.blockquote(body);
2256
2215
  continue;
2257
2216
  }
2258
2217
  case "list": {
2259
- ordered = token.ordered;
2260
- start = token.start;
2261
- loose = token.loose;
2262
- l2 = token.items.length;
2263
- body = "";
2264
- for (j = 0; j < l2; j++) {
2265
- item = token.items[j];
2266
- checked = item.checked;
2267
- task = item.task;
2268
- itemBody = "";
2218
+ const listToken = token;
2219
+ const ordered = listToken.ordered;
2220
+ const start = listToken.start;
2221
+ const loose = listToken.loose;
2222
+ let body = "";
2223
+ for (let j = 0; j < listToken.items.length; j++) {
2224
+ const item = listToken.items[j];
2225
+ const checked = item.checked;
2226
+ const task = item.task;
2227
+ let itemBody = "";
2269
2228
  if (item.task) {
2270
- checkbox = this.renderer.checkbox(checked);
2229
+ const checkbox = this.renderer.checkbox(!!checked);
2271
2230
  if (loose) {
2272
2231
  if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
2273
2232
  item.tokens[0].text = checkbox + " " + item.tokens[0].text;
@@ -2285,24 +2244,27 @@ class Parser {
2285
2244
  }
2286
2245
  }
2287
2246
  itemBody += this.parse(item.tokens, loose);
2288
- body += this.renderer.listitem(itemBody, task, checked);
2247
+ body += this.renderer.listitem(itemBody, task, !!checked);
2289
2248
  }
2290
2249
  out += this.renderer.list(body, ordered, start);
2291
2250
  continue;
2292
2251
  }
2293
2252
  case "html": {
2294
- out += this.renderer.html(token.text, token.block);
2253
+ const htmlToken = token;
2254
+ out += this.renderer.html(htmlToken.text, htmlToken.block);
2295
2255
  continue;
2296
2256
  }
2297
2257
  case "paragraph": {
2298
- out += this.renderer.paragraph(this.parseInline(token.tokens));
2258
+ const paragraphToken = token;
2259
+ out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens));
2299
2260
  continue;
2300
2261
  }
2301
2262
  case "text": {
2302
- body = token.tokens ? this.parseInline(token.tokens) : token.text;
2303
- while (i + 1 < l && tokens[i + 1].type === "text") {
2304
- token = tokens[++i];
2305
- body += "\n" + (token.tokens ? this.parseInline(token.tokens) : token.text);
2263
+ let textToken = token;
2264
+ let body = textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text;
2265
+ while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
2266
+ textToken = tokens[++i];
2267
+ body += "\n" + (textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text);
2306
2268
  }
2307
2269
  out += top ? this.renderer.paragraph(body) : body;
2308
2270
  continue;
@@ -2311,7 +2273,7 @@ class Parser {
2311
2273
  const errMsg = 'Token with "' + token.type + '" type was not found.';
2312
2274
  if (this.options.silent) {
2313
2275
  console.error(errMsg);
2314
- return;
2276
+ return "";
2315
2277
  } else {
2316
2278
  throw new Error(errMsg);
2317
2279
  }
@@ -2325,12 +2287,11 @@ class Parser {
2325
2287
  */
2326
2288
  parseInline(tokens, renderer) {
2327
2289
  renderer = renderer || this.renderer;
2328
- let out = "", i, token, ret;
2329
- const l = tokens.length;
2330
- for (i = 0; i < l; i++) {
2331
- token = tokens[i];
2290
+ let out = "";
2291
+ for (let i = 0; i < tokens.length; i++) {
2292
+ const token = tokens[i];
2332
2293
  if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
2333
- ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
2294
+ const ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
2334
2295
  if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) {
2335
2296
  out += ret || "";
2336
2297
  continue;
@@ -2338,31 +2299,38 @@ class Parser {
2338
2299
  }
2339
2300
  switch (token.type) {
2340
2301
  case "escape": {
2341
- out += renderer.text(token.text);
2302
+ const escapeToken = token;
2303
+ out += renderer.text(escapeToken.text);
2342
2304
  break;
2343
2305
  }
2344
2306
  case "html": {
2345
- out += renderer.html(token.text);
2307
+ const tagToken = token;
2308
+ out += renderer.html(tagToken.text);
2346
2309
  break;
2347
2310
  }
2348
2311
  case "link": {
2349
- out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
2312
+ const linkToken = token;
2313
+ out += renderer.link(linkToken.href, linkToken.title, this.parseInline(linkToken.tokens, renderer));
2350
2314
  break;
2351
2315
  }
2352
2316
  case "image": {
2353
- out += renderer.image(token.href, token.title, token.text);
2317
+ const imageToken = token;
2318
+ out += renderer.image(imageToken.href, imageToken.title, imageToken.text);
2354
2319
  break;
2355
2320
  }
2356
2321
  case "strong": {
2357
- out += renderer.strong(this.parseInline(token.tokens, renderer));
2322
+ const strongToken = token;
2323
+ out += renderer.strong(this.parseInline(strongToken.tokens, renderer));
2358
2324
  break;
2359
2325
  }
2360
2326
  case "em": {
2361
- out += renderer.em(this.parseInline(token.tokens, renderer));
2327
+ const emToken = token;
2328
+ out += renderer.em(this.parseInline(emToken.tokens, renderer));
2362
2329
  break;
2363
2330
  }
2364
2331
  case "codespan": {
2365
- out += renderer.codespan(token.text);
2332
+ const codespanToken = token;
2333
+ out += renderer.codespan(codespanToken.text);
2366
2334
  break;
2367
2335
  }
2368
2336
  case "br": {
@@ -2370,18 +2338,20 @@ class Parser {
2370
2338
  break;
2371
2339
  }
2372
2340
  case "del": {
2373
- out += renderer.del(this.parseInline(token.tokens, renderer));
2341
+ const delToken = token;
2342
+ out += renderer.del(this.parseInline(delToken.tokens, renderer));
2374
2343
  break;
2375
2344
  }
2376
2345
  case "text": {
2377
- out += renderer.text(token.text);
2346
+ const textToken = token;
2347
+ out += renderer.text(textToken.text);
2378
2348
  break;
2379
2349
  }
2380
2350
  default: {
2381
2351
  const errMsg = 'Token with "' + token.type + '" type was not found.';
2382
2352
  if (this.options.silent) {
2383
2353
  console.error(errMsg);
2384
- return;
2354
+ return "";
2385
2355
  } else {
2386
2356
  throw new Error(errMsg);
2387
2357
  }
@@ -2391,9 +2361,10 @@ class Parser {
2391
2361
  return out;
2392
2362
  }
2393
2363
  }
2394
- class Hooks {
2364
+ class _Hooks {
2395
2365
  constructor(options) {
2396
- this.options = options || defaults$3;
2366
+ __publicField(this, "options");
2367
+ this.options = options || _defaults;
2397
2368
  }
2398
2369
  /**
2399
2370
  * Process markdown before marked
@@ -2408,43 +2379,222 @@ class Hooks {
2408
2379
  return html;
2409
2380
  }
2410
2381
  }
2411
- __publicField(Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
2382
+ __publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
2412
2383
  "preprocess",
2413
2384
  "postprocess"
2414
2385
  ]));
2415
- function onError(silent, async, callback) {
2416
- return (e) => {
2417
- e.message += "\nPlease report this to https://github.com/markedjs/marked.";
2418
- if (silent) {
2419
- const msg = "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
2420
- if (async) {
2421
- return Promise.resolve(msg);
2422
- }
2423
- if (callback) {
2424
- callback(null, msg);
2425
- return;
2386
+ class Marked {
2387
+ constructor(...args) {
2388
+ __privateAdd(this, _parseMarkdown);
2389
+ __privateAdd(this, _onError);
2390
+ __publicField(this, "defaults", _getDefaults());
2391
+ __publicField(this, "options", this.setOptions);
2392
+ __publicField(this, "parse", __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lex, _Parser.parse));
2393
+ __publicField(this, "parseInline", __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lexInline, _Parser.parseInline));
2394
+ __publicField(this, "Parser", _Parser);
2395
+ __publicField(this, "parser", _Parser.parse);
2396
+ __publicField(this, "Renderer", _Renderer);
2397
+ __publicField(this, "TextRenderer", _TextRenderer);
2398
+ __publicField(this, "Lexer", _Lexer);
2399
+ __publicField(this, "lexer", _Lexer.lex);
2400
+ __publicField(this, "Tokenizer", _Tokenizer);
2401
+ __publicField(this, "Slugger", _Slugger);
2402
+ __publicField(this, "Hooks", _Hooks);
2403
+ this.use(...args);
2404
+ }
2405
+ /**
2406
+ * Run callback for every token
2407
+ */
2408
+ walkTokens(tokens, callback) {
2409
+ var _a, _b;
2410
+ let values = [];
2411
+ for (const token of tokens) {
2412
+ values = values.concat(callback.call(this, token));
2413
+ switch (token.type) {
2414
+ case "table": {
2415
+ const tableToken = token;
2416
+ for (const cell of tableToken.header) {
2417
+ values = values.concat(this.walkTokens(cell.tokens, callback));
2418
+ }
2419
+ for (const row of tableToken.rows) {
2420
+ for (const cell of row) {
2421
+ values = values.concat(this.walkTokens(cell.tokens, callback));
2422
+ }
2423
+ }
2424
+ break;
2425
+ }
2426
+ case "list": {
2427
+ const listToken = token;
2428
+ values = values.concat(this.walkTokens(listToken.items, callback));
2429
+ break;
2430
+ }
2431
+ default: {
2432
+ const genericToken = token;
2433
+ if ((_b = (_a = this.defaults.extensions) == null ? void 0 : _a.childTokens) == null ? void 0 : _b[genericToken.type]) {
2434
+ this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
2435
+ values = values.concat(this.walkTokens(genericToken[childTokens], callback));
2436
+ });
2437
+ } else if (genericToken.tokens) {
2438
+ values = values.concat(this.walkTokens(genericToken.tokens, callback));
2439
+ }
2440
+ }
2426
2441
  }
2427
- return msg;
2428
- }
2429
- if (async) {
2430
- return Promise.reject(e);
2431
2442
  }
2432
- if (callback) {
2433
- callback(e);
2434
- return;
2435
- }
2436
- throw e;
2437
- };
2443
+ return values;
2444
+ }
2445
+ use(...args) {
2446
+ const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
2447
+ args.forEach((pack) => {
2448
+ const opts = __spreadValues({}, pack);
2449
+ opts.async = this.defaults.async || opts.async || false;
2450
+ if (pack.extensions) {
2451
+ pack.extensions.forEach((ext) => {
2452
+ if (!ext.name) {
2453
+ throw new Error("extension name required");
2454
+ }
2455
+ if ("renderer" in ext) {
2456
+ const prevRenderer = extensions.renderers[ext.name];
2457
+ if (prevRenderer) {
2458
+ extensions.renderers[ext.name] = function(...args2) {
2459
+ let ret = ext.renderer.apply(this, args2);
2460
+ if (ret === false) {
2461
+ ret = prevRenderer.apply(this, args2);
2462
+ }
2463
+ return ret;
2464
+ };
2465
+ } else {
2466
+ extensions.renderers[ext.name] = ext.renderer;
2467
+ }
2468
+ }
2469
+ if ("tokenizer" in ext) {
2470
+ if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
2471
+ throw new Error("extension level must be 'block' or 'inline'");
2472
+ }
2473
+ const extLevel = extensions[ext.level];
2474
+ if (extLevel) {
2475
+ extLevel.unshift(ext.tokenizer);
2476
+ } else {
2477
+ extensions[ext.level] = [ext.tokenizer];
2478
+ }
2479
+ if (ext.start) {
2480
+ if (ext.level === "block") {
2481
+ if (extensions.startBlock) {
2482
+ extensions.startBlock.push(ext.start);
2483
+ } else {
2484
+ extensions.startBlock = [ext.start];
2485
+ }
2486
+ } else if (ext.level === "inline") {
2487
+ if (extensions.startInline) {
2488
+ extensions.startInline.push(ext.start);
2489
+ } else {
2490
+ extensions.startInline = [ext.start];
2491
+ }
2492
+ }
2493
+ }
2494
+ }
2495
+ if ("childTokens" in ext && ext.childTokens) {
2496
+ extensions.childTokens[ext.name] = ext.childTokens;
2497
+ }
2498
+ });
2499
+ opts.extensions = extensions;
2500
+ }
2501
+ if (pack.renderer) {
2502
+ const renderer = this.defaults.renderer || new _Renderer(this.defaults);
2503
+ for (const prop in pack.renderer) {
2504
+ const rendererFunc = pack.renderer[prop];
2505
+ const rendererKey = prop;
2506
+ const prevRenderer = renderer[rendererKey];
2507
+ renderer[rendererKey] = (...args2) => {
2508
+ let ret = rendererFunc.apply(renderer, args2);
2509
+ if (ret === false) {
2510
+ ret = prevRenderer.apply(renderer, args2);
2511
+ }
2512
+ return ret || "";
2513
+ };
2514
+ }
2515
+ opts.renderer = renderer;
2516
+ }
2517
+ if (pack.tokenizer) {
2518
+ const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
2519
+ for (const prop in pack.tokenizer) {
2520
+ const tokenizerFunc = pack.tokenizer[prop];
2521
+ const tokenizerKey = prop;
2522
+ const prevTokenizer = tokenizer[tokenizerKey];
2523
+ tokenizer[tokenizerKey] = (...args2) => {
2524
+ let ret = tokenizerFunc.apply(tokenizer, args2);
2525
+ if (ret === false) {
2526
+ ret = prevTokenizer.apply(tokenizer, args2);
2527
+ }
2528
+ return ret;
2529
+ };
2530
+ }
2531
+ opts.tokenizer = tokenizer;
2532
+ }
2533
+ if (pack.hooks) {
2534
+ const hooks = this.defaults.hooks || new _Hooks();
2535
+ for (const prop in pack.hooks) {
2536
+ const hooksFunc = pack.hooks[prop];
2537
+ const hooksKey = prop;
2538
+ const prevHook = hooks[hooksKey];
2539
+ if (_Hooks.passThroughHooks.has(prop)) {
2540
+ hooks[hooksKey] = (arg) => {
2541
+ if (this.defaults.async) {
2542
+ return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
2543
+ return prevHook.call(hooks, ret2);
2544
+ });
2545
+ }
2546
+ const ret = hooksFunc.call(hooks, arg);
2547
+ return prevHook.call(hooks, ret);
2548
+ };
2549
+ } else {
2550
+ hooks[hooksKey] = (...args2) => {
2551
+ let ret = hooksFunc.apply(hooks, args2);
2552
+ if (ret === false) {
2553
+ ret = prevHook.apply(hooks, args2);
2554
+ }
2555
+ return ret;
2556
+ };
2557
+ }
2558
+ }
2559
+ opts.hooks = hooks;
2560
+ }
2561
+ if (pack.walkTokens) {
2562
+ const walkTokens = this.defaults.walkTokens;
2563
+ const packWalktokens = pack.walkTokens;
2564
+ opts.walkTokens = function(token) {
2565
+ let values = [];
2566
+ values.push(packWalktokens.call(this, token));
2567
+ if (walkTokens) {
2568
+ values = values.concat(walkTokens.call(this, token));
2569
+ }
2570
+ return values;
2571
+ };
2572
+ }
2573
+ this.defaults = __spreadValues(__spreadValues({}, this.defaults), opts);
2574
+ });
2575
+ return this;
2576
+ }
2577
+ setOptions(opt) {
2578
+ this.defaults = __spreadValues(__spreadValues({}, this.defaults), opt);
2579
+ return this;
2580
+ }
2438
2581
  }
2439
- function parseMarkdown(lexer, parser2) {
2440
- return (src, opt, callback) => {
2441
- if (typeof opt === "function") {
2442
- callback = opt;
2443
- opt = null;
2582
+ _parseMarkdown = new WeakSet();
2583
+ parseMarkdown_fn = function(lexer, parser2) {
2584
+ return (src, optOrCallback, callback) => {
2585
+ if (typeof optOrCallback === "function") {
2586
+ callback = optOrCallback;
2587
+ optOrCallback = null;
2588
+ }
2589
+ const origOpt = __spreadValues({}, optOrCallback);
2590
+ const opt = __spreadValues(__spreadValues({}, this.defaults), origOpt);
2591
+ if (this.defaults.async === true && origOpt.async === false) {
2592
+ if (!opt.silent) {
2593
+ console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.");
2594
+ }
2595
+ opt.async = true;
2444
2596
  }
2445
- const origOpt = __spreadValues({}, opt);
2446
- opt = __spreadValues(__spreadValues({}, marked$1.defaults), origOpt);
2447
- const throwError = onError(opt.silent, opt.async, callback);
2597
+ const throwError = __privateMethod(this, _onError, onError_fn).call(this, !!opt.silent, !!opt.async, callback);
2448
2598
  if (typeof src === "undefined" || src === null) {
2449
2599
  return throwError(new Error("marked(): input parameter is undefined or null"));
2450
2600
  }
@@ -2456,6 +2606,7 @@ function parseMarkdown(lexer, parser2) {
2456
2606
  opt.hooks.options = opt;
2457
2607
  }
2458
2608
  if (callback) {
2609
+ const resultCallback = callback;
2459
2610
  const highlight = opt.highlight;
2460
2611
  let tokens;
2461
2612
  try {
@@ -2466,12 +2617,12 @@ function parseMarkdown(lexer, parser2) {
2466
2617
  } catch (e) {
2467
2618
  return throwError(e);
2468
2619
  }
2469
- const done = function(err) {
2620
+ const done = (err) => {
2470
2621
  let out;
2471
2622
  if (!err) {
2472
2623
  try {
2473
2624
  if (opt.walkTokens) {
2474
- marked$1.walkTokens(tokens, opt.walkTokens);
2625
+ this.walkTokens(tokens, opt.walkTokens);
2475
2626
  }
2476
2627
  out = parser2(tokens, opt);
2477
2628
  if (opt.hooks) {
@@ -2482,7 +2633,7 @@ function parseMarkdown(lexer, parser2) {
2482
2633
  }
2483
2634
  }
2484
2635
  opt.highlight = highlight;
2485
- return err ? throwError(err) : callback(null, out);
2636
+ return err ? throwError(err) : resultCallback(null, out);
2486
2637
  };
2487
2638
  if (!highlight || highlight.length < 3) {
2488
2639
  return done();
@@ -2491,11 +2642,11 @@ function parseMarkdown(lexer, parser2) {
2491
2642
  if (!tokens.length)
2492
2643
  return done();
2493
2644
  let pending = 0;
2494
- marked$1.walkTokens(tokens, function(token) {
2645
+ this.walkTokens(tokens, (token) => {
2495
2646
  if (token.type === "code") {
2496
2647
  pending++;
2497
2648
  setTimeout(() => {
2498
- highlight(token.text, token.lang, function(err, code) {
2649
+ highlight(token.text, token.lang, (err, code) => {
2499
2650
  if (err) {
2500
2651
  return done(err);
2501
2652
  }
@@ -2517,7 +2668,7 @@ function parseMarkdown(lexer, parser2) {
2517
2668
  return;
2518
2669
  }
2519
2670
  if (opt.async) {
2520
- return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer(src2, opt)).then((tokens) => opt.walkTokens ? Promise.all(marked$1.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html) => opt.hooks ? opt.hooks.postprocess(html) : html).catch(throwError);
2671
+ return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer(src2, opt)).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html) => opt.hooks ? opt.hooks.postprocess(html) : html).catch(throwError);
2521
2672
  }
2522
2673
  try {
2523
2674
  if (opt.hooks) {
@@ -2525,7 +2676,7 @@ function parseMarkdown(lexer, parser2) {
2525
2676
  }
2526
2677
  const tokens = lexer(src, opt);
2527
2678
  if (opt.walkTokens) {
2528
- marked$1.walkTokens(tokens, opt.walkTokens);
2679
+ this.walkTokens(tokens, opt.walkTokens);
2529
2680
  }
2530
2681
  let html = parser2(tokens, opt);
2531
2682
  if (opt.hooks) {
@@ -2536,191 +2687,71 @@ function parseMarkdown(lexer, parser2) {
2536
2687
  return throwError(e);
2537
2688
  }
2538
2689
  };
2539
- }
2690
+ };
2691
+ _onError = new WeakSet();
2692
+ onError_fn = function(silent, async, callback) {
2693
+ return (e) => {
2694
+ e.message += "\nPlease report this to https://github.com/markedjs/marked.";
2695
+ if (silent) {
2696
+ const msg = "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
2697
+ if (async) {
2698
+ return Promise.resolve(msg);
2699
+ }
2700
+ if (callback) {
2701
+ callback(null, msg);
2702
+ return;
2703
+ }
2704
+ return msg;
2705
+ }
2706
+ if (async) {
2707
+ return Promise.reject(e);
2708
+ }
2709
+ if (callback) {
2710
+ callback(e);
2711
+ return;
2712
+ }
2713
+ throw e;
2714
+ };
2715
+ };
2716
+ const markedInstance = new Marked();
2540
2717
  function marked$1(src, opt, callback) {
2541
- return parseMarkdown(Lexer.lex, Parser.parse)(src, opt, callback);
2718
+ return markedInstance.parse(src, opt, callback);
2542
2719
  }
2543
- marked$1.options = marked$1.setOptions = function(opt) {
2544
- marked$1.defaults = __spreadValues(__spreadValues({}, marked$1.defaults), opt);
2720
+ marked$1.options = marked$1.setOptions = function(options) {
2721
+ markedInstance.setOptions(options);
2722
+ marked$1.defaults = markedInstance.defaults;
2545
2723
  changeDefaults(marked$1.defaults);
2546
2724
  return marked$1;
2547
2725
  };
2548
- marked$1.getDefaults = getDefaults;
2549
- marked$1.defaults = defaults$3;
2726
+ marked$1.getDefaults = _getDefaults;
2727
+ marked$1.defaults = _defaults;
2550
2728
  marked$1.use = function(...args) {
2551
- const extensions = marked$1.defaults.extensions || { renderers: {}, childTokens: {} };
2552
- args.forEach((pack) => {
2553
- const opts = __spreadValues({}, pack);
2554
- opts.async = marked$1.defaults.async || opts.async || false;
2555
- if (pack.extensions) {
2556
- pack.extensions.forEach((ext) => {
2557
- if (!ext.name) {
2558
- throw new Error("extension name required");
2559
- }
2560
- if (ext.renderer) {
2561
- const prevRenderer = extensions.renderers[ext.name];
2562
- if (prevRenderer) {
2563
- extensions.renderers[ext.name] = function(...args2) {
2564
- let ret = ext.renderer.apply(this, args2);
2565
- if (ret === false) {
2566
- ret = prevRenderer.apply(this, args2);
2567
- }
2568
- return ret;
2569
- };
2570
- } else {
2571
- extensions.renderers[ext.name] = ext.renderer;
2572
- }
2573
- }
2574
- if (ext.tokenizer) {
2575
- if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
2576
- throw new Error("extension level must be 'block' or 'inline'");
2577
- }
2578
- if (extensions[ext.level]) {
2579
- extensions[ext.level].unshift(ext.tokenizer);
2580
- } else {
2581
- extensions[ext.level] = [ext.tokenizer];
2582
- }
2583
- if (ext.start) {
2584
- if (ext.level === "block") {
2585
- if (extensions.startBlock) {
2586
- extensions.startBlock.push(ext.start);
2587
- } else {
2588
- extensions.startBlock = [ext.start];
2589
- }
2590
- } else if (ext.level === "inline") {
2591
- if (extensions.startInline) {
2592
- extensions.startInline.push(ext.start);
2593
- } else {
2594
- extensions.startInline = [ext.start];
2595
- }
2596
- }
2597
- }
2598
- }
2599
- if (ext.childTokens) {
2600
- extensions.childTokens[ext.name] = ext.childTokens;
2601
- }
2602
- });
2603
- opts.extensions = extensions;
2604
- }
2605
- if (pack.renderer) {
2606
- const renderer = marked$1.defaults.renderer || new Renderer();
2607
- for (const prop in pack.renderer) {
2608
- const prevRenderer = renderer[prop];
2609
- renderer[prop] = (...args2) => {
2610
- let ret = pack.renderer[prop].apply(renderer, args2);
2611
- if (ret === false) {
2612
- ret = prevRenderer.apply(renderer, args2);
2613
- }
2614
- return ret;
2615
- };
2616
- }
2617
- opts.renderer = renderer;
2618
- }
2619
- if (pack.tokenizer) {
2620
- const tokenizer = marked$1.defaults.tokenizer || new Tokenizer();
2621
- for (const prop in pack.tokenizer) {
2622
- const prevTokenizer = tokenizer[prop];
2623
- tokenizer[prop] = (...args2) => {
2624
- let ret = pack.tokenizer[prop].apply(tokenizer, args2);
2625
- if (ret === false) {
2626
- ret = prevTokenizer.apply(tokenizer, args2);
2627
- }
2628
- return ret;
2629
- };
2630
- }
2631
- opts.tokenizer = tokenizer;
2632
- }
2633
- if (pack.hooks) {
2634
- const hooks = marked$1.defaults.hooks || new Hooks();
2635
- for (const prop in pack.hooks) {
2636
- const prevHook = hooks[prop];
2637
- if (Hooks.passThroughHooks.has(prop)) {
2638
- hooks[prop] = (arg) => {
2639
- if (marked$1.defaults.async) {
2640
- return Promise.resolve(pack.hooks[prop].call(hooks, arg)).then((ret2) => {
2641
- return prevHook.call(hooks, ret2);
2642
- });
2643
- }
2644
- const ret = pack.hooks[prop].call(hooks, arg);
2645
- return prevHook.call(hooks, ret);
2646
- };
2647
- } else {
2648
- hooks[prop] = (...args2) => {
2649
- let ret = pack.hooks[prop].apply(hooks, args2);
2650
- if (ret === false) {
2651
- ret = prevHook.apply(hooks, args2);
2652
- }
2653
- return ret;
2654
- };
2655
- }
2656
- }
2657
- opts.hooks = hooks;
2658
- }
2659
- if (pack.walkTokens) {
2660
- const walkTokens = marked$1.defaults.walkTokens;
2661
- opts.walkTokens = function(token) {
2662
- let values = [];
2663
- values.push(pack.walkTokens.call(this, token));
2664
- if (walkTokens) {
2665
- values = values.concat(walkTokens.call(this, token));
2666
- }
2667
- return values;
2668
- };
2669
- }
2670
- marked$1.setOptions(opts);
2671
- });
2729
+ markedInstance.use(...args);
2730
+ marked$1.defaults = markedInstance.defaults;
2731
+ changeDefaults(marked$1.defaults);
2732
+ return marked$1;
2672
2733
  };
2673
2734
  marked$1.walkTokens = function(tokens, callback) {
2674
- let values = [];
2675
- for (const token of tokens) {
2676
- values = values.concat(callback.call(marked$1, token));
2677
- switch (token.type) {
2678
- case "table": {
2679
- for (const cell of token.header) {
2680
- values = values.concat(marked$1.walkTokens(cell.tokens, callback));
2681
- }
2682
- for (const row of token.rows) {
2683
- for (const cell of row) {
2684
- values = values.concat(marked$1.walkTokens(cell.tokens, callback));
2685
- }
2686
- }
2687
- break;
2688
- }
2689
- case "list": {
2690
- values = values.concat(marked$1.walkTokens(token.items, callback));
2691
- break;
2692
- }
2693
- default: {
2694
- if (marked$1.defaults.extensions && marked$1.defaults.extensions.childTokens && marked$1.defaults.extensions.childTokens[token.type]) {
2695
- marked$1.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
2696
- values = values.concat(marked$1.walkTokens(token[childTokens], callback));
2697
- });
2698
- } else if (token.tokens) {
2699
- values = values.concat(marked$1.walkTokens(token.tokens, callback));
2700
- }
2701
- }
2702
- }
2703
- }
2704
- return values;
2735
+ return markedInstance.walkTokens(tokens, callback);
2705
2736
  };
2706
- marked$1.parseInline = parseMarkdown(Lexer.lexInline, Parser.parseInline);
2707
- marked$1.Parser = Parser;
2708
- marked$1.parser = Parser.parse;
2709
- marked$1.Renderer = Renderer;
2710
- marked$1.TextRenderer = TextRenderer;
2711
- marked$1.Lexer = Lexer;
2712
- marked$1.lexer = Lexer.lex;
2713
- marked$1.Tokenizer = Tokenizer;
2714
- marked$1.Slugger = Slugger;
2715
- marked$1.Hooks = Hooks;
2737
+ marked$1.parseInline = markedInstance.parseInline;
2738
+ marked$1.Parser = _Parser;
2739
+ marked$1.parser = _Parser.parse;
2740
+ marked$1.Renderer = _Renderer;
2741
+ marked$1.TextRenderer = _TextRenderer;
2742
+ marked$1.Lexer = _Lexer;
2743
+ marked$1.lexer = _Lexer.lex;
2744
+ marked$1.Tokenizer = _Tokenizer;
2745
+ marked$1.Slugger = _Slugger;
2746
+ marked$1.Hooks = _Hooks;
2716
2747
  marked$1.parse = marked$1;
2717
2748
  marked$1.options;
2718
2749
  marked$1.setOptions;
2719
2750
  marked$1.use;
2720
2751
  marked$1.walkTokens;
2721
2752
  marked$1.parseInline;
2722
- Parser.parse;
2723
- Lexer.lex;
2753
+ _Parser.parse;
2754
+ _Lexer.lex;
2724
2755
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
2725
2756
  function getDefaultExportFromCjs(x) {
2726
2757
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -3496,7 +3527,7 @@ function t(key, args = {}) {
3496
3527
  str = str.replace(/\{\s*(\w+?)\s*\}/g, (_, token) => args[token] || "");
3497
3528
  return str;
3498
3529
  }
3499
- const version = "2.5.5";
3530
+ const version = "2.6.0";
3500
3531
  class User {
3501
3532
  constructor() {
3502
3533
  __publicField(this, "ctx");
@@ -7482,7 +7513,7 @@ function createPlugManager(editor) {
7482
7513
  editor.getUI().$plugPanelWrap.style.display = "none";
7483
7514
  editor.getUI().$plugBtnWrap.innerHTML = "";
7484
7515
  const DISABLED = getDisabledPlugNames(editor.conf);
7485
- ENABLED_PLUGS.filter((p) => !DISABLED.includes(p.name)).forEach((Plug) => {
7516
+ ENABLED_PLUGS.filter((p) => !DISABLED.includes(p.Name)).forEach((Plug) => {
7486
7517
  initPlugItem(ctx, Plug);
7487
7518
  });
7488
7519
  return ctx;
@@ -8270,7 +8301,7 @@ function handleStatCount(p, args) {
8270
8301
  });
8271
8302
  });
8272
8303
  }
8273
- const _Artalk = class {
8304
+ const _Artalk = class _Artalk {
8274
8305
  constructor(conf) {
8275
8306
  __publicField(this, "conf");
8276
8307
  __publicField(this, "ctx");
@@ -8396,13 +8427,13 @@ const _Artalk = class {
8396
8427
  this.loadCountWidget(conf);
8397
8428
  }
8398
8429
  };
8399
- let Artalk = _Artalk;
8400
- __publicField(Artalk, "instance");
8401
- __publicField(Artalk, "ListLite", ListLite);
8402
- __publicField(Artalk, "defaults", defaults);
8430
+ __publicField(_Artalk, "instance");
8431
+ __publicField(_Artalk, "ListLite", ListLite);
8432
+ __publicField(_Artalk, "defaults", defaults);
8403
8433
  /** Plugins */
8404
- __publicField(Artalk, "plugins", [PvCountWidget]);
8405
- __publicField(Artalk, "DisabledComponents", []);
8434
+ __publicField(_Artalk, "plugins", [PvCountWidget]);
8435
+ __publicField(_Artalk, "DisabledComponents", []);
8436
+ let Artalk = _Artalk;
8406
8437
  export {
8407
8438
  Artalk as default
8408
8439
  };