@headwall/markdown-to-blocks 1.2.0 → 1.4.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.
@@ -854,36 +854,38 @@ var require_Alias = __commonJS({
854
854
  if (node2.anchor === this.source)
855
855
  found = node2;
856
856
  }
857
+ if (found && ctx) {
858
+ const { anchors: anchors2, doc: doc2, maxAliasCount } = ctx;
859
+ let data = anchors2.get(found);
860
+ if (!data) {
861
+ toJS.toJS(found, null, ctx);
862
+ data = anchors2.get(found);
863
+ }
864
+ if (data?.res === void 0) {
865
+ const msg = "This should not happen: Alias anchor was not resolved?";
866
+ throw new ReferenceError(msg);
867
+ }
868
+ if (maxAliasCount >= 0) {
869
+ data.count += 1;
870
+ if (data.aliasCount === 0)
871
+ data.aliasCount = getAliasCount(doc2, found, anchors2);
872
+ if (data.count * data.aliasCount > maxAliasCount) {
873
+ const msg = "Excessive alias count indicates a resource exhaustion attack";
874
+ throw new ReferenceError(msg);
875
+ }
876
+ }
877
+ }
857
878
  return found;
858
879
  }
859
880
  toJSON(_arg, ctx) {
860
881
  if (!ctx)
861
882
  return { source: this.source };
862
- const { anchors: anchors2, doc, maxAliasCount } = ctx;
863
- const source = this.resolve(doc, ctx);
883
+ const source = this.resolve(ctx.doc, ctx);
864
884
  if (!source) {
865
885
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
866
886
  throw new ReferenceError(msg);
867
887
  }
868
- let data = anchors2.get(source);
869
- if (!data) {
870
- toJS.toJS(source, null, ctx);
871
- data = anchors2.get(source);
872
- }
873
- if (data?.res === void 0) {
874
- const msg = "This should not happen: Alias anchor was not resolved?";
875
- throw new ReferenceError(msg);
876
- }
877
- if (maxAliasCount >= 0) {
878
- data.count += 1;
879
- if (data.aliasCount === 0)
880
- data.aliasCount = getAliasCount(doc, source, anchors2);
881
- if (data.count * data.aliasCount > maxAliasCount) {
882
- const msg = "Excessive alias count indicates a resource exhaustion attack";
883
- throw new ReferenceError(msg);
884
- }
885
- }
886
- return data.res;
888
+ return ctx.anchors.get(source).res;
887
889
  }
