artalk 2.5.4 → 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");
@@ -136,7 +150,8 @@ function onImagesLoaded($container, event) {
136
150
  }
137
151
  }
138
152
  function getGravatarURL(ctx, emailMD5) {
139
- return `${ctx.conf.gravatar.mirror.replace(/\/$/, "")}/${emailMD5}?d=${encodeURIComponent(ctx.conf.gravatar.default)}&s=80`;
153
+ const { mirror, params } = ctx.conf.gravatar;
154
+ return `${mirror.replace(/\/$/, "")}/${emailMD5}?${params.replace(/^\?/, "")}`;
140
155
  }
141
156
  function versionCompare(a, b) {
142
157
  const pa = a.split(".");
@@ -367,7 +382,7 @@ function getScrollBarWidth() {
367
382
  document.body.removeChild(outer);
368
383
  return w1 - w2;
369
384
  }
370
- const _Layer = class extends Component {
385
+ const _Layer = class _Layer extends Component {
371
386
  constructor(ctx, name, el) {
372
387
  super(ctx);
373
388
  __publicField(this, "name");
@@ -474,11 +489,11 @@ const _Layer = class extends Component {
474
489
  }
475
490
  }
476
491
  };
477
- let Layer = _Layer;
478
- __publicField(Layer, "BodyOrgOverflow");
479
- __publicField(Layer, "BodyOrgPaddingRight");
492
+ __publicField(_Layer, "BodyOrgOverflow");
493
+ __publicField(_Layer, "BodyOrgPaddingRight");
480
494
  // Timers
481
- __publicField(Layer, "actionTimers", []);
495
+ __publicField(_Layer, "actionTimers", []);
496
+ let Layer = _Layer;
482
497
  function getLayerWrap() {
483
498
  let $wrap = document.querySelector(`.atk-layer-wrap`);
484
499
  if (!$wrap) {
@@ -530,19 +545,19 @@ function updateClassName(ctx, darkMode) {
530
545
  $layerWrap.classList.remove(DarkModeClassName);
531
546
  }
532
547
  }
533
- function getDefaults() {
548
+ function _getDefaults() {
534
549
  return {
535
550
  async: false,
536
551
  baseUrl: null,
537
552
  breaks: false,
538
553
  extensions: null,
539
554
  gfm: true,
540
- headerIds: true,
555
+ headerIds: false,
541
556
  headerPrefix: "",
542
557
  highlight: null,
543
558
  hooks: null,
544
559
  langPrefix: "language-",
545
- mangle: true,
560
+ mangle: false,
546
561
  pedantic: false,
547
562
  renderer: null,
548
563
  sanitize: false,
@@ -554,9 +569,9 @@ function getDefaults() {
554
569
  xhtml: false
555
570
  };
556
571
  }
557
- let defaults$3 = getDefaults();
572
+ let _defaults = _getDefaults();
558
573
  function changeDefaults(newDefaults) {
559
- defaults$3 = newDefaults;
574
+ _defaults = newDefaults;
560
575
  }
561
576
  const escapeTest = /[&<>"']/;
562
577
  const escapeReplace = new RegExp(escapeTest.source, "g");
@@ -600,7 +615,7 @@ function edit$1(regex, opt) {
600
615
  opt = opt || "";
601
616
  const obj = {
602
617
  replace: (name, val) => {
603
- val = val.source || val;
618
+ val = typeof val === "object" && "source" in val ? val.source : val;
604
619
  val = val.replace(caret, "$1");
605
620
  regex = regex.replace(name, val);
606
621
  return obj;
@@ -663,11 +678,11 @@ function resolveUrl(base, href) {
663
678
  return base + href;
664
679
  }
665
680
  }
666
- const noopTest = { exec: function noopTest2() {
667
- } };
681
+ const noopTest = { exec: () => null };
668
682
  function splitCells(tableRow, count) {
669
683
  const row = tableRow.replace(/\|/g, (match, offset, str) => {
670
- let escaped = false, curr = offset;
684
+ let escaped = false;
685
+ let curr = offset;
671
686
  while (--curr >= 0 && str[curr] === "\\")
672
687
  escaped = !escaped;
673
688
  if (escaped) {
@@ -683,11 +698,13 @@ function splitCells(tableRow, count) {
683
698
  if (cells.length > 0 && !cells[cells.length - 1].trim()) {
684
699
  cells.pop();
685
700
  }
686
- if (cells.length > count) {
687
- cells.splice(count);
688
- } else {
689
- while (cells.length < count)
690
- 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
+ }
691
708
  }
692
709
  for (; i < cells.length; i++) {
693
710
  cells[i] = cells[i].trim().replace(/\\\|/g, "|");
@@ -716,9 +733,8 @@ function findClosingBracket(str, b) {
716
733
  if (str.indexOf(b[1]) === -1) {
717
734
  return -1;
718
735
  }
719
- const l = str.length;
720
- let level = 0, i = 0;
721
- for (; i < l; i++) {
736
+ let level = 0;
737
+ for (let i = 0; i < str.length; i++) {
722
738
  if (str[i] === "\\") {
723
739
  i++;
724
740
  } else if (str[i] === b[0]) {
@@ -732,24 +748,34 @@ function findClosingBracket(str, b) {
732
748
  }
733
749
  return -1;
734
750
  }
735
- function checkSanitizeDeprecation(opt) {
736
- if (opt && opt.sanitize && !opt.silent) {
751
+ function checkDeprecations(opt, callback) {
752
+ if (!opt || opt.silent) {
753
+ return;
754
+ }
755
+ if (callback) {
756
+ console.warn("marked(): callback is deprecated since version 5.0.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/using_pro#async");
757
+ }
758
+ if (opt.sanitize || opt.sanitizer) {
737
759
  console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options");
738
760
  }
739
- }
740
- function repeatString(pattern, count) {
741
- if (count < 1) {
742
- return "";
761
+ if (opt.highlight || opt.langPrefix !== "language-") {
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.");
743
763
  }
744
- let result = "";
745
- while (count > 1) {
746
- if (count & 1) {
747
- result += pattern;
748
- }
749
- count >>= 1;
750
- pattern += pattern;
764
+ if (opt.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}`.");
766
+ }
767
+ if (opt.baseUrl) {
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.");
769
+ }
770
+ if (opt.smartypants) {
771
+ console.warn("marked(): smartypants 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-smartypants.");
772
+ }
773
+ if (opt.xhtml) {
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.");
775
+ }
776
+ if (opt.headerIds || opt.headerPrefix) {
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}`.");
751
778
  }
752
- return result + pattern;
753
779
  }
754
780
  function outputLink(cap, link, raw, lexer) {
755
781
  const href = link.href;
@@ -794,9 +820,13 @@ function indentCodeCompensation(raw, text) {
794
820
  return node;
795
821
  }).join("\n");
796
822
  }
797
- class Tokenizer {
823
+ class _Tokenizer {
798
824
  constructor(options) {
799
- 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;
800
830
  }
801
831
  space(src) {
802
832
  const cap = this.rules.block.newline.exec(src);
@@ -881,7 +911,6 @@ class Tokenizer {
881
911
  list(src) {
882
912
  let cap = this.rules.block.list.exec(src);
883
913
  if (cap) {
884
- let raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine, line, nextLine, rawLine, itemContents, endEarly;
885
914
  let bull = cap[1].trim();
886
915
  const isordered = bull.length > 1;
887
916
  const list = {
@@ -897,8 +926,11 @@ class Tokenizer {
897
926
  bull = isordered ? bull : "[*+-]";
898
927
  }
899
928
  const itemRegex = new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`);
929
+ let raw = "";
930
+ let itemContents = "";
931
+ let endsWithBlankLine = false;
900
932
  while (src) {
901
- endEarly = false;
933
+ let endEarly = false;
902
934
  if (!(cap = itemRegex.exec(src))) {
903
935
  break;
904
936
  }
@@ -907,8 +939,9 @@ class Tokenizer {
907
939
  }
908
940
  raw = cap[0];
909
941
  src = src.substring(raw.length);
910
- line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t2) => " ".repeat(3 * t2.length));
911
- 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;
912
945
  if (this.options.pedantic) {
913
946
  indent = 2;
914
947
  itemContents = line.trimLeft();
@@ -918,7 +951,7 @@ class Tokenizer {
918
951
  itemContents = line.slice(indent);
919
952
  indent += cap[1].length;
920
953
  }
921
- blankLine = false;
954
+ let blankLine = false;
922
955
  if (!line && /^ *$/.test(nextLine)) {
923
956
  raw += nextLine + "\n";
924
957
  src = src.substring(nextLine.length + 1);
@@ -930,7 +963,7 @@ class Tokenizer {
930
963
  const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
931
964
  const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
932
965
  while (src) {
933
- rawLine = src.split("\n", 1)[0];
966
+ const rawLine = src.split("\n", 1)[0];
934
967
  nextLine = rawLine;
935
968
  if (this.options.pedantic) {
936
969
  nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
@@ -982,6 +1015,8 @@ class Tokenizer {
982
1015
  endsWithBlankLine = true;
983
1016
  }
984
1017
  }
1018
+ let istask = null;
1019
+ let ischecked;
985
1020
  if (this.options.gfm) {
986
1021
  istask = /^\[[ xX]\] /.exec(itemContents);
987
1022
  if (istask) {
@@ -995,15 +1030,15 @@ class Tokenizer {
995
1030
  task: !!istask,
996
1031
  checked: ischecked,
997
1032
  loose: false,
998
- text: itemContents
1033
+ text: itemContents,
1034
+ tokens: []
999
1035
  });
1000
1036
  list.raw += raw;
1001
1037
  }
1002
1038
  list.items[list.items.length - 1].raw = raw.trimRight();
1003
1039
  list.items[list.items.length - 1].text = itemContents.trimRight();
1004
1040
  list.raw = list.raw.trimRight();
1005
- const l = list.items.length;
1006
- for (i = 0; i < l; i++) {
1041
+ for (let i = 0; i < list.items.length; i++) {
1007
1042
  this.lexer.state.top = false;
1008
1043
  list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
1009
1044
  if (!list.loose) {
@@ -1013,7 +1048,7 @@ class Tokenizer {
1013
1048
  }
1014
1049
  }
1015
1050
  if (list.loose) {
1016
- for (i = 0; i < l; i++) {
1051
+ for (let i = 0; i < list.items.length; i++) {
1017
1052
  list.items[i].loose = true;
1018
1053
  }
1019
1054
  }
@@ -1025,15 +1060,17 @@ class Tokenizer {
1025
1060
  if (cap) {
1026
1061
  const token = {
1027
1062
  type: "html",
1063
+ block: true,
1028
1064
  raw: cap[0],
1029
1065
  pre: !this.options.sanitizer && (cap[1] === "pre" || cap[1] === "script" || cap[1] === "style"),
1030
1066
  text: cap[0]
1031
1067
  };
1032
1068
  if (this.options.sanitize) {
1033
1069
  const text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
1034
- token.type = "paragraph";
1035
- token.text = text;
1036
- 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);
1037
1074
  }
1038
1075
  return token;
1039
1076
  }
@@ -1058,31 +1095,34 @@ class Tokenizer {
1058
1095
  if (cap) {
1059
1096
  const item = {
1060
1097
  type: "table",
1098
+ raw: cap[0],
1061
1099
  header: splitCells(cap[1]).map((c) => {
1062
- return { text: c };
1100
+ return { text: c, tokens: [] };
1063
1101
  }),
1064
1102
  align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
1065
1103
  rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : []
1066
1104
  };
1067
1105
  if (item.header.length === item.align.length) {
1068
- item.raw = cap[0];
1069
1106
  let l = item.align.length;
1070
1107
  let i, j, k, row;
1071
1108
  for (i = 0; i < l; i++) {
1072
- if (/^ *-+: *$/.test(item.align[i])) {
1073
- item.align[i] = "right";
1074
- } else if (/^ *:-+: *$/.test(item.align[i])) {
1075
- item.align[i] = "center";
1076
- } else if (/^ *:-+ *$/.test(item.align[i])) {
1077
- item.align[i] = "left";
1078
- } else {
1079
- 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
+ }
1080
1120
  }
1081
1121
  }
1082
1122
  l = item.rows.length;
1083
1123
  for (i = 0; i < l; i++) {
1084
1124
  item.rows[i] = splitCells(item.rows[i], item.header.length).map((c) => {
1085
- return { text: c };
1125
+ return { text: c, tokens: [] };
1086
1126
  });
1087
1127
  }
1088
1128
  l = item.header.length;
@@ -1163,6 +1203,7 @@ class Tokenizer {
1163
1203
  raw: cap[0],
1164
1204
  inLink: this.lexer.state.inLink,
1165
1205
  inRawBlock: this.lexer.state.inRawBlock,
1206
+ block: false,
1166
1207
  text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0]
1167
1208
  };
1168
1209
  }
@@ -1237,8 +1278,8 @@ class Tokenizer {
1237
1278
  if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
1238
1279
  return;
1239
1280
  const nextChar = match[1] || match[2] || "";
1240
- if (!nextChar || nextChar && (prevChar === "" || this.rules.inline.punctuation.exec(prevChar))) {
1241
- const lLength = match[0].length - 1;
1281
+ if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
1282
+ const lLength = [...match[0]].length - 1;
1242
1283
  let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
1243
1284
  const endReg = match[0][0] === "*" ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
1244
1285
  endReg.lastIndex = 0;
@@ -1247,7 +1288,7 @@ class Tokenizer {
1247
1288
  rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
1248
1289
  if (!rDelim)
1249
1290
  continue;
1250
- rLength = rDelim.length;
1291
+ rLength = [...rDelim].length;
1251
1292
  if (match[3] || match[4]) {
1252
1293
  delimTotal += rLength;
1253
1294
  continue;
@@ -1261,7 +1302,7 @@ class Tokenizer {
1261
1302
  if (delimTotal > 0)
1262
1303
  continue;
1263
1304
  rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
1264
- 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("");
1265
1306
  if (Math.min(lLength, rLength) % 2) {
1266
1307
  const text2 = raw.slice(1, -1);
1267
1308
  return {
@@ -1407,7 +1448,7 @@ const block = {
1407
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|$))",
1408
1449
  def: /^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
1409
1450
  table: noopTest,
1410
- lheading: /^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
1451
+ lheading: /^((?:(?!^bull ).|\n(?!\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
1411
1452
  // regex template, placeholders will be replaced according to different paragraph
1412
1453
  // interruption rules of commonmark and the original markdown spec:
1413
1454
  _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
@@ -1422,6 +1463,7 @@ block.list = edit$1(block.list).replace(/bull/g, block.bullet).replace("hr", "\\
1422
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";
1423
1464
  block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
1424
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();
1425
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();
1426
1468
  block.blockquote = edit$1(block.blockquote).replace("paragraph", block.paragraph).getRegex();
1427
1469
  block.normal = __spreadValues({}, block);
@@ -1432,13 +1474,10 @@ block.gfm = __spreadProps(__spreadValues({}, block.normal), {
1432
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();
1433
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();
1434
1476
  block.pedantic = __spreadProps(__spreadValues({}, block.normal), {
1435
- html: edit$1(
1436
- `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
1437
- ).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(),
1438
1478
  def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
1439
1479
  heading: /^(#{1,6})(.*)(?:\n+|$)/,
1440
1480
  fences: noopTest,
1441
- // fences not supported
1442
1481
  lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
1443
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()
1444
1483
  });
@@ -1447,34 +1486,35 @@ const inline = {
1447
1486
  autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
1448
1487
  url: noopTest,
1449
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]*?\\]\\]>",
1450
- // CDATA section
1451
1489
  link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
1452
1490
  reflink: /^!?\[(label)\]\[(ref)\]/,
1453
1491
  nolink: /^!?\[(ref)\](?:\[\])?/,
1454
1492
  reflinkSearch: "reflink|nolink(?!\\()",
1455
1493
  emStrong: {
1456
- lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
1457
- // (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.
1458
- // () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
1459
- rDelimAst: /^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,
1460
- 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])/
1461
1499
  // ^- Not allowed for _
1462
1500
  },
1463
1501
  code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
1464
1502
  br: /^( {2,}|\\)\n(?!\s*$)/,
1465
1503
  del: noopTest,
1466
1504
  text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
1467
- punctuation: /^([\spunctuation])/
1505
+ punctuation: /^((?![*_])[\spunctuation])/
1468
1506
  };
1469
- inline._punctuation = "!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~";
1470
- inline.punctuation = edit$1(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex();
1471
- inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
1472
- 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;
1473
1512
  inline._comment = edit$1(block._comment).replace("(?:-->|$)", "-->").getRegex();
1474
- inline.emStrong.lDelim = edit$1(inline.emStrong.lDelim).replace(/punct/g, inline._punctuation).getRegex();
1475
- inline.emStrong.rDelimAst = edit$1(inline.emStrong.rDelimAst, "g").replace(/punct/g, inline._punctuation).getRegex();
1476
- inline.emStrong.rDelimUnd = edit$1(inline.emStrong.rDelimUnd, "g").replace(/punct/g, inline._punctuation).getRegex();
1477
- 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();
1478
1518
  inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
1479
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])?)+(?![-_])/;
1480
1520
  inline.autolink = edit$1(inline.autolink).replace("scheme", inline._scheme).replace("email", inline._email).getRegex();
@@ -1521,23 +1561,24 @@ function smartypants(text) {
1521
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, "…");
1522
1562
  }
1523
1563
  function mangle(text) {
1524
- let out = "", i, ch;
1525
- const l = text.length;
1526
- for (i = 0; i < l; i++) {
1527
- ch = text.charCodeAt(i);
1528
- if (Math.random() > 0.5) {
1529
- ch = "x" + ch.toString(16);
1530
- }
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();
1531
1567
  out += "&#" + ch + ";";
1532
1568
  }
1533
1569
  return out;
1534
1570
  }
1535
- class Lexer {
1571
+ class _Lexer {
1536
1572
  constructor(options) {
1573
+ __publicField(this, "tokens");
1574
+ __publicField(this, "options");
1575
+ __publicField(this, "state");
1576
+ __publicField(this, "tokenizer");
1577
+ __publicField(this, "inlineQueue");
1537
1578
  this.tokens = [];
1538
1579
  this.tokens.links = /* @__PURE__ */ Object.create(null);
1539
- this.options = options || defaults$3;
1540
- this.options.tokenizer = this.options.tokenizer || new Tokenizer();
1580
+ this.options = options || _defaults;
1581
+ this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
1541
1582
  this.tokenizer = this.options.tokenizer;
1542
1583
  this.tokenizer.options = this.options;
1543
1584
  this.tokenizer.lexer = this;
@@ -1577,14 +1618,14 @@ class Lexer {
1577
1618
  * Static Lex Method
1578
1619
  */
1579
1620
  static lex(src, options) {
1580
- const lexer = new Lexer(options);
1621
+ const lexer = new _Lexer(options);
1581
1622
  return lexer.lex(src);
1582
1623
  }
1583
1624
  /**
1584
1625
  * Static Lex Inline Method
1585
1626
  */
1586
1627
  static lexInline(src, options) {
1587
- const lexer = new Lexer(options);
1628
+ const lexer = new _Lexer(options);
1588
1629
  return lexer.inlineTokens(src);
1589
1630
  }
1590
1631
  /**
@@ -1599,9 +1640,6 @@ class Lexer {
1599
1640
  }
1600
1641
  return this.tokens;
1601
1642
  }
1602
- /**
1603
- * Lexing
1604
- */
1605
1643
  blockTokens(src, tokens = []) {
1606
1644
  if (this.options.pedantic) {
1607
1645
  src = src.replace(/\t/g, " ").replace(/^ +$/gm, "");
@@ -1610,7 +1648,10 @@ class Lexer {
1610
1648
  return leading + " ".repeat(tabs.length);
1611
1649
  });
1612
1650
  }
1613
- let token, lastToken, cutSrc, lastParagraphClipped;
1651
+ let token;
1652
+ let lastToken;
1653
+ let cutSrc;
1654
+ let lastParagraphClipped;
1614
1655
  while (src) {
1615
1656
  if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
1616
1657
  if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
@@ -1703,7 +1744,7 @@ class Lexer {
1703
1744
  let startIndex = Infinity;
1704
1745
  const tempSrc = src.slice(1);
1705
1746
  let tempStart;
1706
- this.options.extensions.startBlock.forEach(function(getStartIndex) {
1747
+ this.options.extensions.startBlock.forEach((getStartIndex) => {
1707
1748
  tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1708
1749
  if (typeof tempStart === "number" && tempStart >= 0) {
1709
1750
  startIndex = Math.min(startIndex, tempStart);
@@ -1770,17 +1811,16 @@ class Lexer {
1770
1811
  if (links.length > 0) {
1771
1812
  while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
1772
1813
  if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
1773
- 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);
1774
1815
  }
1775
1816
  }
1776
1817
  }
1777
1818
  }
1778
1819
  while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
1779
- 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);
1780
1821
  }
1781
- while ((match = this.tokenizer.rules.inline.escapedEmSt.exec(maskedSrc)) != null) {
1782
- maskedSrc = maskedSrc.slice(0, match.index + match[0].length - 2) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);
1783
- 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);
1784
1824
  }
1785
1825
  while (src) {
1786
1826
  if (!keepPrevChar) {
@@ -1864,7 +1904,7 @@ class Lexer {
1864
1904
  let startIndex = Infinity;
1865
1905
  const tempSrc = src.slice(1);
1866
1906
  let tempStart;
1867
- this.options.extensions.startInline.forEach(function(getStartIndex) {
1907
+ this.options.extensions.startInline.forEach((getStartIndex) => {
1868
1908
  tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1869
1909
  if (typeof tempStart === "number" && tempStart >= 0) {
1870
1910
  startIndex = Math.min(startIndex, tempStart);
@@ -1902,12 +1942,14 @@ class Lexer {
1902
1942
  return tokens;
1903
1943
  }
1904
1944
  }
1905
- class Renderer {
1945
+ class _Renderer {
1906
1946
  constructor(options) {
1907
- this.options = options || defaults$3;
1947
+ __publicField(this, "options");
1948
+ this.options = options || _defaults;
1908
1949
  }
1909
1950
  code(code, infostring, escaped) {
1910
- const lang = (infostring || "").match(/\S*/)[0];
1951
+ var _a;
1952
+ const lang = (_a = (infostring || "").match(/^\S*/)) == null ? void 0 : _a[0];
1911
1953
  if (this.options.highlight) {
1912
1954
  const out = this.options.highlight(code, lang);
1913
1955
  if (out != null && out !== code) {
@@ -1921,23 +1963,14 @@ class Renderer {
1921
1963
  }
1922
1964
  return '<pre><code class="' + this.options.langPrefix + escape(lang) + '">' + (escaped ? code : escape(code, true)) + "</code></pre>\n";
1923
1965
  }
1924
- /**
1925
- * @param {string} quote
1926
- */
1927
1966
  blockquote(quote) {
1928
1967
  return `<blockquote>
1929
1968
  ${quote}</blockquote>
1930
1969
  `;
1931
1970
  }
1932
- html(html) {
1971
+ html(html, block2) {
1933
1972
  return html;
1934
1973
  }
1935
- /**
1936
- * @param {string} text
1937
- * @param {string} level
1938
- * @param {string} raw
1939
- * @param {any} slugger
1940
- */
1941
1974
  heading(text, level, raw, slugger) {
1942
1975
  if (this.options.headerIds) {
1943
1976
  const id = this.options.headerPrefix + slugger.slug(raw);
@@ -1951,38 +1984,26 @@ ${quote}</blockquote>
1951
1984
  return this.options.xhtml ? "<hr/>\n" : "<hr>\n";
1952
1985
  }
1953
1986
  list(body, ordered, start) {
1954
- 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 + '"' : "";
1955
1989
  return "<" + type + startatt + ">\n" + body + "</" + type + ">\n";
1956
1990
  }
1957
- /**
1958
- * @param {string} text
1959
- */
1960
- listitem(text) {
1991
+ listitem(text, task, checked) {
1961
1992
  return `<li>${text}</li>
1962
1993
  `;
1963
1994
  }
1964
1995
  checkbox(checked) {
1965
1996
  return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox"' + (this.options.xhtml ? " /" : "") + "> ";
1966
1997
  }
1967
- /**
1968
- * @param {string} text
1969
- */
1970
1998
  paragraph(text) {
1971
1999
  return `<p>${text}</p>
1972
2000
  `;
1973
2001
  }
1974
- /**
1975
- * @param {string} header
1976
- * @param {string} body
1977
- */
1978
2002
  table(header2, body) {
1979
2003
  if (body)
1980
2004
  body = `<tbody>${body}</tbody>`;
1981
2005
  return "<table>\n<thead>\n" + header2 + "</thead>\n" + body + "</table>\n";
1982
2006
  }
1983
- /**
1984
- * @param {string} content
1985
- */
1986
2007
  tablerow(content) {
1987
2008
  return `<tr>
1988
2009
  ${content}</tr>
@@ -1996,42 +2017,28 @@ ${content}</tr>
1996
2017
  }
1997
2018
  /**
1998
2019
  * span level renderer
1999
- * @param {string} text
2000
2020
  */
2001
2021
  strong(text) {
2002
2022
  return `<strong>${text}</strong>`;
2003
2023
  }
2004
- /**
2005
- * @param {string} text
2006
- */
2007
2024
  em(text) {
2008
2025
  return `<em>${text}</em>`;
2009
2026
  }
2010
- /**
2011
- * @param {string} text
2012
- */
2013
2027
  codespan(text) {
2014
2028
  return `<code>${text}</code>`;
2015
2029
  }
2016
2030
  br() {
2017
2031
  return this.options.xhtml ? "<br/>" : "<br>";
2018
2032
  }
2019
- /**
2020
- * @param {string} text
2021
- */
2022
2033
  del(text) {
2023
2034
  return `<del>${text}</del>`;
2024
2035
  }
2025
- /**
2026
- * @param {string} href
2027
- * @param {string} title
2028
- * @param {string} text
2029
- */
2030
2036
  link(href, title, text) {
2031
- href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
2032
- if (href === null) {
2037
+ const cleanHref = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
2038
+ if (cleanHref === null) {
2033
2039
  return text;
2034
2040
  }
2041
+ href = cleanHref;
2035
2042
  let out = '<a href="' + href + '"';
2036
2043
  if (title) {
2037
2044
  out += ' title="' + title + '"';
@@ -2039,16 +2046,12 @@ ${content}</tr>
2039
2046
  out += ">" + text + "</a>";
2040
2047
  return out;
2041
2048
  }
2042
- /**
2043
- * @param {string} href
2044
- * @param {string} title
2045
- * @param {string} text
2046
- */
2047
2049
  image(href, title, text) {
2048
- href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
2049
- if (href === null) {
2050
+ const cleanHref = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
2051
+ if (cleanHref === null) {
2050
2052
  return text;
2051
2053
  }
2054
+ href = cleanHref;
2052
2055
  let out = `<img src="${href}" alt="${text}"`;
2053
2056
  if (title) {
2054
2057
  out += ` title="${title}"`;
@@ -2060,7 +2063,7 @@ ${content}</tr>
2060
2063
  return text;
2061
2064
  }
2062
2065
  }
2063
- class TextRenderer {
2066
+ class _TextRenderer {
2064
2067
  // no need for block level renderers
2065
2068
  strong(text) {
2066
2069
  return text;
@@ -2090,20 +2093,16 @@ class TextRenderer {
2090
2093
  return "";
2091
2094
  }
2092
2095
  }
2093
- class Slugger {
2096
+ class _Slugger {
2094
2097
  constructor() {
2098
+ __publicField(this, "seen");
2095
2099
  this.seen = {};
2096
2100
  }
2097
- /**
2098
- * @param {string} value
2099
- */
2100
2101
  serialize(value) {
2101
2102
  return value.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig, "").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "").replace(/\s/g, "-");
2102
2103
  }
2103
2104
  /**
2104
2105
  * Finds the next safe (unique) slug to use
2105
- * @param {string} originalSlug
2106
- * @param {boolean} isDryRun
2107
2106
  */
2108
2107
  getNextSafeSlug(originalSlug, isDryRun) {
2109
2108
  let slug = originalSlug;
@@ -2123,49 +2122,50 @@ class Slugger {
2123
2122
  }
2124
2123
  /**
2125
2124
  * Convert string to unique id
2126
- * @param {object} [options]
2127
- * @param {boolean} [options.dryrun] Generates the next unique slug without
2128
- * updating the internal accumulator.
2129
2125
  */
2130
2126
  slug(value, options = {}) {
2131
2127
  const slug = this.serialize(value);
2132
2128
  return this.getNextSafeSlug(slug, options.dryrun);
2133
2129
  }
2134
2130
  }
2135
- class Parser {
2131
+ class _Parser {
2136
2132
  constructor(options) {
2137
- this.options = options || defaults$3;
2138
- 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();
2139
2139
  this.renderer = this.options.renderer;
2140
2140
  this.renderer.options = this.options;
2141
- this.textRenderer = new TextRenderer();
2142
- this.slugger = new Slugger();
2141
+ this.textRenderer = new _TextRenderer();
2142
+ this.slugger = new _Slugger();
2143
2143
  }
2144
2144
  /**
2145
2145
  * Static Parse Method
2146
2146
  */
2147
2147
  static parse(tokens, options) {
2148
- const parser2 = new Parser(options);
2148
+ const parser2 = new _Parser(options);
2149
2149
  return parser2.parse(tokens);
2150
2150
  }
2151
2151
  /**
2152
2152
  * Static Parse Inline Method
2153
2153
  */
2154
2154
  static parseInline(tokens, options) {
2155
- const parser2 = new Parser(options);
2155
+ const parser2 = new _Parser(options);
2156
2156
  return parser2.parseInline(tokens);
2157
2157
  }
2158
2158
  /**
2159
2159
  * Parse Loop
2160
2160
  */
2161
2161
  parse(tokens, top = true) {
2162
- let out = "", i, j, k, l2, l3, row, cell, header2, body, token, ordered, start, loose, itemBody, item, checked, task, checkbox, ret;
2163
- const l = tokens.length;
2164
- for (i = 0; i < l; i++) {
2165
- token = tokens[i];
2162
+ let out = "";
2163
+ for (let i = 0; i < tokens.length; i++) {
2164
+ const token = tokens[i];
2166
2165
  if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
2167
- ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
2168
- 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)) {
2169
2169
  out += ret || "";
2170
2170
  continue;
2171
2171
  }
@@ -2179,44 +2179,29 @@ class Parser {
2179
2179
  continue;
2180
2180
  }
2181
2181
  case "heading": {
2182
- out += this.renderer.heading(
2183
- this.parseInline(token.tokens),
2184
- token.depth,
2185
- unescape(this.parseInline(token.tokens, this.textRenderer)),
2186
- this.slugger
2187
- );
2182
+ const headingToken = token;
2183
+ out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape(this.parseInline(headingToken.tokens, this.textRenderer)), this.slugger);
2188
2184
  continue;
2189
2185
  }
2190
2186
  case "code": {
2191
- out += this.renderer.code(
2192
- token.text,
2193
- token.lang,
2194
- token.escaped
2195
- );
2187
+ const codeToken = token;
2188
+ out += this.renderer.code(codeToken.text, codeToken.lang, !!codeToken.escaped);
2196
2189
  continue;
2197
2190
  }
2198
2191
  case "table": {
2199
- header2 = "";
2200
- cell = "";
2201
- l2 = token.header.length;
2202
- for (j = 0; j < l2; j++) {
2203
- cell += this.renderer.tablecell(
2204
- this.parseInline(token.header[j].tokens),
2205
- { header: true, align: token.align[j] }
2206
- );
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] });
2207
2197
  }
2208
2198
  header2 += this.renderer.tablerow(cell);
2209
- body = "";
2210
- l2 = token.rows.length;
2211
- for (j = 0; j < l2; j++) {
2212
- row = token.rows[j];
2199
+ let body = "";
2200
+ for (let j = 0; j < tableToken.rows.length; j++) {
2201
+ const row = tableToken.rows[j];
2213
2202
  cell = "";
2214
- l3 = row.length;
2215
- for (k = 0; k < l3; k++) {
2216
- cell += this.renderer.tablecell(
2217
- this.parseInline(row[k].tokens),
2218
- { header: false, align: token.align[k] }
2219
- );
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] });
2220
2205
  }
2221
2206
  body += this.renderer.tablerow(cell);
2222
2207
  }
@@ -2224,23 +2209,24 @@ class Parser {
2224
2209
  continue;
2225
2210
  }
2226
2211
  case "blockquote": {
2227
- body = this.parse(token.tokens);
2212
+ const blockquoteToken = token;
2213
+ const body = this.parse(blockquoteToken.tokens);
2228
2214
  out += this.renderer.blockquote(body);
2229
2215
  continue;
2230
2216
  }
2231
2217
  case "list": {
2232
- ordered = token.ordered;
2233
- start = token.start;
2234
- loose = token.loose;
2235
- l2 = token.items.length;
2236
- body = "";
2237
- for (j = 0; j < l2; j++) {
2238
- item = token.items[j];
2239
- checked = item.checked;
2240
- task = item.task;
2241
- 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 = "";
2242
2228
  if (item.task) {
2243
- checkbox = this.renderer.checkbox(checked);
2229
+ const checkbox = this.renderer.checkbox(!!checked);
2244
2230
  if (loose) {
2245
2231
  if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
2246
2232
  item.tokens[0].text = checkbox + " " + item.tokens[0].text;
@@ -2258,24 +2244,27 @@ class Parser {
2258
2244
  }
2259
2245
  }
2260
2246
  itemBody += this.parse(item.tokens, loose);
2261
- body += this.renderer.listitem(itemBody, task, checked);
2247
+ body += this.renderer.listitem(itemBody, task, !!checked);
2262
2248
  }
2263
2249
  out += this.renderer.list(body, ordered, start);
2264
2250
  continue;
2265
2251
  }
2266
2252
  case "html": {
2267
- out += this.renderer.html(token.text);
2253
+ const htmlToken = token;
2254
+ out += this.renderer.html(htmlToken.text, htmlToken.block);
2268
2255
  continue;
2269
2256
  }
2270
2257
  case "paragraph": {
2271
- out += this.renderer.paragraph(this.parseInline(token.tokens));
2258
+ const paragraphToken = token;
2259
+ out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens));
2272
2260
  continue;
2273
2261
  }
2274
2262
  case "text": {
2275
- body = token.tokens ? this.parseInline(token.tokens) : token.text;
2276
- while (i + 1 < l && tokens[i + 1].type === "text") {
2277
- token = tokens[++i];
2278
- 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);
2279
2268
  }
2280
2269
  out += top ? this.renderer.paragraph(body) : body;
2281
2270
  continue;
@@ -2284,7 +2273,7 @@ class Parser {
2284
2273
  const errMsg = 'Token with "' + token.type + '" type was not found.';
2285
2274
  if (this.options.silent) {
2286
2275
  console.error(errMsg);
2287
- return;
2276
+ return "";
2288
2277
  } else {
2289
2278
  throw new Error(errMsg);
2290
2279
  }
@@ -2298,12 +2287,11 @@ class Parser {
2298
2287
  */
2299
2288
  parseInline(tokens, renderer) {
2300
2289
  renderer = renderer || this.renderer;
2301
- let out = "", i, token, ret;
2302
- const l = tokens.length;
2303
- for (i = 0; i < l; i++) {
2304
- token = tokens[i];
2290
+ let out = "";
2291
+ for (let i = 0; i < tokens.length; i++) {
2292
+ const token = tokens[i];
2305
2293
  if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
2306
- ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
2294
+ const ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
2307
2295
  if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) {
2308
2296
  out += ret || "";
2309
2297
  continue;
@@ -2311,31 +2299,38 @@ class Parser {
2311
2299
  }
2312
2300
  switch (token.type) {
2313
2301
  case "escape": {
2314
- out += renderer.text(token.text);
2302
+ const escapeToken = token;
2303
+ out += renderer.text(escapeToken.text);
2315
2304
  break;
2316
2305
  }
2317
2306
  case "html": {
2318
- out += renderer.html(token.text);
2307
+ const tagToken = token;
2308
+ out += renderer.html(tagToken.text);
2319
2309
  break;
2320
2310
  }
2321
2311
  case "link": {
2322
- 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));
2323
2314
  break;
2324
2315
  }
2325
2316
  case "image": {
2326
- out += renderer.image(token.href, token.title, token.text);
2317
+ const imageToken = token;
2318
+ out += renderer.image(imageToken.href, imageToken.title, imageToken.text);
2327
2319
  break;
2328
2320
  }
2329
2321
  case "strong": {
2330
- out += renderer.strong(this.parseInline(token.tokens, renderer));
2322
+ const strongToken = token;
2323
+ out += renderer.strong(this.parseInline(strongToken.tokens, renderer));
2331
2324
  break;
2332
2325
  }
2333
2326
  case "em": {
2334
- out += renderer.em(this.parseInline(token.tokens, renderer));
2327
+ const emToken = token;
2328
+ out += renderer.em(this.parseInline(emToken.tokens, renderer));
2335
2329
  break;
2336
2330
  }
2337
2331
  case "codespan": {
2338
- out += renderer.codespan(token.text);
2332
+ const codespanToken = token;
2333
+ out += renderer.codespan(codespanToken.text);
2339
2334
  break;
2340
2335
  }
2341
2336
  case "br": {
@@ -2343,18 +2338,20 @@ class Parser {
2343
2338
  break;
2344
2339
  }
2345
2340
  case "del": {
2346
- out += renderer.del(this.parseInline(token.tokens, renderer));
2341
+ const delToken = token;
2342
+ out += renderer.del(this.parseInline(delToken.tokens, renderer));
2347
2343
  break;
2348
2344
  }
2349
2345
  case "text": {
2350
- out += renderer.text(token.text);
2346
+ const textToken = token;
2347
+ out += renderer.text(textToken.text);
2351
2348
  break;
2352
2349
  }
2353
2350
  default: {
2354
2351
  const errMsg = 'Token with "' + token.type + '" type was not found.';
2355
2352
  if (this.options.silent) {
2356
2353
  console.error(errMsg);
2357
- return;
2354
+ return "";
2358
2355
  } else {
2359
2356
  throw new Error(errMsg);
2360
2357
  }
@@ -2364,9 +2361,10 @@ class Parser {
2364
2361
  return out;
2365
2362
  }
2366
2363
  }
2367
- class Hooks {
2364
+ class _Hooks {
2368
2365
  constructor(options) {
2369
- this.options = options || defaults$3;
2366
+ __publicField(this, "options");
2367
+ this.options = options || _defaults;
2370
2368
  }
2371
2369
  /**
2372
2370
  * Process markdown before marked
@@ -2381,54 +2379,234 @@ class Hooks {
2381
2379
  return html;
2382
2380
  }
2383
2381
  }
2384
- __publicField(Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
2382
+ __publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
2385
2383
  "preprocess",
2386
2384
  "postprocess"
2387
2385
  ]));
2388
- function onError(silent, async, callback) {
2389
- return (e) => {
2390
- e.message += "\nPlease report this to https://github.com/markedjs/marked.";
2391
- if (silent) {
2392
- const msg = "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
2393
- if (async) {
2394
- return Promise.resolve(msg);
2395
- }
2396
- if (callback) {
2397
- callback(null, msg);
2398
- 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
+ }
2399
2441
  }
2400
- return msg;
2401
- }
2402
- if (async) {
2403
- return Promise.reject(e);
2404
2442
  }
2405
- if (callback) {
2406
- callback(e);
2407
- return;
2408
- }
2409
- throw e;
2410
- };
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
+ }
2411
2581
  }
2412
- function parseMarkdown(lexer, parser2) {
2413
- return (src, opt, callback) => {
2414
- if (typeof opt === "function") {
2415
- callback = opt;
2416
- 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;
2417
2596
  }
2418
- const origOpt = __spreadValues({}, opt);
2419
- opt = __spreadValues(__spreadValues({}, marked$1.defaults), origOpt);
2420
- const throwError = onError(opt.silent, opt.async, callback);
2597
+ const throwError = __privateMethod(this, _onError, onError_fn).call(this, !!opt.silent, !!opt.async, callback);
2421
2598
  if (typeof src === "undefined" || src === null) {
2422
2599
  return throwError(new Error("marked(): input parameter is undefined or null"));
2423
2600
  }
2424
2601
  if (typeof src !== "string") {
2425
2602
  return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
2426
2603
  }
2427
- checkSanitizeDeprecation(opt);
2604
+ checkDeprecations(opt, callback);
2428
2605
  if (opt.hooks) {
2429
2606
  opt.hooks.options = opt;
2430
2607
  }
2431
2608
  if (callback) {
2609
+ const resultCallback = callback;
2432
2610
  const highlight = opt.highlight;
2433
2611
  let tokens;
2434
2612
  try {
@@ -2439,12 +2617,12 @@ function parseMarkdown(lexer, parser2) {
2439
2617
  } catch (e) {
2440
2618
  return throwError(e);
2441
2619
  }
2442
- const done = function(err) {
2620
+ const done = (err) => {
2443
2621
  let out;
2444
2622
  if (!err) {
2445
2623
  try {
2446
2624
  if (opt.walkTokens) {
2447
- marked$1.walkTokens(tokens, opt.walkTokens);
2625
+ this.walkTokens(tokens, opt.walkTokens);
2448
2626
  }
2449
2627
  out = parser2(tokens, opt);
2450
2628
  if (opt.hooks) {
@@ -2455,7 +2633,7 @@ function parseMarkdown(lexer, parser2) {
2455
2633
  }
2456
2634
  }
2457
2635
  opt.highlight = highlight;
2458
- return err ? throwError(err) : callback(null, out);
2636
+ return err ? throwError(err) : resultCallback(null, out);
2459
2637
  };
2460
2638
  if (!highlight || highlight.length < 3) {
2461
2639
  return done();
@@ -2464,11 +2642,11 @@ function parseMarkdown(lexer, parser2) {
2464
2642
  if (!tokens.length)
2465
2643
  return done();
2466
2644
  let pending = 0;
2467
- marked$1.walkTokens(tokens, function(token) {
2645
+ this.walkTokens(tokens, (token) => {
2468
2646
  if (token.type === "code") {
2469
2647
  pending++;
2470
2648
  setTimeout(() => {
2471
- highlight(token.text, token.lang, function(err, code) {
2649
+ highlight(token.text, token.lang, (err, code) => {
2472
2650
  if (err) {
2473
2651
  return done(err);
2474
2652
  }
@@ -2490,7 +2668,7 @@ function parseMarkdown(lexer, parser2) {
2490
2668
  return;
2491
2669
  }
2492
2670
  if (opt.async) {
2493
- 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);
2494
2672
  }
2495
2673
  try {
2496
2674
  if (opt.hooks) {
@@ -2498,7 +2676,7 @@ function parseMarkdown(lexer, parser2) {
2498
2676
  }
2499
2677
  const tokens = lexer(src, opt);
2500
2678
  if (opt.walkTokens) {
2501
- marked$1.walkTokens(tokens, opt.walkTokens);
2679
+ this.walkTokens(tokens, opt.walkTokens);
2502
2680
  }
2503
2681
  let html = parser2(tokens, opt);
2504
2682
  if (opt.hooks) {
@@ -2509,192 +2687,75 @@ function parseMarkdown(lexer, parser2) {
2509
2687
  return throwError(e);
2510
2688
  }
2511
2689
  };
2512
- }
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();
2513
2717
  function marked$1(src, opt, callback) {
2514
- return parseMarkdown(Lexer.lex, Parser.parse)(src, opt, callback);
2718
+ return markedInstance.parse(src, opt, callback);
2515
2719
  }
2516
- marked$1.options = marked$1.setOptions = function(opt) {
2517
- 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;
2518
2723
  changeDefaults(marked$1.defaults);
2519
2724
  return marked$1;
2520
2725
  };
2521
- marked$1.getDefaults = getDefaults;
2522
- marked$1.defaults = defaults$3;
2726
+ marked$1.getDefaults = _getDefaults;
2727
+ marked$1.defaults = _defaults;
2523
2728
  marked$1.use = function(...args) {
2524
- const extensions = marked$1.defaults.extensions || { renderers: {}, childTokens: {} };
2525
- args.forEach((pack) => {
2526
- const opts = __spreadValues({}, pack);
2527
- opts.async = marked$1.defaults.async || opts.async || false;
2528
- if (pack.extensions) {
2529
- pack.extensions.forEach((ext) => {
2530
- if (!ext.name) {
2531
- throw new Error("extension name required");
2532
- }
2533
- if (ext.renderer) {
2534
- const prevRenderer = extensions.renderers[ext.name];
2535
- if (prevRenderer) {
2536
- extensions.renderers[ext.name] = function(...args2) {
2537
- let ret = ext.renderer.apply(this, args2);
2538
- if (ret === false) {
2539
- ret = prevRenderer.apply(this, args2);
2540
- }
2541
- return ret;
2542
- };
2543
- } else {
2544
- extensions.renderers[ext.name] = ext.renderer;
2545
- }
2546
- }
2547
- if (ext.tokenizer) {
2548
- if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
2549
- throw new Error("extension level must be 'block' or 'inline'");
2550
- }
2551
- if (extensions[ext.level]) {
2552
- extensions[ext.level].unshift(ext.tokenizer);
2553
- } else {
2554
- extensions[ext.level] = [ext.tokenizer];
2555
- }
2556
- if (ext.start) {
2557
- if (ext.level === "block") {
2558
- if (extensions.startBlock) {
2559
- extensions.startBlock.push(ext.start);
2560
- } else {
2561
- extensions.startBlock = [ext.start];
2562
- }
2563
- } else if (ext.level === "inline") {
2564
- if (extensions.startInline) {
2565
- extensions.startInline.push(ext.start);
2566
- } else {
2567
- extensions.startInline = [ext.start];
2568
- }
2569
- }
2570
- }
2571
- }
2572
- if (ext.childTokens) {
2573
- extensions.childTokens[ext.name] = ext.childTokens;
2574
- }
2575
- });
2576
- opts.extensions = extensions;
2577
- }
2578
- if (pack.renderer) {
2579
- const renderer = marked$1.defaults.renderer || new Renderer();
2580
- for (const prop in pack.renderer) {
2581
- const prevRenderer = renderer[prop];
2582
- renderer[prop] = (...args2) => {
2583
- let ret = pack.renderer[prop].apply(renderer, args2);
2584
- if (ret === false) {
2585
- ret = prevRenderer.apply(renderer, args2);
2586
- }
2587
- return ret;
2588
- };
2589
- }
2590
- opts.renderer = renderer;
2591
- }
2592
- if (pack.tokenizer) {
2593
- const tokenizer = marked$1.defaults.tokenizer || new Tokenizer();
2594
- for (const prop in pack.tokenizer) {
2595
- const prevTokenizer = tokenizer[prop];
2596
- tokenizer[prop] = (...args2) => {
2597
- let ret = pack.tokenizer[prop].apply(tokenizer, args2);
2598
- if (ret === false) {
2599
- ret = prevTokenizer.apply(tokenizer, args2);
2600
- }
2601
- return ret;
2602
- };
2603
- }
2604
- opts.tokenizer = tokenizer;
2605
- }
2606
- if (pack.hooks) {
2607
- const hooks = marked$1.defaults.hooks || new Hooks();
2608
- for (const prop in pack.hooks) {
2609
- const prevHook = hooks[prop];
2610
- if (Hooks.passThroughHooks.has(prop)) {
2611
- hooks[prop] = (arg) => {
2612
- if (marked$1.defaults.async) {
2613
- return Promise.resolve(pack.hooks[prop].call(hooks, arg)).then((ret2) => {
2614
- return prevHook.call(hooks, ret2);
2615
- });
2616
- }
2617
- const ret = pack.hooks[prop].call(hooks, arg);
2618
- return prevHook.call(hooks, ret);
2619
- };
2620
- } else {
2621
- hooks[prop] = (...args2) => {
2622
- let ret = pack.hooks[prop].apply(hooks, args2);
2623
- if (ret === false) {
2624
- ret = prevHook.apply(hooks, args2);
2625
- }
2626
- return ret;
2627
- };
2628
- }
2629
- }
2630
- opts.hooks = hooks;
2631
- }
2632
- if (pack.walkTokens) {
2633
- const walkTokens = marked$1.defaults.walkTokens;
2634
- opts.walkTokens = function(token) {
2635
- let values = [];
2636
- values.push(pack.walkTokens.call(this, token));
2637
- if (walkTokens) {
2638
- values = values.concat(walkTokens.call(this, token));
2639
- }
2640
- return values;
2641
- };
2642
- }
2643
- marked$1.setOptions(opts);
2644
- });
2729
+ markedInstance.use(...args);
2730
+ marked$1.defaults = markedInstance.defaults;
2731
+ changeDefaults(marked$1.defaults);
2732
+ return marked$1;
2645
2733
  };
2646
2734
  marked$1.walkTokens = function(tokens, callback) {
2647
- let values = [];
2648
- for (const token of tokens) {
2649
- values = values.concat(callback.call(marked$1, token));
2650
- switch (token.type) {
2651
- case "table": {
2652
- for (const cell of token.header) {
2653
- values = values.concat(marked$1.walkTokens(cell.tokens, callback));
2654
- }
2655
- for (const row of token.rows) {
2656
- for (const cell of row) {
2657
- values = values.concat(marked$1.walkTokens(cell.tokens, callback));
2658
- }
2659
- }
2660
- break;
2661
- }
2662
- case "list": {
2663
- values = values.concat(marked$1.walkTokens(token.items, callback));
2664
- break;
2665
- }
2666
- default: {
2667
- if (marked$1.defaults.extensions && marked$1.defaults.extensions.childTokens && marked$1.defaults.extensions.childTokens[token.type]) {
2668
- marked$1.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
2669
- values = values.concat(marked$1.walkTokens(token[childTokens], callback));
2670
- });
2671
- } else if (token.tokens) {
2672
- values = values.concat(marked$1.walkTokens(token.tokens, callback));
2673
- }
2674
- }
2675
- }
2676
- }
2677
- return values;
2735
+ return markedInstance.walkTokens(tokens, callback);
2678
2736
  };
2679
- marked$1.parseInline = parseMarkdown(Lexer.lexInline, Parser.parseInline);
2680
- marked$1.Parser = Parser;
2681
- marked$1.parser = Parser.parse;
2682
- marked$1.Renderer = Renderer;
2683
- marked$1.TextRenderer = TextRenderer;
2684
- marked$1.Lexer = Lexer;
2685
- marked$1.lexer = Lexer.lex;
2686
- marked$1.Tokenizer = Tokenizer;
2687
- marked$1.Slugger = Slugger;
2688
- 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;
2689
2747
  marked$1.parse = marked$1;
2690
2748
  marked$1.options;
2691
2749
  marked$1.setOptions;
2692
2750
  marked$1.use;
2693
2751
  marked$1.walkTokens;
2694
2752
  marked$1.parseInline;
2695
- Parser.parse;
2696
- Lexer.lex;
2753
+ _Parser.parse;
2754
+ _Lexer.lex;
2697
2755
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
2756
+ function getDefaultExportFromCjs(x) {
2757
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
2758
+ }
2698
2759
  var escapes = {
2699
2760
  "&": "&amp;",
2700
2761
  "<": "&lt;",
@@ -3084,15 +3145,8 @@ function insane(html, options, strict) {
3084
3145
  }
3085
3146
  insane.defaults = defaults$1;
3086
3147
  var insane_1 = insane;
3087
- var hanabiExports = {};
3088
- var hanabi$1 = {
3089
- get exports() {
3090
- return hanabiExports;
3091
- },
3092
- set exports(v) {
3093
- hanabiExports = v;
3094
- }
3095
- };
3148
+ const insane$1 = /* @__PURE__ */ getDefaultExportFromCjs(insane_1);
3149
+ var hanabi$1 = { exports: {} };
3096
3150
  (function(module, exports) {
3097
3151
  (function(global2, factory) {
3098
3152
  module.exports = factory();
@@ -3148,7 +3202,8 @@ var hanabi$1 = {
3148
3202
  return index;
3149
3203
  });
3150
3204
  })(hanabi$1);
3151
- const hanabi = hanabiExports;
3205
+ var hanabiExports = hanabi$1.exports;
3206
+ const hanabi = /* @__PURE__ */ getDefaultExportFromCjs(hanabiExports);
3152
3207
  let instance;
3153
3208
  function getInstance() {
3154
3209
  return instance;
@@ -3201,7 +3256,7 @@ function marked(ctx, src) {
3201
3256
  if (!markedContent) {
3202
3257
  markedContent = src.replace(/```\s*([^]+?.*?[^]+?[^]+?)```/g, (_, code) => `<pre><code>${hanabi(code)}</code></pre>`).replace(/!\[(.*?)\]\((.*?)\)/g, (_, alt, imgSrc) => `<img src="${imgSrc}" alt="${alt}" />`).replace(/\[(.*?)\]\((.*?)\)/g, (_, text, link) => `<a href="${link}" target="_blank">${text}</a>`).replace(/\n/g, "<br>");
3203
3258
  }
3204
- let dest = insane_1(markedContent, {
3259
+ let dest = insane$1(markedContent, {
3205
3260
  allowedClasses: {},
3206
3261
  // @refer CVE-2018-8495
3207
3262
  // @link https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-8495
@@ -3472,7 +3527,7 @@ function t(key, args = {}) {
3472
3527
  str = str.replace(/\{\s*(\w+?)\s*\}/g, (_, token) => args[token] || "");
3473
3528
  return str;
3474
3529
  }
3475
- const version = "2.5.4";
3530
+ const version = "2.6.0";
3476
3531
  class User {
3477
3532
  constructor() {
3478
3533
  __publicField(this, "ctx");
@@ -5000,8 +5055,8 @@ const defaults = {
5000
5055
  countEl: "#ArtalkCount",
5001
5056
  pvEl: "#ArtalkPV",
5002
5057
  gravatar: {
5003
- default: "mp",
5004
- mirror: "https://cravatar.cn/avatar/"
5058
+ mirror: "https://cravatar.cn/avatar/",
5059
+ params: "d=mp&s=240"
5005
5060
  },
5006
5061
  pagination: {
5007
5062
  pageSize: 20,
@@ -7458,7 +7513,7 @@ function createPlugManager(editor) {
7458
7513
  editor.getUI().$plugPanelWrap.style.display = "none";
7459
7514
  editor.getUI().$plugBtnWrap.innerHTML = "";
7460
7515
  const DISABLED = getDisabledPlugNames(editor.conf);
7461
- ENABLED_PLUGS.filter((p) => !DISABLED.includes(p.name)).forEach((Plug) => {
7516
+ ENABLED_PLUGS.filter((p) => !DISABLED.includes(p.Name)).forEach((Plug) => {
7462
7517
  initPlugItem(ctx, Plug);
7463
7518
  });
7464
7519
  return ctx;
@@ -7695,10 +7750,12 @@ function Do(m) {
7695
7750
  } catch (err) {
7696
7751
  console.error(err);
7697
7752
  m.editor.showNotify(`${m.editor.$t("commentFail")},${err.msg || String(err)}`, "e");
7753
+ return;
7754
+ } finally {
7755
+ m.editor.hideLoading();
7698
7756
  }
7699
7757
  m.editor.reset();
7700
7758
  m.editor.ctx.trigger("editor-submitted");
7701
- m.editor.hideLoading();
7702
7759
  });
7703
7760
  }
7704
7761
  function getSubmitAddParams(m) {
@@ -8244,7 +8301,7 @@ function handleStatCount(p, args) {
8244
8301
  });
8245
8302
  });
8246
8303
  }
8247
- const _Artalk = class {
8304
+ const _Artalk = class _Artalk {
8248
8305
  constructor(conf) {
8249
8306
  __publicField(this, "conf");
8250
8307
  __publicField(this, "ctx");
@@ -8370,13 +8427,13 @@ const _Artalk = class {
8370
8427
  this.loadCountWidget(conf);
8371
8428
  }
8372
8429
  };
8373
- let Artalk = _Artalk;
8374
- __publicField(Artalk, "instance");
8375
- __publicField(Artalk, "ListLite", ListLite);
8376
- __publicField(Artalk, "defaults", defaults);
8430
+ __publicField(_Artalk, "instance");
8431
+ __publicField(_Artalk, "ListLite", ListLite);
8432
+ __publicField(_Artalk, "defaults", defaults);
8377
8433
  /** Plugins */
8378
- __publicField(Artalk, "plugins", [PvCountWidget]);
8379
- __publicField(Artalk, "DisabledComponents", []);
8434
+ __publicField(_Artalk, "plugins", [PvCountWidget]);
8435
+ __publicField(_Artalk, "DisabledComponents", []);
8436
+ let Artalk = _Artalk;
8380
8437
  export {
8381
8438
  Artalk as default
8382
8439
  };