@atmo-dev/kit 0.18.0 → 0.19.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.
Files changed (114) hide show
  1. package/dist/articles/ArticleCard.svelte +97 -0
  2. package/dist/articles/ArticleCard.svelte.d.ts +20 -0
  3. package/dist/articles/ArticleCodeBlock.svelte +121 -0
  4. package/dist/articles/ArticleCodeBlock.svelte.d.ts +11 -0
  5. package/dist/articles/ArticleEditor.svelte +340 -0
  6. package/dist/articles/ArticleEditor.svelte.d.ts +48 -0
  7. package/dist/articles/ArticleLinkEmbed.svelte +50 -0
  8. package/dist/articles/ArticleLinkEmbed.svelte.d.ts +5 -0
  9. package/dist/articles/ArticleView.svelte +128 -0
  10. package/dist/articles/ArticleView.svelte.d.ts +46 -0
  11. package/dist/articles/PublicationIcon.svelte +37 -0
  12. package/dist/articles/PublicationIcon.svelte.d.ts +10 -0
  13. package/dist/articles/article-link-embed.d.ts +36 -0
  14. package/dist/articles/article-link-embed.js +29 -0
  15. package/dist/articles/dates.d.ts +2 -0
  16. package/dist/articles/dates.js +12 -0
  17. package/dist/articles/images.d.ts +5 -0
  18. package/dist/articles/images.js +44 -0
  19. package/dist/articles/markdown.d.ts +15 -0
  20. package/dist/articles/markdown.js +52 -0
  21. package/dist/articles/paste.d.ts +11 -0
  22. package/dist/articles/paste.js +27 -0
  23. package/dist/articles/records.d.ts +166 -0
  24. package/dist/articles/records.js +423 -0
  25. package/dist/articles/styles.d.ts +4 -0
  26. package/dist/articles/styles.js +14 -0
  27. package/dist/articles-data.d.ts +8 -0
  28. package/dist/articles-data.js +8 -0
  29. package/dist/articles.d.ts +10 -0
  30. package/dist/articles.js +8 -0
  31. package/dist/components/ExternalEmbed.svelte +16 -2
  32. package/dist/components/ExternalEmbed.svelte.d.ts +6 -0
  33. package/dist/components/IconMaker.svelte +119 -0
  34. package/dist/components/IconMaker.svelte.d.ts +9 -0
  35. package/dist/components/IconRail.svelte +9 -6
  36. package/dist/components/IconRail.svelte.d.ts +2 -0
  37. package/dist/components/LinkEmbed.svelte +24 -21
  38. package/dist/components/LinkEmbed.svelte.d.ts +3 -2
  39. package/dist/components/PaletteApply.svelte +62 -0
  40. package/dist/components/PaletteApply.svelte.d.ts +9 -0
  41. package/dist/components/PalettePicker.svelte +92 -0
  42. package/dist/components/PalettePicker.svelte.d.ts +13 -0
  43. package/dist/components/PostComments.svelte +129 -0
  44. package/dist/components/PostComments.svelte.d.ts +15 -0
  45. package/dist/components/RichText.svelte +199 -9
  46. package/dist/components/RichText.svelte.d.ts +17 -0
  47. package/dist/components/RichTextEditor.svelte +155 -13
  48. package/dist/components/RichTextEditor.svelte.d.ts +26 -3
  49. package/dist/components/composer/ComposerPost.svelte +20 -4
  50. package/dist/components/composer/ComposerPost.svelte.d.ts +3 -1
  51. package/dist/components/composer/PostComposer.svelte +29 -3
  52. package/dist/components/composer/PostComposer.svelte.d.ts +12 -1
  53. package/dist/editor/EditorMenus.svelte +438 -0
  54. package/dist/editor/EditorMenus.svelte.d.ts +9 -0
  55. package/dist/editor/SlashOptions.svelte +45 -0
  56. package/dist/editor/SlashOptions.svelte.d.ts +12 -0
  57. package/dist/editor/article-commands.d.ts +44 -0
  58. package/dist/editor/article-commands.js +289 -0
  59. package/dist/editor/article-extensions.d.ts +8 -0
  60. package/dist/editor/article-extensions.js +315 -0
  61. package/dist/editor/article-menus.d.ts +2 -0
  62. package/dist/editor/article-menus.js +3 -0
  63. package/dist/editor/document.d.ts +5 -0
  64. package/dist/editor/document.js +163 -12
  65. package/dist/editor/image-node.d.ts +8 -0
  66. package/dist/editor/image-node.js +75 -0
  67. package/dist/editor/markdown-extensions.d.ts +1 -5
  68. package/dist/editor/markdown-extensions.js +37 -2
  69. package/dist/editor/slash-menu.svelte.d.ts +9 -0
  70. package/dist/editor/slash-menu.svelte.js +134 -0
  71. package/dist/embeds/PlayerLinkEmbed.svelte +9 -1
  72. package/dist/embeds/PostLinkEmbed.svelte +12 -29
  73. package/dist/embeds/PostLinkEmbed.svelte.d.ts +3 -0
  74. package/dist/embeds/ProfileLinkEmbed.svelte +12 -17
  75. package/dist/embeds/ProfileLinkEmbed.svelte.d.ts +3 -0
  76. package/dist/embeds/defaults.d.ts +4 -2
  77. package/dist/embeds/defaults.js +7 -3
  78. package/dist/embeds/load.d.ts +44 -0
  79. package/dist/embeds/load.js +139 -0
  80. package/dist/embeds/types.d.ts +18 -3
  81. package/dist/events/EventComments.svelte +4 -101
  82. package/dist/events/EventComments.svelte.d.ts +1 -1
  83. package/dist/events/EventView.svelte +5 -0
  84. package/dist/events/EventView.svelte.d.ts +3 -0
  85. package/dist/events/event-link-embed.d.ts +4 -1
  86. package/dist/events/event-link-embed.js +9 -1
  87. package/dist/events/event-view/EventLinkEmbed.svelte +8 -8
  88. package/dist/events/event-view/EventLinkEmbed.svelte.d.ts +3 -2
  89. package/dist/icon-maker/artwork.d.ts +11 -0
  90. package/dist/icon-maker/artwork.js +25 -0
  91. package/dist/icon-maker/index.d.ts +12 -0
  92. package/dist/icon-maker/index.js +73 -0
  93. package/dist/index.d.ts +10 -3
  94. package/dist/index.js +7 -1
  95. package/dist/palettes.d.ts +20 -0
  96. package/dist/palettes.js +37 -0
  97. package/dist/richtext/article-styles.d.ts +10 -0
  98. package/dist/richtext/article-styles.js +28 -0
  99. package/dist/richtext/document.d.ts +63 -1
  100. package/dist/richtext/document.js +54 -0
  101. package/dist/richtext/markdown.d.ts +19 -4
  102. package/dist/richtext/markdown.js +223 -18
  103. package/dist/richtext/serialize.d.ts +5 -1
  104. package/dist/richtext/serialize.js +163 -31
  105. package/dist/richtext/vendor/markdown-tree.d.ts +4 -3
  106. package/dist/richtext/vendor/markdown-tree.js +2584 -26
  107. package/dist/richtext.d.ts +7 -5
  108. package/dist/richtext.js +1 -1
  109. package/dist/social/external-embeds.d.ts +5 -0
  110. package/dist/social/external-embeds.js +6 -1
  111. package/dist/social/posts.d.ts +2 -0
  112. package/dist/social/posts.js +43 -2
  113. package/dist/social/profile.js +2 -1
  114. package/package.json +28 -2
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
  // Generated by scripts/vendor-markdown.mjs; do not edit.
3
- // Bundled, MIT-licensed: mdast-util-from-markdown@2.1.0, micromark-extension-gfm-strikethrough@2.1.0, mdast-util-gfm-strikethrough@2.0.1
3
+ // Bundled, MIT-licensed: mdast-util-from-markdown@2.1.0, micromark-extension-gfm-strikethrough@2.1.0, mdast-util-gfm-strikethrough@2.0.1, micromark-extension-gfm-table@2.1.2, mdast-util-gfm-table@2.0.1, micromark-extension-gfm-footnote@2.1.0, mdast-util-gfm-footnote@2.1.0, micromark-extension-gfm-task-list-item@2.1.0, mdast-util-gfm-task-list-item@2.0.1, micromark-extension-math@3.1.0, mdast-util-math@3.0.0
4
4
  // and their dependencies (micromark, mdast-util-to-string, decode-named-character-reference,
5
5
  // character-entities, unist-util-stringify-position and the micromark-* packages),
6
6
  // (c) Titus Wormer and contributors. https://github.com/micromark/micromark