888
890
  toString(ctx, _onComment, _onChompKeep) {
889
891
  const src = `*${this.source}`;
@@ -4885,37 +4887,38 @@ var require_resolve_flow_scalar = __commonJS({
4885
4887
  }
4886
4888
  if (badChar)
4887
4889
  onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
4888
- return foldLines(source);
4890
+ return unfoldLines(source);
4889
4891
  }
4890
4892
  function singleQuotedValue(source, onError) {
4891
4893
  if (source[source.length - 1] !== "'" || source.length === 1)
4892
4894
  onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
4893
- return foldLines(source.slice(1, -1)).replace(/''/g, "'");
4895
+ return unfoldLines(source.slice(1, -1)).replace(/''/g, "'");
4894
4896
  }
4895
- function foldLines(source) {
4896
- let first, line;
4897
+ function unfoldLines(source) {
4898
+ const line = /(.*?)\r?\n/sy;
4899
+ let match = line.exec(source);
4900
+ if (!match)
4901
+ return source;
4902
+ let trimEnd, trimBoth;
4897
4903
  try {
4898
- first = new RegExp("(.*?)(?<![ ])[ ]*\r?\n", "sy");
4899
- line = new RegExp("[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?\n", "sy");
4904
+ trimEnd = new RegExp("(?<![ ])[ ]+$");
4905
+ trimBoth = new RegExp("^[ ]+|(?<![ ])[ ]+$", "g");
4900
4906
  } catch {
4901
- first = /(.*?)[ \t]*\r?\n/sy;
4902
- line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
4907
+ trimEnd = /[ \t]+$/;
4908
+ trimBoth = /^[ \t]+|[ \t]+$/g;
4903
4909
  }
4904
- let match = first.exec(source);
4905
- if (!match)
4906
- return source;
4907
- let res = match[1];
4910
+ let res = match[1].replace(trimEnd, "");
4908
4911
  let sep = " ";
4909
- let pos = first.lastIndex;
4910
- line.lastIndex = pos;
4912
+ let pos = line.lastIndex;
4911
4913
  while (match = line.exec(source)) {
4912
- if (match[1] === "") {
4914
+ const lm = match[1].replace(trimBoth, "");
4915
+ if (lm === "") {
4913
4916
  if (sep === "\n")
4914
4917
  res += sep;
4915
4918
  else
4916
4919
  sep = "\n";
4917
4920
  } else {
4918
- res += sep + match[1];
4921
+ res += sep + lm;
4919
4922
  sep = " ";
4920
4923
  }
4921
4924
  pos = line.lastIndex;
@@ -7557,6 +7560,52 @@ var require_dist = __commonJS({
7557
7560
  }
7558
7561
  });
7559
7562
 
7563
+ // src/types.ts
7564
+ var CODE_LANGUAGE_MODES = ["drop", "class"];
7565
+ var UNSUPPORTED_MODES = ["html", "skip"];
7566
+ var URL_SCHEME_MODES = ["safe", "any"];
7567
+ function applyOptionDefaults(options) {
7568
+ return {
7569
+ headingShift: options?.headingShift ?? 0,
7570
+ minHeadingLevel: options?.minHeadingLevel ?? 2,
7571
+ headingAnchors: options?.headingAnchors ?? false,
7572
+ resolveImage: options?.resolveImage,
7573
+ codeLanguage: options?.codeLanguage ?? "drop",
7574
+ unsupported: options?.unsupported ?? "html",
7575
+ urlSchemes: options?.urlSchemes ?? "safe",
7576
+ gfm: options?.gfm ?? true
7577
+ };
7578
+ }
7579
+ function resolveOptions(options) {
7580
+ const resolved = applyOptionDefaults(options);
7581
+ const problems = validateOptions(resolved);
7582
+ if (problems.length > 0) {
7583
+ throw new RangeError(`invalid options:
7584
+ ${problems.join("\n ")}`);
7585
+ }
7586
+ return resolved;
7587
+ }
7588
+ function validateOptions(options) {
7589
+ const problems = [];
7590
+ if (!Number.isInteger(options.headingShift)) {
7591
+ problems.push(`headingShift must be an integer (got ${String(options.headingShift)})`);
7592
+ }
7593
+ const minLevel = options.minHeadingLevel;
7594
+ if (!Number.isInteger(minLevel) || minLevel < 1 || minLevel > 6) {
7595
+ problems.push(`minHeadingLevel must be an integer from 1 to 6 (got ${String(minLevel)})`);
7596
+ }
7597
+ if (!CODE_LANGUAGE_MODES.includes(options.codeLanguage)) {
7598
+ problems.push(`codeLanguage must be 'drop' or 'class' (got ${JSON.stringify(options.codeLanguage)})`);
7599
+ }
7600
+ if (!UNSUPPORTED_MODES.includes(options.unsupported)) {
7601
+ problems.push(`unsupported must be 'html' or 'skip' (got ${JSON.stringify(options.unsupported)})`);
7602
+ }
7603
+ if (!URL_SCHEME_MODES.includes(options.urlSchemes)) {
7604
+ problems.push(`urlSchemes must be 'safe' or 'any' (got ${JSON.stringify(options.urlSchemes)})`);
7605
+ }
7606
+ return problems;
7607
+ }
7608
+
7560
7609
  // node_modules/devlop/lib/default.js
7561
7610
  function ok() {
7562
7611
  }
@@ -8059,16 +8108,50 @@ var empty = [];
8059
8108
  var CONTINUE = true;
8060
8109
  var EXIT = false;
8061
8110
  var SKIP = "skip";
8062
- function visitParents(tree, test, visitor, reverse) {
8111
+ function visitParents(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, reverse) {
8112
+ if (!tree || typeof tree !== "object") {
8113
+ throw new Error("Unexpected value `" + tree + "` for `tree`, expected node");
8114
+ }
8115
+ let preorder = true;
8063
8116
  let check;
8064
- if (typeof test === "function" && typeof visitor !== "function") {
8065
- reverse = visitor;
8066
- visitor = test;
8117
+ let visitors;
8118
+ let enter;
8119
+ let exit3;
8120
+ if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
8121
+ check = /** @type {Test} */
8122
+ testOrEnterOrVisitors;
8123
+ visitors = enterOrVisitorsOrReverse;
8124
+ if (reverse) preorder = false;
8067
8125
  } else {
8068
- check = test;
8126
+ visitors = /** @type {Visitors | Visitor} */
8127
+ testOrEnterOrVisitors;
8128
+ if (enterOrVisitorsOrReverse) preorder = false;
8129
+ }
8130
+ if (typeof visitors === "function") {
8131
+ enter = visitors;
8132
+ } else if (visitors && typeof visitors === "object") {
8133
+ if (visitors.enter === null || visitors.enter === void 0) {
8134
+ } else if (typeof visitors.enter === "function") {
8135
+ enter = visitors.enter;
8136
+ } else {
8137
+ throw new Error(
8138
+ "Unexpected value `" + visitors.enter + "` for `visitors.enter`, expected optional visitor"
8139
+ );
8140
+ }
8141
+ if (typeof visitors.exit === "function") {
8142
+ exit3 = visitors.exit;
8143
+ } else {
8144
+ throw new Error(
8145
+ "Unexpected value `" + visitors.exit + "` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)"
8146
+ );
8147
+ }
8148
+ } else {
8149
+ throw new Error(
8150
+ "Unexpected value `" + visitors + "` for `enter` or `visitors`, expected visitor or object with visitors"
8151
+ );
8069
8152
  }
8070
8153
  const is2 = convert(check);
8071
- const step = reverse ? -1 : 1;
8154
+ const step = preorder ? 1 : -1;
8072
8155
  factory(tree, void 0, [])();
8073
8156
  function factory(node2, index2, parents) {
8074
8157
  const value2 = (
@@ -8089,12 +8172,10 @@ function visitParents(tree, test, visitor, reverse) {
8089
8172
  }
8090
8173
  return visit2;
8091
8174
  function visit2() {
8175
+ const matches = !check || is2(node2, index2, parents[parents.length - 1] || void 0);
8092
8176
  let result = empty;
8093
- let subresult;
8094
- let offset;
8095
- let grandparents;
8096
- if (!test || is2(node2, index2, parents[parents.length - 1] || void 0)) {
8097
- result = toResult(visitor(node2, parents));
8177
+ if (enter && matches) {
8178
+ result = toResult(enter(node2, parents, index2));
8098
8179
  if (result[0] === EXIT) {
8099
8180
  return result;
8100
8181
  }
@@ -8105,11 +8186,11 @@ function visitParents(tree, test, visitor, reverse) {
8105
8186
  node2
8106
8187
  );
8107
8188
  if (nodeAsParent.children && result[0] !== SKIP) {
8108
- offset = (reverse ? nodeAsParent.children.length : -1) + step;
8109
- grandparents = parents.concat(nodeAsParent);
8189
+ let offset = (preorder ? -1 : nodeAsParent.children.length) + step;
8190
+ const grandparents = [...parents, nodeAsParent];
8110
8191
  while (offset > -1 && offset < nodeAsParent.children.length) {
8111
8192
  const child = nodeAsParent.children[offset];
8112
- subresult = factory(child, offset, grandparents)();
8193
+ const subresult = factory(child, offset, grandparents)();
8113
8194
  if (subresult[0] === EXIT) {
8114
8195
  return subresult;
8115
8196
  }
@@ -8117,6 +8198,17 @@ function visitParents(tree, test, visitor, reverse) {
8117
8198
  }
8118
8199
  }
8119
8200
  }
8201
+ if (exit3 && matches) {
8202
+ const exitResult = toResult(exit3(node2, parents, index2));
8203
+ if (exitResult[0] === SKIP) {
8204
+ throw new Error(
8205
+ "Unexpected value `" + exitResult[0] + "` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing"
8206
+ );
8207
+ }
8208
+ if (exitResult[0] === EXIT || typeof exitResult[1] === "number") {
8209
+ return exitResult;
8210
+ }
8211
+ }
8120
8212
  return result;
8121
8213
  }
8122
8214
  }
@@ -8185,15 +8277,12 @@ function findAndReplace(tree, list3, options) {
8185
8277
  find.lastIndex = position2 + 1;
8186
8278
  } else {
8187
8279
  if (start !== position2) {
8188
- nodes.push({
8189
- type: "text",
8190
- value: node2.value.slice(start, position2)
8191
- });
8280
+ add({ type: "text", value: node2.value.slice(start, position2) });
8192
8281
  }
8193
8282
  if (Array.isArray(value2)) {
8194
- nodes.push(...value2);
8283
+ for (const child of value2) add(child);
8195
8284
  } else if (value2) {
8196
- nodes.push(value2);
8285
+ add(value2);
8197
8286
  }
8198
8287
  start = position2 + match[0].length;
8199
8288
  change = true;
@@ -8205,20 +8294,28 @@ function findAndReplace(tree, list3, options) {
8205
8294
  }
8206
8295
  if (change) {
8207
8296
  if (start < node2.value.length) {
8208
- nodes.push({ type: "text", value: node2.value.slice(start) });
8297
+ add({ type: "text", value: node2.value.slice(start) });
8209
8298
  }
8210
8299
  parent.children.splice(index2, 1, ...nodes);
8211
8300
  } else {
8212
8301
  nodes = [node2];
8213
8302
  }
8214
8303
  return index2 + nodes.length;
8304
+ function add(child) {
8305
+ const previous3 = nodes[nodes.length - 1];
8306
+ if (previous3 && previous3.type === "text" && child.type === "text") {
8307
+ previous3.value += child.value;
8308
+ } else {
8309
+ nodes.push(child);
8310
+ }
8311
+ }
8215
8312
  }
8216
8313
  }
8217
8314
  function toPairs(tupleOrList) {
8218
- const result = [];
8219
8315
  if (!Array.isArray(tupleOrList)) {
8220
8316
  throw new TypeError("Expected find and replace tuple or list of tuples");
8221
8317
  }
8318
+ const result = [];
8222
8319
  const list3 = !tupleOrList[0] || Array.isArray(tupleOrList[0]) ? tupleOrList : [tupleOrList];
8223
8320
  let index2 = -1;
8224
8321
  while (++index2 < list3.length) {
@@ -8513,6 +8610,7 @@ var constructsWithoutStrikethrough = [
8513
8610
  "titleQuote",
8514
8611
  "titleApostrophe"
8515
8612
  ];
8613
+ handleDelete.attention = attentionDelete;
8516
8614
  handleDelete.peek = peekDelete;
8517
8615
  function gfmStrikethroughFromMarkdown() {
8518
8616
  return {
@@ -8523,35 +8621,39 @@ function gfmStrikethroughFromMarkdown() {
8523
8621
  }
8524
8622
  function gfmStrikethroughToMarkdown() {
8525
8623
  return {
8624
+ handlers: { delete: handleDelete },
8526
8625
  unsafe: [
8527
8626
  {
8528
8627
  character: "~",
8529
8628
  inConstruct: "phrasing",
8530
8629
  notInConstruct: constructsWithoutStrikethrough
8531
8630
  }
8532
- ],
8533
- handlers: { delete: handleDelete }
8631
+ ]
8534
8632
  };
8535
8633
  }
8536
8634
  function enterStrikethrough(token) {
8537
- this.enter({ type: "delete", children: [] }, token);
8635
+ this.enter({ type: "delete", children: [], position: void 0 }, token);
8538
8636
  }
8539
8637
  function exitStrikethrough(token) {
8540
8638
  this.exit(token);
8541
8639
  }
8542
8640
  function handleDelete(node2, _, state, info) {
8543
8641
  const tracker = state.createTracker(info);
8642
+ const sequence = state.stack.includes("strikethrough") ? "~" : "~~";
8544
8643
  const exit3 = state.enter("strikethrough");
8545
- let value2 = tracker.move("~~");
8644
+ let value2 = tracker.move(sequence);
8546
8645
  value2 += state.containerPhrasing(node2, {
8547
8646
  ...tracker.current(),
8548
8647
  before: value2,
8549
8648
  after: "~"
8550
8649
  });
8551
- value2 += tracker.move("~~");
8650
+ value2 += tracker.move(sequence);
8552
8651
  exit3();
8553
8652
  return value2;
8554
8653
  }
8654
+ function attentionDelete() {
8655
+ return { construct: "strikethrough", markers: ["~"], sizes: [2, 1] };
8656
+ }
8555
8657
  function peekDelete() {
8556
8658
  return "~";
8557
8659
  }
@@ -8697,6 +8799,34 @@ function toAlignment(value2) {
8697
8799
  return code3 === 67 || code3 === 99 ? 99 : code3 === 76 || code3 === 108 ? 108 : code3 === 82 || code3 === 114 ? 114 : 0;
8698
8800
  }
8699
8801
 
8802
+ // node_modules/mdast-util-phrasing/lib/index.js
8803
+ var phrasing = (
8804
+ /** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
8805
+ convert([
8806
+ "break",
8807
+ "delete",
8808
+ "emphasis",
8809
+ // To do: next major: removed since footnotes were added to GFM.
8810
+ "footnote",
8811
+ "footnoteReference",
8812
+ "image",
8813
+ "imageReference",
8814
+ "inlineCode",
8815
+ // Enabled by `mdast-util-math`:
8816
+ "inlineMath",
8817
+ "link",
8818
+ "linkReference",
8819
+ // Enabled by `mdast-util-mdx`:
8820
+ "mdxJsxTextElement",
8821
+ // Enabled by `mdast-util-mdx`:
8822
+ "mdxTextExpression",
8823
+ "strong",
8824
+ "text",
8825
+ // Enabled by `mdast-util-directive`:
8826
+ "textDirective"
8827
+ ])
8828
+ );
8829
+
8700
8830
  // node_modules/mdast-util-to-markdown/lib/handle/blockquote.js
8701
8831
  function blockquote(node2, _, state, info) {
8702
8832
  const exit3 = state.enter("blockquote");
@@ -8738,8 +8868,9 @@ function listInScope(stack, list3, none) {
8738
8868
  function hardBreak(_, _1, state, info) {
8739
8869
  let index2 = -1;
8740
8870
  while (++index2 < state.unsafe.length) {
8741
- if (state.unsafe[index2].character === "\n" && patternInScope(state.stack, state.unsafe[index2])) {
8742
- return /[ \t]/.test(info.before) ? "" : " ";
8871
+ const pattern = state.unsafe[index2];
8872
+ if (pattern.character === "\n" && !pattern.before && !pattern.after && patternInScope(state.stack, pattern)) {
8873
+ return /[\t ]/.test(info.before) ? "" : " ";
8743
8874
  }
8744
8875
  }
8745
8876
  return "\\\n";
@@ -8774,8 +8905,8 @@ function formatCodeAsIndented(node2, state) {
8774
8905
  return Boolean(
8775
8906
  state.options.fences === false && node2.value && // If there’s no info…
8776
8907
  !node2.lang && // And there’s a non-whitespace character…
8777
- /[^ \r\n]/.test(node2.value) && // And the value doesn’t start or end in a blank…
8778
- !/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(node2.value)
8908
+ /[^\n\r ]/.test(node2.value) && // And the value doesn’t start or end in a blank…
8909
+ !/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(node2.value)
8779
8910
  );
8780
8911
  }
8781
8912
 
@@ -8794,7 +8925,6 @@ function checkFence(state) {
8794
8925
  function code(node2, _, state, info) {
8795
8926
  const marker = checkFence(state);
8796
8927
  const raw = node2.value || "";
8797
- const suffix = marker === "`" ? "GraveAccent" : "Tilde";
8798
8928
  if (formatCodeAsIndented(node2, state)) {
8799
8929
  const exit4 = state.enter("codeIndented");
8800
8930
  const value3 = state.indentLines(raw, map2);
@@ -8804,6 +8934,7 @@ function code(node2, _, state, info) {
8804
8934
  const tracker = state.createTracker(info);
8805
8935
  const sequence = marker.repeat(Math.max(longestStreak(raw, marker) + 1, 3));
8806
8936
  const exit3 = state.enter("codeFenced");
8937
+ const suffix = marker === "`" ? "GraveAccent" : "Tilde";
8807
8938
  let value2 = tracker.move(sequence);
8808
8939
  if (node2.lang) {
8809
8940
  const subexit = state.enter(`codeFencedLang${suffix}`);
@@ -8920,122 +9051,64 @@ function checkEmphasis(state) {
8920
9051
  return marker;
8921
9052
  }
8922
9053
 
8923
- // node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
8924
- function encodeCharacterReference(code3) {
8925
- return "&#x" + code3.toString(16).toUpperCase() + ";";
8926
- }
8927
-
8928
- // node_modules/micromark-util-classify-character/index.js
8929
- function classifyCharacter(code3) {
8930
- if (code3 === null || markdownLineEndingOrSpace(code3) || unicodeWhitespace(code3)) {
8931
- return 1;
8932
- }
8933
- if (unicodePunctuation(code3)) {
8934
- return 2;
8935
- }
8936
- }
8937
-
8938
- // node_modules/mdast-util-to-markdown/lib/util/encode-info.js
8939
- function encodeInfo(outside, inside, marker) {
8940
- const outsideKind = classifyCharacter(outside);
8941
- const insideKind = classifyCharacter(inside);
8942
- if (outsideKind === void 0) {
8943
- return insideKind === void 0 ? (
8944
- // Letter inside:
8945
- // we have to encode *both* letters for `_` as it is looser.
8946
- // it already forms for `*` (and GFMs `~`).
8947
- marker === "_" ? { inside: true, outside: true } : { inside: false, outside: false }
8948
- ) : insideKind === 1 ? (
8949
- // Whitespace inside: encode both (letter, whitespace).
8950
- { inside: true, outside: true }
8951
- ) : (
8952
- // Punctuation inside: encode outer (letter)
8953
- { inside: false, outside: true }
8954
- );
8955
- }
8956
- if (outsideKind === 1) {
8957
- return insideKind === void 0 ? (
8958
- // Letter inside: already forms.
8959
- { inside: false, outside: false }
8960
- ) : insideKind === 1 ? (
8961
- // Whitespace inside: encode both (whitespace).
8962
- { inside: true, outside: true }
8963
- ) : (
8964
- // Punctuation inside: already forms.
8965
- { inside: false, outside: false }
8966
- );
8967
- }
8968
- return insideKind === void 0 ? (
8969
- // Letter inside: already forms.
8970
- { inside: false, outside: false }
8971
- ) : insideKind === 1 ? (
8972
- // Whitespace inside: encode inner (whitespace).
8973
- { inside: true, outside: false }
8974
- ) : (
8975
- // Punctuation inside: already forms.
8976
- { inside: false, outside: false }
8977
- );
8978
- }
8979
-
8980
9054
  // node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
8981
- emphasis.peek = emphasisPeek;
9055
+ emphasis.attention = attention;
9056
+ emphasis.peek = peek;
8982
9057
  function emphasis(node2, _, state, info) {
8983
- const marker = checkEmphasis(state);
8984
- const exit3 = state.enter("emphasis");
8985
- const tracker = state.createTracker(info);
8986
- const before = tracker.move(marker);
8987
- let between = tracker.move(
8988
- state.containerPhrasing(node2, {
8989
- after: marker,
8990
- before,
8991
- ...tracker.current()
8992
- })
8993
- );
8994
- const betweenHead = between.charCodeAt(0);
8995
- const open = encodeInfo(
8996
- info.before.charCodeAt(info.before.length - 1),
8997
- betweenHead,
8998
- marker
8999
- );
9000
- if (open.inside) {
9001
- between = encodeCharacterReference(betweenHead) + between.slice(1);
9002
- }
9003
- const betweenTail = between.charCodeAt(between.length - 1);
9004
- const close2 = encodeInfo(info.after.charCodeAt(0), betweenTail, marker);
9005
- if (close2.inside) {
9006
- between = between.slice(0, -1) + encodeCharacterReference(betweenTail);
9007
- }
9008
- const after = tracker.move(marker);
9058
+ const exit3 = state.enter("phrasing");
9059
+ const value2 = state.containerPhrasing({ type: "root", children: [node2] }, info);
9009
9060
  exit3();
9010
- state.attentionEncodeSurroundingInfo = {
9011
- after: close2.outside,
9012
- before: open.outside
9061
+ return value2;
9062
+ }
9063
+ function attention(_, state) {
9064
+ const marker = checkEmphasis(state);
9065
+ return {
9066
+ construct: "emphasis",
9067
+ markers: marker === "*" ? ["*", "_"] : ["_", "*"],
9068
+ sizes: [1]
9013
9069
  };
9014
- return before + between + after;
9015
9070
  }
9016
- function emphasisPeek(_, _1, state) {
9071
+ function peek(_, _1, state) {
9017
9072
  return state.options.emphasis || "*";
9018
9073
  }
9019
9074
 
9075
+ // node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
9076
+ function encodeCharacterReference(code3) {
9077
+ return "&#x" + code3.toString(16).toUpperCase() + ";";
9078
+ }
9079
+
9020
9080
  // node_modules/unist-util-visit/lib/index.js
9021
- function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
9081
+ function visit(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, maybeReverse) {
9082
+ let check;
9083
+ let visitors;
9022
9084
  let reverse;
9023
- let test;
9024
- let visitor;
9025
- if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
9026
- test = void 0;
9027
- visitor = testOrVisitor;
9028
- reverse = visitorOrReverse;
9029
- } else {
9030
- test = testOrVisitor;
9031
- visitor = visitorOrReverse;
9085
+ if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
9086
+ check = /** @type {Test} */
9087
+ testOrEnterOrVisitors;
9088
+ visitors = enterOrVisitorsOrReverse;
9032
9089
  reverse = maybeReverse;
9090
+ } else {
9091
+ visitors = /** @type {Visitor | Visitors} */
9092
+ testOrEnterOrVisitors;
9093
+ reverse = enterOrVisitorsOrReverse;
9033
9094
  }
9034
- visitParents(tree, test, overload, reverse);
9035
- function overload(node2, parents) {
9036
- const parent = parents[parents.length - 1];
9037
- const index2 = parent ? parent.children.indexOf(node2) : void 0;
9038
- return visitor(node2, index2, parent);
9095
+ if (typeof visitors === "function") {
9096
+ visitParents(tree, check, wrap(visitors), reverse);
9097
+ } else {
9098
+ visitParents(tree, check, wrapVisitors(visitors), reverse);
9099
+ }
9100
+ }
9101
+ function wrapVisitors(visitors) {
9102
+ if (!visitors || typeof visitors !== "object") return visitors;
9103
+ return {
9104
+ enter: typeof visitors.enter === "function" ? wrap(visitors.enter) : visitors.enter,
9105
+ exit: typeof visitors.exit === "function" ? wrap(visitors.exit) : visitors.exit
9106
+ };
9107
+ }
9108
+ function wrap(visitor) {
9109
+ return overload;
9110
+ function overload(node2, parents, index2) {
9111
+ return visitor(node2, index2, parents[parents.length - 1]);
9039
9112
  }
9040
9113
  }
9041
9114
 
@@ -9120,8 +9193,9 @@ function heading(node2, _, state, info) {
9120
9193
  after: "\n",
9121
9194
  ...tracker.current()
9122
9195
  });
9123
- if (/^[\t ]/.test(value2)) {
9124
- value2 = encodeCharacterReference(value2.charCodeAt(0)) + value2.slice(1);
9196
+ const head = value2.charCodeAt(0);
9197
+ if (head === 9 || head === 32) {
9198
+ value2 = encodeCharacterReference(head) + value2.slice(1);
9125
9199
  }
9126
9200
  value2 = value2 ? sequence + " " + value2 : sequence;
9127
9201
  if (state.options.closeAtx) {
@@ -9214,7 +9288,9 @@ function imageReference(node2, _, state, info) {
9214
9288
  value2 += tracker.move(alt + "][");
9215
9289
  subexit();
9216
9290
  const stack = state.stack;
9217
- state.stack = [];
9291
+ state.stack = stack.filter(function(d) {
9292
+ return d !== "phrasing";
9293
+ });
9218
9294
  subexit = state.enter("reference");
9219
9295
  const reference = state.safe(state.associationId(node2), {
9220
9296
  before: value2,
@@ -9246,14 +9322,14 @@ function inlineCode(node2, _, state) {
9246
9322
  while (new RegExp("(^|[^`])" + sequence + "([^`]|$)").test(value2)) {
9247
9323
  sequence += "`";
9248
9324
  }
9249
- if (/[^ \r\n]/.test(value2) && (/^[ \r\n]/.test(value2) && /[ \r\n]$/.test(value2) || /^`|`$/.test(value2))) {
9325
+ if (/[^\n\r ]/.test(value2) && (/^[\n\r ]/.test(value2) && /[\n\r ]$/.test(value2) || /^`|`$/.test(value2))) {
9250
9326
  value2 = " " + value2 + " ";
9251
9327
  }
9252
9328
  while (++index2 < state.unsafe.length) {
9253
9329
  const pattern = state.unsafe[index2];
9254
9330
  const expression = state.compilePattern(pattern);
9255
- let match;
9256
9331
  if (!pattern.atBreak) continue;
9332
+ let match;
9257
9333
  while (match = expression.exec(value2)) {
9258
9334
  let position2 = match.index;
9259
9335
  if (value2.charCodeAt(position2) === 10 && value2.charCodeAt(position2 - 1) === 13) {
@@ -9273,11 +9349,11 @@ function formatLinkAsAutolink(node2, state) {
9273
9349
  const raw = toString(node2);
9274
9350
  return Boolean(
9275
9351
  !state.options.resourceLink && // If there’s a url…
9276
- node2.url && // And there’s a no title…
9352
+ node2.url && // And there’s no title…
9277
9353
  !node2.title && // And the content of `node` is a single text node…
9278
9354
  node2.children && node2.children.length === 1 && node2.children[0].type === "text" && // And if the url is the same as the content…
9279
9355
  (raw === node2.url || "mailto:" + raw === node2.url) && // And that starts w/ a protocol…
9280
- /^[a-z][a-z+.-]+:/i.test(node2.url) && // And that doesn’t contain ASCII control codes (character escapes and
9356
+ /^[a-z][+\-.a-z]+:/i.test(node2.url) && // And that doesn’t contain ASCII control codes (character escapes and
9281
9357
  // references don’t work), space, or angle brackets…
9282
9358
  !/[\0- <>\u007F]/.test(node2.url)
9283
9359
  );
@@ -9289,12 +9365,12 @@ function link(node2, _, state, info) {
9289
9365
  const quote = checkQuote(state);
9290
9366
  const suffix = quote === '"' ? "Quote" : "Apostrophe";
9291
9367
  const tracker = state.createTracker(info);
9292
- let exit3;
9293
- let subexit;
9294
9368
  if (formatLinkAsAutolink(node2, state)) {
9295
9369
  const stack = state.stack;
9296
- state.stack = [];
9297
- exit3 = state.enter("autolink");
9370
+ state.stack = stack.filter(function(d) {
9371
+ return d !== "phrasing";
9372
+ });
9373
+ const exit4 = state.enter("autolink");
9298
9374
  let value3 = tracker.move("<");
9299
9375
  value3 += tracker.move(
9300
9376
  state.containerPhrasing(node2, {
@@ -9304,12 +9380,12 @@ function link(node2, _, state, info) {
9304
9380
  })
9305
9381
  );
9306
9382
  value3 += tracker.move(">");
9307
- exit3();
9383
+ exit4();
9308
9384
  state.stack = stack;
9309
9385
  return value3;
9310
9386
  }
9311
- exit3 = state.enter("link");
9312
- subexit = state.enter("label");
9387
+ const exit3 = state.enter("link");
9388
+ let subexit = state.enter("label");
9313
9389
  let value2 = tracker.move("[");
9314
9390
  value2 += tracker.move(
9315
9391
  state.containerPhrasing(node2, {
@@ -9379,7 +9455,9 @@ function linkReference(node2, _, state, info) {
9379
9455
  value2 += tracker.move(text5 + "][");
9380
9456
  subexit();
9381
9457
  const stack = state.stack;
9382
- state.stack = [];
9458
+ state.stack = stack.filter(function(d) {
9459
+ return d !== "phrasing";
9460
+ });
9383
9461
  subexit = state.enter("reference");
9384
9462
  const reference = state.safe(state.associationId(node2), {
9385
9463
  before: value2,
@@ -9545,41 +9623,16 @@ function paragraph(node2, _, state, info) {
9545
9623
  return value2;
9546
9624
  }
9547
9625
 
9548
- // node_modules/mdast-util-phrasing/lib/index.js
9549
- var phrasing = (
9550
- /** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
9551
- convert([
9552
- "break",
9553
- "delete",
9554
- "emphasis",
9555
- // To do: next major: removed since footnotes were added to GFM.
9556
- "footnote",
9557
- "footnoteReference",
9558
- "image",
9559
- "imageReference",
9560
- "inlineCode",
9561
- // Enabled by `mdast-util-math`:
9562
- "inlineMath",
9563
- "link",
9564
- "linkReference",
9565
- // Enabled by `mdast-util-mdx`:
9566
- "mdxJsxTextElement",
9567
- // Enabled by `mdast-util-mdx`:
9568
- "mdxTextExpression",
9569
- "strong",
9570
- "text",
9571
- // Enabled by `mdast-util-directive`:
9572
- "textDirective"
9573
- ])
9574
- );
9575
-
9576
9626
  // node_modules/mdast-util-to-markdown/lib/handle/root.js
9577
9627
  function root(node2, _, state, info) {
9578
9628
  const hasPhrasing = node2.children.some(function(d) {
9579
9629
  return phrasing(d);
9580
9630
  });
9581
- const container = hasPhrasing ? state.containerPhrasing : state.containerFlow;
9582
- return container.call(state, node2, info);
9631
+ if (!hasPhrasing) return state.containerFlow(node2, info);
9632
+ const exit3 = state.enter("phrasing");
9633
+ const value2 = state.containerPhrasing(node2, info);
9634
+ exit3();
9635
+ return value2;
9583
9636
  }
9584
9637
 
9585
9638
  // node_modules/mdast-util-to-markdown/lib/util/check-strong.js
@@ -9594,48 +9647,35 @@ function checkStrong(state) {
9594
9647
  }
9595
9648
 
9596
9649
  // node_modules/mdast-util-to-markdown/lib/handle/strong.js
9597
- strong.peek = strongPeek;
9650
+ strong.attention = attention2;
9651
+ strong.peek = peek2;
9598
9652
  function strong(node2, _, state, info) {
9599
- const marker = checkStrong(state);
9600
- const exit3 = state.enter("strong");
9601
- const tracker = state.createTracker(info);
9602
- const before = tracker.move(marker + marker);
9603
- let between = tracker.move(
9604
- state.containerPhrasing(node2, {
9605
- after: marker,
9606
- before,
9607
- ...tracker.current()
9608
- })
9609
- );
9610
- const betweenHead = between.charCodeAt(0);
9611
- const open = encodeInfo(
9612
- info.before.charCodeAt(info.before.length - 1),
9613
- betweenHead,
9614
- marker
9615
- );
9616
- if (open.inside) {
9617
- between = encodeCharacterReference(betweenHead) + between.slice(1);
9618
- }
9619
- const betweenTail = between.charCodeAt(between.length - 1);
9620
- const close2 = encodeInfo(info.after.charCodeAt(0), betweenTail, marker);
9621
- if (close2.inside) {
9622
- between = between.slice(0, -1) + encodeCharacterReference(betweenTail);
9623
- }
9624
- const after = tracker.move(marker + marker);
9653
+ const exit3 = state.enter("phrasing");
9654
+ const value2 = state.containerPhrasing({ type: "root", children: [node2] }, info);
9625
9655
  exit3();
9626
- state.attentionEncodeSurroundingInfo = {
9627
- after: close2.outside,
9628
- before: open.outside
9656
+ return value2;
9657
+ }
9658
+ function attention2(_, state) {
9659
+ const marker = checkStrong(state);
9660
+ return {
9661
+ construct: "strong",
9662
+ markers: marker === "*" ? ["*", "_"] : ["_", "*"],
9663
+ sizes: [2]
9629
9664
  };
9630
- return before + between + after;
9631
9665
  }
9632
- function strongPeek(_, _1, state) {
9666
+ function peek2(_, _1, state) {
9633
9667
  return state.options.strong || "*";
9634
9668
  }
9635
9669
 
9636
9670
  // node_modules/mdast-util-to-markdown/lib/handle/text.js
9637
- function text(node2, _, state, info) {
9638
- return state.safe(node2.value, info);
9671
+ function text(node2, parent, state, info) {
9672
+ const siblings = parent ? parent.children : [];
9673
+ const index2 = siblings.indexOf(node2);
9674
+ return state.safe(node2.value, {
9675
+ ...info,
9676
+ afterNode: siblings[index2 + 1],
9677
+ beforeNode: siblings[index2 - 1]
9678
+ });
9639
9679
  }
9640
9680
 
9641
9681
  // node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js
@@ -9679,61 +9719,128 @@ var handle = {
9679
9719
  thematicBreak
9680
9720
  };
9681
9721
 
9682
- // node_modules/character-entities/index.js
9683
- var characterEntities = {
9684
- AElig: "\xC6",
9685
- AMP: "&",
9686
- Aacute: "\xC1",
9687
- Abreve: "\u0102",
9688
- Acirc: "\xC2",
9689
- Acy: "\u0410",
9690
- Afr: "\u{1D504}",
9691
- Agrave: "\xC0",
9692
- Alpha: "\u0391",
9693
- Amacr: "\u0100",
9694
- And: "\u2A53",
9695
- Aogon: "\u0104",
9696
- Aopf: "\u{1D538}",
9697
- ApplyFunction: "\u2061",
9698
- Aring: "\xC5",
9699
- Ascr: "\u{1D49C}",
9700
- Assign: "\u2254",
9701
- Atilde: "\xC3",
9702
- Auml: "\xC4",
9703
- Backslash: "\u2216",
9704
- Barv: "\u2AE7",
9705
- Barwed: "\u2306",
9706
- Bcy: "\u0411",
9707
- Because: "\u2235",
9708
- Bernoullis: "\u212C",
9709
- Beta: "\u0392",
9710
- Bfr: "\u{1D505}",
9711
- Bopf: "\u{1D539}",
9712
- Breve: "\u02D8",
9713
- Bscr: "\u212C",
9714
- Bumpeq: "\u224E",
9715
- CHcy: "\u0427",
9716
- COPY: "\xA9",
9717
- Cacute: "\u0106",
9718
- Cap: "\u22D2",
9719
- CapitalDifferentialD: "\u2145",
9720
- Cayleys: "\u212D",
9721
- Ccaron: "\u010C",
9722
- Ccedil: "\xC7",
9723
- Ccirc: "\u0108",
9724
- Cconint: "\u2230",
9725
- Cdot: "\u010A",
9726
- Cedilla: "\xB8",
9727
- CenterDot: "\xB7",
9728
- Cfr: "\u212D",
9729
- Chi: "\u03A7",
9730
- CircleDot: "\u2299",
9731
- CircleMinus: "\u2296",
9732
- CirclePlus: "\u2295",
9733
- CircleTimes: "\u2297",
9734
- ClockwiseContourIntegral: "\u2232",
9735
- CloseCurlyDoubleQuote: "\u201D",
9736
- CloseCurlyQuote: "\u2019",
9722
+ // node_modules/micromark-util-html-tag-name/index.js
9723
+ var htmlBlockNames = [
9724
+ "address",
9725
+ "article",
9726
+ "aside",
9727
+ "base",
9728
+ "basefont",
9729
+ "blockquote",
9730
+ "body",
9731
+ "caption",
9732
+ "center",
9733
+ "col",
9734
+ "colgroup",
9735
+ "dd",
9736
+ "details",
9737
+ "dialog",
9738
+ "dir",
9739
+ "div",
9740
+ "dl",
9741
+ "dt",
9742
+ "fieldset",
9743
+ "figcaption",
9744
+ "figure",
9745
+ "footer",
9746
+ "form",
9747
+ "frame",
9748
+ "frameset",
9749
+ "h1",
9750
+ "h2",
9751
+ "h3",
9752
+ "h4",
9753
+ "h5",
9754
+ "h6",
9755
+ "head",
9756
+ "header",
9757
+ "hr",
9758
+ "html",
9759
+ "iframe",
9760
+ "legend",
9761
+ "li",
9762
+ "link",
9763
+ "main",
9764
+ "menu",
9765
+ "menuitem",
9766
+ "nav",
9767
+ "noframes",
9768
+ "ol",
9769
+ "optgroup",
9770
+ "option",
9771
+ "p",
9772
+ "param",
9773
+ "search",
9774
+ "section",
9775
+ "summary",
9776
+ "table",
9777
+ "tbody",
9778
+ "td",
9779
+ "tfoot",
9780
+ "th",
9781
+ "thead",
9782
+ "title",
9783
+ "tr",
9784
+ "track",
9785
+ "ul"
9786
+ ];
9787
+ var htmlRawNames = ["pre", "script", "style", "textarea"];
9788
+
9789
+ // node_modules/character-entities/index.js
9790
+ var characterEntities = {
9791
+ AElig: "\xC6",
9792
+ AMP: "&",
9793
+ Aacute: "\xC1",
9794
+ Abreve: "\u0102",
9795
+ Acirc: "\xC2",
9796
+ Acy: "\u0410",
9797
+ Afr: "\u{1D504}",
9798
+ Agrave: "\xC0",
9799
+ Alpha: "\u0391",
9800
+ Amacr: "\u0100",
9801
+ And: "\u2A53",
9802
+ Aogon: "\u0104",
9803
+ Aopf: "\u{1D538}",
9804
+ ApplyFunction: "\u2061",
9805
+ Aring: "\xC5",
9806
+ Ascr: "\u{1D49C}",
9807
+ Assign: "\u2254",
9808
+ Atilde: "\xC3",
9809
+ Auml: "\xC4",
9810
+ Backslash: "\u2216",
9811
+ Barv: "\u2AE7",
9812
+ Barwed: "\u2306",
9813
+ Bcy: "\u0411",
9814
+ Because: "\u2235",
9815
+ Bernoullis: "\u212C",
9816
+ Beta: "\u0392",
9817
+ Bfr: "\u{1D505}",
9818
+ Bopf: "\u{1D539}",
9819
+ Breve: "\u02D8",
9820
+ Bscr: "\u212C",
9821
+ Bumpeq: "\u224E",
9822
+ CHcy: "\u0427",
9823
+ COPY: "\xA9",
9824
+ Cacute: "\u0106",
9825
+ Cap: "\u22D2",
9826
+ CapitalDifferentialD: "\u2145",
9827
+ Cayleys: "\u212D",
9828
+ Ccaron: "\u010C",
9829
+ Ccedil: "\xC7",
9830
+ Ccirc: "\u0108",
9831
+ Cconint: "\u2230",
9832
+ Cdot: "\u010A",
9833
+ Cedilla: "\xB8",
9834
+ CenterDot: "\xB7",
9835
+ Cfr: "\u212D",
9836
+ Chi: "\u03A7",
9837
+ CircleDot: "\u2299",
9838
+ CircleMinus: "\u2296",
9839
+ CirclePlus: "\u2295",
9840
+ CircleTimes: "\u2297",
9841
+ ClockwiseContourIntegral: "\u2232",
9842
+ CloseCurlyDoubleQuote: "\u201D",
9843
+ CloseCurlyQuote: "\u2019",
9737
9844
  Colon: "\u2237",
9738
9845
  Colone: "\u2A74",
9739
9846
  Congruent: "\u2261",
@@ -11850,6 +11957,16 @@ function decode($0, $1, $2) {
11850
11957
  return decodeNamedCharacterReference($2) || $0;
11851
11958
  }
11852
11959
 
11960
+ // node_modules/micromark-util-classify-character/index.js
11961
+ function classifyCharacter(code3) {
11962
+ if (code3 === null || markdownLineEndingOrSpace(code3) || unicodeWhitespace(code3)) {
11963
+ return 1;
11964
+ }
11965
+ if (unicodePunctuation(code3)) {
11966
+ return 2;
11967
+ }
11968
+ }
11969
+
11853
11970
  // node_modules/mdast-util-gfm-table/lib/index.js
11854
11971
  function gfmTableFromMarkdown() {
11855
11972
  return {
@@ -12529,31 +12646,24 @@ function resolveAll(constructs2, events, context) {
12529
12646
  }
12530
12647
 
12531
12648
  // node_modules/micromark-core-commonmark/lib/attention.js
12532
- var attention = {
12649
+ var attention3 = {
12533
12650
  name: "attention",
12534
12651
  resolveAll: resolveAllAttention,
12535
12652
  tokenize: tokenizeAttention
12536
12653
  };
12537
12654
  function resolveAllAttention(events, context) {
12538
12655
  let index2 = -1;
12539
- let open;
12540
- let group;
12541
- let text5;
12542
- let openingSequence;
12543
- let closingSequence;
12544
- let use;
12545
12656
  let nextEvents;
12546
- let offset;
12547
12657
  while (++index2 < events.length) {
12548
12658
  if (events[index2][0] === "enter" && events[index2][1].type === "attentionSequence" && events[index2][1]._close) {
12549
- open = index2;
12659
+ let open = index2;
12550
12660
  while (open--) {
12551
12661
  if (events[open][0] === "exit" && events[open][1].type === "attentionSequence" && events[open][1]._open && // If the markers are the same:
12552
12662
  context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index2][1]).charCodeAt(0)) {
12553
12663
  if ((events[open][1]._close || events[index2][1]._open) && (events[index2][1].end.offset - events[index2][1].start.offset) % 3 && !((events[open][1].end.offset - events[open][1].start.offset + events[index2][1].end.offset - events[index2][1].start.offset) % 3)) {
12554
12664
  continue;
12555
12665
  }
12556
- use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index2][1].end.offset - events[index2][1].start.offset > 1 ? 2 : 1;
12666
+ const use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index2][1].end.offset - events[index2][1].start.offset > 1 ? 2 : 1;
12557
12667
  const start = {
12558
12668
  ...events[open][1].end
12559
12669
  };
@@ -12562,21 +12672,21 @@ function resolveAllAttention(events, context) {
12562
12672
  };
12563
12673
  movePoint(start, -use);
12564
12674
  movePoint(end, use);
12565
- openingSequence = {
12675
+ const openingSequence = {
12566
12676
  type: use > 1 ? "strongSequence" : "emphasisSequence",
12567
12677
  start,
12568
12678
  end: {
12569
12679
  ...events[open][1].end
12570
12680
  }
12571
12681
  };
12572
- closingSequence = {
12682
+ const closingSequence = {
12573
12683
  type: use > 1 ? "strongSequence" : "emphasisSequence",
12574
12684
  start: {
12575
12685
  ...events[index2][1].start
12576
12686
  },
12577
12687
  end
12578
12688
  };
12579
- text5 = {
12689
+ const text5 = {
12580
12690
  type: use > 1 ? "strongText" : "emphasisText",
12581
12691
  start: {
12582
12692
  ...events[open][1].end
@@ -12585,7 +12695,7 @@ function resolveAllAttention(events, context) {
12585
12695
  ...events[index2][1].start
12586
12696
  }
12587
12697
  };
12588
- group = {
12698
+ const group = {
12589
12699
  type: use > 1 ? "strong" : "emphasis",
12590
12700
  start: {
12591
12701
  ...openingSequence.start
@@ -12607,11 +12717,10 @@ function resolveAllAttention(events, context) {
12607
12717
  nextEvents = push(nextEvents, [["enter", group, context], ["enter", openingSequence, context], ["exit", openingSequence, context], ["enter", text5, context]]);
12608
12718
  nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index2), context));
12609
12719
  nextEvents = push(nextEvents, [["exit", text5, context], ["enter", closingSequence, context], ["exit", closingSequence, context], ["exit", group, context]]);
12720
+ let offset = 0;
12610
12721
  if (events[index2][1].end.offset - events[index2][1].start.offset) {
12611
12722
  offset = 2;
12612
12723
  nextEvents = push(nextEvents, [["enter", events[index2][1], context], ["exit", events[index2][1], context]]);
12613
- } else {
12614
- offset = 0;
12615
12724
  }
12616
12725
  splice(events, open - 1, index2 - open + 3, nextEvents);
12617
12726
  index2 = open + nextEvents.length - offset - 2;
@@ -12646,8 +12755,8 @@ function tokenizeAttention(effects, ok3) {
12646
12755
  }
12647
12756
  const token = effects.exit("attentionSequence");
12648
12757
  const after = classifyCharacter(code3);
12649
- const open = !after || after === 2 && before || attentionMarkers2.includes(code3);
12650
- const close2 = !before || before === 2 && after || attentionMarkers2.includes(previous3);
12758
+ const open = !after || after === 2 && before || attentionMarkers2.includes(code3) && code3 !== 42 && code3 !== 95;
12759
+ const close2 = !before || before === 2 && after || attentionMarkers2.includes(previous3) && previous3 !== 42 && previous3 !== 95;
12651
12760
  token._open = Boolean(marker === 42 ? open : open && (before || !close2));
12652
12761
  token._close = Boolean(marker === 42 ? close2 : close2 && (after || !open));
12653
12762
  return ok3(code3);
@@ -12762,7 +12871,7 @@ function tokenizeAutolink(effects, ok3, nok) {
12762
12871
 
12763
12872
  // node_modules/micromark-factory-space/index.js
12764
12873
  function factorySpace(effects, ok3, type, max) {
12765
- const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
12874
+ const limit = max ? max - 1 : Infinity;
12766
12875
  let size = 0;
12767
12876
  return start;
12768
12877
  function start(code3) {
@@ -12781,6 +12890,29 @@ function factorySpace(effects, ok3, type, max) {
12781
12890
  return ok3(code3);
12782
12891
  }
12783
12892
  }
12893
+ function factorySpaceMinMax(effects, ok3, nok, type, min, max) {
12894
+ let size = 0;
12895
+ return start;
12896
+ function start(code3) {
12897
+ if (max > 0 && markdownSpace(code3)) {
12898
+ effects.enter(type);
12899
+ return prefix(code3);
12900
+ }
12901
+ return after(code3);
12902
+ }
12903
+ function prefix(code3) {
12904
+ if (markdownSpace(code3) && size < max) {
12905
+ effects.consume(code3);
12906
+ size++;
12907
+ return prefix;
12908
+ }
12909
+ effects.exit(type);
12910
+ return after(code3);
12911
+ }
12912
+ function after(code3) {
12913
+ return size >= min ? ok3(code3) : nok(code3);
12914
+ }
12915
+ }
12784
12916
 
12785
12917
  // node_modules/micromark-core-commonmark/lib/blank-line.js
12786
12918
  var blankLine = {
@@ -12946,11 +13078,29 @@ function tokenizeCharacterReference(effects, ok3, nok) {
12946
13078
  }
12947
13079
  }
12948
13080
 
12949
- // node_modules/micromark-core-commonmark/lib/code-fenced.js
13081
+ // node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.js
12950
13082
  var nonLazyContinuation = {
12951
13083
  partial: true,
12952
13084
  tokenize: tokenizeNonLazyContinuation
12953
13085
  };
13086
+ function tokenizeNonLazyContinuation(effects, ok3, nok) {
13087
+ const self = this;
13088
+ return start;
13089
+ function start(code3) {
13090
+ if (code3 === null) {
13091
+ return nok(code3);
13092
+ }
13093
+ effects.enter("lineEnding");
13094
+ effects.consume(code3);
13095
+ effects.exit("lineEnding");
13096
+ return after;
13097
+ }
13098
+ function after(code3) {
13099
+ return self.parser.lazy[self.now().line] ? nok(code3) : ok3(code3);
13100
+ }
13101
+ }
13102
+
13103
+ // node_modules/micromark-core-commonmark/lib/code-fenced.js
12954
13104
  var codeFenced = {
12955
13105
  concrete: true,
12956
13106
  name: "codeFenced",
@@ -13112,22 +13262,6 @@ function tokenizeCodeFenced(effects, ok3, nok) {
13112
13262
  }
13113
13263
  }
13114
13264
  }
13115
- function tokenizeNonLazyContinuation(effects, ok3, nok) {
13116
- const self = this;
13117
- return start;
13118
- function start(code3) {
13119
- if (code3 === null) {
13120
- return nok(code3);
13121
- }
13122
- effects.enter("lineEnding");
13123
- effects.consume(code3);
13124
- effects.exit("lineEnding");
13125
- return lineStart;
13126
- }
13127
- function lineStart(code3) {
13128
- return self.parser.lazy[self.now().line] ? nok(code3) : ok3(code3);
13129
- }
13130
- }
13131
13265
 
13132
13266
  // node_modules/micromark-core-commonmark/lib/code-indented.js
13133
13267
  var codeIndented = {
@@ -13139,15 +13273,10 @@ var furtherStart = {
13139
13273
  tokenize: tokenizeFurtherStart
13140
13274
  };
13141
13275
  function tokenizeCodeIndented(effects, ok3, nok) {
13142
- const self = this;
13143
13276
  return start;
13144
13277
  function start(code3) {
13145
13278
  effects.enter("codeIndented");
13146
- return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code3);
13147
- }
13148
- function afterPrefix(code3) {
13149
- const tail = self.events[self.events.length - 1];
13150
- return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? atBreak(code3) : nok(code3);
13279
+ return factorySpaceMinMax(effects, atBreak, nok, "linePrefix", 4, 4)(code3);
13151
13280
  }
13152
13281
  function atBreak(code3) {
13153
13282
  if (code3 === null) {
@@ -13185,11 +13314,10 @@ function tokenizeFurtherStart(effects, ok3, nok) {
13185
13314
  effects.exit("lineEnding");
13186
13315
  return furtherStart2;
13187
13316
  }
13188
- return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code3);
13317
+ return factorySpaceMinMax(effects, ok3, onNotEnoughPrefix, "linePrefix", 4, 4)(code3);
13189
13318
  }
13190
- function afterPrefix(code3) {
13191
- const tail = self.events[self.events.length - 1];
13192
- return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? ok3(code3) : markdownLineEnding(code3) ? furtherStart2(code3) : nok(code3);
13319
+ function onNotEnoughPrefix(code3) {
13320
+ return markdownLineEnding(code3) ? furtherStart2(code3) : nok(code3);
13193
13321
  }
13194
13322
  }
13195
13323
 
@@ -14075,8 +14203,6 @@ var headingAtx = {
14075
14203
  function resolveHeadingAtx(events, context) {
14076
14204
  let contentEnd = events.length - 2;
14077
14205
  let contentStart = 3;
14078
- let content3;
14079
- let text5;
14080
14206
  if (events[contentStart][1].type === "whitespace") {
14081
14207
  contentStart += 2;
14082
14208
  }
@@ -14087,12 +14213,12 @@ function resolveHeadingAtx(events, context) {
14087
14213
  contentEnd -= contentStart + 1 === contentEnd ? 2 : 4;
14088
14214
  }
14089
14215
  if (contentEnd > contentStart) {
14090
- content3 = {
14216
+ const content3 = {
14091
14217
  type: "atxHeadingText",
14092
14218
  start: events[contentStart][1].start,
14093
14219
  end: events[contentEnd][1].end
14094
14220
  };
14095
- text5 = {
14221
+ const text5 = {
14096
14222
  type: "chunkText",
14097
14223
  start: events[contentStart][1].start,
14098
14224
  end: events[contentEnd][1].end,
@@ -14152,77 +14278,10 @@ function tokenizeHeadingAtx(effects, ok3, nok) {
14152
14278
  effects.exit("atxHeadingText");
14153
14279
  return atBreak(code3);
14154
14280
  }
14155
- effects.consume(code3);
14156
- return data;
14157
- }
14158
- }
14159
-
14160
- // node_modules/micromark-util-html-tag-name/index.js
14161
- var htmlBlockNames = [
14162
- "address",
14163
- "article",
14164
- "aside",
14165
- "base",
14166
- "basefont",
14167
- "blockquote",
14168
- "body",
14169
- "caption",
14170
- "center",
14171
- "col",
14172
- "colgroup",
14173
- "dd",
14174
- "details",
14175
- "dialog",
14176
- "dir",
14177
- "div",
14178
- "dl",
14179
- "dt",
14180
- "fieldset",
14181
- "figcaption",
14182
- "figure",
14183
- "footer",
14184
- "form",
14185
- "frame",
14186
- "frameset",
14187
- "h1",
14188
- "h2",
14189
- "h3",
14190
- "h4",
14191
- "h5",
14192
- "h6",
14193
- "head",
14194
- "header",
14195
- "hr",
14196
- "html",
14197
- "iframe",
14198
- "legend",
14199
- "li",
14200
- "link",
14201
- "main",
14202
- "menu",
14203
- "menuitem",
14204
- "nav",
14205
- "noframes",
14206
- "ol",
14207
- "optgroup",
14208
- "option",
14209
- "p",
14210
- "param",
14211
- "search",
14212
- "section",
14213
- "summary",
14214
- "table",
14215
- "tbody",
14216
- "td",
14217
- "tfoot",
14218
- "th",
14219
- "thead",
14220
- "title",
14221
- "tr",
14222
- "track",
14223
- "ul"
14224
- ];
14225
- var htmlRawNames = ["pre", "script", "style", "textarea"];
14281
+ effects.consume(code3);
14282
+ return data;
14283
+ }
14284
+ }
14226
14285
 
14227
14286
  // node_modules/micromark-core-commonmark/lib/html-flow.js
14228
14287
  var htmlFlow = {
@@ -14235,10 +14294,6 @@ var blankLineBefore = {
14235
14294
  partial: true,
14236
14295
  tokenize: tokenizeBlankLineBefore
14237
14296
  };
14238
- var nonLazyContinuationStart = {
14239
- partial: true,
14240
- tokenize: tokenizeNonLazyContinuationStart
14241
- };
14242
14297
  function resolveToHtmlFlow(events) {
14243
14298
  let index2 = events.length;
14244
14299
  while (index2--) {
@@ -14500,7 +14555,7 @@ function tokenizeHtmlFlow(effects, ok3, nok) {
14500
14555
  return continuation;
14501
14556
  }
14502
14557
  function continuationStart(code3) {
14503
- return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code3);
14558
+ return effects.check(nonLazyContinuation, continuationStartNonLazy, continuationAfter)(code3);
14504
14559
  }
14505
14560
  function continuationStartNonLazy(code3) {
14506
14561
  effects.enter("lineEnding");
@@ -14577,22 +14632,6 @@ function tokenizeHtmlFlow(effects, ok3, nok) {
14577
14632
  return ok3(code3);
14578
14633
  }
14579
14634
  }
14580
- function tokenizeNonLazyContinuationStart(effects, ok3, nok) {
14581
- const self = this;
14582
- return start;
14583
- function start(code3) {
14584
- if (markdownLineEnding(code3)) {
14585
- effects.enter("lineEnding");
14586
- effects.consume(code3);
14587
- effects.exit("lineEnding");
14588
- return after;
14589
- }
14590
- return nok(code3);
14591
- }
14592
- function after(code3) {
14593
- return self.parser.lazy[self.now().line] ? nok(code3) : ok3(code3);
14594
- }
14595
- }
14596
14635
  function tokenizeBlankLineBefore(effects, ok3, nok) {
14597
14636
  return start;
14598
14637
  function start(code3) {
@@ -14945,12 +14984,11 @@ function resolveAllLabelEnd(events) {
14945
14984
  function resolveToLabelEnd(events, context) {
14946
14985
  let index2 = events.length;
14947
14986
  let offset = 0;
14948
- let token;
14949
14987
  let open;
14950
14988
  let close2;
14951
14989
  let media;
14952
14990
  while (index2--) {
14953
- token = events[index2][1];
14991
+ const token = events[index2][1];
14954
14992
  if (open) {
14955
14993
  if (token.type === "link" || token.type === "labelLink" && token._inactive) {
14956
14994
  break;
@@ -15009,14 +15047,14 @@ function resolveToLabelEnd(events, context) {
15009
15047
  }
15010
15048
  function tokenizeLabelEnd(effects, ok3, nok) {
15011
15049
  const self = this;
15012
- let index2 = self.events.length;
15050
+ const labelStarts = self._labelStarts;
15013
15051
  let labelStart;
15014
15052
  let defined;
15015
- while (index2--) {
15016
- if ((self.events[index2][1].type === "labelImage" || self.events[index2][1].type === "labelLink") && !self.events[index2][1]._balanced) {
15017
- labelStart = self.events[index2][1];
15018
- break;
15053
+ if (labelStarts) {
15054
+ while (labelStarts.length > 0 && labelStarts[labelStarts.length - 1]._balanced) {
15055
+ labelStarts.pop();
15019
15056
  }
15057
+ labelStart = labelStarts[labelStarts.length - 1];
15020
15058
  }
15021
15059
  return start;
15022
15060
  function start(code3) {
@@ -15050,6 +15088,7 @@ function tokenizeLabelEnd(effects, ok3, nok) {
15050
15088
  return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code3);
15051
15089
  }
15052
15090
  function labelEndOk(code3) {
15091
+ labelStarts.pop();
15053
15092
  return ok3(code3);
15054
15093
  }
15055
15094
  function labelEndNok(code3) {
@@ -15143,6 +15182,7 @@ var labelStartImage = {
15143
15182
  };
15144
15183
  function tokenizeLabelStartImage(effects, ok3, nok) {
15145
15184
  const self = this;
15185
+ let labelImage;
15146
15186
  return start;
15147
15187
  function start(code3) {
15148
15188
  effects.enter("labelImage");
@@ -15156,13 +15196,18 @@ function tokenizeLabelStartImage(effects, ok3, nok) {
15156
15196
  effects.enter("labelMarker");
15157
15197
  effects.consume(code3);
15158
15198
  effects.exit("labelMarker");
15159
- effects.exit("labelImage");
15199
+ labelImage = effects.exit("labelImage");
15160
15200
  return after;
15161
15201
  }
15162
15202
  return nok(code3);
15163
15203
  }
15164
15204
  function after(code3) {
15165
- return code3 === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code3) : ok3(code3);
15205
+ if (code3 === 94 && "_hiddenFootnoteSupport" in self.parser.constructs) {
15206
+ return nok(code3);
15207
+ }
15208
+ self._labelStarts = self._labelStarts || [];
15209
+ self._labelStarts.push(labelImage);
15210
+ return ok3(code3);
15166
15211
  }
15167
15212
  }
15168
15213
 
@@ -15174,17 +15219,23 @@ var labelStartLink = {
15174
15219
  };
15175
15220
  function tokenizeLabelStartLink(effects, ok3, nok) {
15176
15221
  const self = this;
15222
+ let labelLink;
15177
15223
  return start;
15178
15224
  function start(code3) {
15179
15225
  effects.enter("labelLink");
15180
15226
  effects.enter("labelMarker");
15181
15227
  effects.consume(code3);
15182
15228
  effects.exit("labelMarker");
15183
- effects.exit("labelLink");
15229
+ labelLink = effects.exit("labelLink");
15184
15230
  return after;
15185
15231
  }
15186
15232
  function after(code3) {
15187
- return code3 === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code3) : ok3(code3);
15233
+ if (code3 === 94 && "_hiddenFootnoteSupport" in self.parser.constructs) {
15234
+ return nok(code3);
15235
+ }
15236
+ self._labelStarts = self._labelStarts || [];
15237
+ self._labelStarts.push(labelLink);
15238
+ return ok3(code3);
15188
15239
  }
15189
15240
  }
15190
15241
 
@@ -15372,6 +15423,104 @@ function tokenizeListItemPrefixWhitespace(effects, ok3, nok) {
15372
15423
  }
15373
15424
  }
15374
15425
 
15426
+ // node_modules/micromark-util-edit-map/index.js
15427
+ var EditMap = class {
15428
+ /**
15429
+ * Create a new edit map.
15430
+ *
15431
+ * @returns
15432
+ * New instance.
15433
+ */
15434
+ constructor() {
15435
+ this.index = /* @__PURE__ */ new Map();
15436
+ this.map = [];
15437
+ }
15438
+ /**
15439
+ * Create an edit: a remove and/or add at a certain place.
15440
+ *
15441
+ * @param {number} index
15442
+ * Index at which to apply the edit.
15443
+ * @param {number} remove
15444
+ * Count of items to remove at the index.
15445
+ * @param {Array<Event>} add
15446
+ * Items to add at the index.
15447
+ * @returns {undefined}
15448
+ * Nothing.
15449
+ */
15450
+ add(index2, remove, add) {
15451
+ addImplementation(this, index2, remove, add, false);
15452
+ }
15453
+ /**
15454
+ * Create an edit: but insert `add` before existing additions, instead of
15455
+ * after them.
15456
+ *
15457
+ * @param {number} index
15458
+ * Index at which to apply the edit.
15459
+ * @param {number} remove
15460
+ * Count of items to remove at the index.
15461
+ * @param {Array<Event>} add
15462
+ * Items to add at the index.
15463
+ * @returns {undefined}
15464
+ * Nothing.
15465
+ */
15466
+ addBefore(index2, remove, add) {
15467
+ addImplementation(this, index2, remove, add, true);
15468
+ }
15469
+ /**
15470
+ * Done, change the events.
15471
+ *
15472
+ * @param {Array<Event>} events
15473
+ * List of events to apply the edits to.
15474
+ * @returns {undefined}
15475
+ * Nothing.
15476
+ */
15477
+ consume(events) {
15478
+ this.map.sort(function(a, b) {
15479
+ return a[0] - b[0];
15480
+ });
15481
+ if (this.map.length === 0) {
15482
+ return;
15483
+ }
15484
+ let index2 = this.map.length;
15485
+ const vecs = [];
15486
+ while (index2 > 0) {
15487
+ index2 -= 1;
15488
+ vecs.push(events.slice(this.map[index2][0] + this.map[index2][1]), this.map[index2][2]);
15489
+ events.length = this.map[index2][0];
15490
+ }
15491
+ vecs.push(events.slice());
15492
+ events.length = 0;
15493
+ let slice = vecs.pop();
15494
+ while (slice) {
15495
+ for (const element of slice) {
15496
+ events.push(element);
15497
+ }
15498
+ slice = vecs.pop();
15499
+ }
15500
+ this.map.length = 0;
15501
+ this.index.clear();
15502
+ }
15503
+ };
15504
+ function addImplementation(editMap, at, remove, add, before) {
15505
+ if (remove === 0 && add.length === 0) {
15506
+ return;
15507
+ }
15508
+ const existing = editMap.index.get(at);
15509
+ if (existing) {
15510
+ existing[1] += remove;
15511
+ if (before) {
15512
+ add.push(...existing[2]);
15513
+ existing[2] = add;
15514
+ } else {
15515
+ existing[2].push(...add);
15516
+ }
15517
+ return;
15518
+ }
15519
+ const change = [at, remove, add];
15520
+ editMap.map.push(change);
15521
+ editMap.index.set(at, change);
15522
+ }
15523
+
15375
15524
  // node_modules/micromark-core-commonmark/lib/setext-underline.js
15376
15525
  var setextUnderline = {
15377
15526
  name: "setextUnderline",
@@ -15379,6 +15528,7 @@ var setextUnderline = {
15379
15528
  tokenize: tokenizeSetextUnderline
15380
15529
  };
15381
15530
  function resolveToSetextUnderline(events, context) {
15531
+ const editMap = new EditMap();
15382
15532
  let index2 = events.length;
15383
15533
  let content3;
15384
15534
  let text5;
@@ -15394,7 +15544,7 @@ function resolveToSetextUnderline(events, context) {
15394
15544
  }
15395
15545
  } else {
15396
15546
  if (events[index2][1].type === "content") {
15397
- events.splice(index2, 1);
15547
+ editMap.add(index2, 1, []);
15398
15548
  }
15399
15549
  if (!definition3 && events[index2][1].type === "definition") {
15400
15550
  definition3 = index2;
@@ -15412,15 +15562,16 @@ function resolveToSetextUnderline(events, context) {
15412
15562
  };
15413
15563
  events[text5][1].type = "setextHeadingText";
15414
15564
  if (definition3) {
15415
- events.splice(text5, 0, ["enter", heading2, context]);
15416
- events.splice(definition3 + 1, 0, ["exit", events[content3][1], context]);
15565
+ editMap.add(text5, 0, [["enter", heading2, context]]);
15566
+ editMap.add(definition3 + 1, 0, [["exit", events[content3][1], context]]);
15417
15567
  events[content3][1].end = {
15418
15568
  ...events[definition3][1].end
15419
15569
  };
15420
15570
  } else {
15421
15571
  events[content3][1] = heading2;
15422
15572
  }
15423
- events.push(["exit", heading2, context]);
15573
+ editMap.add(events.length, 0, [["exit", heading2, context]]);
15574
+ editMap.consume(events);
15424
15575
  return events;
15425
15576
  }
15426
15577
  function tokenizeSetextUnderline(effects, ok3, nok) {
@@ -15834,23 +15985,28 @@ function gfmStrikethrough(options) {
15834
15985
  }
15835
15986
 
15836
15987
  // node_modules/micromark-extension-gfm-table/lib/edit-map.js
15837
- var EditMap = class {
15988
+ var EditMap2 = class {
15838
15989
  /**
15839
15990
  * Create a new edit map.
15840
15991
  */
15841
15992
  constructor() {
15842
15993
  this.map = [];
15994
+ this.index = /* @__PURE__ */ new Map();
15843
15995
  }
15844
15996
  /**
15845
15997
  * Create an edit: a remove and/or add at a certain place.
15846
15998
  *
15847
15999
  * @param {number} index
16000
+ * Index at which to apply the edit.
15848
16001
  * @param {number} remove
16002
+ * Count of items to remove at the index.
15849
16003
  * @param {Array<Event>} add
16004
+ * Items to add at the index.
15850
16005
  * @returns {undefined}
16006
+ * Nothing.
15851
16007
  */
15852
16008
  add(index2, remove, add) {
15853
- addImplementation(this, index2, remove, add);
16009
+ addImplementation2(this, index2, remove, add);
15854
16010
  }
15855
16011
  // To do: add this when moving to `micromark`.
15856
16012
  // /**
@@ -15868,7 +16024,9 @@ var EditMap = class {
15868
16024
  * Done, change the events.
15869
16025
  *
15870
16026
  * @param {Array<Event>} events
16027
+ * List of events to apply the edits to.
15871
16028
  * @returns {undefined}
16029
+ * Nothing.
15872
16030
  */
15873
16031
  consume(events) {
15874
16032
  this.map.sort(function(a, b) {
@@ -15894,22 +16052,22 @@ var EditMap = class {
15894
16052
  slice = vecs.pop();
15895
16053
  }
15896
16054
  this.map.length = 0;
16055
+ this.index.clear();
15897
16056
  }
15898
16057
  };
15899
- function addImplementation(editMap, at, remove, add) {
15900
- let index2 = 0;
16058
+ function addImplementation2(editMap, at, remove, add) {
15901
16059
  if (remove === 0 && add.length === 0) {
15902
16060
  return;
15903
16061
  }
15904
- while (index2 < editMap.map.length) {
15905
- if (editMap.map[index2][0] === at) {
15906
- editMap.map[index2][1] += remove;
15907
- editMap.map[index2][2].push(...add);
15908
- return;
15909
- }
15910
- index2 += 1;
16062
+ const existing = editMap.index.get(at);
16063
+ if (existing) {
16064
+ existing[1] += remove;
16065
+ existing[2].push(...add);
16066
+ return;
15911
16067
  }
15912
- editMap.map.push([at, remove, add]);
16068
+ const change = [at, remove, add];
16069
+ editMap.map.push(change);
16070
+ editMap.index.set(at, change);
15913
16071
  }
15914
16072
 
15915
16073
  // node_modules/micromark-extension-gfm-table/lib/infer.js
@@ -15960,10 +16118,15 @@ function tokenizeTable(effects, ok3, nok) {
15960
16118
  function start(code3) {
15961
16119
  let index2 = self.events.length - 1;
15962
16120
  while (index2 > -1) {
15963
- const type = self.events[index2][1].type;
16121
+ const {
16122
+ type
16123
+ } = self.events[index2][1];
15964
16124
  if (type === "lineEnding" || // Note: markdown-rs uses `whitespace` instead of `linePrefix`
15965
- type === "linePrefix") index2--;
15966
- else break;
16125
+ type === "linePrefix") {
16126
+ index2--;
16127
+ } else {
16128
+ break;
16129
+ }
15967
16130
  }
15968
16131
  const tail = index2 > -1 ? self.events[index2][1].type : null;
15969
16132
  const next = tail === "tableHead" || tail === "tableRow" ? bodyRowStart : headRowBefore;
@@ -16177,7 +16340,7 @@ function resolveTable(events, context) {
16177
16340
  let currentTable;
16178
16341
  let currentBody;
16179
16342
  let currentCell;
16180
- const map3 = new EditMap();
16343
+ const map3 = new EditMap2();
16181
16344
  while (++index2 < events.length) {
16182
16345
  const event = events[index2];
16183
16346
  const token = event[1];
@@ -16524,8 +16687,10 @@ function initializeDocument(effects) {
16524
16687
  };
16525
16688
  index2++;
16526
16689
  }
16527
- splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
16528
- self.events.length = index2;
16690
+ const editMap = new EditMap();
16691
+ editMap.add(indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
16692
+ editMap.add(indexBeforeExits, index2 - indexBeforeExits, []);
16693
+ editMap.consume(self.events);
16529
16694
  return checkNewContainers(code3);
16530
16695
  }
16531
16696
  return start(code3);
@@ -16544,7 +16709,9 @@ function initializeDocument(effects) {
16544
16709
  return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code3);
16545
16710
  }
16546
16711
  function thereIsANewContainer(code3) {
16547
- if (childFlow) closeFlow();
16712
+ if (childFlow) {
16713
+ closeFlow();
16714
+ }
16548
16715
  exitContainers(continued);
16549
16716
  return documentContinued(code3);
16550
16717
  }
@@ -16564,7 +16731,9 @@ function initializeDocument(effects) {
16564
16731
  }
16565
16732
  function flowStart(code3) {
16566
16733
  if (code3 === null) {
16567
- if (childFlow) closeFlow();
16734
+ if (childFlow) {
16735
+ closeFlow();
16736
+ }
16568
16737
  exitContainers(0);
16569
16738
  effects.consume(code3);
16570
16739
  return;
@@ -16596,9 +16765,13 @@ function initializeDocument(effects) {
16596
16765
  }
16597
16766
  function writeToChild(token, endOfFile) {
16598
16767
  const stream = self.sliceStream(token);
16599
- if (endOfFile) stream.push(null);
16768
+ if (endOfFile) {
16769
+ stream.push(null);
16770
+ }
16600
16771
  token.previous = childToken;
16601
- if (childToken) childToken.next = token;
16772
+ if (childToken) {
16773
+ childToken.next = token;
16774
+ }
16602
16775
  childToken = token;
16603
16776
  childFlow.defineSkip(token.start);
16604
16777
  childFlow.write(stream);
@@ -16635,8 +16808,10 @@ function initializeDocument(effects) {
16635
16808
  };
16636
16809
  index2++;
16637
16810
  }
16638
- splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
16639
- self.events.length = index2;
16811
+ const editMap = new EditMap();
16812
+ editMap.add(indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
16813
+ editMap.add(indexBeforeExits, index2 - indexBeforeExits, []);
16814
+ editMap.consume(self.events);
16640
16815
  }
16641
16816
  }
16642
16817
  function exitContainers(size) {
@@ -16775,6 +16950,7 @@ function createResolver(extraResolver) {
16775
16950
  }
16776
16951
  }
16777
16952
  function resolveAllLineSuffixes(events, context) {
16953
+ const editMap = new EditMap();
16778
16954
  let eventIndex = 0;
16779
16955
  while (++eventIndex <= events.length) {
16780
16956
  if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") {
@@ -16792,7 +16968,9 @@ function resolveAllLineSuffixes(events, context) {
16792
16968
  size++;
16793
16969
  bufferIndex--;
16794
16970
  }
16795
- if (bufferIndex) break;
16971
+ if (bufferIndex) {
16972
+ break;
16973
+ }
16796
16974
  bufferIndex = -1;
16797
16975
  } else if (chunk === -2) {
16798
16976
  tabs = true;
@@ -16826,13 +17004,13 @@ function resolveAllLineSuffixes(events, context) {
16826
17004
  if (data.start.offset === data.end.offset) {
16827
17005
  Object.assign(data, token);
16828
17006
  } else {
16829
- events.splice(eventIndex, 0, ["enter", token, context], ["exit", token, context]);
16830
- eventIndex += 2;
17007
+ editMap.add(eventIndex, 0, [["enter", token, context], ["exit", token, context]]);
16831
17008
  }
16832
17009
  }
16833
17010
  eventIndex++;
16834
17011
  }
16835
17012
  }
17013
+ editMap.consume(events);
16836
17014
  return events;
16837
17015
  }
16838
17016
 
@@ -16893,16 +17071,16 @@ var text4 = {
16893
17071
  [-3]: lineEnding,
16894
17072
  [33]: labelStartImage,
16895
17073
  [38]: characterReference,
16896
- [42]: attention,
17074
+ [42]: attention3,
16897
17075
  [60]: [autolink, htmlText],
16898
17076
  [91]: labelStartLink,
16899
17077
  [92]: [hardBreakEscape, characterEscape],
16900
17078
  [93]: labelEnd,
16901
- [95]: attention,
17079
+ [95]: attention3,
16902
17080
  [96]: codeText
16903
17081
  };
16904
17082
  var insideSpan = {
16905
- null: [attention, resolver]
17083
+ null: [attention3, resolver]
16906
17084
  };
16907
17085
  var attentionMarkers = {
16908
17086
  null: [42, 95]
@@ -16990,11 +17168,10 @@ function createTokenizer(parser, initialize, from) {
16990
17168
  accountForPotentialSkip();
16991
17169
  }
16992
17170
  function main() {
16993
- let chunkIndex;
16994
17171
  while (point3._index < chunks.length) {
16995
17172
  const chunk = chunks[point3._index];
16996
17173
  if (typeof chunk === "string") {
16997
- chunkIndex = point3._index;
17174
+ const chunkIndex = point3._index;
16998
17175
  if (point3._bufferIndex < 0) {
16999
17176
  point3._bufferIndex = 0;
17000
17177
  }
@@ -17202,30 +17379,34 @@ function serializeChunks(chunks, expandTabs) {
17202
17379
  let value2;
17203
17380
  if (typeof chunk === "string") {
17204
17381
  value2 = chunk;
17205
- } else switch (chunk) {
17206
- case -5: {
17207
- value2 = "\r";
17208
- break;
17209
- }
17210
- case -4: {
17211
- value2 = "\n";
17212
- break;
17213
- }
17214
- case -3: {
17215
- value2 = "\r\n";
17216
- break;
17217
- }
17218
- case -2: {
17219
- value2 = expandTabs ? " " : " ";
17220
- break;
17221
- }
17222
- case -1: {
17223
- if (!expandTabs && atTab) continue;
17224
- value2 = " ";
17225
- break;
17226
- }
17227
- default: {
17228
- value2 = String.fromCharCode(chunk);
17382
+ } else {
17383
+ switch (chunk) {
17384
+ case -5: {
17385
+ value2 = "\r";
17386
+ break;
17387
+ }
17388
+ case -4: {
17389
+ value2 = "\n";
17390
+ break;
17391
+ }
17392
+ case -3: {
17393
+ value2 = "\r\n";
17394
+ break;
17395
+ }
17396
+ case -2: {
17397
+ value2 = expandTabs ? " " : " ";
17398
+ break;
17399
+ }
17400
+ case -1: {
17401
+ if (!expandTabs && atTab) {
17402
+ continue;
17403
+ }
17404
+ value2 = " ";
17405
+ break;
17406
+ }
17407
+ default: {
17408
+ value2 = String.fromCharCode(chunk);
17409
+ }
17229
17410
  }
17230
17411
  }
17231
17412
  atTab = chunk === -2;
@@ -17276,14 +17457,9 @@ function preprocess() {
17276
17457
  let atCarriageReturn;
17277
17458
  return preprocessor;
17278
17459
  function preprocessor(value2, encoding, end) {
17279
- const chunks = [];
17280
- let match;
17281
- let next;
17282
- let startPosition;
17283
- let endPosition;
17284
- let code3;
17285
17460
  value2 = buffer + (typeof value2 === "string" ? value2.toString() : new TextDecoder(encoding || void 0).decode(value2));
17286
- startPosition = 0;
17461
+ const chunks = [];
17462
+ let startPosition = 0;
17287
17463
  buffer = "";
17288
17464
  if (start) {
17289
17465
  if (value2.charCodeAt(0) === 65279) {
@@ -17293,9 +17469,9 @@ function preprocess() {
17293
17469
  }
17294
17470
  while (startPosition < value2.length) {
17295
17471
  search.lastIndex = startPosition;
17296
- match = search.exec(value2);
17297
- endPosition = match && match.index !== void 0 ? match.index : value2.length;
17298
- code3 = value2.charCodeAt(endPosition);
17472
+ const match = search.exec(value2);
17473
+ const endPosition = match && match.index !== void 0 ? match.index : value2.length;
17474
+ const code3 = value2.charCodeAt(endPosition);
17299
17475
  if (!match) {
17300
17476
  buffer = value2.slice(startPosition);
17301
17477
  break;
@@ -17319,9 +17495,11 @@ function preprocess() {
17319
17495
  break;
17320
17496
  }
17321
17497
  case 9: {
17322
- next = Math.ceil(column / 4) * 4;
17498
+ const next = Math.ceil(column / 4) * 4;
17323
17499
  chunks.push(-2);
17324
- while (column++ < next) chunks.push(-1);
17500
+ while (column++ < next) {
17501
+ chunks.push(-1);
17502
+ }
17325
17503
  break;
17326
17504
  }
17327
17505
  case 10: {
@@ -17338,8 +17516,12 @@ function preprocess() {
17338
17516
  startPosition = endPosition + 1;
17339
17517
  }
17340
17518
  if (end) {
17341
- if (atCarriageReturn) chunks.push(-5);
17342
- if (buffer) chunks.push(buffer);
17519
+ if (atCarriageReturn) {
17520
+ chunks.push(-5);
17521
+ }
17522
+ if (buffer) {
17523
+ chunks.push(buffer);
17524
+ }
17343
17525
  chunks.push(null);
17344
17526
  }
17345
17527
  return chunks;
@@ -17383,6 +17565,8 @@ function fromMarkdown(value2, encoding, options) {
17383
17565
  }
17384
17566
  function compiler(options) {
17385
17567
  const config = {
17568
+ afterExit: [],
17569
+ beforeEnter: [],
17386
17570
  transforms: [],
17387
17571
  canContainEols: ["emphasis", "fragment", "heading", "paragraph", "strong"],
17388
17572
  enter: {
@@ -17486,7 +17670,8 @@ function compiler(options) {
17486
17670
  function compile(events) {
17487
17671
  let tree = {
17488
17672
  type: "root",
17489
- children: []
17673
+ children: [],
17674
+ position: void 0
17490
17675
  };
17491
17676
  const context = {
17492
17677
  stack: [tree],
@@ -17499,24 +17684,40 @@ function compiler(options) {
17499
17684
  data
17500
17685
  };
17501
17686
  const listStack = [];
17687
+ const prepared = [];
17502
17688
  let index2 = -1;
17503
17689
  while (++index2 < events.length) {
17690
+ prepared.push(events[index2]);
17504
17691
  if (events[index2][1].type === "listOrdered" || events[index2][1].type === "listUnordered") {
17505
17692
  if (events[index2][0] === "enter") {
17506
- listStack.push(index2);
17693
+ listStack.push(prepared.length - 1);
17507
17694
  } else {
17508
17695
  const tail = listStack.pop();
17509
- index2 = prepareList(events, tail, index2);
17696
+ prepareList(prepared, tail);
17510
17697
  }
17511
17698
  }
17512
17699
  }
17700
+ events = prepared;
17513
17701
  index2 = -1;
17514
17702
  while (++index2 < events.length) {
17515
17703
  const handler2 = config[events[index2][0]];
17704
+ if (events[index2][0] === "enter" && config.beforeEnter.length > 0) {
17705
+ callListeners(config.beforeEnter, {
17706
+ ...context,
17707
+ sliceSerialize: events[index2][2].sliceSerialize
17708
+ }, events[index2][1]);
17709
+ }
17516
17710
  if (own3.call(handler2, events[index2][1].type)) {
17517
- handler2[events[index2][1].type].call(Object.assign({
17711
+ handler2[events[index2][1].type].call({
17712
+ ...context,
17713
+ sliceSerialize: events[index2][2].sliceSerialize
17714
+ }, events[index2][1]);
17715
+ }
17716
+ if (events[index2][0] === "exit" && config.afterExit.length > 0) {
17717
+ callListeners(config.afterExit, {
17718
+ ...context,
17518
17719
  sliceSerialize: events[index2][2].sliceSerialize
17519
- }, context), events[index2][1]);
17720
+ }, events[index2][1]);
17520
17721
  }
17521
17722
  }
17522
17723
  if (context.tokenStack.length > 0) {
@@ -17542,7 +17743,14 @@ function compiler(options) {
17542
17743
  }
17543
17744
  return tree;
17544
17745
  }
17545
- function prepareList(events, start, length) {
17746
+ function callListeners(listeners, context, token) {
17747
+ let index2 = -1;
17748
+ while (++index2 < listeners.length) {
17749
+ listeners[index2].call(context, token);
17750
+ }
17751
+ }
17752
+ function prepareList(events, start) {
17753
+ const end = events.length - 1;
17546
17754
  let index2 = start - 1;
17547
17755
  let containerBalance = -1;
17548
17756
  let listSpread = false;
@@ -17550,7 +17758,8 @@ function compiler(options) {
17550
17758
  let lineIndex;
17551
17759
  let firstBlankLineIndex;
17552
17760
  let atMarker;
17553
- while (++index2 <= length) {
17761
+ const insertions = [];
17762
+ while (++index2 <= end) {
17554
17763
  const event = events[index2];
17555
17764
  switch (event[1].type) {
17556
17765
  case "listUnordered":
@@ -17607,9 +17816,10 @@ function compiler(options) {
17607
17816
  listItem3._spread = true;
17608
17817
  }
17609
17818
  listItem3.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end);
17610
- events.splice(lineIndex || index2, 0, ["exit", listItem3, event[2]]);
17611
- index2++;
17612
- length++;
17819
+ insertions.push({
17820
+ at: lineIndex || index2,
17821
+ event: ["exit", listItem3, event[2]]
17822
+ });
17613
17823
  }
17614
17824
  if (event[1].type === "listItemPrefix") {
17615
17825
  const item = {
@@ -17620,16 +17830,25 @@ function compiler(options) {
17620
17830
  end: void 0
17621
17831
  };
17622
17832
  listItem3 = item;
17623
- events.splice(index2, 0, ["enter", item, event[2]]);
17624
- index2++;
17625
- length++;
17833
+ insertions.push({
17834
+ at: index2,
17835
+ event: ["enter", item, event[2]]
17836
+ });
17626
17837
  firstBlankLineIndex = void 0;
17627
17838
  atMarker = true;
17628
17839
  }
17629
17840
  }
17630
17841
  }
17842
+ const listEvents = events.splice(start);
17843
+ let insertion = 0;
17844
+ index2 = -1;
17845
+ while (++index2 < listEvents.length) {
17846
+ while (insertion < insertions.length && insertions[insertion].at === start + index2) {
17847
+ events.push(insertions[insertion++].event);
17848
+ }
17849
+ events.push(listEvents[index2]);
17850
+ }
17631
17851
  events[start][1]._spread = listSpread;
17632
- return length;
17633
17852
  }
17634
17853
  function opener2(create2, and) {
17635
17854
  return open;
@@ -17671,7 +17890,8 @@ function compiler(options) {
17671
17890
  start: token.start,
17672
17891
  end: token.end
17673
17892
  }) + "): it\u2019s not open");
17674
- } else if (open[0].type !== token.type) {
17893
+ }
17894
+ if (open[0].type !== token.type) {
17675
17895
  if (onExitError) {
17676
17896
  onExitError.call(this, token, open[0]);
17677
17897
  } else {
@@ -17907,7 +18127,8 @@ function compiler(options) {
17907
18127
  function blockQuote2() {
17908
18128
  return {
17909
18129
  type: "blockquote",
17910
- children: []
18130
+ children: [],
18131
+ position: void 0
17911
18132
  };
17912
18133
  }
17913
18134
  function codeFlow() {
@@ -17915,13 +18136,15 @@ function compiler(options) {
17915
18136
  type: "code",
17916
18137
  lang: null,
17917
18138
  meta: null,
17918
- value: ""
18139
+ value: "",
18140
+ position: void 0
17919
18141
  };
17920
18142
  }
17921
18143
  function codeText2() {
17922
18144
  return {
17923
18145
  type: "inlineCode",
17924
- value: ""
18146
+ value: "",
18147
+ position: void 0
17925
18148
  };
17926
18149
  }
17927
18150
  function definition3() {
@@ -17930,13 +18153,15 @@ function compiler(options) {
17930
18153
  identifier: "",
17931
18154
  label: null,
17932
18155
  title: null,
17933
- url: ""
18156
+ url: "",
18157
+ position: void 0
17934
18158
  };
17935
18159
  }
17936
18160
  function emphasis2() {
17937
18161
  return {
17938
18162
  type: "emphasis",
17939
- children: []
18163
+ children: [],
18164
+ position: void 0
17940
18165
  };
17941
18166
  }
17942
18167
  function heading2() {
@@ -17944,18 +18169,21 @@ function compiler(options) {
17944
18169
  type: "heading",
17945
18170
  // @ts-expect-error `depth` will be set later.
17946
18171
  depth: 0,
17947
- children: []
18172
+ children: [],
18173
+ position: void 0
17948
18174
  };
17949
18175
  }
17950
18176
  function hardBreak2() {
17951
18177
  return {
17952
- type: "break"
18178
+ type: "break",
18179
+ position: void 0
17953
18180
  };
17954
18181
  }
17955
18182
  function html2() {
17956
18183
  return {
17957
18184
  type: "html",
17958
- value: ""
18185
+ value: "",
18186
+ position: void 0
17959
18187
  };
17960
18188
  }
17961
18189
  function image2() {
@@ -17963,7 +18191,8 @@ function compiler(options) {
17963
18191
  type: "image",
17964
18192
  title: null,
17965
18193
  url: "",
17966
- alt: null
18194
+ alt: null,
18195
+ position: void 0
17967
18196
  };
17968
18197
  }
17969
18198
  function link2() {
@@ -17971,7 +18200,8 @@ function compiler(options) {
17971
18200
  type: "link",
17972
18201
  title: null,
17973
18202
  url: "",
17974
- children: []
18203
+ children: [],
18204
+ position: void 0
17975
18205
  };
17976
18206
  }
17977
18207
  function list3(token) {
@@ -17980,7 +18210,8 @@ function compiler(options) {
17980
18210
  ordered: token.type === "listOrdered",
17981
18211
  start: null,
17982
18212
  spread: token._spread,
17983
- children: []
18213
+ children: [],
18214
+ position: void 0
17984
18215
  };
17985
18216
  }
17986
18217
  function listItem2(token) {
@@ -17988,30 +18219,35 @@ function compiler(options) {
17988
18219
  type: "listItem",
17989
18220
  spread: token._spread,
17990
18221
  checked: null,
17991
- children: []
18222
+ children: [],
18223
+ position: void 0
17992
18224
  };
17993
18225
  }
17994
18226
  function paragraph2() {
17995
18227
  return {
17996
18228
  type: "paragraph",
17997
- children: []
18229
+ children: [],
18230
+ position: void 0
17998
18231
  };
17999
18232
  }
18000
18233
  function strong2() {
18001
18234
  return {
18002
18235
  type: "strong",
18003
- children: []
18236
+ children: [],
18237
+ position: void 0
18004
18238
  };
18005
18239
  }
18006
18240
  function text5() {
18007
18241
  return {
18008
18242
  type: "text",
18009
- value: ""
18243
+ value: "",
18244
+ position: void 0
18010
18245
  };
18011
18246
  }
18012
18247
  function thematicBreak3() {
18013
18248
  return {
18014
- type: "thematicBreak"
18249
+ type: "thematicBreak",
18250
+ position: void 0
18015
18251
  };
18016
18252
  }
18017
18253
  }
@@ -18052,6 +18288,14 @@ function extension(combined, extension2) {
18052
18288
  }
18053
18289
  break;
18054
18290
  }
18291
+ case "afterExit":
18292
+ case "beforeEnter": {
18293
+ const right = extension2[key];
18294
+ if (right) {
18295
+ combined[key].push(right);
18296
+ }
18297
+ break;
18298
+ }
18055
18299
  case "enter":
18056
18300
  case "exit": {
18057
18301
  const right = extension2[key];
@@ -18073,12 +18317,11 @@ function defaultOnError(left, right) {
18073
18317
  start: right.start,
18074
18318
  end: right.end
18075
18319
  }) + ") is open");
18076
- } else {
18077
- throw new Error("Cannot close document, a token (`" + right.type + "`, " + stringifyPosition({
18078
- start: right.start,
18079
- end: right.end
18080
- }) + ") is still open");
18081
18320
  }
18321
+ throw new Error("Cannot close document, a token (`" + right.type + "`, " + stringifyPosition({
18322
+ start: right.start,
18323
+ end: right.end
18324
+ }) + ") is still open");
18082
18325
  }
18083
18326
 
18084
18327
  // node_modules/remark-parse/lib/index.js
@@ -18143,7 +18386,7 @@ function trough() {
18143
18386
  }
18144
18387
  values = output;
18145
18388
  if (fn) {
18146
- wrap(fn, next)(...output);
18389
+ wrap2(fn, next)(...output);
18147
18390
  } else {
18148
18391
  callback(null, ...output);
18149
18392
  }
@@ -18159,7 +18402,7 @@ function trough() {
18159
18402
  return pipeline;
18160
18403
  }
18161
18404
  }
18162
- function wrap(middleware, callback) {
18405
+ function wrap2(middleware, callback) {
18163
18406
  let called;
18164
18407
  return wrapped;
18165
18408
  function wrapped(...parameters) {
@@ -19489,6 +19732,44 @@ function escapeAttribute(value2) {
19489
19732
  return escaped;
19490
19733
  }
19491
19734
 
19735
+ // src/url.ts
19736
+ var LINK_SCHEMES = ["http", "https", "mailto", "tel"];
19737
+ var IMAGE_SCHEMES = ["http", "https"];
19738
+ function urlScheme(url) {
19739
+ const normalised = url.replace(/[\t\n\r]/g, "").replace(/^[\u0000- ]+|[\u0000- ]+$/g, "");
19740
+ const match = /^([a-z][a-z0-9+.-]*):/i.exec(normalised);
19741
+ return match?.[1] != null ? match[1].toLowerCase() : null;
19742
+ }
19743
+ function hasAllowedScheme(url, schemes) {
19744
+ const scheme = urlScheme(url);
19745
+ return scheme == null || schemes.includes(scheme);
19746
+ }
19747
+ function isSafeLinkUrl(url) {
19748
+ return hasAllowedScheme(url, LINK_SCHEMES);
19749
+ }
19750
+ function isSafeImageUrl(url) {
19751
+ return hasAllowedScheme(url, IMAGE_SCHEMES);
19752
+ }
19753
+
19754
+ // src/resolve-image.ts
19755
+ function resolveMarkdownImage(node2, options) {
19756
+ const alt = node2.alt ?? "";
19757
+ const resolved = options.resolveImage?.(node2.url, alt, node2.title ?? void 0);
19758
+ const id = resolved?.id;
19759
+ if (id != null && !(Number.isSafeInteger(id) && id > 0)) {
19760
+ throw new RangeError(
19761
+ `resolveImage returned an invalid id for ${JSON.stringify(node2.url)}: expected a positive integer, got ${JSON.stringify(id)}`
19762
+ );
19763
+ }
19764
+ const image2 = {
19765
+ ...resolved,
19766
+ url: resolved?.url ?? node2.url,
19767
+ alt: resolved?.alt ?? alt
19768
+ };
19769
+ const allowed = options.urlSchemes === "any" || isSafeImageUrl(image2.url);
19770
+ return allowed ? image2 : null;
19771
+ }
19772
+
19492
19773
  // src/inline.ts
19493
19774
  function renderInline(nodes, options) {
19494
19775
  const parts = [];
@@ -19525,7 +19806,7 @@ function renderInlineNode(node2, options) {
19525
19806
  out = renderInlineImage(node2, options);
19526
19807
  break;
19527
19808
  case "html":
19528
- out = node2.value;
19809
+ out = options.unsupported === "skip" ? "" : node2.value;
19529
19810
  break;
19530
19811
  default:
19531
19812
  out = renderUnknownInline(node2, options);
@@ -19534,19 +19815,24 @@ function renderInlineNode(node2, options) {
19534
19815
  return out;
19535
19816
  }
19536
19817
  function renderLink(node2, options) {
19537
- const href = escapeAttribute(node2.url);
19538
- const title = node2.title != null && node2.title !== "" ? ` title="${escapeAttribute(node2.title)}"` : "";
19539
19818
  const inner = renderInline(node2.children, options);
19540
- return `<a href="${href}"${title}>${inner}</a>`;
19819
+ let out = inner;
19820
+ if (options.urlSchemes === "any" || isSafeLinkUrl(node2.url)) {
19821
+ const href = escapeAttribute(node2.url);
19822
+ const title = node2.title != null && node2.title !== "" ? ` title="${escapeAttribute(node2.title)}"` : "";
19823
+ out = `<a href="${href}"${title}>${inner}</a>`;
19824
+ }
19825
+ return out;
19541
19826
  }
19542
19827
  function renderInlineImage(node2, options) {
19543
- const alt = node2.alt ?? "";
19544
- const resolved = options.resolveImage?.(node2.url, alt, node2.title ?? void 0);
19545
- const url = resolved?.url ?? node2.url;
19546
- const altText = resolved?.alt ?? alt;
19547
- const altAttr = ` alt="${escapeAttribute(altText)}"`;
19548
- const idClass = resolved?.id != null ? ` class="wp-image-${resolved.id}"` : "";
19549
- return `<img src="${escapeAttribute(url)}"${altAttr}${idClass}/>`;
19828
+ const image2 = resolveMarkdownImage(node2, options);
19829
+ let out = "";
19830
+ if (image2 != null) {
19831
+ const altAttr = ` alt="${escapeAttribute(image2.alt ?? "")}"`;
19832
+ const idClass = image2.id != null ? ` class="wp-image-${image2.id}"` : "";
19833
+ out = `<img src="${escapeAttribute(image2.url)}"${altAttr}${idClass}/>`;
19834
+ }
19835
+ return out;
19550
19836
  }
19551
19837
  function renderUnknownInline(node2, options) {
19552
19838
  let out = "";
@@ -19584,31 +19870,22 @@ function createHeadingSlugger() {
19584
19870
  };
19585
19871
  }
19586
19872
 
19587
- // src/types.ts
19588
- function resolveOptions(options) {
19589
- return {
19590
- headingShift: options?.headingShift ?? 0,
19591
- minHeadingLevel: options?.minHeadingLevel ?? 2,
19592
- headingAnchors: options?.headingAnchors ?? false,
19593
- resolveImage: options?.resolveImage,
19594
- codeLanguage: options?.codeLanguage ?? "drop",
19595
- unsupported: options?.unsupported ?? "html",
19596
- gfm: options?.gfm ?? true
19597
- };
19598
- }
19599
-
19600
19873
  // src/blocks/code.ts
19601
19874
  function renderCode(node2, ctx) {
19602
- const body = escapeCode(node2.value);
19875
+ const body = escapeShortcodesAndEmbeds(escapeCode(node2.value));
19603
19876
  let codeOpen = "<code>";
19604
19877
  if (ctx.options.codeLanguage === "class" && node2.lang) {
19605
- codeOpen = `<code class="language-${node2.lang}">`;
19878
+ codeOpen = `<code class="language-${escapeAttribute(node2.lang)}">`;
19606
19879
  }
19607
19880
  const inner = `<pre class="wp-block-code">${codeOpen}${body}</code></pre>`;
19608
19881
  return `<!-- wp:code -->
19609
19882
  ${inner}
19610
19883
  <!-- /wp:code -->`;
19611
19884
  }
19885
+ function escapeShortcodesAndEmbeds(html2) {
19886
+ const escaped = html2.replace(/\[/g, "&#91;").replace(/^(\s*https?:)\/\/([^\s<>"]+\s*)$/m, "$1&#47;&#47;$2");
19887
+ return escaped;
19888
+ }
19612
19889
 
19613
19890
  // src/blocks/html.ts
19614
19891
  function renderHtml(node2, ctx) {
@@ -19620,38 +19897,43 @@ ${node2.value}
19620
19897
  <!-- /wp:html -->`;
19621
19898
  }
19622
19899
 
19900
+ // src/attributes.ts
19901
+ function serializeBlockAttributes(attributes) {
19902
+ let out = "";
19903
+ if (Object.keys(attributes).length > 0) {
19904
+ const json = JSON.stringify(attributes).replace(/--/g, "\\u002d\\u002d").replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/ /g, "\\u00a0");
19905
+ out = ` ${json}`;
19906
+ }
19907
+ return out;
19908
+ }
19909
+
19623
19910
  // src/blocks/image.ts
19624
19911
  function renderImage(node2, ctx) {
19625
- const alt = node2.alt ?? "";
19626
- const resolved = ctx.options.resolveImage?.(
19627
- node2.url,
19628
- alt,
19629
- node2.title ?? void 0
19630
- );
19631
- return resolved != null && resolved.id != null ? renderLibraryImage(resolved, alt) : renderExternalImage(resolved, node2.url, alt);
19912
+ const image2 = resolveMarkdownImage(node2, ctx.options);
19913
+ let out = null;
19914
+ if (image2 != null) {
19915
+ out = image2.id != null ? renderLibraryImage(image2, image2.id) : renderExternalImage(image2);
19916
+ }
19917
+ return out;
19632
19918
  }
19633
- function renderLibraryImage(resolved, fallbackAlt) {
19634
- const id = resolved.id;
19635
- const altText = resolved.alt ?? fallbackAlt;
19636
- const sizeSlug = resolved.sizeSlug;
19919
+ function renderLibraryImage(image2, id) {
19920
+ const sizeSlug = image2.sizeSlug;
19637
19921
  const attrs = { id };
19638
19922
  if (sizeSlug != null) {
19639
19923
  attrs.sizeSlug = sizeSlug;
19640
19924
  }
19641
19925
  attrs.linkDestination = "none";
19642
- const figureClass = sizeSlug != null ? `wp-block-image size-${sizeSlug}` : "wp-block-image";
19643
- const img = `<img src="${escapeAttribute(resolved.url)}" alt="${escapeAttribute(altText)}" class="wp-image-${id}"/>`;
19644
- const caption = renderCaption(resolved.caption);
19926
+ const figureClass = sizeSlug != null ? `wp-block-image size-${escapeAttribute(sizeSlug)}` : "wp-block-image";
19927
+ const img = `<img src="${escapeAttribute(image2.url)}" alt="${escapeAttribute(image2.alt ?? "")}" class="wp-image-${id}"/>`;
19928
+ const caption = renderCaption(image2.caption);
19645
19929
  const inner = `<figure class="${figureClass}">${img}${caption}</figure>`;
19646
- return `<!-- wp:image ${JSON.stringify(attrs)} -->
19930
+ return `<!-- wp:image${serializeBlockAttributes(attrs)} -->
19647
19931
  ${inner}
19648
19932
  <!-- /wp:image -->`;
19649
19933
  }
19650
- function renderExternalImage(resolved, fallbackUrl, fallbackAlt) {
19651
- const url = resolved?.url ?? fallbackUrl;
19652
- const altText = resolved?.alt ?? fallbackAlt;
19653
- const img = `<img src="${escapeAttribute(url)}" alt="${escapeAttribute(altText)}"/>`;
19654
- const caption = renderCaption(resolved?.caption);
19934
+ function renderExternalImage(image2) {
19935
+ const img = `<img src="${escapeAttribute(image2.url)}" alt="${escapeAttribute(image2.alt ?? "")}"/>`;
19936
+ const caption = renderCaption(image2.caption);
19655
19937
  const inner = `<figure class="wp-block-image">${img}${caption}</figure>`;
19656
19938
  return `<!-- wp:image -->
19657
19939
  ${inner}
@@ -19664,16 +19946,6 @@ function renderCaption(caption) {
19664
19946
  return `<figcaption class="wp-element-caption">${escapeText(caption)}</figcaption>`;
19665
19947
  }
19666
19948
 
19667
- // src/attributes.ts
19668
- function serializeBlockAttributes(attributes) {
19669
- let out = "";
19670
- if (Object.keys(attributes).length > 0) {
19671
- const json = JSON.stringify(attributes).replace(/--/g, "\\u002d\\u002d").replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/ /g, "\\u00a0");
19672
- out = ` ${json}`;
19673
- }
19674
- return out;
19675
- }
19676
-
19677
19949
  // src/blocks/heading.ts
19678
19950
  function renderHeading(node2, ctx) {
19679
19951
  const { headingShift, minHeadingLevel, headingAnchors } = ctx.options;
@@ -19713,12 +19985,21 @@ function headingText(nodes) {
19713
19985
  // src/blocks/list.ts
19714
19986
  function renderList(node2, ctx) {
19715
19987
  const tag = node2.ordered ? "ol" : "ul";
19716
- const attrs = node2.ordered ? ' {"ordered":true}' : "";
19988
+ const attributes = {};
19989
+ let startAttr = "";
19990
+ if (node2.ordered) {
19991
+ attributes.ordered = true;
19992
+ if (node2.start != null && node2.start !== 1) {
19993
+ attributes.start = node2.start;
19994
+ startAttr = ` start="${node2.start}"`;
19995
+ }
19996
+ }
19997
+ const attrs = serializeBlockAttributes(attributes);
19717
19998
  const items = [];
19718
19999
  for (const child of node2.children) {
19719
20000
  items.push(renderListItem(child, ctx));
19720
20001
  }
19721
- const inner = `<${tag} class="wp-block-list">${items.join("\n\n")}</${tag}>`;
20002
+ const inner = `<${tag}${startAttr} class="wp-block-list">${items.join("\n\n")}</${tag}>`;
19722
20003
  return `<!-- wp:list${attrs} -->
19723
20004
  ${inner}
19724
20005
  <!-- /wp:list -->`;
@@ -19806,14 +20087,35 @@ function renderRow(row, cellTag, ctx) {
19806
20087
  }
19807
20088
 
19808
20089
  // src/convert.ts
20090
+ var MAX_NESTING_DEPTH = 200;
19809
20091
  function parseMarkdown(markdown, options) {
19810
20092
  const base = unified().use(remarkParse).use(remarkFrontmatter, ["yaml"]);
19811
20093
  const processor = options.gfm ? base.use(remarkGfm) : base;
19812
20094
  const tree = processor.parse(markdown);
19813
20095
  const root2 = processor.runSync(tree);
20096
+ const depth = maxDepth(root2);
20097
+ if (depth > MAX_NESTING_DEPTH) {
20098
+ throw new RangeError(
20099
+ `Markdown nests ${depth} levels deep; the limit is ${MAX_NESTING_DEPTH}`
20100
+ );
20101
+ }
19814
20102
  resolveReferences(root2);
19815
20103
  return root2;
19816
20104
  }
20105
+ function maxDepth(root2) {
20106
+ let deepest = 0;
20107
+ const pending = [{ node: root2, depth: 0 }];
20108
+ let entry = pending.pop();
20109
+ while (entry != null) {
20110
+ deepest = Math.max(deepest, entry.depth);
20111
+ const children = entry.node.children ?? [];
20112
+ for (const child of children) {
20113
+ pending.push({ node: child, depth: entry.depth + 1 });
20114
+ }
20115
+ entry = pending.pop();
20116
+ }
20117
+ return deepest;
20118
+ }
19817
20119
  function resolveReferences(tree) {
19818
20120
  const definitions = /* @__PURE__ */ new Map();
19819
20121
  visit(tree, "definition", (node2) => {
@@ -19821,25 +20123,23 @@ function resolveReferences(tree) {
19821
20123
  });
19822
20124
  visit(tree, "linkReference", (node2) => {
19823
20125
  const def = definitions.get(node2.identifier);
19824
- if (def == null) {
19825
- return;
20126
+ if (def != null) {
20127
+ const link2 = node2;
20128
+ link2.type = "link";
20129
+ link2.url = def.url;
20130
+ link2.title = def.title ?? null;
19826
20131
  }
19827
- const link2 = node2;
19828
- link2.type = "link";
19829
- link2.url = def.url;
19830
- link2.title = def.title ?? null;
19831
20132
  });
19832
20133
  visit(tree, "imageReference", (node2) => {
19833
20134
  const def = definitions.get(node2.identifier);
19834
- if (def == null) {
19835
- return;
20135
+ if (def != null) {
20136
+ const alt = node2.alt ?? "";
20137
+ const image2 = node2;
20138
+ image2.type = "image";
20139
+ image2.url = def.url;
20140
+ image2.title = def.title ?? null;
20141
+ image2.alt = alt;
19836
20142
  }
19837
- const alt = node2.alt ?? "";
19838
- const image2 = node2;
19839
- image2.type = "image";
19840
- image2.url = def.url;
19841
- image2.title = def.title ?? null;
19842
- image2.alt = alt;
19843
20143
  });
19844
20144
  }
19845
20145
  function createContext(options) {
@@ -19962,8 +20262,10 @@ function parseFrontmatter(value2) {
19962
20262
  }
19963
20263
 
19964
20264
  export {
20265
+ applyOptionDefaults,
20266
+ validateOptions,
19965
20267
  markdownToBlockList,
19966
20268
  markdownToBlocks,
19967
20269
  parseMarkdownDocument
19968
20270
  };
19969
- //# sourceMappingURL=chunk-CHMDS2SX.js.map
20271
+ //# sourceMappingURL=chunk-26IEHNWU.js.map