@michengai/dsh-btw 0.1.24 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -2869,7 +2869,7 @@ function normalizeUri(value) {
2869
2869
 
2870
2870
  // node_modules/micromark-factory-space/index.js
2871
2871
  function factorySpace(effects, ok3, type, max) {
2872
- const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
2872
+ const limit = max ? max - 1 : Infinity;
2873
2873
  let size = 0;
2874
2874
  return start2;
2875
2875
  function start2(code4) {
@@ -2888,6 +2888,29 @@ function factorySpace(effects, ok3, type, max) {
2888
2888
  return ok3(code4);
2889
2889
  }
2890
2890
  }
2891
+ function factorySpaceMinMax(effects, ok3, nok, type, min, max) {
2892
+ let size = 0;
2893
+ return start2;
2894
+ function start2(code4) {
2895
+ if (max > 0 && markdownSpace(code4)) {
2896
+ effects.enter(type);
2897
+ return prefix(code4);
2898
+ }
2899
+ return after(code4);
2900
+ }
2901
+ function prefix(code4) {
2902
+ if (markdownSpace(code4) && size < max) {
2903
+ effects.consume(code4);
2904
+ size++;
2905
+ return prefix;
2906
+ }
2907
+ effects.exit(type);
2908
+ return after(code4);
2909
+ }
2910
+ function after(code4) {
2911
+ return size >= min ? ok3(code4) : nok(code4);
2912
+ }
2913
+ }
2891
2914
 
2892
2915
  // node_modules/micromark/lib/initialize/content.js
2893
2916
  var content = {
@@ -2939,6 +2962,104 @@ function initializeContent(effects) {
2939
2962
  }
2940
2963
  }
2941
2964
 
2965
+ // node_modules/micromark-util-edit-map/index.js
2966
+ var EditMap = class {
2967
+ /**
2968
+ * Create a new edit map.
2969
+ *
2970
+ * @returns
2971
+ * New instance.
2972
+ */
2973
+ constructor() {
2974
+ this.index = /* @__PURE__ */ new Map();
2975
+ this.map = [];
2976
+ }
2977
+ /**
2978
+ * Create an edit: a remove and/or add at a certain place.
2979
+ *
2980
+ * @param {number} index
2981
+ * Index at which to apply the edit.
2982
+ * @param {number} remove
2983
+ * Count of items to remove at the index.
2984
+ * @param {Array<Event>} add
2985
+ * Items to add at the index.
2986
+ * @returns {undefined}
2987
+ * Nothing.
2988
+ */
2989
+ add(index2, remove, add) {
2990
+ addImplementation(this, index2, remove, add, false);
2991
+ }
2992
+ /**
2993
+ * Create an edit: but insert `add` before existing additions, instead of
2994
+ * after them.
2995
+ *
2996
+ * @param {number} index
2997
+ * Index at which to apply the edit.
2998
+ * @param {number} remove
2999
+ * Count of items to remove at the index.
3000
+ * @param {Array<Event>} add
3001
+ * Items to add at the index.
3002
+ * @returns {undefined}
3003
+ * Nothing.
3004
+ */
3005
+ addBefore(index2, remove, add) {
3006
+ addImplementation(this, index2, remove, add, true);
3007
+ }
3008
+ /**
3009
+ * Done, change the events.
3010
+ *
3011
+ * @param {Array<Event>} events
3012
+ * List of events to apply the edits to.
3013
+ * @returns {undefined}
3014
+ * Nothing.
3015
+ */
3016
+ consume(events) {
3017
+ this.map.sort(function(a, b) {
3018
+ return a[0] - b[0];
3019
+ });
3020
+ if (this.map.length === 0) {
3021
+ return;
3022
+ }
3023
+ let index2 = this.map.length;
3024
+ const vecs = [];
3025
+ while (index2 > 0) {
3026
+ index2 -= 1;
3027
+ vecs.push(events.slice(this.map[index2][0] + this.map[index2][1]), this.map[index2][2]);
3028
+ events.length = this.map[index2][0];
3029
+ }
3030
+ vecs.push(events.slice());
3031
+ events.length = 0;
3032
+ let slice = vecs.pop();
3033
+ while (slice) {
3034
+ for (const element3 of slice) {
3035
+ events.push(element3);
3036
+ }
3037
+ slice = vecs.pop();
3038
+ }
3039
+ this.map.length = 0;
3040
+ this.index.clear();
3041
+ }
3042
+ };
3043
+ function addImplementation(editMap, at, remove, add, before) {
3044
+ if (remove === 0 && add.length === 0) {
3045
+ return;
3046
+ }
3047
+ const existing = editMap.index.get(at);
3048
+ if (existing) {
3049
+ existing[1] += remove;
3050
+ if (before) {
3051
+ add.push(...existing[2]);
3052
+ existing[2] = add;
3053
+ } else {
3054
+ existing[2].push(...add);
3055
+ }
3056
+ return;
3057
+ }
3058
+ const change = [at, remove, add];
3059
+ editMap.map.push(change);
3060
+ editMap.index.set(at, change);
3061
+ }
3062
+
2942
3063
  // node_modules/micromark/lib/initialize/document.js
2943
3064
  var document2 = {
2944
3065
  tokenize: initializeDocument
@@ -2986,8 +3107,10 @@ function initializeDocument(effects) {
2986
3107
  };
2987
3108
  index2++;
2988
3109
  }
2989
- splice(self2.events, indexBeforeFlow + 1, 0, self2.events.slice(indexBeforeExits));
2990
- self2.events.length = index2;
3110
+ const editMap = new EditMap();
3111
+ editMap.add(indexBeforeFlow + 1, 0, self2.events.slice(indexBeforeExits));
3112
+ editMap.add(indexBeforeExits, index2 - indexBeforeExits, []);
3113
+ editMap.consume(self2.events);
2991
3114
  return checkNewContainers(code4);
2992
3115
  }
2993
3116
  return start2(code4);
@@ -3006,7 +3129,9 @@ function initializeDocument(effects) {
3006
3129
  return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code4);
3007
3130
  }
3008
3131
  function thereIsANewContainer(code4) {
3009
- if (childFlow) closeFlow();
3132
+ if (childFlow) {
3133
+ closeFlow();
3134
+ }
3010
3135
  exitContainers(continued);
3011
3136
  return documentContinued(code4);
3012
3137
  }
@@ -3026,7 +3151,9 @@ function initializeDocument(effects) {
3026
3151
  }
3027
3152
  function flowStart(code4) {
3028
3153
  if (code4 === null) {
3029
- if (childFlow) closeFlow();
3154
+ if (childFlow) {
3155
+ closeFlow();
3156
+ }
3030
3157
  exitContainers(0);
3031
3158
  effects.consume(code4);
3032
3159
  return;
@@ -3058,9 +3185,13 @@ function initializeDocument(effects) {
3058
3185
  }
3059
3186
  function writeToChild(token, endOfFile) {
3060
3187
  const stream = self2.sliceStream(token);
3061
- if (endOfFile) stream.push(null);
3188
+ if (endOfFile) {
3189
+ stream.push(null);
3190
+ }
3062
3191
  token.previous = childToken;
3063
- if (childToken) childToken.next = token;
3192
+ if (childToken) {
3193
+ childToken.next = token;
3194
+ }
3064
3195
  childToken = token;
3065
3196
  childFlow.defineSkip(token.start);
3066
3197
  childFlow.write(stream);
@@ -3097,8 +3228,10 @@ function initializeDocument(effects) {
3097
3228
  };
3098
3229
  index2++;
3099
3230
  }
3100
- splice(self2.events, indexBeforeFlow + 1, 0, self2.events.slice(indexBeforeExits));
3101
- self2.events.length = index2;
3231
+ const editMap = new EditMap();
3232
+ editMap.add(indexBeforeFlow + 1, 0, self2.events.slice(indexBeforeExits));
3233
+ editMap.add(indexBeforeExits, index2 - indexBeforeExits, []);
3234
+ editMap.consume(self2.events);
3102
3235
  }
3103
3236
  }
