@headwall/markdown-to-blocks 1.2.0 → 1.3.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;
@@ -8185,15 +8188,12 @@ function findAndReplace(tree, list3, options) {
8185
8188
  find.lastIndex = position2 + 1;
8186
8189
  } else {
8187
8190
  if (start !== position2) {
8188
- nodes.push({
8189
- type: "text",
8190
- value: node2.value.slice(start, position2)
8191
- });
8191
+ add({ type: "text", value: node2.value.slice(start, position2) });
8192
8192
  }
8193
8193
  if (Array.isArray(value2)) {
8194
- nodes.push(...value2);
8194
+ for (const child of value2) add(child);
8195
8195
  } else if (value2) {
8196
- nodes.push(value2);
8196
+ add(value2);
8197
8197
  }
8198
8198
  start = position2 + match[0].length;
8199
8199
  change = true;
@@ -8205,20 +8205,28 @@ function findAndReplace(tree, list3, options) {
8205
8205
  }
8206
8206
  if (change) {
8207
8207
  if (start < node2.value.length) {
8208
- nodes.push({ type: "text", value: node2.value.slice(start) });
8208
+ add({ type: "text", value: node2.value.slice(start) });
8209
8209
  }
8210
8210
  parent.children.splice(index2, 1, ...nodes);
8211
8211
  } else {
8212
8212
  nodes = [node2];
8213
8213
  }
8214
8214
  return index2 + nodes.length;
8215
+ function add(child) {
8216
+ const previous3 = nodes[nodes.length - 1];
8217
+ if (previous3 && previous3.type === "text" && child.type === "text") {
8218
+ previous3.value += child.value;
8219
+ } else {
8220
+ nodes.push(child);
8221
+ }
8222
+ }
8215
8223
  }
8216
8224
  }
