@readme/markdown 14.14.1 → 15.0.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/368.node.js +1 -393
- package/dist/368.node.js.map +1 -1
- package/dist/lib/micromark/loose-html-entities/index.d.ts +5 -4
- package/dist/lib/utils/mdxish/mdxish-render-utils.d.ts +1 -1
- package/dist/lib/utils/mdxish/mdxish-variables.d.ts +8 -0
- package/dist/main.js +184 -113
- package/dist/main.node.js +184 -113
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/mdxish/tables/gfm-cell-normalization.d.ts +9 -0
- package/dist/render-fixture.node.js +168 -130
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +3 -2
package/dist/main.node.js
CHANGED
|
@@ -275,7 +275,7 @@ function visit(tree, test, visitor, reverse) {
|
|
|
275
275
|
|
|
276
276
|
/***/ }),
|
|
277
277
|
|
|
278
|
-
/***/
|
|
278
|
+
/***/ 7644:
|
|
279
279
|
/***/ ((__unused_webpack_module, exports) => {
|
|
280
280
|
|
|
281
281
|
"use strict";
|
|
@@ -349,7 +349,7 @@ exports["default"] = canonical;
|
|
|
349
349
|
|
|
350
350
|
/***/ }),
|
|
351
351
|
|
|
352
|
-
/***/
|
|
352
|
+
/***/ 4350:
|
|
353
353
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
354
354
|
|
|
355
355
|
"use strict";
|
|
@@ -358,15 +358,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
358
358
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
359
359
|
};
|
|
360
360
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
361
|
-
const canonical_1 = __importDefault(__webpack_require__(
|
|
362
|
-
const modes_1 = __webpack_require__(
|
|
363
|
-
const uppercase_1 = __importDefault(__webpack_require__(
|
|
361
|
+
const canonical_1 = __importDefault(__webpack_require__(7644));
|
|
362
|
+
const modes_1 = __webpack_require__(1130);
|
|
363
|
+
const uppercase_1 = __importDefault(__webpack_require__(3622));
|
|
364
364
|
exports["default"] = { uppercase: uppercase_1.default, canonical: canonical_1.default, modes: modes_1.modes, getMode: modes_1.getMode };
|
|
365
365
|
|
|
366
366
|
|
|
367
367
|
/***/ }),
|
|
368
368
|
|
|
369
|
-
/***/
|
|
369
|
+
/***/ 1130:
|
|
370
370
|
/***/ ((__unused_webpack_module, exports) => {
|
|
371
371
|
|
|
372
372
|
"use strict";
|
|
@@ -425,6 +425,7 @@ exports.modes = {
|
|
|
425
425
|
node: 'javascript',
|
|
426
426
|
macruby: 'ruby',
|
|
427
427
|
markdown: 'gfm',
|
|
428
|
+
md: 'gfm',
|
|
428
429
|
ml: ['mllike', 'text/x-ocaml'],
|
|
429
430
|
mssql: ['sql', 'text/x-mssql'],
|
|
430
431
|
mysql: ['sql', 'text/x-mysql'],
|
|
@@ -479,7 +480,7 @@ function getMode(lang) {
|
|
|
479
480
|
|
|
480
481
|
/***/ }),
|
|
481
482
|
|
|
482
|
-
/***/
|
|
483
|
+
/***/ 3622:
|
|
483
484
|
/***/ ((__unused_webpack_module, exports) => {
|
|
484
485
|
|
|
485
486
|
"use strict";
|
|
@@ -19303,7 +19304,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
19303
19304
|
stripComments: () => (/* reexport */ lib_stripComments),
|
|
19304
19305
|
tags: () => (/* reexport */ lib_tags),
|
|
19305
19306
|
tailwindCompiler: () => (/* reexport */ tailwindCompiler),
|
|
19306
|
-
utils: () => (/* binding */
|
|
19307
|
+
utils: () => (/* binding */ index_utils)
|
|
19307
19308
|
});
|
|
19308
19309
|
|
|
19309
19310
|
// NAMESPACE OBJECT: ./components/index.ts
|
|
@@ -19625,16 +19626,16 @@ const Code = (props) => {
|
|
|
19625
19626
|
};
|
|
19626
19627
|
/* harmony default export */ const components_Code = (Code);
|
|
19627
19628
|
|
|
19628
|
-
// EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/index.js
|
|
19629
|
-
var
|
|
19630
|
-
var
|
|
19629
|
+
// EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/utils/index.js
|
|
19630
|
+
var utils = __webpack_require__(4350);
|
|
19631
|
+
var utils_default = /*#__PURE__*/__webpack_require__.n(utils);
|
|
19631
19632
|
;// ./components/CodeTabs/index.tsx
|
|
19632
19633
|
|
|
19633
19634
|
|
|
19634
19635
|
|
|
19635
19636
|
|
|
19636
19637
|
let mermaid;
|
|
19637
|
-
const { uppercase } = (
|
|
19638
|
+
const { uppercase } = (utils_default());
|
|
19638
19639
|
// Module-level queue that batches mermaid nodes across all CodeTabs instances into a
|
|
19639
19640
|
// single mermaid.run() call. This is necessary because mermaid generates SVG element IDs
|
|
19640
19641
|
// using Date.now(), which collides when multiple diagrams render in the same millisecond.
|
|
@@ -94657,11 +94658,6 @@ const looseHtmlEntityConstruct = {
|
|
|
94657
94658
|
name: 'looseHtmlEntity',
|
|
94658
94659
|
tokenize: tokenizeLooseHtmlEntity,
|
|
94659
94660
|
};
|
|
94660
|
-
function resolveEntity(name) {
|
|
94661
|
-
const input = `&${name};`;
|
|
94662
|
-
const decoded = decode_decodeHTMLStrict(input);
|
|
94663
|
-
return decoded !== input ? decoded : undefined;
|
|
94664
|
-
}
|
|
94665
94661
|
function tokenizeLooseHtmlEntity(effects, ok, nok) {
|
|
94666
94662
|
let length = 0;
|
|
94667
94663
|
const start = (code) => {
|
|
@@ -94728,28 +94724,9 @@ function tokenizeLooseHtmlEntity(effects, ok, nok) {
|
|
|
94728
94724
|
}
|
|
94729
94725
|
function exitLooseHtmlEntity(token) {
|
|
94730
94726
|
const raw = this.sliceSerialize(token);
|
|
94731
|
-
|
|
94732
|
-
|
|
94733
|
-
|
|
94734
|
-
if (decoded) {
|
|
94735
|
-
this.enter({ type: 'text', value: decoded }, token);
|
|
94736
|
-
this.exit(token);
|
|
94737
|
-
return;
|
|
94738
|
-
}
|
|
94739
|
-
}
|
|
94740
|
-
else {
|
|
94741
|
-
for (let len = entityChars.length; len >= 2; len -= 1) {
|
|
94742
|
-
const candidate = entityChars.slice(0, len);
|
|
94743
|
-
const decoded = resolveEntity(candidate);
|
|
94744
|
-
if (decoded) {
|
|
94745
|
-
const remainder = entityChars.slice(len);
|
|
94746
|
-
this.enter({ type: 'text', value: decoded + remainder }, token);
|
|
94747
|
-
this.exit(token);
|
|
94748
|
-
return;
|
|
94749
|
-
}
|
|
94750
|
-
}
|
|
94751
|
-
}
|
|
94752
|
-
this.enter({ type: 'text', value: raw }, token);
|
|
94727
|
+
// `decodeHTML` follows the HTML spec's legacy rules, where only a small
|
|
94728
|
+
// whitelist of names may omit the semicolon, so `&partner_key` stays intact.
|
|
94729
|
+
this.enter({ type: 'text', value: esm_decode_decodeHTML(raw) }, token);
|
|
94753
94730
|
this.exit(token);
|
|
94754
94731
|
}
|
|
94755
94732
|
function looseHtmlEntity() {
|
|
@@ -94769,10 +94746,11 @@ function looseHtmlEntityFromMarkdown() {
|
|
|
94769
94746
|
/**
|
|
94770
94747
|
* Micromark extension for HTML entities without semicolons.
|
|
94771
94748
|
*
|
|
94772
|
-
* Handles named entities
|
|
94773
|
-
*
|
|
94774
|
-
* `&#
|
|
94775
|
-
* standard parser
|
|
94749
|
+
* Handles the named entities the HTML spec lets authors write without a
|
|
94750
|
+
* semicolon (e.g. ` `, `&`, `©`), decimal numeric references (e.g.
|
|
94751
|
+
* ` `, `©`), and hex numeric references (e.g. ` `, ` `).
|
|
94752
|
+
* Entities that already include the semicolon are left for the standard parser
|
|
94753
|
+
* to handle.
|
|
94776
94754
|
*/
|
|
94777
94755
|
|
|
94778
94756
|
|
|
@@ -126552,9 +126530,9 @@ const resolveDeferredAttributeExpressionProps = () => (tree, file) => {
|
|
|
126552
126530
|
properties[name] = name === 'style' && style_object_to_css_isPlainObject(result) ? styleObjectToCssText(result) : result;
|
|
126553
126531
|
}
|
|
126554
126532
|
catch {
|
|
126555
|
-
// Evaluation failed —
|
|
126556
|
-
//
|
|
126557
|
-
properties[name] = source
|
|
126533
|
+
// Evaluation failed — keep the literal `{...}`, matching how `evaluateExpressions` falls
|
|
126534
|
+
// back in body text. Variable references like `{user.name}` stay resolvable at render time.
|
|
126535
|
+
properties[name] = `{${source}}`;
|
|
126558
126536
|
}
|
|
126559
126537
|
});
|
|
126560
126538
|
delete node.data.deferredExpressions;
|
|
@@ -126641,10 +126619,44 @@ const restoreBooleanProperties = () => tree => {
|
|
|
126641
126619
|
};
|
|
126642
126620
|
|
|
126643
126621
|
|
|
126622
|
+
;// ./processor/transform/mdxish/tables/gfm-cell-normalization.ts
|
|
126623
|
+
/** `<br />` is the only line break a GFM pipe cell can carry, since cells are single-line. */
|
|
126624
|
+
const createLineBreak = () => ({
|
|
126625
|
+
type: 'mdxJsxTextElement',
|
|
126626
|
+
name: 'br',
|
|
126627
|
+
attributes: [],
|
|
126628
|
+
children: [],
|
|
126629
|
+
});
|
|
126630
|
+
const createText = (value) => ({ type: 'text', value });
|
|
126631
|
+
const isText = (node) => node.type === 'text';
|
|
126632
|
+
const hasChildren = (node) => 'children' in node;
|
|
126633
|
+
const splitOnLineBreaks = (value) => value.split('\n').reduce((nodes, segment, index) => {
|
|
126634
|
+
if (index > 0)
|
|
126635
|
+
nodes.push(createLineBreak());
|
|
126636
|
+
if (segment)
|
|
126637
|
+
nodes.push(createText(segment));
|
|
126638
|
+
return nodes;
|
|
126639
|
+
}, []);
|
|
126640
|
+
const normalizeNodes = (nodes) => nodes.flatMap(node => {
|
|
126641
|
+
if (node.type === 'break')
|
|
126642
|
+
return createLineBreak();
|
|
126643
|
+
if (isText(node))
|
|
126644
|
+
return splitOnLineBreaks(node.value);
|
|
126645
|
+
if (hasChildren(node))
|
|
126646
|
+
return { ...node, children: normalizeNodes(node.children) };
|
|
126647
|
+
return node;
|
|
126648
|
+
});
|
|
126649
|
+
/**
|
|
126650
|
+
* Returns a copy of the cell's children with line breaks — `break` nodes and newlines inside
|
|
126651
|
+
* text — rewritten to the `<br />` a single-line GFM pipe cell can carry.
|
|
126652
|
+
*/
|
|
126653
|
+
const normalizeCellChildrenForGfm = (cell) => normalizeNodes(cell.children);
|
|
126654
|
+
|
|
126644
126655
|
;// ./processor/transform/mdxish/tables/mdxish-tables-to-jsx.ts
|
|
126645
126656
|
|
|
126646
126657
|
|
|
126647
126658
|
|
|
126659
|
+
|
|
126648
126660
|
const SELF_CLOSING_JSX_REGEX = /^\s*<[A-Z][^>]*\/>\s*$/;
|
|
126649
126661
|
const mdxish_tables_to_jsx_alignToStyle = (align) => {
|
|
126650
126662
|
if (!align || align === 'left')
|
|
@@ -126660,6 +126672,38 @@ const mdxish_tables_to_jsx_alignToStyle = (align) => {
|
|
|
126660
126672
|
};
|
|
126661
126673
|
const mdxish_tables_to_jsx_isTableCell = (node) => ['tableHead', 'tableCell'].includes(node.type);
|
|
126662
126674
|
const mdxish_tables_to_jsx_isLiteral = (node) => 'value' in node;
|
|
126675
|
+
/**
|
|
126676
|
+
* Block-level content that a single-line GFM cell cannot hold. `phrasing()` returns true
|
|
126677
|
+
* for inline types (text, emphasis, strong, link…), which are safe to keep.
|
|
126678
|
+
*/
|
|
126679
|
+
const isFlowChild = (child) => {
|
|
126680
|
+
if (child.type === 'paragraph' || child.type === 'plain' || child.type === 'escape')
|
|
126681
|
+
return false;
|
|
126682
|
+
if (child.type === NodeTypes.variable)
|
|
126683
|
+
return false;
|
|
126684
|
+
if (phrasing(child))
|
|
126685
|
+
return false;
|
|
126686
|
+
if (child.type === 'html')
|
|
126687
|
+
return SELF_CLOSING_JSX_REGEX.test(child.value);
|
|
126688
|
+
return true;
|
|
126689
|
+
};
|
|
126690
|
+
/** A newline in a normalized cell (e.g. inside `inlineCode`) has no inline equivalent. */
|
|
126691
|
+
const containsLiteralNewline = (nodes) => nodes.some(node => (mdxish_tables_to_jsx_isLiteral(node) && node.value.includes('\n')) || (hasChildren(node) && containsLiteralNewline(node.children)));
|
|
126692
|
+
/** True when normalized cell content survives a single-line GFM pipe cell without losing structure. */
|
|
126693
|
+
const canCellBeGfm = (children) => {
|
|
126694
|
+
// Multiple paragraphs are distinct blocks; a single-line cell cannot keep them apart.
|
|
126695
|
+
if (children.filter(child => child.type === 'paragraph').length > 1)
|
|
126696
|
+
return false;
|
|
126697
|
+
if (children.some(isFlowChild))
|
|
126698
|
+
return false;
|
|
126699
|
+
return !containsLiteralNewline(children);
|
|
126700
|
+
};
|
|
126701
|
+
/** On the promote path a `break` would serialize as a dangling `\`, so collapse it to a newline. */
|
|
126702
|
+
const flattenBreaksToNewlines = (cell) => {
|
|
126703
|
+
visit(cell, 'break', (_, index, parent) => {
|
|
126704
|
+
parent.children.splice(index, 1, { type: 'text', value: '\n' });
|
|
126705
|
+
});
|
|
126706
|
+
};
|
|
126663
126707
|
/**
|
|
126664
126708
|
* Mdxish-specific version of `tablesToJsx`. Differs from the shared MDX version:
|
|
126665
126709
|
*
|
|
@@ -126670,52 +126714,25 @@ const mdxish_tables_to_jsx_isLiteral = (node) => 'value' in node;
|
|
|
126670
126714
|
*/
|
|
126671
126715
|
const mdxishTablesToJsx = () => tree => {
|
|
126672
126716
|
visit(tree, (node) => ['table', 'tableau'].includes(node.type), (table, index, parent) => {
|
|
126673
|
-
|
|
126717
|
+
const gfmCells = [];
|
|
126718
|
+
let requiresJsxTable = false;
|
|
126674
126719
|
visit(table, mdxish_tables_to_jsx_isTableCell, (cell) => {
|
|
126675
|
-
|
|
126676
|
-
|
|
126677
|
-
|
|
126678
|
-
|
|
126679
|
-
});
|
|
126680
|
-
// A cell with more than one paragraph child cannot be serialized as GFM
|
|
126681
|
-
// (pipe tables are single-line per cell), so force JSX <Table> output to
|
|
126682
|
-
// preserve paragraph separation.
|
|
126683
|
-
const paragraphCount = cell.children.filter(child => child.type === 'paragraph').length;
|
|
126684
|
-
if (paragraphCount > 1) {
|
|
126685
|
-
hasFlowContent = true;
|
|
126686
|
-
return;
|
|
126687
|
-
}
|
|
126688
|
-
// Check if any child is "flow" content (block-level) that requires JSX <Table>
|
|
126689
|
-
// serialization instead of GFM. `phrasing()` from mdast-util-phrasing returns
|
|
126690
|
-
// true for inline node types (text, emphasis, strong, link, etc.) which are
|
|
126691
|
-
// safe to keep in GFM cells.
|
|
126692
|
-
const hasFlowChild = cell.children.some(child => {
|
|
126693
|
-
if (child.type === 'paragraph' || child.type === 'plain' || child.type === 'escape')
|
|
126694
|
-
return false;
|
|
126695
|
-
if (child.type === NodeTypes.variable)
|
|
126696
|
-
return false;
|
|
126697
|
-
if (phrasing(child))
|
|
126698
|
-
return false;
|
|
126699
|
-
if (child.type === 'html') {
|
|
126700
|
-
return SELF_CLOSING_JSX_REGEX.test(child.value);
|
|
126701
|
-
}
|
|
126702
|
-
return true;
|
|
126703
|
-
});
|
|
126704
|
-
if (hasFlowChild) {
|
|
126705
|
-
hasFlowContent = true;
|
|
126706
|
-
}
|
|
126707
|
-
if (!hasFlowContent) {
|
|
126708
|
-
visit(cell, mdxish_tables_to_jsx_isLiteral, (node) => {
|
|
126709
|
-
if (node.value.match(/\n/)) {
|
|
126710
|
-
hasFlowContent = true;
|
|
126711
|
-
}
|
|
126712
|
-
});
|
|
126720
|
+
const normalized = normalizeCellChildrenForGfm(cell);
|
|
126721
|
+
if (!canCellBeGfm(normalized)) {
|
|
126722
|
+
requiresJsxTable = true;
|
|
126723
|
+
return EXIT;
|
|
126713
126724
|
}
|
|
126725
|
+
gfmCells.push([cell, normalized]);
|
|
126726
|
+
return undefined;
|
|
126714
126727
|
});
|
|
126715
|
-
if (!
|
|
126728
|
+
if (!requiresJsxTable) {
|
|
126729
|
+
gfmCells.forEach(([cell, children]) => {
|
|
126730
|
+
cell.children = children;
|
|
126731
|
+
});
|
|
126716
126732
|
table.type = 'table';
|
|
126717
126733
|
return;
|
|
126718
126734
|
}
|
|
126735
|
+
visit(table, mdxish_tables_to_jsx_isTableCell, flattenBreaksToNewlines);
|
|
126719
126736
|
const styles = table.align.map(mdxish_tables_to_jsx_alignToStyle);
|
|
126720
126737
|
const head = {
|
|
126721
126738
|
attributes: [],
|
|
@@ -127421,6 +127438,24 @@ const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }
|
|
|
127421
127438
|
};
|
|
127422
127439
|
/* harmony default export */ const contexts = (Contexts);
|
|
127423
127440
|
|
|
127441
|
+
;// ./utils/user.ts
|
|
127442
|
+
const User = (variables) => {
|
|
127443
|
+
const { user = {}, defaults = [] } = variables || {};
|
|
127444
|
+
return new Proxy(user, {
|
|
127445
|
+
get(target, attribute) {
|
|
127446
|
+
if (typeof attribute === 'symbol') {
|
|
127447
|
+
return '';
|
|
127448
|
+
}
|
|
127449
|
+
if (attribute in target) {
|
|
127450
|
+
return target[attribute];
|
|
127451
|
+
}
|
|
127452
|
+
const def = defaults.find((d) => d.name === attribute);
|
|
127453
|
+
return def ? def.default : attribute.toUpperCase();
|
|
127454
|
+
},
|
|
127455
|
+
});
|
|
127456
|
+
};
|
|
127457
|
+
/* harmony default export */ const user = (User);
|
|
127458
|
+
|
|
127424
127459
|
;// ./lib/utils/makeUseMdxComponents.ts
|
|
127425
127460
|
|
|
127426
127461
|
|
|
@@ -127451,6 +127486,35 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
127451
127486
|
};
|
|
127452
127487
|
/* harmony default export */ const makeUseMdxComponents = (makeUseMDXComponents);
|
|
127453
127488
|
|
|
127489
|
+
;// ./lib/utils/mdxish/mdxish-variables.ts
|
|
127490
|
+
|
|
127491
|
+
// The `$` guard skips template-literal interpolation: `${user.name}` embeds `{user.name}`, and
|
|
127492
|
+
// substituting it would leave a mangled `` `Hi $Name` `` behind. Those belong to an expression,
|
|
127493
|
+
// which either evaluated already or is meant to stay literal.
|
|
127494
|
+
const MDX_VARIABLE_REGEX = new RegExp(`(?<!\\$)${variable_dist.MDX_VARIABLE_REGEXP}`, 'gu');
|
|
127495
|
+
// Bracket notation names the same variable as dot notation, so normalize it before substituting.
|
|
127496
|
+
// Escaped and `$`-prefixed forms are left alone so a reference that stays literal keeps its source.
|
|
127497
|
+
// A closing escape needs no lookahead: requiring a literal `]}` already rules out `]\}`.
|
|
127498
|
+
const BRACKET_NOTATION_REGEX = /(?<![$\\])\{user\[['"](\w+)['"]\]\}/gu;
|
|
127499
|
+
/**
|
|
127500
|
+
* Resolve `{user.*}` in a JSX attribute value against the same `user` binding the rmdx engine gets,
|
|
127501
|
+
* so both engines agree. Body text differs on empty values: `Variable` falls back to the default.
|
|
127502
|
+
*
|
|
127503
|
+
* Legacy `<<...>>` is valid inside a quoted attribute but deliberately left literal — attributes are
|
|
127504
|
+
* an MDX surface, and `{user.*}` is the syntax authors use there.
|
|
127505
|
+
*/
|
|
127506
|
+
function resolveAttributeVariables(value, user) {
|
|
127507
|
+
if (!value.includes('{user'))
|
|
127508
|
+
return value;
|
|
127509
|
+
return value
|
|
127510
|
+
.replace(BRACKET_NOTATION_REGEX, '{user.$1}')
|
|
127511
|
+
.replace(MDX_VARIABLE_REGEX, (source, escapePrefix, name, escapeSuffix) => {
|
|
127512
|
+
if (escapePrefix || escapeSuffix)
|
|
127513
|
+
return source;
|
|
127514
|
+
return user[name];
|
|
127515
|
+
});
|
|
127516
|
+
}
|
|
127517
|
+
|
|
127454
127518
|
;// ./lib/utils/mdxish/mdxish-render-utils.tsx
|
|
127455
127519
|
|
|
127456
127520
|
|
|
@@ -127459,6 +127523,8 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
127459
127523
|
|
|
127460
127524
|
|
|
127461
127525
|
|
|
127526
|
+
|
|
127527
|
+
|
|
127462
127528
|
/** Flatten CustomComponents into a component map for rehype-react */
|
|
127463
127529
|
function exportComponentsForRehype(components) {
|
|
127464
127530
|
const exported = Object.entries(components).reduce((memo, [tag, mod]) => {
|
|
@@ -127486,6 +127552,28 @@ function exportComponentsForRehype(components) {
|
|
|
127486
127552
|
result.variable = (variable_dist_default());
|
|
127487
127553
|
return result;
|
|
127488
127554
|
}
|
|
127555
|
+
/**
|
|
127556
|
+
* Code rides on a `value` prop, and `variablesCodeResolver` owns it at parse time where it
|
|
127557
|
+
* deliberately leaves mermaid alone; resolving it again here would override that.
|
|
127558
|
+
*/
|
|
127559
|
+
const CODE_TAG_NAMES = new Set(['code']);
|
|
127560
|
+
/** Raw markup injected with `dangerouslySetInnerHTML` by HTMLBlock and Embed — never interpolate. */
|
|
127561
|
+
const RAW_HTML_PROP_NAMES = new Set(['html']);
|
|
127562
|
+
/**
|
|
127563
|
+
* Resolve `{user.*}` in string-valued props. Body text is handled by the `Variable` component, but
|
|
127564
|
+
* attributes are plain strings, so they are substituted here — at render time, so that a
|
|
127565
|
+
* server-parsed (user-agnostic) tree resolves against the current reader's variables.
|
|
127566
|
+
*/
|
|
127567
|
+
function resolveVariablesInProps(props, user, tagName) {
|
|
127568
|
+
const isCodeTag = Boolean(tagName && CODE_TAG_NAMES.has(tagName));
|
|
127569
|
+
const resolvedEntries = Object.entries(props).map(([key, value]) => {
|
|
127570
|
+
const isDocumentContent = RAW_HTML_PROP_NAMES.has(key) || (isCodeTag && key === 'value');
|
|
127571
|
+
if (typeof value !== 'string' || isDocumentContent)
|
|
127572
|
+
return [key, value];
|
|
127573
|
+
return [key, resolveAttributeVariables(value, user)];
|
|
127574
|
+
});
|
|
127575
|
+
return Object.fromEntries(resolvedEntries);
|
|
127576
|
+
}
|
|
127489
127577
|
/**
|
|
127490
127578
|
* Custom React.createElement wrapper that recovers real JS prop values for
|
|
127491
127579
|
* custom components. rehype-react v6 uses hast-to-hyperscript, which stringifies
|
|
@@ -127497,7 +127585,7 @@ function exportComponentsForRehype(components) {
|
|
|
127497
127585
|
* Only arrays win over `rest`, overwriting other shapes would undo correct
|
|
127498
127586
|
* React conversions like `style="color:red"` → `{ color: 'red' }`.
|
|
127499
127587
|
*/
|
|
127500
|
-
function createElementPreservingHastProps(type, props, ...children) {
|
|
127588
|
+
const makeCreateElementPreservingHastProps = (user) => function createElementPreservingHastProps(type, props, ...children) {
|
|
127501
127589
|
if (props?.node?.properties) {
|
|
127502
127590
|
const { node, ...rest } = props;
|
|
127503
127591
|
const mergedProps = { ...rest };
|
|
@@ -127507,15 +127595,16 @@ function createElementPreservingHastProps(type, props, ...children) {
|
|
|
127507
127595
|
});
|
|
127508
127596
|
// Strip undefined so positional args don't shadow node.properties.children
|
|
127509
127597
|
const definedChildren = children.filter(c => c !== undefined);
|
|
127510
|
-
|
|
127598
|
+
const withVariables = resolveVariablesInProps(mergedProps, user, node.tagName);
|
|
127599
|
+
return external_react_default().createElement(type, withVariables, ...definedChildren);
|
|
127511
127600
|
}
|
|
127512
|
-
return external_react_default().createElement(type, props, ...children);
|
|
127513
|
-
}
|
|
127601
|
+
return external_react_default().createElement(type, props && resolveVariablesInProps(props, user), ...children);
|
|
127602
|
+
};
|
|
127514
127603
|
/** Create a rehype-react processor */
|
|
127515
|
-
function createRehypeReactProcessor(components) {
|
|
127604
|
+
function createRehypeReactProcessor(components, variables) {
|
|
127516
127605
|
// @ts-expect-error - rehype-react types are incompatible with React.Fragment return type
|
|
127517
127606
|
return unified().use((rehype_react_default()), {
|
|
127518
|
-
createElement:
|
|
127607
|
+
createElement: makeCreateElementPreservingHastProps(user(variables)),
|
|
127519
127608
|
Fragment: (external_react_default()).Fragment,
|
|
127520
127609
|
components,
|
|
127521
127610
|
passNode: true,
|
|
@@ -127530,7 +127619,7 @@ function createTocComponent(tocHast) {
|
|
|
127530
127619
|
components: { p: (external_react_default()).Fragment },
|
|
127531
127620
|
});
|
|
127532
127621
|
const tocReactElement = tocProcessor.stringify(tocHast);
|
|
127533
|
-
const TocComponent = () => tocReactElement ?
|
|
127622
|
+
const TocComponent = () => tocReactElement ? external_react_default().createElement(components_TableOfContents, null, tocReactElement) : null;
|
|
127534
127623
|
TocComponent.displayName = 'Toc';
|
|
127535
127624
|
return TocComponent;
|
|
127536
127625
|
}
|
|
@@ -127579,7 +127668,7 @@ const renderMdxish = (tree, opts = {}) => {
|
|
|
127579
127668
|
Object.entries(localScope).forEach(([name, value]) => {
|
|
127580
127669
|
componentsForRehype[name] = value;
|
|
127581
127670
|
});
|
|
127582
|
-
const processor = createRehypeReactProcessor(componentsForRehype);
|
|
127671
|
+
const processor = createRehypeReactProcessor(componentsForRehype, variables);
|
|
127583
127672
|
const content = processor.stringify(tree);
|
|
127584
127673
|
const tocHast = headings.length > 0 ? tocToHast(headings, variables) : null;
|
|
127585
127674
|
return buildRMDXModule(content, headings, tocHast, { ...contextOpts, variables });
|
|
@@ -127635,24 +127724,6 @@ function runSync(code, options) {
|
|
|
127635
127724
|
// EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js
|
|
127636
127725
|
var jsx_runtime = __webpack_require__(4848);
|
|
127637
127726
|
var jsx_runtime_namespaceObject = /*#__PURE__*/__webpack_require__.t(jsx_runtime, 2);
|
|
127638
|
-
;// ./utils/user.ts
|
|
127639
|
-
const User = (variables) => {
|
|
127640
|
-
const { user = {}, defaults = [] } = variables || {};
|
|
127641
|
-
return new Proxy(user, {
|
|
127642
|
-
get(target, attribute) {
|
|
127643
|
-
if (typeof attribute === 'symbol') {
|
|
127644
|
-
return '';
|
|
127645
|
-
}
|
|
127646
|
-
if (attribute in target) {
|
|
127647
|
-
return target[attribute];
|
|
127648
|
-
}
|
|
127649
|
-
const def = defaults.find((d) => d.name === attribute);
|
|
127650
|
-
return def ? def.default : attribute.toUpperCase();
|
|
127651
|
-
},
|
|
127652
|
-
});
|
|
127653
|
-
};
|
|
127654
|
-
/* harmony default export */ const user = (User);
|
|
127655
|
-
|
|
127656
127727
|
;// ./lib/run.tsx
|
|
127657
127728
|
|
|
127658
127729
|
|
|
@@ -127897,7 +127968,7 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
|
127897
127968
|
|
|
127898
127969
|
|
|
127899
127970
|
|
|
127900
|
-
const
|
|
127971
|
+
const index_utils = {
|
|
127901
127972
|
get options() {
|
|
127902
127973
|
return { ...options };
|
|
127903
127974
|
},
|