3104
3237
  function exitContainers(size) {
@@ -3153,24 +3286,17 @@ var attention = {
3153
3286
  };
3154
3287
  function resolveAllAttention(events, context) {
3155
3288
  let index2 = -1;
3156
- let open;
3157
- let group;
3158
- let text7;
3159
- let openingSequence;
3160
- let closingSequence;
3161
- let use;
3162
3289
  let nextEvents;
3163
- let offset;
3164
3290
  while (++index2 < events.length) {
3165
3291
  if (events[index2][0] === "enter" && events[index2][1].type === "attentionSequence" && events[index2][1]._close) {
3166
- open = index2;
3292
+ let open = index2;
3167
3293
  while (open--) {
3168
3294
  if (events[open][0] === "exit" && events[open][1].type === "attentionSequence" && events[open][1]._open && // If the markers are the same:
3169
3295
  context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index2][1]).charCodeAt(0)) {
3170
3296
  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)) {
3171
3297
  continue;
3172
3298
  }
3173
- 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;
3299
+ 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;
3174
3300
  const start2 = {
3175
3301
  ...events[open][1].end
3176
3302
  };
@@ -3179,21 +3305,21 @@ function resolveAllAttention(events, context) {
3179
3305
  };
3180
3306
  movePoint(start2, -use);
3181
3307
  movePoint(end, use);
3182
- openingSequence = {
3308
+ const openingSequence = {
3183
3309
  type: use > 1 ? "strongSequence" : "emphasisSequence",
3184
3310
  start: start2,
3185
3311
  end: {
3186
3312
  ...events[open][1].end
3187
3313
  }
3188
3314
  };
3189
- closingSequence = {
3315
+ const closingSequence = {
3190
3316
  type: use > 1 ? "strongSequence" : "emphasisSequence",
3191
3317
  start: {
3192
3318
  ...events[index2][1].start
3193
3319
  },
3194
3320
  end
3195
3321
  };
3196
- text7 = {
3322
+ const text7 = {
3197
3323
  type: use > 1 ? "strongText" : "emphasisText",
3198
3324
  start: {
3199
3325
  ...events[open][1].end
@@ -3202,7 +3328,7 @@ function resolveAllAttention(events, context) {
3202
3328
  ...events[index2][1].start
3203
3329
  }
3204
3330
  };
3205
- group = {
3331
+ const group = {
3206
3332
  type: use > 1 ? "strong" : "emphasis",
3207
3333
  start: {
3208
3334
  ...openingSequence.start
@@ -3224,11 +3350,10 @@ function resolveAllAttention(events, context) {
3224
3350
  nextEvents = push(nextEvents, [["enter", group, context], ["enter", openingSequence, context], ["exit", openingSequence, context], ["enter", text7, context]]);
3225
3351
  nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index2), context));
3226
3352
  nextEvents = push(nextEvents, [["exit", text7, context], ["enter", closingSequence, context], ["exit", closingSequence, context], ["exit", group, context]]);
3353
+ let offset = 0;
3227
3354
  if (events[index2][1].end.offset - events[index2][1].start.offset) {
3228
3355
  offset = 2;
3229
3356
  nextEvents = push(nextEvents, [["enter", events[index2][1], context], ["exit", events[index2][1], context]]);
3230
- } else {
3231
- offset = 0;
3232
3357
  }
3233
3358
  splice(events, open - 1, index2 - open + 3, nextEvents);
3234
3359
  index2 = open + nextEvents.length - offset - 2;
@@ -3263,8 +3388,8 @@ function tokenizeAttention(effects, ok3) {
3263
3388
  }
3264
3389
  const token = effects.exit("attentionSequence");
3265
3390
  const after = classifyCharacter(code4);
3266
- const open = !after || after === 2 && before || attentionMarkers2.includes(code4);
3267
- const close = !before || before === 2 && after || attentionMarkers2.includes(previous3);
3391
+ const open = !after || after === 2 && before || attentionMarkers2.includes(code4) && code4 !== 42 && code4 !== 95;
3392
+ const close = !before || before === 2 && after || attentionMarkers2.includes(previous3) && previous3 !== 42 && previous3 !== 95;
3268
3393
  token._open = Boolean(marker === 42 ? open : open && (before || !close));
3269
3394
  token._close = Boolean(marker === 42 ? close : close && (after || !open));
3270
3395
  return ok3(code4);
@@ -3541,11 +3666,29 @@ function tokenizeCharacterReference(effects, ok3, nok) {
3541
3666
  }
3542
3667
  }
3543
3668
 
3544
- // node_modules/micromark-core-commonmark/lib/code-fenced.js
3669
+ // node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.js
3545
3670
  var nonLazyContinuation = {
3546
3671
  partial: true,
3547
3672
  tokenize: tokenizeNonLazyContinuation
3548
3673
  };
3674
+ function tokenizeNonLazyContinuation(effects, ok3, nok) {
3675
+ const self2 = this;
3676
+ return start2;
3677
+ function start2(code4) {
3678
+ if (code4 === null) {
3679
+ return nok(code4);
3680
+ }
3681
+ effects.enter("lineEnding");
3682
+ effects.consume(code4);
3683
+ effects.exit("lineEnding");
3684
+ return after;
3685
+ }
3686
+ function after(code4) {
3687
+ return self2.parser.lazy[self2.now().line] ? nok(code4) : ok3(code4);
3688
+ }
3689
+ }
3690
+
3691
+ // node_modules/micromark-core-commonmark/lib/code-fenced.js
3549
3692
  var codeFenced = {
3550
3693
  concrete: true,
3551
3694
  name: "codeFenced",
@@ -3707,22 +3850,6 @@ function tokenizeCodeFenced(effects, ok3, nok) {
3707
3850
  }
3708
3851
  }
3709
3852
  }
3710
- function tokenizeNonLazyContinuation(effects, ok3, nok) {
3711
- const self2 = this;
3712
- return start2;
3713
- function start2(code4) {
3714
- if (code4 === null) {
3715
- return nok(code4);
3716
- }
3717
- effects.enter("lineEnding");
3718
- effects.consume(code4);
3719
- effects.exit("lineEnding");
3720
- return lineStart;
3721
- }
3722
- function lineStart(code4) {
3723
- return self2.parser.lazy[self2.now().line] ? nok(code4) : ok3(code4);
3724
- }
3725
- }
3726
3853
 
3727
3854
  // node_modules/micromark-core-commonmark/lib/code-indented.js
3728
3855
  var codeIndented = {
@@ -3734,15 +3861,10 @@ var furtherStart = {
3734
3861
  tokenize: tokenizeFurtherStart
3735
3862
  };
3736
3863
  function tokenizeCodeIndented(effects, ok3, nok) {
3737
- const self2 = this;
3738
3864
  return start2;
3739
3865
  function start2(code4) {
3740
3866
  effects.enter("codeIndented");
3741
- return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code4);
3742
- }
3743
- function afterPrefix(code4) {
3744
- const tail = self2.events[self2.events.length - 1];
3745
- return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? atBreak(code4) : nok(code4);
3867
+ return factorySpaceMinMax(effects, atBreak, nok, "linePrefix", 4, 4)(code4);
3746
3868
  }
3747
3869
  function atBreak(code4) {
3748
3870
  if (code4 === null) {
@@ -3780,11 +3902,10 @@ function tokenizeFurtherStart(effects, ok3, nok) {
3780
3902
  effects.exit("lineEnding");
3781
3903
  return furtherStart2;
3782
3904
  }
3783
- return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code4);
3905
+ return factorySpaceMinMax(effects, ok3, onNotEnoughPrefix, "linePrefix", 4, 4)(code4);
3784
3906
  }
3785
- function afterPrefix(code4) {
3786
- const tail = self2.events[self2.events.length - 1];
3787
- return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? ok3(code4) : markdownLineEnding(code4) ? furtherStart2(code4) : nok(code4);
3907
+ function onNotEnoughPrefix(code4) {
3908
+ return markdownLineEnding(code4) ? furtherStart2(code4) : nok(code4);
3788
3909
  }
3789
3910
  }
3790
3911
 
@@ -4670,8 +4791,6 @@ var headingAtx = {
4670
4791
  function resolveHeadingAtx(events, context) {
4671
4792
  let contentEnd = events.length - 2;
4672
4793
  let contentStart = 3;
4673
- let content3;
4674
- let text7;
4675
4794
  if (events[contentStart][1].type === "whitespace") {
4676
4795
  contentStart += 2;
4677
4796
  }
@@ -4682,12 +4801,12 @@ function resolveHeadingAtx(events, context) {
4682
4801
  contentEnd -= contentStart + 1 === contentEnd ? 2 : 4;
4683
4802
  }
4684
4803
  if (contentEnd > contentStart) {
4685
- content3 = {
4804
+ const content3 = {
4686
4805
  type: "atxHeadingText",
4687
4806
  start: events[contentStart][1].start,
4688
4807
  end: events[contentEnd][1].end
4689
4808
  };
4690
- text7 = {
4809
+ const text7 = {
4691
4810
  type: "chunkText",
4692
4811
  start: events[contentStart][1].start,
4693
4812
  end: events[contentEnd][1].end,
@@ -4830,10 +4949,6 @@ var blankLineBefore = {
4830
4949
  partial: true,
4831
4950
  tokenize: tokenizeBlankLineBefore
4832
4951
  };
4833
- var nonLazyContinuationStart = {
4834
- partial: true,
4835
- tokenize: tokenizeNonLazyContinuationStart
4836
- };
4837
4952
  function resolveToHtmlFlow(events) {
4838
4953
  let index2 = events.length;
4839
4954
  while (index2--) {
@@ -5095,7 +5210,7 @@ function tokenizeHtmlFlow(effects, ok3, nok) {
5095
5210
  return continuation;
5096
5211
  }
5097
5212
  function continuationStart(code4) {
5098
- return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code4);
5213
+ return effects.check(nonLazyContinuation, continuationStartNonLazy, continuationAfter)(code4);
5099
5214
  }
5100
5215
  function continuationStartNonLazy(code4) {
5101
5216
  effects.enter("lineEnding");
@@ -5172,22 +5287,6 @@ function tokenizeHtmlFlow(effects, ok3, nok) {
5172
5287
  return ok3(code4);
5173
5288
  }
5174
5289
  }
5175
- function tokenizeNonLazyContinuationStart(effects, ok3, nok) {
5176
- const self2 = this;
5177
- return start2;
5178
- function start2(code4) {
5179
- if (markdownLineEnding(code4)) {
5180
- effects.enter("lineEnding");
5181
- effects.consume(code4);
5182
- effects.exit("lineEnding");
5183
- return after;
5184
- }
5185
- return nok(code4);
5186
- }
5187
- function after(code4) {
5188
- return self2.parser.lazy[self2.now().line] ? nok(code4) : ok3(code4);
5189
- }
5190
- }
5191
5290
  function tokenizeBlankLineBefore(effects, ok3, nok) {
5192
5291
  return start2;
5193
5292
  function start2(code4) {
@@ -5540,12 +5639,11 @@ function resolveAllLabelEnd(events) {
5540
5639
  function resolveToLabelEnd(events, context) {
5541
5640
  let index2 = events.length;
5542
5641
  let offset = 0;
5543
- let token;
5544
5642
  let open;
5545
5643
  let close;
5546
5644
  let media;
5547
5645
  while (index2--) {
5548
- token = events[index2][1];
5646
+ const token = events[index2][1];
5549
5647
  if (open) {
5550
5648
  if (token.type === "link" || token.type === "labelLink" && token._inactive) {
5551
5649
  break;
@@ -5604,14 +5702,14 @@ function resolveToLabelEnd(events, context) {
5604
5702
  }
5605
5703
  function tokenizeLabelEnd(effects, ok3, nok) {
5606
5704
  const self2 = this;
5607
- let index2 = self2.events.length;
5705
+ const labelStarts = self2._labelStarts;
5608
5706
  let labelStart;
5609
5707
  let defined;
5610
- while (index2--) {
5611
- if ((self2.events[index2][1].type === "labelImage" || self2.events[index2][1].type === "labelLink") && !self2.events[index2][1]._balanced) {
5612
- labelStart = self2.events[index2][1];
5613
- break;
5708
+ if (labelStarts) {
5709
+ while (labelStarts.length > 0 && labelStarts[labelStarts.length - 1]._balanced) {
5710
+ labelStarts.pop();
5614
5711
  }
5712
+ labelStart = labelStarts[labelStarts.length - 1];
5615
5713
  }
5616
5714
  return start2;
5617
5715
  function start2(code4) {
@@ -5645,6 +5743,7 @@ function tokenizeLabelEnd(effects, ok3, nok) {
5645
5743
  return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code4);
5646
5744
  }
5647
5745
  function labelEndOk(code4) {
5746
+ labelStarts.pop();
5648
5747
  return ok3(code4);
5649
5748
  }
5650
5749
  function labelEndNok(code4) {
@@ -5738,6 +5837,7 @@ var labelStartImage = {
5738
5837
  };
5739
5838
  function tokenizeLabelStartImage(effects, ok3, nok) {
5740
5839
  const self2 = this;
5840
+ let labelImage;
5741
5841
  return start2;
5742
5842
  function start2(code4) {
5743
5843
  effects.enter("labelImage");
@@ -5751,13 +5851,18 @@ function tokenizeLabelStartImage(effects, ok3, nok) {
5751
5851
  effects.enter("labelMarker");
5752
5852
  effects.consume(code4);
5753
5853
  effects.exit("labelMarker");
5754
- effects.exit("labelImage");
5854
+ labelImage = effects.exit("labelImage");
5755
5855
  return after;
5756
5856
  }
5757
5857
  return nok(code4);
5758
5858
  }
5759
5859
  function after(code4) {
5760
- return code4 === 94 && "_hiddenFootnoteSupport" in self2.parser.constructs ? nok(code4) : ok3(code4);
5860
+ if (code4 === 94 && "_hiddenFootnoteSupport" in self2.parser.constructs) {
5861
+ return nok(code4);
5862
+ }
5863
+ self2._labelStarts = self2._labelStarts || [];
5864
+ self2._labelStarts.push(labelImage);
5865
+ return ok3(code4);
5761
5866
  }
5762
5867
  }
5763
5868
 
@@ -5769,17 +5874,23 @@ var labelStartLink = {
5769
5874
  };
5770
5875
  function tokenizeLabelStartLink(effects, ok3, nok) {
5771
5876
  const self2 = this;
5877
+ let labelLink;
5772
5878
  return start2;
5773
5879
  function start2(code4) {
5774
5880
  effects.enter("labelLink");
5775
5881
  effects.enter("labelMarker");
5776
5882
  effects.consume(code4);
5777
5883
  effects.exit("labelMarker");
5778
- effects.exit("labelLink");
5884
+ labelLink = effects.exit("labelLink");
5779
5885
  return after;
5780
5886
  }
5781
5887
  function after(code4) {
5782
- return code4 === 94 && "_hiddenFootnoteSupport" in self2.parser.constructs ? nok(code4) : ok3(code4);
5888
+ if (code4 === 94 && "_hiddenFootnoteSupport" in self2.parser.constructs) {
5889
+ return nok(code4);
5890
+ }
5891
+ self2._labelStarts = self2._labelStarts || [];
5892
+ self2._labelStarts.push(labelLink);
5893
+ return ok3(code4);
5783
5894
  }
5784
5895
  }
5785
5896
 
@@ -5974,6 +6085,7 @@ var setextUnderline = {
5974
6085
  tokenize: tokenizeSetextUnderline
5975
6086
  };
5976
6087
  function resolveToSetextUnderline(events, context) {
6088
+ const editMap = new EditMap();
5977
6089
  let index2 = events.length;
5978
6090
  let content3;
5979
6091
  let text7;
@@ -5989,7 +6101,7 @@ function resolveToSetextUnderline(events, context) {
5989
6101
  }
5990
6102
  } else {
5991
6103
  if (events[index2][1].type === "content") {
5992
- events.splice(index2, 1);
6104
+ editMap.add(index2, 1, []);
5993
6105
  }
5994
6106
  if (!definition3 && events[index2][1].type === "definition") {
5995
6107
  definition3 = index2;
@@ -6007,15 +6119,16 @@ function resolveToSetextUnderline(events, context) {
6007
6119
  };
6008
6120
  events[text7][1].type = "setextHeadingText";
6009
6121
  if (definition3) {
6010
- events.splice(text7, 0, ["enter", heading3, context]);
6011
- events.splice(definition3 + 1, 0, ["exit", events[content3][1], context]);
6122
+ editMap.add(text7, 0, [["enter", heading3, context]]);
6123
+ editMap.add(definition3 + 1, 0, [["exit", events[content3][1], context]]);
6012
6124
  events[content3][1].end = {
6013
6125
  ...events[definition3][1].end
6014
6126
  };
6015
6127
  } else {
6016
6128
  events[content3][1] = heading3;
6017
6129
  }
6018
- events.push(["exit", heading3, context]);
6130
+ editMap.add(events.length, 0, [["exit", heading3, context]]);
6131
+ editMap.consume(events);
6019
6132
  return events;
6020
6133
  }
6021
6134
  function tokenizeSetextUnderline(effects, ok3, nok) {
@@ -6175,6 +6288,7 @@ function createResolver(extraResolver) {
6175
6288
  }
6176
6289
  }
6177
6290
  function resolveAllLineSuffixes(events, context) {
6291
+ const editMap = new EditMap();
6178
6292
  let eventIndex = 0;
6179
6293
  while (++eventIndex <= events.length) {
6180
6294
  if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") {
@@ -6192,7 +6306,9 @@ function resolveAllLineSuffixes(events, context) {
6192
6306
  size++;
6193
6307
  bufferIndex--;
6194
6308
  }
6195
- if (bufferIndex) break;
6309
+ if (bufferIndex) {
6310
+ break;
6311
+ }
6196
6312
  bufferIndex = -1;
6197
6313
  } else if (chunk === -2) {
6198
6314
  tabs = true;
@@ -6226,13 +6342,13 @@ function resolveAllLineSuffixes(events, context) {
6226
6342
  if (data.start.offset === data.end.offset) {
6227
6343
  Object.assign(data, token);
6228
6344
  } else {
6229
- events.splice(eventIndex, 0, ["enter", token, context], ["exit", token, context]);
6230
- eventIndex += 2;
6345
+ editMap.add(eventIndex, 0, [["enter", token, context], ["exit", token, context]]);
6231
6346
  }
6232
6347
  }
6233
6348
  eventIndex++;
6234
6349
  }
6235
6350
  }
6351
+ editMap.consume(events);
6236
6352
  return events;
6237
6353
  }
6238
6354
 
@@ -6390,11 +6506,10 @@ function createTokenizer(parser, initialize, from) {
6390
6506
  accountForPotentialSkip();
6391
6507
  }
6392
6508
  function main() {
6393
- let chunkIndex;
6394
6509
  while (point4._index < chunks.length) {
6395
6510
  const chunk = chunks[point4._index];
6396
6511
  if (typeof chunk === "string") {
6397
- chunkIndex = point4._index;
6512
+ const chunkIndex = point4._index;
6398
6513
  if (point4._bufferIndex < 0) {
6399
6514
  point4._bufferIndex = 0;
6400
6515
  }
@@ -6602,30 +6717,34 @@ function serializeChunks(chunks, expandTabs) {
6602
6717
  let value;
6603
6718
  if (typeof chunk === "string") {
6604
6719
  value = chunk;
6605
- } else switch (chunk) {
6606
- case -5: {
6607
- value = "\r";
6608
- break;
6609
- }
6610
- case -4: {
6611
- value = "\n";
6612
- break;
6613
- }
6614
- case -3: {
6615
- value = "\r\n";
6616
- break;
6617
- }
6618
- case -2: {
6619
- value = expandTabs ? " " : " ";
6620
- break;
6621
- }
6622
- case -1: {
6623
- if (!expandTabs && atTab) continue;
6624
- value = " ";
6625
- break;
6626
- }
6627
- default: {
6628
- value = String.fromCharCode(chunk);
6720
+ } else {
6721
+ switch (chunk) {
6722
+ case -5: {
6723
+ value = "\r";
6724
+ break;
6725
+ }
6726
+ case -4: {
6727
+ value = "\n";
6728
+ break;
6729
+ }
6730
+ case -3: {
6731
+ value = "\r\n";
6732
+ break;
6733
+ }
6734
+ case -2: {
6735
+ value = expandTabs ? " " : " ";
6736
+ break;
6737
+ }
6738
+ case -1: {
6739
+ if (!expandTabs && atTab) {
6740
+ continue;
6741
+ }
6742
+ value = " ";
6743
+ break;
6744
+ }
6745
+ default: {
6746
+ value = String.fromCharCode(chunk);
6747
+ }
6629
6748
  }
6630
6749
  }
6631
6750
  atTab = chunk === -2;
@@ -6676,14 +6795,9 @@ function preprocess() {
6676
6795
  let atCarriageReturn;
6677
6796
  return preprocessor;
6678
6797
  function preprocessor(value, encoding, end) {
6679
- const chunks = [];
6680
- let match;
6681
- let next;
6682
- let startPosition;
6683
- let endPosition;
6684
- let code4;
6685
6798
  value = buffer + (typeof value === "string" ? value.toString() : new TextDecoder(encoding || void 0).decode(value));
6686
- startPosition = 0;
6799
+ const chunks = [];
6800
+ let startPosition = 0;
6687
6801
  buffer = "";
6688
6802
  if (start2) {
6689
6803
  if (value.charCodeAt(0) === 65279) {
@@ -6693,9 +6807,9 @@ function preprocess() {
6693
6807
  }
6694
6808
  while (startPosition < value.length) {
6695
6809
  search.lastIndex = startPosition;
6696
- match = search.exec(value);
6697
- endPosition = match && match.index !== void 0 ? match.index : value.length;
6698
- code4 = value.charCodeAt(endPosition);
6810
+ const match = search.exec(value);
6811
+ const endPosition = match && match.index !== void 0 ? match.index : value.length;
6812
+ const code4 = value.charCodeAt(endPosition);
6699
6813
  if (!match) {
6700
6814
  buffer = value.slice(startPosition);
6701
6815
  break;
@@ -6719,9 +6833,11 @@ function preprocess() {
6719
6833
  break;
6720
6834
  }
6721
6835
  case 9: {
6722
- next = Math.ceil(column / 4) * 4;
6836
+ const next = Math.ceil(column / 4) * 4;
6723
6837
  chunks.push(-2);
6724
- while (column++ < next) chunks.push(-1);
6838
+ while (column++ < next) {
6839
+ chunks.push(-1);
6840
+ }
6725
6841
  break;
6726
6842
  }
6727
6843
  case 10: {
@@ -6738,8 +6854,12 @@ function preprocess() {
6738
6854
  startPosition = endPosition + 1;
6739
6855
  }
6740
6856
  if (end) {
6741
- if (atCarriageReturn) chunks.push(-5);
6742
- if (buffer) chunks.push(buffer);
6857
+ if (atCarriageReturn) {
6858
+ chunks.push(-5);
6859
+ }
6860
+ if (buffer) {
6861
+ chunks.push(buffer);
6862
+ }
6743
6863
  chunks.push(null);
6744
6864
  }
6745
6865
  return chunks;
@@ -6775,6 +6895,8 @@ function fromMarkdown(value, encoding, options) {
6775
6895
  }
6776
6896
  function compiler(options) {
6777
6897
  const config = {
6898
+ afterExit: [],
6899
+ beforeEnter: [],
6778
6900
  transforms: [],
6779
6901
  canContainEols: ["emphasis", "fragment", "heading", "paragraph", "strong"],
6780
6902
  enter: {
@@ -6878,7 +7000,8 @@ function compiler(options) {
6878
7000
  function compile(events) {
6879
7001
  let tree = {
6880
7002
  type: "root",
6881
- children: []
7003
+ children: [],
7004
+ position: void 0
6882
7005
  };
6883
7006
  const context = {
6884
7007
  stack: [tree],
@@ -6891,24 +7014,40 @@ function compiler(options) {
6891
7014
  data
6892
7015
  };
6893
7016
  const listStack = [];
7017
+ const prepared = [];
6894
7018
  let index2 = -1;
6895
7019
  while (++index2 < events.length) {
7020
+ prepared.push(events[index2]);
6896
7021
  if (events[index2][1].type === "listOrdered" || events[index2][1].type === "listUnordered") {
6897
7022
  if (events[index2][0] === "enter") {
6898
- listStack.push(index2);
7023
+ listStack.push(prepared.length - 1);
6899
7024
  } else {
6900
7025
  const tail = listStack.pop();
6901
- index2 = prepareList(events, tail, index2);
7026
+ prepareList(prepared, tail);
6902
7027
  }
6903
7028
  }
6904
7029
  }
7030
+ events = prepared;
6905
7031
  index2 = -1;
6906
7032
  while (++index2 < events.length) {
6907
7033
  const handler = config[events[index2][0]];
7034
+ if (events[index2][0] === "enter" && config.beforeEnter.length > 0) {
7035
+ callListeners(config.beforeEnter, {
7036
+ ...context,
7037
+ sliceSerialize: events[index2][2].sliceSerialize
7038
+ }, events[index2][1]);
7039
+ }
6908
7040
  if (own2.call(handler, events[index2][1].type)) {
6909
- handler[events[index2][1].type].call(Object.assign({
7041
+ handler[events[index2][1].type].call({
7042
+ ...context,
7043
+ sliceSerialize: events[index2][2].sliceSerialize
7044
+ }, events[index2][1]);
7045
+ }
7046
+ if (events[index2][0] === "exit" && config.afterExit.length > 0) {
7047
+ callListeners(config.afterExit, {
7048
+ ...context,
6910
7049
  sliceSerialize: events[index2][2].sliceSerialize
6911
- }, context), events[index2][1]);
7050
+ }, events[index2][1]);
6912
7051
  }
6913
7052
  }
6914
7053
  if (context.tokenStack.length > 0) {
@@ -6934,7 +7073,14 @@ function compiler(options) {
6934
7073
  }
6935
7074
  return tree;
6936
7075
  }
6937
- function prepareList(events, start2, length) {
7076
+ function callListeners(listeners, context, token) {
7077
+ let index2 = -1;
7078
+ while (++index2 < listeners.length) {
7079
+ listeners[index2].call(context, token);
7080
+ }
7081
+ }
7082
+ function prepareList(events, start2) {
7083
+ const end = events.length - 1;
6938
7084
  let index2 = start2 - 1;
6939
7085
  let containerBalance = -1;
6940
7086
  let listSpread = false;
@@ -6942,7 +7088,8 @@ function compiler(options) {
6942
7088
  let lineIndex;
6943
7089
  let firstBlankLineIndex;
6944
7090
  let atMarker;
6945
- while (++index2 <= length) {
7091
+ const insertions = [];
7092
+ while (++index2 <= end) {
6946
7093
  const event = events[index2];
6947
7094
  switch (event[1].type) {
6948
7095
  case "listUnordered":
@@ -6999,9 +7146,10 @@ function compiler(options) {
6999
7146
  listItem4._spread = true;
7000
7147
  }
7001
7148
  listItem4.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end);
7002
- events.splice(lineIndex || index2, 0, ["exit", listItem4, event[2]]);
7003
- index2++;
7004
- length++;
7149
+ insertions.push({
7150
+ at: lineIndex || index2,
7151
+ event: ["exit", listItem4, event[2]]
7152
+ });
7005
7153
  }
7006
7154
  if (event[1].type === "listItemPrefix") {
7007
7155
  const item = {
@@ -7012,16 +7160,25 @@ function compiler(options) {
7012
7160
  end: void 0
7013
7161
  };
7014
7162
  listItem4 = item;
7015
- events.splice(index2, 0, ["enter", item, event[2]]);
7016
- index2++;
7017
- length++;
7163
+ insertions.push({
7164
+ at: index2,
7165
+ event: ["enter", item, event[2]]
7166
+ });
7018
7167
  firstBlankLineIndex = void 0;
7019
7168
  atMarker = true;
7020
7169
  }
7021
7170
  }
7022
7171
  }
7172
+ const listEvents = events.splice(start2);
7173
+ let insertion = 0;
7174
+ index2 = -1;
7175
+ while (++index2 < listEvents.length) {
7176
+ while (insertion < insertions.length && insertions[insertion].at === start2 + index2) {
7177
+ events.push(insertions[insertion++].event);
7178
+ }
7179
+ events.push(listEvents[index2]);
7180
+ }
7023
7181
  events[start2][1]._spread = listSpread;
7024
- return length;
7025
7182
  }
7026
7183
  function opener(create2, and) {
7027
7184
  return open;
@@ -7063,7 +7220,8 @@ function compiler(options) {
7063
7220
  start: token.start,
7064
7221
  end: token.end
7065
7222
  }) + "): it\u2019s not open");
7066
- } else if (open[0].type !== token.type) {
7223
+ }
7224
+ if (open[0].type !== token.type) {
7067
7225
  if (onExitError) {
7068
7226
  onExitError.call(this, token, open[0]);
7069
7227
  } else {
@@ -7299,7 +7457,8 @@ function compiler(options) {
7299
7457
  function blockQuote2() {
7300
7458
  return {
7301
7459
  type: "blockquote",
7302
- children: []
7460
+ children: [],
7461
+ position: void 0
7303
7462
  };
7304
7463
  }
7305
7464
  function codeFlow() {
@@ -7307,13 +7466,15 @@ function compiler(options) {
7307
7466
  type: "code",
7308
7467
  lang: null,
7309
7468
  meta: null,
7310
- value: ""
7469
+ value: "",
7470
+ position: void 0
7311
7471
  };
7312
7472
  }
7313
7473
  function codeText2() {
7314
7474
  return {
7315
7475
  type: "inlineCode",
7316
- value: ""
7476
+ value: "",
7477
+ position: void 0
7317
7478
  };
7318
7479
  }
7319
7480
  function definition3() {
@@ -7322,13 +7483,15 @@ function compiler(options) {
7322
7483
  identifier: "",
7323
7484
  label: null,
7324
7485
  title: null,
7325
- url: ""
7486
+ url: "",
7487
+ position: void 0
7326
7488
  };
7327
7489
  }
7328
7490
  function emphasis3() {
7329
7491
  return {
7330
7492
  type: "emphasis",
7331
- children: []
7493
+ children: [],
7494
+ position: void 0
7332
7495
  };
7333
7496
  }
7334
7497
  function heading3() {
@@ -7336,18 +7499,21 @@ function compiler(options) {
7336
7499
  type: "heading",
7337
7500
  // @ts-expect-error `depth` will be set later.
7338
7501
  depth: 0,
7339
- children: []
7502
+ children: [],
7503
+ position: void 0
7340
7504
  };
7341
7505
  }
7342
7506
  function hardBreak3() {
7343
7507
  return {
7344
- type: "break"
7508
+ type: "break",
7509
+ position: void 0
7345
7510
  };
7346
7511
  }
7347
7512
  function html5() {
7348
7513
  return {
7349
7514
  type: "html",
7350
- value: ""
7515
+ value: "",
7516
+ position: void 0
7351
7517
  };
7352
7518
  }
7353
7519
  function image3() {
@@ -7355,7 +7521,8 @@ function compiler(options) {
7355
7521
  type: "image",
7356
7522
  title: null,
7357
7523
  url: "",
7358
- alt: null
7524
+ alt: null,
7525
+ position: void 0
7359
7526
  };
7360
7527
  }
7361
7528
  function link3() {
@@ -7363,7 +7530,8 @@ function compiler(options) {
7363
7530
  type: "link",
7364
7531
  title: null,
7365
7532
  url: "",
7366
- children: []
7533
+ children: [],
7534
+ position: void 0
7367
7535
  };
7368
7536
  }
7369
7537
  function list4(token) {
@@ -7372,7 +7540,8 @@ function compiler(options) {
7372
7540
  ordered: token.type === "listOrdered",
7373
7541
  start: null,
7374
7542
  spread: token._spread,
7375
- children: []
7543
+ children: [],
7544
+ position: void 0
7376
7545
  };
7377
7546
  }
7378
7547
  function listItem3(token) {
@@ -7380,30 +7549,35 @@ function compiler(options) {
7380
7549
  type: "listItem",
7381
7550
  spread: token._spread,
7382
7551
  checked: null,
7383
- children: []
7552
+ children: [],
7553
+ position: void 0
7384
7554
  };
7385
7555
  }
7386
7556
  function paragraph3() {
7387
7557
  return {
7388
7558
  type: "paragraph",
7389
- children: []
7559
+ children: [],
7560
+ position: void 0
7390
7561
  };
7391
7562
  }
7392
7563
  function strong3() {
7393
7564
  return {
7394
7565
  type: "strong",
7395
- children: []
7566
+ children: [],
7567
+ position: void 0
7396
7568
  };
7397
7569
  }
7398
7570
  function text7() {
7399
7571
  return {
7400
7572
  type: "text",
7401
- value: ""
7573
+ value: "",
7574
+ position: void 0
7402
7575
  };
7403
7576
  }
7404
7577
  function thematicBreak4() {
7405
7578
  return {
7406
- type: "thematicBreak"
7579
+ type: "thematicBreak",
7580
+ position: void 0
7407
7581
  };
7408
7582
  }
7409
7583
  }
@@ -7444,6 +7618,14 @@ function extension(combined, extension2) {
7444
7618
  }
7445
7619
  break;
7446
7620
  }
7621
+ case "afterExit":
7622
+ case "beforeEnter": {
7623
+ const right = extension2[key];
7624
+ if (right) {
7625
+ combined[key].push(right);
7626
+ }
7627
+ break;
7628
+ }
7447
7629
  case "enter":
7448
7630
  case "exit": {
7449
7631
  const right = extension2[key];
@@ -7465,12 +7647,11 @@ function defaultOnError(left, right) {
7465
7647
  start: right.start,
7466
7648
  end: right.end
7467
7649
  }) + ") is open");
7468
- } else {
7469
- throw new Error("Cannot close document, a token (`" + right.type + "`, " + stringifyPosition({
7470
- start: right.start,
7471
- end: right.end
7472
- }) + ") is still open");
7473
7650
  }
7651
+ throw new Error("Cannot close document, a token (`" + right.type + "`, " + stringifyPosition({
7652
+ start: right.start,
7653
+ end: right.end
7654
+ }) + ") is still open");
7474
7655
  }
7475
7656
 
7476
7657
  // node_modules/remark-parse/lib/index.js
@@ -10475,15 +10656,12 @@ function findAndReplace(tree, list4, options) {
10475
10656
  find2.lastIndex = position3 + 1;
10476
10657
  } else {
10477
10658
  if (start2 !== position3) {
10478
- nodes.push({
10479
- type: "text",
10480
- value: node2.value.slice(start2, position3)
10481
- });
10659
+ add({ type: "text", value: node2.value.slice(start2, position3) });
10482
10660
  }
10483
10661
  if (Array.isArray(value)) {
10484
- nodes.push(...value);
10662
+ for (const child of value) add(child);
10485
10663
  } else if (value) {
10486
- nodes.push(value);
10664
+ add(value);
10487
10665
  }
10488
10666
  start2 = position3 + match[0].length;
10489
10667
  change = true;
@@ -10495,20 +10673,28 @@ function findAndReplace(tree, list4, options) {
10495
10673
  }
10496
10674
  if (change) {
10497
10675
  if (start2 < node2.value.length) {
10498
- nodes.push({ type: "text", value: node2.value.slice(start2) });
10676
+ add({ type: "text", value: node2.value.slice(start2) });
10499
10677
  }
10500
10678
  parent.children.splice(index2, 1, ...nodes);
10501
10679
  } else {
10502
10680
  nodes = [node2];
10503
10681
  }
10504
10682
  return index2 + nodes.length;
10683
+ function add(child) {
10684
+ const previous3 = nodes[nodes.length - 1];
10685
+ if (previous3 && previous3.type === "text" && child.type === "text") {
10686
+ previous3.value += child.value;
10687
+ } else {
10688
+ nodes.push(child);
10689
+ }
10690
+ }
10505
10691
  }
10506
10692
  }
10507
10693
  function toPairs(tupleOrList) {
10508
- const result = [];
10509
10694
  if (!Array.isArray(tupleOrList)) {
10510
10695
  throw new TypeError("Expected find and replace tuple or list of tuples");
10511
10696
  }
10697
+ const result = [];
10512
10698
  const list4 = !tupleOrList[0] || Array.isArray(tupleOrList[0]) ? tupleOrList : [tupleOrList];
10513
10699
  let index2 = -1;
10514
10700
  while (++index2 < list4.length) {
@@ -10798,6 +10984,7 @@ var constructsWithoutStrikethrough = [
10798
10984
  "titleQuote",
10799
10985
  "titleApostrophe"
10800
10986
  ];
10987
+ handleDelete.attention = attentionDelete;
10801
10988
  handleDelete.peek = peekDelete;
10802
10989
  function gfmStrikethroughFromMarkdown() {
10803
10990
  return {
@@ -10808,35 +10995,39 @@ function gfmStrikethroughFromMarkdown() {
10808
10995
  }
10809
10996
  function gfmStrikethroughToMarkdown() {
10810
10997
  return {
10998
+ handlers: { delete: handleDelete },
10811
10999
  unsafe: [
10812
11000
  {
10813
11001
  character: "~",
10814
11002
  inConstruct: "phrasing",
10815
11003
  notInConstruct: constructsWithoutStrikethrough
10816
11004
  }
10817
- ],
10818
- handlers: { delete: handleDelete }
11005
+ ]
10819
11006
  };
10820
11007
  }
10821
11008
  function enterStrikethrough(token) {
10822
- this.enter({ type: "delete", children: [] }, token);
11009
+ this.enter({ type: "delete", children: [], position: void 0 }, token);
10823
11010
  }
10824
11011
  function exitStrikethrough(token) {
10825
11012
  this.exit(token);
10826
11013
  }
10827
11014
  function handleDelete(node2, _, state, info) {
10828
11015
  const tracker = state.createTracker(info);
11016
+ const sequence = state.stack.includes("strikethrough") ? "~" : "~~";
10829
11017
  const exit3 = state.enter("strikethrough");
10830
- let value = tracker.move("~~");
11018
+ let value = tracker.move(sequence);
10831
11019
  value += state.containerPhrasing(node2, {
10832
11020
  ...tracker.current(),
10833
11021
  before: value,
10834
11022
  after: "~"
10835
11023
  });
10836
- value += tracker.move("~~");
11024
+ value += tracker.move(sequence);
10837
11025
  exit3();
10838
11026
  return value;
10839
11027
  }
11028
+ function attentionDelete() {
11029
+ return { construct: "strikethrough", markers: ["~"], sizes: [2, 1] };
11030
+ }
10840
11031
  function peekDelete() {
10841
11032
  return "~";
10842
11033
  }
@@ -10982,6 +11173,34 @@ function toAlignment(value) {
10982
11173
  return code4 === 67 || code4 === 99 ? 99 : code4 === 76 || code4 === 108 ? 108 : code4 === 82 || code4 === 114 ? 114 : 0;
10983
11174
  }
10984
11175
 
11176
+ // node_modules/mdast-util-phrasing/lib/index.js
11177
+ var phrasing = (
11178
+ /** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
11179
+ convert([
11180
+ "break",
11181
+ "delete",
11182
+ "emphasis",
11183
+ // To do: next major: removed since footnotes were added to GFM.
11184
+ "footnote",
11185
+ "footnoteReference",
11186
+ "image",
11187
+ "imageReference",
11188
+ "inlineCode",
11189
+ // Enabled by `mdast-util-math`:
11190
+ "inlineMath",
11191
+ "link",
11192
+ "linkReference",
11193
+ // Enabled by `mdast-util-mdx`:
11194
+ "mdxJsxTextElement",
11195
+ // Enabled by `mdast-util-mdx`:
11196
+ "mdxTextExpression",
11197
+ "strong",
11198
+ "text",
11199
+ // Enabled by `mdast-util-directive`:
11200
+ "textDirective"
11201
+ ])
11202
+ );
11203
+
10985
11204
  // node_modules/mdast-util-to-markdown/lib/handle/blockquote.js
10986
11205
  function blockquote2(node2, _, state, info) {
10987
11206
  const exit3 = state.enter("blockquote");
@@ -11023,8 +11242,9 @@ function listInScope(stack, list4, none) {
11023
11242
  function hardBreak2(_, _1, state, info) {
11024
11243
  let index2 = -1;
11025
11244
  while (++index2 < state.unsafe.length) {
11026
- if (state.unsafe[index2].character === "\n" && patternInScope(state.stack, state.unsafe[index2])) {
11027
- return /[ \t]/.test(info.before) ? "" : " ";
11245
+ const pattern = state.unsafe[index2];
11246
+ if (pattern.character === "\n" && !pattern.before && !pattern.after && patternInScope(state.stack, pattern)) {
11247
+ return /[\t ]/.test(info.before) ? "" : " ";
11028
11248
  }
11029
11249
  }
11030
11250
  return "\\\n";
@@ -11059,8 +11279,8 @@ function formatCodeAsIndented(node2, state) {
11059
11279
  return Boolean(
11060
11280
  state.options.fences === false && node2.value && // If there’s no info…
11061
11281
  !node2.lang && // And there’s a non-whitespace character…
11062
- /[^ \r\n]/.test(node2.value) && // And the value doesn’t start or end in a blank…
11063
- !/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(node2.value)
11282
+ /[^\n\r ]/.test(node2.value) && // And the value doesn’t start or end in a blank…
11283
+ !/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(node2.value)
11064
11284
  );
11065
11285
  }
11066
11286
 
@@ -11079,7 +11299,6 @@ function checkFence(state) {
11079
11299
  function code2(node2, _, state, info) {
11080
11300
  const marker = checkFence(state);
11081
11301
  const raw = node2.value || "";
11082
- const suffix = marker === "`" ? "GraveAccent" : "Tilde";
11083
11302
  if (formatCodeAsIndented(node2, state)) {
11084
11303
  const exit4 = state.enter("codeIndented");
11085
11304
  const value2 = state.indentLines(raw, map2);
@@ -11089,6 +11308,7 @@ function code2(node2, _, state, info) {
11089
11308
  const tracker = state.createTracker(info);
11090
11309
  const sequence = marker.repeat(Math.max(longestStreak(raw, marker) + 1, 3));
11091
11310
  const exit3 = state.enter("codeFenced");
11311
+ const suffix = marker === "`" ? "GraveAccent" : "Tilde";
11092
11312
  let value = tracker.move(sequence);
11093
11313
  if (node2.lang) {
11094
11314
  const subexit = state.enter(`codeFencedLang${suffix}`);
@@ -11205,93 +11425,32 @@ function checkEmphasis(state) {
11205
11425
  return marker;
11206
11426
  }
11207
11427
 
11208
- // node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
11209
- function encodeCharacterReference(code4) {
11210
- return "&#x" + code4.toString(16).toUpperCase() + ";";
11211
- }
11212
-
11213
- // node_modules/mdast-util-to-markdown/lib/util/encode-info.js
11214
- function encodeInfo(outside, inside, marker) {
11215
- const outsideKind = classifyCharacter(outside);
11216
- const insideKind = classifyCharacter(inside);
11217
- if (outsideKind === void 0) {
11218
- return insideKind === void 0 ? (
11219
- // Letter inside:
11220
- // we have to encode *both* letters for `_` as it is looser.
11221
- // it already forms for `*` (and GFMs `~`).
11222
- marker === "_" ? { inside: true, outside: true } : { inside: false, outside: false }
11223
- ) : insideKind === 1 ? (
11224
- // Whitespace inside: encode both (letter, whitespace).
11225
- { inside: true, outside: true }
11226
- ) : (
11227
- // Punctuation inside: encode outer (letter)
11228
- { inside: false, outside: true }
11229
- );
11230
- }
11231
- if (outsideKind === 1) {
11232
- return insideKind === void 0 ? (
11233
- // Letter inside: already forms.
11234
- { inside: false, outside: false }
11235
- ) : insideKind === 1 ? (
11236
- // Whitespace inside: encode both (whitespace).
11237
- { inside: true, outside: true }
11238
- ) : (
11239
- // Punctuation inside: already forms.
11240
- { inside: false, outside: false }
11241
- );
11242
- }
11243
- return insideKind === void 0 ? (
11244
- // Letter inside: already forms.
11245
- { inside: false, outside: false }
11246
- ) : insideKind === 1 ? (
11247
- // Whitespace inside: encode inner (whitespace).
11248
- { inside: true, outside: false }
11249
- ) : (
11250
- // Punctuation inside: already forms.
11251
- { inside: false, outside: false }
11252
- );
11253
- }
11254
-
11255
11428
  // node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
11256
- emphasis2.peek = emphasisPeek;
11429
+ emphasis2.attention = attention2;
11430
+ emphasis2.peek = peek;
11257
11431
  function emphasis2(node2, _, state, info) {
11258
- const marker = checkEmphasis(state);
11259
- const exit3 = state.enter("emphasis");
11260
- const tracker = state.createTracker(info);
11261
- const before = tracker.move(marker);
11262
- let between = tracker.move(
11263
- state.containerPhrasing(node2, {
11264
- after: marker,
11265
- before,
11266
- ...tracker.current()
11267
- })
11268
- );
11269
- const betweenHead = between.charCodeAt(0);
11270
- const open = encodeInfo(
11271
- info.before.charCodeAt(info.before.length - 1),
11272
- betweenHead,
11273
- marker
11274
- );
11275
- if (open.inside) {
11276
- between = encodeCharacterReference(betweenHead) + between.slice(1);
11277
- }
11278
- const betweenTail = between.charCodeAt(between.length - 1);
11279
- const close = encodeInfo(info.after.charCodeAt(0), betweenTail, marker);
11280
- if (close.inside) {
11281
- between = between.slice(0, -1) + encodeCharacterReference(betweenTail);
11282
- }
11283
- const after = tracker.move(marker);
11432
+ const exit3 = state.enter("phrasing");
11433
+ const value = state.containerPhrasing({ type: "root", children: [node2] }, info);
11284
11434
  exit3();
11285
- state.attentionEncodeSurroundingInfo = {
11286
- after: close.outside,
11287
- before: open.outside
11435
+ return value;
11436
+ }
11437
+ function attention2(_, state) {
11438
+ const marker = checkEmphasis(state);
11439
+ return {
11440
+ construct: "emphasis",
11441
+ markers: marker === "*" ? ["*", "_"] : ["_", "*"],
11442
+ sizes: [1]
11288
11443
  };
11289
- return before + between + after;
11290
11444
  }
11291
- function emphasisPeek(_, _1, state) {
11445
+ function peek(_, _1, state) {
11292
11446
  return state.options.emphasis || "*";
11293
11447
  }
11294
11448
 
11449
+ // node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
11450
+ function encodeCharacterReference(code4) {
11451
+ return "&#x" + code4.toString(16).toUpperCase() + ";";
11452
+ }
11453
+
11295
11454
  // node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
11296
11455
  function formatHeadingAsSetext(node2, state) {
11297
11456
  let literalWithBreak = false;
@@ -11336,8 +11495,9 @@ function heading2(node2, _, state, info) {
11336
11495
  after: "\n",
11337
11496
  ...tracker.current()
11338
11497
  });
11339
- if (/^[\t ]/.test(value)) {
11340
- value = encodeCharacterReference(value.charCodeAt(0)) + value.slice(1);
11498
+ const head = value.charCodeAt(0);
11499
+ if (head === 9 || head === 32) {
11500
+ value = encodeCharacterReference(head) + value.slice(1);
11341
11501
  }
11342
11502
  value = value ? sequence + " " + value : sequence;
11343
11503
  if (state.options.closeAtx) {
@@ -11430,7 +11590,9 @@ function imageReference2(node2, _, state, info) {
11430
11590
  value += tracker.move(alt + "][");
11431
11591
  subexit();
11432
11592
  const stack = state.stack;
11433
- state.stack = [];
11593
+ state.stack = stack.filter(function(d) {
11594
+ return d !== "phrasing";
11595
+ });
11434
11596
  subexit = state.enter("reference");
11435
11597
  const reference = state.safe(state.associationId(node2), {
11436
11598
  before: value,
@@ -11462,14 +11624,14 @@ function inlineCode2(node2, _, state) {
11462
11624
  while (new RegExp("(^|[^`])" + sequence + "([^`]|$)").test(value)) {
11463
11625
  sequence += "`";
11464
11626
  }
11465
- if (/[^ \r\n]/.test(value) && (/^[ \r\n]/.test(value) && /[ \r\n]$/.test(value) || /^`|`$/.test(value))) {
11627
+ if (/[^\n\r ]/.test(value) && (/^[\n\r ]/.test(value) && /[\n\r ]$/.test(value) || /^`|`$/.test(value))) {
11466
11628
  value = " " + value + " ";
11467
11629
  }
11468
11630
  while (++index2 < state.unsafe.length) {
11469
11631
  const pattern = state.unsafe[index2];
11470
11632
  const expression = state.compilePattern(pattern);
11471
- let match;
11472
11633
  if (!pattern.atBreak) continue;
11634
+ let match;
11473
11635
  while (match = expression.exec(value)) {
11474
11636
  let position3 = match.index;
11475
11637
  if (value.charCodeAt(position3) === 10 && value.charCodeAt(position3 - 1) === 13) {
@@ -11489,11 +11651,11 @@ function formatLinkAsAutolink(node2, state) {
11489
11651
  const raw = toString(node2);
11490
11652
  return Boolean(
11491
11653
  !state.options.resourceLink && // If there’s a url…
11492
- node2.url && // And there’s a no title…
11654
+ node2.url && // And there’s no title…
11493
11655
  !node2.title && // And the content of `node` is a single text node…
11494
11656
  node2.children && node2.children.length === 1 && node2.children[0].type === "text" && // And if the url is the same as the content…
11495
11657
  (raw === node2.url || "mailto:" + raw === node2.url) && // And that starts w/ a protocol…
11496
- /^[a-z][a-z+.-]+:/i.test(node2.url) && // And that doesn’t contain ASCII control codes (character escapes and
11658
+ /^[a-z][+\-.a-z]+:/i.test(node2.url) && // And that doesn’t contain ASCII control codes (character escapes and
11497
11659
  // references don’t work), space, or angle brackets…
11498
11660
  !/[\0- <>\u007F]/.test(node2.url)
11499
11661
  );
@@ -11505,12 +11667,12 @@ function link2(node2, _, state, info) {
11505
11667
  const quote = checkQuote(state);
11506
11668
  const suffix = quote === '"' ? "Quote" : "Apostrophe";
11507
11669
  const tracker = state.createTracker(info);
11508
- let exit3;
11509
- let subexit;
11510
11670
  if (formatLinkAsAutolink(node2, state)) {
11511
11671
  const stack = state.stack;
11512
- state.stack = [];
11513
- exit3 = state.enter("autolink");
11672
+ state.stack = stack.filter(function(d) {
11673
+ return d !== "phrasing";
11674
+ });
11675
+ const exit4 = state.enter("autolink");
11514
11676
  let value2 = tracker.move("<");
11515
11677
  value2 += tracker.move(
11516
11678
  state.containerPhrasing(node2, {
@@ -11520,12 +11682,12 @@ function link2(node2, _, state, info) {
11520
11682
  })
11521
11683
  );
11522
11684
  value2 += tracker.move(">");
11523
- exit3();
11685
+ exit4();
11524
11686
  state.stack = stack;
11525
11687
  return value2;
11526
11688
  }
11527
- exit3 = state.enter("link");
11528
- subexit = state.enter("label");
11689
+ const exit3 = state.enter("link");
11690
+ let subexit = state.enter("label");
11529
11691
  let value = tracker.move("[");
11530
11692
  value += tracker.move(
11531
11693
  state.containerPhrasing(node2, {
@@ -11595,7 +11757,9 @@ function linkReference2(node2, _, state, info) {
11595
11757
  value += tracker.move(text7 + "][");
11596
11758
  subexit();
11597
11759
  const stack = state.stack;
11598
- state.stack = [];
11760
+ state.stack = stack.filter(function(d) {
11761
+ return d !== "phrasing";
11762
+ });
11599
11763
  subexit = state.enter("reference");
11600
11764
  const reference = state.safe(state.associationId(node2), {
11601
11765
  before: value,
@@ -11761,41 +11925,16 @@ function paragraph2(node2, _, state, info) {
11761
11925
  return value;
11762
11926
  }
11763
11927
 
11764
- // node_modules/mdast-util-phrasing/lib/index.js
11765
- var phrasing = (
11766
- /** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
11767
- convert([
11768
- "break",
11769
- "delete",
11770
- "emphasis",
11771
- // To do: next major: removed since footnotes were added to GFM.
11772
- "footnote",
11773
- "footnoteReference",
11774
- "image",
11775
- "imageReference",
11776
- "inlineCode",
11777
- // Enabled by `mdast-util-math`:
11778
- "inlineMath",
11779
- "link",
11780
- "linkReference",
11781
- // Enabled by `mdast-util-mdx`:
11782
- "mdxJsxTextElement",
11783
- // Enabled by `mdast-util-mdx`:
11784
- "mdxTextExpression",
11785
- "strong",
11786
- "text",
11787
- // Enabled by `mdast-util-directive`:
11788
- "textDirective"
11789
- ])
11790
- );
11791
-
11792
11928
  // node_modules/mdast-util-to-markdown/lib/handle/root.js
11793
11929
  function root3(node2, _, state, info) {
11794
11930
  const hasPhrasing = node2.children.some(function(d) {
11795
11931
  return phrasing(d);
11796
11932
  });
11797
- const container = hasPhrasing ? state.containerPhrasing : state.containerFlow;
11798
- return container.call(state, node2, info);
11933
+ if (!hasPhrasing) return state.containerFlow(node2, info);
11934
+ const exit3 = state.enter("phrasing");
11935
+ const value = state.containerPhrasing(node2, info);
11936
+ exit3();
11937
+ return value;
11799
11938
  }
11800
11939
 
11801
11940
  // node_modules/mdast-util-to-markdown/lib/util/check-strong.js
@@ -11810,48 +11949,35 @@ function checkStrong(state) {
11810
11949
  }
11811
11950
 
11812
11951
  // node_modules/mdast-util-to-markdown/lib/handle/strong.js
11813
- strong2.peek = strongPeek;
11952
+ strong2.attention = attention3;
11953
+ strong2.peek = peek2;
11814
11954
  function strong2(node2, _, state, info) {
11815
- const marker = checkStrong(state);
11816
- const exit3 = state.enter("strong");
11817
- const tracker = state.createTracker(info);
11818
- const before = tracker.move(marker + marker);
11819
- let between = tracker.move(
11820
- state.containerPhrasing(node2, {
11821
- after: marker,
11822
- before,
11823
- ...tracker.current()
11824
- })
11825
- );
11826
- const betweenHead = between.charCodeAt(0);
11827
- const open = encodeInfo(
11828
- info.before.charCodeAt(info.before.length - 1),
11829
- betweenHead,
11830
- marker
11831
- );
11832
- if (open.inside) {
11833
- between = encodeCharacterReference(betweenHead) + between.slice(1);
11834
- }
11835
- const betweenTail = between.charCodeAt(between.length - 1);
11836
- const close = encodeInfo(info.after.charCodeAt(0), betweenTail, marker);
11837
- if (close.inside) {
11838
- between = between.slice(0, -1) + encodeCharacterReference(betweenTail);
11839
- }
11840
- const after = tracker.move(marker + marker);
11955
+ const exit3 = state.enter("phrasing");
11956
+ const value = state.containerPhrasing({ type: "root", children: [node2] }, info);
11841
11957
  exit3();
11842
- state.attentionEncodeSurroundingInfo = {
11843
- after: close.outside,
11844
- before: open.outside
11958
+ return value;
11959
+ }
11960
+ function attention3(_, state) {
11961
+ const marker = checkStrong(state);
11962
+ return {
11963
+ construct: "strong",
11964
+ markers: marker === "*" ? ["*", "_"] : ["_", "*"],
11965
+ sizes: [2]
11845
11966
  };
11846
- return before + between + after;
11847
11967
  }
11848
- function strongPeek(_, _1, state) {
11968
+ function peek2(_, _1, state) {
11849
11969
  return state.options.strong || "*";
11850
11970
  }
11851
11971
 
11852
11972
  // node_modules/mdast-util-to-markdown/lib/handle/text.js
11853
- function text5(node2, _, state, info) {
11854
- return state.safe(node2.value, info);
11973
+ function text5(node2, parent, state, info) {
11974
+ const siblings = parent ? parent.children : [];
11975
+ const index2 = siblings.indexOf(node2);
11976
+ return state.safe(node2.value, {
11977
+ ...info,
11978
+ afterNode: siblings[index2 + 1],
11979
+ beforeNode: siblings[index2 - 1]
11980
+ });
11855
11981
  }
11856
11982
 
11857
11983
  // node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js
@@ -12855,23 +12981,28 @@ function gfmStrikethrough(options) {
12855
12981
  }
12856
12982
 
12857
12983
  // node_modules/micromark-extension-gfm-table/lib/edit-map.js
12858
- var EditMap = class {
12984
+ var EditMap2 = class {
12859
12985
  /**
12860
12986
  * Create a new edit map.
12861
12987
  */
12862
12988
  constructor() {
12863
12989
  this.map = [];
12990
+ this.index = /* @__PURE__ */ new Map();
12864
12991
  }
12865
12992
  /**
12866
12993
  * Create an edit: a remove and/or add at a certain place.
12867
12994
  *
12868
12995
  * @param {number} index
12996
+ * Index at which to apply the edit.
12869
12997
  * @param {number} remove
12998
+ * Count of items to remove at the index.
12870
12999
  * @param {Array<Event>} add
13000
+ * Items to add at the index.
12871
13001
  * @returns {undefined}
13002
+ * Nothing.
12872
13003
  */
12873
13004
  add(index2, remove, add) {
12874
- addImplementation(this, index2, remove, add);
13005
+ addImplementation2(this, index2, remove, add);
12875
13006
  }
12876
13007
  // To do: add this when moving to `micromark`.
12877
13008
  // /**
@@ -12889,7 +13020,9 @@ var EditMap = class {
12889
13020
  * Done, change the events.
12890
13021
  *
12891
13022
  * @param {Array<Event>} events
13023
+ * List of events to apply the edits to.
12892
13024
  * @returns {undefined}
13025
+ * Nothing.
12893
13026
  */
12894
13027
  consume(events) {
12895
13028
  this.map.sort(function(a, b) {
@@ -12915,22 +13048,22 @@ var EditMap = class {
12915
13048
  slice = vecs.pop();
12916
13049
  }
12917
13050
  this.map.length = 0;
13051
+ this.index.clear();
12918
13052
  }
12919
13053
  };
12920
- function addImplementation(editMap, at, remove, add) {
12921
- let index2 = 0;
13054
+ function addImplementation2(editMap, at, remove, add) {
12922
13055
  if (remove === 0 && add.length === 0) {
12923
13056
  return;
12924
13057
  }
12925
- while (index2 < editMap.map.length) {
12926
- if (editMap.map[index2][0] === at) {
12927
- editMap.map[index2][1] += remove;
12928
- editMap.map[index2][2].push(...add);
12929
- return;
12930
- }
12931
- index2 += 1;
13058
+ const existing = editMap.index.get(at);
13059
+ if (existing) {
13060
+ existing[1] += remove;
13061
+ existing[2].push(...add);
13062
+ return;
12932
13063
  }
12933
- editMap.map.push([at, remove, add]);
13064
+ const change = [at, remove, add];
13065
+ editMap.map.push(change);
13066
+ editMap.index.set(at, change);
12934
13067
  }
12935
13068
 
12936
13069
  // node_modules/micromark-extension-gfm-table/lib/infer.js
@@ -12981,10 +13114,15 @@ function tokenizeTable(effects, ok3, nok) {
12981
13114
  function start2(code4) {
12982
13115
  let index2 = self2.events.length - 1;
12983
13116
  while (index2 > -1) {
12984
- const type = self2.events[index2][1].type;
13117
+ const {
13118
+ type
13119
+ } = self2.events[index2][1];
12985
13120
  if (type === "lineEnding" || // Note: markdown-rs uses `whitespace` instead of `linePrefix`
12986
- type === "linePrefix") index2--;
12987
- else break;
13121
+ type === "linePrefix") {
13122
+ index2--;
13123
+ } else {
13124
+ break;
13125
+ }
12988
13126
  }
12989
13127
  const tail = index2 > -1 ? self2.events[index2][1].type : null;
12990
13128
  const next = tail === "tableHead" || tail === "tableRow" ? bodyRowStart : headRowBefore;
@@ -13198,7 +13336,7 @@ function resolveTable(events, context) {
13198
13336
  let currentTable;
13199
13337
  let currentBody;
13200
13338
  let currentCell;
13201
- const map3 = new EditMap();
13339
+ const map3 = new EditMap2();
13202
13340
  while (++index2 < events.length) {
13203
13341
  const event = events[index2];
13204
13342
  const token = event[1];