@readme/markdown 15.9.4 → 15.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.node.js CHANGED
@@ -19111,7 +19111,7 @@ module.exports = function () {
19111
19111
 
19112
19112
  /***/ },
19113
19113
 
19114
- /***/ 3975
19114
+ /***/ 5893
19115
19115
  (module, __webpack_exports__, __webpack_require__) {
19116
19116
 
19117
19117
  "use strict";
@@ -19136,6 +19136,7 @@ __webpack_require__.d(__webpack_exports__, {
19136
19136
  mdx: () => (/* reexport */ lib_mdx),
19137
19137
  mdxish: () => (/* reexport */ lib_mdxish),
19138
19138
  mdxishAstProcessor: () => (/* reexport */ mdxishAstProcessor),
19139
+ mdxishHeadingIds: () => (/* reexport */ mdxishHeadingIds),
19139
19140
  mdxishMdastToMd: () => (/* reexport */ mdxishMdastToMd),
19140
19141
  mdxishTags: () => (/* reexport */ mdxishTags),
19141
19142
  migrate: () => (/* reexport */ lib_migrate),
@@ -19467,8 +19468,11 @@ const Card = ({ badge, children, href, kind = 'card', icon, iconColor, LinkCompo
19467
19468
  href && external_react_default().createElement("i", { "aria-hidden": "true", className: "Card-arrow fa-regular fa-arrow-right" }))),
19468
19469
  children)));
19469
19470
  };
