@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.js
CHANGED
|
@@ -285,7 +285,7 @@ function visit(tree, test, visitor, reverse) {
|
|
|
285
285
|
|
|
286
286
|
/***/ }),
|
|
287
287
|
|
|
288
|
-
/***/
|
|
288
|
+
/***/ 7644:
|
|
289
289
|
/***/ ((__unused_webpack_module, exports) => {
|
|
290
290
|
|
|
291
291
|
"use strict";
|
|
@@ -359,7 +359,7 @@ exports["default"] = canonical;
|
|
|
359
359
|
|
|
360
360
|
/***/ }),
|
|
361
361
|
|
|
362
|
-
/***/
|
|
362
|
+
/***/ 4350:
|
|
363
363
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
364
364
|
|
|
365
365
|
"use strict";
|
|
@@ -368,15 +368,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
368
368
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
369
369
|
};
|
|
370
370
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
371
|
-
const canonical_1 = __importDefault(__webpack_require__(
|
|
372
|
-
const modes_1 = __webpack_require__(
|
|
373
|
-
const uppercase_1 = __importDefault(__webpack_require__(
|
|
371
|
+
const canonical_1 = __importDefault(__webpack_require__(7644));
|
|
372
|
+
const modes_1 = __webpack_require__(1130);
|
|
373
|
+
const uppercase_1 = __importDefault(__webpack_require__(3622));
|
|
374
374
|
exports["default"] = { uppercase: uppercase_1.default, canonical: canonical_1.default, modes: modes_1.modes, getMode: modes_1.getMode };
|
|
375
375
|
|
|
376
376
|
|
|
377
377
|
/***/ }),
|
|
378
378
|
|
|
379
|
-
/***/
|
|
379
|
+
/***/ 1130:
|
|
380
380
|
/***/ ((__unused_webpack_module, exports) => {
|
|
381
381
|
|
|
382
382
|
"use strict";
|
|
@@ -435,6 +435,7 @@ exports.modes = {
|
|
|
435
435
|
node: 'javascript',
|
|
436
436
|
macruby: 'ruby',
|
|
437
437
|
markdown: 'gfm',
|
|
438
|
+
md: 'gfm',
|
|
438
439
|
ml: ['mllike', 'text/x-ocaml'],
|
|
439
440
|
mssql: ['sql', 'text/x-mssql'],
|
|
440
441
|
mysql: ['sql', 'text/x-mysql'],
|
|
@@ -489,7 +490,7 @@ function getMode(lang) {
|
|
|
489
490
|
|
|
490
491
|
/***/ }),
|
|
491
492
|
|
|
492
|
-
/***/
|
|
493
|
+
/***/ 3622:
|
|
493
494
|
/***/ ((__unused_webpack_module, exports) => {
|
|
494
495
|
|
|
495
496
|
"use strict";
|
|
@@ -11619,7 +11620,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
11619
11620
|
stripComments: () => (/* reexport */ lib_stripComments),
|
|
11620
11621
|
tags: () => (/* reexport */ lib_tags),
|
|
11621
11622
|
tailwindCompiler: () => (/* reexport */ tailwindCompiler),
|
|
11622
|
-
utils: () => (/* binding */
|
|
11623
|
+
utils: () => (/* binding */ index_utils)
|
|
11623
11624
|
});
|
|
11624
11625
|
|
|
11625
11626
|
// NAMESPACE OBJECT: ./components/index.ts
|
|
@@ -11941,16 +11942,16 @@ const Code = (props) => {
|
|
|
11941
11942
|
};
|
|
11942
11943
|
/* harmony default export */ const components_Code = (Code);
|
|
11943
11944
|
|
|
11944
|
-
// EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/index.js
|
|
11945
|
-
var
|
|
11946
|
-
var
|
|
11945
|
+
// EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/utils/index.js
|
|
11946
|
+
var utils = __webpack_require__(4350);
|
|
11947
|
+
var utils_default = /*#__PURE__*/__webpack_require__.n(utils);
|
|
11947
11948
|
;// ./components/CodeTabs/index.tsx
|
|
11948
11949
|
|
|
11949
11950
|
|
|
11950
11951
|
|
|
11951
11952
|
|
|
11952
11953
|
let mermaid;
|
|
11953
|
-
const { uppercase } = (
|
|
11954
|
+
const { uppercase } = (utils_default());
|
|
11954
11955
|
// Module-level queue that batches mermaid nodes across all CodeTabs instances into a
|
|
11955
11956
|
// single mermaid.run() call. This is necessary because mermaid generates SVG element IDs
|
|
11956
11957
|
// using Date.now(), which collides when multiple diagrams render in the same millisecond.
|
|
@@ -74433,11 +74434,6 @@ const looseHtmlEntityConstruct = {
|
|
|
74433
74434
|
name: 'looseHtmlEntity',
|
|
74434
74435
|
tokenize: tokenizeLooseHtmlEntity,
|
|
74435
74436
|
};
|
|
74436
|
-
function resolveEntity(name) {
|
|
74437
|
-
const input = `&${name};`;
|
|
74438
|
-
const decoded = decode_decodeHTMLStrict(input);
|
|
74439
|
-
return decoded !== input ? decoded : undefined;
|
|
74440
|
-
}
|
|
74441
74437
|
function tokenizeLooseHtmlEntity(effects, ok, nok) {
|
|
74442
74438
|
let length = 0;
|
|
74443
74439
|
const start = (code) => {
|
|
@@ -74504,28 +74500,9 @@ function tokenizeLooseHtmlEntity(effects, ok, nok) {
|
|
|
74504
74500
|
}
|
|
74505
74501
|
function exitLooseHtmlEntity(token) {
|
|
74506
74502
|
const raw = this.sliceSerialize(token);
|
|
74507
|
-
|
|
74508
|
-
|
|
74509
|
-
|
|
74510
|
-
if (decoded) {
|
|
74511
|
-
this.enter({ type: 'text', value: decoded }, token);
|
|
74512
|
-
this.exit(token);
|
|
74513
|
-
return;
|
|
74514
|
-
}
|
|
74515
|
-
}
|
|
74516
|
-
else {
|
|
74517
|
-
for (let len = entityChars.length; len >= 2; len -= 1) {
|
|
74518
|
-
const candidate = entityChars.slice(0, len);
|
|
74519
|
-
const decoded = resolveEntity(candidate);
|
|
74520
|
-
if (decoded) {
|
|
74521
|
-
const remainder = entityChars.slice(len);
|
|
74522
|
-
this.enter({ type: 'text', value: decoded + remainder }, token);
|
|
74523
|
-
this.exit(token);
|
|
74524
|
-
return;
|
|
74525
|
-
}
|
|
74526
|
-
}
|
|
74527
|
-
}
|
|
74528
|
-
this.enter({ type: 'text', value: raw }, token);
|
|
74503
|
+
// `decodeHTML` follows the HTML spec's legacy rules, where only a small
|
|
74504
|
+
// whitelist of names may omit the semicolon, so `&partner_key` stays intact.
|
|
74505
|
+
this.enter({ type: 'text', value: esm_decode_decodeHTML(raw) }, token);
|
|
74529
74506
|
this.exit(token);
|
|
74530
74507
|
}
|
|
74531
74508
|
function looseHtmlEntity() {
|
|
@@ -74545,10 +74522,11 @@ function looseHtmlEntityFromMarkdown() {
|
|
|
74545
74522
|
/**
|
|
74546
74523
|
* Micromark extension for HTML entities without semicolons.
|
|
74547
74524
|
*
|
|
74548
|
-
* Handles named entities
|
|
74549
|
-
*
|
|
74550
|
-
* `&#
|
|
74551
|
-
* standard parser
|
|
74525
|
+
* Handles the named entities the HTML spec lets authors write without a
|
|
74526
|
+
* semicolon (e.g. ` `, `&`, `©`), decimal numeric references (e.g.
|
|
74527
|
+
* ` `, `©`), and hex numeric references (e.g. ` `, ` `).
|
|
74528
|
+
* Entities that already include the semicolon are left for the standard parser
|
|
74529
|
+
* to handle.
|
|
74552
74530
|
*/
|
|
74553
74531
|
|
|
74554
74532
|
|
|
@@ -106328,9 +106306,9 @@ const resolveDeferredAttributeExpressionProps = () => (tree, file) => {
|
|
|
106328
106306
|
properties[name] = name === 'style' && style_object_to_css_isPlainObject(result) ? styleObjectToCssText(result) : result;
|
|
106329
106307
|
}
|
|
106330
106308
|
catch {
|
|
106331
|
-
// Evaluation failed —
|
|
106332
|
-
//
|
|
106333
|
-
properties[name] = source
|
|
106309
|
+
// Evaluation failed — keep the literal `{...}`, matching how `evaluateExpressions` falls
|
|
106310
|
+
// back in body text. Variable references like `{user.name}` stay resolvable at render time.
|
|
106311
|
+
properties[name] = `{${source}}`;
|
|
106334
106312
|
}
|
|
106335
106313
|
});
|
|
106336
106314
|
delete node.data.deferredExpressions;
|
|
@@ -106417,10 +106395,44 @@ const restoreBooleanProperties = () => tree => {
|
|
|
106417
106395
|
};
|
|
106418
106396
|
|
|
106419
106397
|
|
|
106398
|
+
;// ./processor/transform/mdxish/tables/gfm-cell-normalization.ts
|
|
106399
|
+
/** `<br />` is the only line break a GFM pipe cell can carry, since cells are single-line. */
|
|
106400
|
+
const createLineBreak = () => ({
|
|
106401
|
+
type: 'mdxJsxTextElement',
|
|
106402
|
+
name: 'br',
|
|
106403
|
+
attributes: [],
|
|
106404
|
+
children: [],
|
|
106405
|
+
});
|
|
106406
|
+
const createText = (value) => ({ type: 'text', value });
|
|
106407
|
+
const isText = (node) => node.type === 'text';
|
|
106408
|
+
const hasChildren = (node) => 'children' in node;
|
|
106409
|
+
const splitOnLineBreaks = (value) => value.split('\n').reduce((nodes, segment, index) => {
|
|
106410
|
+
if (index > 0)
|
|
106411
|
+
nodes.push(createLineBreak());
|
|
106412
|
+
if (segment)
|
|
106413
|
+
nodes.push(createText(segment));
|
|
106414
|
+
return nodes;
|
|
106415
|
+
}, []);
|
|
106416
|
+
const normalizeNodes = (nodes) => nodes.flatMap(node => {
|
|
106417
|
+
if (node.type === 'break')
|
|
106418
|
+
return createLineBreak();
|
|
106419
|
+
if (isText(node))
|
|
106420
|
+
return splitOnLineBreaks(node.value);
|
|
106421
|
+
if (hasChildren(node))
|
|
106422
|
+
return { ...node, children: normalizeNodes(node.children) };
|
|
106423
|
+
return node;
|
|
106424
|
+
});
|
|
106425
|
+
/**
|
|
106426
|
+
* Returns a copy of the cell's children with line breaks — `break` nodes and newlines inside
|
|
106427
|
+
* text — rewritten to the `<br />` a single-line GFM pipe cell can carry.
|
|
106428
|
+
*/
|
|
106429
|
+
const normalizeCellChildrenForGfm = (cell) => normalizeNodes(cell.children);
|
|
106430
|
+
|
|
106420
106431
|
;// ./processor/transform/mdxish/tables/mdxish-tables-to-jsx.ts
|
|
106421
106432
|
|
|
106422
106433
|
|
|
106423
106434
|
|
|
106435
|
+
|
|
106424
106436
|
const SELF_CLOSING_JSX_REGEX = /^\s*<[A-Z][^>]*\/>\s*$/;
|
|
106425
106437
|
const mdxish_tables_to_jsx_alignToStyle = (align) => {
|
|
106426
106438
|
if (!align || align === 'left')
|
|
@@ -106436,6 +106448,38 @@ const mdxish_tables_to_jsx_alignToStyle = (align) => {
|
|
|
106436
106448
|
};
|
|
106437
106449
|
const mdxish_tables_to_jsx_isTableCell = (node) => ['tableHead', 'tableCell'].includes(node.type);
|
|
106438
106450
|
const mdxish_tables_to_jsx_isLiteral = (node) => 'value' in node;
|
|
106451
|
+
/**
|
|
106452
|
+
* Block-level content that a single-line GFM cell cannot hold. `phrasing()` returns true
|
|
106453
|
+
* for inline types (text, emphasis, strong, link…), which are safe to keep.
|
|
106454
|
+
*/
|
|
106455
|
+
const isFlowChild = (child) => {
|
|
106456
|
+
if (child.type === 'paragraph' || child.type === 'plain' || child.type === 'escape')
|
|
106457
|
+
return false;
|
|
106458
|
+
if (child.type === NodeTypes.variable)
|
|
106459
|
+
return false;
|
|
106460
|
+
if (phrasing(child))
|
|
106461
|
+
return false;
|
|
106462
|
+
if (child.type === 'html')
|
|
106463
|
+
return SELF_CLOSING_JSX_REGEX.test(child.value);
|
|
106464
|
+
return true;
|
|
106465
|
+
};
|
|
106466
|
+
/** A newline in a normalized cell (e.g. inside `inlineCode`) has no inline equivalent. */
|
|
106467
|
+
const containsLiteralNewline = (nodes) => nodes.some(node => (mdxish_tables_to_jsx_isLiteral(node) && node.value.includes('\n')) || (hasChildren(node) && containsLiteralNewline(node.children)));
|
|
106468
|
+
/** True when normalized cell content survives a single-line GFM pipe cell without losing structure. */
|
|
106469
|
+
const canCellBeGfm = (children) => {
|
|
106470
|
+
// Multiple paragraphs are distinct blocks; a single-line cell cannot keep them apart.
|
|
106471
|
+
if (children.filter(child => child.type === 'paragraph').length > 1)
|
|
106472
|
+
return false;
|
|
106473
|
+
if (children.some(isFlowChild))
|
|
106474
|
+
return false;
|
|
106475
|
+
return !containsLiteralNewline(children);
|
|
106476
|
+
};
|
|
106477
|
+
/** On the promote path a `break` would serialize as a dangling `\`, so collapse it to a newline. */
|
|
106478
|
+
const flattenBreaksToNewlines = (cell) => {
|
|
106479
|
+
visit(cell, 'break', (_, index, parent) => {
|
|
106480
|
+
parent.children.splice(index, 1, { type: 'text', value: '\n' });
|
|
106481
|
+
});
|
|
106482
|
+
};
|
|
106439
106483
|
/**
|
|
106440
106484
|
* Mdxish-specific version of `tablesToJsx`. Differs from the shared MDX version:
|
|
106441
106485
|
*
|
|
@@ -106446,52 +106490,25 @@ const mdxish_tables_to_jsx_isLiteral = (node) => 'value' in node;
|
|
|
106446
106490
|
*/
|
|
106447
106491
|
const mdxishTablesToJsx = () => tree => {
|
|
106448
106492
|
visit(tree, (node) => ['table', 'tableau'].includes(node.type), (table, index, parent) => {
|
|
106449
|
-
|
|
106493
|
+
const gfmCells = [];
|
|
106494
|
+
let requiresJsxTable = false;
|
|
106450
106495
|
visit(table, mdxish_tables_to_jsx_isTableCell, (cell) => {
|
|
106451
|
-
|
|
106452
|
-
|
|
106453
|
-
|
|
106454
|
-
|
|
106455
|
-
});
|
|
106456
|
-
// A cell with more than one paragraph child cannot be serialized as GFM
|
|
106457
|
-
// (pipe tables are single-line per cell), so force JSX <Table> output to
|
|
106458
|
-
// preserve paragraph separation.
|
|
106459
|
-
const paragraphCount = cell.children.filter(child => child.type === 'paragraph').length;
|
|
106460
|
-
if (paragraphCount > 1) {
|
|
106461
|
-
hasFlowContent = true;
|
|
106462
|
-
return;
|
|
106463
|
-
}
|
|
106464
|
-
// Check if any child is "flow" content (block-level) that requires JSX <Table>
|
|
106465
|
-
// serialization instead of GFM. `phrasing()` from mdast-util-phrasing returns
|
|
106466
|
-
// true for inline node types (text, emphasis, strong, link, etc.) which are
|
|
106467
|
-
// safe to keep in GFM cells.
|
|
106468
|
-
const hasFlowChild = cell.children.some(child => {
|
|
106469
|
-
if (child.type === 'paragraph' || child.type === 'plain' || child.type === 'escape')
|
|
106470
|
-
return false;
|
|
106471
|
-
if (child.type === NodeTypes.variable)
|
|
106472
|
-
return false;
|
|
106473
|
-
if (phrasing(child))
|
|
106474
|
-
return false;
|
|
106475
|
-
if (child.type === 'html') {
|
|
106476
|
-
return SELF_CLOSING_JSX_REGEX.test(child.value);
|
|
106477
|
-
}
|
|
106478
|
-
return true;
|
|
106479
|
-
});
|
|
106480
|
-
if (hasFlowChild) {
|
|
106481
|
-
hasFlowContent = true;
|
|
106482
|
-
}
|
|
106483
|
-
if (!hasFlowContent) {
|
|
106484
|
-
visit(cell, mdxish_tables_to_jsx_isLiteral, (node) => {
|
|
106485
|
-
if (node.value.match(/\n/)) {
|
|
106486
|
-
hasFlowContent = true;
|
|
106487
|
-
}
|
|
106488
|
-
});
|
|
106496
|
+
const normalized = normalizeCellChildrenForGfm(cell);
|
|
106497
|
+
if (!canCellBeGfm(normalized)) {
|
|
106498
|
+
requiresJsxTable = true;
|
|
106499
|
+
return EXIT;
|
|
106489
106500
|
}
|
|
106501
|
+
gfmCells.push([cell, normalized]);
|
|
106502
|
+
return undefined;
|
|
106490
106503
|
});
|
|
106491
|
-
if (!
|
|
106504
|
+
if (!requiresJsxTable) {
|
|
106505
|
+
gfmCells.forEach(([cell, children]) => {
|
|
106506
|
+
cell.children = children;
|
|
106507
|
+
});
|
|
106492
106508
|
table.type = 'table';
|
|
106493
106509
|
return;
|
|
106494
106510
|
}
|
|
106511
|
+
visit(table, mdxish_tables_to_jsx_isTableCell, flattenBreaksToNewlines);
|
|
106495
106512
|
const styles = table.align.map(mdxish_tables_to_jsx_alignToStyle);
|
|
106496
106513
|
const head = {
|
|
106497
106514
|
attributes: [],
|
|
@@ -107197,6 +107214,24 @@ const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }
|
|
|
107197
107214
|
};
|
|
107198
107215
|
/* harmony default export */ const contexts = (Contexts);
|
|
107199
107216
|
|
|
107217
|
+
;// ./utils/user.ts
|
|
107218
|
+
const User = (variables) => {
|
|
107219
|
+
const { user = {}, defaults = [] } = variables || {};
|
|
107220
|
+
return new Proxy(user, {
|
|
107221
|
+
get(target, attribute) {
|
|
107222
|
+
if (typeof attribute === 'symbol') {
|
|
107223
|
+
return '';
|
|
107224
|
+
}
|
|
107225
|
+
if (attribute in target) {
|
|
107226
|
+
return target[attribute];
|
|
107227
|
+
}
|
|
107228
|
+
const def = defaults.find((d) => d.name === attribute);
|
|
107229
|
+
return def ? def.default : attribute.toUpperCase();
|
|
107230
|
+
},
|
|
107231
|
+
});
|
|
107232
|
+
};
|
|
107233
|
+
/* harmony default export */ const user = (User);
|
|
107234
|
+
|
|
107200
107235
|
;// ./lib/utils/makeUseMdxComponents.ts
|
|
107201
107236
|
|
|
107202
107237
|
|
|
@@ -107227,6 +107262,35 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
107227
107262
|
};
|
|
107228
107263
|
/* harmony default export */ const makeUseMdxComponents = (makeUseMDXComponents);
|
|
107229
107264
|
|
|
107265
|
+
;// ./lib/utils/mdxish/mdxish-variables.ts
|
|
107266
|
+
|
|
107267
|
+
// The `$` guard skips template-literal interpolation: `${user.name}` embeds `{user.name}`, and
|
|
107268
|
+
// substituting it would leave a mangled `` `Hi $Name` `` behind. Those belong to an expression,
|
|
107269
|
+
// which either evaluated already or is meant to stay literal.
|
|
107270
|
+
const MDX_VARIABLE_REGEX = new RegExp(`(?<!\\$)${variable_.MDX_VARIABLE_REGEXP}`, 'gu');
|
|
107271
|
+
// Bracket notation names the same variable as dot notation, so normalize it before substituting.
|
|
107272
|
+
// Escaped and `$`-prefixed forms are left alone so a reference that stays literal keeps its source.
|
|
107273
|
+
// A closing escape needs no lookahead: requiring a literal `]}` already rules out `]\}`.
|
|
107274
|
+
const BRACKET_NOTATION_REGEX = /(?<![$\\])\{user\[['"](\w+)['"]\]\}/gu;
|
|
107275
|
+
/**
|
|
107276
|
+
* Resolve `{user.*}` in a JSX attribute value against the same `user` binding the rmdx engine gets,
|
|
107277
|
+
* so both engines agree. Body text differs on empty values: `Variable` falls back to the default.
|
|
107278
|
+
*
|
|
107279
|
+
* Legacy `<<...>>` is valid inside a quoted attribute but deliberately left literal — attributes are
|
|
107280
|
+
* an MDX surface, and `{user.*}` is the syntax authors use there.
|
|
107281
|
+
*/
|
|
107282
|
+
function resolveAttributeVariables(value, user) {
|
|
107283
|
+
if (!value.includes('{user'))
|
|
107284
|
+
return value;
|
|
107285
|
+
return value
|
|
107286
|
+
.replace(BRACKET_NOTATION_REGEX, '{user.$1}')
|
|
107287
|
+
.replace(MDX_VARIABLE_REGEX, (source, escapePrefix, name, escapeSuffix) => {
|
|
107288
|
+
if (escapePrefix || escapeSuffix)
|
|
107289
|
+
return source;
|
|
107290
|
+
return user[name];
|
|
107291
|
+
});
|
|
107292
|
+
}
|
|
107293
|
+
|
|
107230
107294
|
;// ./lib/utils/mdxish/mdxish-render-utils.tsx
|
|
107231
107295
|
|
|
107232
107296
|
|
|
@@ -107235,6 +107299,8 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
107235
107299
|
|
|
107236
107300
|
|
|
107237
107301
|
|
|
107302
|
+
|
|
107303
|
+
|
|
107238
107304
|
/** Flatten CustomComponents into a component map for rehype-react */
|
|
107239
107305
|
function exportComponentsForRehype(components) {
|
|
107240
107306
|
const exported = Object.entries(components).reduce((memo, [tag, mod]) => {
|
|
@@ -107262,6 +107328,28 @@ function exportComponentsForRehype(components) {
|
|
|
107262
107328
|
result.variable = (variable_default());
|
|
107263
107329
|
return result;
|
|
107264
107330
|
}
|
|
107331
|
+
/**
|
|
107332
|
+
* Code rides on a `value` prop, and `variablesCodeResolver` owns it at parse time where it
|
|
107333
|
+
* deliberately leaves mermaid alone; resolving it again here would override that.
|
|
107334
|
+
*/
|
|
107335
|
+
const CODE_TAG_NAMES = new Set(['code']);
|
|
107336
|
+
/** Raw markup injected with `dangerouslySetInnerHTML` by HTMLBlock and Embed — never interpolate. */
|
|
107337
|
+
const RAW_HTML_PROP_NAMES = new Set(['html']);
|
|
107338
|
+
/**
|
|
107339
|
+
* Resolve `{user.*}` in string-valued props. Body text is handled by the `Variable` component, but
|
|
107340
|
+
* attributes are plain strings, so they are substituted here — at render time, so that a
|
|
107341
|
+
* server-parsed (user-agnostic) tree resolves against the current reader's variables.
|
|
107342
|
+
*/
|
|
107343
|
+
function resolveVariablesInProps(props, user, tagName) {
|
|
107344
|
+
const isCodeTag = Boolean(tagName && CODE_TAG_NAMES.has(tagName));
|
|
107345
|
+
const resolvedEntries = Object.entries(props).map(([key, value]) => {
|
|
107346
|
+
const isDocumentContent = RAW_HTML_PROP_NAMES.has(key) || (isCodeTag && key === 'value');
|
|
107347
|
+
if (typeof value !== 'string' || isDocumentContent)
|
|
107348
|
+
return [key, value];
|
|
107349
|
+
return [key, resolveAttributeVariables(value, user)];
|
|
107350
|
+
});
|
|
107351
|
+
return Object.fromEntries(resolvedEntries);
|
|
107352
|
+
}
|
|
107265
107353
|
/**
|
|
107266
107354
|
* Custom React.createElement wrapper that recovers real JS prop values for
|
|
107267
107355
|
* custom components. rehype-react v6 uses hast-to-hyperscript, which stringifies
|
|
@@ -107273,7 +107361,7 @@ function exportComponentsForRehype(components) {
|
|
|
107273
107361
|
* Only arrays win over `rest`, overwriting other shapes would undo correct
|
|
107274
107362
|
* React conversions like `style="color:red"` → `{ color: 'red' }`.
|
|
107275
107363
|
*/
|
|
107276
|
-
function createElementPreservingHastProps(type, props, ...children) {
|
|
107364
|
+
const makeCreateElementPreservingHastProps = (user) => function createElementPreservingHastProps(type, props, ...children) {
|
|
107277
107365
|
if (props?.node?.properties) {
|
|
107278
107366
|
const { node, ...rest } = props;
|
|
107279
107367
|
const mergedProps = { ...rest };
|
|
@@ -107283,15 +107371,16 @@ function createElementPreservingHastProps(type, props, ...children) {
|
|
|
107283
107371
|
});
|
|
107284
107372
|
// Strip undefined so positional args don't shadow node.properties.children
|
|
107285
107373
|
const definedChildren = children.filter(c => c !== undefined);
|
|
107286
|
-
|
|
107374
|
+
const withVariables = resolveVariablesInProps(mergedProps, user, node.tagName);
|
|
107375
|
+
return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(type, withVariables, ...definedChildren);
|
|
107287
107376
|
}
|
|
107288
|
-
return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(type, props, ...children);
|
|
107289
|
-
}
|
|
107377
|
+
return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(type, props && resolveVariablesInProps(props, user), ...children);
|
|
107378
|
+
};
|
|
107290
107379
|
/** Create a rehype-react processor */
|
|
107291
|
-
function createRehypeReactProcessor(components) {
|
|
107380
|
+
function createRehypeReactProcessor(components, variables) {
|
|
107292
107381
|
// @ts-expect-error - rehype-react types are incompatible with React.Fragment return type
|
|
107293
107382
|
return unified().use((rehype_react_default()), {
|
|
107294
|
-
createElement:
|
|
107383
|
+
createElement: makeCreateElementPreservingHastProps(user(variables)),
|
|
107295
107384
|
Fragment: (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default()).Fragment,
|
|
107296
107385
|
components,
|
|
107297
107386
|
passNode: true,
|
|
@@ -107306,7 +107395,7 @@ function createTocComponent(tocHast) {
|
|
|
107306
107395
|
components: { p: (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default()).Fragment },
|
|
107307
107396
|
});
|
|
107308
107397
|
const tocReactElement = tocProcessor.stringify(tocHast);
|
|
107309
|
-
const TocComponent = () => tocReactElement ?
|
|
107398
|
+
const TocComponent = () => tocReactElement ? external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(components_TableOfContents, null, tocReactElement) : null;
|
|
107310
107399
|
TocComponent.displayName = 'Toc';
|
|
107311
107400
|
return TocComponent;
|
|
107312
107401
|
}
|
|
@@ -107355,7 +107444,7 @@ const renderMdxish = (tree, opts = {}) => {
|
|
|
107355
107444
|
Object.entries(localScope).forEach(([name, value]) => {
|
|
107356
107445
|
componentsForRehype[name] = value;
|
|
107357
107446
|
});
|
|
107358
|
-
const processor = createRehypeReactProcessor(componentsForRehype);
|
|
107447
|
+
const processor = createRehypeReactProcessor(componentsForRehype, variables);
|
|
107359
107448
|
const content = processor.stringify(tree);
|
|
107360
107449
|
const tocHast = headings.length > 0 ? tocToHast(headings, variables) : null;
|
|
107361
107450
|
return buildRMDXModule(content, headings, tocHast, { ...contextOpts, variables });
|
|
@@ -107411,24 +107500,6 @@ function runSync(code, options) {
|
|
|
107411
107500
|
// EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js
|
|
107412
107501
|
var jsx_runtime = __webpack_require__(2467);
|
|
107413
107502
|
var jsx_runtime_namespaceObject = /*#__PURE__*/__webpack_require__.t(jsx_runtime, 2);
|
|
107414
|
-
;// ./utils/user.ts
|
|
107415
|
-
const User = (variables) => {
|
|
107416
|
-
const { user = {}, defaults = [] } = variables || {};
|
|
107417
|
-
return new Proxy(user, {
|
|
107418
|
-
get(target, attribute) {
|
|
107419
|
-
if (typeof attribute === 'symbol') {
|
|
107420
|
-
return '';
|
|
107421
|
-
}
|
|
107422
|
-
if (attribute in target) {
|
|
107423
|
-
return target[attribute];
|
|
107424
|
-
}
|
|
107425
|
-
const def = defaults.find((d) => d.name === attribute);
|
|
107426
|
-
return def ? def.default : attribute.toUpperCase();
|
|
107427
|
-
},
|
|
107428
|
-
});
|
|
107429
|
-
};
|
|
107430
|
-
/* harmony default export */ const user = (User);
|
|
107431
|
-
|
|
107432
107503
|
;// ./lib/run.tsx
|
|
107433
107504
|
|
|
107434
107505
|
|
|
@@ -107673,7 +107744,7 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
|
107673
107744
|
|
|
107674
107745
|
|
|
107675
107746
|
|
|
107676
|
-
const
|
|
107747
|
+
const index_utils = {
|
|
107677
107748
|
get options() {
|
|
107678
107749
|
return { ...options };
|
|
107679
107750
|
},
|