@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
|
@@ -19111,7 +19111,7 @@ module.exports = function () {
|
|
|
19111
19111
|
|
|
19112
19112
|
/***/ },
|
|
19113
19113
|
|
|
19114
|
-
/***/
|
|
19114
|
+
/***/ 5919
|
|
19115
19115
|
(module, __webpack_exports__, __webpack_require__) {
|
|
19116
19116
|
|
|
19117
19117
|
"use strict";
|
|
@@ -68716,6 +68716,209 @@ const mdast = (text, opts = {}) => {
|
|
|
68716
68716
|
};
|
|
68717
68717
|
/* harmony default export */ const lib_mdast = (mdast);
|
|
68718
68718
|
|
|
68719
|
+
;// ./node_modules/micromark-util-symbol/lib/codes.js
|
|
68720
|
+
/**
|
|
68721
|
+
* Character codes.
|
|
68722
|
+
*
|
|
68723
|
+
* This module is compiled away!
|
|
68724
|
+
*
|
|
68725
|
+
* micromark works based on character codes.
|
|
68726
|
+
* This module contains constants for the ASCII block and the replacement
|
|
68727
|
+
* character.
|
|
68728
|
+
* A couple of them are handled in a special way, such as the line endings
|
|
68729
|
+
* (CR, LF, and CR+LF, commonly known as end-of-line: EOLs), the tab (horizontal
|
|
68730
|
+
* tab) and its expansion based on what column it’s at (virtual space),
|
|
68731
|
+
* and the end-of-file (eof) character.
|
|
68732
|
+
* As values are preprocessed before handling them, the actual characters LF,
|
|
68733
|
+
* CR, HT, and NUL (which is present as the replacement character), are
|
|
68734
|
+
* guaranteed to not exist.
|
|
68735
|
+
*
|
|
68736
|
+
* Unicode basic latin block.
|
|
68737
|
+
*/
|
|
68738
|
+
const codes = /** @type {const} */ ({
|
|
68739
|
+
carriageReturn: -5,
|
|
68740
|
+
lineFeed: -4,
|
|
68741
|
+
carriageReturnLineFeed: -3,
|
|
68742
|
+
horizontalTab: -2,
|
|
68743
|
+
virtualSpace: -1,
|
|
68744
|
+
eof: null,
|
|
68745
|
+
nul: 0,
|
|
68746
|
+
soh: 1,
|
|
68747
|
+
stx: 2,
|
|
68748
|
+
etx: 3,
|
|
68749
|
+
eot: 4,
|
|
68750
|
+
enq: 5,
|
|
68751
|
+
ack: 6,
|
|
68752
|
+
bel: 7,
|
|
68753
|
+
bs: 8,
|
|
68754
|
+
ht: 9, // `\t`
|
|
68755
|
+
lf: 10, // `\n`
|
|
68756
|
+
vt: 11, // `\v`
|
|
68757
|
+
ff: 12, // `\f`
|
|
68758
|
+
cr: 13, // `\r`
|
|
68759
|
+
so: 14,
|
|
68760
|
+
si: 15,
|
|
68761
|
+
dle: 16,
|
|
68762
|
+
dc1: 17,
|
|
68763
|
+
dc2: 18,
|
|
68764
|
+
dc3: 19,
|
|
68765
|
+
dc4: 20,
|
|
68766
|
+
nak: 21,
|
|
68767
|
+
syn: 22,
|
|
68768
|
+
etb: 23,
|
|
68769
|
+
can: 24,
|
|
68770
|
+
em: 25,
|
|
68771
|
+
sub: 26,
|
|
68772
|
+
esc: 27,
|
|
68773
|
+
fs: 28,
|
|
68774
|
+
gs: 29,
|
|
68775
|
+
rs: 30,
|
|
68776
|
+
us: 31,
|
|
68777
|
+
space: 32,
|
|
68778
|
+
exclamationMark: 33, // `!`
|
|
68779
|
+
quotationMark: 34, // `"`
|
|
68780
|
+
numberSign: 35, // `#`
|
|
68781
|
+
dollarSign: 36, // `$`
|
|
68782
|
+
percentSign: 37, // `%`
|
|
68783
|
+
ampersand: 38, // `&`
|
|
68784
|
+
apostrophe: 39, // `'`
|
|
68785
|
+
leftParenthesis: 40, // `(`
|
|
68786
|
+
rightParenthesis: 41, // `)`
|
|
68787
|
+
asterisk: 42, // `*`
|
|
68788
|
+
plusSign: 43, // `+`
|
|
68789
|
+
comma: 44, // `,`
|
|
68790
|
+
dash: 45, // `-`
|
|
68791
|
+
dot: 46, // `.`
|
|
68792
|
+
slash: 47, // `/`
|
|
68793
|
+
digit0: 48, // `0`
|
|
68794
|
+
digit1: 49, // `1`
|
|
68795
|
+
digit2: 50, // `2`
|
|
68796
|
+
digit3: 51, // `3`
|
|
68797
|
+
digit4: 52, // `4`
|
|
68798
|
+
digit5: 53, // `5`
|
|
68799
|
+
digit6: 54, // `6`
|
|
68800
|
+
digit7: 55, // `7`
|
|
68801
|
+
digit8: 56, // `8`
|
|
68802
|
+
digit9: 57, // `9`
|
|
68803
|
+
colon: 58, // `:`
|
|
68804
|
+
semicolon: 59, // `;`
|
|
68805
|
+
lessThan: 60, // `<`
|
|
68806
|
+
equalsTo: 61, // `=`
|
|
68807
|
+
greaterThan: 62, // `>`
|
|
68808
|
+
questionMark: 63, // `?`
|
|
68809
|
+
atSign: 64, // `@`
|
|
68810
|
+
uppercaseA: 65, // `A`
|
|
68811
|
+
uppercaseB: 66, // `B`
|
|
68812
|
+
uppercaseC: 67, // `C`
|
|
68813
|
+
uppercaseD: 68, // `D`
|
|
68814
|
+
uppercaseE: 69, // `E`
|
|
68815
|
+
uppercaseF: 70, // `F`
|
|
68816
|
+
uppercaseG: 71, // `G`
|
|
68817
|
+
uppercaseH: 72, // `H`
|
|
68818
|
+
uppercaseI: 73, // `I`
|
|
68819
|
+
uppercaseJ: 74, // `J`
|
|
68820
|
+
uppercaseK: 75, // `K`
|
|
68821
|
+
uppercaseL: 76, // `L`
|
|
68822
|
+
uppercaseM: 77, // `M`
|
|
68823
|
+
uppercaseN: 78, // `N`
|
|
68824
|
+
uppercaseO: 79, // `O`
|
|
68825
|
+
uppercaseP: 80, // `P`
|
|
68826
|
+
uppercaseQ: 81, // `Q`
|
|
68827
|
+
uppercaseR: 82, // `R`
|
|
68828
|
+
uppercaseS: 83, // `S`
|
|
68829
|
+
uppercaseT: 84, // `T`
|
|
68830
|
+
uppercaseU: 85, // `U`
|
|
68831
|
+
uppercaseV: 86, // `V`
|
|
68832
|
+
uppercaseW: 87, // `W`
|
|
68833
|
+
uppercaseX: 88, // `X`
|
|
68834
|
+
uppercaseY: 89, // `Y`
|
|
68835
|
+
uppercaseZ: 90, // `Z`
|
|
68836
|
+
leftSquareBracket: 91, // `[`
|
|
68837
|
+
backslash: 92, // `\`
|
|
68838
|
+
rightSquareBracket: 93, // `]`
|
|
68839
|
+
caret: 94, // `^`
|
|
68840
|
+
underscore: 95, // `_`
|
|
68841
|
+
graveAccent: 96, // `` ` ``
|
|
68842
|
+
lowercaseA: 97, // `a`
|
|
68843
|
+
lowercaseB: 98, // `b`
|
|
68844
|
+
lowercaseC: 99, // `c`
|
|
68845
|
+
lowercaseD: 100, // `d`
|
|
68846
|
+
lowercaseE: 101, // `e`
|
|
68847
|
+
lowercaseF: 102, // `f`
|
|
68848
|
+
lowercaseG: 103, // `g`
|
|
68849
|
+
lowercaseH: 104, // `h`
|
|
68850
|
+
lowercaseI: 105, // `i`
|
|
68851
|
+
lowercaseJ: 106, // `j`
|
|
68852
|
+
lowercaseK: 107, // `k`
|
|
68853
|
+
lowercaseL: 108, // `l`
|
|
68854
|
+
lowercaseM: 109, // `m`
|
|
68855
|
+
lowercaseN: 110, // `n`
|
|
68856
|
+
lowercaseO: 111, // `o`
|
|
68857
|
+
lowercaseP: 112, // `p`
|
|
68858
|
+
lowercaseQ: 113, // `q`
|
|
68859
|
+
lowercaseR: 114, // `r`
|
|
68860
|
+
lowercaseS: 115, // `s`
|
|
68861
|
+
lowercaseT: 116, // `t`
|
|
68862
|
+
lowercaseU: 117, // `u`
|
|
68863
|
+
lowercaseV: 118, // `v`
|
|
68864
|
+
lowercaseW: 119, // `w`
|
|
68865
|
+
lowercaseX: 120, // `x`
|
|
68866
|
+
lowercaseY: 121, // `y`
|
|
68867
|
+
lowercaseZ: 122, // `z`
|
|
68868
|
+
leftCurlyBrace: 123, // `{`
|
|
68869
|
+
verticalBar: 124, // `|`
|
|
68870
|
+
rightCurlyBrace: 125, // `}`
|
|
68871
|
+
tilde: 126, // `~`
|
|
68872
|
+
del: 127,
|
|
68873
|
+
// Unicode Specials block.
|
|
68874
|
+
byteOrderMarker: 65_279,
|
|
68875
|
+
// Unicode Specials block.
|
|
68876
|
+
replacementCharacter: 65_533 // `�`
|
|
68877
|
+
})
|
|
68878
|
+
|
|
68879
|
+
;// ./lib/micromark/heading-id/syntax.ts
|
|
68880
|
+
|
|
68881
|
+
|
|
68882
|
+
/** One character a `{#id}` heading id may use: the ones github-slugger keeps, plus `.` and `:`. */
|
|
68883
|
+
const HEADING_ID_CHAR = '[\\p{L}\\p{M}\\p{N}_.:-]';
|
|
68884
|
+
const ID_CLOSE_REGEX = new RegExp(`^${HEADING_ID_CHAR}+\\}$`, 'u');
|
|
68885
|
+
const typeAt = (events, index) => events[index]?.[1].type;
|
|
68886
|
+
function isIdToken(events, index, context, type, value) {
|
|
68887
|
+
return typeAt(events, index) === type && value.test(context.sliceSerialize(events[index][1]));
|
|
68888
|
+
}
|
|
68889
|
+
/** The exit index of the heading's last content token, past any trailing space and closing `##`. */
|
|
68890
|
+
function contentEnd(events) {
|
|
68891
|
+
let end = events.length - 2;
|
|
68892
|
+
if (typeAt(events, end) === 'whitespace')
|
|
68893
|
+
end -= 2;
|
|
68894
|
+
if (typeAt(events, end) === 'atxHeadingSequence' && typeAt(events, end - 2) === 'whitespace')
|
|
68895
|
+
end -= 4;
|
|
68896
|
+
return end;
|
|
68897
|
+
}
|
|
68898
|
+
const resolveHeadingId = (events, context) => {
|
|
68899
|
+
// Each token is an enter and an exit event; these indexes point at the exits.
|
|
68900
|
+
const close = contentEnd(events);
|
|
68901
|
+
const hash = close - 2;
|
|
68902
|
+
const open = close - 4;
|
|
68903
|
+
const space = close - 6;
|
|
68904
|
+
const endsWithId = isIdToken(events, close, context, 'atxHeadingText', ID_CLOSE_REGEX) &&
|
|
68905
|
+
isIdToken(events, hash, context, 'atxHeadingSequence', /^#$/) &&
|
|
68906
|
+
isIdToken(events, open, context, 'atxHeadingText', /^\{$/) &&
|
|
68907
|
+
typeAt(events, space) === 'whitespace';
|
|
68908
|
+
if (!endsWithId)
|
|
68909
|
+
return headingAtx.resolve?.(events, context) ?? events;
|
|
68910
|
+
const id = { type: 'headingId', start: events[open][1].start, end: events[close][1].end };
|
|
68911
|
+
events.splice(space - 1, close - space + 2);
|
|
68912
|
+
const resolved = headingAtx.resolve?.(events, context) ?? events;
|
|
68913
|
+
resolved.splice(resolved.length - 1, 0, ['enter', id, context], ['exit', id, context]);
|
|
68914
|
+
return resolved;
|
|
68915
|
+
};
|
|
68916
|
+
const headingIdConstruct = { ...headingAtx, resolve: resolveHeadingId };
|
|
68917
|
+
/** The ATX heading construct, with a line-final ` {#id}` split off as a `headingId` token. */
|
|
68918
|
+
function headingId() {
|
|
68919
|
+
return { flow: { [codes.numberSign]: headingIdConstruct } };
|
|
68920
|
+
}
|
|
68921
|
+
|
|
68719
68922
|
;// ./lib/utils/jsx-acorn-parser.ts
|
|
68720
68923
|
|
|
68721
68924
|
|
|
@@ -68827,6 +69030,7 @@ const evaluateLiteralExpression = (source) => {
|
|
|
68827
69030
|
|
|
68828
69031
|
|
|
68829
69032
|
|
|
69033
|
+
|
|
68830
69034
|
/**
|
|
68831
69035
|
* Evaluate a JavaScript expression source and return its value.
|
|
68832
69036
|
*
|
|
@@ -68943,6 +69147,24 @@ const getHPropKeys = (node) => {
|
|
|
68943
69147
|
const hProps = getHProps(node);
|
|
68944
69148
|
return Object.keys(hProps) || [];
|
|
68945
69149
|
};
|
|
69150
|
+
/** Turn a non-renderable evaluation result into a text node. */
|
|
69151
|
+
const createTextNode = (result, position) => {
|
|
69152
|
+
if (result === null || result === undefined)
|
|
69153
|
+
return { type: 'text', value: '', position };
|
|
69154
|
+
if (typeof result === 'object')
|
|
69155
|
+
return { type: 'text', value: JSON.stringify(result), position };
|
|
69156
|
+
return { type: 'text', value: String(result), position };
|
|
69157
|
+
};
|
|
69158
|
+
const HEADING_ID_REGEX = new RegExp(`^${HEADING_ID_CHAR}+$`, 'u');
|
|
69159
|
+
/**
|
|
69160
|
+
* The id a heading's trailing `{#id}` set, when it is one the `{#id}` syntax can spell.
|
|
69161
|
+
*
|
|
69162
|
+
* Ids may use letters, numbers, `-`, `_`, `.` and `:`; anything else, like `x y`, is dropped.
|
|
69163
|
+
*/
|
|
69164
|
+
const explicitHeadingId = (node) => {
|
|
69165
|
+
const id = node.data?.hProperties?.id;
|
|
69166
|
+
return typeof id === 'string' && HEADING_ID_REGEX.test(id) ? id : undefined;
|
|
69167
|
+
};
|
|
68946
69168
|
/**
|
|
68947
69169
|
* Gets the attributes of an MDX element and returns them as an object of hProperties.
|
|
68948
69170
|
*
|
|
@@ -93266,6 +93488,26 @@ const mdxToHast = () => tree => {
|
|
|
93266
93488
|
};
|
|
93267
93489
|
/* harmony default export */ const mdx_to_hast = ((/* unused pure expression or super */ null && (mdxToHast)));
|
|
93268
93490
|
|
|
93491
|
+
;// ./lib/mdast-util/mdx-expression/index.ts
|
|
93492
|
+
|
|
93493
|
+
const upstream = mdxExpressionFromMarkdown();
|
|
93494
|
+
/**
|
|
93495
|
+
* An image's alt is its label flattened to text, which drops an expression's braces. Keep the
|
|
93496
|
+
* `{...}` source there so `{user.*}` still resolves in alt at render time (RM-10865).
|
|
93497
|
+
*/
|
|
93498
|
+
function exitTextExpression(token) {
|
|
93499
|
+
upstream.exit.mdxTextExpression.call(this, token);
|
|
93500
|
+
if (!this.stack.some(node => node.type === 'image'))
|
|
93501
|
+
return;
|
|
93502
|
+
const { children } = this.stack[this.stack.length - 1];
|
|
93503
|
+
const { position } = children[children.length - 1];
|
|
93504
|
+
children[children.length - 1] = { type: 'text', value: this.sliceSerialize(token), position };
|
|
93505
|
+
}
|
|
93506
|
+
/** Upstream `mdxExpressionFromMarkdown`, overriding only the text-expression exit to keep `{...}` source in image alt. */
|
|
93507
|
+
function mdxishExpressionFromMarkdown() {
|
|
93508
|
+
return { ...upstream, exit: { ...upstream.exit, mdxTextExpression: exitTextExpression } };
|
|
93509
|
+
}
|
|
93510
|
+
|
|
93269
93511
|
;// ./lib/mdast-util/empty-task-list-item/index.ts
|
|
93270
93512
|
/**
|
|
93271
93513
|
* Normalizes list items that are written as only `[ ]` or `[x]` into GFM task
|
|
@@ -93372,6 +93614,17 @@ function gemojiFromMarkdown() {
|
|
|
93372
93614
|
};
|
|
93373
93615
|
}
|
|
93374
93616
|
|
|
93617
|
+
;// ./lib/mdast-util/heading-id/index.ts
|
|
93618
|
+
function exitHeadingId(token) {
|
|
93619
|
+
const heading = this.stack[this.stack.length - 1];
|
|
93620
|
+
const id = this.sliceSerialize(token).slice('{#'.length, -'}'.length);
|
|
93621
|
+
heading.data = { ...heading.data, hProperties: { ...heading.data?.hProperties, id } };
|
|
93622
|
+
}
|
|
93623
|
+
/** Sets a heading's id from its `headingId` token. */
|
|
93624
|
+
function headingIdFromMarkdown() {
|
|
93625
|
+
return { exit: { headingId: exitHeadingId } };
|
|
93626
|
+
}
|
|
93627
|
+
|
|
93375
93628
|
;// ./lib/mdast-util/html-block-component/index.ts
|
|
93376
93629
|
const contextMap = new WeakMap();
|
|
93377
93630
|
function findHtmlBlockComponentToken() {
|
|
@@ -93498,6 +93751,16 @@ function exitlegacyVariableValue(token) {
|
|
|
93498
93751
|
function exitlegacyVariable(token) {
|
|
93499
93752
|
const ctx = legacy_variable_contextMap.get(token);
|
|
93500
93753
|
const serialized = this.sliceSerialize(token);
|
|
93754
|
+
// An escaped `\<<name>>` (or `\<<name\>>`) is literal text, as in the legacy parser.
|
|
93755
|
+
if (serialized.startsWith('\\')) {
|
|
93756
|
+
const literal = serialized.slice(1).replace('\\>>', '>>');
|
|
93757
|
+
// An image's alt is flattened to a string, so keep the escape for render-time resolution to honor.
|
|
93758
|
+
const inImageAlt = this.stack.some(node => node.type === 'image');
|
|
93759
|
+
this.enter({ type: 'text', value: inImageAlt ? `\\${literal}` : literal }, token);
|
|
93760
|
+
this.exit(token);
|
|
93761
|
+
legacy_variable_contextMap.delete(token);
|
|
93762
|
+
return;
|
|
93763
|
+
}
|
|
93501
93764
|
const variableName = serialized.startsWith('<<') && serialized.endsWith('>>')
|
|
93502
93765
|
? serialized.slice(2, -2)
|
|
93503
93766
|
: ctx?.value ?? '';
|
|
@@ -93740,166 +94003,6 @@ function mdxComponentFromMarkdown() {
|
|
|
93740
94003
|
};
|
|
93741
94004
|
}
|
|
93742
94005
|
|
|
93743
|
-
;// ./node_modules/micromark-util-symbol/lib/codes.js
|
|
93744
|
-
/**
|
|
93745
|
-
* Character codes.
|
|
93746
|
-
*
|
|
93747
|
-
* This module is compiled away!
|
|
93748
|
-
*
|
|
93749
|
-
* micromark works based on character codes.
|
|
93750
|
-
* This module contains constants for the ASCII block and the replacement
|
|
93751
|
-
* character.
|
|
93752
|
-
* A couple of them are handled in a special way, such as the line endings
|
|
93753
|
-
* (CR, LF, and CR+LF, commonly known as end-of-line: EOLs), the tab (horizontal
|
|
93754
|
-
* tab) and its expansion based on what column it’s at (virtual space),
|
|
93755
|
-
* and the end-of-file (eof) character.
|
|
93756
|
-
* As values are preprocessed before handling them, the actual characters LF,
|
|
93757
|
-
* CR, HT, and NUL (which is present as the replacement character), are
|
|
93758
|
-
* guaranteed to not exist.
|
|
93759
|
-
*
|
|
93760
|
-
* Unicode basic latin block.
|
|
93761
|
-
*/
|
|
93762
|
-
const codes = /** @type {const} */ ({
|
|
93763
|
-
carriageReturn: -5,
|
|
93764
|
-
lineFeed: -4,
|
|
93765
|
-
carriageReturnLineFeed: -3,
|
|
93766
|
-
horizontalTab: -2,
|
|
93767
|
-
virtualSpace: -1,
|
|
93768
|
-
eof: null,
|
|
93769
|
-
nul: 0,
|
|
93770
|
-
soh: 1,
|
|
93771
|
-
stx: 2,
|
|
93772
|
-
etx: 3,
|
|
93773
|
-
eot: 4,
|
|
93774
|
-
enq: 5,
|
|
93775
|
-
ack: 6,
|
|
93776
|
-
bel: 7,
|
|
93777
|
-
bs: 8,
|
|
93778
|
-
ht: 9, // `\t`
|
|
93779
|
-
lf: 10, // `\n`
|
|
93780
|
-
vt: 11, // `\v`
|
|
93781
|
-
ff: 12, // `\f`
|
|
93782
|
-
cr: 13, // `\r`
|
|
93783
|
-
so: 14,
|
|
93784
|
-
si: 15,
|
|
93785
|
-
dle: 16,
|
|
93786
|
-
dc1: 17,
|
|
93787
|
-
dc2: 18,
|
|
93788
|
-
dc3: 19,
|
|
93789
|
-
dc4: 20,
|
|
93790
|
-
nak: 21,
|
|
93791
|
-
syn: 22,
|
|
93792
|
-
etb: 23,
|
|
93793
|
-
can: 24,
|
|
93794
|
-
em: 25,
|
|
93795
|
-
sub: 26,
|
|
93796
|
-
esc: 27,
|
|
93797
|
-
fs: 28,
|
|
93798
|
-
gs: 29,
|
|
93799
|
-
rs: 30,
|
|
93800
|
-
us: 31,
|
|
93801
|
-
space: 32,
|
|
93802
|
-
exclamationMark: 33, // `!`
|
|
93803
|
-
quotationMark: 34, // `"`
|
|
93804
|
-
numberSign: 35, // `#`
|
|
93805
|
-
dollarSign: 36, // `$`
|
|
93806
|
-
percentSign: 37, // `%`
|
|
93807
|
-
ampersand: 38, // `&`
|
|
93808
|
-
apostrophe: 39, // `'`
|
|
93809
|
-
leftParenthesis: 40, // `(`
|
|
93810
|
-
rightParenthesis: 41, // `)`
|
|
93811
|
-
asterisk: 42, // `*`
|
|
93812
|
-
plusSign: 43, // `+`
|
|
93813
|
-
comma: 44, // `,`
|
|
93814
|
-
dash: 45, // `-`
|
|
93815
|
-
dot: 46, // `.`
|
|
93816
|
-
slash: 47, // `/`
|
|
93817
|
-
digit0: 48, // `0`
|
|
93818
|
-
digit1: 49, // `1`
|
|
93819
|
-
digit2: 50, // `2`
|
|
93820
|
-
digit3: 51, // `3`
|
|
93821
|
-
digit4: 52, // `4`
|
|
93822
|
-
digit5: 53, // `5`
|
|
93823
|
-
digit6: 54, // `6`
|
|
93824
|
-
digit7: 55, // `7`
|
|
93825
|
-
digit8: 56, // `8`
|
|
93826
|
-
digit9: 57, // `9`
|
|
93827
|
-
colon: 58, // `:`
|
|
93828
|
-
semicolon: 59, // `;`
|
|
93829
|
-
lessThan: 60, // `<`
|
|
93830
|
-
equalsTo: 61, // `=`
|
|
93831
|
-
greaterThan: 62, // `>`
|
|
93832
|
-
questionMark: 63, // `?`
|
|
93833
|
-
atSign: 64, // `@`
|
|
93834
|
-
uppercaseA: 65, // `A`
|
|
93835
|
-
uppercaseB: 66, // `B`
|
|
93836
|
-
uppercaseC: 67, // `C`
|
|
93837
|
-
uppercaseD: 68, // `D`
|
|
93838
|
-
uppercaseE: 69, // `E`
|
|
93839
|
-
uppercaseF: 70, // `F`
|
|
93840
|
-
uppercaseG: 71, // `G`
|
|
93841
|
-
uppercaseH: 72, // `H`
|
|
93842
|
-
uppercaseI: 73, // `I`
|
|
93843
|
-
uppercaseJ: 74, // `J`
|
|
93844
|
-
uppercaseK: 75, // `K`
|
|
93845
|
-
uppercaseL: 76, // `L`
|
|
93846
|
-
uppercaseM: 77, // `M`
|
|
93847
|
-
uppercaseN: 78, // `N`
|
|
93848
|
-
uppercaseO: 79, // `O`
|
|
93849
|
-
uppercaseP: 80, // `P`
|
|
93850
|
-
uppercaseQ: 81, // `Q`
|
|
93851
|
-
uppercaseR: 82, // `R`
|
|
93852
|
-
uppercaseS: 83, // `S`
|
|
93853
|
-
uppercaseT: 84, // `T`
|
|
93854
|
-
uppercaseU: 85, // `U`
|
|
93855
|
-
uppercaseV: 86, // `V`
|
|
93856
|
-
uppercaseW: 87, // `W`
|
|
93857
|
-
uppercaseX: 88, // `X`
|
|
93858
|
-
uppercaseY: 89, // `Y`
|
|
93859
|
-
uppercaseZ: 90, // `Z`
|
|
93860
|
-
leftSquareBracket: 91, // `[`
|
|
93861
|
-
backslash: 92, // `\`
|
|
93862
|
-
rightSquareBracket: 93, // `]`
|
|
93863
|
-
caret: 94, // `^`
|
|
93864
|
-
underscore: 95, // `_`
|
|
93865
|
-
graveAccent: 96, // `` ` ``
|
|
93866
|
-
lowercaseA: 97, // `a`
|
|
93867
|
-
lowercaseB: 98, // `b`
|
|
93868
|
-
lowercaseC: 99, // `c`
|
|
93869
|
-
lowercaseD: 100, // `d`
|
|
93870
|
-
lowercaseE: 101, // `e`
|
|
93871
|
-
lowercaseF: 102, // `f`
|
|
93872
|
-
lowercaseG: 103, // `g`
|
|
93873
|
-
lowercaseH: 104, // `h`
|
|
93874
|
-
lowercaseI: 105, // `i`
|
|
93875
|
-
lowercaseJ: 106, // `j`
|
|
93876
|
-
lowercaseK: 107, // `k`
|
|
93877
|
-
lowercaseL: 108, // `l`
|
|
93878
|
-
lowercaseM: 109, // `m`
|
|
93879
|
-
lowercaseN: 110, // `n`
|
|
93880
|
-
lowercaseO: 111, // `o`
|
|
93881
|
-
lowercaseP: 112, // `p`
|
|
93882
|
-
lowercaseQ: 113, // `q`
|
|
93883
|
-
lowercaseR: 114, // `r`
|
|
93884
|
-
lowercaseS: 115, // `s`
|
|
93885
|
-
lowercaseT: 116, // `t`
|
|
93886
|
-
lowercaseU: 117, // `u`
|
|
93887
|
-
lowercaseV: 118, // `v`
|
|
93888
|
-
lowercaseW: 119, // `w`
|
|
93889
|
-
lowercaseX: 120, // `x`
|
|
93890
|
-
lowercaseY: 121, // `y`
|
|
93891
|
-
lowercaseZ: 122, // `z`
|
|
93892
|
-
leftCurlyBrace: 123, // `{`
|
|
93893
|
-
verticalBar: 124, // `|`
|
|
93894
|
-
rightCurlyBrace: 125, // `}`
|
|
93895
|
-
tilde: 126, // `~`
|
|
93896
|
-
del: 127,
|
|
93897
|
-
// Unicode Specials block.
|
|
93898
|
-
byteOrderMarker: 65_279,
|
|
93899
|
-
// Unicode Specials block.
|
|
93900
|
-
replacementCharacter: 65_533 // `�`
|
|
93901
|
-
})
|
|
93902
|
-
|
|
93903
94006
|
;// ./lib/micromark/gemoji/syntax.ts
|
|
93904
94007
|
|
|
93905
94008
|
// Matches the name pattern from the original regex: \+1 or [-\w]+
|
|
@@ -93987,6 +94090,9 @@ function syntax_gemoji() {
|
|
|
93987
94090
|
};
|
|
93988
94091
|
}
|
|
93989
94092
|
|
|
94093
|
+
;// ./lib/micromark/heading-id/index.ts
|
|
94094
|
+
|
|
94095
|
+
|
|
93990
94096
|
;// ./node_modules/micromark-util-symbol/lib/types.js
|
|
93991
94097
|
/**
|
|
93992
94098
|
* This module is compiled away!
|
|
@@ -95091,9 +95197,16 @@ const legacyVariableConstruct = {
|
|
|
95091
95197
|
function syntax_tokenize(effects, ok, nok) {
|
|
95092
95198
|
let hasValue = false;
|
|
95093
95199
|
const start = (code) => {
|
|
95200
|
+
effects.enter('legacyVariable');
|
|
95201
|
+
// Claim `\<<name>>` before CommonMark's character escape drops the backslash, as the legacy parser did.
|
|
95202
|
+
if (code !== codes.backslash)
|
|
95203
|
+
return open(code);
|
|
95204
|
+
effects.consume(code); // \
|
|
95205
|
+
return open;
|
|
95206
|
+
};
|
|
95207
|
+
const open = (code) => {
|
|
95094
95208
|
if (code !== codes.lessThan)
|
|
95095
95209
|
return nok(code);
|
|
95096
|
-
effects.enter('legacyVariable');
|
|
95097
95210
|
effects.enter('legacyVariableMarkerStart');
|
|
95098
95211
|
effects.consume(code); // <
|
|
95099
95212
|
return open2;
|
|
@@ -95133,7 +95246,7 @@ function syntax_tokenize(effects, ok, nok) {
|
|
|
95133
95246
|
}
|
|
95134
95247
|
function legacyVariable() {
|
|
95135
95248
|
return {
|
|
95136
|
-
text: { [codes.lessThan]: legacyVariableConstruct },
|
|
95249
|
+
text: { [codes.backslash]: legacyVariableConstruct, [codes.lessThan]: legacyVariableConstruct },
|
|
95137
95250
|
};
|
|
95138
95251
|
}
|
|
95139
95252
|
|
|
@@ -97429,6 +97542,8 @@ function mdxExpressionLenient() {
|
|
|
97429
97542
|
|
|
97430
97543
|
|
|
97431
97544
|
|
|
97545
|
+
|
|
97546
|
+
|
|
97432
97547
|
|
|
97433
97548
|
|
|
97434
97549
|
|
|
@@ -97457,17 +97572,19 @@ const REGISTRY = {
|
|
|
97457
97572
|
magicBlock: { syntax: magicBlock, fromMarkdown: magicBlockFromMarkdown },
|
|
97458
97573
|
// Two `{` tokenizers, never registered together: the document parser takes text
|
|
97459
97574
|
// only, the component-body re-parser needs flow too for multi-line expressions.
|
|
97460
|
-
mdxExpressionLenient: { syntax: mdxExpressionLenient, fromMarkdown:
|
|
97575
|
+
mdxExpressionLenient: { syntax: mdxExpressionLenient, fromMarkdown: mdxishExpressionFromMarkdown, expression: true },
|
|
97461
97576
|
// `allowEmpty` is the package default; passed explicitly because `mdx-jsx`
|
|
97462
97577
|
// registers the same tokenizer with it off for attribute expressions.
|
|
97463
97578
|
mdxExpression: {
|
|
97464
97579
|
syntax: () => mdxExpression({ allowEmpty: true }),
|
|
97465
|
-
fromMarkdown:
|
|
97580
|
+
fromMarkdown: mdxishExpressionFromMarkdown,
|
|
97466
97581
|
expression: true,
|
|
97467
97582
|
},
|
|
97468
97583
|
mdxComponent: { syntax: mdxComponent, fromMarkdown: mdxComponentFromMarkdown },
|
|
97469
97584
|
gemoji: { syntax: syntax_gemoji, fromMarkdown: gemojiFromMarkdown },
|
|
97470
97585
|
legacyVariable: { syntax: legacyVariable, fromMarkdown: legacyVariableFromMarkdown },
|
|
97586
|
+
// Replaces the ATX heading construct in `flow`, so it never touches prose outside a heading.
|
|
97587
|
+
headingId: { syntax: headingId, fromMarkdown: headingIdFromMarkdown },
|
|
97471
97588
|
looseHtmlEntity: { syntax: looseHtmlEntity, fromMarkdown: looseHtmlEntityFromMarkdown },
|
|
97472
97589
|
htmlBlockComponent: { syntax: htmlBlockComponent, fromMarkdown: htmlBlockComponentFromMarkdown },
|
|
97473
97590
|
// This is for in-document variable & function definitions
|
|
@@ -97498,18 +97615,13 @@ const EXPRESSIONS = ['jsxComment', 'mdxExpressionLenient', 'mdxjsEsm'];
|
|
|
97498
97615
|
*/
|
|
97499
97616
|
const FEATURES = {
|
|
97500
97617
|
/** `lib/mdxish.ts` — the document parser; the only site taking every group */
|
|
97501
|
-
document: [...BLOCK_CLAIMS, ...INLINE, ...EXPRESSIONS, 'emptyTaskListItem'],
|
|
97618
|
+
document: [...BLOCK_CLAIMS, ...INLINE, ...EXPRESSIONS, 'emptyTaskListItem', 'headingId'],
|
|
97502
97619
|
/**
|
|
97503
97620
|
* `components/utils.ts` — re-parses a component body, which should tokenize
|
|
97504
97621
|
* like the document around it: when the two drifted a `<Table>` in a
|
|
97505
97622
|
* `<Callout>` lost every row (CX-3705).
|
|
97506
97623
|
*/
|
|
97507
|
-
componentBody: [
|
|
97508
|
-
...BLOCK_CLAIMS,
|
|
97509
|
-
...INLINE,
|
|
97510
|
-
'mdxExpression',
|
|
97511
|
-
'emptyTaskListItem',
|
|
97512
|
-
],
|
|
97624
|
+
componentBody: [...BLOCK_CLAIMS, ...INLINE, 'mdxExpression', 'emptyTaskListItem', 'headingId'],
|
|
97513
97625
|
/**
|
|
97514
97626
|
* `lib/mdxishTags.ts` — collects component names, so nothing inline is needed.
|
|
97515
97627
|
* Omits `htmlBlockComponent` deliberately since it's not a custom component,
|
|
@@ -101062,6 +101174,7 @@ const splitHtmlWithNestedTables = (node, source) => {
|
|
|
101062
101174
|
|
|
101063
101175
|
|
|
101064
101176
|
|
|
101177
|
+
|
|
101065
101178
|
|
|
101066
101179
|
|
|
101067
101180
|
const isTableCell = (node) => isMDXElement(node) && ['th', 'td'].includes(node.name);
|
|
@@ -101082,9 +101195,13 @@ const buildTableNodeProcessor = (withMdx) => {
|
|
|
101082
101195
|
const { micromarkExtensions, fromMarkdownExtensions } = mdxishExtensions(FEATURES.tableCell);
|
|
101083
101196
|
// `mdxjs` goes first (= lowest priority): its `mdxJsx` also claims `text` + `<`,
|
|
101084
101197
|
// and `legacyVariable` has to keep winning that race so `<<var>>` still parses.
|
|
101198
|
+
// `mdxishExpressionFromMarkdown` follows `mdxFromMarkdown` to override its expression exit.
|
|
101085
101199
|
return unified()
|
|
101086
101200
|
.data('micromarkExtensions', [...(withMdx ? [mdxjs()] : []), ...micromarkExtensions])
|
|
101087
|
-
.data('fromMarkdownExtensions', [
|
|
101201
|
+
.data('fromMarkdownExtensions', [
|
|
101202
|
+
...(withMdx ? [mdxFromMarkdown(), mdxishExpressionFromMarkdown()] : []),
|
|
101203
|
+
...fromMarkdownExtensions,
|
|
101204
|
+
])
|
|
101088
101205
|
.use(remarkParse)
|
|
101089
101206
|
.use(normalize_malformed_md_syntax)
|
|
101090
101207
|
.use([[callouts, { isMdxish: true }], code_tabs])
|
|
@@ -121956,6 +122073,18 @@ const embed_embed = (node) => {
|
|
|
121956
122073
|
};
|
|
121957
122074
|
/* harmony default export */ const compile_embed = (embed_embed);
|
|
121958
122075
|
|
|
122076
|
+
;// ./processor/compile/heading.ts
|
|
122077
|
+
|
|
122078
|
+
|
|
122079
|
+
const SETEXT_UNDERLINE_REGEX = /\n(?:=+|-+)$/;
|
|
122080
|
+
/** Writes an explicit heading id back as ` {#id}`. A setext heading, written for a line break, can't carry one. */
|
|
122081
|
+
const compile_heading_heading = ((node, parent, state, info) => {
|
|
122082
|
+
const markdown = handle.heading(node, parent, state, info);
|
|
122083
|
+
const id = explicitHeadingId(node);
|
|
122084
|
+
return id && !SETEXT_UNDERLINE_REGEX.test(markdown) ? `${markdown} {#${id}}` : markdown;
|
|
122085
|
+
});
|
|
122086
|
+
/* harmony default export */ const compile_heading = (compile_heading_heading);
|
|
122087
|
+
|
|
121959
122088
|
;// ./processor/compile/html-block.ts
|
|
121960
122089
|
|
|
121961
122090
|
const htmlBlock = (node) => {
|
|
@@ -122101,6 +122230,7 @@ const mdxishText = (node, parent, state, info) => compile_text_text(node, parent
|
|
|
122101
122230
|
|
|
122102
122231
|
|
|
122103
122232
|
|
|
122233
|
+
|
|
122104
122234
|
function compilers(mdxish = false) {
|
|
122105
122235
|
const data = this.data();
|
|
122106
122236
|
const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
@@ -122121,6 +122251,7 @@ function compilers(mdxish = false) {
|
|
|
122121
122251
|
text: compile_text_text,
|
|
122122
122252
|
yaml: compile_compatibility,
|
|
122123
122253
|
// needed only for mdxish
|
|
122254
|
+
...(mdxish && { heading: compile_heading }),
|
|
122124
122255
|
...(mdxish && { list: compile_list }),
|
|
122125
122256
|
...(mdxish && { listItem: list_item }),
|
|
122126
122257
|
...(mdxish && { text: compile_text }),
|
|
@@ -124239,6 +124370,7 @@ function reactElementToHast(node) {
|
|
|
124239
124370
|
|
|
124240
124371
|
|
|
124241
124372
|
|
|
124373
|
+
|
|
124242
124374
|
/**
|
|
124243
124375
|
* Bind the components a given expression actually uses as tags. Scoped per expression on purpose:
|
|
124244
124376
|
* binding the whole hash would shadow same-named globals (a `math` component would break
|
|
@@ -124289,14 +124421,6 @@ const wrapInParagraph = (child) => ({
|
|
|
124289
124421
|
position: child.position,
|
|
124290
124422
|
});
|
|
124291
124423
|
const placeText = (text, needsBlock) => (needsBlock ? wrapInParagraph(text) : text);
|
|
124292
|
-
/** Turn a non-renderable evaluation result into a text node. */
|
|
124293
|
-
const createTextNode = (result, position) => {
|
|
124294
|
-
if (result === null || result === undefined)
|
|
124295
|
-
return { type: 'text', value: '', position };
|
|
124296
|
-
if (typeof result === 'object')
|
|
124297
|
-
return { type: 'text', value: JSON.stringify(result), position };
|
|
124298
|
-
return { type: 'text', value: String(result), position };
|
|
124299
|
-
};
|
|
124300
124424
|
/**
|
|
124301
124425
|
* AST transformer to evaluate MDX expressions.
|
|
124302
124426
|
* Replaces mdxFlowExpression and mdxTextExpression nodes with their evaluated values.
|
|
@@ -124416,6 +124540,26 @@ const evaluateStyleBlockExpressions = () => (tree, file) => {
|
|
|
124416
124540
|
};
|
|
124417
124541
|
/* harmony default export */ const evaluate_style_block_expressions = (evaluateStyleBlockExpressions);
|
|
124418
124542
|
|
|
124543
|
+
;// ./processor/transform/mdxish/heading-ids.ts
|
|
124544
|
+
|
|
124545
|
+
/**
|
|
124546
|
+
* Records every heading id set by `{#id}`, so the slug pass never gives one to another heading.
|
|
124547
|
+
* Warns when two headings share an id, since links can only reach the first.
|
|
124548
|
+
*/
|
|
124549
|
+
const headingIdsTransformer = () => (tree, file) => {
|
|
124550
|
+
visit(tree, 'heading', (node) => {
|
|
124551
|
+
const id = node.data?.hProperties?.id;
|
|
124552
|
+
if (typeof id !== 'string')
|
|
124553
|
+
return;
|
|
124554
|
+
const ids = file.data.explicitHeadingIds ?? new Set();
|
|
124555
|
+
file.data.explicitHeadingIds = ids;
|
|
124556
|
+
if (ids.has(id))
|
|
124557
|
+
console.warn(`[mdxish] Heading id "${id}" is used more than once; links reach only the first.`);
|
|
124558
|
+
ids.add(id);
|
|
124559
|
+
});
|
|
124560
|
+
};
|
|
124561
|
+
/* harmony default export */ const heading_ids = (headingIdsTransformer);
|
|
124562
|
+
|
|
124419
124563
|
;// ./processor/transform/mdxish/heading-slugs.ts
|
|
124420
124564
|
|
|
124421
124565
|
|
|
@@ -124441,12 +124585,17 @@ function textContent(node) {
|
|
|
124441
124585
|
* Id's are used to construct slug anchor links & Table of Contents during rendering
|
|
124442
124586
|
* Use the text / nodes that make up the heading to generate the id
|
|
124443
124587
|
*/
|
|
124444
|
-
const generateSlugForHeadings = () => (tree) => {
|
|
124588
|
+
const generateSlugForHeadings = () => (tree, file) => {
|
|
124445
124589
|
const slugger = new BananaSlug();
|
|
124590
|
+
// The slugger only counts the ids it generates, so `{#id}` ones are skipped past by hand.
|
|
124591
|
+
const explicitIds = file.data.explicitHeadingIds ?? new Set();
|
|
124446
124592
|
visit(tree, 'element', (node) => {
|
|
124447
124593
|
if (isHeading(node) && !node.properties.id) {
|
|
124448
124594
|
const text = node.children.map(textContent).join('');
|
|
124449
|
-
|
|
124595
|
+
let id = slugger.slug(text);
|
|
124596
|
+
while (explicitIds.has(id))
|
|
124597
|
+
id = slugger.slug(text);
|
|
124598
|
+
node.properties.id = id;
|
|
124450
124599
|
}
|
|
124451
124600
|
});
|
|
124452
124601
|
return tree;
|
|
@@ -127807,22 +127956,28 @@ const BARE_VARIABLE_REGEX = new RegExp(`^${variable_dist.MDX_VARIABLE_REGEXP}$`,
|
|
|
127807
127956
|
// Escaped and `$`-prefixed forms are left alone so a reference that stays literal keeps its source.
|
|
127808
127957
|
// A closing escape needs no lookahead: requiring a literal `]}` already rules out `]\}`.
|
|
127809
127958
|
const BRACKET_NOTATION_REGEX = /(?<![$\\])\{user\[['"](\w+)['"]\]\}/gu;
|
|
127959
|
+
const ALT_VARIABLE_REGEX = new RegExp(`${MDX_VARIABLE_REGEX.source}|${variable_dist.VARIABLE_REGEXP}`, 'gu');
|
|
127810
127960
|
/**
|
|
127811
127961
|
* Resolve `{user.*}` in a JSX attribute value against the same `user` binding the rmdx engine gets,
|
|
127812
127962
|
* so both engines agree. Body text differs on empty values: `Variable` falls back to the default.
|
|
127813
127963
|
*
|
|
127814
127964
|
* Legacy `<<...>>` is valid inside a quoted attribute but deliberately left literal — attributes are
|
|
127815
|
-
* an MDX surface, and `{user.*}` is the syntax authors use there.
|
|
127965
|
+
* an MDX surface, and `{user.*}` is the syntax authors use there. Image alt is the exception, resolved
|
|
127966
|
+
* in the same pass so a substituted value is never rescanned (RM-10865).
|
|
127816
127967
|
*/
|
|
127817
|
-
function resolveAttributeVariables(value, user) {
|
|
127818
|
-
if (!value.includes('{user'))
|
|
127968
|
+
function resolveAttributeVariables(value, user, isImageAlt = false) {
|
|
127969
|
+
if (!isImageAlt && !value.includes('{user'))
|
|
127819
127970
|
return value;
|
|
127820
127971
|
return value
|
|
127821
127972
|
.replace(BRACKET_NOTATION_REGEX, '{user.$1}')
|
|
127822
|
-
.replace(MDX_VARIABLE_REGEX, (source,
|
|
127823
|
-
|
|
127824
|
-
|
|
127825
|
-
|
|
127973
|
+
.replace(isImageAlt ? ALT_VARIABLE_REGEX : MDX_VARIABLE_REGEX, (source, _prefix, name, _suffix, legacyName) => {
|
|
127974
|
+
// Variable names can't contain a backslash, so one marks an escaped reference.
|
|
127975
|
+
if (source.includes('\\'))
|
|
127976
|
+
return isImageAlt ? source.replaceAll('\\', '') : source;
|
|
127977
|
+
const key = (name ?? legacyName).trim();
|
|
127978
|
+
if (key.startsWith('glossary:'))
|
|
127979
|
+
return key.slice('glossary:'.length).trim();
|
|
127980
|
+
return stringifyVariableValue(user[key]);
|
|
127826
127981
|
});
|
|
127827
127982
|
}
|
|
127828
127983
|
/** Whether an attribute expression's source is a bare `user.*` reference, left for render-time substitution. */
|
|
@@ -128326,6 +128481,7 @@ function loadComponents() {
|
|
|
128326
128481
|
|
|
128327
128482
|
|
|
128328
128483
|
|
|
128484
|
+
|
|
128329
128485
|
|
|
128330
128486
|
|
|
128331
128487
|
const defaultTransformers = [
|
|
@@ -128445,24 +128601,15 @@ function mdxishMdastToMd(mdast) {
|
|
|
128445
128601
|
.use(mdxish_remarkStringify, stringifyOptions);
|
|
128446
128602
|
return processor.stringify(processor.runSync(mdast));
|
|
128447
128603
|
}
|
|
128448
|
-
/**
|
|
128449
|
-
|
|
128450
|
-
* Detects and renders custom component tags from the components hash.
|
|
128451
|
-
*
|
|
128452
|
-
* @see .claude/context/MDXish/Processor Overview.md
|
|
128453
|
-
*/
|
|
128454
|
-
function mdxish(mdContent, opts = {}) {
|
|
128604
|
+
/** The steps `mdxish()` runs after parsing; run it on the parse's VFile, since steps read `file.data`. */
|
|
128605
|
+
function mdxishRenderProcessor(opts = {}) {
|
|
128455
128606
|
const { components: userComponents = {}, hardBreaks: enableHardBreaks = true, safeMode = false, sanitize = false, variables, } = opts;
|
|
128456
128607
|
const components = {
|
|
128457
128608
|
...loadComponents(),
|
|
128458
128609
|
...userComponents,
|
|
128459
128610
|
};
|
|
128460
|
-
|
|
128461
|
-
|
|
128462
|
-
const withoutComments = removeJSXComments(protectedContent);
|
|
128463
|
-
const contentWithoutComments = restoreCodeBlocks(withoutComments, protectedCode);
|
|
128464
|
-
const { processor, parserReadyContent } = mdxishAstProcessor(contentWithoutComments, opts);
|
|
128465
|
-
processor
|
|
128611
|
+
return unified()
|
|
128612
|
+
.use(heading_ids)
|
|
128466
128613
|
.use(safeMode ? undefined : evaluate_exports, { sanitize }) // Evaluate `export const/function` and stash scope on file.data.mdxishScope
|
|
128467
128614
|
.use(enableHardBreaks ? hard_breaks : undefined) // Must precede evaluateExpressions to avoid splitting the \n in an evaluated template literal into a <br> node
|
|
128468
128615
|
.use(safeMode ? undefined : evaluate_expressions, { components, variables }) // Evaluate self-contained MDX expressions (e.g. `{1+1}`)
|
|
@@ -128480,11 +128627,25 @@ function mdxish(mdContent, opts = {}) {
|
|
|
128480
128627
|
.use(heading_slugs)
|
|
128481
128628
|
.use(rehypeMdxishComponents, {
|
|
128482
128629
|
components,
|
|
128630
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define -- component bodies render through mdxish() again
|
|
128483
128631
|
processMarkdown: (markdown) => mdxish(markdown, opts),
|
|
128484
128632
|
});
|
|
128633
|
+
}
|
|
128634
|
+
/**
|
|
128635
|
+
* Processes markdown content with MDX syntax support and returns a HAST.
|
|
128636
|
+
* Detects and renders custom component tags from the components hash.
|
|
128637
|
+
*
|
|
128638
|
+
* @see .claude/context/MDXish/Processor Overview.md
|
|
128639
|
+
*/
|
|
128640
|
+
function mdxish(mdContent, opts = {}) {
|
|
128641
|
+
// Remove JSX comments before processing (protect code blocks first)
|
|
128642
|
+
const { protectedCode, protectedContent } = protectCodeBlocks(mdContent);
|
|
128643
|
+
const withoutComments = removeJSXComments(protectedContent);
|
|
128644
|
+
const contentWithoutComments = restoreCodeBlocks(withoutComments, protectedCode);
|
|
128645
|
+
const { processor, parserReadyContent } = mdxishAstProcessor(contentWithoutComments, opts);
|
|
128485
128646
|
const vfile = new VFile({ value: parserReadyContent });
|
|
128486
|
-
const mdast = processor.parse(parserReadyContent);
|
|
128487
|
-
const hast =
|
|
128647
|
+
const mdast = processor.runSync(processor.parse(parserReadyContent), vfile);
|
|
128648
|
+
const hast = mdxishRenderProcessor(opts).runSync(mdast, vfile);
|
|
128488
128649
|
if (!hast) {
|
|
128489
128650
|
throw new Error('Markdown pipeline did not produce a HAST tree.');
|
|
128490
128651
|
}
|
|
@@ -128512,6 +128673,142 @@ const mix = (text, opts = {}) => {
|
|
|
128512
128673
|
};
|
|
128513
128674
|
/* harmony default export */ const lib_mix = ((/* unused pure expression or super */ null && (mix)));
|
|
128514
128675
|
|
|
128676
|
+
;// ./lib/mdxishHeadingIds.ts
|
|
128677
|
+
/* unused harmony import specifier */ var mdxishHeadingIds_visit;
|
|
128678
|
+
/* unused harmony import specifier */ var mdxishHeadingIds_visitParents;
|
|
128679
|
+
/* unused harmony import specifier */ var mdxishHeadingIds_VFile;
|
|
128680
|
+
/* unused harmony import specifier */ var mdxishHeadingIds_isMDXElement;
|
|
128681
|
+
/* unused harmony import specifier */ var mdxishHeadingIds_createTextNode;
|
|
128682
|
+
/* unused harmony import specifier */ var mdxishHeadingIds_mdxishRenderProcessor;
|
|
128683
|
+
/* unused harmony import specifier */ var mdxishHeadingIds_jsxAcornParser;
|
|
128684
|
+
/* unused harmony import specifier */ var mdxishHeadingIds_evaluateLiteralExpression;
|
|
128685
|
+
|
|
128686
|
+
|
|
128687
|
+
|
|
128688
|
+
|
|
128689
|
+
|
|
128690
|
+
|
|
128691
|
+
|
|
128692
|
+
|
|
128693
|
+
const HEADING_INDEX = 'dataMdxishHeadingIndex';
|
|
128694
|
+
const HEADING_TAG_REGEX = /^h[1-6]$/;
|
|
128695
|
+
const JSX_COMMENT_ONLY_REGEX = new RegExp(`^${JSX_COMMENT_REGEX.source}$`);
|
|
128696
|
+
const isExpression = (node) => node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression';
|
|
128697
|
+
function collectHeadings(tree) {
|
|
128698
|
+
const headings = [];
|
|
128699
|
+
mdxishHeadingIds_visit(tree, 'heading', (node) => {
|
|
128700
|
+
headings.push(node);
|
|
128701
|
+
});
|
|
128702
|
+
return headings;
|
|
128703
|
+
}
|
|
128704
|
+
function literalValue(source) {
|
|
128705
|
+
try {
|
|
128706
|
+
return { value: mdxishHeadingIds_evaluateLiteralExpression(source) };
|
|
128707
|
+
}
|
|
128708
|
+
catch {
|
|
128709
|
+
return null;
|
|
128710
|
+
}
|
|
128711
|
+
}
|
|
128712
|
+
function trimHeadingText(heading) {
|
|
128713
|
+
const first = heading.children[0];
|
|
128714
|
+
if (first?.type === 'text')
|
|
128715
|
+
first.value = first.value.trimStart();
|
|
128716
|
+
const last = heading.children.at(-1);
|
|
128717
|
+
if (last?.type === 'text')
|
|
128718
|
+
last.value = last.value.trimEnd();
|
|
128719
|
+
}
|
|
128720
|
+
const isNamePath = (node) => node.type === 'Identifier' ||
|
|
128721
|
+
(node.type === 'MemberExpression' && !node.computed && !!node.object && isNamePath(node.object));
|
|
128722
|
+
// A name like `{price}` or `{plan.name}` can only read a value, never build an element. Code the parser
|
|
128723
|
+
// rejects can't run at all, so the hub shows it as text.
|
|
128724
|
+
function canBuildElements(source) {
|
|
128725
|
+
try {
|
|
128726
|
+
return !isNamePath(mdxishHeadingIds_jsxAcornParser.parseExpressionAt(source, 0, { ecmaVersion: 'latest' }));
|
|
128727
|
+
}
|
|
128728
|
+
catch {
|
|
128729
|
+
return false;
|
|
128730
|
+
}
|
|
128731
|
+
}
|
|
128732
|
+
const isHeadingElement = (node) => mdxishHeadingIds_isMDXElement(node) && HEADING_TAG_REGEX.test(node.name ?? '');
|
|
128733
|
+
// An expression the hub has to run changes a heading from inside one (Markdown or an HTML heading tag), by
|
|
128734
|
+
// building an element (a call or JSX), or as a block: alone in its paragraph, its result is lifted out as one.
|
|
128735
|
+
function canChangeHeadings(node, ancestors, heading) {
|
|
128736
|
+
if (heading || ancestors.some(isHeadingElement) || node.type === 'mdxFlowExpression' || canBuildElements(node.value))
|
|
128737
|
+
return true;
|
|
128738
|
+
const parent = ancestors[ancestors.length - 1];
|
|
128739
|
+
return parent.children.every(child => child === node || (child.type === 'text' && !child.value.trim()));
|
|
128740
|
+
}
|
|
128741
|
+
// Safe mode leaves `<h2 id={...}>` without the id the hub evaluates, which shifts the numbering.
|
|
128742
|
+
function hasEvaluatedHeadingAttribute(tree) {
|
|
128743
|
+
let found = false;
|
|
128744
|
+
mdxishHeadingIds_visit(tree, isHeadingElement, (node) => {
|
|
128745
|
+
found = node.attributes.some(attribute => attribute.type === 'mdxJsxExpressionAttribute' || typeof attribute.value === 'object');
|
|
128746
|
+
return found ? (/* inlined export .EXIT */false) : undefined;
|
|
128747
|
+
});
|
|
128748
|
+
return found;
|
|
128749
|
+
}
|
|
128750
|
+
// Matches what the hub renders without running code: comments are stripped and plain literals become their
|
|
128751
|
+
// text. `false` when an expression that needs running could change the headings.
|
|
128752
|
+
function settleExpressions(tree) {
|
|
128753
|
+
const edits = [];
|
|
128754
|
+
let settled = true;
|
|
128755
|
+
mdxishHeadingIds_visitParents(tree, isExpression, (node, ancestors) => {
|
|
128756
|
+
const heading = ancestors.find((ancestor) => ancestor.type === 'heading');
|
|
128757
|
+
const parent = ancestors[ancestors.length - 1];
|
|
128758
|
+
if (JSX_COMMENT_ONLY_REGEX.test(`{${node.value}}`)) {
|
|
128759
|
+
edits.push({ heading, node, parent, replacement: null });
|
|
128760
|
+
return;
|
|
128761
|
+
}
|
|
128762
|
+
const literal = literalValue(node.value);
|
|
128763
|
+
if (literal) {
|
|
128764
|
+
edits.push({ heading, node, parent, replacement: mdxishHeadingIds_createTextNode(literal.value, node.position) });
|
|
128765
|
+
return;
|
|
128766
|
+
}
|
|
128767
|
+
if (canChangeHeadings(node, ancestors, heading))
|
|
128768
|
+
settled = false;
|
|
128769
|
+
});
|
|
128770
|
+
const apply = ({ node, parent, replacement }) => {
|
|
128771
|
+
parent.children.splice(parent.children.indexOf(node), 1, ...(replacement ? [replacement] : []));
|
|
128772
|
+
};
|
|
128773
|
+
// Comments go first: the hub strips them from the source, so the parser trims only the source
|
|
128774
|
+
// whitespace around them, never the spaces a literal adds.
|
|
128775
|
+
edits
|
|
128776
|
+
.filter(edit => !edit.replacement)
|
|
128777
|
+
.forEach(edit => {
|
|
128778
|
+
apply(edit);
|
|
128779
|
+
if (edit.heading)
|
|
128780
|
+
trimHeadingText(edit.heading);
|
|
128781
|
+
});
|
|
128782
|
+
edits.filter(edit => edit.replacement).forEach(apply);
|
|
128783
|
+
return settled;
|
|
128784
|
+
}
|
|
128785
|
+
/** Each heading's rendered anchor id, worked out without running code; `null` when code could change them. */
|
|
128786
|
+
function mdxishHeadingIds(tree, opts = {}) {
|
|
128787
|
+
const headings = collectHeadings(tree);
|
|
128788
|
+
if (headings.length === 0)
|
|
128789
|
+
return new Map();
|
|
128790
|
+
const copy = structuredClone(tree);
|
|
128791
|
+
let hasExport = false;
|
|
128792
|
+
mdxishHeadingIds_visit(copy, 'mdxjsEsm', () => {
|
|
128793
|
+
hasExport = true;
|
|
128794
|
+
});
|
|
128795
|
+
// An `export` can define components that render headings.
|
|
128796
|
+
if (hasExport || hasEvaluatedHeadingAttribute(copy) || !settleExpressions(copy))
|
|
128797
|
+
return null;
|
|
128798
|
+
collectHeadings(copy).forEach((heading, index) => {
|
|
128799
|
+
heading.data = { ...heading.data, hProperties: { ...heading.data?.hProperties, [HEADING_INDEX]: index } };
|
|
128800
|
+
});
|
|
128801
|
+
const hast = mdxishHeadingIds_mdxishRenderProcessor({ ...opts, safeMode: true }).runSync(copy, new mdxishHeadingIds_VFile());
|
|
128802
|
+
const ids = new Map();
|
|
128803
|
+
mdxishHeadingIds_visit(hast, 'element', (node) => {
|
|
128804
|
+
const index = node.properties[HEADING_INDEX];
|
|
128805
|
+
if (index === undefined || typeof node.properties.id !== 'string')
|
|
128806
|
+
return;
|
|
128807
|
+
ids.set(headings[Number(index)], node.properties.id);
|
|
128808
|
+
});
|
|
128809
|
+
return ids;
|
|
128810
|
+
}
|
|
128811
|
+
|
|
128515
128812
|
;// ./lib/extractToc.ts
|
|
128516
128813
|
/* unused harmony import specifier */ var extractToc_extractToc;
|
|
128517
128814
|
|
|
@@ -128680,8 +128977,10 @@ function exportComponentsForRehype(components) {
|
|
|
128680
128977
|
* deliberately leaves mermaid alone; resolving it again here would override that.
|
|
128681
128978
|
*/
|
|
128682
128979
|
const CODE_TAG_NAMES = new Set(['code']);
|
|
128980
|
+
const isImageAlt = (tagName, key) => tagName === 'img' && key === 'alt';
|
|
128683
128981
|
/**
|
|
128684
|
-
* Resolve `{user.*}` in string-valued props
|
|
128982
|
+
* Resolve `{user.*}` in string-valued props, plus legacy `<<...>>` in img alt, where markdown flattens
|
|
128983
|
+
* body variables to text (RM-10865). Body text is handled by the `Variable` component, but
|
|
128685
128984
|
* attributes are plain strings, so they are substituted here — at render time, so that a
|
|
128686
128985
|
* server-parsed (user-agnostic) tree resolves against the current reader's variables.
|
|
128687
128986
|
*/
|
|
@@ -128691,7 +128990,7 @@ function resolveVariablesInProps(props, user, tagName) {
|
|
|
128691
128990
|
const isDocumentContent = RAW_HTML_PROP_NAMES.has(key) || (isCodeTag && key === 'value');
|
|
128692
128991
|
if (typeof value !== 'string' || isDocumentContent)
|
|
128693
128992
|
return [key, value];
|
|
128694
|
-
return [key, resolveAttributeVariables(value, user)];
|
|
128993
|
+
return [key, resolveAttributeVariables(value, user, isImageAlt(tagName, key))];
|
|
128695
128994
|
});
|
|
128696
128995
|
return Object.fromEntries(resolvedEntries);
|
|
128697
128996
|
}
|
|
@@ -129054,6 +129353,7 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
|
129054
129353
|
|
|
129055
129354
|
|
|
129056
129355
|
|
|
129356
|
+
|
|
129057
129357
|
|
|
129058
129358
|
;// ./lib/render-fixture/renderFixture.ts
|
|
129059
129359
|
|
|
@@ -129526,7 +129826,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"*":["about","acceptCharset","accessK
|
|
|
129526
129826
|
/******/ // startup
|
|
129527
129827
|
/******/ // Load entry module and return exports
|
|
129528
129828
|
/******/ // This entry module used 'module' so it can't be inlined
|
|
129529
|
-
/******/ let __webpack_exports__ = __webpack_require__(
|
|
129829
|
+
/******/ let __webpack_exports__ = __webpack_require__(5919);
|
|
129530
129830
|
/******/ module.exports = __webpack_exports__;
|
|
129531
129831
|
/******/
|
|
129532
129832
|
/******/ })()
|