@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.js
CHANGED
|
@@ -11423,7 +11423,7 @@ module.exports = function () {
|
|
|
11423
11423
|
|
|
11424
11424
|
/***/ },
|
|
11425
11425
|
|
|
11426
|
-
/***/
|
|
11426
|
+
/***/ 9477
|
|
11427
11427
|
(module, __webpack_exports__, __webpack_require__) {
|
|
11428
11428
|
|
|
11429
11429
|
"use strict";
|
|
@@ -11448,6 +11448,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
11448
11448
|
mdx: () => (/* reexport */ lib_mdx),
|
|
11449
11449
|
mdxish: () => (/* reexport */ lib_mdxish),
|
|
11450
11450
|
mdxishAstProcessor: () => (/* reexport */ mdxishAstProcessor),
|
|
11451
|
+
mdxishHeadingIds: () => (/* reexport */ mdxishHeadingIds),
|
|
11451
11452
|
mdxishMdastToMd: () => (/* reexport */ mdxishMdastToMd),
|
|
11452
11453
|
mdxishTags: () => (/* reexport */ mdxishTags),
|
|
11453
11454
|
migrate: () => (/* reexport */ lib_migrate),
|
|
@@ -54835,6 +54836,209 @@ const mdast = (text, opts = {}) => {
|
|
|
54835
54836
|
};
|
|
54836
54837
|
/* harmony default export */ const lib_mdast = (mdast);
|
|
54837
54838
|
|
|
54839
|
+
;// ./node_modules/micromark-util-symbol/lib/codes.js
|
|
54840
|
+
/**
|
|
54841
|
+
* Character codes.
|
|
54842
|
+
*
|
|
54843
|
+
* This module is compiled away!
|
|
54844
|
+
*
|
|
54845
|
+
* micromark works based on character codes.
|
|
54846
|
+
* This module contains constants for the ASCII block and the replacement
|
|
54847
|
+
* character.
|
|
54848
|
+
* A couple of them are handled in a special way, such as the line endings
|
|
54849
|
+
* (CR, LF, and CR+LF, commonly known as end-of-line: EOLs), the tab (horizontal
|
|
54850
|
+
* tab) and its expansion based on what column it’s at (virtual space),
|
|
54851
|
+
* and the end-of-file (eof) character.
|
|
54852
|
+
* As values are preprocessed before handling them, the actual characters LF,
|
|
54853
|
+
* CR, HT, and NUL (which is present as the replacement character), are
|
|
54854
|
+
* guaranteed to not exist.
|
|
54855
|
+
*
|
|
54856
|
+
* Unicode basic latin block.
|
|
54857
|
+
*/
|
|
54858
|
+
const codes = /** @type {const} */ ({
|
|
54859
|
+
carriageReturn: -5,
|
|
54860
|
+
lineFeed: -4,
|
|
54861
|
+
carriageReturnLineFeed: -3,
|
|
54862
|
+
horizontalTab: -2,
|
|
54863
|
+
virtualSpace: -1,
|
|
54864
|
+
eof: null,
|
|
54865
|
+
nul: 0,
|
|
54866
|
+
soh: 1,
|
|
54867
|
+
stx: 2,
|
|
54868
|
+
etx: 3,
|
|
54869
|
+
eot: 4,
|
|
54870
|
+
enq: 5,
|
|
54871
|
+
ack: 6,
|
|
54872
|
+
bel: 7,
|
|
54873
|
+
bs: 8,
|
|
54874
|
+
ht: 9, // `\t`
|
|
54875
|
+
lf: 10, // `\n`
|
|
54876
|
+
vt: 11, // `\v`
|
|
54877
|
+
ff: 12, // `\f`
|
|
54878
|
+
cr: 13, // `\r`
|
|
54879
|
+
so: 14,
|
|
54880
|
+
si: 15,
|
|
54881
|
+
dle: 16,
|
|
54882
|
+
dc1: 17,
|
|
54883
|
+
dc2: 18,
|
|
54884
|
+
dc3: 19,
|
|
54885
|
+
dc4: 20,
|
|
54886
|
+
nak: 21,
|
|
54887
|
+
syn: 22,
|
|
54888
|
+
etb: 23,
|
|
54889
|
+
can: 24,
|
|
54890
|
+
em: 25,
|
|
54891
|
+
sub: 26,
|
|
54892
|
+
esc: 27,
|
|
54893
|
+
fs: 28,
|
|
54894
|
+
gs: 29,
|
|
54895
|
+
rs: 30,
|
|
54896
|
+
us: 31,
|
|
54897
|
+
space: 32,
|
|
54898
|
+
exclamationMark: 33, // `!`
|
|
54899
|
+
quotationMark: 34, // `"`
|
|
54900
|
+
numberSign: 35, // `#`
|
|
54901
|
+
dollarSign: 36, // `$`
|
|
54902
|
+
percentSign: 37, // `%`
|
|
54903
|
+
ampersand: 38, // `&`
|
|
54904
|
+
apostrophe: 39, // `'`
|
|
54905
|
+
leftParenthesis: 40, // `(`
|
|
54906
|
+
rightParenthesis: 41, // `)`
|
|
54907
|
+
asterisk: 42, // `*`
|
|
54908
|
+
plusSign: 43, // `+`
|
|
54909
|
+
comma: 44, // `,`
|
|
54910
|
+
dash: 45, // `-`
|
|
54911
|
+
dot: 46, // `.`
|
|
54912
|
+
slash: 47, // `/`
|
|
54913
|
+
digit0: 48, // `0`
|
|
54914
|
+
digit1: 49, // `1`
|
|
54915
|
+
digit2: 50, // `2`
|
|
54916
|
+
digit3: 51, // `3`
|
|
54917
|
+
digit4: 52, // `4`
|
|
54918
|
+
digit5: 53, // `5`
|
|
54919
|
+
digit6: 54, // `6`
|
|
54920
|
+
digit7: 55, // `7`
|
|
54921
|
+
digit8: 56, // `8`
|
|
54922
|
+
digit9: 57, // `9`
|
|
54923
|
+
colon: 58, // `:`
|
|
54924
|
+
semicolon: 59, // `;`
|
|
54925
|
+
lessThan: 60, // `<`
|
|
54926
|
+
equalsTo: 61, // `=`
|
|
54927
|
+
greaterThan: 62, // `>`
|
|
54928
|
+
questionMark: 63, // `?`
|
|
54929
|
+
atSign: 64, // `@`
|
|
54930
|
+
uppercaseA: 65, // `A`
|
|
54931
|
+
uppercaseB: 66, // `B`
|
|
54932
|
+
uppercaseC: 67, // `C`
|
|
54933
|
+
uppercaseD: 68, // `D`
|
|
54934
|
+
uppercaseE: 69, // `E`
|
|
54935
|
+
uppercaseF: 70, // `F`
|
|
54936
|
+
uppercaseG: 71, // `G`
|
|
54937
|
+
uppercaseH: 72, // `H`
|
|
54938
|
+
uppercaseI: 73, // `I`
|
|
54939
|
+
uppercaseJ: 74, // `J`
|
|
54940
|
+
uppercaseK: 75, // `K`
|
|
54941
|
+
uppercaseL: 76, // `L`
|
|
54942
|
+
uppercaseM: 77, // `M`
|
|
54943
|
+
uppercaseN: 78, // `N`
|
|
54944
|
+
uppercaseO: 79, // `O`
|
|
54945
|
+
uppercaseP: 80, // `P`
|
|
54946
|
+
uppercaseQ: 81, // `Q`
|
|
54947
|
+
uppercaseR: 82, // `R`
|
|
54948
|
+
uppercaseS: 83, // `S`
|
|
54949
|
+
uppercaseT: 84, // `T`
|
|
54950
|
+
uppercaseU: 85, // `U`
|
|
54951
|
+
uppercaseV: 86, // `V`
|
|
54952
|
+
uppercaseW: 87, // `W`
|
|
54953
|
+
uppercaseX: 88, // `X`
|
|
54954
|
+
uppercaseY: 89, // `Y`
|
|
54955
|
+
uppercaseZ: 90, // `Z`
|
|
54956
|
+
leftSquareBracket: 91, // `[`
|
|
54957
|
+
backslash: 92, // `\`
|
|
54958
|
+
rightSquareBracket: 93, // `]`
|
|
54959
|
+
caret: 94, // `^`
|
|
54960
|
+
underscore: 95, // `_`
|
|
54961
|
+
graveAccent: 96, // `` ` ``
|
|
54962
|
+
lowercaseA: 97, // `a`
|
|
54963
|
+
lowercaseB: 98, // `b`
|
|
54964
|
+
lowercaseC: 99, // `c`
|
|
54965
|
+
lowercaseD: 100, // `d`
|
|
54966
|
+
lowercaseE: 101, // `e`
|
|
54967
|
+
lowercaseF: 102, // `f`
|
|
54968
|
+
lowercaseG: 103, // `g`
|
|
54969
|
+
lowercaseH: 104, // `h`
|
|
54970
|
+
lowercaseI: 105, // `i`
|
|
54971
|
+
lowercaseJ: 106, // `j`
|
|
54972
|
+
lowercaseK: 107, // `k`
|
|
54973
|
+
lowercaseL: 108, // `l`
|
|
54974
|
+
lowercaseM: 109, // `m`
|
|
54975
|
+
lowercaseN: 110, // `n`
|
|
54976
|
+
lowercaseO: 111, // `o`
|
|
54977
|
+
lowercaseP: 112, // `p`
|
|
54978
|
+
lowercaseQ: 113, // `q`
|
|
54979
|
+
lowercaseR: 114, // `r`
|
|
54980
|
+
lowercaseS: 115, // `s`
|
|
54981
|
+
lowercaseT: 116, // `t`
|
|
54982
|
+
lowercaseU: 117, // `u`
|
|
54983
|
+
lowercaseV: 118, // `v`
|
|
54984
|
+
lowercaseW: 119, // `w`
|
|
54985
|
+
lowercaseX: 120, // `x`
|
|
54986
|
+
lowercaseY: 121, // `y`
|
|
54987
|
+
lowercaseZ: 122, // `z`
|
|
54988
|
+
leftCurlyBrace: 123, // `{`
|
|
54989
|
+
verticalBar: 124, // `|`
|
|
54990
|
+
rightCurlyBrace: 125, // `}`
|
|
54991
|
+
tilde: 126, // `~`
|
|
54992
|
+
del: 127,
|
|
54993
|
+
// Unicode Specials block.
|
|
54994
|
+
byteOrderMarker: 65_279,
|
|
54995
|
+
// Unicode Specials block.
|
|
54996
|
+
replacementCharacter: 65_533 // `�`
|
|
54997
|
+
})
|
|
54998
|
+
|
|
54999
|
+
;// ./lib/micromark/heading-id/syntax.ts
|
|
55000
|
+
|
|
55001
|
+
|
|
55002
|
+
/** One character a `{#id}` heading id may use: the ones github-slugger keeps, plus `.` and `:`. */
|
|
55003
|
+
const HEADING_ID_CHAR = '[\\p{L}\\p{M}\\p{N}_.:-]';
|
|
55004
|
+
const ID_CLOSE_REGEX = new RegExp(`^${HEADING_ID_CHAR}+\\}$`, 'u');
|
|
55005
|
+
const typeAt = (events, index) => events[index]?.[1].type;
|
|
55006
|
+
function isIdToken(events, index, context, type, value) {
|
|
55007
|
+
return typeAt(events, index) === type && value.test(context.sliceSerialize(events[index][1]));
|
|
55008
|
+
}
|
|
55009
|
+
/** The exit index of the heading's last content token, past any trailing space and closing `##`. */
|
|
55010
|
+
function contentEnd(events) {
|
|
55011
|
+
let end = events.length - 2;
|
|
55012
|
+
if (typeAt(events, end) === 'whitespace')
|
|
55013
|
+
end -= 2;
|
|
55014
|
+
if (typeAt(events, end) === 'atxHeadingSequence' && typeAt(events, end - 2) === 'whitespace')
|
|
55015
|
+
end -= 4;
|
|
55016
|
+
return end;
|
|
55017
|
+
}
|
|
55018
|
+
const resolveHeadingId = (events, context) => {
|
|
55019
|
+
// Each token is an enter and an exit event; these indexes point at the exits.
|
|
55020
|
+
const close = contentEnd(events);
|
|
55021
|
+
const hash = close - 2;
|
|
55022
|
+
const open = close - 4;
|
|
55023
|
+
const space = close - 6;
|
|
55024
|
+
const endsWithId = isIdToken(events, close, context, 'atxHeadingText', ID_CLOSE_REGEX) &&
|
|
55025
|
+
isIdToken(events, hash, context, 'atxHeadingSequence', /^#$/) &&
|
|
55026
|
+
isIdToken(events, open, context, 'atxHeadingText', /^\{$/) &&
|
|
55027
|
+
typeAt(events, space) === 'whitespace';
|
|
55028
|
+
if (!endsWithId)
|
|
55029
|
+
return headingAtx.resolve?.(events, context) ?? events;
|
|
55030
|
+
const id = { type: 'headingId', start: events[open][1].start, end: events[close][1].end };
|
|
55031
|
+
events.splice(space - 1, close - space + 2);
|
|
55032
|
+
const resolved = headingAtx.resolve?.(events, context) ?? events;
|
|
55033
|
+
resolved.splice(resolved.length - 1, 0, ['enter', id, context], ['exit', id, context]);
|
|
55034
|
+
return resolved;
|
|
55035
|
+
};
|
|
55036
|
+
const headingIdConstruct = { ...headingAtx, resolve: resolveHeadingId };
|
|
55037
|
+
/** The ATX heading construct, with a line-final ` {#id}` split off as a `headingId` token. */
|
|
55038
|
+
function headingId() {
|
|
55039
|
+
return { flow: { [codes.numberSign]: headingIdConstruct } };
|
|
55040
|
+
}
|
|
55041
|
+
|
|
54838
55042
|
;// ./lib/utils/jsx-acorn-parser.ts
|
|
54839
55043
|
|
|
54840
55044
|
|
|
@@ -54946,6 +55150,7 @@ const evaluateLiteralExpression = (source) => {
|
|
|
54946
55150
|
|
|
54947
55151
|
|
|
54948
55152
|
|
|
55153
|
+
|
|
54949
55154
|
/**
|
|
54950
55155
|
* Evaluate a JavaScript expression source and return its value.
|
|
54951
55156
|
*
|
|
@@ -55062,6 +55267,24 @@ const getHPropKeys = (node) => {
|
|
|
55062
55267
|
const hProps = getHProps(node);
|
|
55063
55268
|
return Object.keys(hProps) || [];
|
|
55064
55269
|
};
|
|
55270
|
+
/** Turn a non-renderable evaluation result into a text node. */
|
|
55271
|
+
const createTextNode = (result, position) => {
|
|
55272
|
+
if (result === null || result === undefined)
|
|
55273
|
+
return { type: 'text', value: '', position };
|
|
55274
|
+
if (typeof result === 'object')
|
|
55275
|
+
return { type: 'text', value: JSON.stringify(result), position };
|
|
55276
|
+
return { type: 'text', value: String(result), position };
|
|
55277
|
+
};
|
|
55278
|
+
const HEADING_ID_REGEX = new RegExp(`^${HEADING_ID_CHAR}+$`, 'u');
|
|
55279
|
+
/**
|
|
55280
|
+
* The id a heading's trailing `{#id}` set, when it is one the `{#id}` syntax can spell.
|
|
55281
|
+
*
|
|
55282
|
+
* Ids may use letters, numbers, `-`, `_`, `.` and `:`; anything else, like `x y`, is dropped.
|
|
55283
|
+
*/
|
|
55284
|
+
const explicitHeadingId = (node) => {
|
|
55285
|
+
const id = node.data?.hProperties?.id;
|
|
55286
|
+
return typeof id === 'string' && HEADING_ID_REGEX.test(id) ? id : undefined;
|
|
55287
|
+
};
|
|
55065
55288
|
/**
|
|
55066
55289
|
* Gets the attributes of an MDX element and returns them as an object of hProperties.
|
|
55067
55290
|
*
|
|
@@ -73071,6 +73294,26 @@ const mdxToHast = () => tree => {
|
|
|
73071
73294
|
};
|
|
73072
73295
|
/* harmony default export */ const mdx_to_hast = (mdxToHast);
|
|
73073
73296
|
|
|
73297
|
+
;// ./lib/mdast-util/mdx-expression/index.ts
|
|
73298
|
+
|
|
73299
|
+
const upstream = mdxExpressionFromMarkdown();
|
|
73300
|
+
/**
|
|
73301
|
+
* An image's alt is its label flattened to text, which drops an expression's braces. Keep the
|
|
73302
|
+
* `{...}` source there so `{user.*}` still resolves in alt at render time (RM-10865).
|
|
73303
|
+
*/
|
|
73304
|
+
function exitTextExpression(token) {
|
|
73305
|
+
upstream.exit.mdxTextExpression.call(this, token);
|
|
73306
|
+
if (!this.stack.some(node => node.type === 'image'))
|
|
73307
|
+
return;
|
|
73308
|
+
const { children } = this.stack[this.stack.length - 1];
|
|
73309
|
+
const { position } = children[children.length - 1];
|
|
73310
|
+
children[children.length - 1] = { type: 'text', value: this.sliceSerialize(token), position };
|
|
73311
|
+
}
|
|
73312
|
+
/** Upstream `mdxExpressionFromMarkdown`, overriding only the text-expression exit to keep `{...}` source in image alt. */
|
|
73313
|
+
function mdxishExpressionFromMarkdown() {
|
|
73314
|
+
return { ...upstream, exit: { ...upstream.exit, mdxTextExpression: exitTextExpression } };
|
|
73315
|
+
}
|
|
73316
|
+
|
|
73074
73317
|
;// ./lib/mdast-util/empty-task-list-item/index.ts
|
|
73075
73318
|
/**
|
|
73076
73319
|
* Normalizes list items that are written as only `[ ]` or `[x]` into GFM task
|
|
@@ -73177,6 +73420,17 @@ function gemojiFromMarkdown() {
|
|
|
73177
73420
|
};
|
|
73178
73421
|
}
|
|
73179
73422
|
|
|
73423
|
+
;// ./lib/mdast-util/heading-id/index.ts
|
|
73424
|
+
function exitHeadingId(token) {
|
|
73425
|
+
const heading = this.stack[this.stack.length - 1];
|
|
73426
|
+
const id = this.sliceSerialize(token).slice('{#'.length, -'}'.length);
|
|
73427
|
+
heading.data = { ...heading.data, hProperties: { ...heading.data?.hProperties, id } };
|
|
73428
|
+
}
|
|
73429
|
+
/** Sets a heading's id from its `headingId` token. */
|
|
73430
|
+
function headingIdFromMarkdown() {
|
|
73431
|
+
return { exit: { headingId: exitHeadingId } };
|
|
73432
|
+
}
|
|
73433
|
+
|
|
73180
73434
|
;// ./lib/mdast-util/html-block-component/index.ts
|
|
73181
73435
|
const contextMap = new WeakMap();
|
|
73182
73436
|
function findHtmlBlockComponentToken() {
|
|
@@ -73303,6 +73557,16 @@ function exitlegacyVariableValue(token) {
|
|
|
73303
73557
|
function exitlegacyVariable(token) {
|
|
73304
73558
|
const ctx = legacy_variable_contextMap.get(token);
|
|
73305
73559
|
const serialized = this.sliceSerialize(token);
|
|
73560
|
+
// An escaped `\<<name>>` (or `\<<name\>>`) is literal text, as in the legacy parser.
|
|
73561
|
+
if (serialized.startsWith('\\')) {
|
|
73562
|
+
const literal = serialized.slice(1).replace('\\>>', '>>');
|
|
73563
|
+
// An image's alt is flattened to a string, so keep the escape for render-time resolution to honor.
|
|
73564
|
+
const inImageAlt = this.stack.some(node => node.type === 'image');
|
|
73565
|
+
this.enter({ type: 'text', value: inImageAlt ? `\\${literal}` : literal }, token);
|
|
73566
|
+
this.exit(token);
|
|
73567
|
+
legacy_variable_contextMap.delete(token);
|
|
73568
|
+
return;
|
|
73569
|
+
}
|
|
73306
73570
|
const variableName = serialized.startsWith('<<') && serialized.endsWith('>>')
|
|
73307
73571
|
? serialized.slice(2, -2)
|
|
73308
73572
|
: ctx?.value ?? '';
|
|
@@ -73545,166 +73809,6 @@ function mdxComponentFromMarkdown() {
|
|
|
73545
73809
|
};
|
|
73546
73810
|
}
|
|
73547
73811
|
|
|
73548
|
-
;// ./node_modules/micromark-util-symbol/lib/codes.js
|
|
73549
|
-
/**
|
|
73550
|
-
* Character codes.
|
|
73551
|
-
*
|
|
73552
|
-
* This module is compiled away!
|
|
73553
|
-
*
|
|
73554
|
-
* micromark works based on character codes.
|
|
73555
|
-
* This module contains constants for the ASCII block and the replacement
|
|
73556
|
-
* character.
|
|
73557
|
-
* A couple of them are handled in a special way, such as the line endings
|
|
73558
|
-
* (CR, LF, and CR+LF, commonly known as end-of-line: EOLs), the tab (horizontal
|
|
73559
|
-
* tab) and its expansion based on what column it’s at (virtual space),
|
|
73560
|
-
* and the end-of-file (eof) character.
|
|
73561
|
-
* As values are preprocessed before handling them, the actual characters LF,
|
|
73562
|
-
* CR, HT, and NUL (which is present as the replacement character), are
|
|
73563
|
-
* guaranteed to not exist.
|
|
73564
|
-
*
|
|
73565
|
-
* Unicode basic latin block.
|
|
73566
|
-
*/
|
|
73567
|
-
const codes = /** @type {const} */ ({
|
|
73568
|
-
carriageReturn: -5,
|
|
73569
|
-
lineFeed: -4,
|
|
73570
|
-
carriageReturnLineFeed: -3,
|
|
73571
|
-
horizontalTab: -2,
|
|
73572
|
-
virtualSpace: -1,
|
|
73573
|
-
eof: null,
|
|
73574
|
-
nul: 0,
|
|
73575
|
-
soh: 1,
|
|
73576
|
-
stx: 2,
|
|
73577
|
-
etx: 3,
|
|
73578
|
-
eot: 4,
|
|
73579
|
-
enq: 5,
|
|
73580
|
-
ack: 6,
|
|
73581
|
-
bel: 7,
|
|
73582
|
-
bs: 8,
|
|
73583
|
-
ht: 9, // `\t`
|
|
73584
|
-
lf: 10, // `\n`
|
|
73585
|
-
vt: 11, // `\v`
|
|
73586
|
-
ff: 12, // `\f`
|
|
73587
|
-
cr: 13, // `\r`
|
|
73588
|
-
so: 14,
|
|
73589
|
-
si: 15,
|
|
73590
|
-
dle: 16,
|
|
73591
|
-
dc1: 17,
|
|
73592
|
-
dc2: 18,
|
|
73593
|
-
dc3: 19,
|
|
73594
|
-
dc4: 20,
|
|
73595
|
-
nak: 21,
|
|
73596
|
-
syn: 22,
|
|
73597
|
-
etb: 23,
|
|
73598
|
-
can: 24,
|
|
73599
|
-
em: 25,
|
|
73600
|
-
sub: 26,
|
|
73601
|
-
esc: 27,
|
|
73602
|
-
fs: 28,
|
|
73603
|
-
gs: 29,
|
|
73604
|
-
rs: 30,
|
|
73605
|
-
us: 31,
|
|
73606
|
-
space: 32,
|
|
73607
|
-
exclamationMark: 33, // `!`
|
|
73608
|
-
quotationMark: 34, // `"`
|
|
73609
|
-
numberSign: 35, // `#`
|
|
73610
|
-
dollarSign: 36, // `$`
|
|
73611
|
-
percentSign: 37, // `%`
|
|
73612
|
-
ampersand: 38, // `&`
|
|
73613
|
-
apostrophe: 39, // `'`
|
|
73614
|
-
leftParenthesis: 40, // `(`
|
|
73615
|
-
rightParenthesis: 41, // `)`
|
|
73616
|
-
asterisk: 42, // `*`
|
|
73617
|
-
plusSign: 43, // `+`
|
|
73618
|
-
comma: 44, // `,`
|
|
73619
|
-
dash: 45, // `-`
|
|
73620
|
-
dot: 46, // `.`
|
|
73621
|
-
slash: 47, // `/`
|
|
73622
|
-
digit0: 48, // `0`
|
|
73623
|
-
digit1: 49, // `1`
|
|
73624
|
-
digit2: 50, // `2`
|
|
73625
|
-
digit3: 51, // `3`
|
|
73626
|
-
digit4: 52, // `4`
|
|
73627
|
-
digit5: 53, // `5`
|
|
73628
|
-
digit6: 54, // `6`
|
|
73629
|
-
digit7: 55, // `7`
|
|
73630
|
-
digit8: 56, // `8`
|
|
73631
|
-
digit9: 57, // `9`
|
|
73632
|
-
colon: 58, // `:`
|
|
73633
|
-
semicolon: 59, // `;`
|
|
73634
|
-
lessThan: 60, // `<`
|
|
73635
|
-
equalsTo: 61, // `=`
|
|
73636
|
-
greaterThan: 62, // `>`
|
|
73637
|
-
questionMark: 63, // `?`
|
|
73638
|
-
atSign: 64, // `@`
|
|
73639
|
-
uppercaseA: 65, // `A`
|
|
73640
|
-
uppercaseB: 66, // `B`
|
|
73641
|
-
uppercaseC: 67, // `C`
|
|
73642
|
-
uppercaseD: 68, // `D`
|
|
73643
|
-
uppercaseE: 69, // `E`
|
|
73644
|
-
uppercaseF: 70, // `F`
|
|
73645
|
-
uppercaseG: 71, // `G`
|
|
73646
|
-
uppercaseH: 72, // `H`
|
|
73647
|
-
uppercaseI: 73, // `I`
|
|
73648
|
-
uppercaseJ: 74, // `J`
|
|
73649
|
-
uppercaseK: 75, // `K`
|
|
73650
|
-
uppercaseL: 76, // `L`
|
|
73651
|
-
uppercaseM: 77, // `M`
|
|
73652
|
-
uppercaseN: 78, // `N`
|
|
73653
|
-
uppercaseO: 79, // `O`
|
|
73654
|
-
uppercaseP: 80, // `P`
|
|
73655
|
-
uppercaseQ: 81, // `Q`
|
|
73656
|
-
uppercaseR: 82, // `R`
|
|
73657
|
-
uppercaseS: 83, // `S`
|
|
73658
|
-
uppercaseT: 84, // `T`
|
|
73659
|
-
uppercaseU: 85, // `U`
|
|
73660
|
-
uppercaseV: 86, // `V`
|
|
73661
|
-
uppercaseW: 87, // `W`
|
|
73662
|
-
uppercaseX: 88, // `X`
|
|
73663
|
-
uppercaseY: 89, // `Y`
|
|
73664
|
-
uppercaseZ: 90, // `Z`
|
|
73665
|
-
leftSquareBracket: 91, // `[`
|
|
73666
|
-
backslash: 92, // `\`
|
|
73667
|
-
rightSquareBracket: 93, // `]`
|
|
73668
|
-
caret: 94, // `^`
|
|
73669
|
-
underscore: 95, // `_`
|
|
73670
|
-
graveAccent: 96, // `` ` ``
|
|
73671
|
-
lowercaseA: 97, // `a`
|
|
73672
|
-
lowercaseB: 98, // `b`
|
|
73673
|
-
lowercaseC: 99, // `c`
|
|
73674
|
-
lowercaseD: 100, // `d`
|
|
73675
|
-
lowercaseE: 101, // `e`
|
|
73676
|
-
lowercaseF: 102, // `f`
|
|
73677
|
-
lowercaseG: 103, // `g`
|
|
73678
|
-
lowercaseH: 104, // `h`
|
|
73679
|
-
lowercaseI: 105, // `i`
|
|
73680
|
-
lowercaseJ: 106, // `j`
|
|
73681
|
-
lowercaseK: 107, // `k`
|
|
73682
|
-
lowercaseL: 108, // `l`
|
|
73683
|
-
lowercaseM: 109, // `m`
|
|
73684
|
-
lowercaseN: 110, // `n`
|
|
73685
|
-
lowercaseO: 111, // `o`
|
|
73686
|
-
lowercaseP: 112, // `p`
|
|
73687
|
-
lowercaseQ: 113, // `q`
|
|
73688
|
-
lowercaseR: 114, // `r`
|
|
73689
|
-
lowercaseS: 115, // `s`
|
|
73690
|
-
lowercaseT: 116, // `t`
|
|
73691
|
-
lowercaseU: 117, // `u`
|
|
73692
|
-
lowercaseV: 118, // `v`
|
|
73693
|
-
lowercaseW: 119, // `w`
|
|
73694
|
-
lowercaseX: 120, // `x`
|
|
73695
|
-
lowercaseY: 121, // `y`
|
|
73696
|
-
lowercaseZ: 122, // `z`
|
|
73697
|
-
leftCurlyBrace: 123, // `{`
|
|
73698
|
-
verticalBar: 124, // `|`
|
|
73699
|
-
rightCurlyBrace: 125, // `}`
|
|
73700
|
-
tilde: 126, // `~`
|
|
73701
|
-
del: 127,
|
|
73702
|
-
// Unicode Specials block.
|
|
73703
|
-
byteOrderMarker: 65_279,
|
|
73704
|
-
// Unicode Specials block.
|
|
73705
|
-
replacementCharacter: 65_533 // `�`
|
|
73706
|
-
})
|
|
73707
|
-
|
|
73708
73812
|
;// ./lib/micromark/gemoji/syntax.ts
|
|
73709
73813
|
|
|
73710
73814
|
// Matches the name pattern from the original regex: \+1 or [-\w]+
|
|
@@ -73792,6 +73896,9 @@ function syntax_gemoji() {
|
|
|
73792
73896
|
};
|
|
73793
73897
|
}
|
|
73794
73898
|
|
|
73899
|
+
;// ./lib/micromark/heading-id/index.ts
|
|
73900
|
+
|
|
73901
|
+
|
|
73795
73902
|
;// ./node_modules/micromark-util-symbol/lib/types.js
|
|
73796
73903
|
/**
|
|
73797
73904
|
* This module is compiled away!
|
|
@@ -74896,9 +75003,16 @@ const legacyVariableConstruct = {
|
|
|
74896
75003
|
function syntax_tokenize(effects, ok, nok) {
|
|
74897
75004
|
let hasValue = false;
|
|
74898
75005
|
const start = (code) => {
|
|
75006
|
+
effects.enter('legacyVariable');
|
|
75007
|
+
// Claim `\<<name>>` before CommonMark's character escape drops the backslash, as the legacy parser did.
|
|
75008
|
+
if (code !== codes.backslash)
|
|
75009
|
+
return open(code);
|
|
75010
|
+
effects.consume(code); // \
|
|
75011
|
+
return open;
|
|
75012
|
+
};
|
|
75013
|
+
const open = (code) => {
|
|
74899
75014
|
if (code !== codes.lessThan)
|
|
74900
75015
|
return nok(code);
|
|
74901
|
-
effects.enter('legacyVariable');
|
|
74902
75016
|
effects.enter('legacyVariableMarkerStart');
|
|
74903
75017
|
effects.consume(code); // <
|
|
74904
75018
|
return open2;
|
|
@@ -74938,7 +75052,7 @@ function syntax_tokenize(effects, ok, nok) {
|
|
|
74938
75052
|
}
|
|
74939
75053
|
function legacyVariable() {
|
|
74940
75054
|
return {
|
|
74941
|
-
text: { [codes.lessThan]: legacyVariableConstruct },
|
|
75055
|
+
text: { [codes.backslash]: legacyVariableConstruct, [codes.lessThan]: legacyVariableConstruct },
|
|
74942
75056
|
};
|
|
74943
75057
|
}
|
|
74944
75058
|
|
|
@@ -77234,6 +77348,8 @@ function mdxExpressionLenient() {
|
|
|
77234
77348
|
|
|
77235
77349
|
|
|
77236
77350
|
|
|
77351
|
+
|
|
77352
|
+
|
|
77237
77353
|
|
|
77238
77354
|
|
|
77239
77355
|
|
|
@@ -77262,17 +77378,19 @@ const REGISTRY = {
|
|
|
77262
77378
|
magicBlock: { syntax: magicBlock, fromMarkdown: magicBlockFromMarkdown },
|
|
77263
77379
|
// Two `{` tokenizers, never registered together: the document parser takes text
|
|
77264
77380
|
// only, the component-body re-parser needs flow too for multi-line expressions.
|
|
77265
|
-
mdxExpressionLenient: { syntax: mdxExpressionLenient, fromMarkdown:
|
|
77381
|
+
mdxExpressionLenient: { syntax: mdxExpressionLenient, fromMarkdown: mdxishExpressionFromMarkdown, expression: true },
|
|
77266
77382
|
// `allowEmpty` is the package default; passed explicitly because `mdx-jsx`
|
|
77267
77383
|
// registers the same tokenizer with it off for attribute expressions.
|
|
77268
77384
|
mdxExpression: {
|
|
77269
77385
|
syntax: () => mdxExpression({ allowEmpty: true }),
|
|
77270
|
-
fromMarkdown:
|
|
77386
|
+
fromMarkdown: mdxishExpressionFromMarkdown,
|
|
77271
77387
|
expression: true,
|
|
77272
77388
|
},
|
|
77273
77389
|
mdxComponent: { syntax: mdxComponent, fromMarkdown: mdxComponentFromMarkdown },
|
|
77274
77390
|
gemoji: { syntax: syntax_gemoji, fromMarkdown: gemojiFromMarkdown },
|
|
77275
77391
|
legacyVariable: { syntax: legacyVariable, fromMarkdown: legacyVariableFromMarkdown },
|
|
77392
|
+
// Replaces the ATX heading construct in `flow`, so it never touches prose outside a heading.
|
|
77393
|
+
headingId: { syntax: headingId, fromMarkdown: headingIdFromMarkdown },
|
|
77276
77394
|
looseHtmlEntity: { syntax: looseHtmlEntity, fromMarkdown: looseHtmlEntityFromMarkdown },
|
|
77277
77395
|
htmlBlockComponent: { syntax: htmlBlockComponent, fromMarkdown: htmlBlockComponentFromMarkdown },
|
|
77278
77396
|
// This is for in-document variable & function definitions
|
|
@@ -77303,18 +77421,13 @@ const EXPRESSIONS = ['jsxComment', 'mdxExpressionLenient', 'mdxjsEsm'];
|
|
|
77303
77421
|
*/
|
|
77304
77422
|
const FEATURES = {
|
|
77305
77423
|
/** `lib/mdxish.ts` — the document parser; the only site taking every group */
|
|
77306
|
-
document: [...BLOCK_CLAIMS, ...INLINE, ...EXPRESSIONS, 'emptyTaskListItem'],
|
|
77424
|
+
document: [...BLOCK_CLAIMS, ...INLINE, ...EXPRESSIONS, 'emptyTaskListItem', 'headingId'],
|
|
77307
77425
|
/**
|
|
77308
77426
|
* `components/utils.ts` — re-parses a component body, which should tokenize
|
|
77309
77427
|
* like the document around it: when the two drifted a `<Table>` in a
|
|
77310
77428
|
* `<Callout>` lost every row (CX-3705).
|
|
77311
77429
|
*/
|
|
77312
|
-
componentBody: [
|
|
77313
|
-
...BLOCK_CLAIMS,
|
|
77314
|
-
...INLINE,
|
|
77315
|
-
'mdxExpression',
|
|
77316
|
-
'emptyTaskListItem',
|
|
77317
|
-
],
|
|
77430
|
+
componentBody: [...BLOCK_CLAIMS, ...INLINE, 'mdxExpression', 'emptyTaskListItem', 'headingId'],
|
|
77318
77431
|
/**
|
|
77319
77432
|
* `lib/mdxishTags.ts` — collects component names, so nothing inline is needed.
|
|
77320
77433
|
* Omits `htmlBlockComponent` deliberately since it's not a custom component,
|
|
@@ -80867,6 +80980,7 @@ const splitHtmlWithNestedTables = (node, source) => {
|
|
|
80867
80980
|
|
|
80868
80981
|
|
|
80869
80982
|
|
|
80983
|
+
|
|
80870
80984
|
|
|
80871
80985
|
|
|
80872
80986
|
const isTableCell = (node) => isMDXElement(node) && ['th', 'td'].includes(node.name);
|
|
@@ -80887,9 +81001,13 @@ const buildTableNodeProcessor = (withMdx) => {
|
|
|
80887
81001
|
const { micromarkExtensions, fromMarkdownExtensions } = mdxishExtensions(FEATURES.tableCell);
|
|
80888
81002
|
// `mdxjs` goes first (= lowest priority): its `mdxJsx` also claims `text` + `<`,
|
|
80889
81003
|
// and `legacyVariable` has to keep winning that race so `<<var>>` still parses.
|
|
81004
|
+
// `mdxishExpressionFromMarkdown` follows `mdxFromMarkdown` to override its expression exit.
|
|
80890
81005
|
return unified()
|
|
80891
81006
|
.data('micromarkExtensions', [...(withMdx ? [mdxjs()] : []), ...micromarkExtensions])
|
|
80892
|
-
.data('fromMarkdownExtensions', [
|
|
81007
|
+
.data('fromMarkdownExtensions', [
|
|
81008
|
+
...(withMdx ? [mdxFromMarkdown(), mdxishExpressionFromMarkdown()] : []),
|
|
81009
|
+
...fromMarkdownExtensions,
|
|
81010
|
+
])
|
|
80893
81011
|
.use(remarkParse)
|
|
80894
81012
|
.use(normalize_malformed_md_syntax)
|
|
80895
81013
|
.use([[callouts, { isMdxish: true }], code_tabs])
|
|
@@ -101933,6 +102051,18 @@ const embed_embed = (node) => {
|
|
|
101933
102051
|
};
|
|
101934
102052
|
/* harmony default export */ const compile_embed = (embed_embed);
|
|
101935
102053
|
|
|
102054
|
+
;// ./processor/compile/heading.ts
|
|
102055
|
+
|
|
102056
|
+
|
|
102057
|
+
const SETEXT_UNDERLINE_REGEX = /\n(?:=+|-+)$/;
|
|
102058
|
+
/** Writes an explicit heading id back as ` {#id}`. A setext heading, written for a line break, can't carry one. */
|
|
102059
|
+
const compile_heading_heading = ((node, parent, state, info) => {
|
|
102060
|
+
const markdown = handle.heading(node, parent, state, info);
|
|
102061
|
+
const id = explicitHeadingId(node);
|
|
102062
|
+
return id && !SETEXT_UNDERLINE_REGEX.test(markdown) ? `${markdown} {#${id}}` : markdown;
|
|
102063
|
+
});
|
|
102064
|
+
/* harmony default export */ const compile_heading = (compile_heading_heading);
|
|
102065
|
+
|
|
101936
102066
|
;// ./processor/compile/html-block.ts
|
|
101937
102067
|
|
|
101938
102068
|
const htmlBlock = (node) => {
|
|
@@ -102078,6 +102208,7 @@ const mdxishText = (node, parent, state, info) => compile_text_text(node, parent
|
|
|
102078
102208
|
|
|
102079
102209
|
|
|
102080
102210
|
|
|
102211
|
+
|
|
102081
102212
|
function compilers(mdxish = false) {
|
|
102082
102213
|
const data = this.data();
|
|
102083
102214
|
const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
@@ -102098,6 +102229,7 @@ function compilers(mdxish = false) {
|
|
|
102098
102229
|
text: compile_text_text,
|
|
102099
102230
|
yaml: compile_compatibility,
|
|
102100
102231
|
// needed only for mdxish
|
|
102232
|
+
...(mdxish && { heading: compile_heading }),
|
|
102101
102233
|
...(mdxish && { list: compile_list }),
|
|
102102
102234
|
...(mdxish && { listItem: list_item }),
|
|
102103
102235
|
...(mdxish && { text: compile_text }),
|
|
@@ -105647,6 +105779,7 @@ function reactElementToHast(node) {
|
|
|
105647
105779
|
|
|
105648
105780
|
|
|
105649
105781
|
|
|
105782
|
+
|
|
105650
105783
|
/**
|
|
105651
105784
|
* Bind the components a given expression actually uses as tags. Scoped per expression on purpose:
|
|
105652
105785
|
* binding the whole hash would shadow same-named globals (a `math` component would break
|
|
@@ -105697,14 +105830,6 @@ const wrapInParagraph = (child) => ({
|
|
|
105697
105830
|
position: child.position,
|
|
105698
105831
|
});
|
|
105699
105832
|
const placeText = (text, needsBlock) => (needsBlock ? wrapInParagraph(text) : text);
|
|
105700
|
-
/** Turn a non-renderable evaluation result into a text node. */
|
|
105701
|
-
const createTextNode = (result, position) => {
|
|
105702
|
-
if (result === null || result === undefined)
|
|
105703
|
-
return { type: 'text', value: '', position };
|
|
105704
|
-
if (typeof result === 'object')
|
|
105705
|
-
return { type: 'text', value: JSON.stringify(result), position };
|
|
105706
|
-
return { type: 'text', value: String(result), position };
|
|
105707
|
-
};
|
|
105708
105833
|
/**
|
|
105709
105834
|
* AST transformer to evaluate MDX expressions.
|
|
105710
105835
|
* Replaces mdxFlowExpression and mdxTextExpression nodes with their evaluated values.
|
|
@@ -105824,6 +105949,26 @@ const evaluateStyleBlockExpressions = () => (tree, file) => {
|
|
|
105824
105949
|
};
|
|
105825
105950
|
/* harmony default export */ const evaluate_style_block_expressions = (evaluateStyleBlockExpressions);
|
|
105826
105951
|
|
|
105952
|
+
;// ./processor/transform/mdxish/heading-ids.ts
|
|
105953
|
+
|
|
105954
|
+
/**
|
|
105955
|
+
* Records every heading id set by `{#id}`, so the slug pass never gives one to another heading.
|
|
105956
|
+
* Warns when two headings share an id, since links can only reach the first.
|
|
105957
|
+
*/
|
|
105958
|
+
const headingIdsTransformer = () => (tree, file) => {
|
|
105959
|
+
visit(tree, 'heading', (node) => {
|
|
105960
|
+
const id = node.data?.hProperties?.id;
|
|
105961
|
+
if (typeof id !== 'string')
|
|
105962
|
+
return;
|
|
105963
|
+
const ids = file.data.explicitHeadingIds ?? new Set();
|
|
105964
|
+
file.data.explicitHeadingIds = ids;
|
|
105965
|
+
if (ids.has(id))
|
|
105966
|
+
console.warn(`[mdxish] Heading id "${id}" is used more than once; links reach only the first.`);
|
|
105967
|
+
ids.add(id);
|
|
105968
|
+
});
|
|
105969
|
+
};
|
|
105970
|
+
/* harmony default export */ const heading_ids = (headingIdsTransformer);
|
|
105971
|
+
|
|
105827
105972
|
;// ./processor/transform/mdxish/heading-slugs.ts
|
|
105828
105973
|
|
|
105829
105974
|
|
|
@@ -105849,12 +105994,17 @@ function textContent(node) {
|
|
|
105849
105994
|
* Id's are used to construct slug anchor links & Table of Contents during rendering
|
|
105850
105995
|
* Use the text / nodes that make up the heading to generate the id
|
|
105851
105996
|
*/
|
|
105852
|
-
const generateSlugForHeadings = () => (tree) => {
|
|
105997
|
+
const generateSlugForHeadings = () => (tree, file) => {
|
|
105853
105998
|
const slugger = new BananaSlug();
|
|
105999
|
+
// The slugger only counts the ids it generates, so `{#id}` ones are skipped past by hand.
|
|
106000
|
+
const explicitIds = file.data.explicitHeadingIds ?? new Set();
|
|
105854
106001
|
visit(tree, 'element', (node) => {
|
|
105855
106002
|
if (isHeading(node) && !node.properties.id) {
|
|
105856
106003
|
const text = node.children.map(textContent).join('');
|
|
105857
|
-
|
|
106004
|
+
let id = slugger.slug(text);
|
|
106005
|
+
while (explicitIds.has(id))
|
|
106006
|
+
id = slugger.slug(text);
|
|
106007
|
+
node.properties.id = id;
|
|
105858
106008
|
}
|
|
105859
106009
|
});
|
|
105860
106010
|
return tree;
|
|
@@ -107790,22 +107940,28 @@ const BARE_VARIABLE_REGEX = new RegExp(`^${variable_.MDX_VARIABLE_REGEXP}$`, 'u'
|
|
|
107790
107940
|
// Escaped and `$`-prefixed forms are left alone so a reference that stays literal keeps its source.
|
|
107791
107941
|
// A closing escape needs no lookahead: requiring a literal `]}` already rules out `]\}`.
|
|
107792
107942
|
const BRACKET_NOTATION_REGEX = /(?<![$\\])\{user\[['"](\w+)['"]\]\}/gu;
|
|
107943
|
+
const ALT_VARIABLE_REGEX = new RegExp(`${MDX_VARIABLE_REGEX.source}|${variable_.VARIABLE_REGEXP}`, 'gu');
|
|
107793
107944
|
/**
|
|
107794
107945
|
* Resolve `{user.*}` in a JSX attribute value against the same `user` binding the rmdx engine gets,
|
|
107795
107946
|
* so both engines agree. Body text differs on empty values: `Variable` falls back to the default.
|
|
107796
107947
|
*
|
|
107797
107948
|
* Legacy `<<...>>` is valid inside a quoted attribute but deliberately left literal — attributes are
|
|
107798
|
-
* an MDX surface, and `{user.*}` is the syntax authors use there.
|
|
107949
|
+
* an MDX surface, and `{user.*}` is the syntax authors use there. Image alt is the exception, resolved
|
|
107950
|
+
* in the same pass so a substituted value is never rescanned (RM-10865).
|
|
107799
107951
|
*/
|
|
107800
|
-
function resolveAttributeVariables(value, user) {
|
|
107801
|
-
if (!value.includes('{user'))
|
|
107952
|
+
function resolveAttributeVariables(value, user, isImageAlt = false) {
|
|
107953
|
+
if (!isImageAlt && !value.includes('{user'))
|
|
107802
107954
|
return value;
|
|
107803
107955
|
return value
|
|
107804
107956
|
.replace(BRACKET_NOTATION_REGEX, '{user.$1}')
|
|
107805
|
-
.replace(MDX_VARIABLE_REGEX, (source,
|
|
107806
|
-
|
|
107807
|
-
|
|
107808
|
-
|
|
107957
|
+
.replace(isImageAlt ? ALT_VARIABLE_REGEX : MDX_VARIABLE_REGEX, (source, _prefix, name, _suffix, legacyName) => {
|
|
107958
|
+
// Variable names can't contain a backslash, so one marks an escaped reference.
|
|
107959
|
+
if (source.includes('\\'))
|
|
107960
|
+
return isImageAlt ? source.replaceAll('\\', '') : source;
|
|
107961
|
+
const key = (name ?? legacyName).trim();
|
|
107962
|
+
if (key.startsWith('glossary:'))
|
|
107963
|
+
return key.slice('glossary:'.length).trim();
|
|
107964
|
+
return stringifyVariableValue(user[key]);
|
|
107809
107965
|
});
|
|
107810
107966
|
}
|
|
107811
107967
|
/** Whether an attribute expression's source is a bare `user.*` reference, left for render-time substitution. */
|
|
@@ -108363,6 +108519,7 @@ function loadComponents() {
|
|
|
108363
108519
|
|
|
108364
108520
|
|
|
108365
108521
|
|
|
108522
|
+
|
|
108366
108523
|
|
|
108367
108524
|
|
|
108368
108525
|
const defaultTransformers = [
|
|
@@ -108482,24 +108639,15 @@ function mdxishMdastToMd(mdast) {
|
|
|
108482
108639
|
.use(remarkStringify, stringifyOptions);
|
|
108483
108640
|
return processor.stringify(processor.runSync(mdast));
|
|
108484
108641
|
}
|
|
108485
|
-
/**
|
|
108486
|
-
|
|
108487
|
-
* Detects and renders custom component tags from the components hash.
|
|
108488
|
-
*
|
|
108489
|
-
* @see .claude/context/MDXish/Processor Overview.md
|
|
108490
|
-
*/
|
|
108491
|
-
function mdxish(mdContent, opts = {}) {
|
|
108642
|
+
/** The steps `mdxish()` runs after parsing; run it on the parse's VFile, since steps read `file.data`. */
|
|
108643
|
+
function mdxishRenderProcessor(opts = {}) {
|
|
108492
108644
|
const { components: userComponents = {}, hardBreaks: enableHardBreaks = true, safeMode = false, sanitize = false, variables, } = opts;
|
|
108493
108645
|
const components = {
|
|
108494
108646
|
...loadComponents(),
|
|
108495
108647
|
...userComponents,
|
|
108496
108648
|
};
|
|
108497
|
-
|
|
108498
|
-
|
|
108499
|
-
const withoutComments = removeJSXComments(protectedContent);
|
|
108500
|
-
const contentWithoutComments = restoreCodeBlocks(withoutComments, protectedCode);
|
|
108501
|
-
const { processor, parserReadyContent } = mdxishAstProcessor(contentWithoutComments, opts);
|
|
108502
|
-
processor
|
|
108649
|
+
return unified()
|
|
108650
|
+
.use(heading_ids)
|
|
108503
108651
|
.use(safeMode ? undefined : evaluate_exports, { sanitize }) // Evaluate `export const/function` and stash scope on file.data.mdxishScope
|
|
108504
108652
|
.use(enableHardBreaks ? hard_breaks : undefined) // Must precede evaluateExpressions to avoid splitting the \n in an evaluated template literal into a <br> node
|
|
108505
108653
|
.use(safeMode ? undefined : evaluate_expressions, { components, variables }) // Evaluate self-contained MDX expressions (e.g. `{1+1}`)
|
|
@@ -108517,11 +108665,25 @@ function mdxish(mdContent, opts = {}) {
|
|
|
108517
108665
|
.use(heading_slugs)
|
|
108518
108666
|
.use(rehypeMdxishComponents, {
|
|
108519
108667
|
components,
|
|
108668
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define -- component bodies render through mdxish() again
|
|
108520
108669
|
processMarkdown: (markdown) => mdxish(markdown, opts),
|
|
108521
108670
|
});
|
|
108671
|
+
}
|
|
108672
|
+
/**
|
|
108673
|
+
* Processes markdown content with MDX syntax support and returns a HAST.
|
|
108674
|
+
* Detects and renders custom component tags from the components hash.
|
|
108675
|
+
*
|
|
108676
|
+
* @see .claude/context/MDXish/Processor Overview.md
|
|
108677
|
+
*/
|
|
108678
|
+
function mdxish(mdContent, opts = {}) {
|
|
108679
|
+
// Remove JSX comments before processing (protect code blocks first)
|
|
108680
|
+
const { protectedCode, protectedContent } = protectCodeBlocks(mdContent);
|
|
108681
|
+
const withoutComments = removeJSXComments(protectedContent);
|
|
108682
|
+
const contentWithoutComments = restoreCodeBlocks(withoutComments, protectedCode);
|
|
108683
|
+
const { processor, parserReadyContent } = mdxishAstProcessor(contentWithoutComments, opts);
|
|
108522
108684
|
const vfile = new VFile({ value: parserReadyContent });
|
|
108523
|
-
const mdast = processor.parse(parserReadyContent);
|
|
108524
|
-
const hast =
|
|
108685
|
+
const mdast = processor.runSync(processor.parse(parserReadyContent), vfile);
|
|
108686
|
+
const hast = mdxishRenderProcessor(opts).runSync(mdast, vfile);
|
|
108525
108687
|
if (!hast) {
|
|
108526
108688
|
throw new Error('Markdown pipeline did not produce a HAST tree.');
|
|
108527
108689
|
}
|
|
@@ -108546,6 +108708,134 @@ const mix = (text, opts = {}) => {
|
|
|
108546
108708
|
};
|
|
108547
108709
|
/* harmony default export */ const lib_mix = (mix);
|
|
108548
108710
|
|
|
108711
|
+
;// ./lib/mdxishHeadingIds.ts
|
|
108712
|
+
|
|
108713
|
+
|
|
108714
|
+
|
|
108715
|
+
|
|
108716
|
+
|
|
108717
|
+
|
|
108718
|
+
|
|
108719
|
+
|
|
108720
|
+
const HEADING_INDEX = 'dataMdxishHeadingIndex';
|
|
108721
|
+
const HEADING_TAG_REGEX = /^h[1-6]$/;
|
|
108722
|
+
const JSX_COMMENT_ONLY_REGEX = new RegExp(`^${JSX_COMMENT_REGEX.source}$`);
|
|
108723
|
+
const isExpression = (node) => node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression';
|
|
108724
|
+
function collectHeadings(tree) {
|
|
108725
|
+
const headings = [];
|
|
108726
|
+
visit(tree, 'heading', (node) => {
|
|
108727
|
+
headings.push(node);
|
|
108728
|
+
});
|
|
108729
|
+
return headings;
|
|
108730
|
+
}
|
|
108731
|
+
function literalValue(source) {
|
|
108732
|
+
try {
|
|
108733
|
+
return { value: evaluateLiteralExpression(source) };
|
|
108734
|
+
}
|
|
108735
|
+
catch {
|
|
108736
|
+
return null;
|
|
108737
|
+
}
|
|
108738
|
+
}
|
|
108739
|
+
function trimHeadingText(heading) {
|
|
108740
|
+
const first = heading.children[0];
|
|
108741
|
+
if (first?.type === 'text')
|
|
108742
|
+
first.value = first.value.trimStart();
|
|
108743
|
+
const last = heading.children.at(-1);
|
|
108744
|
+
if (last?.type === 'text')
|
|
108745
|
+
last.value = last.value.trimEnd();
|
|
108746
|
+
}
|
|
108747
|
+
const isNamePath = (node) => node.type === 'Identifier' ||
|
|
108748
|
+
(node.type === 'MemberExpression' && !node.computed && !!node.object && isNamePath(node.object));
|
|
108749
|
+
// A name like `{price}` or `{plan.name}` can only read a value, never build an element. Code the parser
|
|
108750
|
+
// rejects can't run at all, so the hub shows it as text.
|
|
108751
|
+
function canBuildElements(source) {
|
|
108752
|
+
try {
|
|
108753
|
+
return !isNamePath(jsxAcornParser.parseExpressionAt(source, 0, { ecmaVersion: 'latest' }));
|
|
108754
|
+
}
|
|
108755
|
+
catch {
|
|
108756
|
+
return false;
|
|
108757
|
+
}
|
|
108758
|
+
}
|
|
108759
|
+
const isHeadingElement = (node) => isMDXElement(node) && HEADING_TAG_REGEX.test(node.name ?? '');
|
|
108760
|
+
// An expression the hub has to run changes a heading from inside one (Markdown or an HTML heading tag), by
|
|
108761
|
+
// building an element (a call or JSX), or as a block: alone in its paragraph, its result is lifted out as one.
|
|
108762
|
+
function canChangeHeadings(node, ancestors, heading) {
|
|
108763
|
+
if (heading || ancestors.some(isHeadingElement) || node.type === 'mdxFlowExpression' || canBuildElements(node.value))
|
|
108764
|
+
return true;
|
|
108765
|
+
const parent = ancestors[ancestors.length - 1];
|
|
108766
|
+
return parent.children.every(child => child === node || (child.type === 'text' && !child.value.trim()));
|
|
108767
|
+
}
|
|
108768
|
+
// Safe mode leaves `<h2 id={...}>` without the id the hub evaluates, which shifts the numbering.
|
|
108769
|
+
function hasEvaluatedHeadingAttribute(tree) {
|
|
108770
|
+
let found = false;
|
|
108771
|
+
visit(tree, isHeadingElement, (node) => {
|
|
108772
|
+
found = node.attributes.some(attribute => attribute.type === 'mdxJsxExpressionAttribute' || typeof attribute.value === 'object');
|
|
108773
|
+
return found ? (/* inlined export .EXIT */false) : undefined;
|
|
108774
|
+
});
|
|
108775
|
+
return found;
|
|
108776
|
+
}
|
|
108777
|
+
// Matches what the hub renders without running code: comments are stripped and plain literals become their
|
|
108778
|
+
// text. `false` when an expression that needs running could change the headings.
|
|
108779
|
+
function settleExpressions(tree) {
|
|
108780
|
+
const edits = [];
|
|
108781
|
+
let settled = true;
|
|
108782
|
+
visitParents(tree, isExpression, (node, ancestors) => {
|
|
108783
|
+
const heading = ancestors.find((ancestor) => ancestor.type === 'heading');
|
|
108784
|
+
const parent = ancestors[ancestors.length - 1];
|
|
108785
|
+
if (JSX_COMMENT_ONLY_REGEX.test(`{${node.value}}`)) {
|
|
108786
|
+
edits.push({ heading, node, parent, replacement: null });
|
|
108787
|
+
return;
|
|
108788
|
+
}
|
|
108789
|
+
const literal = literalValue(node.value);
|
|
108790
|
+
if (literal) {
|
|
108791
|
+
edits.push({ heading, node, parent, replacement: createTextNode(literal.value, node.position) });
|
|
108792
|
+
return;
|
|
108793
|
+
}
|
|
108794
|
+
if (canChangeHeadings(node, ancestors, heading))
|
|
108795
|
+
settled = false;
|
|
108796
|
+
});
|
|
108797
|
+
const apply = ({ node, parent, replacement }) => {
|
|
108798
|
+
parent.children.splice(parent.children.indexOf(node), 1, ...(replacement ? [replacement] : []));
|
|
108799
|
+
};
|
|
108800
|
+
// Comments go first: the hub strips them from the source, so the parser trims only the source
|
|
108801
|
+
// whitespace around them, never the spaces a literal adds.
|
|
108802
|
+
edits
|
|
108803
|
+
.filter(edit => !edit.replacement)
|
|
108804
|
+
.forEach(edit => {
|
|
108805
|
+
apply(edit);
|
|
108806
|
+
if (edit.heading)
|
|
108807
|
+
trimHeadingText(edit.heading);
|
|
108808
|
+
});
|
|
108809
|
+
edits.filter(edit => edit.replacement).forEach(apply);
|
|
108810
|
+
return settled;
|
|
108811
|
+
}
|
|
108812
|
+
/** Each heading's rendered anchor id, worked out without running code; `null` when code could change them. */
|
|
108813
|
+
function mdxishHeadingIds(tree, opts = {}) {
|
|
108814
|
+
const headings = collectHeadings(tree);
|
|
108815
|
+
if (headings.length === 0)
|
|
108816
|
+
return new Map();
|
|
108817
|
+
const copy = structuredClone(tree);
|
|
108818
|
+
let hasExport = false;
|
|
108819
|
+
visit(copy, 'mdxjsEsm', () => {
|
|
108820
|
+
hasExport = true;
|
|
108821
|
+
});
|
|
108822
|
+
// An `export` can define components that render headings.
|
|
108823
|
+
if (hasExport || hasEvaluatedHeadingAttribute(copy) || !settleExpressions(copy))
|
|
108824
|
+
return null;
|
|
108825
|
+
collectHeadings(copy).forEach((heading, index) => {
|
|
108826
|
+
heading.data = { ...heading.data, hProperties: { ...heading.data?.hProperties, [HEADING_INDEX]: index } };
|
|
108827
|
+
});
|
|
108828
|
+
const hast = mdxishRenderProcessor({ ...opts, safeMode: true }).runSync(copy, new VFile());
|
|
108829
|
+
const ids = new Map();
|
|
108830
|
+
visit(hast, 'element', (node) => {
|
|
108831
|
+
const index = node.properties[HEADING_INDEX];
|
|
108832
|
+
if (index === undefined || typeof node.properties.id !== 'string')
|
|
108833
|
+
return;
|
|
108834
|
+
ids.set(headings[Number(index)], node.properties.id);
|
|
108835
|
+
});
|
|
108836
|
+
return ids;
|
|
108837
|
+
}
|
|
108838
|
+
|
|
108549
108839
|
;// ./lib/extractToc.ts
|
|
108550
108840
|
|
|
108551
108841
|
/* harmony default export */ const lib_extractToc = (extractToc);
|
|
@@ -108758,8 +109048,10 @@ function exportComponentsForRehype(components) {
|
|
|
108758
109048
|
* deliberately leaves mermaid alone; resolving it again here would override that.
|
|
108759
109049
|
*/
|
|
108760
109050
|
const CODE_TAG_NAMES = new Set(['code']);
|
|
109051
|
+
const isImageAlt = (tagName, key) => tagName === 'img' && key === 'alt';
|
|
108761
109052
|
/**
|
|
108762
|
-
* Resolve `{user.*}` in string-valued props
|
|
109053
|
+
* Resolve `{user.*}` in string-valued props, plus legacy `<<...>>` in img alt, where markdown flattens
|
|
109054
|
+
* body variables to text (RM-10865). Body text is handled by the `Variable` component, but
|
|
108763
109055
|
* attributes are plain strings, so they are substituted here — at render time, so that a
|
|
108764
109056
|
* server-parsed (user-agnostic) tree resolves against the current reader's variables.
|
|
108765
109057
|
*/
|
|
@@ -108769,7 +109061,7 @@ function resolveVariablesInProps(props, user, tagName) {
|
|
|
108769
109061
|
const isDocumentContent = RAW_HTML_PROP_NAMES.has(key) || (isCodeTag && key === 'value');
|
|
108770
109062
|
if (typeof value !== 'string' || isDocumentContent)
|
|
108771
109063
|
return [key, value];
|
|
108772
|
-
return [key, resolveAttributeVariables(value, user)];
|
|
109064
|
+
return [key, resolveAttributeVariables(value, user, isImageAlt(tagName, key))];
|
|
108773
109065
|
});
|
|
108774
109066
|
return Object.fromEntries(resolvedEntries);
|
|
108775
109067
|
}
|
|
@@ -109163,6 +109455,7 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
|
109163
109455
|
|
|
109164
109456
|
|
|
109165
109457
|
|
|
109458
|
+
|
|
109166
109459
|
|
|
109167
109460
|
;// ./index.tsx
|
|
109168
109461
|
|
|
@@ -109459,7 +109752,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"*":["about","acceptCharset","accessK
|
|
|
109459
109752
|
/******/ // startup
|
|
109460
109753
|
/******/ // Load entry module and return exports
|
|
109461
109754
|
/******/ // This entry module used 'module' so it can't be inlined
|
|
109462
|
-
/******/ let __webpack_exports__ = __webpack_require__(
|
|
109755
|
+
/******/ let __webpack_exports__ = __webpack_require__(9477);
|
|
109463
109756
|
/******/
|
|
109464
109757
|
/******/ return __webpack_exports__;
|
|
109465
109758
|
/******/ })()
|