8217
8225
  function toPairs(tupleOrList) {
8218
- const result = [];
8219
8226
  if (!Array.isArray(tupleOrList)) {
8220
8227
  throw new TypeError("Expected find and replace tuple or list of tuples");
8221
8228
  }
8229
+ const result = [];
8222
8230
  const list3 = !tupleOrList[0] || Array.isArray(tupleOrList[0]) ? tupleOrList : [tupleOrList];
8223
8231
  let index2 = -1;
8224
8232
  while (++index2 < list3.length) {
@@ -8513,6 +8521,7 @@ var constructsWithoutStrikethrough = [
8513
8521
  "titleQuote",
8514
8522
  "titleApostrophe"
8515
8523
  ];
8524
+ handleDelete.attention = attentionDelete;
8516
8525
  handleDelete.peek = peekDelete;
8517
8526
  function gfmStrikethroughFromMarkdown() {
8518
8527
  return {
@@ -8523,35 +8532,39 @@ function gfmStrikethroughFromMarkdown() {
8523
8532
  }
8524
8533
  function gfmStrikethroughToMarkdown() {
8525
8534
  return {
8535
+ handlers: { delete: handleDelete },
8526
8536
  unsafe: [
8527
8537
  {
8528
8538
  character: "~",
8529
8539
  inConstruct: "phrasing",
8530
8540
  notInConstruct: constructsWithoutStrikethrough
8531
8541
  }
8532
- ],
8533
- handlers: { delete: handleDelete }
8542
+ ]
8534
8543
  };
8535
8544
  }
8536
8545
  function enterStrikethrough(token) {
8537
- this.enter({ type: "delete", children: [] }, token);
8546
+ this.enter({ type: "delete", children: [], position: void 0 }, token);
8538
8547
  }
8539
8548
  function exitStrikethrough(token) {
8540
8549
  this.exit(token);
8541
8550
  }
8542
8551
  function handleDelete(node2, _, state, info) {
8543
8552
  const tracker = state.createTracker(info);
8553
+ const sequence = state.stack.includes("strikethrough") ? "~" : "~~";
8544
8554
  const exit3 = state.enter("strikethrough");
8545
- let value2 = tracker.move("~~");
8555
+ let value2 = tracker.move(sequence);
8546
8556
  value2 += state.containerPhrasing(node2, {
8547
8557
  ...tracker.current(),
8548
8558
  before: value2,
8549
8559
  after: "~"
8550
8560
  });
8551
- value2 += tracker.move("~~");
8561
+ value2 += tracker.move(sequence);
8552
8562
  exit3();
8553
8563
  return value2;
8554
8564
  }
8565
+ function attentionDelete() {
8566
+ return { construct: "strikethrough", markers: ["~"], sizes: [2, 1] };
8567
+ }
8555
8568
  function peekDelete() {
8556
8569
  return "~";
8557
8570
  }
@@ -8697,6 +8710,34 @@ function toAlignment(value2) {
8697
8710
  return code3 === 67 || code3 === 99 ? 99 : code3 === 76 || code3 === 108 ? 108 : code3 === 82 || code3 === 114 ? 114 : 0;
8698
8711
  }
8699
8712
 
8713
+ // node_modules/mdast-util-phrasing/lib/index.js
8714
+ var phrasing = (
8715
+ /** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
8716
+ convert([
8717
+ "break",
8718
+ "delete",
8719
+ "emphasis",
8720
+ // To do: next major: removed since footnotes were added to GFM.
8721
+ "footnote",
8722
+ "footnoteReference",
8723
+ "image",
8724
+ "imageReference",
8725
+ "inlineCode",
8726
+ // Enabled by `mdast-util-math`:
8727
+ "inlineMath",
8728
+ "link",
8729
+ "linkReference",
8730
+ // Enabled by `mdast-util-mdx`:
8731
+ "mdxJsxTextElement",
8732
+ // Enabled by `mdast-util-mdx`:
8733
+ "mdxTextExpression",
8734
+ "strong",
8735
+ "text",
8736
+ // Enabled by `mdast-util-directive`:
8737
+ "textDirective"
8738
+ ])
8739
+ );
8740
+
8700
8741
  // node_modules/mdast-util-to-markdown/lib/handle/blockquote.js
8701
8742
  function blockquote(node2, _, state, info) {
8702
8743
  const exit3 = state.enter("blockquote");
@@ -8738,8 +8779,9 @@ function listInScope(stack, list3, none) {
8738
8779
  function hardBreak(_, _1, state, info) {
8739
8780
  let index2 = -1;
8740
8781
  while (++index2 < state.unsafe.length) {
8741
- if (state.unsafe[index2].character === "\n" && patternInScope(state.stack, state.unsafe[index2])) {
8742
- return /[ \t]/.test(info.before) ? "" : " ";
8782
+ const pattern = state.unsafe[index2];
8783
+ if (pattern.character === "\n" && !pattern.before && !pattern.after && patternInScope(state.stack, pattern)) {
8784
+ return /[\t ]/.test(info.before) ? "" : " ";
8743
8785
  }
8744
8786
  }
8745
8787
  return "\\\n";
@@ -8774,8 +8816,8 @@ function formatCodeAsIndented(node2, state) {
8774
8816
  return Boolean(
8775
8817
  state.options.fences === false && node2.value && // If there’s no info…
8776
8818
  !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)
8819
+ /[^\n\r ]/.test(node2.value) && // And the value doesn’t start or end in a blank…
8820
+ !/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(node2.value)
8779
8821
  );
8780
8822
  }
8781
8823
 
@@ -8794,7 +8836,6 @@ function checkFence(state) {
8794
8836
  function code(node2, _, state, info) {
8795
8837
  const marker = checkFence(state);
8796
8838
  const raw = node2.value || "";
8797
- const suffix = marker === "`" ? "GraveAccent" : "Tilde";
8798
8839
  if (formatCodeAsIndented(node2, state)) {
8799
8840
  const exit4 = state.enter("codeIndented");
8800
8841
  const value3 = state.indentLines(raw, map2);
@@ -8804,6 +8845,7 @@ function code(node2, _, state, info) {
8804
8845
  const tracker = state.createTracker(info);
8805
8846
  const sequence = marker.repeat(Math.max(longestStreak(raw, marker) + 1, 3));
8806
8847
  const exit3 = state.enter("codeFenced");
8848
+ const suffix = marker === "`" ? "GraveAccent" : "Tilde";
8807
8849
  let value2 = tracker.move(sequence);
8808
8850
  if (node2.lang) {
8809
8851
  const subexit = state.enter(`codeFencedLang${suffix}`);
@@ -8920,103 +8962,32 @@ function checkEmphasis(state) {
8920
8962
  return marker;
8921
8963
  }
8922
8964
 
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
8965
  // node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
8981
- emphasis.peek = emphasisPeek;
8966
+ emphasis.attention = attention;
8967
+ emphasis.peek = peek;
8982
8968
  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);
8969
+ const exit3 = state.enter("phrasing");
8970
+ const value2 = state.containerPhrasing({ type: "root", children: [node2] }, info);
9009
8971
  exit3();
9010
- state.attentionEncodeSurroundingInfo = {
9011
- after: close2.outside,
9012
- before: open.outside
8972
+ return value2;
8973
+ }
8974
+ function attention(_, state) {
8975
+ const marker = checkEmphasis(state);
8976
+ return {
8977
+ construct: "emphasis",
8978
+ markers: marker === "*" ? ["*", "_"] : ["_", "*"],
8979
+ sizes: [1]
9013
8980
  };
9014
- return before + between + after;
9015
8981
  }
9016
- function emphasisPeek(_, _1, state) {
8982
+ function peek(_, _1, state) {
9017
8983
  return state.options.emphasis || "*";
9018
8984
  }
9019
8985
 
8986
+ // node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
8987
+ function encodeCharacterReference(code3) {
8988
+ return "&#x" + code3.toString(16).toUpperCase() + ";";
8989
+ }
8990
+
9020
8991
  // node_modules/unist-util-visit/lib/index.js
9021
8992
  function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
9022
8993
  let reverse;
@@ -9120,8 +9091,9 @@ function heading(node2, _, state, info) {
9120
9091
  after: "\n",
9121
9092
  ...tracker.current()
9122
9093
  });
9123
- if (/^[\t ]/.test(value2)) {
9124
- value2 = encodeCharacterReference(value2.charCodeAt(0)) + value2.slice(1);
9094
+ const head = value2.charCodeAt(0);
9095
+ if (head === 9 || head === 32) {
9096
+ value2 = encodeCharacterReference(head) + value2.slice(1);
9125
9097
  }
9126
9098
  value2 = value2 ? sequence + " " + value2 : sequence;
9127
9099
  if (state.options.closeAtx) {
@@ -9214,7 +9186,9 @@ function imageReference(node2, _, state, info) {
9214
9186
  value2 += tracker.move(alt + "][");
9215
9187
  subexit();
9216
9188
  const stack = state.stack;
9217
- state.stack = [];
9189
+ state.stack = stack.filter(function(d) {
9190
+ return d !== "phrasing";
9191
+ });
9218
9192
  subexit = state.enter("reference");
9219
9193
  const reference = state.safe(state.associationId(node2), {
9220
9194
  before: value2,
@@ -9246,14 +9220,14 @@ function inlineCode(node2, _, state) {
9246
9220
  while (new RegExp("(^|[^`])" + sequence + "([^`]|$)").test(value2)) {
9247
9221
  sequence += "`";
9248
9222
  }
9249
- if (/[^ \r\n]/.test(value2) && (/^[ \r\n]/.test(value2) && /[ \r\n]$/.test(value2) || /^`|`$/.test(value2))) {
9223
+ if (/[^\n\r ]/.test(value2) && (/^[\n\r ]/.test(value2) && /[\n\r ]$/.test(value2) || /^`|`$/.test(value2))) {
9250
9224
  value2 = " " + value2 + " ";
9251
9225
  }
9252
9226
  while (++index2 < state.unsafe.length) {
9253
9227
  const pattern = state.unsafe[index2];
9254
9228
  const expression = state.compilePattern(pattern);
9255
- let match;
9256
9229
  if (!pattern.atBreak) continue;
9230
+ let match;
9257
9231
  while (match = expression.exec(value2)) {
9258
9232
  let position2 = match.index;
9259
9233
  if (value2.charCodeAt(position2) === 10 && value2.charCodeAt(position2 - 1) === 13) {
@@ -9273,11 +9247,11 @@ function formatLinkAsAutolink(node2, state) {
9273
9247
  const raw = toString(node2);
9274
9248
  return Boolean(
9275
9249
  !state.options.resourceLink && // If there’s a url…
9276
- node2.url && // And there’s a no title…
9250
+ node2.url && // And there’s no title…
9277
9251
  !node2.title && // And the content of `node` is a single text node…
9278
9252
  node2.children && node2.children.length === 1 && node2.children[0].type === "text" && // And if the url is the same as the content…
9279
9253
  (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
9254
+ /^[a-z][+\-.a-z]+:/i.test(node2.url) && // And that doesn’t contain ASCII control codes (character escapes and
9281
9255
  // references don’t work), space, or angle brackets…
9282
9256
  !/[\0- <>\u007F]/.test(node2.url)
9283
9257
  );
@@ -9289,12 +9263,12 @@ function link(node2, _, state, info) {
9289
9263
  const quote = checkQuote(state);
9290
9264
  const suffix = quote === '"' ? "Quote" : "Apostrophe";
9291
9265
  const tracker = state.createTracker(info);
9292
- let exit3;
9293
- let subexit;
9294
9266
  if (formatLinkAsAutolink(node2, state)) {
9295
9267
  const stack = state.stack;
9296
- state.stack = [];
9297
- exit3 = state.enter("autolink");
9268
+ state.stack = stack.filter(function(d) {
9269
+ return d !== "phrasing";
9270
+ });
9271
+ const exit4 = state.enter("autolink");
9298
9272
  let value3 = tracker.move("<");
9299
9273
  value3 += tracker.move(
9300
9274
  state.containerPhrasing(node2, {
@@ -9304,12 +9278,12 @@ function link(node2, _, state, info) {
9304
9278
  })
9305
9279
  );
9306
9280
  value3 += tracker.move(">");
9307
- exit3();
9281
+ exit4();
9308
9282
  state.stack = stack;
9309
9283
  return value3;
9310
9284
  }
9311
- exit3 = state.enter("link");
9312
- subexit = state.enter("label");
9285
+ const exit3 = state.enter("link");
9286
+ let subexit = state.enter("label");
9313
9287
  let value2 = tracker.move("[");
9314
9288
  value2 += tracker.move(
9315
9289
  state.containerPhrasing(node2, {
@@ -9379,7 +9353,9 @@ function linkReference(node2, _, state, info) {
9379
9353
  value2 += tracker.move(text5 + "][");
9380
9354
  subexit();
9381
9355
  const stack = state.stack;
9382
- state.stack = [];
9356
+ state.stack = stack.filter(function(d) {
9357
+ return d !== "phrasing";
9358
+ });
9383
9359
  subexit = state.enter("reference");
9384
9360
  const reference = state.safe(state.associationId(node2), {
9385
9361
  before: value2,
@@ -9545,41 +9521,16 @@ function paragraph(node2, _, state, info) {
9545
9521
  return value2;
9546
9522
  }
9547
9523
 
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
9524
  // node_modules/mdast-util-to-markdown/lib/handle/root.js
9577
9525
  function root(node2, _, state, info) {
9578
9526
  const hasPhrasing = node2.children.some(function(d) {
9579
9527
  return phrasing(d);
9580
9528
  });
9581
- const container = hasPhrasing ? state.containerPhrasing : state.containerFlow;
9582
- return container.call(state, node2, info);
9529
+ if (!hasPhrasing) return state.containerFlow(node2, info);
9530
+ const exit3 = state.enter("phrasing");
9531
+ const value2 = state.containerPhrasing(node2, info);
9532
+ exit3();
9533
+ return value2;
9583
9534
  }
9584
9535
 
9585
9536
  // node_modules/mdast-util-to-markdown/lib/util/check-strong.js
@@ -9594,48 +9545,35 @@ function checkStrong(state) {
9594
9545
  }
9595
9546
 
9596
9547
  // node_modules/mdast-util-to-markdown/lib/handle/strong.js
9597
- strong.peek = strongPeek;
9548
+ strong.attention = attention2;
9549
+ strong.peek = peek2;
9598
9550
  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);
9551
+ const exit3 = state.enter("phrasing");
9552
+ const value2 = state.containerPhrasing({ type: "root", children: [node2] }, info);
9625
9553
  exit3();
9626
- state.attentionEncodeSurroundingInfo = {
9627
- after: close2.outside,
9628
- before: open.outside
9554
+ return value2;
9555
+ }
9556
+ function attention2(_, state) {
9557
+ const marker = checkStrong(state);
9558
+ return {
9559
+ construct: "strong",
9560
+ markers: marker === "*" ? ["*", "_"] : ["_", "*"],
9561
+ sizes: [2]
9629
9562
  };
9630
- return before + between + after;
9631
9563
  }
9632
- function strongPeek(_, _1, state) {
9564
+ function peek2(_, _1, state) {
9633
9565
  return state.options.strong || "*";
9634
9566
  }
9635
9567
 
9636
9568
  // node_modules/mdast-util-to-markdown/lib/handle/text.js
9637
- function text(node2, _, state, info) {
9638
- return state.safe(node2.value, info);
9569
+ function text(node2, parent, state, info) {
9570
+ const siblings = parent ? parent.children : [];
9571
+ const index2 = siblings.indexOf(node2);
9572
+ return state.safe(node2.value, {
9573
+ ...info,
9574
+ afterNode: siblings[index2 + 1],
9575
+ beforeNode: siblings[index2 - 1]
9576
+ });
9639
9577
  }
9640
9578
 
9641
9579
  // node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js
@@ -9679,6 +9617,73 @@ var handle = {
9679
9617
  thematicBreak
9680
9618
  };
9681
9619
 
9620
+ // node_modules/micromark-util-html-tag-name/index.js
9621
+ var htmlBlockNames = [
9622
+ "address",
9623
+ "article",
9624
+ "aside",
9625
+ "base",
9626
+ "basefont",
9627
+ "blockquote",
9628
+ "body",
9629
+ "caption",
9630
+ "center",
9631
+ "col",
9632
+ "colgroup",
9633
+ "dd",
9634
+ "details",
9635
+ "dialog",
9636
+ "dir",
9637
+ "div",
9638
+ "dl",
9639
+ "dt",
9640
+ "fieldset",
9641
+ "figcaption",
9642
+ "figure",
9643
+ "footer",
9644
+ "form",
9645
+ "frame",
9646
+ "frameset",
9647
+ "h1",
9648
+ "h2",
9649
+ "h3",
9650
+ "h4",
9651
+ "h5",
9652
+ "h6",
9653
+ "head",
9654
+ "header",
9655
+ "hr",
9656
+ "html",
9657
+ "iframe",
9658
+ "legend",
9659
+ "li",
9660
+ "link",
9661
+ "main",
9662
+ "menu",
9663
+ "menuitem",
9664
+ "nav",
9665
+ "noframes",
9666
+ "ol",
9667
+ "optgroup",
9668
+ "option",
9669
+ "p",
9670
+ "param",
9671
+ "search",
9672
+ "section",
9673
+ "summary",
9674
+ "table",
9675
+ "tbody",
9676
+ "td",
9677
+ "tfoot",
9678
+ "th",
9679
+ "thead",
9680
+ "title",
9681
+ "tr",
9682
+ "track",
9683
+ "ul"
9684
+ ];
9685
+ var htmlRawNames = ["pre", "script", "style", "textarea"];
9686
+
9682
9687
  // node_modules/character-entities/index.js
9683
9688
  var characterEntities = {
9684
9689
  AElig: "\xC6",
@@ -11850,6 +11855,16 @@ function decode($0, $1, $2) {
11850
11855
  return decodeNamedCharacterReference($2) || $0;
11851
11856
  }
11852
11857
 
11858
+ // node_modules/micromark-util-classify-character/index.js
11859
+ function classifyCharacter(code3) {
11860
+ if (code3 === null || markdownLineEndingOrSpace(code3) || unicodeWhitespace(code3)) {
11861
+ return 1;
11862
+ }
11863
+ if (unicodePunctuation(code3)) {
11864
+ return 2;
11865
+ }
11866
+ }
11867
+
11853
11868
  // node_modules/mdast-util-gfm-table/lib/index.js
11854
11869
  function gfmTableFromMarkdown() {
11855
11870
  return {
@@ -12529,31 +12544,24 @@ function resolveAll(constructs2, events, context) {
12529
12544
  }
12530
12545
 
12531
12546
  // node_modules/micromark-core-commonmark/lib/attention.js
12532
- var attention = {
12547
+ var attention3 = {
12533
12548
  name: "attention",
12534
12549
  resolveAll: resolveAllAttention,
12535
12550
  tokenize: tokenizeAttention
12536
12551
  };
12537
12552
  function resolveAllAttention(events, context) {
12538
12553
  let index2 = -1;
12539
- let open;
12540
- let group;
12541
- let text5;
12542
- let openingSequence;
12543
- let closingSequence;
12544
- let use;
12545
12554
  let nextEvents;
12546
- let offset;
12547
12555
  while (++index2 < events.length) {
12548
12556
  if (events[index2][0] === "enter" && events[index2][1].type === "attentionSequence" && events[index2][1]._close) {
12549
- open = index2;
12557
+ let open = index2;
12550
12558
  while (open--) {
12551
12559
  if (events[open][0] === "exit" && events[open][1].type === "attentionSequence" && events[open][1]._open && // If the markers are the same:
12552
12560
  context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index2][1]).charCodeAt(0)) {
12553
12561
  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
12562
  continue;
12555
12563
  }
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;
12564
+ 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
12565
  const start = {
12558
12566
  ...events[open][1].end
12559
12567
  };
@@ -12562,21 +12570,21 @@ function resolveAllAttention(events, context) {
12562
12570
  };
12563
12571
  movePoint(start, -use);
12564
12572
  movePoint(end, use);
12565
- openingSequence = {
12573
+ const openingSequence = {
12566
12574
  type: use > 1 ? "strongSequence" : "emphasisSequence",
12567
12575
  start,
12568
12576
  end: {
12569
12577
  ...events[open][1].end
12570
12578
  }
12571
12579
  };
12572
- closingSequence = {
12580
+ const closingSequence = {
12573
12581
  type: use > 1 ? "strongSequence" : "emphasisSequence",
12574
12582
  start: {
12575
12583
  ...events[index2][1].start
12576
12584
  },
12577
12585
  end
12578
12586
  };
12579
- text5 = {
12587
+ const text5 = {
12580
12588
  type: use > 1 ? "strongText" : "emphasisText",
12581
12589
  start: {
12582
12590
  ...events[open][1].end
@@ -12585,7 +12593,7 @@ function resolveAllAttention(events, context) {
12585
12593
  ...events[index2][1].start
12586
12594
  }
12587
12595
  };
12588
- group = {
12596
+ const group = {
12589
12597
  type: use > 1 ? "strong" : "emphasis",
12590
12598
  start: {
12591
12599
  ...openingSequence.start
@@ -12607,11 +12615,10 @@ function resolveAllAttention(events, context) {
12607
12615
  nextEvents = push(nextEvents, [["enter", group, context], ["enter", openingSequence, context], ["exit", openingSequence, context], ["enter", text5, context]]);
12608
12616
  nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index2), context));
12609
12617
  nextEvents = push(nextEvents, [["exit", text5, context], ["enter", closingSequence, context], ["exit", closingSequence, context], ["exit", group, context]]);
12618
+ let offset = 0;
12610
12619
  if (events[index2][1].end.offset - events[index2][1].start.offset) {
12611
12620
  offset = 2;
12612
12621
  nextEvents = push(nextEvents, [["enter", events[index2][1], context], ["exit", events[index2][1], context]]);
12613
- } else {
12614
- offset = 0;
12615
12622
  }
12616
12623
  splice(events, open - 1, index2 - open + 3, nextEvents);
12617
12624
  index2 = open + nextEvents.length - offset - 2;
@@ -12646,8 +12653,8 @@ function tokenizeAttention(effects, ok3) {
12646
12653
  }
12647
12654
  const token = effects.exit("attentionSequence");
12648
12655
  const after = classifyCharacter(code3);
12649
- const open = !after || after === 2 && before || attentionMarkers2.includes(code3);
12650
- const close2 = !before || before === 2 && after || attentionMarkers2.includes(previous3);
12656
+ const open = !after || after === 2 && before || attentionMarkers2.includes(code3) && code3 !== 42 && code3 !== 95;
12657
+ const close2 = !before || before === 2 && after || attentionMarkers2.includes(previous3) && previous3 !== 42 && previous3 !== 95;
12651
12658
  token._open = Boolean(marker === 42 ? open : open && (before || !close2));
12652
12659
  token._close = Boolean(marker === 42 ? close2 : close2 && (after || !open));
12653
12660
  return ok3(code3);
@@ -12762,7 +12769,7 @@ function tokenizeAutolink(effects, ok3, nok) {
12762
12769
 
12763
12770
  // node_modules/micromark-factory-space/index.js
12764
12771
  function factorySpace(effects, ok3, type, max) {
12765
- const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
12772
+ const limit = max ? max - 1 : Infinity;
12766
12773
  let size = 0;
12767
12774
  return start;
12768
12775
  function start(code3) {
@@ -12781,6 +12788,29 @@ function factorySpace(effects, ok3, type, max) {
12781
12788
  return ok3(code3);
12782
12789
  }
12783
12790
  }
12791
+ function factorySpaceMinMax(effects, ok3, nok, type, min, max) {
12792
+ let size = 0;
12793
+ return start;
12794
+ function start(code3) {
12795
+ if (max > 0 && markdownSpace(code3)) {
12796
+ effects.enter(type);
12797
+ return prefix(code3);
12798
+ }
12799
+ return after(code3);
12800
+ }
12801
+ function prefix(code3) {
12802
+ if (markdownSpace(code3) && size < max) {
12803
+ effects.consume(code3);
12804
+ size++;
12805
+ return prefix;
12806
+ }
12807
+ effects.exit(type);
12808
+ return after(code3);
12809
+ }
12810
+ function after(code3) {
12811
+ return size >= min ? ok3(code3) : nok(code3);
12812
+ }
12813
+ }
12784
12814
 
12785
12815
  // node_modules/micromark-core-commonmark/lib/blank-line.js
12786
12816
  var blankLine = {
@@ -12946,17 +12976,35 @@ function tokenizeCharacterReference(effects, ok3, nok) {
12946
12976
  }
12947
12977
  }
12948
12978
 
12949
- // node_modules/micromark-core-commonmark/lib/code-fenced.js
12979
+ // node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.js
12950
12980
  var nonLazyContinuation = {
12951
12981
  partial: true,
12952
12982
  tokenize: tokenizeNonLazyContinuation
12953
12983
  };
12954
- var codeFenced = {
12955
- concrete: true,
12956
- name: "codeFenced",
12957
- tokenize: tokenizeCodeFenced
12958
- };
12959
- function tokenizeCodeFenced(effects, ok3, nok) {
12984
+ function tokenizeNonLazyContinuation(effects, ok3, nok) {
12985
+ const self = this;
12986
+ return start;
12987
+ function start(code3) {
12988
+ if (code3 === null) {
12989
+ return nok(code3);
12990
+ }
12991
+ effects.enter("lineEnding");
12992
+ effects.consume(code3);
12993
+ effects.exit("lineEnding");
12994
+ return after;
12995
+ }
12996
+ function after(code3) {
12997
+ return self.parser.lazy[self.now().line] ? nok(code3) : ok3(code3);
12998
+ }
12999
+ }
13000
+
13001
+ // node_modules/micromark-core-commonmark/lib/code-fenced.js
13002
+ var codeFenced = {
13003
+ concrete: true,
13004
+ name: "codeFenced",
13005
+ tokenize: tokenizeCodeFenced
13006
+ };
13007
+ function tokenizeCodeFenced(effects, ok3, nok) {
12960
13008
  const self = this;
12961
13009
  const closeStart = {
12962
13010
  partial: true,
@@ -13112,22 +13160,6 @@ function tokenizeCodeFenced(effects, ok3, nok) {
13112
13160
  }
13113
13161
  }
13114
13162
  }
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
13163
 
13132
13164
  // node_modules/micromark-core-commonmark/lib/code-indented.js
13133
13165
  var codeIndented = {
@@ -13139,15 +13171,10 @@ var furtherStart = {
13139
13171
  tokenize: tokenizeFurtherStart
13140
13172
  };
13141
13173
  function tokenizeCodeIndented(effects, ok3, nok) {
13142
- const self = this;
13143
13174
  return start;
13144
13175
  function start(code3) {
13145
13176
  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);
13177
+ return factorySpaceMinMax(effects, atBreak, nok, "linePrefix", 4, 4)(code3);
13151
13178
  }
13152
13179
  function atBreak(code3) {
13153
13180
  if (code3 === null) {
@@ -13185,11 +13212,10 @@ function tokenizeFurtherStart(effects, ok3, nok) {
13185
13212
  effects.exit("lineEnding");
13186
13213
  return furtherStart2;
13187
13214
  }
13188
- return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code3);
13215
+ return factorySpaceMinMax(effects, ok3, onNotEnoughPrefix, "linePrefix", 4, 4)(code3);
13189
13216
  }
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);
13217
+ function onNotEnoughPrefix(code3) {
13218
+ return markdownLineEnding(code3) ? furtherStart2(code3) : nok(code3);
13193
13219
  }
13194
13220
  }
13195
13221
 
@@ -14075,8 +14101,6 @@ var headingAtx = {
14075
14101
  function resolveHeadingAtx(events, context) {
14076
14102
  let contentEnd = events.length - 2;
14077
14103
  let contentStart = 3;
14078
- let content3;
14079
- let text5;
14080
14104
  if (events[contentStart][1].type === "whitespace") {
14081
14105
  contentStart += 2;
14082
14106
  }
@@ -14087,12 +14111,12 @@ function resolveHeadingAtx(events, context) {
14087
14111
  contentEnd -= contentStart + 1 === contentEnd ? 2 : 4;
14088
14112
  }
14089
14113
  if (contentEnd > contentStart) {
14090
- content3 = {
14114
+ const content3 = {
14091
14115
  type: "atxHeadingText",
14092
14116
  start: events[contentStart][1].start,
14093
14117
  end: events[contentEnd][1].end
14094
14118
  };
14095
- text5 = {
14119
+ const text5 = {
14096
14120
  type: "chunkText",
14097
14121
  start: events[contentStart][1].start,
14098
14122
  end: events[contentEnd][1].end,
@@ -14157,73 +14181,6 @@ function tokenizeHeadingAtx(effects, ok3, nok) {
14157
14181
  }
14158
14182
  }
14159
14183
 
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"];
14226
-
14227
14184
  // node_modules/micromark-core-commonmark/lib/html-flow.js
14228
14185
  var htmlFlow = {
14229
14186
  concrete: true,
@@ -14235,10 +14192,6 @@ var blankLineBefore = {
14235
14192
  partial: true,
14236
14193
  tokenize: tokenizeBlankLineBefore
14237
14194
  };
14238
- var nonLazyContinuationStart = {
14239
- partial: true,
14240
- tokenize: tokenizeNonLazyContinuationStart
14241
- };
14242
14195
  function resolveToHtmlFlow(events) {
14243
14196
  let index2 = events.length;
14244
14197
  while (index2--) {
@@ -14500,7 +14453,7 @@ function tokenizeHtmlFlow(effects, ok3, nok) {
14500
14453
  return continuation;
14501
14454
  }
14502
14455
  function continuationStart(code3) {
14503
- return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code3);
14456
+ return effects.check(nonLazyContinuation, continuationStartNonLazy, continuationAfter)(code3);
14504
14457
  }
14505
14458
  function continuationStartNonLazy(code3) {
14506
14459
  effects.enter("lineEnding");
@@ -14577,22 +14530,6 @@ function tokenizeHtmlFlow(effects, ok3, nok) {
14577
14530
  return ok3(code3);
14578
14531
  }
14579
14532
  }
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
14533
  function tokenizeBlankLineBefore(effects, ok3, nok) {
14597
14534
  return start;
14598
14535
  function start(code3) {
@@ -14945,12 +14882,11 @@ function resolveAllLabelEnd(events) {
14945
14882
  function resolveToLabelEnd(events, context) {
14946
14883
  let index2 = events.length;
14947
14884
  let offset = 0;
14948
- let token;
14949
14885
  let open;
14950
14886
  let close2;
14951
14887
  let media;
14952
14888
  while (index2--) {
14953
- token = events[index2][1];
14889
+ const token = events[index2][1];
14954
14890
  if (open) {
14955
14891
  if (token.type === "link" || token.type === "labelLink" && token._inactive) {
14956
14892
  break;
@@ -15009,14 +14945,14 @@ function resolveToLabelEnd(events, context) {
15009
14945
  }
15010
14946
  function tokenizeLabelEnd(effects, ok3, nok) {
15011
14947
  const self = this;
15012
- let index2 = self.events.length;
14948
+ const labelStarts = self._labelStarts;
15013
14949
  let labelStart;
15014
14950
  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;
14951
+ if (labelStarts) {
14952
+ while (labelStarts.length > 0 && labelStarts[labelStarts.length - 1]._balanced) {
14953
+ labelStarts.pop();
15019
14954
  }
14955
+ labelStart = labelStarts[labelStarts.length - 1];
15020
14956
  }
15021
14957
  return start;
15022
14958
  function start(code3) {
@@ -15050,6 +14986,7 @@ function tokenizeLabelEnd(effects, ok3, nok) {
15050
14986
  return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code3);
15051
14987
  }
15052
14988
  function labelEndOk(code3) {
14989
+ labelStarts.pop();
15053
14990
  return ok3(code3);
15054
14991
  }
15055
14992
  function labelEndNok(code3) {
@@ -15143,6 +15080,7 @@ var labelStartImage = {
15143
15080
  };
15144
15081
  function tokenizeLabelStartImage(effects, ok3, nok) {
15145
15082
  const self = this;
15083
+ let labelImage;
15146
15084
  return start;
15147
15085
  function start(code3) {
15148
15086
  effects.enter("labelImage");
@@ -15156,13 +15094,18 @@ function tokenizeLabelStartImage(effects, ok3, nok) {
15156
15094
  effects.enter("labelMarker");
15157
15095
  effects.consume(code3);
15158
15096
  effects.exit("labelMarker");
15159
- effects.exit("labelImage");
15097
+ labelImage = effects.exit("labelImage");
15160
15098
  return after;
15161
15099
  }
15162
15100
  return nok(code3);
15163
15101
  }
15164
15102
  function after(code3) {
15165
- return code3 === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code3) : ok3(code3);
15103
+ if (code3 === 94 && "_hiddenFootnoteSupport" in self.parser.constructs) {
15104
+ return nok(code3);
15105
+ }
15106
+ self._labelStarts = self._labelStarts || [];
15107
+ self._labelStarts.push(labelImage);
15108
+ return ok3(code3);
15166
15109
  }
15167
15110
  }
15168
15111
 
@@ -15174,17 +15117,23 @@ var labelStartLink = {
15174
15117
  };
15175
15118
  function tokenizeLabelStartLink(effects, ok3, nok) {
15176
15119
  const self = this;
15120
+ let labelLink;
15177
15121
  return start;
15178
15122
  function start(code3) {
15179
15123
  effects.enter("labelLink");
15180
15124
  effects.enter("labelMarker");
15181
15125
  effects.consume(code3);
15182
15126
  effects.exit("labelMarker");
15183
- effects.exit("labelLink");
15127
+ labelLink = effects.exit("labelLink");
15184
15128
  return after;
15185
15129
  }
15186
15130
  function after(code3) {
15187
- return code3 === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code3) : ok3(code3);
15131
+ if (code3 === 94 && "_hiddenFootnoteSupport" in self.parser.constructs) {
15132
+ return nok(code3);
15133
+ }
15134
+ self._labelStarts = self._labelStarts || [];
15135
+ self._labelStarts.push(labelLink);
15136
+ return ok3(code3);
15188
15137
  }
15189
15138
  }
15190
15139
 
@@ -15372,6 +15321,104 @@ function tokenizeListItemPrefixWhitespace(effects, ok3, nok) {
15372
15321
  }
15373
15322
  }
15374
15323
 
15324
+ // node_modules/micromark-util-edit-map/index.js
15325
+ var EditMap = class {
15326
+ /**
15327
+ * Create a new edit map.
15328
+ *
15329
+ * @returns
15330
+ * New instance.
15331
+ */
15332
+ constructor() {
15333
+ this.index = /* @__PURE__ */ new Map();
15334
+ this.map = [];
15335
+ }
15336
+ /**
15337
+ * Create an edit: a remove and/or add at a certain place.
15338
+ *
15339
+ * @param {number} index
15340
+ * Index at which to apply the edit.
15341
+ * @param {number} remove
15342
+ * Count of items to remove at the index.
15343
+ * @param {Array<Event>} add
15344
+ * Items to add at the index.
15345
+ * @returns {undefined}
15346
+ * Nothing.
15347
+ */
15348
+ add(index2, remove, add) {
15349
+ addImplementation(this, index2, remove, add, false);
15350
+ }
15351
+ /**
15352
+ * Create an edit: but insert `add` before existing additions, instead of
15353
+ * after them.
15354
+ *
15355
+ * @param {number} index
15356
+ * Index at which to apply the edit.
15357
+ * @param {number} remove
15358
+ * Count of items to remove at the index.
15359
+ * @param {Array<Event>} add
15360
+ * Items to add at the index.
15361
+ * @returns {undefined}
15362
+ * Nothing.
15363
+ */
15364
+ addBefore(index2, remove, add) {
15365
+ addImplementation(this, index2, remove, add, true);
15366
+ }
15367
+ /**
15368
+ * Done, change the events.
15369
+ *
15370
+ * @param {Array<Event>} events
15371
+ * List of events to apply the edits to.
15372
+ * @returns {undefined}
15373
+ * Nothing.
15374
+ */
15375
+ consume(events) {
15376
+ this.map.sort(function(a, b) {
15377
+ return a[0] - b[0];
15378
+ });
15379
+ if (this.map.length === 0) {
15380
+ return;
15381
+ }
15382
+ let index2 = this.map.length;
15383
+ const vecs = [];
15384
+ while (index2 > 0) {
15385
+ index2 -= 1;
15386
+ vecs.push(events.slice(this.map[index2][0] + this.map[index2][1]), this.map[index2][2]);
15387
+ events.length = this.map[index2][0];
15388
+ }
15389
+ vecs.push(events.slice());
15390
+ events.length = 0;
15391
+ let slice = vecs.pop();
15392
+ while (slice) {
15393
+ for (const element of slice) {
15394
+ events.push(element);
15395
+ }
15396
+ slice = vecs.pop();
15397
+ }
15398
+ this.map.length = 0;
15399
+ this.index.clear();
15400
+ }
15401
+ };
15402
+ function addImplementation(editMap, at, remove, add, before) {
15403
+ if (remove === 0 && add.length === 0) {
15404
+ return;
15405
+ }
15406
+ const existing = editMap.index.get(at);
15407
+ if (existing) {
15408
+ existing[1] += remove;
15409
+ if (before) {
15410
+ add.push(...existing[2]);
15411
+ existing[2] = add;
15412
+ } else {
15413
+ existing[2].push(...add);
15414
+ }
15415
+ return;
15416
+ }
15417
+ const change = [at, remove, add];
15418
+ editMap.map.push(change);
15419
+ editMap.index.set(at, change);
15420
+ }
15421
+
15375
15422
  // node_modules/micromark-core-commonmark/lib/setext-underline.js
15376
15423
  var setextUnderline = {
15377
15424
  name: "setextUnderline",
@@ -15379,6 +15426,7 @@ var setextUnderline = {
15379
15426
  tokenize: tokenizeSetextUnderline
15380
15427
  };
15381
15428
  function resolveToSetextUnderline(events, context) {
15429
+ const editMap = new EditMap();
15382
15430
  let index2 = events.length;
15383
15431
  let content3;
15384
15432
  let text5;
@@ -15394,7 +15442,7 @@ function resolveToSetextUnderline(events, context) {
15394
15442
  }
15395
15443
  } else {
15396
15444
  if (events[index2][1].type === "content") {
15397
- events.splice(index2, 1);
15445
+ editMap.add(index2, 1, []);
15398
15446
  }
15399
15447
  if (!definition3 && events[index2][1].type === "definition") {
15400
15448
  definition3 = index2;
@@ -15412,15 +15460,16 @@ function resolveToSetextUnderline(events, context) {
15412
15460
  };
15413
15461
  events[text5][1].type = "setextHeadingText";
15414
15462
  if (definition3) {
15415
- events.splice(text5, 0, ["enter", heading2, context]);
15416
- events.splice(definition3 + 1, 0, ["exit", events[content3][1], context]);
15463
+ editMap.add(text5, 0, [["enter", heading2, context]]);
15464
+ editMap.add(definition3 + 1, 0, [["exit", events[content3][1], context]]);
15417
15465
  events[content3][1].end = {
15418
15466
  ...events[definition3][1].end
15419
15467
  };
15420
15468
  } else {
15421
15469
  events[content3][1] = heading2;
15422
15470
  }
15423
- events.push(["exit", heading2, context]);
15471
+ editMap.add(events.length, 0, [["exit", heading2, context]]);
15472
+ editMap.consume(events);
15424
15473
  return events;
15425
15474
  }
15426
15475
  function tokenizeSetextUnderline(effects, ok3, nok) {
@@ -15834,23 +15883,28 @@ function gfmStrikethrough(options) {
15834
15883
  }
15835
15884
 
15836
15885
  // node_modules/micromark-extension-gfm-table/lib/edit-map.js
15837
- var EditMap = class {
15886
+ var EditMap2 = class {
15838
15887
  /**
15839
15888
  * Create a new edit map.
15840
15889
  */
15841
15890
  constructor() {
15842
15891
  this.map = [];
15892
+ this.index = /* @__PURE__ */ new Map();
15843
15893
  }
15844
15894
  /**
15845
15895
  * Create an edit: a remove and/or add at a certain place.
15846
15896
  *
15847
15897
  * @param {number} index
15898
+ * Index at which to apply the edit.
15848
15899
  * @param {number} remove
15900
+ * Count of items to remove at the index.
15849
15901
  * @param {Array<Event>} add
15902
+ * Items to add at the index.
15850
15903
  * @returns {undefined}
15904
+ * Nothing.
15851
15905
  */
15852
15906
  add(index2, remove, add) {
15853
- addImplementation(this, index2, remove, add);
15907
+ addImplementation2(this, index2, remove, add);
15854
15908
  }
15855
15909
  // To do: add this when moving to `micromark`.
15856
15910
  // /**
@@ -15868,7 +15922,9 @@ var EditMap = class {
15868
15922
  * Done, change the events.
15869
15923
  *
15870
15924
  * @param {Array<Event>} events
15925
+ * List of events to apply the edits to.
15871
15926
  * @returns {undefined}
15927
+ * Nothing.
15872
15928
  */
15873
15929
  consume(events) {
15874
15930
  this.map.sort(function(a, b) {
@@ -15894,22 +15950,22 @@ var EditMap = class {
15894
15950
  slice = vecs.pop();
15895
15951
  }
15896
15952
  this.map.length = 0;
15953
+ this.index.clear();
15897
15954
  }
15898
15955
  };
15899
- function addImplementation(editMap, at, remove, add) {
15900
- let index2 = 0;
15956
+ function addImplementation2(editMap, at, remove, add) {
15901
15957
  if (remove === 0 && add.length === 0) {
15902
15958
  return;
15903
15959
  }
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;
15960
+ const existing = editMap.index.get(at);
15961
+ if (existing) {
15962
+ existing[1] += remove;
15963
+ existing[2].push(...add);
15964
+ return;
15911
15965
  }
15912
- editMap.map.push([at, remove, add]);
15966
+ const change = [at, remove, add];
15967
+ editMap.map.push(change);
15968
+ editMap.index.set(at, change);
15913
15969
  }
15914
15970
 
15915
15971
  // node_modules/micromark-extension-gfm-table/lib/infer.js
@@ -15960,10 +16016,15 @@ function tokenizeTable(effects, ok3, nok) {
15960
16016
  function start(code3) {
15961
16017
  let index2 = self.events.length - 1;
15962
16018
  while (index2 > -1) {
15963
- const type = self.events[index2][1].type;
16019
+ const {
16020
+ type
16021
+ } = self.events[index2][1];
15964
16022
  if (type === "lineEnding" || // Note: markdown-rs uses `whitespace` instead of `linePrefix`
15965
- type === "linePrefix") index2--;
15966
- else break;
16023
+ type === "linePrefix") {
16024
+ index2--;
16025
+ } else {
16026
+ break;
16027
+ }
15967
16028
  }
15968
16029
  const tail = index2 > -1 ? self.events[index2][1].type : null;
15969
16030
  const next = tail === "tableHead" || tail === "tableRow" ? bodyRowStart : headRowBefore;
@@ -16177,7 +16238,7 @@ function resolveTable(events, context) {
16177
16238
  let currentTable;
16178
16239
  let currentBody;
16179
16240
  let currentCell;
16180
- const map3 = new EditMap();
16241
+ const map3 = new EditMap2();
16181
16242
  while (++index2 < events.length) {
16182
16243
  const event = events[index2];
16183
16244
  const token = event[1];
@@ -16524,8 +16585,10 @@ function initializeDocument(effects) {
16524
16585
  };
16525
16586
  index2++;
16526
16587
  }
16527
- splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
16528
- self.events.length = index2;
16588
+ const editMap = new EditMap();
16589
+ editMap.add(indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
16590
+ editMap.add(indexBeforeExits, index2 - indexBeforeExits, []);
16591
+ editMap.consume(self.events);
16529
16592
  return checkNewContainers(code3);
16530
16593
  }
16531
16594
  return start(code3);
@@ -16544,7 +16607,9 @@ function initializeDocument(effects) {
16544
16607
  return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code3);
16545
16608
  }
16546
16609
  function thereIsANewContainer(code3) {
16547
- if (childFlow) closeFlow();
16610
+ if (childFlow) {
16611
+ closeFlow();
16612
+ }
16548
16613
  exitContainers(continued);
16549
16614
  return documentContinued(code3);
16550
16615
  }
@@ -16564,7 +16629,9 @@ function initializeDocument(effects) {
16564
16629
  }
16565
16630
  function flowStart(code3) {
16566
16631
  if (code3 === null) {
16567
- if (childFlow) closeFlow();
16632
+ if (childFlow) {
16633
+ closeFlow();
16634
+ }
16568
16635
  exitContainers(0);
16569
16636
  effects.consume(code3);
16570
16637
  return;
@@ -16596,9 +16663,13 @@ function initializeDocument(effects) {
16596
16663
  }
16597
16664
  function writeToChild(token, endOfFile) {
16598
16665
  const stream = self.sliceStream(token);
16599
- if (endOfFile) stream.push(null);
16666
+ if (endOfFile) {
16667
+ stream.push(null);
16668
+ }
16600
16669
  token.previous = childToken;
16601
- if (childToken) childToken.next = token;
16670
+ if (childToken) {
16671
+ childToken.next = token;
16672
+ }
16602
16673
  childToken = token;
16603
16674
  childFlow.defineSkip(token.start);
16604
16675
  childFlow.write(stream);
@@ -16635,8 +16706,10 @@ function initializeDocument(effects) {
16635
16706
  };
16636
16707
  index2++;
16637
16708
  }
16638
- splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
16639
- self.events.length = index2;
16709
+ const editMap = new EditMap();
16710
+ editMap.add(indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
16711
+ editMap.add(indexBeforeExits, index2 - indexBeforeExits, []);
16712
+ editMap.consume(self.events);
16640
16713
  }
16641
16714
  }
16642
16715
  function exitContainers(size) {
@@ -16775,6 +16848,7 @@ function createResolver(extraResolver) {
16775
16848
  }
16776
16849
  }
16777
16850
  function resolveAllLineSuffixes(events, context) {
16851
+ const editMap = new EditMap();
16778
16852
  let eventIndex = 0;
16779
16853
  while (++eventIndex <= events.length) {
16780
16854
  if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") {
@@ -16792,7 +16866,9 @@ function resolveAllLineSuffixes(events, context) {
16792
16866
  size++;
16793
16867
  bufferIndex--;
16794
16868
  }
16795
- if (bufferIndex) break;
16869
+ if (bufferIndex) {
16870
+ break;
16871
+ }
16796
16872
  bufferIndex = -1;
16797
16873
  } else if (chunk === -2) {
16798
16874
  tabs = true;
@@ -16826,13 +16902,13 @@ function resolveAllLineSuffixes(events, context) {
16826
16902
  if (data.start.offset === data.end.offset) {
16827
16903
  Object.assign(data, token);
16828
16904
  } else {
16829
- events.splice(eventIndex, 0, ["enter", token, context], ["exit", token, context]);
16830
- eventIndex += 2;
16905
+ editMap.add(eventIndex, 0, [["enter", token, context], ["exit", token, context]]);
16831
16906
  }
16832
16907
  }
16833
16908
  eventIndex++;
16834
16909
  }
16835
16910
  }
16911
+ editMap.consume(events);
16836
16912
  return events;
16837
16913
  }
16838
16914
 
@@ -16893,16 +16969,16 @@ var text4 = {
16893
16969
  [-3]: lineEnding,
16894
16970
  [33]: labelStartImage,
16895
16971
  [38]: characterReference,
16896
- [42]: attention,
16972
+ [42]: attention3,
16897
16973
  [60]: [autolink, htmlText],
16898
16974
  [91]: labelStartLink,
16899
16975
  [92]: [hardBreakEscape, characterEscape],
16900
16976
  [93]: labelEnd,
16901
- [95]: attention,
16977
+ [95]: attention3,
16902
16978
  [96]: codeText
16903
16979
  };
16904
16980
  var insideSpan = {
16905
- null: [attention, resolver]
16981
+ null: [attention3, resolver]
16906
16982
  };
16907
16983
  var attentionMarkers = {
16908
16984
  null: [42, 95]
@@ -16990,11 +17066,10 @@ function createTokenizer(parser, initialize, from) {
16990
17066
  accountForPotentialSkip();
16991
17067
  }
16992
17068
  function main() {
16993
- let chunkIndex;
16994
17069
  while (point3._index < chunks.length) {
16995
17070
  const chunk = chunks[point3._index];
16996
17071
  if (typeof chunk === "string") {
16997
- chunkIndex = point3._index;
17072
+ const chunkIndex = point3._index;
16998
17073
  if (point3._bufferIndex < 0) {
16999
17074
  point3._bufferIndex = 0;
17000
17075
  }
@@ -17202,30 +17277,34 @@ function serializeChunks(chunks, expandTabs) {
17202
17277
  let value2;
17203
17278
  if (typeof chunk === "string") {
17204
17279
  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);
17280
+ } else {
17281
+ switch (chunk) {
17282
+ case -5: {
17283
+ value2 = "\r";
17284
+ break;
17285
+ }
17286
+ case -4: {
17287
+ value2 = "\n";
17288
+ break;
17289
+ }
17290
+ case -3: {
17291
+ value2 = "\r\n";
17292
+ break;
17293
+ }
17294
+ case -2: {
17295
+ value2 = expandTabs ? " " : " ";
17296
+ break;
17297
+ }
17298
+ case -1: {
17299
+ if (!expandTabs && atTab) {
17300
+ continue;
17301
+ }
17302
+ value2 = " ";
17303
+ break;
17304
+ }
17305
+ default: {
17306
+ value2 = String.fromCharCode(chunk);
17307
+ }
17229
17308
  }
17230
17309
  }
17231
17310
  atTab = chunk === -2;
@@ -17276,14 +17355,9 @@ function preprocess() {
17276
17355
  let atCarriageReturn;
17277
17356
  return preprocessor;
17278
17357
  function preprocessor(value2, encoding, end) {
17279
- const chunks = [];
17280
- let match;
17281
- let next;
17282
- let startPosition;
17283
- let endPosition;
17284
- let code3;
17285
17358
  value2 = buffer + (typeof value2 === "string" ? value2.toString() : new TextDecoder(encoding || void 0).decode(value2));
17286
- startPosition = 0;
17359
+ const chunks = [];
17360
+ let startPosition = 0;
17287
17361
  buffer = "";
17288
17362
  if (start) {
17289
17363
  if (value2.charCodeAt(0) === 65279) {
@@ -17293,9 +17367,9 @@ function preprocess() {
17293
17367
  }
17294
17368
  while (startPosition < value2.length) {
17295
17369
  search.lastIndex = startPosition;
17296
- match = search.exec(value2);
17297
- endPosition = match && match.index !== void 0 ? match.index : value2.length;
17298
- code3 = value2.charCodeAt(endPosition);
17370
+ const match = search.exec(value2);
17371
+ const endPosition = match && match.index !== void 0 ? match.index : value2.length;
17372
+ const code3 = value2.charCodeAt(endPosition);
17299
17373
  if (!match) {
17300
17374
  buffer = value2.slice(startPosition);
17301
17375
  break;
@@ -17319,9 +17393,11 @@ function preprocess() {
17319
17393
  break;
17320
17394
  }
17321
17395
  case 9: {
17322
- next = Math.ceil(column / 4) * 4;
17396
+ const next = Math.ceil(column / 4) * 4;
17323
17397
  chunks.push(-2);
17324
- while (column++ < next) chunks.push(-1);
17398
+ while (column++ < next) {
17399
+ chunks.push(-1);
17400
+ }
17325
17401
  break;
17326
17402
  }
17327
17403
  case 10: {
@@ -17338,8 +17414,12 @@ function preprocess() {
17338
17414
  startPosition = endPosition + 1;
17339
17415
  }
17340
17416
  if (end) {
17341
- if (atCarriageReturn) chunks.push(-5);
17342
- if (buffer) chunks.push(buffer);
17417
+ if (atCarriageReturn) {
17418
+ chunks.push(-5);
17419
+ }
17420
+ if (buffer) {
17421
+ chunks.push(buffer);
17422
+ }
17343
17423
  chunks.push(null);
17344
17424
  }
17345
17425
  return chunks;
@@ -17383,6 +17463,8 @@ function fromMarkdown(value2, encoding, options) {
17383
17463
  }
17384
17464
  function compiler(options) {
17385
17465
  const config = {
17466
+ afterExit: [],
17467
+ beforeEnter: [],
17386
17468
  transforms: [],
17387
17469
  canContainEols: ["emphasis", "fragment", "heading", "paragraph", "strong"],
17388
17470
  enter: {
@@ -17486,7 +17568,8 @@ function compiler(options) {
17486
17568
  function compile(events) {
17487
17569
  let tree = {
17488
17570
  type: "root",
17489
- children: []
17571
+ children: [],
17572
+ position: void 0
17490
17573
  };
17491
17574
  const context = {
17492
17575
  stack: [tree],
@@ -17499,24 +17582,40 @@ function compiler(options) {
17499
17582
  data
17500
17583
  };
17501
17584
  const listStack = [];
17585
+ const prepared = [];
17502
17586
  let index2 = -1;
17503
17587
  while (++index2 < events.length) {
17588
+ prepared.push(events[index2]);
17504
17589
  if (events[index2][1].type === "listOrdered" || events[index2][1].type === "listUnordered") {
17505
17590
  if (events[index2][0] === "enter") {
17506
- listStack.push(index2);
17591
+ listStack.push(prepared.length - 1);
17507
17592
  } else {
17508
17593
  const tail = listStack.pop();
17509
- index2 = prepareList(events, tail, index2);
17594
+ prepareList(prepared, tail);
17510
17595
  }
17511
17596
  }
17512
17597
  }
17598
+ events = prepared;
17513
17599
  index2 = -1;
17514
17600
  while (++index2 < events.length) {
17515
17601
  const handler2 = config[events[index2][0]];
17602
+ if (events[index2][0] === "enter" && config.beforeEnter.length > 0) {
17603
+ callListeners(config.beforeEnter, {
17604
+ ...context,
17605
+ sliceSerialize: events[index2][2].sliceSerialize
17606
+ }, events[index2][1]);
17607
+ }
17516
17608
  if (own3.call(handler2, events[index2][1].type)) {
17517
- handler2[events[index2][1].type].call(Object.assign({
17609
+ handler2[events[index2][1].type].call({
17610
+ ...context,
17518
17611
  sliceSerialize: events[index2][2].sliceSerialize
17519
- }, context), events[index2][1]);
17612
+ }, events[index2][1]);
17613
+ }
17614
+ if (events[index2][0] === "exit" && config.afterExit.length > 0) {
17615
+ callListeners(config.afterExit, {
17616
+ ...context,
17617
+ sliceSerialize: events[index2][2].sliceSerialize
17618
+ }, events[index2][1]);
17520
17619
  }
17521
17620
  }
17522
17621
  if (context.tokenStack.length > 0) {
@@ -17542,7 +17641,14 @@ function compiler(options) {
17542
17641
  }
17543
17642
  return tree;
17544
17643
  }
17545
- function prepareList(events, start, length) {
17644
+ function callListeners(listeners, context, token) {
17645
+ let index2 = -1;
17646
+ while (++index2 < listeners.length) {
17647
+ listeners[index2].call(context, token);
17648
+ }
17649
+ }
17650
+ function prepareList(events, start) {
17651
+ const end = events.length - 1;
17546
17652
  let index2 = start - 1;
17547
17653
  let containerBalance = -1;
17548
17654
  let listSpread = false;
@@ -17550,7 +17656,8 @@ function compiler(options) {
17550
17656
  let lineIndex;
17551
17657
  let firstBlankLineIndex;
17552
17658
  let atMarker;
17553
- while (++index2 <= length) {
17659
+ const insertions = [];
17660
+ while (++index2 <= end) {
17554
17661
  const event = events[index2];
17555
17662
  switch (event[1].type) {
17556
17663
  case "listUnordered":
@@ -17607,9 +17714,10 @@ function compiler(options) {
17607
17714
  listItem3._spread = true;
17608
17715
  }
17609
17716
  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++;
17717
+ insertions.push({
17718
+ at: lineIndex || index2,
17719
+ event: ["exit", listItem3, event[2]]
17720
+ });
17613
17721
  }
17614
17722
  if (event[1].type === "listItemPrefix") {
17615
17723
  const item = {
@@ -17620,16 +17728,25 @@ function compiler(options) {
17620
17728
  end: void 0
17621
17729
  };
17622
17730
  listItem3 = item;
17623
- events.splice(index2, 0, ["enter", item, event[2]]);
17624
- index2++;
17625
- length++;
17731
+ insertions.push({
17732
+ at: index2,
17733
+ event: ["enter", item, event[2]]
17734
+ });
17626
17735
  firstBlankLineIndex = void 0;
17627
17736
  atMarker = true;
17628
17737
  }
17629
17738
  }
17630
17739
  }
17740
+ const listEvents = events.splice(start);
17741
+ let insertion = 0;
17742
+ index2 = -1;
17743
+ while (++index2 < listEvents.length) {
17744
+ while (insertion < insertions.length && insertions[insertion].at === start + index2) {
17745
+ events.push(insertions[insertion++].event);
17746
+ }
17747
+ events.push(listEvents[index2]);
17748
+ }
17631
17749
  events[start][1]._spread = listSpread;
17632
- return length;
17633
17750
  }
17634
17751
  function opener2(create2, and) {
17635
17752
  return open;
@@ -17671,7 +17788,8 @@ function compiler(options) {
17671
17788
  start: token.start,
17672
17789
  end: token.end
17673
17790
  }) + "): it\u2019s not open");
17674
- } else if (open[0].type !== token.type) {
17791
+ }
17792
+ if (open[0].type !== token.type) {
17675
17793
  if (onExitError) {
17676
17794
  onExitError.call(this, token, open[0]);
17677
17795
  } else {
@@ -17907,7 +18025,8 @@ function compiler(options) {
17907
18025
  function blockQuote2() {
17908
18026
  return {
17909
18027
  type: "blockquote",
17910
- children: []
18028
+ children: [],
18029
+ position: void 0
17911
18030
  };
17912
18031
  }
17913
18032
  function codeFlow() {
@@ -17915,13 +18034,15 @@ function compiler(options) {
17915
18034
  type: "code",
17916
18035
  lang: null,
17917
18036
  meta: null,
17918
- value: ""
18037
+ value: "",
18038
+ position: void 0
17919
18039
  };
17920
18040
  }
17921
18041
  function codeText2() {
17922
18042
  return {
17923
18043
  type: "inlineCode",
17924
- value: ""
18044
+ value: "",
18045
+ position: void 0
17925
18046
  };
17926
18047
  }
17927
18048
  function definition3() {
@@ -17930,13 +18051,15 @@ function compiler(options) {
17930
18051
  identifier: "",
17931
18052
  label: null,
17932
18053
  title: null,
17933
- url: ""
18054
+ url: "",
18055
+ position: void 0
17934
18056
  };
17935
18057
  }
17936
18058
  function emphasis2() {
17937
18059
  return {
17938
18060
  type: "emphasis",
17939
- children: []
18061
+ children: [],
18062
+ position: void 0
17940
18063
  };
17941
18064
  }
17942
18065
  function heading2() {
@@ -17944,18 +18067,21 @@ function compiler(options) {
17944
18067
  type: "heading",
17945
18068
  // @ts-expect-error `depth` will be set later.
17946
18069
  depth: 0,
17947
- children: []
18070
+ children: [],
18071
+ position: void 0
17948
18072
  };
17949
18073
  }
17950
18074
  function hardBreak2() {
17951
18075
  return {
17952
- type: "break"
18076
+ type: "break",
18077
+ position: void 0
17953
18078
  };
17954
18079
  }
17955
18080
  function html2() {
17956
18081
  return {
17957
18082
  type: "html",
17958
- value: ""
18083
+ value: "",
18084
+ position: void 0
17959
18085
  };
17960
18086
  }
17961
18087
  function image2() {
@@ -17963,7 +18089,8 @@ function compiler(options) {
17963
18089
  type: "image",
17964
18090
  title: null,
17965
18091
  url: "",
17966
- alt: null
18092
+ alt: null,
18093
+ position: void 0
17967
18094
  };
17968
18095
  }
17969
18096
  function link2() {
@@ -17971,7 +18098,8 @@ function compiler(options) {
17971
18098
  type: "link",
17972
18099
  title: null,
17973
18100
  url: "",
17974
- children: []
18101
+ children: [],
18102
+ position: void 0
17975
18103
  };
17976
18104
  }
17977
18105
  function list3(token) {
@@ -17980,7 +18108,8 @@ function compiler(options) {
17980
18108
  ordered: token.type === "listOrdered",
17981
18109
  start: null,
17982
18110
  spread: token._spread,
17983
- children: []
18111
+ children: [],
18112
+ position: void 0
17984
18113
  };
17985
18114
  }
17986
18115
  function listItem2(token) {
@@ -17988,30 +18117,35 @@ function compiler(options) {
17988
18117
  type: "listItem",
17989
18118
  spread: token._spread,
17990
18119
  checked: null,
17991
- children: []
18120
+ children: [],
18121
+ position: void 0
17992
18122
  };
17993
18123
  }
17994
18124
  function paragraph2() {
17995
18125
  return {
17996
18126
  type: "paragraph",
17997
- children: []
18127
+ children: [],
18128
+ position: void 0
17998
18129
  };
17999
18130
  }
18000
18131
  function strong2() {
18001
18132
  return {
18002
18133
  type: "strong",
18003
- children: []
18134
+ children: [],
18135
+ position: void 0
18004
18136
  };
18005
18137
  }
18006
18138
  function text5() {
18007
18139
  return {
18008
18140
  type: "text",
18009
- value: ""
18141
+ value: "",
18142
+ position: void 0
18010
18143
  };
18011
18144
  }
18012
18145
  function thematicBreak3() {
18013
18146
  return {
18014
- type: "thematicBreak"
18147
+ type: "thematicBreak",
18148
+ position: void 0
18015
18149
  };
18016
18150
  }
18017
18151
  }
@@ -18052,6 +18186,14 @@ function extension(combined, extension2) {
18052
18186
  }
18053
18187
  break;
18054
18188
  }
18189
+ case "afterExit":
18190
+ case "beforeEnter": {
18191
+ const right = extension2[key];
18192
+ if (right) {
18193
+ combined[key].push(right);
18194
+ }
18195
+ break;
18196
+ }
18055
18197
  case "enter":
18056
18198
  case "exit": {
18057
18199
  const right = extension2[key];
@@ -18073,12 +18215,11 @@ function defaultOnError(left, right) {
18073
18215
  start: right.start,
18074
18216
  end: right.end
18075
18217
  }) + ") 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
18218
  }
18219
+ throw new Error("Cannot close document, a token (`" + right.type + "`, " + stringifyPosition({
18220
+ start: right.start,
18221
+ end: right.end
18222
+ }) + ") is still open");
18082
18223
  }
18083
18224
 
18084
18225
  // node_modules/remark-parse/lib/index.js
@@ -19966,4 +20107,4 @@ export {
19966
20107
  markdownToBlocks,
19967
20108
  parseMarkdownDocument
19968
20109
  };
19969
- //# sourceMappingURL=chunk-CHMDS2SX.js.map
20110
+ //# sourceMappingURL=chunk-FWYKR6IX.js.map