@@ -2850,7 +2850,7 @@ function initializeContent(effects) {
2850
2850
  * And, in other cases, it’s needed to parse subcontent: pass some events
2851
2851
  * through another tokenizer and inject the result.
2852
2852
  */
2853
- var EditMap = class {
2853
+ var EditMap$1 = class {
2854
2854
  /**
2855
2855
  * Create a new edit map.
2856
2856
  *
@@ -2885,7 +2885,7 @@ var EditMap = class {
2885
2885
  * Nothing.
2886
2886
  */
2887
2887
  add(index, remove, add) {
2888
- addImplementation(this, index, remove, add, false);
2888
+ addImplementation$1(this, index, remove, add, false);
2889
2889
  }
2890
2890
  /**
2891
2891
  * Create an edit: but insert `add` before existing additions, instead of
@@ -2901,7 +2901,7 @@ var EditMap = class {
2901
2901
  * Nothing.
2902
2902
  */
2903
2903
  addBefore(index, remove, add) {
2904
- addImplementation(this, index, remove, add, true);
2904
+ addImplementation$1(this, index, remove, add, true);
2905
2905
  }
2906
2906
  /**
2907
2907
  * Done, change the events.
@@ -2951,7 +2951,7 @@ var EditMap = class {
2951
2951
  * @returns {undefined}
2952
2952
  * Nothing.
2953
2953
  */
2954
- function addImplementation(editMap, at, remove, add, before) {
2954
+ function addImplementation$1(editMap, at, remove, add, before) {
2955
2955
  if (remove === 0 && add.length === 0) return;
2956
2956
  const existing = editMap.index.get(at);
2957
2957
  if (existing) {
@@ -3040,7 +3040,7 @@ function initializeDocument(effects) {
3040
3040
  self.events[index][1].end = { ...point };
3041
3041
  index++;
3042
3042
  }
3043
- const editMap = new EditMap();
3043
+ const editMap = new EditMap$1();
3044
3044
  editMap.add(indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
3045
3045
  editMap.add(indexBeforeExits, index - indexBeforeExits, []);
3046
3046
  editMap.consume(self.events);
@@ -3153,7 +3153,7 @@ function initializeDocument(effects) {
3153
3153
  self.events[index][1].end = { ...point };
3154
3154
  index++;
3155
3155
  }
3156
- const editMap = new EditMap();
3156
+ const editMap = new EditMap$1();
3157
3157
  editMap.add(indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
3158
3158
  editMap.add(indexBeforeExits, index - indexBeforeExits, []);
3159
3159
  editMap.consume(self.events);
@@ -3727,7 +3727,7 @@ function tokenizeBlankLine(effects, ok, nok) {
3727
3727
  /** @type {Construct} */
3728
3728
  var blockQuote = {
3729
3729
  continuation: { tokenize: tokenizeBlockQuoteContinuation },
3730
- exit,
3730
+ exit: exit$1,
3731
3731
  name: "blockQuote",
3732
3732
  tokenize: tokenizeBlockQuoteStart
3733
3733
  };
@@ -3837,7 +3837,7 @@ function tokenizeBlockQuoteContinuation(effects, ok, nok) {
3837
3837
  }
3838
3838
  }
3839
3839
  /** @type {Exiter} */
3840
- function exit(effects) {
3840
+ function exit$1(effects) {
3841
3841
  effects.exit("blockQuote");
3842
3842
  }
3843
3843
  // node_modules/.pnpm/micromark-core-commonmark@2.0.4/node_modules/micromark-core-commonmark/lib/character-escape.js
@@ -4038,16 +4038,16 @@ function tokenizeCharacterReference(effects, ok, nok) {
4038
4038
  }
4039
4039
  // node_modules/.pnpm/micromark-core-commonmark@2.0.4/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.js
4040
4040
  /** @type {Construct} */
4041
- var nonLazyContinuation = {
4041
+ var nonLazyContinuation$1 = {
4042
4042
  partial: true,
4043
- tokenize: tokenizeNonLazyContinuation
4043
+ tokenize: tokenizeNonLazyContinuation$1
4044
4044
  };
4045
4045
  /**
4046
4046
  * @this {TokenizeContext}
4047
4047
  * Context.
4048
4048
  * @type {Tokenizer}
4049
4049
  */
4050
- function tokenizeNonLazyContinuation(effects, ok, nok) {
4050
+ function tokenizeNonLazyContinuation$1(effects, ok, nok) {
4051
4051
  const self = this;
4052
4052
  return start;
4053
4053
  /**
@@ -4189,7 +4189,7 @@ function tokenizeCodeFenced(effects, ok, nok) {
4189
4189
  function infoBefore(code) {
4190
4190
  if (code === null || markdownLineEnding(code)) {
4191
4191
  effects.exit("codeFencedFence");
4192
- return self.interrupt ? ok(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
4192
+ return self.interrupt ? ok(code) : effects.check(nonLazyContinuation$1, atNonLazyBreak, after)(code);
4193
4193
  }
4194
4194
  effects.enter("codeFencedFenceInfo");
4195
4195
  effects.enter("chunkString", { contentType: "string" });
@@ -4324,7 +4324,7 @@ function tokenizeCodeFenced(effects, ok, nok) {
4324
4324
  * @type {State}
4325
4325
  */
4326
4326
  function beforeContentChunk(code) {
4327
- if (code === null || markdownLineEnding(code)) return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
4327
+ if (code === null || markdownLineEnding(code)) return effects.check(nonLazyContinuation$1, atNonLazyBreak, after)(code);
4328
4328
  effects.enter("codeFlowValue");
4329
4329
  return contentChunk(code);
4330
4330
  }
@@ -4609,7 +4609,7 @@ function tokenizeFurtherStart(effects, ok, nok) {
4609
4609
  /** @type {Construct} */
4610
4610
  var codeText = {
4611
4611
  name: "codeText",
4612
- previous,
4612
+ previous: previous$1,
4613
4613
  resolve: resolveCodeText,
4614
4614
  tokenize: tokenizeCodeText
4615
4615
  };
@@ -4652,7 +4652,7 @@ function resolveCodeText(events) {
4652
4652
  * Context.
4653
4653
  * @type {Previous}
4654
4654
  */
4655
- function previous(code) {
4655
+ function previous$1(code) {
4656
4656
  return code !== 96 || this.events[this.events.length - 1][1].type === "characterEscape";
4657
4657
  }
4658
4658
  /**
@@ -6865,7 +6865,7 @@ function tokenizeHtmlFlow(effects, ok, nok) {
6865
6865
  * @type {State}
6866
6866
  */
6867
6867
  function continuationStart(code) {
6868
- return effects.check(nonLazyContinuation, continuationStartNonLazy, continuationAfter)(code);
6868
+ return effects.check(nonLazyContinuation$1, continuationStartNonLazy, continuationAfter)(code);
6869
6869
  }
6870
6870
  /**
6871
6871
  * In continuation, at eol, before non-lazy content.
@@ -8446,7 +8446,7 @@ var listItemPrefixWhitespaceConstruct = {
8446
8446
  /** @type {Construct} */
8447
8447
  var indentConstruct = {
8448
8448
  partial: true,
8449
- tokenize: tokenizeIndent
8449
+ tokenize: tokenizeIndent$1
8450
8450
  };
8451
8451
  /**
8452
8452
  * @this {TokenizeContext}
@@ -8560,7 +8560,7 @@ function tokenizeListContinuation(effects, ok, nok) {
8560
8560
  * Context.
8561
8561
  * @type {Tokenizer}
8562
8562
  */
8563
- function tokenizeIndent(effects, ok, nok) {
8563
+ function tokenizeIndent$1(effects, ok, nok) {
8564
8564
  const self = this;
8565
8565
  return factorySpace(effects, afterPrefix, "listItemIndent", self.containerState.size + 1);
8566
8566
  /** @type {State} */
@@ -8610,7 +8610,7 @@ var setextUnderline = {
8610
8610
  };
8611
8611
  /** @type {Resolver} */
8612
8612
  function resolveToSetextUnderline(events, context) {
8613
- const editMap = new EditMap();
8613
+ const editMap = new EditMap$1();
8614
8614
  let index = events.length;
8615
8615
  /** @type {number | undefined} */
8616
8616
  let content;
@@ -8907,7 +8907,7 @@ function createResolver(extraResolver) {
8907
8907
  * @type {Resolver}
8908
8908
  */
8909
8909
  function resolveAllLineSuffixes(events, context) {
8910
- const editMap = new EditMap();
8910
+ const editMap = new EditMap$1();
8911
8911
  let eventIndex = 0;
8912
8912
  while (++eventIndex <= events.length) if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") {
8913
8913
  const data = events[eventIndex - 1][1];
@@ -11021,12 +11021,2570 @@ function attentionDelete() {
11021
11021
  function peekDelete() {
11022
11022
  return "~";
11023
11023
  }
11024
- // scripts/markdown-tree-entry.js
11025
- /** CommonMark plus ~~strikethrough~~, as an mdast tree with source positions. */
11026
- function markdownTree(text) {
11024
+ // node_modules/.pnpm/micromark-extension-gfm-table@2.1.2/node_modules/micromark-extension-gfm-table/lib/edit-map.js
11025
+ /**
11026
+ * @import {Event} from 'micromark-util-types'
11027
+ */
11028
+ /**
11029
+ * @typedef {[number, number, Array<Event>]} Change
11030
+ * @typedef {[number, number, number]} Jump
11031
+ */
11032
+ /**
11033
+ * Tracks a bunch of edits.
11034
+ */
11035
+ var EditMap = class {
11036
+ /**
11037
+ * Create a new edit map.
11038
+ */
11039
+ constructor() {
11040
+ /**
11041
+ * Record of changes.
11042
+ *
11043
+ * @type {Array<Change>}
11044
+ */
11045
+ this.map = [];
11046
+ /**
11047
+ * Changes by index, so `add` does not scan `map` (quadratic on
11048
+ * table-heavy documents).
11049
+ *
11050
+ * @type {Map<number, Change>}
11051
+ */
11052
+ this.index = /* @__PURE__ */ new Map();
11053
+ }
11054
+ /**
11055
+ * Create an edit: a remove and/or add at a certain place.
11056
+ *
11057
+ * @param {number} index
11058
+ * Index at which to apply the edit.
11059
+ * @param {number} remove
11060
+ * Count of items to remove at the index.
11061
+ * @param {Array<Event>} add
11062
+ * Items to add at the index.
11063
+ * @returns {undefined}
11064
+ * Nothing.
11065
+ */
11066
+ add(index, remove, add) {
11067
+ addImplementation(this, index, remove, add);
11068
+ }
11069
+ /**
11070
+ * Done, change the events.
11071
+ *
11072
+ * @param {Array<Event>} events
11073
+ * List of events to apply the edits to.
11074
+ * @returns {undefined}
11075
+ * Nothing.
11076
+ */
11077
+ consume(events) {
11078
+ this.map.sort(function(a, b) {
11079
+ return a[0] - b[0];
11080
+ });
11081
+ /* c8 ignore next 3 -- `resolve` is never called without tables, so without edits. */
11082
+ if (this.map.length === 0) return;
11083
+ let index = this.map.length;
11084
+ /** @type {Array<Array<Event>>} */
11085
+ const vecs = [];
11086
+ while (index > 0) {
11087
+ index -= 1;
11088
+ vecs.push(events.slice(this.map[index][0] + this.map[index][1]), this.map[index][2]);
11089
+ events.length = this.map[index][0];
11090
+ }
11091
+ vecs.push(events.slice());
11092
+ events.length = 0;
11093
+ let slice = vecs.pop();
11094
+ while (slice) {
11095
+ for (const element of slice) events.push(element);
11096
+ slice = vecs.pop();
11097
+ }
11098
+ this.map.length = 0;
11099
+ this.index.clear();
11100
+ }
11101
+ };
11102
+ /**
11103
+ * Create an edit.
11104
+ *
11105
+ * @param {EditMap} editMap
11106
+ * Edit map to apply to.
11107
+ * @param {number} at
11108
+ * Index at which to apply the edit.
11109
+ * @param {number} remove
11110
+ * Count of items to remove at the index.
11111
+ * @param {Array<Event>} add
11112
+ * Items to add at the index.
11113
+ * @returns {undefined}
11114
+ * Nothing.
11115
+ */
11116
+ function addImplementation(editMap, at, remove, add) {
11117
+ /* c8 ignore next 3 -- `resolve` is never called without tables, so without edits. */
11118
+ if (remove === 0 && add.length === 0) return;
11119
+ const existing = editMap.index.get(at);
11120
+ if (existing) {
11121
+ existing[1] += remove;
11122
+ existing[2].push(...add);
11123
+ return;
11124
+ }
11125
+ /** @type {Change} */
11126
+ const change = [
11127
+ at,
11128
+ remove,
11129
+ add
11130
+ ];
11131
+ editMap.map.push(change);
11132
+ editMap.index.set(at, change);
11133
+ }
11134
+ // node_modules/.pnpm/micromark-extension-gfm-table@2.1.2/node_modules/micromark-extension-gfm-table/lib/infer.js
11135
+ /**
11136
+ * @import {Event} from 'micromark-util-types'
11137
+ */
11138
+ /**
11139
+ * @typedef {'center' | 'left' | 'none' | 'right'} Align
11140
+ */
11141
+ /**
11142
+ * Figure out the alignment of a GFM table.
11143
+ *
11144
+ * @param {Readonly<Array<Event>>} events
11145
+ * List of events.
11146
+ * @param {number} index
11147
+ * Table enter event.
11148
+ * @returns {Array<Align>}
11149
+ * List of aligns.
11150
+ */
11151
+ function gfmTableAlign(events, index) {
11152
+ let inDelimiterRow = false;
11153
+ /** @type {Array<Align>} */
11154
+ const align = [];
11155
+ while (index < events.length) {
11156
+ const event = events[index];
11157
+ if (inDelimiterRow) {
11158
+ if (event[0] === "enter") {
11159
+ if (event[1].type === "tableContent") align.push(events[index + 1][1].type === "tableDelimiterMarker" ? "left" : "none");
11160
+ } else if (event[1].type === "tableContent") {
11161
+ if (events[index - 1][1].type === "tableDelimiterMarker") {
11162
+ const alignIndex = align.length - 1;
11163
+ align[alignIndex] = align[alignIndex] === "left" ? "center" : "right";
11164
+ }
11165
+ } else if (event[1].type === "tableDelimiterRow") break;
11166
+ } else if (event[0] === "enter" && event[1].type === "tableDelimiterRow") inDelimiterRow = true;
11167
+ index += 1;
11168
+ }
11169
+ return align;
11170
+ }
11171
+ // node_modules/.pnpm/micromark-extension-gfm-table@2.1.2/node_modules/micromark-extension-gfm-table/lib/syntax.js
11172
+ /**
11173
+ * @import {Event, Extension, Point, Resolver, State, Token, TokenizeContext, Tokenizer} from 'micromark-util-types'
11174
+ */
11175
+ /**
11176
+ * @typedef {[number, number, number, number]} Range
11177
+ * Cell info.
11178
+ *
11179
+ * @typedef {0 | 1 | 2 | 3} RowKind
11180
+ * Where we are: `1` for head row, `2` for delimiter row, `3` for body row.
11181
+ */
11182
+ /**
11183
+ * Create an HTML extension for `micromark` to support GitHub tables syntax.
11184
+ *
11185
+ * @returns {Extension}
11186
+ * Extension for `micromark` that can be passed in `extensions` to enable GFM
11187
+ * table syntax.
11188
+ */
11189
+ function gfmTable() {
11190
+ return { flow: { null: {
11191
+ name: "table",
11192
+ tokenize: tokenizeTable,
11193
+ resolveAll: resolveTable
11194
+ } } };
11195
+ }
11196
+ /**
11197
+ * Tokenizer for GFM tables.
11198
+ *
11199
+ * @this {TokenizeContext}
11200
+ * @type {Tokenizer}
11201
+ */
11202
+ function tokenizeTable(effects, ok, nok) {
11203
+ const self = this;
11204
+ let size = 0;
11205
+ let sizeB = 0;
11206
+ /** @type {boolean | undefined} */
11207
+ let seen;
11208
+ return start;
11209
+ /**
11210
+ * Start of a GFM table.
11211
+ *
11212
+ * If there is a valid table row or table head before, then we try to parse
11213
+ * another row.
11214
+ * Otherwise, we try to parse a head.
11215
+ *
11216
+ * ```markdown
11217
+ * > | | a |
11218
+ * ^
11219
+ * | | - |
11220
+ * > | | b |
11221
+ * ^
11222
+ * ```
11223
+ * @type {State}
11224
+ */
11225
+ function start(code) {
11226
+ let index = self.events.length - 1;
11227
+ while (index > -1) {
11228
+ const { type } = self.events[index][1];
11229
+ if (type === "lineEnding" || type === "linePrefix") index--;
11230
+ else break;
11231
+ }
11232
+ const tail = index > -1 ? self.events[index][1].type : null;
11233
+ const next = tail === "tableHead" || tail === "tableRow" ? bodyRowStart : headRowBefore;
11234
+ if (next === bodyRowStart && self.parser.lazy[self.now().line]) return nok(code);
11235
+ return next(code);
11236
+ }
11237
+ /**
11238
+ * Before table head row.
11239
+ *
11240
+ * ```markdown
11241
+ * > | | a |
11242
+ * ^
11243
+ * | | - |
11244
+ * | | b |
11245
+ * ```
11246
+ *
11247
+ * @type {State}
11248
+ */
11249
+ function headRowBefore(code) {
11250
+ effects.enter("tableHead");
11251
+ effects.enter("tableRow");
11252
+ return headRowStart(code);
11253
+ }
11254
+ /**
11255
+ * Before table head row, after whitespace.
11256
+ *
11257
+ * ```markdown
11258
+ * > | | a |
11259
+ * ^
11260
+ * | | - |
11261
+ * | | b |
11262
+ * ```
11263
+ *
11264
+ * @type {State}
11265
+ */
11266
+ function headRowStart(code) {
11267
+ if (code === 124) return headRowBreak(code);
11268
+ seen = true;
11269
+ sizeB += 1;
11270
+ return headRowBreak(code);
11271
+ }
11272
+ /**
11273
+ * At break in table head row.
11274
+ *
11275
+ * ```markdown
11276
+ * > | | a |
11277
+ * ^
11278
+ * ^
11279
+ * ^
11280
+ * | | - |
11281
+ * | | b |
11282
+ * ```
11283
+ *
11284
+ * @type {State}
11285
+ */
11286
+ function headRowBreak(code) {
11287
+ if (code === null) return nok(code);
11288
+ if (markdownLineEnding(code)) {
11289
+ if (sizeB > 1) {
11290
+ sizeB = 0;
11291
+ self.interrupt = true;
11292
+ effects.exit("tableRow");
11293
+ effects.enter("lineEnding");
11294
+ effects.consume(code);
11295
+ effects.exit("lineEnding");
11296
+ return headDelimiterStart;
11297
+ }
11298
+ return nok(code);
11299
+ }
11300
+ if (markdownSpace(code)) return factorySpace(effects, headRowBreak, "whitespace")(code);
11301
+ sizeB += 1;
11302
+ if (seen) {
11303
+ seen = false;
11304
+ size += 1;
11305
+ }
11306
+ if (code === 124) {
11307
+ effects.enter("tableCellDivider");
11308
+ effects.consume(code);
11309
+ effects.exit("tableCellDivider");
11310
+ seen = true;
11311
+ return headRowBreak;
11312
+ }
11313
+ effects.enter("data");
11314
+ return headRowData(code);
11315
+ }
11316
+ /**
11317
+ * In table head row data.
11318
+ *
11319
+ * ```markdown
11320
+ * > | | a |
11321
+ * ^
11322
+ * | | - |
11323
+ * | | b |
11324
+ * ```
11325
+ *
11326
+ * @type {State}
11327
+ */
11328
+ function headRowData(code) {
11329
+ if (code === null || code === 124 || markdownLineEndingOrSpace(code)) {
11330
+ effects.exit("data");
11331
+ return headRowBreak(code);
11332
+ }
11333
+ effects.consume(code);
11334
+ return code === 92 ? headRowEscape : headRowData;
11335
+ }
11336
+ /**
11337
+ * In table head row escape.
11338
+ *
11339
+ * ```markdown
11340
+ * > | | a\-b |
11341
+ * ^
11342
+ * | | ---- |
11343
+ * | | c |
11344
+ * ```
11345
+ *
11346
+ * @type {State}
11347
+ */
11348
+ function headRowEscape(code) {
11349
+ if (code === 92 || code === 124) {
11350
+ effects.consume(code);
11351
+ return headRowData;
11352
+ }
11353
+ return headRowData(code);
11354
+ }
11355
+ /**
11356
+ * Before delimiter row.
11357
+ *
11358
+ * ```markdown
11359
+ * | | a |
11360
+ * > | | - |
11361
+ * ^
11362
+ * | | b |
11363
+ * ```
11364
+ *
11365
+ * @type {State}
11366
+ */
11367
+ function headDelimiterStart(code) {
11368
+ self.interrupt = false;
11369
+ if (self.parser.lazy[self.now().line]) return nok(code);
11370
+ effects.enter("tableDelimiterRow");
11371
+ seen = false;
11372
+ if (markdownSpace(code)) return factorySpace(effects, headDelimiterBefore, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code);
11373
+ return headDelimiterBefore(code);
11374
+ }
11375
+ /**
11376
+ * Before delimiter row, after optional whitespace.
11377
+ *
11378
+ * Reused when a `|` is found later, to parse another cell.
11379
+ *
11380
+ * ```markdown
11381
+ * | | a |
11382
+ * > | | - |
11383
+ * ^
11384
+ * | | b |
11385
+ * ```
11386
+ *
11387
+ * @type {State}
11388
+ */
11389
+ function headDelimiterBefore(code) {
11390
+ if (code === 45 || code === 58) return headDelimiterValueBefore(code);
11391
+ if (code === 124) {
11392
+ seen = true;
11393
+ effects.enter("tableCellDivider");
11394
+ effects.consume(code);
11395
+ effects.exit("tableCellDivider");
11396
+ return headDelimiterCellBefore;
11397
+ }
11398
+ return headDelimiterNok(code);
11399
+ }
11400
+ /**
11401
+ * After `|`, before delimiter cell.
11402
+ *
11403
+ * ```markdown
11404
+ * | | a |
11405
+ * > | | - |
11406
+ * ^
11407
+ * ```
11408
+ *
11409
+ * @type {State}
11410
+ */
11411
+ function headDelimiterCellBefore(code) {
11412
+ if (markdownSpace(code)) return factorySpace(effects, headDelimiterValueBefore, "whitespace")(code);
11413
+ return headDelimiterValueBefore(code);
11414
+ }
11415
+ /**
11416
+ * Before delimiter cell value.
11417
+ *
11418
+ * ```markdown
11419
+ * | | a |
11420
+ * > | | - |
11421
+ * ^
11422
+ * ```
11423
+ *
11424
+ * @type {State}
11425
+ */
11426
+ function headDelimiterValueBefore(code) {
11427
+ if (code === 58) {
11428
+ sizeB += 1;
11429
+ seen = true;
11430
+ effects.enter("tableDelimiterMarker");
11431
+ effects.consume(code);
11432
+ effects.exit("tableDelimiterMarker");
11433
+ return headDelimiterLeftAlignmentAfter;
11434
+ }
11435
+ if (code === 45) {
11436
+ sizeB += 1;
11437
+ return headDelimiterLeftAlignmentAfter(code);
11438
+ }
11439
+ if (code === null || markdownLineEnding(code)) return headDelimiterCellAfter(code);
11440
+ return headDelimiterNok(code);
11441
+ }
11442
+ /**
11443
+ * After delimiter cell left alignment marker.
11444
+ *
11445
+ * ```markdown
11446
+ * | | a |
11447
+ * > | | :- |
11448
+ * ^
11449
+ * ```
11450
+ *
11451
+ * @type {State}
11452
+ */
11453
+ function headDelimiterLeftAlignmentAfter(code) {
11454
+ if (code === 45) {
11455
+ effects.enter("tableDelimiterFiller");
11456
+ return headDelimiterFiller(code);
11457
+ }
11458
+ return headDelimiterNok(code);
11459
+ }
11460
+ /**
11461
+ * In delimiter cell filler.
11462
+ *
11463
+ * ```markdown
11464
+ * | | a |
11465
+ * > | | - |
11466
+ * ^
11467
+ * ```
11468
+ *
11469
+ * @type {State}
11470
+ */
11471
+ function headDelimiterFiller(code) {
11472
+ if (code === 45) {
11473
+ effects.consume(code);
11474
+ return headDelimiterFiller;
11475
+ }
11476
+ if (code === 58) {
11477
+ seen = true;
11478
+ effects.exit("tableDelimiterFiller");
11479
+ effects.enter("tableDelimiterMarker");
11480
+ effects.consume(code);
11481
+ effects.exit("tableDelimiterMarker");
11482
+ return headDelimiterRightAlignmentAfter;
11483
+ }
11484
+ effects.exit("tableDelimiterFiller");
11485
+ return headDelimiterRightAlignmentAfter(code);
11486
+ }
11487
+ /**
11488
+ * After delimiter cell right alignment marker.
11489
+ *
11490
+ * ```markdown
11491
+ * | | a |
11492
+ * > | | -: |
11493
+ * ^
11494
+ * ```
11495
+ *
11496
+ * @type {State}
11497
+ */
11498
+ function headDelimiterRightAlignmentAfter(code) {
11499
+ if (markdownSpace(code)) return factorySpace(effects, headDelimiterCellAfter, "whitespace")(code);
11500
+ return headDelimiterCellAfter(code);
11501
+ }
11502
+ /**
11503
+ * After delimiter cell.
11504
+ *
11505
+ * ```markdown
11506
+ * | | a |
11507
+ * > | | -: |
11508
+ * ^
11509
+ * ```
11510
+ *
11511
+ * @type {State}
11512
+ */
11513
+ function headDelimiterCellAfter(code) {
11514
+ if (code === 124) return headDelimiterBefore(code);
11515
+ if (code === null || markdownLineEnding(code)) {
11516
+ if (!seen || size !== sizeB) return headDelimiterNok(code);
11517
+ effects.exit("tableDelimiterRow");
11518
+ effects.exit("tableHead");
11519
+ return ok(code);
11520
+ }
11521
+ return headDelimiterNok(code);
11522
+ }
11523
+ /**
11524
+ * In delimiter row, at a disallowed byte.
11525
+ *
11526
+ * ```markdown
11527
+ * | | a |
11528
+ * > | | x |
11529
+ * ^
11530
+ * ```
11531
+ *
11532
+ * @type {State}
11533
+ */
11534
+ function headDelimiterNok(code) {
11535
+ return nok(code);
11536
+ }
11537
+ /**
11538
+ * Before table body row.
11539
+ *
11540
+ * ```markdown
11541
+ * | | a |
11542
+ * | | - |
11543
+ * > | | b |
11544
+ * ^
11545
+ * ```
11546
+ *
11547
+ * @type {State}
11548
+ */
11549
+ function bodyRowStart(code) {
11550
+ effects.enter("tableRow");
11551
+ return bodyRowBreak(code);
11552
+ }
11553
+ /**
11554
+ * At break in table body row.
11555
+ *
11556
+ * ```markdown
11557
+ * | | a |
11558
+ * | | - |
11559
+ * > | | b |
11560
+ * ^
11561
+ * ^
11562
+ * ^
11563
+ * ```
11564
+ *
11565
+ * @type {State}
11566
+ */
11567
+ function bodyRowBreak(code) {
11568
+ if (code === 124) {
11569
+ effects.enter("tableCellDivider");
11570
+ effects.consume(code);
11571
+ effects.exit("tableCellDivider");
11572
+ return bodyRowBreak;
11573
+ }
11574
+ if (code === null || markdownLineEnding(code)) {
11575
+ effects.exit("tableRow");
11576
+ return ok(code);
11577
+ }
11578
+ if (markdownSpace(code)) return factorySpace(effects, bodyRowBreak, "whitespace")(code);
11579
+ effects.enter("data");
11580
+ return bodyRowData(code);
11581
+ }
11582
+ /**
11583
+ * In table body row data.
11584
+ *
11585
+ * ```markdown
11586
+ * | | a |
11587
+ * | | - |
11588
+ * > | | b |
11589
+ * ^
11590
+ * ```
11591
+ *
11592
+ * @type {State}
11593
+ */
11594
+ function bodyRowData(code) {
11595
+ if (code === null || code === 124 || markdownLineEndingOrSpace(code)) {
11596
+ effects.exit("data");
11597
+ return bodyRowBreak(code);
11598
+ }
11599
+ effects.consume(code);
11600
+ return code === 92 ? bodyRowEscape : bodyRowData;
11601
+ }
11602
+ /**
11603
+ * In table body row escape.
11604
+ *
11605
+ * ```markdown
11606
+ * | | a |
11607
+ * | | ---- |
11608
+ * > | | b\-c |
11609
+ * ^
11610
+ * ```
11611
+ *
11612
+ * @type {State}
11613
+ */
11614
+ function bodyRowEscape(code) {
11615
+ if (code === 92 || code === 124) {
11616
+ effects.consume(code);
11617
+ return bodyRowData;
11618
+ }
11619
+ return bodyRowData(code);
11620
+ }
11621
+ }
11622
+ /** @type {Resolver} */
11623
+ function resolveTable(events, context) {
11624
+ let index = -1;
11625
+ let inFirstCellAwaitingPipe = true;
11626
+ /** @type {RowKind} */
11627
+ let rowKind = 0;
11628
+ /** @type {Range} */
11629
+ let lastCell = [
11630
+ 0,
11631
+ 0,
11632
+ 0,
11633
+ 0
11634
+ ];
11635
+ /** @type {Range} */
11636
+ let cell = [
11637
+ 0,
11638
+ 0,
11639
+ 0,
11640
+ 0
11641
+ ];
11642
+ let afterHeadAwaitingFirstBodyRow = false;
11643
+ let lastTableEnd = 0;
11644
+ /** @type {Token | undefined} */
11645
+ let currentTable;
11646
+ /** @type {Token | undefined} */
11647
+ let currentBody;
11648
+ /** @type {Token | undefined} */
11649
+ let currentCell;
11650
+ const map = new EditMap();
11651
+ while (++index < events.length) {
11652
+ const event = events[index];
11653
+ const token = event[1];
11654
+ if (event[0] === "enter") {
11655
+ if (token.type === "tableHead") {
11656
+ afterHeadAwaitingFirstBodyRow = false;
11657
+ if (lastTableEnd !== 0) {
11658
+ flushTableEnd(map, context, lastTableEnd, currentTable, currentBody);
11659
+ currentBody = void 0;
11660
+ lastTableEnd = 0;
11661
+ }
11662
+ currentTable = {
11663
+ type: "table",
11664
+ start: Object.assign({}, token.start),
11665
+ end: Object.assign({}, token.end)
11666
+ };
11667
+ map.add(index, 0, [[
11668
+ "enter",
11669
+ currentTable,
11670
+ context
11671
+ ]]);
11672
+ } else if (token.type === "tableRow" || token.type === "tableDelimiterRow") {
11673
+ inFirstCellAwaitingPipe = true;
11674
+ currentCell = void 0;
11675
+ lastCell = [
11676
+ 0,
11677
+ 0,
11678
+ 0,
11679
+ 0
11680
+ ];
11681
+ cell = [
11682
+ 0,
11683
+ index + 1,
11684
+ 0,
11685
+ 0
11686
+ ];
11687
+ if (afterHeadAwaitingFirstBodyRow) {
11688
+ afterHeadAwaitingFirstBodyRow = false;
11689
+ currentBody = {
11690
+ type: "tableBody",
11691
+ start: Object.assign({}, token.start),
11692
+ end: Object.assign({}, token.end)
11693
+ };
11694
+ map.add(index, 0, [[
11695
+ "enter",
11696
+ currentBody,
11697
+ context
11698
+ ]]);
11699
+ }
11700
+ rowKind = token.type === "tableDelimiterRow" ? 2 : currentBody ? 3 : 1;
11701
+ } else if (rowKind && (token.type === "data" || token.type === "tableDelimiterMarker" || token.type === "tableDelimiterFiller")) {
11702
+ inFirstCellAwaitingPipe = false;
11703
+ if (cell[2] === 0) {
11704
+ if (lastCell[1] !== 0) {
11705
+ cell[0] = cell[1];
11706
+ currentCell = flushCell(map, context, lastCell, rowKind, void 0, currentCell);
11707
+ lastCell = [
11708
+ 0,
11709
+ 0,
11710
+ 0,
11711
+ 0
11712
+ ];
11713
+ }
11714
+ cell[2] = index;
11715
+ }
11716
+ } else if (token.type === "tableCellDivider") {
11717
+ if (inFirstCellAwaitingPipe) inFirstCellAwaitingPipe = false;
11718
+ else {
11719
+ if (lastCell[1] !== 0) {
11720
+ cell[0] = cell[1];
11721
+ currentCell = flushCell(map, context, lastCell, rowKind, void 0, currentCell);
11722
+ }
11723
+ lastCell = cell;
11724
+ cell = [
11725
+ lastCell[1],
11726
+ index,
11727
+ 0,
11728
+ 0
11729
+ ];
11730
+ }
11731
+ }
11732
+ } else if (token.type === "tableHead") {
11733
+ afterHeadAwaitingFirstBodyRow = true;
11734
+ lastTableEnd = index;
11735
+ } else if (token.type === "tableRow" || token.type === "tableDelimiterRow") {
11736
+ lastTableEnd = index;
11737
+ if (lastCell[1] !== 0) {
11738
+ cell[0] = cell[1];
11739
+ currentCell = flushCell(map, context, lastCell, rowKind, index, currentCell);
11740
+ } else if (cell[1] !== 0) currentCell = flushCell(map, context, cell, rowKind, index, currentCell);
11741
+ rowKind = 0;
11742
+ } else if (rowKind && (token.type === "data" || token.type === "tableDelimiterMarker" || token.type === "tableDelimiterFiller")) cell[3] = index;
11743
+ }
11744
+ if (lastTableEnd !== 0) flushTableEnd(map, context, lastTableEnd, currentTable, currentBody);
11745
+ map.consume(context.events);
11746
+ index = -1;
11747
+ while (++index < context.events.length) {
11748
+ const event = context.events[index];
11749
+ if (event[0] === "enter" && event[1].type === "table") event[1]._align = gfmTableAlign(context.events, index);
11750
+ }
11751
+ return events;
11752
+ }
11753
+ /**
11754
+ * Generate a cell.
11755
+ *
11756
+ * @param {EditMap} map
11757
+ * Edit map to apply to.
11758
+ * @param {Readonly<TokenizeContext>} context
11759
+ * Tokenize context.
11760
+ * @param {Readonly<Range>} range
11761
+ * Range of the cell within events.
11762
+ * @param {RowKind} rowKind
11763
+ * Type of row.
11764
+ * @param {number | undefined} rowEnd
11765
+ * Index of the end of the row, if known.
11766
+ * @param {Token | undefined} previousCell
11767
+ * Previous cell token, if any.
11768
+ * @returns {Token | undefined}
11769
+ * Current cell token after flushing, if any.
11770
+ */
11771
+ function flushCell(map, context, range, rowKind, rowEnd, previousCell) {
11772
+ const groupName = rowKind === 1 ? "tableHeader" : rowKind === 2 ? "tableDelimiter" : "tableData";
11773
+ const valueName = "tableContent";
11774
+ if (range[0] !== 0) {
11775
+ previousCell.end = Object.assign({}, getPoint(context.events, range[0]));
11776
+ map.add(range[0], 0, [[
11777
+ "exit",
11778
+ previousCell,
11779
+ context
11780
+ ]]);
11781
+ }
11782
+ const now = getPoint(context.events, range[1]);
11783
+ previousCell = {
11784
+ type: groupName,
11785
+ start: Object.assign({}, now),
11786
+ end: Object.assign({}, now)
11787
+ };
11788
+ map.add(range[1], 0, [[
11789
+ "enter",
11790
+ previousCell,
11791
+ context
11792
+ ]]);
11793
+ if (range[2] !== 0) {
11794
+ const relatedStart = getPoint(context.events, range[2]);
11795
+ const relatedEnd = getPoint(context.events, range[3]);
11796
+ /** @type {Token} */
11797
+ const valueToken = {
11798
+ type: valueName,
11799
+ start: Object.assign({}, relatedStart),
11800
+ end: Object.assign({}, relatedEnd)
11801
+ };
11802
+ map.add(range[2], 0, [[
11803
+ "enter",
11804
+ valueToken,
11805
+ context
11806
+ ]]);
11807
+ if (rowKind !== 2) {
11808
+ const start = context.events[range[2]];
11809
+ const end = context.events[range[3]];
11810
+ start[1].end = Object.assign({}, end[1].end);
11811
+ start[1].type = "chunkText";
11812
+ start[1].contentType = "text";
11813
+ if (range[3] > range[2] + 1) {
11814
+ const a = range[2] + 1;
11815
+ const b = range[3] - range[2] - 1;
11816
+ map.add(a, b, []);
11817
+ }
11818
+ }
11819
+ map.add(range[3] + 1, 0, [[
11820
+ "exit",
11821
+ valueToken,
11822
+ context
11823
+ ]]);
11824
+ }
11825
+ if (rowEnd !== void 0) {
11826
+ previousCell.end = Object.assign({}, getPoint(context.events, rowEnd));
11827
+ map.add(rowEnd, 0, [[
11828
+ "exit",
11829
+ previousCell,
11830
+ context
11831
+ ]]);
11832
+ previousCell = void 0;
11833
+ }
11834
+ return previousCell;
11835
+ }
11836
+ /**
11837
+ * Generate table end (and table body end).
11838
+ *
11839
+ * @param {Readonly<EditMap>} map
11840
+ * Edit map to apply to.
11841
+ * @param {Readonly<TokenizeContext>} context
11842
+ * Tokenize context.
11843
+ * @param {number} index
11844
+ * Index within the events where the table end should be inserted.
11845
+ * @param {Token} table
11846
+ * Table token.
11847
+ * @param {Token | undefined} tableBody
11848
+ * Table body token, if any.
11849
+ * @returns {undefined}
11850
+ * Nothing.
11851
+ */
11852
+ function flushTableEnd(map, context, index, table, tableBody) {
11853
+ /** @type {Array<Event>} */
11854
+ const exits = [];
11855
+ const related = getPoint(context.events, index);
11856
+ if (tableBody) {
11857
+ tableBody.end = Object.assign({}, related);
11858
+ exits.push([
11859
+ "exit",
11860
+ tableBody,
11861
+ context
11862
+ ]);
11863
+ }
11864
+ table.end = Object.assign({}, related);
11865
+ exits.push([
11866
+ "exit",
11867
+ table,
11868
+ context
11869
+ ]);
11870
+ map.add(index + 1, 0, exits);
11871
+ }
11872
+ /**
11873
+ * Get the point (start or end) for a given event in the list of events.
11874
+ *
11875
+ * @param {Readonly<Array<Event>>} events
11876
+ * List of events.
11877
+ * @param {number} index
11878
+ * Index of the event to get the point for.
11879
+ * @returns {Readonly<Point>}
11880
+ * Start point for enter and end point for exit.
11881
+ */
11882
+ function getPoint(events, index) {
11883
+ const event = events[index];
11884
+ const side = event[0] === "enter" ? "start" : "end";
11885
+ return event[1][side];
11886
+ }
11887
+ // node_modules/.pnpm/mdast-util-gfm-table@2.0.1/node_modules/mdast-util-gfm-table/lib/index.js
11888
+ /**
11889
+ * @import {Heading, InlineCode, Table, TableCell, TableRow} from 'mdast'
11890
+ * @import {Options as MarkdownTableOptions} from 'markdown-table'
11891
+ * @import {
11892
+ * CompileContext,
11893
+ * Extension as FromMarkdownExtension,
11894
+ * Handle as FromMarkdownHandle,
11895
+ * } from 'mdast-util-from-markdown'
11896
+ * @import {
11897
+ * Options as ToMarkdownExtension,
11898
+ * Handle as ToMarkdownHandle,
11899
+ * Info,
11900
+ * Join,
11901
+ * State
11902
+ * } from 'mdast-util-to-markdown'
11903
+ */
11904
+ /**
11905
+ * @typedef Options
11906
+ * Configuration.
11907
+ * @property {boolean | null | undefined} [tableCellPadding=true]
11908
+ * Whether to add a space of padding between delimiters and cells (default:
11909
+ * `true`).
11910
+ * @property {boolean | null | undefined} [tablePipeAlign=true]
11911
+ * Whether to align the delimiters (default: `true`).
11912
+ * @property {MarkdownTableOptions['stringLength'] | null | undefined} [stringLength]
11913
+ * Function to detect the length of table cell content, used when aligning
11914
+ * the delimiters between cells (optional).
11915
+ */
11916
+ /**
11917
+ * Create an extension for `mdast-util-from-markdown` to enable GFM tables in
11918
+ * markdown.
11919
+ *
11920
+ * @returns {FromMarkdownExtension}
11921
+ * Extension for `mdast-util-from-markdown` to enable GFM tables.
11922
+ */
11923
+ function gfmTableFromMarkdown() {
11924
+ return {
11925
+ enter: {
11926
+ table: enterTable,
11927
+ tableData: enterCell,
11928
+ tableHeader: enterCell,
11929
+ tableRow: enterRow
11930
+ },
11931
+ exit: {
11932
+ codeText: exitCodeText,
11933
+ table: exitTable,
11934
+ tableData: exit,
11935
+ tableHeader: exit,
11936
+ tableRow: exit
11937
+ }
11938
+ };
11939
+ }
11940
+ /**
11941
+ * Enter a table.
11942
+ *
11943
+ * @this {CompileContext}
11944
+ * @type {FromMarkdownHandle}
11945
+ */
11946
+ function enterTable(token) {
11947
+ const align = token._align;
11948
+ this.enter({
11949
+ type: "table",
11950
+ align: align.map(function(d) {
11951
+ return d === "none" ? null : d;
11952
+ }),
11953
+ children: [],
11954
+ position: void 0
11955
+ }, token);
11956
+ this.data.inTable = true;
11957
+ }
11958
+ /**
11959
+ * Exit a table.
11960
+ *
11961
+ * @this {CompileContext}
11962
+ * @type {FromMarkdownHandle}
11963
+ */
11964
+ function exitTable(token) {
11965
+ this.exit(token);
11966
+ this.data.inTable = void 0;
11967
+ }
11968
+ /**
11969
+ * Enter a row.
11970
+ *
11971
+ * @this {CompileContext}
11972
+ * @type {FromMarkdownHandle}
11973
+ */
11974
+ function enterRow(token) {
11975
+ this.enter({
11976
+ type: "tableRow",
11977
+ children: [],
11978
+ position: void 0
11979
+ }, token);
11980
+ }
11981
+ /**
11982
+ * Exit a row or cell.
11983
+ *
11984
+ * @this {CompileContext}
11985
+ * @type {FromMarkdownHandle}
11986
+ */
11987
+ function exit(token) {
11988
+ this.exit(token);
11989
+ }
11990
+ /**
11991
+ * Enter a cell.
11992
+ *
11993
+ * @this {CompileContext}
11994
+ * @type {FromMarkdownHandle}
11995
+ */
11996
+ function enterCell(token) {
11997
+ this.enter({
11998
+ type: "tableCell",
11999
+ children: [],
12000
+ position: void 0
12001
+ }, token);
12002
+ }
12003
+ /**
12004
+ * Exit code (text).
12005
+ *
12006
+ * Overwrites the default code text data handler to unescape escaped pipes
12007
+ * when they are in tables.
12008
+ *
12009
+ * @this {CompileContext}
12010
+ * @type {FromMarkdownHandle}
12011
+ */
12012
+ function exitCodeText(token) {
12013
+ let value = this.resume();
12014
+ if (this.data.inTable) value = value.replace(/\\([\\|])/g, replace);
12015
+ const node = this.stack[this.stack.length - 1];
12016
+ node.type;
12017
+ node.value = value;
12018
+ this.exit(token);
12019
+ }
12020
+ /**
12021
+ * Unescape an escaped pipe.
12022
+ *
12023
+ * @param {string} $0
12024
+ * Whole match.
12025
+ * @param {string} $1
12026
+ * Escaped character.
12027
+ * @returns {string}
12028
+ * Replacement.
12029
+ */
12030
+ function replace($0, $1) {
12031
+ return $1 === "|" ? $1 : $0;
12032
+ }
12033
+ // node_modules/.pnpm/micromark-extension-gfm-footnote@2.1.0/node_modules/micromark-extension-gfm-footnote/lib/syntax.js
12034
+ /**
12035
+ * @import {Event, Exiter, Extension, Resolver, State, Token, TokenizeContext, Tokenizer} from 'micromark-util-types'
12036
+ */
12037
+ var indent = {
12038
+ tokenize: tokenizeIndent,
12039
+ partial: true
12040
+ };
12041
+ /**
12042
+ * Create an extension for `micromark` to enable GFM footnote syntax.
12043
+ *
12044
+ * @returns {Extension}
12045
+ * Extension for `micromark` that can be passed in `extensions` to
12046
+ * enable GFM footnote syntax.
12047
+ */
12048
+ function gfmFootnote() {
12049
+ /** @type {Extension} */
12050
+ return {
12051
+ document: { [91]: {
12052
+ name: "gfmFootnoteDefinition",
12053
+ tokenize: tokenizeDefinitionStart,
12054
+ continuation: { tokenize: tokenizeDefinitionContinuation },
12055
+ exit: gfmFootnoteDefinitionEnd
12056
+ } },
12057
+ text: {
12058
+ [91]: {
12059
+ name: "gfmFootnoteCall",
12060
+ tokenize: tokenizeGfmFootnoteCall
12061
+ },
12062
+ [93]: {
12063
+ name: "gfmPotentialFootnoteCall",
12064
+ add: "after",
12065
+ tokenize: tokenizePotentialGfmFootnoteCall,
12066
+ resolveTo: resolveToPotentialGfmFootnoteCall
12067
+ }
12068
+ }
12069
+ };
12070
+ }
12071
+ /**
12072
+ * @this {TokenizeContext}
12073
+ * @type {Tokenizer}
12074
+ */
12075
+ function tokenizePotentialGfmFootnoteCall(effects, ok, nok) {
12076
+ const self = this;
12077
+ let index = self.events.length;
12078
+ const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []);
12079
+ /** @type {Token} */
12080
+ let labelStart;
12081
+ while (index--) {
12082
+ const token = self.events[index][1];
12083
+ if (token.type === "labelImage") {
12084
+ labelStart = token;
12085
+ break;
12086
+ }
12087
+ if (token.type === "gfmFootnoteCall" || token.type === "labelLink" || token.type === "label" || token.type === "image" || token.type === "link") break;
12088
+ }
12089
+ return start;
12090
+ /**
12091
+ * @type {State}
12092
+ */
12093
+ function start(code) {
12094
+ if (!labelStart || !labelStart._balanced) return nok(code);
12095
+ const id = normalizeIdentifier(self.sliceSerialize({
12096
+ start: labelStart.end,
12097
+ end: self.now()
12098
+ }));
12099
+ if (id.codePointAt(0) !== 94 || !defined.includes(id.slice(1))) return nok(code);
12100
+ effects.enter("gfmFootnoteCallLabelMarker");
12101
+ effects.consume(code);
12102
+ effects.exit("gfmFootnoteCallLabelMarker");
12103
+ return ok(code);
12104
+ }
12105
+ }
12106
+ /** @type {Resolver} */
12107
+ function resolveToPotentialGfmFootnoteCall(events, context) {
12108
+ let index = events.length;
12109
+ while (index--) if (events[index][1].type === "labelImage" && events[index][0] === "enter") {
12110
+ events[index][1];
12111
+ break;
12112
+ }
12113
+ events[index + 1][1].type = "data";
12114
+ events[index + 3][1].type = "gfmFootnoteCallLabelMarker";
12115
+ /** @type {Token} */
12116
+ const call = {
12117
+ type: "gfmFootnoteCall",
12118
+ start: Object.assign({}, events[index + 3][1].start),
12119
+ end: Object.assign({}, events[events.length - 1][1].end)
12120
+ };
12121
+ /** @type {Token} */
12122
+ const marker = {
12123
+ type: "gfmFootnoteCallMarker",
12124
+ start: Object.assign({}, events[index + 3][1].end),
12125
+ end: Object.assign({}, events[index + 3][1].end)
12126
+ };
12127
+ marker.end.column++;
12128
+ marker.end.offset++;
12129
+ marker.end._bufferIndex++;
12130
+ /** @type {Token} */
12131
+ const string = {
12132
+ type: "gfmFootnoteCallString",
12133
+ start: Object.assign({}, marker.end),
12134
+ end: Object.assign({}, events[events.length - 1][1].start)
12135
+ };
12136
+ /** @type {Token} */
12137
+ const chunk = {
12138
+ type: "chunkString",
12139
+ contentType: "string",
12140
+ start: Object.assign({}, string.start),
12141
+ end: Object.assign({}, string.end)
12142
+ };
12143
+ /** @type {Array<Event>} */
12144
+ const replacement = [
12145
+ events[index + 1],
12146
+ events[index + 2],
12147
+ [
12148
+ "enter",
12149
+ call,
12150
+ context
12151
+ ],
12152
+ events[index + 3],
12153
+ events[index + 4],
12154
+ [
12155
+ "enter",
12156
+ marker,
12157
+ context
12158
+ ],
12159
+ [
12160
+ "exit",
12161
+ marker,
12162
+ context
12163
+ ],
12164
+ [
12165
+ "enter",
12166
+ string,
12167
+ context
12168
+ ],
12169
+ [
12170
+ "enter",
12171
+ chunk,
12172
+ context
12173
+ ],
12174
+ [
12175
+ "exit",
12176
+ chunk,
12177
+ context
12178
+ ],
12179
+ [
12180
+ "exit",
12181
+ string,
12182
+ context
12183
+ ],
12184
+ events[events.length - 2],
12185
+ events[events.length - 1],
12186
+ [
12187
+ "exit",
12188
+ call,
12189
+ context
12190
+ ]
12191
+ ];
12192
+ events.splice(index, events.length - index + 1, ...replacement);
12193
+ return events;
12194
+ }
12195
+ /**
12196
+ * @this {TokenizeContext}
12197
+ * @type {Tokenizer}
12198
+ */
12199
+ function tokenizeGfmFootnoteCall(effects, ok, nok) {
12200
+ const self = this;
12201
+ const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []);
12202
+ let size = 0;
12203
+ /** @type {boolean} */
12204
+ let data;
12205
+ return start;
12206
+ /**
12207
+ * Start of footnote label.
12208
+ *
12209
+ * ```markdown
12210
+ * > | a [^b] c
12211
+ * ^
12212
+ * ```
12213
+ *
12214
+ * @type {State}
12215
+ */
12216
+ function start(code) {
12217
+ effects.enter("gfmFootnoteCall");
12218
+ effects.enter("gfmFootnoteCallLabelMarker");
12219
+ effects.consume(code);
12220
+ effects.exit("gfmFootnoteCallLabelMarker");
12221
+ return callStart;
12222
+ }
12223
+ /**
12224
+ * After `[`, at `^`.
12225
+ *
12226
+ * ```markdown
12227
+ * > | a [^b] c
12228
+ * ^
12229
+ * ```
12230
+ *
12231
+ * @type {State}
12232
+ */
12233
+ function callStart(code) {
12234
+ if (code !== 94) return nok(code);
12235
+ effects.enter("gfmFootnoteCallMarker");
12236
+ effects.consume(code);
12237
+ effects.exit("gfmFootnoteCallMarker");
12238
+ effects.enter("gfmFootnoteCallString");
12239
+ effects.enter("chunkString").contentType = "string";
12240
+ return callData;
12241
+ }
12242
+ /**
12243
+ * In label.
12244
+ *
12245
+ * ```markdown
12246
+ * > | a [^b] c
12247
+ * ^
12248
+ * ```
12249
+ *
12250
+ * @type {State}
12251
+ */
12252
+ function callData(code) {
12253
+ if (size > 999 || code === 93 && !data || code === null || code === 91 || markdownLineEndingOrSpace(code)) return nok(code);
12254
+ if (code === 93) {
12255
+ effects.exit("chunkString");
12256
+ const token = effects.exit("gfmFootnoteCallString");
12257
+ if (!defined.includes(normalizeIdentifier(self.sliceSerialize(token)))) return nok(code);
12258
+ effects.enter("gfmFootnoteCallLabelMarker");
12259
+ effects.consume(code);
12260
+ effects.exit("gfmFootnoteCallLabelMarker");
12261
+ effects.exit("gfmFootnoteCall");
12262
+ return ok;
12263
+ }
12264
+ if (!markdownLineEndingOrSpace(code)) data = true;
12265
+ size++;
12266
+ effects.consume(code);
12267
+ return code === 92 ? callEscape : callData;
12268
+ }
12269
+ /**
12270
+ * On character after escape.
12271
+ *
12272
+ * ```markdown
12273
+ * > | a [^b\c] d
12274
+ * ^
12275
+ * ```
12276
+ *
12277
+ * @type {State}
12278
+ */
12279
+ function callEscape(code) {
12280
+ if (code === 91 || code === 92 || code === 93) {
12281
+ effects.consume(code);
12282
+ size++;
12283
+ return callData;
12284
+ }
12285
+ return callData(code);
12286
+ }
12287
+ }
12288
+ /**
12289
+ * @this {TokenizeContext}
12290
+ * @type {Tokenizer}
12291
+ */
12292
+ function tokenizeDefinitionStart(effects, ok, nok) {
12293
+ const self = this;
12294
+ const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []);
12295
+ /** @type {string} */
12296
+ let identifier;
12297
+ let size = 0;
12298
+ /** @type {boolean | undefined} */
12299
+ let data;
12300
+ return start;
12301
+ /**
12302
+ * Start of GFM footnote definition.
12303
+ *
12304
+ * ```markdown
12305
+ * > | [^a]: b
12306
+ * ^
12307
+ * ```
12308
+ *
12309
+ * @type {State}
12310
+ */
12311
+ function start(code) {
12312
+ effects.enter("gfmFootnoteDefinition")._container = true;
12313
+ effects.enter("gfmFootnoteDefinitionLabel");
12314
+ effects.enter("gfmFootnoteDefinitionLabelMarker");
12315
+ effects.consume(code);
12316
+ effects.exit("gfmFootnoteDefinitionLabelMarker");
12317
+ return labelAtMarker;
12318
+ }
12319
+ /**
12320
+ * In label, at caret.
12321
+ *
12322
+ * ```markdown
12323
+ * > | [^a]: b
12324
+ * ^
12325
+ * ```
12326
+ *
12327
+ * @type {State}
12328
+ */
12329
+ function labelAtMarker(code) {
12330
+ if (code === 94) {
12331
+ effects.enter("gfmFootnoteDefinitionMarker");
12332
+ effects.consume(code);
12333
+ effects.exit("gfmFootnoteDefinitionMarker");
12334
+ effects.enter("gfmFootnoteDefinitionLabelString");
12335
+ effects.enter("chunkString").contentType = "string";
12336
+ return labelInside;
12337
+ }
12338
+ return nok(code);
12339
+ }
12340
+ /**
12341
+ * In label.
12342
+ *
12343
+ * > 👉 **Note**: `cmark-gfm` prevents whitespace from occurring in footnote
12344
+ * > definition labels.
12345
+ *
12346
+ * ```markdown
12347
+ * > | [^a]: b
12348
+ * ^
12349
+ * ```
12350
+ *
12351
+ * @type {State}
12352
+ */
12353
+ function labelInside(code) {
12354
+ if (size > 999 || code === 93 && !data || code === null || code === 91 || markdownLineEndingOrSpace(code)) return nok(code);
12355
+ if (code === 93) {
12356
+ effects.exit("chunkString");
12357
+ const token = effects.exit("gfmFootnoteDefinitionLabelString");
12358
+ identifier = normalizeIdentifier(self.sliceSerialize(token));
12359
+ effects.enter("gfmFootnoteDefinitionLabelMarker");
12360
+ effects.consume(code);
12361
+ effects.exit("gfmFootnoteDefinitionLabelMarker");
12362
+ effects.exit("gfmFootnoteDefinitionLabel");
12363
+ return labelAfter;
12364
+ }
12365
+ if (!markdownLineEndingOrSpace(code)) data = true;
12366
+ size++;
12367
+ effects.consume(code);
12368
+ return code === 92 ? labelEscape : labelInside;
12369
+ }
12370
+ /**
12371
+ * After `\`, at a special character.
12372
+ *
12373
+ * > 👉 **Note**: `cmark-gfm` currently does not support escaped brackets:
12374
+ * > <https://github.com/github/cmark-gfm/issues/240>
12375
+ *
12376
+ * ```markdown
12377
+ * > | [^a\*b]: c
12378
+ * ^
12379
+ * ```
12380
+ *
12381
+ * @type {State}
12382
+ */
12383
+ function labelEscape(code) {
12384
+ if (code === 91 || code === 92 || code === 93) {
12385
+ effects.consume(code);
12386
+ size++;
12387
+ return labelInside;
12388
+ }
12389
+ return labelInside(code);
12390
+ }
12391
+ /**
12392
+ * After definition label.
12393
+ *
12394
+ * ```markdown
12395
+ * > | [^a]: b
12396
+ * ^
12397
+ * ```
12398
+ *
12399
+ * @type {State}
12400
+ */
12401
+ function labelAfter(code) {
12402
+ if (code === 58) {
12403
+ effects.enter("definitionMarker");
12404
+ effects.consume(code);
12405
+ effects.exit("definitionMarker");
12406
+ if (!defined.includes(identifier)) defined.push(identifier);
12407
+ return factorySpace(effects, whitespaceAfter, "gfmFootnoteDefinitionWhitespace");
12408
+ }
12409
+ return nok(code);
12410
+ }
12411
+ /**
12412
+ * After definition prefix.
12413
+ *
12414
+ * ```markdown
12415
+ * > | [^a]: b
12416
+ * ^
12417
+ * ```
12418
+ *
12419
+ * @type {State}
12420
+ */
12421
+ function whitespaceAfter(code) {
12422
+ return ok(code);
12423
+ }
12424
+ }
12425
+ /**
12426
+ * @this {TokenizeContext}
12427
+ * @type {Tokenizer}
12428
+ */
12429
+ function tokenizeDefinitionContinuation(effects, ok, nok) {
12430
+ return effects.check(blankLine, ok, effects.attempt(indent, ok, nok));
12431
+ }
12432
+ /** @type {Exiter} */
12433
+ function gfmFootnoteDefinitionEnd(effects) {
12434
+ effects.exit("gfmFootnoteDefinition");
12435
+ }
12436
+ /**
12437
+ * @this {TokenizeContext}
12438
+ * @type {Tokenizer}
12439
+ */
12440
+ function tokenizeIndent(effects, ok, nok) {
12441
+ const self = this;
12442
+ return factorySpace(effects, afterPrefix, "gfmFootnoteDefinitionIndent", 5);
12443
+ /**
12444
+ * @type {State}
12445
+ */
12446
+ function afterPrefix(code) {
12447
+ const tail = self.events[self.events.length - 1];
12448
+ return tail && tail[1].type === "gfmFootnoteDefinitionIndent" && tail[2].sliceSerialize(tail[1], true).length === 4 ? ok(code) : nok(code);
12449
+ }
12450
+ }
12451
+ // node_modules/.pnpm/mdast-util-gfm-footnote@2.1.0/node_modules/mdast-util-gfm-footnote/lib/index.js
12452
+ /**
12453
+ * @import {
12454
+ * CompileContext,
12455
+ * Extension as FromMarkdownExtension,
12456
+ * Handle as FromMarkdownHandle
12457
+ * } from 'mdast-util-from-markdown'
12458
+ * @import {ToMarkdownOptions} from 'mdast-util-gfm-footnote'
12459
+ * @import {
12460
+ * Handle as ToMarkdownHandle,
12461
+ * Map,
12462
+ * Options as ToMarkdownExtension
12463
+ * } from 'mdast-util-to-markdown'
12464
+ * @import {FootnoteDefinition, FootnoteReference} from 'mdast'
12465
+ */
12466
+ footnoteReference.peek = footnoteReferencePeek;
12467
+ /**
12468
+ * @this {CompileContext}
12469
+ * @type {FromMarkdownHandle}
12470
+ */
12471
+ function enterFootnoteCallString() {
12472
+ this.buffer();
12473
+ }
12474
+ /**
12475
+ * @this {CompileContext}
12476
+ * @type {FromMarkdownHandle}
12477
+ */
12478
+ function enterFootnoteCall(token) {
12479
+ this.enter({
12480
+ type: "footnoteReference",
12481
+ identifier: "",
12482
+ label: ""
12483
+ }, token);
12484
+ }
12485
+ /**
12486
+ * @this {CompileContext}
12487
+ * @type {FromMarkdownHandle}
12488
+ */
12489
+ function enterFootnoteDefinitionLabelString() {
12490
+ this.buffer();
12491
+ }
12492
+ /**
12493
+ * @this {CompileContext}
12494
+ * @type {FromMarkdownHandle}
12495
+ */
12496
+ function enterFootnoteDefinition(token) {
12497
+ this.enter({
12498
+ type: "footnoteDefinition",
12499
+ identifier: "",
12500
+ label: "",
12501
+ children: []
12502
+ }, token);
12503
+ }
12504
+ /**
12505
+ * @this {CompileContext}
12506
+ * @type {FromMarkdownHandle}
12507
+ */
12508
+ function exitFootnoteCallString(token) {
12509
+ const label = this.resume();
12510
+ const node = this.stack[this.stack.length - 1];
12511
+ node.type;
12512
+ node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
12513
+ node.label = label;
12514
+ }
12515
+ /**
12516
+ * @this {CompileContext}
12517
+ * @type {FromMarkdownHandle}
12518
+ */
12519
+ function exitFootnoteCall(token) {
12520
+ this.exit(token);
12521
+ }
12522
+ /**
12523
+ * @this {CompileContext}
12524
+ * @type {FromMarkdownHandle}
12525
+ */
12526
+ function exitFootnoteDefinitionLabelString(token) {
12527
+ const label = this.resume();
12528
+ const node = this.stack[this.stack.length - 1];
12529
+ node.type;
12530
+ node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
12531
+ node.label = label;
12532
+ }
12533
+ /**
12534
+ * @this {CompileContext}
12535
+ * @type {FromMarkdownHandle}
12536
+ */
12537
+ function exitFootnoteDefinition(token) {
12538
+ this.exit(token);
12539
+ }
12540
+ /** @type {ToMarkdownHandle} */
12541
+ function footnoteReferencePeek() {
12542
+ return "[";
12543
+ }
12544
+ /**
12545
+ * @type {ToMarkdownHandle}
12546
+ * @param {FootnoteReference} node
12547
+ */
12548
+ function footnoteReference(node, _, state, info) {
12549
+ const tracker = state.createTracker(info);
12550
+ let value = tracker.move("[^");
12551
+ const exit = state.enter("footnoteReference");
12552
+ const subexit = state.enter("reference");
12553
+ value += tracker.move(state.safe(state.associationId(node), {
12554
+ after: "]",
12555
+ before: value
12556
+ }));
12557
+ subexit();
12558
+ exit();
12559
+ value += tracker.move("]");
12560
+ return value;
12561
+ }
12562
+ /**
12563
+ * Create an extension for `mdast-util-from-markdown` to enable GFM footnotes
12564
+ * in markdown.
12565
+ *
12566
+ * @returns {FromMarkdownExtension}
12567
+ * Extension for `mdast-util-from-markdown`.
12568
+ */
12569
+ function gfmFootnoteFromMarkdown() {
12570
+ return {
12571
+ enter: {
12572
+ gfmFootnoteCallString: enterFootnoteCallString,
12573
+ gfmFootnoteCall: enterFootnoteCall,
12574
+ gfmFootnoteDefinitionLabelString: enterFootnoteDefinitionLabelString,
12575
+ gfmFootnoteDefinition: enterFootnoteDefinition
12576
+ },
12577
+ exit: {
12578
+ gfmFootnoteCallString: exitFootnoteCallString,
12579
+ gfmFootnoteCall: exitFootnoteCall,
12580
+ gfmFootnoteDefinitionLabelString: exitFootnoteDefinitionLabelString,
12581
+ gfmFootnoteDefinition: exitFootnoteDefinition
12582
+ }
12583
+ };
12584
+ }
12585
+ // node_modules/.pnpm/micromark-extension-gfm-task-list-item@2.1.0/node_modules/micromark-extension-gfm-task-list-item/lib/syntax.js
12586
+ /**
12587
+ * @import {Extension, State, TokenizeContext, Tokenizer} from 'micromark-util-types'
12588
+ */
12589
+ var tasklistCheck = {
12590
+ name: "tasklistCheck",
12591
+ tokenize: tokenizeTasklistCheck
12592
+ };
12593
+ /**
12594
+ * Create an HTML extension for `micromark` to support GFM task list items
12595
+ * syntax.
12596
+ *
12597
+ * @returns {Extension}
12598
+ * Extension for `micromark` that can be passed in `htmlExtensions` to
12599
+ * support GFM task list items when serializing to HTML.
12600
+ */
12601
+ function gfmTaskListItem() {
12602
+ return { text: { [91]: tasklistCheck } };
12603
+ }
12604
+ /**
12605
+ * @this {TokenizeContext}
12606
+ * @type {Tokenizer}
12607
+ */
12608
+ function tokenizeTasklistCheck(effects, ok, nok) {
12609
+ const self = this;
12610
+ return open;
12611
+ /**
12612
+ * At start of task list item check.
12613
+ *
12614
+ * ```markdown
12615
+ * > | * [x] y.
12616
+ * ^
12617
+ * ```
12618
+ *
12619
+ * @type {State}
12620
+ */
12621
+ function open(code) {
12622
+ if (self.previous !== null || !self._gfmTasklistFirstContentOfListItem) return nok(code);
12623
+ effects.enter("taskListCheck");
12624
+ effects.enter("taskListCheckMarker");
12625
+ effects.consume(code);
12626
+ effects.exit("taskListCheckMarker");
12627
+ return inside;
12628
+ }
12629
+ /**
12630
+ * In task list item check.
12631
+ *
12632
+ * ```markdown
12633
+ * > | * [x] y.
12634
+ * ^
12635
+ * ```
12636
+ *
12637
+ * @type {State}
12638
+ */
12639
+ function inside(code) {
12640
+ if (markdownLineEndingOrSpace(code)) {
12641
+ effects.enter("taskListCheckValueUnchecked");
12642
+ effects.consume(code);
12643
+ effects.exit("taskListCheckValueUnchecked");
12644
+ return close;
12645
+ }
12646
+ if (code === 88 || code === 120) {
12647
+ effects.enter("taskListCheckValueChecked");
12648
+ effects.consume(code);
12649
+ effects.exit("taskListCheckValueChecked");
12650
+ return close;
12651
+ }
12652
+ return nok(code);
12653
+ }
12654
+ /**
12655
+ * At close of task list item check.
12656
+ *
12657
+ * ```markdown
12658
+ * > | * [x] y.
12659
+ * ^
12660
+ * ```
12661
+ *
12662
+ * @type {State}
12663
+ */
12664
+ function close(code) {
12665
+ if (code === 93) {
12666
+ effects.enter("taskListCheckMarker");
12667
+ effects.consume(code);
12668
+ effects.exit("taskListCheckMarker");
12669
+ effects.exit("taskListCheck");
12670
+ return after;
12671
+ }
12672
+ return nok(code);
12673
+ }
12674
+ /**
12675
+ * @type {State}
12676
+ */
12677
+ function after(code) {
12678
+ if (markdownLineEnding(code)) return ok(code);
12679
+ if (markdownSpace(code)) return effects.check({ tokenize: spaceThenNonSpace }, ok, nok)(code);
12680
+ return nok(code);
12681
+ }
12682
+ }
12683
+ /**
12684
+ * @this {TokenizeContext}
12685
+ * @type {Tokenizer}
12686
+ */
12687
+ function spaceThenNonSpace(effects, ok, nok) {
12688
+ return factorySpace(effects, after, "whitespace");
12689
+ /**
12690
+ * After whitespace, after task list item check.
12691
+ *
12692
+ * ```markdown
12693
+ * > | * [x] y.
12694
+ * ^
12695
+ * ```
12696
+ *
12697
+ * @type {State}
12698
+ */
12699
+ function after(code) {
12700
+ return code === null ? nok(code) : ok(code);
12701
+ }
12702
+ }
12703
+ // node_modules/.pnpm/mdast-util-gfm-task-list-item@2.0.1/node_modules/mdast-util-gfm-task-list-item/lib/index.js
12704
+ /**
12705
+ * @import {ListItem, Paragraph, Parents} from 'mdast'
12706
+ * @import {
12707
+ * CompileContext,
12708
+ * Extension as FromMarkdownExtension,
12709
+ * Handle as FromMarkdownHandle
12710
+ * } from 'mdast-util-from-markdown'
12711
+ * @import {
12712
+ * Handle as ToMarkdownHandle,
12713
+ * Join as ToMarkdownJoin,
12714
+ * Options as ToMarkdownExtension
12715
+ * } from 'mdast-util-to-markdown'
12716
+ */
12717
+ /**
12718
+ * Create an extension for `mdast-util-from-markdown` to enable GFM task
12719
+ * list items in markdown.
12720
+ *
12721
+ * @returns {FromMarkdownExtension}
12722
+ * Extension for `mdast-util-from-markdown` to enable GFM task list items.
12723
+ */
12724
+ function gfmTaskListItemFromMarkdown() {
12725
+ return { exit: {
12726
+ taskListCheckValueChecked: exitCheck,
12727
+ taskListCheckValueUnchecked: exitCheck,
12728
+ paragraph: exitParagraphWithTaskListItem
12729
+ } };
12730
+ }
12731
+ /**
12732
+ * Exit a check.
12733
+ *
12734
+ * @this {CompileContext}
12735
+ * @type {FromMarkdownHandle}
12736
+ */
12737
+ function exitCheck(token) {
12738
+ const node = this.stack[this.stack.length - 2];
12739
+ node.type;
12740
+ node.checked = token.type === "taskListCheckValueChecked";
12741
+ }
12742
+ /**
12743
+ * Exit a paragraph, removing the whitespace after a check.
12744
+ *
12745
+ * @this {CompileContext}
12746
+ * @type {FromMarkdownHandle}
12747
+ */
12748
+ function exitParagraphWithTaskListItem(token) {
12749
+ const parent = this.stack[this.stack.length - 2];
12750
+ if (parent && parent.type === "listItem" && typeof parent.checked === "boolean") {
12751
+ const node = this.stack[this.stack.length - 1];
12752
+ node.type;
12753
+ const head = node.children[0];
12754
+ if (head && head.type === "text") {
12755
+ const siblings = parent.children;
12756
+ let index = -1;
12757
+ /** @type {Paragraph | undefined} */
12758
+ let firstParagraph;
12759
+ while (++index < siblings.length) {
12760
+ const sibling = siblings[index];
12761
+ if (sibling.type === "paragraph") {
12762
+ firstParagraph = sibling;
12763
+ break;
12764
+ }
12765
+ }
12766
+ if (firstParagraph === node) {
12767
+ head.value = head.value.slice(1);
12768
+ if (head.value.length === 0) node.children.shift();
12769
+ else if (node.position && head.position && typeof head.position.start.offset === "number") {
12770
+ head.position.start.column++;
12771
+ head.position.start.offset++;
12772
+ node.position.start = { ...head.position.start };
12773
+ }
12774
+ }
12775
+ }
12776
+ }
12777
+ this.exit(token);
12778
+ }
12779
+ // node_modules/.pnpm/micromark-extension-math@3.1.0/node_modules/micromark-extension-math/lib/math-flow.js
12780
+ /**
12781
+ * @import {Construct, State, TokenizeContext, Tokenizer} from 'micromark-util-types'
12782
+ */
12783
+ /** @type {Construct} */
12784
+ var mathFlow = {
12785
+ tokenize: tokenizeMathFenced,
12786
+ concrete: true,
12787
+ name: "mathFlow"
12788
+ };
12789
+ /** @type {Construct} */
12790
+ var nonLazyContinuation = {
12791
+ tokenize: tokenizeNonLazyContinuation,
12792
+ partial: true
12793
+ };
12794
+ /**
12795
+ * @this {TokenizeContext}
12796
+ * @type {Tokenizer}
12797
+ */
12798
+ function tokenizeMathFenced(effects, ok, nok) {
12799
+ const self = this;
12800
+ const tail = self.events[self.events.length - 1];
12801
+ const initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
12802
+ let sizeOpen = 0;
12803
+ return start;
12804
+ /**
12805
+ * Start of math.
12806
+ *
12807
+ * ```markdown
12808
+ * > | $$
12809
+ * ^
12810
+ * | \frac{1}{2}
12811
+ * | $$
12812
+ * ```
12813
+ *
12814
+ * @type {State}
12815
+ */
12816
+ function start(code) {
12817
+ effects.enter("mathFlow");
12818
+ effects.enter("mathFlowFence");
12819
+ effects.enter("mathFlowFenceSequence");
12820
+ return sequenceOpen(code);
12821
+ }
12822
+ /**
12823
+ * In opening fence sequence.
12824
+ *
12825
+ * ```markdown
12826
+ * > | $$
12827
+ * ^
12828
+ * | \frac{1}{2}
12829
+ * | $$
12830
+ * ```
12831
+ *
12832
+ * @type {State}
12833
+ */
12834
+ function sequenceOpen(code) {
12835
+ if (code === 36) {
12836
+ effects.consume(code);
12837
+ sizeOpen++;
12838
+ return sequenceOpen;
12839
+ }
12840
+ if (sizeOpen < 2) return nok(code);
12841
+ effects.exit("mathFlowFenceSequence");
12842
+ return factorySpace(effects, metaBefore, "whitespace")(code);
12843
+ }
12844
+ /**
12845
+ * In opening fence, before meta.
12846
+ *
12847
+ * ```markdown
12848
+ * > | $$asciimath
12849
+ * ^
12850
+ * | x < y
12851
+ * | $$
12852
+ * ```
12853
+ *
12854
+ * @type {State}
12855
+ */
12856
+ function metaBefore(code) {
12857
+ if (code === null || markdownLineEnding(code)) return metaAfter(code);
12858
+ effects.enter("mathFlowFenceMeta");
12859
+ effects.enter("chunkString", { contentType: "string" });
12860
+ return meta(code);
12861
+ }
12862
+ /**
12863
+ * In meta.
12864
+ *
12865
+ * ```markdown
12866
+ * > | $$asciimath
12867
+ * ^
12868
+ * | x < y
12869
+ * | $$
12870
+ * ```
12871
+ *
12872
+ * @type {State}
12873
+ */
12874
+ function meta(code) {
12875
+ if (code === null || markdownLineEnding(code)) {
12876
+ effects.exit("chunkString");
12877
+ effects.exit("mathFlowFenceMeta");
12878
+ return metaAfter(code);
12879
+ }
12880
+ if (code === 36) return nok(code);
12881
+ effects.consume(code);
12882
+ return meta;
12883
+ }
12884
+ /**
12885
+ * After meta.
12886
+ *
12887
+ * ```markdown
12888
+ * > | $$
12889
+ * ^
12890
+ * | \frac{1}{2}
12891
+ * | $$
12892
+ * ```
12893
+ *
12894
+ * @type {State}
12895
+ */
12896
+ function metaAfter(code) {
12897
+ effects.exit("mathFlowFence");
12898
+ if (self.interrupt) return ok(code);
12899
+ return effects.attempt(nonLazyContinuation, beforeNonLazyContinuation, after)(code);
12900
+ }
12901
+ /**
12902
+ * After eol/eof in math, at a non-lazy closing fence or content.
12903
+ *
12904
+ * ```markdown
12905
+ * | $$
12906
+ * > | \frac{1}{2}
12907
+ * ^
12908
+ * > | $$
12909
+ * ^
12910
+ * ```
12911
+ *
12912
+ * @type {State}
12913
+ */
12914
+ function beforeNonLazyContinuation(code) {
12915
+ return effects.attempt({
12916
+ tokenize: tokenizeClosingFence,
12917
+ partial: true
12918
+ }, after, contentStart)(code);
12919
+ }
12920
+ /**
12921
+ * Before math content, definitely not before a closing fence.
12922
+ *
12923
+ * ```markdown
12924
+ * | $$
12925
+ * > | \frac{1}{2}
12926
+ * ^
12927
+ * | $$
12928
+ * ```
12929
+ *
12930
+ * @type {State}
12931
+ */
12932
+ function contentStart(code) {
12933
+ return (initialSize ? factorySpace(effects, beforeContentChunk, "linePrefix", initialSize + 1) : beforeContentChunk)(code);
12934
+ }
12935
+ /**
12936
+ * Before math content, after optional prefix.
12937
+ *
12938
+ * ```markdown
12939
+ * | $$
12940
+ * > | \frac{1}{2}
12941
+ * ^
12942
+ * | $$
12943
+ * ```
12944
+ *
12945
+ * @type {State}
12946
+ */
12947
+ function beforeContentChunk(code) {
12948
+ if (code === null) return after(code);
12949
+ if (markdownLineEnding(code)) return effects.attempt(nonLazyContinuation, beforeNonLazyContinuation, after)(code);
12950
+ effects.enter("mathFlowValue");
12951
+ return contentChunk(code);
12952
+ }
12953
+ /**
12954
+ * In math content.
12955
+ *
12956
+ * ```markdown
12957
+ * | $$
12958
+ * > | \frac{1}{2}
12959
+ * ^
12960
+ * | $$
12961
+ * ```
12962
+ *
12963
+ * @type {State}
12964
+ */
12965
+ function contentChunk(code) {
12966
+ if (code === null || markdownLineEnding(code)) {
12967
+ effects.exit("mathFlowValue");
12968
+ return beforeContentChunk(code);
12969
+ }
12970
+ effects.consume(code);
12971
+ return contentChunk;
12972
+ }
12973
+ /**
12974
+ * After math (ha!).
12975
+ *
12976
+ * ```markdown
12977
+ * | $$
12978
+ * | \frac{1}{2}
12979
+ * > | $$
12980
+ * ^
12981
+ * ```
12982
+ *
12983
+ * @type {State}
12984
+ */
12985
+ function after(code) {
12986
+ effects.exit("mathFlow");
12987
+ return ok(code);
12988
+ }
12989
+ /** @type {Tokenizer} */
12990
+ function tokenizeClosingFence(effects, ok, nok) {
12991
+ let size = 0;
12992
+ /**
12993
+ * Before closing fence, at optional whitespace.
12994
+ *
12995
+ * ```markdown
12996
+ * | $$
12997
+ * | \frac{1}{2}
12998
+ * > | $$
12999
+ * ^
13000
+ * ```
13001
+ */
13002
+ return factorySpace(effects, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
13003
+ /**
13004
+ * In closing fence, after optional whitespace, at sequence.
13005
+ *
13006
+ * ```markdown
13007
+ * | $$
13008
+ * | \frac{1}{2}
13009
+ * > | $$
13010
+ * ^
13011
+ * ```
13012
+ *
13013
+ * @type {State}
13014
+ */
13015
+ function beforeSequenceClose(code) {
13016
+ effects.enter("mathFlowFence");
13017
+ effects.enter("mathFlowFenceSequence");
13018
+ return sequenceClose(code);
13019
+ }
13020
+ /**
13021
+ * In closing fence sequence.
13022
+ *
13023
+ * ```markdown
13024
+ * | $$
13025
+ * | \frac{1}{2}
13026
+ * > | $$
13027
+ * ^
13028
+ * ```
13029
+ *
13030
+ * @type {State}
13031
+ */
13032
+ function sequenceClose(code) {
13033
+ if (code === 36) {
13034
+ size++;
13035
+ effects.consume(code);
13036
+ return sequenceClose;
13037
+ }
13038
+ if (size < sizeOpen) return nok(code);
13039
+ effects.exit("mathFlowFenceSequence");
13040
+ return factorySpace(effects, afterSequenceClose, "whitespace")(code);
13041
+ }
13042
+ /**
13043
+ * After closing fence sequence, after optional whitespace.
13044
+ *
13045
+ * ```markdown
13046
+ * | $$
13047
+ * | \frac{1}{2}
13048
+ * > | $$
13049
+ * ^
13050
+ * ```
13051
+ *
13052
+ * @type {State}
13053
+ */
13054
+ function afterSequenceClose(code) {
13055
+ if (code === null || markdownLineEnding(code)) {
13056
+ effects.exit("mathFlowFence");
13057
+ return ok(code);
13058
+ }
13059
+ return nok(code);
13060
+ }
13061
+ }
13062
+ }
13063
+ /**
13064
+ * @this {TokenizeContext}
13065
+ * @type {Tokenizer}
13066
+ */
13067
+ function tokenizeNonLazyContinuation(effects, ok, nok) {
13068
+ const self = this;
13069
+ return start;
13070
+ /** @type {State} */
13071
+ function start(code) {
13072
+ if (code === null) return ok(code);
13073
+ effects.enter("lineEnding");
13074
+ effects.consume(code);
13075
+ effects.exit("lineEnding");
13076
+ return lineStart;
13077
+ }
13078
+ /** @type {State} */
13079
+ function lineStart(code) {
13080
+ return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
13081
+ }
13082
+ }
13083
+ // node_modules/.pnpm/micromark-extension-math@3.1.0/node_modules/micromark-extension-math/lib/math-text.js
13084
+ /**
13085
+ * @import {Options} from 'micromark-extension-math'
13086
+ * @import {Construct, Previous, Resolver, State, Token, TokenizeContext, Tokenizer} from 'micromark-util-types'
13087
+ */
13088
+ /**
13089
+ * @param {Options | null | undefined} [options={}]
13090
+ * Configuration (default: `{}`).
13091
+ * @returns {Construct}
13092
+ * Construct.
13093
+ */
13094
+ function mathText(options) {
13095
+ let single = (options || {}).singleDollarTextMath;
13096
+ if (single === null || single === void 0) single = true;
13097
+ return {
13098
+ tokenize: tokenizeMathText,
13099
+ resolve: resolveMathText,
13100
+ previous,
13101
+ name: "mathText"
13102
+ };
13103
+ /**
13104
+ * @this {TokenizeContext}
13105
+ * @type {Tokenizer}
13106
+ */
13107
+ function tokenizeMathText(effects, ok, nok) {
13108
+ let sizeOpen = 0;
13109
+ /** @type {number} */
13110
+ let size;
13111
+ /** @type {Token} */
13112
+ let token;
13113
+ return start;
13114
+ /**
13115
+ * Start of math (text).
13116
+ *
13117
+ * ```markdown
13118
+ * > | $a$
13119
+ * ^
13120
+ * > | \$a$
13121
+ * ^
13122
+ * ```
13123
+ *
13124
+ * @type {State}
13125
+ */
13126
+ function start(code) {
13127
+ effects.enter("mathText");
13128
+ effects.enter("mathTextSequence");
13129
+ return sequenceOpen(code);
13130
+ }
13131
+ /**
13132
+ * In opening sequence.
13133
+ *
13134
+ * ```markdown
13135
+ * > | $a$
13136
+ * ^
13137
+ * ```
13138
+ *
13139
+ * @type {State}
13140
+ */
13141
+ function sequenceOpen(code) {
13142
+ if (code === 36) {
13143
+ effects.consume(code);
13144
+ sizeOpen++;
13145
+ return sequenceOpen;
13146
+ }
13147
+ if (sizeOpen < 2 && !single) return nok(code);
13148
+ effects.exit("mathTextSequence");
13149
+ return between(code);
13150
+ }
13151
+ /**
13152
+ * Between something and something else.
13153
+ *
13154
+ * ```markdown
13155
+ * > | $a$
13156
+ * ^^
13157
+ * ```
13158
+ *
13159
+ * @type {State}
13160
+ */
13161
+ function between(code) {
13162
+ if (code === null) return nok(code);
13163
+ if (code === 36) {
13164
+ token = effects.enter("mathTextSequence");
13165
+ size = 0;
13166
+ return sequenceClose(code);
13167
+ }
13168
+ if (code === 32) {
13169
+ effects.enter("space");
13170
+ effects.consume(code);
13171
+ effects.exit("space");
13172
+ return between;
13173
+ }
13174
+ if (markdownLineEnding(code)) {
13175
+ effects.enter("lineEnding");
13176
+ effects.consume(code);
13177
+ effects.exit("lineEnding");
13178
+ return between;
13179
+ }
13180
+ effects.enter("mathTextData");
13181
+ return data(code);
13182
+ }
13183
+ /**
13184
+ * In data.
13185
+ *
13186
+ * ```markdown
13187
+ * > | $a$
13188
+ * ^
13189
+ * ```
13190
+ *
13191
+ * @type {State}
13192
+ */
13193
+ function data(code) {
13194
+ if (code === null || code === 32 || code === 36 || markdownLineEnding(code)) {
13195
+ effects.exit("mathTextData");
13196
+ return between(code);
13197
+ }
13198
+ effects.consume(code);
13199
+ return data;
13200
+ }
13201
+ /**
13202
+ * In closing sequence.
13203
+ *
13204
+ * ```markdown
13205
+ * > | `a`
13206
+ * ^
13207
+ * ```
13208
+ *
13209
+ * @type {State}
13210
+ */
13211
+ function sequenceClose(code) {
13212
+ if (code === 36) {
13213
+ effects.consume(code);
13214
+ size++;
13215
+ return sequenceClose;
13216
+ }
13217
+ if (size === sizeOpen) {
13218
+ effects.exit("mathTextSequence");
13219
+ effects.exit("mathText");
13220
+ return ok(code);
13221
+ }
13222
+ token.type = "mathTextData";
13223
+ return data(code);
13224
+ }
13225
+ }
13226
+ }
13227
+ /** @type {Resolver} */
13228
+ function resolveMathText(events) {
13229
+ let tailExitIndex = events.length - 4;
13230
+ let headEnterIndex = 3;
13231
+ /** @type {number} */
13232
+ let index;
13233
+ /** @type {number | undefined} */
13234
+ let enter;
13235
+ if ((events[headEnterIndex][1].type === "lineEnding" || events[headEnterIndex][1].type === "space") && (events[tailExitIndex][1].type === "lineEnding" || events[tailExitIndex][1].type === "space")) {
13236
+ index = headEnterIndex;
13237
+ while (++index < tailExitIndex) if (events[index][1].type === "mathTextData") {
13238
+ events[tailExitIndex][1].type = "mathTextPadding";
13239
+ events[headEnterIndex][1].type = "mathTextPadding";
13240
+ headEnterIndex += 2;
13241
+ tailExitIndex -= 2;
13242
+ break;
13243
+ }
13244
+ }
13245
+ index = headEnterIndex - 1;
13246
+ tailExitIndex++;
13247
+ while (++index <= tailExitIndex) if (enter === void 0) {
13248
+ if (index !== tailExitIndex && events[index][1].type !== "lineEnding") enter = index;
13249
+ } else if (index === tailExitIndex || events[index][1].type === "lineEnding") {
13250
+ events[enter][1].type = "mathTextData";
13251
+ if (index !== enter + 2) {
13252
+ events[enter][1].end = events[index - 1][1].end;
13253
+ events.splice(enter + 2, index - enter - 2);
13254
+ tailExitIndex -= index - enter - 2;
13255
+ index = enter + 2;
13256
+ }
13257
+ enter = void 0;
13258
+ }
13259
+ return events;
13260
+ }
13261
+ /**
13262
+ * @this {TokenizeContext}
13263
+ * @type {Previous}
13264
+ */
13265
+ function previous(code) {
13266
+ return code !== 36 || this.events[this.events.length - 1][1].type === "characterEscape";
13267
+ }
13268
+ // node_modules/.pnpm/micromark-extension-math@3.1.0/node_modules/micromark-extension-math/lib/syntax.js
13269
+ /**
13270
+ * @import {Options} from 'micromark-extension-math'
13271
+ * @import {Extension} from 'micromark-util-types'
13272
+ */
13273
+ /**
13274
+ * Create an extension for `micromark` to enable math syntax.
13275
+ *
13276
+ * @param {Options | null | undefined} [options={}]
13277
+ * Configuration (default: `{}`).
13278
+ * @returns {Extension}
13279
+ * Extension for `micromark` that can be passed in `extensions`, to
13280
+ * enable math syntax.
13281
+ */
13282
+ function math(options) {
13283
+ return {
13284
+ flow: { [36]: mathFlow },
13285
+ text: { [36]: mathText(options) }
13286
+ };
13287
+ }
13288
+ // node_modules/.pnpm/mdast-util-math@3.0.0/node_modules/mdast-util-math/lib/index.js
13289
+ /**
13290
+ * @typedef {import('hast').Element} HastElement
13291
+ * @typedef {import('hast').ElementContent} HastElementContent
13292
+ * @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext
13293
+ * @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension
13294
+ * @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle
13295
+ * @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle
13296
+ * @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
13297
+ * @typedef {import('../index.js').InlineMath} InlineMath
13298
+ * @typedef {import('../index.js').Math} Math
13299
+ *
13300
+ * @typedef ToOptions
13301
+ * Configuration.
13302
+ * @property {boolean | null | undefined} [singleDollarTextMath=true]
13303
+ * Whether to support math (text) with a single dollar (default: `true`).
13304
+ *
13305
+ * Single dollars work in Pandoc and many other places, but often interfere
13306
+ * with “normal” dollars in text.
13307
+ * If you turn this off, you can still use two or more dollars for text math.
13308
+ */
13309
+ /**
13310
+ * Create an extension for `mdast-util-from-markdown`.
13311
+ *
13312
+ * @returns {FromMarkdownExtension}
13313
+ * Extension for `mdast-util-from-markdown`.
13314
+ */
13315
+ function mathFromMarkdown() {
13316
+ return {
13317
+ enter: {
13318
+ mathFlow: enterMathFlow,
13319
+ mathFlowFenceMeta: enterMathFlowMeta,
13320
+ mathText: enterMathText
13321
+ },
13322
+ exit: {
13323
+ mathFlow: exitMathFlow,
13324
+ mathFlowFence: exitMathFlowFence,
13325
+ mathFlowFenceMeta: exitMathFlowMeta,
13326
+ mathFlowValue: exitMathData,
13327
+ mathText: exitMathText,
13328
+ mathTextData: exitMathData
13329
+ }
13330
+ };
13331
+ /**
13332
+ * @this {CompileContext}
13333
+ * @type {FromMarkdownHandle}
13334
+ */
13335
+ function enterMathFlow(token) {
13336
+ this.enter({
13337
+ type: "math",
13338
+ meta: null,
13339
+ value: "",
13340
+ data: {
13341
+ hName: "pre",
13342
+ hChildren: [{
13343
+ type: "element",
13344
+ tagName: "code",
13345
+ properties: { className: ["language-math", "math-display"] },
13346
+ children: []
13347
+ }]
13348
+ }
13349
+ }, token);
13350
+ }
13351
+ /**
13352
+ * @this {CompileContext}
13353
+ * @type {FromMarkdownHandle}
13354
+ */
13355
+ function enterMathFlowMeta() {
13356
+ this.buffer();
13357
+ }
13358
+ /**
13359
+ * @this {CompileContext}
13360
+ * @type {FromMarkdownHandle}
13361
+ */
13362
+ function exitMathFlowMeta() {
13363
+ const data = this.resume();
13364
+ const node = this.stack[this.stack.length - 1];
13365
+ node.type;
13366
+ node.meta = data;
13367
+ }
13368
+ /**
13369
+ * @this {CompileContext}
13370
+ * @type {FromMarkdownHandle}
13371
+ */
13372
+ function exitMathFlowFence() {
13373
+ if (this.data.mathFlowInside) return;
13374
+ this.buffer();
13375
+ this.data.mathFlowInside = true;
13376
+ }
13377
+ /**
13378
+ * @this {CompileContext}
13379
+ * @type {FromMarkdownHandle}
13380
+ */
13381
+ function exitMathFlow(token) {
13382
+ const data = this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, "");
13383
+ const node = this.stack[this.stack.length - 1];
13384
+ node.type;
13385
+ this.exit(token);
13386
+ node.value = data;
13387
+ const code = node.data.hChildren[0];
13388
+ code.type;
13389
+ code.tagName;
13390
+ code.children.push({
13391
+ type: "text",
13392
+ value: data
13393
+ });
13394
+ this.data.mathFlowInside = void 0;
13395
+ }
13396
+ /**
13397
+ * @this {CompileContext}
13398
+ * @type {FromMarkdownHandle}
13399
+ */
13400
+ function enterMathText(token) {
13401
+ this.enter({
13402
+ type: "inlineMath",
13403
+ value: "",
13404
+ data: {
13405
+ hName: "code",
13406
+ hProperties: { className: ["language-math", "math-inline"] },
13407
+ hChildren: []
13408
+ }
13409
+ }, token);
13410
+ this.buffer();
13411
+ }
13412
+ /**
13413
+ * @this {CompileContext}
13414
+ * @type {FromMarkdownHandle}
13415
+ */
13416
+ function exitMathText(token) {
13417
+ const data = this.resume();
13418
+ const node = this.stack[this.stack.length - 1];
13419
+ node.type;
13420
+ this.exit(token);
13421
+ node.value = data;
13422
+ node.data.hChildren.push({
13423
+ type: "text",
13424
+ value: data
13425
+ });
13426
+ }
13427
+ /**
13428
+ * @this {CompileContext}
13429
+ * @type {FromMarkdownHandle}
13430
+ */
13431
+ function exitMathData(token) {
13432
+ this.config.enter.data.call(this, token);
13433
+ this.config.exit.data.call(this, token);
13434
+ }
13435
+ }
13436
+ // scripts/markdown-highlight.js
13437
+ var EQUALS = 61;
13438
+ /** Exactly two equals signs open and close a highlight, with the flanking rules of `~~`. */
13439
+ function highlight() {
13440
+ const tokenizer = {
13441
+ name: "highlight",
13442
+ tokenize,
13443
+ resolveAll: resolve
13444
+ };
13445
+ return {
13446
+ text: { [EQUALS]: tokenizer },
13447
+ insideSpan: { null: [tokenizer] },
13448
+ attentionMarkers: { null: [EQUALS] }
13449
+ };
13450
+ function resolve(events, context) {
13451
+ let index = -1;
13452
+ while (++index < events.length) {
13453
+ if (events[index][0] !== "enter" || events[index][1].type !== "highlightSequenceTemporary" || !events[index][1]._close) continue;
13454
+ let open = index;
13455
+ while (open--) {
13456
+ if (events[open][0] !== "exit" || events[open][1].type !== "highlightSequenceTemporary" || !events[open][1]._open) continue;
13457
+ events[index][1].type = "highlightSequence";
13458
+ events[open][1].type = "highlightSequence";
13459
+ const marked = {
13460
+ type: "highlight",
13461
+ start: Object.assign({}, events[open][1].start),
13462
+ end: Object.assign({}, events[index][1].end)
13463
+ };
13464
+ const text = {
13465
+ type: "highlightText",
13466
+ start: Object.assign({}, events[open][1].end),
13467
+ end: Object.assign({}, events[index][1].start)
13468
+ };
13469
+ const next = [
13470
+ [
13471
+ "enter",
13472
+ marked,
13473
+ context
13474
+ ],
13475
+ [
13476
+ "enter",
13477
+ events[open][1],
13478
+ context
13479
+ ],
13480
+ [
13481
+ "exit",
13482
+ events[open][1],
13483
+ context
13484
+ ],
13485
+ [
13486
+ "enter",
13487
+ text,
13488
+ context
13489
+ ]
13490
+ ];
13491
+ const insideSpan = context.parser.constructs.insideSpan.null;
13492
+ if (insideSpan) splice(next, next.length, 0, resolveAll(insideSpan, events.slice(open + 1, index), context));
13493
+ splice(next, next.length, 0, [
13494
+ [
13495
+ "exit",
13496
+ text,
13497
+ context
13498
+ ],
13499
+ [
13500
+ "enter",
13501
+ events[index][1],
13502
+ context
13503
+ ],
13504
+ [
13505
+ "exit",
13506
+ events[index][1],
13507
+ context
13508
+ ],
13509
+ [
13510
+ "exit",
13511
+ marked,
13512
+ context
13513
+ ]
13514
+ ]);
13515
+ splice(events, open - 1, index - open + 3, next);
13516
+ index = open + next.length - 2;
13517
+ break;
13518
+ }
13519
+ }
13520
+ index = -1;
13521
+ while (++index < events.length) if (events[index][1].type === "highlightSequenceTemporary") events[index][1].type = "data";
13522
+ return events;
13523
+ }
13524
+ function tokenize(effects, ok, nok) {
13525
+ const previous = this.previous;
13526
+ const events = this.events;
13527
+ let size = 0;
13528
+ return start;
13529
+ function start(code) {
13530
+ if (previous === EQUALS && events[events.length - 1][1].type !== "characterEscape") return nok(code);
13531
+ effects.enter("highlightSequenceTemporary");
13532
+ return more(code);
13533
+ }
13534
+ function more(code) {
13535
+ const before = classifyCharacter(previous);
13536
+ if (code === EQUALS) {
13537
+ if (size > 1) return nok(code);
13538
+ effects.consume(code);
13539
+ size++;
13540
+ return more;
13541
+ }
13542
+ if (size < 2) return nok(code);
13543
+ const token = effects.exit("highlightSequenceTemporary");
13544
+ const after = classifyCharacter(code);
13545
+ token._open = !after || after === 2 && Boolean(before);
13546
+ token._close = !before || before === 2 && Boolean(after);
13547
+ return ok(code);
13548
+ }
13549
+ }
13550
+ }
13551
+ /** `highlight` nodes with phrasing children. */
13552
+ function highlightFromMarkdown() {
13553
+ return {
13554
+ canContainEols: ["highlight"],
13555
+ enter: { highlight(token) {
13556
+ this.enter({
13557
+ type: "highlight",
13558
+ children: []
13559
+ }, token);
13560
+ } },
13561
+ exit: { highlight(token) {
13562
+ this.exit(token);
13563
+ } }
13564
+ };
13565
+ }
13566
+ // scripts/markdown-tree-entry.js
13567
+ /**
13568
+ * CommonMark plus ~~strikethrough~~ and, with `article`, tables, footnotes, task lists, math
13569
+ * and ==highlights==, as an mdast tree with source positions.
13570
+ */
13571
+ function markdownTree(text, options) {
13572
+ const article = !!options?.article;
11027
13573
  return fromMarkdown(text, {
11028
- extensions: [gfmStrikethrough({ singleTilde: false })],
11029
- mdastExtensions: [gfmStrikethroughFromMarkdown()]
13574
+ extensions: [gfmStrikethrough({ singleTilde: false }), ...article ? [
13575
+ gfmTable(),
13576
+ gfmFootnote(),
13577
+ gfmTaskListItem(),
13578
+ math(),
13579
+ highlight()
13580
+ ] : []],
13581
+ mdastExtensions: [gfmStrikethroughFromMarkdown(), ...article ? [
13582
+ gfmTableFromMarkdown(),
13583
+ gfmFootnoteFromMarkdown(),
13584
+ gfmTaskListItemFromMarkdown(),
13585
+ mathFromMarkdown(),
13586
+ highlightFromMarkdown()
13587
+ ] : []]
11030
13588
  });
11031
13589
  }
11032
13590
  export { markdownTree };