@readme/markdown 15.9.3 → 15.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/mdast-util/heading-id/index.d.ts +3 -0
- package/dist/lib/mdast-util/mdx-expression/index.d.ts +3 -0
- package/dist/lib/mdxish.d.ts +2 -0
- package/dist/lib/mdxishHeadingIds.d.ts +4 -0
- package/dist/lib/micromark/heading-id/index.d.ts +1 -0
- package/dist/lib/micromark/heading-id/syntax.d.ts +10 -0
- package/dist/lib/micromark/mdxish-extensions.d.ts +16 -10
- package/dist/lib/utils/mdxish/mdxish-variables.d.ts +3 -2
- package/dist/main.js +501 -208
- package/dist/main.node.js +501 -208
- package/dist/main.node.js.map +1 -1
- package/dist/processor/compile/heading.d.ts +5 -0
- package/dist/processor/transform/mdxish/heading-ids.d.ts +14 -0
- package/dist/processor/transform/mdxish/heading-slugs.d.ts +2 -1
- package/dist/processor/utils.d.ts +9 -1
- package/dist/render-fixture.node.js +508 -208
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +2 -1
package/dist/main.node.js
CHANGED
|
@@ -19111,7 +19111,7 @@ module.exports = function () {
|
|
|
19111
19111
|
|
|
19112
19112
|
/***/ },
|
|
19113
19113
|
|
|
19114
|
-
/***/
|
|
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),
|
|
@@ -75084,6 +75085,209 @@ const mdast = (text, opts = {}) => {
|
|
|
75084
75085
|
};
|
|
75085
75086
|
/* harmony default export */ const lib_mdast = (mdast);
|
|
75086
75087
|
|
|
75088
|
+
;// ./node_modules/micromark-util-symbol/lib/codes.js
|
|
75089
|
+
/**
|
|
75090
|
+
* Character codes.
|
|
75091
|
+
*
|
|
75092
|
+
* This module is compiled away!
|
|
75093
|
+
*
|
|
75094
|
+
* micromark works based on character codes.
|
|
75095
|
+
* This module contains constants for the ASCII block and the replacement
|
|
75096
|
+
* character.
|
|
75097
|
+
* A couple of them are handled in a special way, such as the line endings
|
|
75098
|
+
* (CR, LF, and CR+LF, commonly known as end-of-line: EOLs), the tab (horizontal
|
|
75099
|
+
* tab) and its expansion based on what column it’s at (virtual space),
|
|
75100
|
+
* and the end-of-file (eof) character.
|
|
75101
|
+
* As values are preprocessed before handling them, the actual characters LF,
|
|
75102
|
+
* CR, HT, and NUL (which is present as the replacement character), are
|
|
75103
|
+
* guaranteed to not exist.
|
|
75104
|
+
*
|
|
75105
|
+
* Unicode basic latin block.
|
|
75106
|
+
*/
|
|
75107
|
+
const codes = /** @type {const} */ ({
|
|
75108
|
+
carriageReturn: -5,
|
|
75109
|
+
lineFeed: -4,
|
|
75110
|
+
carriageReturnLineFeed: -3,
|
|
75111
|
+
horizontalTab: -2,
|
|
75112
|
+
virtualSpace: -1,
|
|
75113
|
+
eof: null,
|
|
75114
|
+
nul: 0,
|
|
75115
|
+
soh: 1,
|
|
75116
|
+
stx: 2,
|
|
75117
|
+
etx: 3,
|
|
75118
|
+
eot: 4,
|
|
75119
|
+
enq: 5,
|
|
75120
|
+
ack: 6,
|
|
75121
|
+
bel: 7,
|
|
75122
|
+
bs: 8,
|
|
75123
|
+
ht: 9, // `\t`
|
|
75124
|
+
lf: 10, // `\n`
|
|
75125
|
+
vt: 11, // `\v`
|
|
75126
|
+
ff: 12, // `\f`
|
|
75127
|
+
cr: 13, // `\r`
|
|
75128
|
+
so: 14,
|
|
75129
|
+
si: 15,
|
|
75130
|
+
dle: 16,
|
|
75131
|
+
dc1: 17,
|
|
75132
|
+
dc2: 18,
|
|
75133
|
+
dc3: 19,
|
|
75134
|
+
dc4: 20,
|
|
75135
|
+
nak: 21,
|
|
75136
|
+
syn: 22,
|
|
75137
|
+
etb: 23,
|
|
75138
|
+
can: 24,
|
|
75139
|
+
em: 25,
|
|
75140
|
+
sub: 26,
|
|
75141
|
+
esc: 27,
|
|
75142
|
+
fs: 28,
|
|
75143
|
+
gs: 29,
|
|
75144
|
+
rs: 30,
|
|
75145
|
+
us: 31,
|
|
75146
|
+
space: 32,
|
|
75147
|
+
exclamationMark: 33, // `!`
|
|
75148
|
+
quotationMark: 34, // `"`
|
|
75149
|
+
numberSign: 35, // `#`
|
|
75150
|
+
dollarSign: 36, // `$`
|
|
75151
|
+
percentSign: 37, // `%`
|
|
75152
|
+
ampersand: 38, // `&`
|
|
75153
|
+
apostrophe: 39, // `'`
|
|
75154
|
+
leftParenthesis: 40, // `(`
|
|
75155
|
+
rightParenthesis: 41, // `)`
|
|
75156
|
+
asterisk: 42, // `*`
|
|
75157
|
+
plusSign: 43, // `+`
|
|
75158
|
+
comma: 44, // `,`
|
|
75159
|
+
dash: 45, // `-`
|
|
75160
|
+
dot: 46, // `.`
|
|
75161
|
+
slash: 47, // `/`
|
|
75162
|
+
digit0: 48, // `0`
|
|
75163
|
+
digit1: 49, // `1`
|
|
75164
|
+
digit2: 50, // `2`
|
|
75165
|
+
digit3: 51, // `3`
|
|
75166
|
+
digit4: 52, // `4`
|
|
75167
|
+
digit5: 53, // `5`
|
|
75168
|
+
digit6: 54, // `6`
|
|
75169
|
+
digit7: 55, // `7`
|
|
75170
|
+
digit8: 56, // `8`
|
|
75171
|
+
digit9: 57, // `9`
|
|
75172
|
+
colon: 58, // `:`
|
|
75173
|
+
semicolon: 59, // `;`
|
|
75174
|
+
lessThan: 60, // `<`
|
|
75175
|
+
equalsTo: 61, // `=`
|
|
75176
|
+
greaterThan: 62, // `>`
|
|
75177
|
+
questionMark: 63, // `?`
|
|
75178
|
+
atSign: 64, // `@`
|
|
75179
|
+
uppercaseA: 65, // `A`
|
|
75180
|
+
uppercaseB: 66, // `B`
|
|
75181
|
+
uppercaseC: 67, // `C`
|
|
75182
|
+
uppercaseD: 68, // `D`
|
|
75183
|
+
uppercaseE: 69, // `E`
|
|
75184
|
+
uppercaseF: 70, // `F`
|
|
75185
|
+
uppercaseG: 71, // `G`
|
|
75186
|
+
uppercaseH: 72, // `H`
|
|
75187
|
+
uppercaseI: 73, // `I`
|
|
75188
|
+
uppercaseJ: 74, // `J`
|
|
75189
|
+
uppercaseK: 75, // `K`
|
|
75190
|
+
uppercaseL: 76, // `L`
|
|
75191
|
+
uppercaseM: 77, // `M`
|
|
75192
|
+
uppercaseN: 78, // `N`
|
|
75193
|
+
uppercaseO: 79, // `O`
|
|
75194
|
+
uppercaseP: 80, // `P`
|
|
75195
|
+
uppercaseQ: 81, // `Q`
|
|
75196
|
+
uppercaseR: 82, // `R`
|
|
75197
|
+
uppercaseS: 83, // `S`
|
|
75198
|
+
uppercaseT: 84, // `T`
|
|
75199
|
+
uppercaseU: 85, // `U`
|
|
75200
|
+
uppercaseV: 86, // `V`
|
|
75201
|
+
uppercaseW: 87, // `W`
|
|
75202
|
+
uppercaseX: 88, // `X`
|
|
75203
|
+
uppercaseY: 89, // `Y`
|
|
75204
|
+
uppercaseZ: 90, // `Z`
|
|
75205
|
+
leftSquareBracket: 91, // `[`
|
|
75206
|
+
backslash: 92, // `\`
|
|
75207
|
+
rightSquareBracket: 93, // `]`
|
|
75208
|
+
caret: 94, // `^`
|
|
75209
|
+
underscore: 95, // `_`
|
|
75210
|
+
graveAccent: 96, // `` ` ``
|
|
75211
|
+
lowercaseA: 97, // `a`
|
|
75212
|
+
lowercaseB: 98, // `b`
|
|
75213
|
+
lowercaseC: 99, // `c`
|
|
75214
|
+
lowercaseD: 100, // `d`
|
|
75215
|
+
lowercaseE: 101, // `e`
|
|
75216
|
+
lowercaseF: 102, // `f`
|
|
75217
|
+
lowercaseG: 103, // `g`
|
|
75218
|
+
lowercaseH: 104, // `h`
|
|
75219
|
+
lowercaseI: 105, // `i`
|
|
75220
|
+
lowercaseJ: 106, // `j`
|
|
75221
|
+
lowercaseK: 107, // `k`
|
|
75222
|
+
lowercaseL: 108, // `l`
|
|
75223
|
+
lowercaseM: 109, // `m`
|
|
75224
|
+
lowercaseN: 110, // `n`
|
|
75225
|
+
lowercaseO: 111, // `o`
|
|
75226
|
+
lowercaseP: 112, // `p`
|
|
75227
|
+
lowercaseQ: 113, // `q`
|
|
75228
|
+
lowercaseR: 114, // `r`
|
|
75229
|
+
lowercaseS: 115, // `s`
|
|
75230
|
+
lowercaseT: 116, // `t`
|
|
75231
|
+
lowercaseU: 117, // `u`
|
|
75232
|
+
lowercaseV: 118, // `v`
|
|
75233
|
+
lowercaseW: 119, // `w`
|
|
75234
|
+
lowercaseX: 120, // `x`
|
|
75235
|
+
lowercaseY: 121, // `y`
|
|
75236
|
+
lowercaseZ: 122, // `z`
|
|
75237
|
+
leftCurlyBrace: 123, // `{`
|
|
75238
|
+
verticalBar: 124, // `|`
|
|
75239
|
+
rightCurlyBrace: 125, // `}`
|
|
75240
|
+
tilde: 126, // `~`
|
|
75241
|
+
del: 127,
|
|
75242
|
+
// Unicode Specials block.
|
|
75243
|
+
byteOrderMarker: 65_279,
|
|
75244
|
+
// Unicode Specials block.
|
|
75245
|
+
replacementCharacter: 65_533 // `�`
|
|
75246
|
+
})
|
|
75247
|
+
|
|
75248
|
+
;// ./lib/micromark/heading-id/syntax.ts
|
|
75249
|
+
|
|
75250
|
+
|
|
75251
|
+
/** One character a `{#id}` heading id may use: the ones github-slugger keeps, plus `.` and `:`. */
|
|
75252
|
+
const HEADING_ID_CHAR = '[\\p{L}\\p{M}\\p{N}_.:-]';
|
|
75253
|
+
const ID_CLOSE_REGEX = new RegExp(`^${HEADING_ID_CHAR}+\\}$`, 'u');
|
|
75254
|
+
const typeAt = (events, index) => events[index]?.[1].type;
|
|
75255
|
+
function isIdToken(events, index, context, type, value) {
|
|
75256
|
+
return typeAt(events, index) === type && value.test(context.sliceSerialize(events[index][1]));
|
|
75257
|
+
}
|
|
75258
|
+
/** The exit index of the heading's last content token, past any trailing space and closing `##`. */
|
|
75259
|
+
function contentEnd(events) {
|
|
75260
|
+
let end = events.length - 2;
|
|
75261
|
+
if (typeAt(events, end) === 'whitespace')
|
|
75262
|
+
end -= 2;
|
|
75263
|
+
if (typeAt(events, end) === 'atxHeadingSequence' && typeAt(events, end - 2) === 'whitespace')
|
|
75264
|
+
end -= 4;
|
|
75265
|
+
return end;
|
|
75266
|
+
}
|
|
75267
|
+
const resolveHeadingId = (events, context) => {
|
|
75268
|
+
// Each token is an enter and an exit event; these indexes point at the exits.
|
|
75269
|
+
const close = contentEnd(events);
|
|
75270
|
+
const hash = close - 2;
|
|
75271
|
+
const open = close - 4;
|
|
75272
|
+
const space = close - 6;
|
|
75273
|
+
const endsWithId = isIdToken(events, close, context, 'atxHeadingText', ID_CLOSE_REGEX) &&
|
|
75274
|
+
isIdToken(events, hash, context, 'atxHeadingSequence', /^#$/) &&
|
|
75275
|
+
isIdToken(events, open, context, 'atxHeadingText', /^\{$/) &&
|
|
75276
|
+
typeAt(events, space) === 'whitespace';
|
|
75277
|
+
if (!endsWithId)
|
|
75278
|
+
return headingAtx.resolve?.(events, context) ?? events;
|
|
75279
|
+
const id = { type: 'headingId', start: events[open][1].start, end: events[close][1].end };
|
|
75280
|
+
events.splice(space - 1, close - space + 2);
|
|
75281
|
+
const resolved = headingAtx.resolve?.(events, context) ?? events;
|
|
75282
|
+
resolved.splice(resolved.length - 1, 0, ['enter', id, context], ['exit', id, context]);
|
|
75283
|
+
return resolved;
|
|
75284
|
+
};
|
|
75285
|
+
const headingIdConstruct = { ...headingAtx, resolve: resolveHeadingId };
|
|
75286
|
+
/** The ATX heading construct, with a line-final ` {#id}` split off as a `headingId` token. */
|
|
75287
|
+
function headingId() {
|
|
75288
|
+
return { flow: { [codes.numberSign]: headingIdConstruct } };
|
|
75289
|
+
}
|
|
75290
|
+
|
|
75087
75291
|
;// ./lib/utils/jsx-acorn-parser.ts
|
|
75088
75292
|
|
|
75089
75293
|
|
|
@@ -75195,6 +75399,7 @@ const evaluateLiteralExpression = (source) => {
|
|
|
75195
75399
|
|
|
75196
75400
|
|
|
75197
75401
|
|
|
75402
|
+
|
|
75198
75403
|
/**
|
|
75199
75404
|
* Evaluate a JavaScript expression source and return its value.
|
|
75200
75405
|
*
|
|
@@ -75311,6 +75516,24 @@ const getHPropKeys = (node) => {
|
|
|
75311
75516
|
const hProps = getHProps(node);
|
|
75312
75517
|
return Object.keys(hProps) || [];
|
|
75313
75518
|
};
|
|
75519
|
+
/** Turn a non-renderable evaluation result into a text node. */
|
|
75520
|
+
const createTextNode = (result, position) => {
|
|
75521
|
+
if (result === null || result === undefined)
|
|
75522
|
+
return { type: 'text', value: '', position };
|
|
75523
|
+
if (typeof result === 'object')
|
|
75524
|
+
return { type: 'text', value: JSON.stringify(result), position };
|
|
75525
|
+
return { type: 'text', value: String(result), position };
|
|
75526
|
+
};
|
|
75527
|
+
const HEADING_ID_REGEX = new RegExp(`^${HEADING_ID_CHAR}+$`, 'u');
|
|
75528
|
+
/**
|
|
75529
|
+
* The id a heading's trailing `{#id}` set, when it is one the `{#id}` syntax can spell.
|
|
75530
|
+
*
|
|
75531
|
+
* Ids may use letters, numbers, `-`, `_`, `.` and `:`; anything else, like `x y`, is dropped.
|
|
75532
|
+
*/
|
|
75533
|
+
const explicitHeadingId = (node) => {
|
|
75534
|
+
const id = node.data?.hProperties?.id;
|
|
75535
|
+
return typeof id === 'string' && HEADING_ID_REGEX.test(id) ? id : undefined;
|
|
75536
|
+
};
|
|
75314
75537
|
/**
|
|
75315
75538
|
* Gets the attributes of an MDX element and returns them as an object of hProperties.
|
|
75316
75539
|
*
|
|
@@ -93320,6 +93543,26 @@ const mdxToHast = () => tree => {
|
|
|
93320
93543
|
};
|
|
93321
93544
|
/* harmony default export */ const mdx_to_hast = (mdxToHast);
|
|
93322
93545
|
|
|
93546
|
+
;// ./lib/mdast-util/mdx-expression/index.ts
|
|
93547
|
+
|
|
93548
|
+
const upstream = mdxExpressionFromMarkdown();
|
|
93549
|
+
/**
|
|
93550
|
+
* An image's alt is its label flattened to text, which drops an expression's braces. Keep the
|
|
93551
|
+
* `{...}` source there so `{user.*}` still resolves in alt at render time (RM-10865).
|
|
93552
|
+
*/
|
|
93553
|
+
function exitTextExpression(token) {
|
|
93554
|
+
upstream.exit.mdxTextExpression.call(this, token);
|
|
93555
|
+
if (!this.stack.some(node => node.type === 'image'))
|
|
93556
|
+
return;
|
|
93557
|
+
const { children } = this.stack[this.stack.length - 1];
|
|
93558
|
+
const { position } = children[children.length - 1];
|
|
93559
|
+
children[children.length - 1] = { type: 'text', value: this.sliceSerialize(token), position };
|
|
93560
|
+
}
|
|
93561
|
+
/** Upstream `mdxExpressionFromMarkdown`, overriding only the text-expression exit to keep `{...}` source in image alt. */
|
|
93562
|
+
function mdxishExpressionFromMarkdown() {
|
|
93563
|
+
return { ...upstream, exit: { ...upstream.exit, mdxTextExpression: exitTextExpression } };
|
|
93564
|
+
}
|
|
93565
|
+
|
|
93323
93566
|
;// ./lib/mdast-util/empty-task-list-item/index.ts
|
|
93324
93567
|
/**
|
|
93325
93568
|
* Normalizes list items that are written as only `[ ]` or `[x]` into GFM task
|
|
@@ -93426,6 +93669,17 @@ function gemojiFromMarkdown() {
|
|
|
93426
93669
|
};
|
|
93427
93670
|
}
|
|
93428
93671
|
|
|
93672
|
+
;// ./lib/mdast-util/heading-id/index.ts
|
|
93673
|
+
function exitHeadingId(token) {
|
|
93674
|
+
const heading = this.stack[this.stack.length - 1];
|
|
93675
|
+
const id = this.sliceSerialize(token).slice('{#'.length, -'}'.length);
|
|
93676
|
+
heading.data = { ...heading.data, hProperties: { ...heading.data?.hProperties, id } };
|
|
93677
|
+
}
|
|
93678
|
+
/** Sets a heading's id from its `headingId` token. */
|
|
93679
|
+
function headingIdFromMarkdown() {
|
|
93680
|
+
return { exit: { headingId: exitHeadingId } };
|
|
93681
|
+
}
|
|
93682
|
+
|
|
93429
93683
|
;// ./lib/mdast-util/html-block-component/index.ts
|
|
93430
93684
|
const contextMap = new WeakMap();
|
|
93431
93685
|
function findHtmlBlockComponentToken() {
|
|
@@ -93552,6 +93806,16 @@ function exitlegacyVariableValue(token) {
|
|
|
93552
93806
|
function exitlegacyVariable(token) {
|
|
93553
93807
|
const ctx = legacy_variable_contextMap.get(token);
|
|
93554
93808
|
const serialized = this.sliceSerialize(token);
|
|
93809
|
+
// An escaped `\<<name>>` (or `\<<name\>>`) is literal text, as in the legacy parser.
|
|
93810
|
+
if (serialized.startsWith('\\')) {
|
|
93811
|
+
const literal = serialized.slice(1).replace('\\>>', '>>');
|
|
93812
|
+
// An image's alt is flattened to a string, so keep the escape for render-time resolution to honor.
|
|
93813
|
+
const inImageAlt = this.stack.some(node => node.type === 'image');
|
|
93814
|
+
this.enter({ type: 'text', value: inImageAlt ? `\\${literal}` : literal }, token);
|
|
93815
|
+
this.exit(token);
|
|
93816
|
+
legacy_variable_contextMap.delete(token);
|
|
93817
|
+
return;
|
|
93818
|
+
}
|
|
93555
93819
|
const variableName = serialized.startsWith('<<') && serialized.endsWith('>>')
|
|
93556
93820
|
? serialized.slice(2, -2)
|
|
93557
93821
|
: ctx?.value ?? '';
|
|
@@ -93794,166 +94058,6 @@ function mdxComponentFromMarkdown() {
|
|
|
93794
94058
|
};
|
|
93795
94059
|
}
|
|
93796
94060
|
|
|
93797
|
-
;// ./node_modules/micromark-util-symbol/lib/codes.js
|
|
93798
|
-
/**
|
|
93799
|
-
* Character codes.
|
|
93800
|
-
*
|
|
93801
|
-
* This module is compiled away!
|
|
93802
|
-
*
|
|
93803
|
-
* micromark works based on character codes.
|
|
93804
|
-
* This module contains constants for the ASCII block and the replacement
|
|
93805
|
-
* character.
|
|
93806
|
-
* A couple of them are handled in a special way, such as the line endings
|
|
93807
|
-
* (CR, LF, and CR+LF, commonly known as end-of-line: EOLs), the tab (horizontal
|
|
93808
|
-
* tab) and its expansion based on what column it’s at (virtual space),
|
|
93809
|
-
* and the end-of-file (eof) character.
|
|
93810
|
-
* As values are preprocessed before handling them, the actual characters LF,
|
|
93811
|
-
* CR, HT, and NUL (which is present as the replacement character), are
|
|
93812
|
-
* guaranteed to not exist.
|
|
93813
|
-
*
|
|
93814
|
-
* Unicode basic latin block.
|
|
93815
|
-
*/
|
|
93816
|
-
const codes = /** @type {const} */ ({
|
|
93817
|
-
carriageReturn: -5,
|
|
93818
|
-
lineFeed: -4,
|
|
93819
|
-
carriageReturnLineFeed: -3,
|
|
93820
|
-
horizontalTab: -2,
|
|
93821
|
-
virtualSpace: -1,
|
|
93822
|
-
eof: null,
|
|
93823
|
-
nul: 0,
|
|
93824
|
-
soh: 1,
|
|
93825
|
-
stx: 2,
|
|
93826
|
-
etx: 3,
|
|
93827
|
-
eot: 4,
|
|
93828
|
-
enq: 5,
|
|
93829
|
-
ack: 6,
|
|
93830
|
-
bel: 7,
|
|
93831
|
-
bs: 8,
|
|
93832
|
-
ht: 9, // `\t`
|
|
93833
|
-
lf: 10, // `\n`
|
|
93834
|
-
vt: 11, // `\v`
|
|
93835
|
-
ff: 12, // `\f`
|
|
93836
|
-
cr: 13, // `\r`
|
|
93837
|
-
so: 14,
|
|
93838
|
-
si: 15,
|
|
93839
|
-
dle: 16,
|
|
93840
|
-
dc1: 17,
|
|
93841
|
-
dc2: 18,
|
|
93842
|
-
dc3: 19,
|
|
93843
|
-
dc4: 20,
|
|
93844
|
-
nak: 21,
|
|
93845
|
-
syn: 22,
|
|
93846
|
-
etb: 23,
|
|
93847
|
-
can: 24,
|
|
93848
|
-
em: 25,
|
|
93849
|
-
sub: 26,
|
|
93850
|
-
esc: 27,
|
|
93851
|
-
fs: 28,
|
|
93852
|
-
gs: 29,
|
|
93853
|
-
rs: 30,
|
|
93854
|
-
us: 31,
|
|
93855
|
-
space: 32,
|
|
93856
|
-
exclamationMark: 33, // `!`
|
|
93857
|
-
quotationMark: 34, // `"`
|
|
93858
|
-
numberSign: 35, // `#`
|
|
93859
|
-
dollarSign: 36, // `$`
|
|
93860
|
-
percentSign: 37, // `%`
|
|
93861
|
-
ampersand: 38, // `&`
|
|
93862
|
-
apostrophe: 39, // `'`
|
|
93863
|
-
leftParenthesis: 40, // `(`
|
|
93864
|
-
rightParenthesis: 41, // `)`
|
|
93865
|
-
asterisk: 42, // `*`
|
|
93866
|
-
plusSign: 43, // `+`
|
|
93867
|
-
comma: 44, // `,`
|
|
93868
|
-
dash: 45, // `-`
|
|
93869
|
-
dot: 46, // `.`
|
|
93870
|
-
slash: 47, // `/`
|
|
93871
|
-
digit0: 48, // `0`
|
|
93872
|
-
digit1: 49, // `1`
|
|
93873
|
-
digit2: 50, // `2`
|
|
93874
|
-
digit3: 51, // `3`
|
|
93875
|
-
digit4: 52, // `4`
|
|
93876
|
-
digit5: 53, // `5`
|
|
93877
|
-
digit6: 54, // `6`
|
|
93878
|
-
digit7: 55, // `7`
|
|
93879
|
-
digit8: 56, // `8`
|
|
93880
|
-
digit9: 57, // `9`
|
|
93881
|
-
colon: 58, // `:`
|
|
93882
|
-
semicolon: 59, // `;`
|
|
93883
|
-
lessThan: 60, // `<`
|
|
93884
|
-
equalsTo: 61, // `=`
|
|
93885
|
-
greaterThan: 62, // `>`
|
|
93886
|
-
questionMark: 63, // `?`
|
|
93887
|
-
atSign: 64, // `@`
|
|
93888
|
-
uppercaseA: 65, // `A`
|
|
93889
|
-
uppercaseB: 66, // `B`
|
|
93890
|
-
uppercaseC: 67, // `C`
|
|
93891
|
-
uppercaseD: 68, // `D`
|
|
93892
|
-
uppercaseE: 69, // `E`
|
|
93893
|
-
uppercaseF: 70, // `F`
|
|
93894
|
-
uppercaseG: 71, // `G`
|
|
93895
|
-
uppercaseH: 72, // `H`
|
|
93896
|
-
uppercaseI: 73, // `I`
|
|
93897
|
-
uppercaseJ: 74, // `J`
|
|
93898
|
-
uppercaseK: 75, // `K`
|
|
93899
|
-
uppercaseL: 76, // `L`
|
|
93900
|
-
uppercaseM: 77, // `M`
|
|
93901
|
-
uppercaseN: 78, // `N`
|
|
93902
|
-
uppercaseO: 79, // `O`
|
|
93903
|
-
uppercaseP: 80, // `P`
|
|
93904
|
-
uppercaseQ: 81, // `Q`
|
|
93905
|
-
uppercaseR: 82, // `R`
|
|
93906
|
-
uppercaseS: 83, // `S`
|
|
93907
|
-
uppercaseT: 84, // `T`
|
|
93908
|
-
uppercaseU: 85, // `U`
|
|
93909
|
-
uppercaseV: 86, // `V`
|
|
93910
|
-
uppercaseW: 87, // `W`
|
|
93911
|
-
uppercaseX: 88, // `X`
|
|
93912
|
-
uppercaseY: 89, // `Y`
|
|
93913
|
-
uppercaseZ: 90, // `Z`
|
|
93914
|
-
leftSquareBracket: 91, // `[`
|
|
93915
|
-
backslash: 92, // `\`
|
|
93916
|
-
rightSquareBracket: 93, // `]`
|
|
93917
|
-
caret: 94, // `^`
|
|
93918
|
-
underscore: 95, // `_`
|
|
93919
|
-
graveAccent: 96, // `` ` ``
|
|
93920
|
-
lowercaseA: 97, // `a`
|
|
93921
|
-
lowercaseB: 98, // `b`
|
|
93922
|
-
lowercaseC: 99, // `c`
|
|
93923
|
-
lowercaseD: 100, // `d`
|
|
93924
|
-
lowercaseE: 101, // `e`
|
|
93925
|
-
lowercaseF: 102, // `f`
|
|
93926
|
-
lowercaseG: 103, // `g`
|
|
93927
|
-
lowercaseH: 104, // `h`
|
|
93928
|
-
lowercaseI: 105, // `i`
|
|
93929
|
-
lowercaseJ: 106, // `j`
|
|
93930
|
-
lowercaseK: 107, // `k`
|
|
93931
|
-
lowercaseL: 108, // `l`
|
|
93932
|
-
lowercaseM: 109, // `m`
|
|
93933
|
-
lowercaseN: 110, // `n`
|
|
93934
|
-
lowercaseO: 111, // `o`
|
|
93935
|
-
lowercaseP: 112, // `p`
|
|
93936
|
-
lowercaseQ: 113, // `q`
|
|
93937
|
-
lowercaseR: 114, // `r`
|
|
93938
|
-
lowercaseS: 115, // `s`
|
|
93939
|
-
lowercaseT: 116, // `t`
|
|
93940
|
-
lowercaseU: 117, // `u`
|
|
93941
|
-
lowercaseV: 118, // `v`
|
|
93942
|
-
lowercaseW: 119, // `w`
|
|
93943
|
-
lowercaseX: 120, // `x`
|
|
93944
|
-
lowercaseY: 121, // `y`
|
|
93945
|
-
lowercaseZ: 122, // `z`
|
|
93946
|
-
leftCurlyBrace: 123, // `{`
|
|
93947
|
-
verticalBar: 124, // `|`
|
|
93948
|
-
rightCurlyBrace: 125, // `}`
|
|
93949
|
-
tilde: 126, // `~`
|
|
93950
|
-
del: 127,
|
|
93951
|
-
// Unicode Specials block.
|
|
93952
|
-
byteOrderMarker: 65_279,
|
|
93953
|
-
// Unicode Specials block.
|
|
93954
|
-
replacementCharacter: 65_533 // `�`
|
|
93955
|
-
})
|
|
93956
|
-
|
|
93957
94061
|
;// ./lib/micromark/gemoji/syntax.ts
|
|
93958
94062
|
|
|
93959
94063
|
// Matches the name pattern from the original regex: \+1 or [-\w]+
|
|
@@ -94041,6 +94145,9 @@ function syntax_gemoji() {
|
|
|
94041
94145
|
};
|
|
94042
94146
|
}
|
|
94043
94147
|
|
|
94148
|
+
;// ./lib/micromark/heading-id/index.ts
|
|
94149
|
+
|
|
94150
|
+
|
|
94044
94151
|
;// ./node_modules/micromark-util-symbol/lib/types.js
|
|
94045
94152
|
/**
|
|
94046
94153
|
* This module is compiled away!
|
|
@@ -95145,9 +95252,16 @@ const legacyVariableConstruct = {
|
|
|
95145
95252
|
function syntax_tokenize(effects, ok, nok) {
|
|
95146
95253
|
let hasValue = false;
|
|
95147
95254
|
const start = (code) => {
|
|
95255
|
+
effects.enter('legacyVariable');
|
|
95256
|
+
// Claim `\<<name>>` before CommonMark's character escape drops the backslash, as the legacy parser did.
|
|
95257
|
+
if (code !== codes.backslash)
|
|
95258
|
+
return open(code);
|
|
95259
|
+
effects.consume(code); // \
|
|
95260
|
+
return open;
|
|
95261
|
+
};
|
|
95262
|
+
const open = (code) => {
|
|
95148
95263
|
if (code !== codes.lessThan)
|
|
95149
95264
|
return nok(code);
|
|
95150
|
-
effects.enter('legacyVariable');
|
|
95151
95265
|
effects.enter('legacyVariableMarkerStart');
|
|
95152
95266
|
effects.consume(code); // <
|
|
95153
95267
|
return open2;
|
|
@@ -95187,7 +95301,7 @@ function syntax_tokenize(effects, ok, nok) {
|
|
|
95187
95301
|
}
|
|
95188
95302
|
function legacyVariable() {
|
|
95189
95303
|
return {
|
|
95190
|
-
text: { [codes.lessThan]: legacyVariableConstruct },
|
|
95304
|
+
text: { [codes.backslash]: legacyVariableConstruct, [codes.lessThan]: legacyVariableConstruct },
|
|
95191
95305
|
};
|
|
95192
95306
|
}
|
|
95193
95307
|
|
|
@@ -97483,6 +97597,8 @@ function mdxExpressionLenient() {
|
|
|
97483
97597
|
|
|
97484
97598
|
|
|
97485
97599
|
|
|
97600
|
+
|
|
97601
|
+
|
|
97486
97602
|
|
|
97487
97603
|
|
|
97488
97604
|
|
|
@@ -97511,17 +97627,19 @@ const REGISTRY = {
|
|
|
97511
97627
|
magicBlock: { syntax: magicBlock, fromMarkdown: magicBlockFromMarkdown },
|
|
97512
97628
|
// Two `{` tokenizers, never registered together: the document parser takes text
|
|
97513
97629
|
// only, the component-body re-parser needs flow too for multi-line expressions.
|
|
97514
|
-
mdxExpressionLenient: { syntax: mdxExpressionLenient, fromMarkdown:
|
|
97630
|
+
mdxExpressionLenient: { syntax: mdxExpressionLenient, fromMarkdown: mdxishExpressionFromMarkdown, expression: true },
|
|
97515
97631
|
// `allowEmpty` is the package default; passed explicitly because `mdx-jsx`
|
|
97516
97632
|
// registers the same tokenizer with it off for attribute expressions.
|
|
97517
97633
|
mdxExpression: {
|
|
97518
97634
|
syntax: () => mdxExpression({ allowEmpty: true }),
|
|
97519
|
-
fromMarkdown:
|
|
97635
|
+
fromMarkdown: mdxishExpressionFromMarkdown,
|
|
97520
97636
|
expression: true,
|
|
97521
97637
|
},
|
|
97522
97638
|
mdxComponent: { syntax: mdxComponent, fromMarkdown: mdxComponentFromMarkdown },
|
|
97523
97639
|
gemoji: { syntax: syntax_gemoji, fromMarkdown: gemojiFromMarkdown },
|
|
97524
97640
|
legacyVariable: { syntax: legacyVariable, fromMarkdown: legacyVariableFromMarkdown },
|
|
97641
|
+
// Replaces the ATX heading construct in `flow`, so it never touches prose outside a heading.
|
|
97642
|
+
headingId: { syntax: headingId, fromMarkdown: headingIdFromMarkdown },
|
|
97525
97643
|
looseHtmlEntity: { syntax: looseHtmlEntity, fromMarkdown: looseHtmlEntityFromMarkdown },
|
|
97526
97644
|
htmlBlockComponent: { syntax: htmlBlockComponent, fromMarkdown: htmlBlockComponentFromMarkdown },
|
|
97527
97645
|
// This is for in-document variable & function definitions
|
|
@@ -97552,18 +97670,13 @@ const EXPRESSIONS = ['jsxComment', 'mdxExpressionLenient', 'mdxjsEsm'];
|
|
|
97552
97670
|
*/
|
|
97553
97671
|
const FEATURES = {
|
|
97554
97672
|
/** `lib/mdxish.ts` — the document parser; the only site taking every group */
|
|
97555
|
-
document: [...BLOCK_CLAIMS, ...INLINE, ...EXPRESSIONS, 'emptyTaskListItem'],
|
|
97673
|
+
document: [...BLOCK_CLAIMS, ...INLINE, ...EXPRESSIONS, 'emptyTaskListItem', 'headingId'],
|
|
97556
97674
|
/**
|
|
97557
97675
|
* `components/utils.ts` — re-parses a component body, which should tokenize
|
|
97558
97676
|
* like the document around it: when the two drifted a `<Table>` in a
|
|
97559
97677
|
* `<Callout>` lost every row (CX-3705).
|
|
97560
97678
|
*/
|
|
97561
|
-
componentBody: [
|
|
97562
|
-
...BLOCK_CLAIMS,
|
|
97563
|
-
...INLINE,
|
|
97564
|
-
'mdxExpression',
|
|
97565
|
-
'emptyTaskListItem',
|
|
97566
|
-
],
|
|
97679
|
+
componentBody: [...BLOCK_CLAIMS, ...INLINE, 'mdxExpression', 'emptyTaskListItem', 'headingId'],
|
|
97567
97680
|
/**
|
|
97568
97681
|
* `lib/mdxishTags.ts` — collects component names, so nothing inline is needed.
|
|
97569
97682
|
* Omits `htmlBlockComponent` deliberately since it's not a custom component,
|
|
@@ -101116,6 +101229,7 @@ const splitHtmlWithNestedTables = (node, source) => {
|
|
|
101116
101229
|
|
|
101117
101230
|
|
|
101118
101231
|
|
|
101232
|
+
|
|
101119
101233
|
|
|
101120
101234
|
|
|
101121
101235
|
const isTableCell = (node) => isMDXElement(node) && ['th', 'td'].includes(node.name);
|
|
@@ -101136,9 +101250,13 @@ const buildTableNodeProcessor = (withMdx) => {
|
|
|
101136
101250
|
const { micromarkExtensions, fromMarkdownExtensions } = mdxishExtensions(FEATURES.tableCell);
|
|
101137
101251
|
// `mdxjs` goes first (= lowest priority): its `mdxJsx` also claims `text` + `<`,
|
|
101138
101252
|
// and `legacyVariable` has to keep winning that race so `<<var>>` still parses.
|
|
101253
|
+
// `mdxishExpressionFromMarkdown` follows `mdxFromMarkdown` to override its expression exit.
|
|
101139
101254
|
return unified()
|
|
101140
101255
|
.data('micromarkExtensions', [...(withMdx ? [mdxjs()] : []), ...micromarkExtensions])
|
|
101141
|
-
.data('fromMarkdownExtensions', [
|
|
101256
|
+
.data('fromMarkdownExtensions', [
|
|
101257
|
+
...(withMdx ? [mdxFromMarkdown(), mdxishExpressionFromMarkdown()] : []),
|
|
101258
|
+
...fromMarkdownExtensions,
|
|
101259
|
+
])
|
|
101142
101260
|
.use(remarkParse)
|
|
101143
101261
|
.use(normalize_malformed_md_syntax)
|
|
101144
101262
|
.use([[callouts, { isMdxish: true }], code_tabs])
|
|
@@ -122182,6 +122300,18 @@ const embed_embed = (node) => {
|
|
|
122182
122300
|
};
|
|
122183
122301
|
/* harmony default export */ const compile_embed = (embed_embed);
|
|
122184
122302
|
|
|
122303
|
+
;// ./processor/compile/heading.ts
|
|
122304
|
+
|
|
122305
|
+
|
|
122306
|
+
const SETEXT_UNDERLINE_REGEX = /\n(?:=+|-+)$/;
|
|
122307
|
+
/** Writes an explicit heading id back as ` {#id}`. A setext heading, written for a line break, can't carry one. */
|
|
122308
|
+
const compile_heading_heading = ((node, parent, state, info) => {
|
|
122309
|
+
const markdown = handle.heading(node, parent, state, info);
|
|
122310
|
+
const id = explicitHeadingId(node);
|
|
122311
|
+
return id && !SETEXT_UNDERLINE_REGEX.test(markdown) ? `${markdown} {#${id}}` : markdown;
|
|
122312
|
+
});
|
|
122313
|
+
/* harmony default export */ const compile_heading = (compile_heading_heading);
|
|
122314
|
+
|
|
122185
122315
|
;// ./processor/compile/html-block.ts
|
|
122186
122316
|
|
|
122187
122317
|
const htmlBlock = (node) => {
|
|
@@ -122327,6 +122457,7 @@ const mdxishText = (node, parent, state, info) => compile_text_text(node, parent
|
|
|
122327
122457
|
|
|
122328
122458
|
|
|
122329
122459
|
|
|
122460
|
+
|
|
122330
122461
|
function compilers(mdxish = false) {
|
|
122331
122462
|
const data = this.data();
|
|
122332
122463
|
const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
@@ -122347,6 +122478,7 @@ function compilers(mdxish = false) {
|
|
|
122347
122478
|
text: compile_text_text,
|
|
122348
122479
|
yaml: compile_compatibility,
|
|
122349
122480
|
// needed only for mdxish
|
|
122481
|
+
...(mdxish && { heading: compile_heading }),
|
|
122350
122482
|
...(mdxish && { list: compile_list }),
|
|
122351
122483
|
...(mdxish && { listItem: list_item }),
|
|
122352
122484
|
...(mdxish && { text: compile_text }),
|
|
@@ -125896,6 +126028,7 @@ function reactElementToHast(node) {
|
|
|
125896
126028
|
|
|
125897
126029
|
|
|
125898
126030
|
|
|
126031
|
+
|
|
125899
126032
|
/**
|
|
125900
126033
|
* Bind the components a given expression actually uses as tags. Scoped per expression on purpose:
|
|
125901
126034
|
* binding the whole hash would shadow same-named globals (a `math` component would break
|
|
@@ -125946,14 +126079,6 @@ const wrapInParagraph = (child) => ({
|
|
|
125946
126079
|
position: child.position,
|
|
125947
126080
|
});
|
|
125948
126081
|
const placeText = (text, needsBlock) => (needsBlock ? wrapInParagraph(text) : text);
|
|
125949
|
-
/** Turn a non-renderable evaluation result into a text node. */
|
|
125950
|
-
const createTextNode = (result, position) => {
|
|
125951
|
-
if (result === null || result === undefined)
|
|
125952
|
-
return { type: 'text', value: '', position };
|
|
125953
|
-
if (typeof result === 'object')
|
|
125954
|
-
return { type: 'text', value: JSON.stringify(result), position };
|
|
125955
|
-
return { type: 'text', value: String(result), position };
|
|
125956
|
-
};
|
|
125957
126082
|
/**
|
|
125958
126083
|
* AST transformer to evaluate MDX expressions.
|
|
125959
126084
|
* Replaces mdxFlowExpression and mdxTextExpression nodes with their evaluated values.
|
|
@@ -126073,6 +126198,26 @@ const evaluateStyleBlockExpressions = () => (tree, file) => {
|
|
|
126073
126198
|
};
|
|
126074
126199
|
/* harmony default export */ const evaluate_style_block_expressions = (evaluateStyleBlockExpressions);
|
|
126075
126200
|
|
|
126201
|
+
;// ./processor/transform/mdxish/heading-ids.ts
|
|
126202
|
+
|
|
126203
|
+
/**
|
|
126204
|
+
* Records every heading id set by `{#id}`, so the slug pass never gives one to another heading.
|
|
126205
|
+
* Warns when two headings share an id, since links can only reach the first.
|
|
126206
|
+
*/
|
|
126207
|
+
const headingIdsTransformer = () => (tree, file) => {
|
|
126208
|
+
visit(tree, 'heading', (node) => {
|
|
126209
|
+
const id = node.data?.hProperties?.id;
|
|
126210
|
+
if (typeof id !== 'string')
|
|
126211
|
+
return;
|
|
126212
|
+
const ids = file.data.explicitHeadingIds ?? new Set();
|
|
126213
|
+
file.data.explicitHeadingIds = ids;
|
|
126214
|
+
if (ids.has(id))
|
|
126215
|
+
console.warn(`[mdxish] Heading id "${id}" is used more than once; links reach only the first.`);
|
|
126216
|
+
ids.add(id);
|
|
126217
|
+
});
|
|
126218
|
+
};
|
|
126219
|
+
/* harmony default export */ const heading_ids = (headingIdsTransformer);
|
|
126220
|
+
|
|
126076
126221
|
;// ./processor/transform/mdxish/heading-slugs.ts
|
|
126077
126222
|
|
|
126078
126223
|
|
|
@@ -126098,12 +126243,17 @@ function textContent(node) {
|
|
|
126098
126243
|
* Id's are used to construct slug anchor links & Table of Contents during rendering
|
|
126099
126244
|
* Use the text / nodes that make up the heading to generate the id
|
|
126100
126245
|
*/
|
|
126101
|
-
const generateSlugForHeadings = () => (tree) => {
|
|
126246
|
+
const generateSlugForHeadings = () => (tree, file) => {
|
|
126102
126247
|
const slugger = new BananaSlug();
|
|
126248
|
+
// The slugger only counts the ids it generates, so `{#id}` ones are skipped past by hand.
|
|
126249
|
+
const explicitIds = file.data.explicitHeadingIds ?? new Set();
|
|
126103
126250
|
visit(tree, 'element', (node) => {
|
|
126104
126251
|
if (isHeading(node) && !node.properties.id) {
|
|
126105
126252
|
const text = node.children.map(textContent).join('');
|
|
126106
|
-
|
|
126253
|
+
let id = slugger.slug(text);
|
|
126254
|
+
while (explicitIds.has(id))
|
|
126255
|
+
id = slugger.slug(text);
|
|
126256
|
+
node.properties.id = id;
|
|
126107
126257
|
}
|
|
126108
126258
|
});
|
|
126109
126259
|
return tree;
|
|
@@ -128039,22 +128189,28 @@ const BARE_VARIABLE_REGEX = new RegExp(`^${variable_dist.MDX_VARIABLE_REGEXP}$`,
|
|
|
128039
128189
|
// Escaped and `$`-prefixed forms are left alone so a reference that stays literal keeps its source.
|
|
128040
128190
|
// A closing escape needs no lookahead: requiring a literal `]}` already rules out `]\}`.
|
|
128041
128191
|
const BRACKET_NOTATION_REGEX = /(?<![$\\])\{user\[['"](\w+)['"]\]\}/gu;
|
|
128192
|
+
const ALT_VARIABLE_REGEX = new RegExp(`${MDX_VARIABLE_REGEX.source}|${variable_dist.VARIABLE_REGEXP}`, 'gu');
|
|
128042
128193
|
/**
|
|
128043
128194
|
* Resolve `{user.*}` in a JSX attribute value against the same `user` binding the rmdx engine gets,
|
|
128044
128195
|
* so both engines agree. Body text differs on empty values: `Variable` falls back to the default.
|
|
128045
128196
|
*
|
|
128046
128197
|
* Legacy `<<...>>` is valid inside a quoted attribute but deliberately left literal — attributes are
|
|
128047
|
-
* an MDX surface, and `{user.*}` is the syntax authors use there.
|
|
128198
|
+
* an MDX surface, and `{user.*}` is the syntax authors use there. Image alt is the exception, resolved
|
|
128199
|
+
* in the same pass so a substituted value is never rescanned (RM-10865).
|
|
128048
128200
|
*/
|
|
128049
|
-
function resolveAttributeVariables(value, user) {
|
|
128050
|
-
if (!value.includes('{user'))
|
|
128201
|
+
function resolveAttributeVariables(value, user, isImageAlt = false) {
|
|
128202
|
+
if (!isImageAlt && !value.includes('{user'))
|
|
128051
128203
|
return value;
|
|
128052
128204
|
return value
|
|
128053
128205
|
.replace(BRACKET_NOTATION_REGEX, '{user.$1}')
|
|
128054
|
-
.replace(MDX_VARIABLE_REGEX, (source,
|
|
128055
|
-
|
|
128056
|
-
|
|
128057
|
-
|
|
128206
|
+
.replace(isImageAlt ? ALT_VARIABLE_REGEX : MDX_VARIABLE_REGEX, (source, _prefix, name, _suffix, legacyName) => {
|
|
128207
|
+
// Variable names can't contain a backslash, so one marks an escaped reference.
|
|
128208
|
+
if (source.includes('\\'))
|
|
128209
|
+
return isImageAlt ? source.replaceAll('\\', '') : source;
|
|
128210
|
+
const key = (name ?? legacyName).trim();
|
|
128211
|
+
if (key.startsWith('glossary:'))
|
|
128212
|
+
return key.slice('glossary:'.length).trim();
|
|
128213
|
+
return stringifyVariableValue(user[key]);
|
|
128058
128214
|
});
|
|
128059
128215
|
}
|
|
128060
128216
|
/** Whether an attribute expression's source is a bare `user.*` reference, left for render-time substitution. */
|
|
@@ -128612,6 +128768,7 @@ function loadComponents() {
|
|
|
128612
128768
|
|
|
128613
128769
|
|
|
128614
128770
|
|
|
128771
|
+
|
|
128615
128772
|
|
|
128616
128773
|
|
|
128617
128774
|
const defaultTransformers = [
|
|
@@ -128731,24 +128888,15 @@ function mdxishMdastToMd(mdast) {
|
|
|
128731
128888
|
.use(remarkStringify, stringifyOptions);
|
|
128732
128889
|
return processor.stringify(processor.runSync(mdast));
|
|
128733
128890
|
}
|
|
128734
|
-
/**
|
|
128735
|
-
|
|
128736
|
-
* Detects and renders custom component tags from the components hash.
|
|
128737
|
-
*
|
|
128738
|
-
* @see .claude/context/MDXish/Processor Overview.md
|
|
128739
|
-
*/
|
|
128740
|
-
function mdxish(mdContent, opts = {}) {
|
|
128891
|
+
/** The steps `mdxish()` runs after parsing; run it on the parse's VFile, since steps read `file.data`. */
|
|
128892
|
+
function mdxishRenderProcessor(opts = {}) {
|
|
128741
128893
|
const { components: userComponents = {}, hardBreaks: enableHardBreaks = true, safeMode = false, sanitize = false, variables, } = opts;
|
|
128742
128894
|
const components = {
|
|
128743
128895
|
...loadComponents(),
|
|
128744
128896
|
...userComponents,
|
|
128745
128897
|
};
|
|
128746
|
-
|
|
128747
|
-
|
|
128748
|
-
const withoutComments = removeJSXComments(protectedContent);
|
|
128749
|
-
const contentWithoutComments = restoreCodeBlocks(withoutComments, protectedCode);
|
|
128750
|
-
const { processor, parserReadyContent } = mdxishAstProcessor(contentWithoutComments, opts);
|
|
128751
|
-
processor
|
|
128898
|
+
return unified()
|
|
128899
|
+
.use(heading_ids)
|
|
128752
128900
|
.use(safeMode ? undefined : evaluate_exports, { sanitize }) // Evaluate `export const/function` and stash scope on file.data.mdxishScope
|
|
128753
128901
|
.use(enableHardBreaks ? hard_breaks : undefined) // Must precede evaluateExpressions to avoid splitting the \n in an evaluated template literal into a <br> node
|
|
128754
128902
|
.use(safeMode ? undefined : evaluate_expressions, { components, variables }) // Evaluate self-contained MDX expressions (e.g. `{1+1}`)
|
|
@@ -128766,11 +128914,25 @@ function mdxish(mdContent, opts = {}) {
|
|
|
128766
128914
|
.use(heading_slugs)
|
|
128767
128915
|
.use(rehypeMdxishComponents, {
|
|
128768
128916
|
components,
|
|
128917
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define -- component bodies render through mdxish() again
|
|
128769
128918
|
processMarkdown: (markdown) => mdxish(markdown, opts),
|
|
128770
128919
|
});
|
|
128920
|
+
}
|
|
128921
|
+
/**
|
|
128922
|
+
* Processes markdown content with MDX syntax support and returns a HAST.
|
|
128923
|
+
* Detects and renders custom component tags from the components hash.
|
|
128924
|
+
*
|
|
128925
|
+
* @see .claude/context/MDXish/Processor Overview.md
|
|
128926
|
+
*/
|
|
128927
|
+
function mdxish(mdContent, opts = {}) {
|
|
128928
|
+
// Remove JSX comments before processing (protect code blocks first)
|
|
128929
|
+
const { protectedCode, protectedContent } = protectCodeBlocks(mdContent);
|
|
128930
|
+
const withoutComments = removeJSXComments(protectedContent);
|
|
128931
|
+
const contentWithoutComments = restoreCodeBlocks(withoutComments, protectedCode);
|
|
128932
|
+
const { processor, parserReadyContent } = mdxishAstProcessor(contentWithoutComments, opts);
|
|
128771
128933
|
const vfile = new VFile({ value: parserReadyContent });
|
|
128772
|
-
const mdast = processor.parse(parserReadyContent);
|
|
128773
|
-
const hast =
|
|
128934
|
+
const mdast = processor.runSync(processor.parse(parserReadyContent), vfile);
|
|
128935
|
+
const hast = mdxishRenderProcessor(opts).runSync(mdast, vfile);
|
|
128774
128936
|
if (!hast) {
|
|
128775
128937
|
throw new Error('Markdown pipeline did not produce a HAST tree.');
|
|
128776
128938
|
}
|
|
@@ -128795,6 +128957,134 @@ const mix = (text, opts = {}) => {
|
|
|
128795
128957
|
};
|
|
128796
128958
|
/* harmony default export */ const lib_mix = (mix);
|
|
128797
128959
|
|
|
128960
|
+
;// ./lib/mdxishHeadingIds.ts
|
|
128961
|
+
|
|
128962
|
+
|
|
128963
|
+
|
|
128964
|
+
|
|
128965
|
+
|
|
128966
|
+
|
|
128967
|
+
|
|
128968
|
+
|
|
128969
|
+
const HEADING_INDEX = 'dataMdxishHeadingIndex';
|
|
128970
|
+
const HEADING_TAG_REGEX = /^h[1-6]$/;
|
|
128971
|
+
const JSX_COMMENT_ONLY_REGEX = new RegExp(`^${JSX_COMMENT_REGEX.source}$`);
|
|
128972
|
+
const isExpression = (node) => node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression';
|
|
128973
|
+
function collectHeadings(tree) {
|
|
128974
|
+
const headings = [];
|
|
128975
|
+
visit(tree, 'heading', (node) => {
|
|
128976
|
+
headings.push(node);
|
|
128977
|
+
});
|
|
128978
|
+
return headings;
|
|
128979
|
+
}
|
|
128980
|
+
function literalValue(source) {
|
|
128981
|
+
try {
|
|
128982
|
+
return { value: evaluateLiteralExpression(source) };
|
|
128983
|
+
}
|
|
128984
|
+
catch {
|
|
128985
|
+
return null;
|
|
128986
|
+
}
|
|
128987
|
+
}
|
|
128988
|
+
function trimHeadingText(heading) {
|
|
128989
|
+
const first = heading.children[0];
|
|
128990
|
+
if (first?.type === 'text')
|
|
128991
|
+
first.value = first.value.trimStart();
|
|
128992
|
+
const last = heading.children.at(-1);
|
|
128993
|
+
if (last?.type === 'text')
|
|
128994
|
+
last.value = last.value.trimEnd();
|
|
128995
|
+
}
|
|
128996
|
+
const isNamePath = (node) => node.type === 'Identifier' ||
|
|
128997
|
+
(node.type === 'MemberExpression' && !node.computed && !!node.object && isNamePath(node.object));
|
|
128998
|
+
// A name like `{price}` or `{plan.name}` can only read a value, never build an element. Code the parser
|
|
128999
|
+
// rejects can't run at all, so the hub shows it as text.
|
|
129000
|
+
function canBuildElements(source) {
|
|
129001
|
+
try {
|
|
129002
|
+
return !isNamePath(jsxAcornParser.parseExpressionAt(source, 0, { ecmaVersion: 'latest' }));
|
|
129003
|
+
}
|
|
129004
|
+
catch {
|
|
129005
|
+
return false;
|
|
129006
|
+
}
|
|
129007
|
+
}
|
|
129008
|
+
const isHeadingElement = (node) => isMDXElement(node) && HEADING_TAG_REGEX.test(node.name ?? '');
|
|
129009
|
+
// An expression the hub has to run changes a heading from inside one (Markdown or an HTML heading tag), by
|
|
129010
|
+
// building an element (a call or JSX), or as a block: alone in its paragraph, its result is lifted out as one.
|
|
129011
|
+
function canChangeHeadings(node, ancestors, heading) {
|
|
129012
|
+
if (heading || ancestors.some(isHeadingElement) || node.type === 'mdxFlowExpression' || canBuildElements(node.value))
|
|
129013
|
+
return true;
|
|
129014
|
+
const parent = ancestors[ancestors.length - 1];
|
|
129015
|
+
return parent.children.every(child => child === node || (child.type === 'text' && !child.value.trim()));
|
|
129016
|
+
}
|
|
129017
|
+
// Safe mode leaves `<h2 id={...}>` without the id the hub evaluates, which shifts the numbering.
|
|
129018
|
+
function hasEvaluatedHeadingAttribute(tree) {
|
|
129019
|
+
let found = false;
|
|
129020
|
+
visit(tree, isHeadingElement, (node) => {
|
|
129021
|
+
found = node.attributes.some(attribute => attribute.type === 'mdxJsxExpressionAttribute' || typeof attribute.value === 'object');
|
|
129022
|
+
return found ? (/* inlined export .EXIT */false) : undefined;
|
|
129023
|
+
});
|
|
129024
|
+
return found;
|
|
129025
|
+
}
|
|
129026
|
+
// Matches what the hub renders without running code: comments are stripped and plain literals become their
|
|
129027
|
+
// text. `false` when an expression that needs running could change the headings.
|
|
129028
|
+
function settleExpressions(tree) {
|
|
129029
|
+
const edits = [];
|
|
129030
|
+
let settled = true;
|
|
129031
|
+
visitParents(tree, isExpression, (node, ancestors) => {
|
|
129032
|
+
const heading = ancestors.find((ancestor) => ancestor.type === 'heading');
|
|
129033
|
+
const parent = ancestors[ancestors.length - 1];
|
|
129034
|
+
if (JSX_COMMENT_ONLY_REGEX.test(`{${node.value}}`)) {
|
|
129035
|
+
edits.push({ heading, node, parent, replacement: null });
|
|
129036
|
+
return;
|
|
129037
|
+
}
|
|
129038
|
+
const literal = literalValue(node.value);
|
|
129039
|
+
if (literal) {
|
|
129040
|
+
edits.push({ heading, node, parent, replacement: createTextNode(literal.value, node.position) });
|
|
129041
|
+
return;
|
|
129042
|
+
}
|
|
129043
|
+
if (canChangeHeadings(node, ancestors, heading))
|
|
129044
|
+
settled = false;
|
|
129045
|
+
});
|
|
129046
|
+
const apply = ({ node, parent, replacement }) => {
|
|
129047
|
+
parent.children.splice(parent.children.indexOf(node), 1, ...(replacement ? [replacement] : []));
|
|
129048
|
+
};
|
|
129049
|
+
// Comments go first: the hub strips them from the source, so the parser trims only the source
|
|
129050
|
+
// whitespace around them, never the spaces a literal adds.
|
|
129051
|
+
edits
|
|
129052
|
+
.filter(edit => !edit.replacement)
|
|
129053
|
+
.forEach(edit => {
|
|
129054
|
+
apply(edit);
|
|
129055
|
+
if (edit.heading)
|
|
129056
|
+
trimHeadingText(edit.heading);
|
|
129057
|
+
});
|
|
129058
|
+
edits.filter(edit => edit.replacement).forEach(apply);
|
|
129059
|
+
return settled;
|
|
129060
|
+
}
|
|
129061
|
+
/** Each heading's rendered anchor id, worked out without running code; `null` when code could change them. */
|
|
129062
|
+
function mdxishHeadingIds(tree, opts = {}) {
|
|
129063
|
+
const headings = collectHeadings(tree);
|
|
129064
|
+
if (headings.length === 0)
|
|
129065
|
+
return new Map();
|
|
129066
|
+
const copy = structuredClone(tree);
|
|
129067
|
+
let hasExport = false;
|
|
129068
|
+
visit(copy, 'mdxjsEsm', () => {
|
|
129069
|
+
hasExport = true;
|
|
129070
|
+
});
|
|
129071
|
+
// An `export` can define components that render headings.
|
|
129072
|
+
if (hasExport || hasEvaluatedHeadingAttribute(copy) || !settleExpressions(copy))
|
|
129073
|
+
return null;
|
|
129074
|
+
collectHeadings(copy).forEach((heading, index) => {
|
|
129075
|
+
heading.data = { ...heading.data, hProperties: { ...heading.data?.hProperties, [HEADING_INDEX]: index } };
|
|
129076
|
+
});
|
|
129077
|
+
const hast = mdxishRenderProcessor({ ...opts, safeMode: true }).runSync(copy, new VFile());
|
|
129078
|
+
const ids = new Map();
|
|
129079
|
+
visit(hast, 'element', (node) => {
|
|
129080
|
+
const index = node.properties[HEADING_INDEX];
|
|
129081
|
+
if (index === undefined || typeof node.properties.id !== 'string')
|
|
129082
|
+
return;
|
|
129083
|
+
ids.set(headings[Number(index)], node.properties.id);
|
|
129084
|
+
});
|
|
129085
|
+
return ids;
|
|
129086
|
+
}
|
|
129087
|
+
|
|
128798
129088
|
;// ./lib/extractToc.ts
|
|
128799
129089
|
|
|
128800
129090
|
/* harmony default export */ const lib_extractToc = (extractToc);
|
|
@@ -129007,8 +129297,10 @@ function exportComponentsForRehype(components) {
|
|
|
129007
129297
|
* deliberately leaves mermaid alone; resolving it again here would override that.
|
|
129008
129298
|
*/
|
|
129009
129299
|
const CODE_TAG_NAMES = new Set(['code']);
|
|
129300
|
+
const isImageAlt = (tagName, key) => tagName === 'img' && key === 'alt';
|
|
129010
129301
|
/**
|
|
129011
|
-
* Resolve `{user.*}` in string-valued props
|
|
129302
|
+
* Resolve `{user.*}` in string-valued props, plus legacy `<<...>>` in img alt, where markdown flattens
|
|
129303
|
+
* body variables to text (RM-10865). Body text is handled by the `Variable` component, but
|
|
129012
129304
|
* attributes are plain strings, so they are substituted here — at render time, so that a
|
|
129013
129305
|
* server-parsed (user-agnostic) tree resolves against the current reader's variables.
|
|
129014
129306
|
*/
|
|
@@ -129018,7 +129310,7 @@ function resolveVariablesInProps(props, user, tagName) {
|
|
|
129018
129310
|
const isDocumentContent = RAW_HTML_PROP_NAMES.has(key) || (isCodeTag && key === 'value');
|
|
129019
129311
|
if (typeof value !== 'string' || isDocumentContent)
|
|
129020
129312
|
return [key, value];
|
|
129021
|
-
return [key, resolveAttributeVariables(value, user)];
|
|
129313
|
+
return [key, resolveAttributeVariables(value, user, isImageAlt(tagName, key))];
|
|
129022
129314
|
});
|
|
129023
129315
|
return Object.fromEntries(resolvedEntries);
|
|
129024
129316
|
}
|
|
@@ -129412,6 +129704,7 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
|
129412
129704
|
|
|
129413
129705
|
|
|
129414
129706
|
|
|
129707
|
+
|
|
129415
129708
|
|
|
129416
129709
|
;// ./index.tsx
|
|
129417
129710
|
|
|
@@ -129767,7 +130060,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"*":["about","acceptCharset","accessK
|
|
|
129767
130060
|
/******/ // startup
|
|
129768
130061
|
/******/ // Load entry module and return exports
|
|
129769
130062
|
/******/ // This entry module used 'module' so it can't be inlined
|
|
129770
|
-
/******/ let __webpack_exports__ = __webpack_require__(
|
|
130063
|
+
/******/ let __webpack_exports__ = __webpack_require__(5893);
|
|
129771
130064
|
/******/ module.exports = __webpack_exports__;
|
|
129772
130065
|
/******/
|
|
129773
130066
|
/******/ })()
|