19471
+ // max() can't take keyword widths like auto or min-content, so only wrap a length or a math expression
19472
+ const canWrapColumns = (columns, cardWidth) => Number(columns) > 0 && /^(\.?\d|(calc|min|max|clamp)\()/.test(cardWidth);
19470
19473
  const CardsGrid = ({ cardWidth = '200px', columns = 'auto-fit', children }) => {
19471
- return (external_react_default().createElement("div", { className: "CardsGrid", style: { '--CardsGrid-cardWidth': cardWidth, '--CardsGrid-columns': columns } }, children));
19474
+ const className = canWrapColumns(columns, cardWidth) ? 'CardsGrid CardsGrid_wrap' : 'CardsGrid';
19475
+ return (external_react_default().createElement("div", { className: className, style: { '--CardsGrid-cardWidth': cardWidth, '--CardsGrid-columns': columns } }, children));
19472
19476
  };
19473
19477
  /* harmony default export */ const Cards = (CardsGrid);
19474
19478
 
@@ -75084,6 +75088,209 @@ const mdast = (text, opts = {}) => {
75084
75088
  };
75085
75089
  /* harmony default export */ const lib_mdast = (mdast);
75086
75090
 
75091
+ ;// ./node_modules/micromark-util-symbol/lib/codes.js
75092
+ /**
75093
+ * Character codes.
75094
+ *
75095
+ * This module is compiled away!
75096
+ *
75097
+ * micromark works based on character codes.
75098
+ * This module contains constants for the ASCII block and the replacement
75099
+ * character.
75100
+ * A couple of them are handled in a special way, such as the line endings
75101
+ * (CR, LF, and CR+LF, commonly known as end-of-line: EOLs), the tab (horizontal
75102
+ * tab) and its expansion based on what column it’s at (virtual space),
75103
+ * and the end-of-file (eof) character.
75104
+ * As values are preprocessed before handling them, the actual characters LF,
75105
+ * CR, HT, and NUL (which is present as the replacement character), are
75106
+ * guaranteed to not exist.
75107
+ *
75108
+ * Unicode basic latin block.
75109
+ */
75110
+ const codes = /** @type {const} */ ({
75111
+ carriageReturn: -5,
75112
+ lineFeed: -4,
75113
+ carriageReturnLineFeed: -3,
75114
+ horizontalTab: -2,
75115
+ virtualSpace: -1,
75116
+ eof: null,
75117
+ nul: 0,
75118
+ soh: 1,
75119
+ stx: 2,
75120
+ etx: 3,
75121
+ eot: 4,
75122
+ enq: 5,
75123
+ ack: 6,
75124
+ bel: 7,
75125
+ bs: 8,
75126
+ ht: 9, // `\t`
75127
+ lf: 10, // `\n`
75128
+ vt: 11, // `\v`
75129
+ ff: 12, // `\f`
75130
+ cr: 13, // `\r`
75131
+ so: 14,
75132
+ si: 15,
75133
+ dle: 16,
75134
+ dc1: 17,
75135
+ dc2: 18,
75136
+ dc3: 19,
75137
+ dc4: 20,
75138
+ nak: 21,
75139
+ syn: 22,
75140
+ etb: 23,
75141
+ can: 24,
75142
+ em: 25,
75143
+ sub: 26,
75144
+ esc: 27,
75145
+ fs: 28,
75146
+ gs: 29,
75147
+ rs: 30,
75148
+ us: 31,
75149
+ space: 32,
75150
+ exclamationMark: 33, // `!`
75151
+ quotationMark: 34, // `"`
75152
+ numberSign: 35, // `#`
75153
+ dollarSign: 36, // `$`
75154
+ percentSign: 37, // `%`
75155
+ ampersand: 38, // `&`
75156
+ apostrophe: 39, // `'`
75157
+ leftParenthesis: 40, // `(`
75158
+ rightParenthesis: 41, // `)`
75159
+ asterisk: 42, // `*`
75160
+ plusSign: 43, // `+`
75161
+ comma: 44, // `,`
75162
+ dash: 45, // `-`
75163
+ dot: 46, // `.`
75164
+ slash: 47, // `/`
75165
+ digit0: 48, // `0`
75166
+ digit1: 49, // `1`
75167
+ digit2: 50, // `2`
75168
+ digit3: 51, // `3`
75169
+ digit4: 52, // `4`
75170
+ digit5: 53, // `5`
75171
+ digit6: 54, // `6`
75172
+ digit7: 55, // `7`
75173
+ digit8: 56, // `8`
75174
+ digit9: 57, // `9`
75175
+ colon: 58, // `:`
75176
+ semicolon: 59, // `;`
75177
+ lessThan: 60, // `<`
75178
+ equalsTo: 61, // `=`
75179
+ greaterThan: 62, // `>`
75180
+ questionMark: 63, // `?`
75181
+ atSign: 64, // `@`
75182
+ uppercaseA: 65, // `A`
75183
+ uppercaseB: 66, // `B`
75184
+ uppercaseC: 67, // `C`
75185
+ uppercaseD: 68, // `D`
75186
+ uppercaseE: 69, // `E`
75187
+ uppercaseF: 70, // `F`
75188
+ uppercaseG: 71, // `G`
75189
+ uppercaseH: 72, // `H`
75190
+ uppercaseI: 73, // `I`
75191
+ uppercaseJ: 74, // `J`
75192
+ uppercaseK: 75, // `K`
75193
+ uppercaseL: 76, // `L`
75194
+ uppercaseM: 77, // `M`
75195
+ uppercaseN: 78, // `N`
75196
+ uppercaseO: 79, // `O`
75197
+ uppercaseP: 80, // `P`
75198
+ uppercaseQ: 81, // `Q`
75199
+ uppercaseR: 82, // `R`
75200
+ uppercaseS: 83, // `S`
75201
+ uppercaseT: 84, // `T`
75202
+ uppercaseU: 85, // `U`
75203
+ uppercaseV: 86, // `V`
75204
+ uppercaseW: 87, // `W`
75205
+ uppercaseX: 88, // `X`
75206
+ uppercaseY: 89, // `Y`
75207
+ uppercaseZ: 90, // `Z`
75208
+ leftSquareBracket: 91, // `[`
75209
+ backslash: 92, // `\`
75210
+ rightSquareBracket: 93, // `]`
75211
+ caret: 94, // `^`
75212
+ underscore: 95, // `_`
75213
+ graveAccent: 96, // `` ` ``
75214
+ lowercaseA: 97, // `a`
75215
+ lowercaseB: 98, // `b`
75216
+ lowercaseC: 99, // `c`
75217
+ lowercaseD: 100, // `d`
75218
+ lowercaseE: 101, // `e`
75219
+ lowercaseF: 102, // `f`
75220
+ lowercaseG: 103, // `g`
75221
+ lowercaseH: 104, // `h`
75222
+ lowercaseI: 105, // `i`
75223
+ lowercaseJ: 106, // `j`
75224
+ lowercaseK: 107, // `k`
75225
+ lowercaseL: 108, // `l`
75226
+ lowercaseM: 109, // `m`
75227
+ lowercaseN: 110, // `n`
75228
+ lowercaseO: 111, // `o`
75229
+ lowercaseP: 112, // `p`
75230
+ lowercaseQ: 113, // `q`
75231
+ lowercaseR: 114, // `r`
75232
+ lowercaseS: 115, // `s`
75233
+ lowercaseT: 116, // `t`
75234
+ lowercaseU: 117, // `u`
75235
+ lowercaseV: 118, // `v`
75236
+ lowercaseW: 119, // `w`
75237
+ lowercaseX: 120, // `x`
75238
+ lowercaseY: 121, // `y`
75239
+ lowercaseZ: 122, // `z`
75240
+ leftCurlyBrace: 123, // `{`
75241
+ verticalBar: 124, // `|`
75242
+ rightCurlyBrace: 125, // `}`
75243
+ tilde: 126, // `~`
75244
+ del: 127,
75245
+ // Unicode Specials block.
75246
+ byteOrderMarker: 65_279,
75247
+ // Unicode Specials block.
75248
+ replacementCharacter: 65_533 // `�`
75249
+ })
75250
+
75251
+ ;// ./lib/micromark/heading-id/syntax.ts
75252
+
75253
+
75254
+ /** One character a `{#id}` heading id may use: the ones github-slugger keeps, plus `.` and `:`. */
75255
+ const HEADING_ID_CHAR = '[\\p{L}\\p{M}\\p{N}_.:-]';
75256
+ const ID_CLOSE_REGEX = new RegExp(`^${HEADING_ID_CHAR}+\\}$`, 'u');
75257
+ const typeAt = (events, index) => events[index]?.[1].type;
75258
+ function isIdToken(events, index, context, type, value) {
75259
+ return typeAt(events, index) === type && value.test(context.sliceSerialize(events[index][1]));
75260
+ }
75261
+ /** The exit index of the heading's last content token, past any trailing space and closing `##`. */
75262
+ function contentEnd(events) {
75263
+ let end = events.length - 2;
75264
+ if (typeAt(events, end) === 'whitespace')
75265
+ end -= 2;
75266
+ if (typeAt(events, end) === 'atxHeadingSequence' && typeAt(events, end - 2) === 'whitespace')
75267
+ end -= 4;
75268
+ return end;
75269
+ }
75270
+ const resolveHeadingId = (events, context) => {
75271
+ // Each token is an enter and an exit event; these indexes point at the exits.
75272
+ const close = contentEnd(events);
75273
+ const hash = close - 2;
75274
+ const open = close - 4;
75275
+ const space = close - 6;
75276
+ const endsWithId = isIdToken(events, close, context, 'atxHeadingText', ID_CLOSE_REGEX) &&
75277
+ isIdToken(events, hash, context, 'atxHeadingSequence', /^#$/) &&
75278
+ isIdToken(events, open, context, 'atxHeadingText', /^\{$/) &&
75279
+ typeAt(events, space) === 'whitespace';
75280
+ if (!endsWithId)
75281
+ return headingAtx.resolve?.(events, context) ?? events;
75282
+ const id = { type: 'headingId', start: events[open][1].start, end: events[close][1].end };
75283
+ events.splice(space - 1, close - space + 2);
75284
+ const resolved = headingAtx.resolve?.(events, context) ?? events;
75285
+ resolved.splice(resolved.length - 1, 0, ['enter', id, context], ['exit', id, context]);
75286
+ return resolved;
75287
+ };
75288
+ const headingIdConstruct = { ...headingAtx, resolve: resolveHeadingId };
75289
+ /** The ATX heading construct, with a line-final ` {#id}` split off as a `headingId` token. */
75290
+ function headingId() {
75291
+ return { flow: { [codes.numberSign]: headingIdConstruct } };
75292
+ }
75293
+
75087
75294
  ;// ./lib/utils/jsx-acorn-parser.ts
75088
75295
 
75089
75296
 
@@ -75195,6 +75402,7 @@ const evaluateLiteralExpression = (source) => {
75195
75402
 
75196
75403
 
75197
75404
 
75405
+
75198
75406
  /**
75199
75407
  * Evaluate a JavaScript expression source and return its value.
75200
75408
  *
@@ -75311,6 +75519,24 @@ const getHPropKeys = (node) => {
75311
75519
  const hProps = getHProps(node);
75312
75520
  return Object.keys(hProps) || [];
75313
75521
  };
75522
+ /** Turn a non-renderable evaluation result into a text node. */
75523
+ const createTextNode = (result, position) => {
75524
+ if (result === null || result === undefined)
75525
+ return { type: 'text', value: '', position };
75526
+ if (typeof result === 'object')
75527
+ return { type: 'text', value: JSON.stringify(result), position };
75528
+ return { type: 'text', value: String(result), position };
75529
+ };
75530
+ const HEADING_ID_REGEX = new RegExp(`^${HEADING_ID_CHAR}+$`, 'u');
75531
+ /**
75532
+ * The id a heading's trailing `{#id}` set, when it is one the `{#id}` syntax can spell.
75533
+ *
75534
+ * Ids may use letters, numbers, `-`, `_`, `.` and `:`; anything else, like `x y`, is dropped.
75535
+ */
75536
+ const explicitHeadingId = (node) => {
75537
+ const id = node.data?.hProperties?.id;
75538
+ return typeof id === 'string' && HEADING_ID_REGEX.test(id) ? id : undefined;
75539
+ };
75314
75540
  /**
75315
75541
  * Gets the attributes of an MDX element and returns them as an object of hProperties.
75316
75542
  *
@@ -93446,6 +93672,17 @@ function gemojiFromMarkdown() {
93446
93672
  };
93447
93673
  }
93448
93674
 
93675
+ ;// ./lib/mdast-util/heading-id/index.ts
93676
+ function exitHeadingId(token) {
93677
+ const heading = this.stack[this.stack.length - 1];
93678
+ const id = this.sliceSerialize(token).slice('{#'.length, -'}'.length);
93679
+ heading.data = { ...heading.data, hProperties: { ...heading.data?.hProperties, id } };
93680
+ }
93681
+ /** Sets a heading's id from its `headingId` token. */
93682
+ function headingIdFromMarkdown() {
93683
+ return { exit: { headingId: exitHeadingId } };
93684
+ }
93685
+
93449
93686
  ;// ./lib/mdast-util/html-block-component/index.ts
93450
93687
  const contextMap = new WeakMap();
93451
93688
  function findHtmlBlockComponentToken() {
@@ -93824,166 +94061,6 @@ function mdxComponentFromMarkdown() {
93824
94061
  };
93825
94062
  }
93826
94063
 
93827
- ;// ./node_modules/micromark-util-symbol/lib/codes.js
93828
- /**
93829
- * Character codes.
93830
- *
93831
- * This module is compiled away!
93832
- *
93833
- * micromark works based on character codes.
93834
- * This module contains constants for the ASCII block and the replacement
93835
- * character.
93836
- * A couple of them are handled in a special way, such as the line endings
93837
- * (CR, LF, and CR+LF, commonly known as end-of-line: EOLs), the tab (horizontal
93838
- * tab) and its expansion based on what column it’s at (virtual space),
93839
- * and the end-of-file (eof) character.
93840
- * As values are preprocessed before handling them, the actual characters LF,
93841
- * CR, HT, and NUL (which is present as the replacement character), are
93842
- * guaranteed to not exist.
93843
- *
93844
- * Unicode basic latin block.
93845
- */
93846
- const codes = /** @type {const} */ ({
93847
- carriageReturn: -5,
93848
- lineFeed: -4,
93849
- carriageReturnLineFeed: -3,
93850
- horizontalTab: -2,
93851
- virtualSpace: -1,
93852
- eof: null,
93853
- nul: 0,
93854
- soh: 1,
93855
- stx: 2,
93856
- etx: 3,
93857
- eot: 4,
93858
- enq: 5,
93859
- ack: 6,
93860
- bel: 7,
93861
- bs: 8,
93862
- ht: 9, // `\t`
93863
- lf: 10, // `\n`
93864
- vt: 11, // `\v`
93865
- ff: 12, // `\f`
93866
- cr: 13, // `\r`
93867
- so: 14,
93868
- si: 15,
93869
- dle: 16,
93870
- dc1: 17,
93871
- dc2: 18,
93872
- dc3: 19,
93873
- dc4: 20,
93874
- nak: 21,
93875
- syn: 22,
93876
- etb: 23,
93877
- can: 24,
93878
- em: 25,
93879
- sub: 26,
93880
- esc: 27,
93881
- fs: 28,
93882
- gs: 29,
93883
- rs: 30,
93884
- us: 31,
93885
- space: 32,
93886
- exclamationMark: 33, // `!`
93887
- quotationMark: 34, // `"`
93888
- numberSign: 35, // `#`
93889
- dollarSign: 36, // `$`
93890
- percentSign: 37, // `%`
93891
- ampersand: 38, // `&`
93892
- apostrophe: 39, // `'`
93893
- leftParenthesis: 40, // `(`
93894
- rightParenthesis: 41, // `)`
93895
- asterisk: 42, // `*`
93896
- plusSign: 43, // `+`
93897
- comma: 44, // `,`
93898
- dash: 45, // `-`
93899
- dot: 46, // `.`
93900
- slash: 47, // `/`
93901
- digit0: 48, // `0`
93902
- digit1: 49, // `1`
93903
- digit2: 50, // `2`
93904
- digit3: 51, // `3`
93905
- digit4: 52, // `4`
93906
- digit5: 53, // `5`
93907
- digit6: 54, // `6`
93908
- digit7: 55, // `7`
93909
- digit8: 56, // `8`
93910
- digit9: 57, // `9`
93911
- colon: 58, // `:`
93912
- semicolon: 59, // `;`
93913
- lessThan: 60, // `<`
93914
- equalsTo: 61, // `=`
93915
- greaterThan: 62, // `>`
93916
- questionMark: 63, // `?`
93917
- atSign: 64, // `@`
93918
- uppercaseA: 65, // `A`
93919
- uppercaseB: 66, // `B`
93920
- uppercaseC: 67, // `C`
93921
- uppercaseD: 68, // `D`
93922
- uppercaseE: 69, // `E`
93923
- uppercaseF: 70, // `F`
93924
- uppercaseG: 71, // `G`
93925
- uppercaseH: 72, // `H`
93926
- uppercaseI: 73, // `I`
93927
- uppercaseJ: 74, // `J`
93928
- uppercaseK: 75, // `K`
93929
- uppercaseL: 76, // `L`
93930
- uppercaseM: 77, // `M`
93931
- uppercaseN: 78, // `N`
93932
- uppercaseO: 79, // `O`
93933
- uppercaseP: 80, // `P`
93934
- uppercaseQ: 81, // `Q`
93935
- uppercaseR: 82, // `R`
93936
- uppercaseS: 83, // `S`
93937
- uppercaseT: 84, // `T`
93938
- uppercaseU: 85, // `U`
93939
- uppercaseV: 86, // `V`
93940
- uppercaseW: 87, // `W`
93941
- uppercaseX: 88, // `X`
93942
- uppercaseY: 89, // `Y`
93943
- uppercaseZ: 90, // `Z`
93944
- leftSquareBracket: 91, // `[`
93945
- backslash: 92, // `\`
93946
- rightSquareBracket: 93, // `]`
93947
- caret: 94, // `^`
93948
- underscore: 95, // `_`
93949
- graveAccent: 96, // `` ` ``
93950
- lowercaseA: 97, // `a`
93951
- lowercaseB: 98, // `b`
93952
- lowercaseC: 99, // `c`
93953
- lowercaseD: 100, // `d`
93954
- lowercaseE: 101, // `e`
93955
- lowercaseF: 102, // `f`
93956
- lowercaseG: 103, // `g`
93957
- lowercaseH: 104, // `h`
93958
- lowercaseI: 105, // `i`
93959
- lowercaseJ: 106, // `j`
93960
- lowercaseK: 107, // `k`
93961
- lowercaseL: 108, // `l`
93962
- lowercaseM: 109, // `m`
93963
- lowercaseN: 110, // `n`
93964
- lowercaseO: 111, // `o`
93965
- lowercaseP: 112, // `p`
93966
- lowercaseQ: 113, // `q`
93967
- lowercaseR: 114, // `r`
93968
- lowercaseS: 115, // `s`
93969
- lowercaseT: 116, // `t`
93970
- lowercaseU: 117, // `u`
93971
- lowercaseV: 118, // `v`
93972
- lowercaseW: 119, // `w`
93973
- lowercaseX: 120, // `x`
93974
- lowercaseY: 121, // `y`
93975
- lowercaseZ: 122, // `z`
93976
- leftCurlyBrace: 123, // `{`
93977
- verticalBar: 124, // `|`
93978
- rightCurlyBrace: 125, // `}`
93979
- tilde: 126, // `~`
93980
- del: 127,
93981
- // Unicode Specials block.
93982
- byteOrderMarker: 65_279,
93983
- // Unicode Specials block.
93984
- replacementCharacter: 65_533 // `�`
93985
- })
93986
-
93987
94064
  ;// ./lib/micromark/gemoji/syntax.ts
93988
94065
 
93989
94066
  // Matches the name pattern from the original regex: \+1 or [-\w]+
@@ -94071,6 +94148,9 @@ function syntax_gemoji() {
94071
94148
  };
94072
94149
  }
94073
94150
 
94151
+ ;// ./lib/micromark/heading-id/index.ts
94152
+
94153
+
94074
94154
  ;// ./node_modules/micromark-util-symbol/lib/types.js
94075
94155
  /**
94076
94156
  * This module is compiled away!
@@ -97520,6 +97600,8 @@ function mdxExpressionLenient() {
97520
97600
 
97521
97601
 
97522
97602
 
97603
+
97604
+
97523
97605
 
97524
97606
 
97525
97607
 
@@ -97559,6 +97641,8 @@ const REGISTRY = {
97559
97641
  mdxComponent: { syntax: mdxComponent, fromMarkdown: mdxComponentFromMarkdown },
97560
97642
  gemoji: { syntax: syntax_gemoji, fromMarkdown: gemojiFromMarkdown },
97561
97643
  legacyVariable: { syntax: legacyVariable, fromMarkdown: legacyVariableFromMarkdown },
97644
+ // Replaces the ATX heading construct in `flow`, so it never touches prose outside a heading.
97645
+ headingId: { syntax: headingId, fromMarkdown: headingIdFromMarkdown },
97562
97646
  looseHtmlEntity: { syntax: looseHtmlEntity, fromMarkdown: looseHtmlEntityFromMarkdown },
97563
97647
  htmlBlockComponent: { syntax: htmlBlockComponent, fromMarkdown: htmlBlockComponentFromMarkdown },
97564
97648
  // This is for in-document variable & function definitions
@@ -97589,18 +97673,13 @@ const EXPRESSIONS = ['jsxComment', 'mdxExpressionLenient', 'mdxjsEsm'];
97589
97673
  */
97590
97674
  const FEATURES = {
97591
97675
  /** `lib/mdxish.ts` — the document parser; the only site taking every group */
97592
- document: [...BLOCK_CLAIMS, ...INLINE, ...EXPRESSIONS, 'emptyTaskListItem'],
97676
+ document: [...BLOCK_CLAIMS, ...INLINE, ...EXPRESSIONS, 'emptyTaskListItem', 'headingId'],
97593
97677
  /**
97594
97678
  * `components/utils.ts` — re-parses a component body, which should tokenize
97595
97679
  * like the document around it: when the two drifted a `<Table>` in a
97596
97680
  * `<Callout>` lost every row (CX-3705).
97597
97681
  */
97598
- componentBody: [
97599
- ...BLOCK_CLAIMS,
97600
- ...INLINE,
97601
- 'mdxExpression',
97602
- 'emptyTaskListItem',
97603
- ],
97682
+ componentBody: [...BLOCK_CLAIMS, ...INLINE, 'mdxExpression', 'emptyTaskListItem', 'headingId'],
97604
97683
  /**
97605
97684
  * `lib/mdxishTags.ts` — collects component names, so nothing inline is needed.
97606
97685
  * Omits `htmlBlockComponent` deliberately since it's not a custom component,
@@ -122224,6 +122303,18 @@ const embed_embed = (node) => {
122224
122303
  };
122225
122304
  /* harmony default export */ const compile_embed = (embed_embed);
122226
122305
 
122306
+ ;// ./processor/compile/heading.ts
122307
+
122308
+
122309
+ const SETEXT_UNDERLINE_REGEX = /\n(?:=+|-+)$/;
122310
+ /** Writes an explicit heading id back as ` {#id}`. A setext heading, written for a line break, can't carry one. */
122311
+ const compile_heading_heading = ((node, parent, state, info) => {
122312
+ const markdown = handle.heading(node, parent, state, info);
122313
+ const id = explicitHeadingId(node);
122314
+ return id && !SETEXT_UNDERLINE_REGEX.test(markdown) ? `${markdown} {#${id}}` : markdown;
122315
+ });
122316
+ /* harmony default export */ const compile_heading = (compile_heading_heading);
122317
+
122227
122318
  ;// ./processor/compile/html-block.ts
122228
122319
 
122229
122320
  const htmlBlock = (node) => {
@@ -122369,6 +122460,7 @@ const mdxishText = (node, parent, state, info) => compile_text_text(node, parent
122369
122460
 
122370
122461
 
122371
122462
 
122463
+
122372
122464
  function compilers(mdxish = false) {
122373
122465
  const data = this.data();
122374
122466
  const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
@@ -122389,6 +122481,7 @@ function compilers(mdxish = false) {
122389
122481
  text: compile_text_text,
122390
122482
  yaml: compile_compatibility,
122391
122483
  // needed only for mdxish
122484
+ ...(mdxish && { heading: compile_heading }),
122392
122485
  ...(mdxish && { list: compile_list }),
122393
122486
  ...(mdxish && { listItem: list_item }),
122394
122487
  ...(mdxish && { text: compile_text }),
@@ -124198,6 +124291,7 @@ const rehypeMdxishComponents = ({ components, processMarkdown }) => {
124198
124291
  ;// ./processor/plugin/mdxish-handlers.ts
124199
124292
 
124200
124293
 
124294
+
124201
124295
  // If hChildren is populated, it means the node holds a renderable value (e.g. React)
124202
124296
  // See evaluate-expressions.ts for more details
124203
124297
  // Otherwise, it's a simple value and we fall back to text
@@ -124263,8 +124357,30 @@ const embedHandler = (state, node) => {
124263
124357
  children: isMagicBlockEmbed ? [] : state.all(node),
124264
124358
  };
124265
124359
  };
124360
+ /**
124361
+ * Renders a list item whose marker sits alone on its line with that line kept empty.
124362
+ *
124363
+ * `-` over an indented block (a sublist, a code block) parses to the same mdast as the
124364
+ * block written on the marker's line, since CommonMark has no empty paragraph, so both
124365
+ * would render as `- - B`. Positions still tell the spellings apart. A `<br>` holds the
124366
+ * line open, which an empty `<p>` wouldn't.
124367
+ */
124368
+ const listItemHandler = (state, node, parent) => {
124369
+ const item = node;
124370
+ const result = handlers_handlers.listItem(state, item, parent);
124371
+ const first = item.children[0];
124372
+ if (!first || first.type === 'paragraph')
124373
+ return result;
124374
+ const itemLine = item.position?.start.line;
124375
+ const blockLine = first.position?.start.line;
124376
+ if (itemLine === undefined || blockLine === undefined || blockLine <= itemLine)
124377
+ return result;
124378
+ result.children.unshift({ type: 'element', tagName: 'br', properties: {}, children: [] });
124379
+ return result;
124380
+ };
124266
124381
  const mdxComponentHandlers = {
124267
124382
  embed: embedHandler,
124383
+ listItem: listItemHandler,
124268
124384
  mdxFlowExpression: mdxExpressionHandler,
124269
124385
  mdxJsxFlowElement: mdxJsxElementHandler,
124270
124386
  mdxJsxTextElement: mdxJsxElementHandler,
@@ -125938,6 +126054,7 @@ function reactElementToHast(node) {
125938
126054
 
125939
126055
 
125940
126056
 
126057
+
125941
126058
  /**
125942
126059
  * Bind the components a given expression actually uses as tags. Scoped per expression on purpose:
125943
126060
  * binding the whole hash would shadow same-named globals (a `math` component would break
@@ -125988,14 +126105,6 @@ const wrapInParagraph = (child) => ({
125988
126105
  position: child.position,
125989
126106
  });
125990
126107
  const placeText = (text, needsBlock) => (needsBlock ? wrapInParagraph(text) : text);
125991
- /** Turn a non-renderable evaluation result into a text node. */
125992
- const createTextNode = (result, position) => {
125993
- if (result === null || result === undefined)
125994
- return { type: 'text', value: '', position };
125995
- if (typeof result === 'object')
125996
- return { type: 'text', value: JSON.stringify(result), position };
125997
- return { type: 'text', value: String(result), position };
125998
- };
125999
126108
  /**
126000
126109
  * AST transformer to evaluate MDX expressions.
126001
126110
  * Replaces mdxFlowExpression and mdxTextExpression nodes with their evaluated values.
@@ -126115,6 +126224,26 @@ const evaluateStyleBlockExpressions = () => (tree, file) => {
126115
126224
  };
126116
126225
  /* harmony default export */ const evaluate_style_block_expressions = (evaluateStyleBlockExpressions);
126117
126226
 
126227
+ ;// ./processor/transform/mdxish/heading-ids.ts
126228
+
126229
+ /**
126230
+ * Records every heading id set by `{#id}`, so the slug pass never gives one to another heading.
126231
+ * Warns when two headings share an id, since links can only reach the first.
126232
+ */
126233
+ const headingIdsTransformer = () => (tree, file) => {
126234
+ visit(tree, 'heading', (node) => {
126235
+ const id = node.data?.hProperties?.id;
126236
+ if (typeof id !== 'string')
126237
+ return;
126238
+ const ids = file.data.explicitHeadingIds ?? new Set();
126239
+ file.data.explicitHeadingIds = ids;
126240
+ if (ids.has(id))
126241
+ console.warn(`[mdxish] Heading id "${id}" is used more than once; links reach only the first.`);
126242
+ ids.add(id);
126243
+ });
126244
+ };
126245
+ /* harmony default export */ const heading_ids = (headingIdsTransformer);
126246
+
126118
126247
  ;// ./processor/transform/mdxish/heading-slugs.ts
126119
126248
 
126120
126249
 
@@ -126140,12 +126269,17 @@ function textContent(node) {
126140
126269
  * Id's are used to construct slug anchor links & Table of Contents during rendering
126141
126270
  * Use the text / nodes that make up the heading to generate the id
126142
126271
  */
126143
- const generateSlugForHeadings = () => (tree) => {
126272
+ const generateSlugForHeadings = () => (tree, file) => {
126144
126273
  const slugger = new BananaSlug();
126274
+ // The slugger only counts the ids it generates, so `{#id}` ones are skipped past by hand.
126275
+ const explicitIds = file.data.explicitHeadingIds ?? new Set();
126145
126276
  visit(tree, 'element', (node) => {
126146
126277
  if (isHeading(node) && !node.properties.id) {
126147
126278
  const text = node.children.map(textContent).join('');
126148
- node.properties.id = slugger.slug(text);
126279
+ let id = slugger.slug(text);
126280
+ while (explicitIds.has(id))
126281
+ id = slugger.slug(text);
126282
+ node.properties.id = id;
126149
126283
  }
126150
126284
  });
126151
126285
  return tree;
@@ -128660,6 +128794,7 @@ function loadComponents() {
128660
128794
 
128661
128795
 
128662
128796
 
128797
+
128663
128798
 
128664
128799
 
128665
128800
  const defaultTransformers = [
@@ -128779,24 +128914,15 @@ function mdxishMdastToMd(mdast) {
128779
128914
  .use(remarkStringify, stringifyOptions);
128780
128915
  return processor.stringify(processor.runSync(mdast));
128781
128916
  }
128782
- /**
128783
- * Processes markdown content with MDX syntax support and returns a HAST.
128784
- * Detects and renders custom component tags from the components hash.
128785
- *
128786
- * @see .claude/context/MDXish/Processor Overview.md
128787
- */
128788
- function mdxish(mdContent, opts = {}) {
128917
+ /** The steps `mdxish()` runs after parsing; run it on the parse's VFile, since steps read `file.data`. */
128918
+ function mdxishRenderProcessor(opts = {}) {
128789
128919
  const { components: userComponents = {}, hardBreaks: enableHardBreaks = true, safeMode = false, sanitize = false, variables, } = opts;
128790
128920
  const components = {
128791
128921
  ...loadComponents(),
128792
128922
  ...userComponents,
128793
128923
  };
128794
- // Remove JSX comments before processing (protect code blocks first)
128795
- const { protectedCode, protectedContent } = protectCodeBlocks(mdContent);
128796
- const withoutComments = removeJSXComments(protectedContent);
128797
- const contentWithoutComments = restoreCodeBlocks(withoutComments, protectedCode);
128798
- const { processor, parserReadyContent } = mdxishAstProcessor(contentWithoutComments, opts);
128799
- processor
128924
+ return unified()
128925
+ .use(heading_ids)
128800
128926
  .use(safeMode ? undefined : evaluate_exports, { sanitize }) // Evaluate `export const/function` and stash scope on file.data.mdxishScope
128801
128927
  .use(enableHardBreaks ? hard_breaks : undefined) // Must precede evaluateExpressions to avoid splitting the \n in an evaluated template literal into a <br> node
128802
128928
  .use(safeMode ? undefined : evaluate_expressions, { components, variables }) // Evaluate self-contained MDX expressions (e.g. `{1+1}`)
@@ -128814,11 +128940,25 @@ function mdxish(mdContent, opts = {}) {
128814
128940
  .use(heading_slugs)
128815
128941
  .use(rehypeMdxishComponents, {
128816
128942
  components,
128943
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define -- component bodies render through mdxish() again
128817
128944
  processMarkdown: (markdown) => mdxish(markdown, opts),
128818
128945
  });
128946
+ }
128947
+ /**
128948
+ * Processes markdown content with MDX syntax support and returns a HAST.
128949
+ * Detects and renders custom component tags from the components hash.
128950
+ *
128951
+ * @see .claude/context/MDXish/Processor Overview.md
128952
+ */
128953
+ function mdxish(mdContent, opts = {}) {
128954
+ // Remove JSX comments before processing (protect code blocks first)
128955
+ const { protectedCode, protectedContent } = protectCodeBlocks(mdContent);
128956
+ const withoutComments = removeJSXComments(protectedContent);
128957
+ const contentWithoutComments = restoreCodeBlocks(withoutComments, protectedCode);
128958
+ const { processor, parserReadyContent } = mdxishAstProcessor(contentWithoutComments, opts);
128819
128959
  const vfile = new VFile({ value: parserReadyContent });
128820
- const mdast = processor.parse(parserReadyContent);
128821
- const hast = processor.runSync(mdast, vfile);
128960
+ const mdast = processor.runSync(processor.parse(parserReadyContent), vfile);
128961
+ const hast = mdxishRenderProcessor(opts).runSync(mdast, vfile);
128822
128962
  if (!hast) {
128823
128963
  throw new Error('Markdown pipeline did not produce a HAST tree.');
128824
128964
  }
@@ -128843,6 +128983,134 @@ const mix = (text, opts = {}) => {
128843
128983
  };
128844
128984
  /* harmony default export */ const lib_mix = (mix);
128845
128985
 
128986
+ ;// ./lib/mdxishHeadingIds.ts
128987
+
128988
+
128989
+
128990
+
128991
+
128992
+
128993
+
128994
+
128995
+ const HEADING_INDEX = 'dataMdxishHeadingIndex';
128996
+ const HEADING_TAG_REGEX = /^h[1-6]$/;
128997
+ const JSX_COMMENT_ONLY_REGEX = new RegExp(`^${JSX_COMMENT_REGEX.source}$`);
128998
+ const isExpression = (node) => node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression';
128999
+ function collectHeadings(tree) {
129000
+ const headings = [];
129001
+ visit(tree, 'heading', (node) => {
129002
+ headings.push(node);
129003
+ });
129004
+ return headings;
129005
+ }
129006
+ function literalValue(source) {
129007
+ try {
129008
+ return { value: evaluateLiteralExpression(source) };
129009
+ }
129010
+ catch {
129011
+ return null;
129012
+ }
129013
+ }
129014
+ function trimHeadingText(heading) {
129015
+ const first = heading.children[0];
129016
+ if (first?.type === 'text')
129017
+ first.value = first.value.trimStart();
129018
+ const last = heading.children.at(-1);
129019
+ if (last?.type === 'text')
129020
+ last.value = last.value.trimEnd();
129021
+ }
129022
+ const isNamePath = (node) => node.type === 'Identifier' ||
129023
+ (node.type === 'MemberExpression' && !node.computed && !!node.object && isNamePath(node.object));
129024
+ // A name like `{price}` or `{plan.name}` can only read a value, never build an element. Code the parser
129025
+ // rejects can't run at all, so the hub shows it as text.
129026
+ function canBuildElements(source) {
129027
+ try {
129028
+ return !isNamePath(jsxAcornParser.parseExpressionAt(source, 0, { ecmaVersion: 'latest' }));
129029
+ }
129030
+ catch {
129031
+ return false;
129032
+ }
129033
+ }
129034
+ const isHeadingElement = (node) => isMDXElement(node) && HEADING_TAG_REGEX.test(node.name ?? '');
129035
+ // An expression the hub has to run changes a heading from inside one (Markdown or an HTML heading tag), by
129036
+ // building an element (a call or JSX), or as a block: alone in its paragraph, its result is lifted out as one.
129037
+ function canChangeHeadings(node, ancestors, heading) {
129038
+ if (heading || ancestors.some(isHeadingElement) || node.type === 'mdxFlowExpression' || canBuildElements(node.value))
129039
+ return true;
129040
+ const parent = ancestors[ancestors.length - 1];
129041
+ return parent.children.every(child => child === node || (child.type === 'text' && !child.value.trim()));
129042
+ }
129043
+ // Safe mode leaves `<h2 id={...}>` without the id the hub evaluates, which shifts the numbering.
129044
+ function hasEvaluatedHeadingAttribute(tree) {
129045
+ let found = false;
129046
+ visit(tree, isHeadingElement, (node) => {
129047
+ found = node.attributes.some(attribute => attribute.type === 'mdxJsxExpressionAttribute' || typeof attribute.value === 'object');
129048
+ return found ? (/* inlined export .EXIT */false) : undefined;
129049
+ });
129050
+ return found;
129051
+ }
129052
+ // Matches what the hub renders without running code: comments are stripped and plain literals become their
129053
+ // text. `false` when an expression that needs running could change the headings.
129054
+ function settleExpressions(tree) {
129055
+ const edits = [];
129056
+ let settled = true;
129057
+ visitParents(tree, isExpression, (node, ancestors) => {
129058
+ const heading = ancestors.find((ancestor) => ancestor.type === 'heading');
129059
+ const parent = ancestors[ancestors.length - 1];
129060
+ if (JSX_COMMENT_ONLY_REGEX.test(`{${node.value}}`)) {
129061
+ edits.push({ heading, node, parent, replacement: null });
129062
+ return;
129063
+ }
129064
+ const literal = literalValue(node.value);
129065
+ if (literal) {
129066
+ edits.push({ heading, node, parent, replacement: createTextNode(literal.value, node.position) });
129067
+ return;
129068
+ }
129069
+ if (canChangeHeadings(node, ancestors, heading))
129070
+ settled = false;
129071
+ });
129072
+ const apply = ({ node, parent, replacement }) => {
129073
+ parent.children.splice(parent.children.indexOf(node), 1, ...(replacement ? [replacement] : []));
129074
+ };
129075
+ // Comments go first: the hub strips them from the source, so the parser trims only the source
129076
+ // whitespace around them, never the spaces a literal adds.
129077
+ edits
129078
+ .filter(edit => !edit.replacement)
129079
+ .forEach(edit => {
129080
+ apply(edit);
129081
+ if (edit.heading)
129082
+ trimHeadingText(edit.heading);
129083
+ });
129084
+ edits.filter(edit => edit.replacement).forEach(apply);
129085
+ return settled;
129086
+ }
129087
+ /** Each heading's rendered anchor id, worked out without running code; `null` when code could change them. */
129088
+ function mdxishHeadingIds(tree, opts = {}) {
129089
+ const headings = collectHeadings(tree);
129090
+ if (headings.length === 0)
129091
+ return new Map();
129092
+ const copy = structuredClone(tree);
129093
+ let hasExport = false;
129094
+ visit(copy, 'mdxjsEsm', () => {
129095
+ hasExport = true;
129096
+ });
129097
+ // An `export` can define components that render headings.
129098
+ if (hasExport || hasEvaluatedHeadingAttribute(copy) || !settleExpressions(copy))
129099
+ return null;
129100
+ collectHeadings(copy).forEach((heading, index) => {
129101
+ heading.data = { ...heading.data, hProperties: { ...heading.data?.hProperties, [HEADING_INDEX]: index } };
129102
+ });
129103
+ const hast = mdxishRenderProcessor({ ...opts, safeMode: true }).runSync(copy, new VFile());
129104
+ const ids = new Map();
129105
+ visit(hast, 'element', (node) => {
129106
+ const index = node.properties[HEADING_INDEX];
129107
+ if (index === undefined || typeof node.properties.id !== 'string')
129108
+ return;
129109
+ ids.set(headings[Number(index)], node.properties.id);
129110
+ });
129111
+ return ids;
129112
+ }
129113
+
128846
129114
  ;// ./lib/extractToc.ts
128847
129115
 
128848
129116
  /* harmony default export */ const lib_extractToc = (extractToc);
@@ -129462,6 +129730,7 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
129462
129730
 
129463
129731
 
129464
129732
 
129733
+
129465
129734
 
129466
129735
  ;// ./index.tsx
129467
129736
 
@@ -129817,7 +130086,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"*":["about","acceptCharset","accessK
129817
130086
  /******/ // startup
129818
130087
  /******/ // Load entry module and return exports
129819
130088
  /******/ // This entry module used 'module' so it can't be inlined
129820
- /******/ let __webpack_exports__ = __webpack_require__(3975);
130089
+ /******/ let __webpack_exports__ = __webpack_require__(5893);
129821
130090
  /******/ module.exports = __webpack_exports__;
129822
130091
  /******/
129823
130092
  /******/ })()