@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.
@@ -0,0 +1,9 @@
1
+ import type { Node, TableCell } from 'mdast';
2
+ export declare const hasChildren: (node: Node) => node is Node & {
3
+ children: Node[];
4
+ };
5
+ /**
6
+ * Returns a copy of the cell's children with line breaks — `break` nodes and newlines inside
7
+ * text — rewritten to the `<br />` a single-line GFM pipe cell can carry.
8
+ */
9
+ export declare const normalizeCellChildrenForGfm: (cell: TableCell) => TableCell["children"];
@@ -275,7 +275,7 @@ function visit(tree, test, visitor, reverse) {
275
275
 
276
276
  /***/ }),
277
277
 
278
- /***/ 9762:
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
- /***/ 7900:
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__(9762));
362
- const modes_1 = __webpack_require__(1412);
363
- const uppercase_1 = __importDefault(__webpack_require__(8892));
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
- /***/ 1412:
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
- /***/ 8892:
483
+ /***/ 3622:
483
484
  /***/ ((__unused_webpack_module, exports) => {
484
485
 
485
486
  "use strict";
@@ -20197,7 +20198,7 @@ const CONTINUE = true
20197
20198
  /**
20198
20199
  * Stop traversing immediately.
20199
20200
  */
20200
- const EXIT = false
20201
+ const lib_EXIT = false
20201
20202
 
20202
20203
  /**
20203
20204
  * Do not traverse this node’s children.
@@ -20311,7 +20312,7 @@ function visitParents(tree, test, visitor, reverse) {
20311
20312
  // @ts-expect-error: `visitor` is now a visitor.
20312
20313
  result = toResult(visitor(node, parents))
20313
20314
 
20314
- if (result[0] === EXIT) {
20315
+ if (result[0] === lib_EXIT) {
20315
20316
  return result
20316
20317
  }
20317
20318
  }
@@ -20328,7 +20329,7 @@ function visitParents(tree, test, visitor, reverse) {
20328
20329
 
20329
20330
  subresult = factory(child, offset, grandparents)()
20330
20331
 
20331
- if (subresult[0] === EXIT) {
20332
+ if (subresult[0] === lib_EXIT) {
20332
20333
  return subresult
20333
20334
  }
20334
20335
 
@@ -34035,7 +34036,7 @@ function formatHeadingAsSetext(node, state) {
34035
34036
  node.type === 'break'
34036
34037
  ) {
34037
34038
  literalWithBreak = true
34038
- return EXIT
34039
+ return lib_EXIT
34039
34040
  }
34040
34041
  })
34041
34042
 
@@ -52885,7 +52886,7 @@ const lib_CONTINUE = Symbol('continue')
52885
52886
  /**
52886
52887
  * Stop traversing immediately.
52887
52888
  */
52888
- const lib_EXIT = Symbol('exit')
52889
+ const estree_util_visit_lib_EXIT = Symbol('exit')
52889
52890
 
52890
52891
  /**
52891
52892
  * Do not traverse this node’s children.
@@ -52945,7 +52946,7 @@ function estree_util_visit_lib_visit(tree, visitor) {
52945
52946
  /** @type {ActionTuple} */
52946
52947
  const result = enter ? lib_toResult(enter(node, key, index, parents)) : []
52947
52948
 
52948
- if (result[0] === lib_EXIT) {
52949
+ if (result[0] === estree_util_visit_lib_EXIT) {
52949
52950
  return result
52950
52951
  }
52951
52952
 
@@ -52981,7 +52982,7 @@ function estree_util_visit_lib_visit(tree, visitor) {
52981
52982
  cIndex,
52982
52983
  grandparents
52983
52984
  )()
52984
- if (subresult[0] === lib_EXIT) return subresult
52985
+ if (subresult[0] === estree_util_visit_lib_EXIT) return subresult
52985
52986
  cIndex =
52986
52987
  typeof subresult[1] === 'number' ? subresult[1] : cIndex + 1
52987
52988
  } else {
@@ -52990,7 +52991,7 @@ function estree_util_visit_lib_visit(tree, visitor) {
52990
52991
  }
52991
52992
  } else if (nodelike(value)) {
52992
52993
  const subresult = build(value, cKey, undefined, grandparents)()
52993
- if (subresult[0] === lib_EXIT) return subresult
52994
+ if (subresult[0] === estree_util_visit_lib_EXIT) return subresult
52994
52995
  }
52995
52996
  }
52996
52997
  }
@@ -68773,7 +68774,7 @@ const hasNamedExport = (tree, name) => {
68773
68774
  node.data.estree.body[0].declaration.type === 'VariableDeclaration') {
68774
68775
  const { declarations } = node.data.estree.body[0].declaration;
68775
68776
  hasExport = !!declarations.find(declaration => 'name' in declaration.id && declaration.id.name === name);
68776
- return hasExport ? EXIT : CONTINUE;
68777
+ return hasExport ? lib_EXIT : CONTINUE;
68777
68778
  }
68778
68779
  });
68779
68780
  return hasExport;
@@ -69274,7 +69275,7 @@ const compatibilityTransfomer = () => tree => {
69274
69275
  const trimEmphasis = (node) => {
69275
69276
  lib_visit(node, 'text', child => {
69276
69277
  child.value = child.value.trim();
69277
- return EXIT;
69278
+ return lib_EXIT;
69278
69279
  });
69279
69280
  return node;
69280
69281
  };
@@ -86560,16 +86561,16 @@ const Code = (props) => {
86560
86561
  };
86561
86562
  /* harmony default export */ const components_Code = (Code);
86562
86563
 
86563
- // EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/index.js
86564
- var dist_utils = __webpack_require__(7900);
86565
- var dist_utils_default = /*#__PURE__*/__webpack_require__.n(dist_utils);
86564
+ // EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/utils/index.js
86565
+ var utils = __webpack_require__(4350);
86566
+ var utils_default = /*#__PURE__*/__webpack_require__.n(utils);
86566
86567
  ;// ./components/CodeTabs/index.tsx
86567
86568
 
86568
86569
 
86569
86570
 
86570
86571
 
86571
86572
  let mermaid;
86572
- const { uppercase } = (dist_utils_default());
86573
+ const { uppercase } = (utils_default());
86573
86574
  // Module-level queue that batches mermaid nodes across all CodeTabs instances into a
86574
86575
  // single mermaid.run() call. This is necessary because mermaid generates SVG element IDs
86575
86576
  // using Date.now(), which collides when multiple diagrams render in the same millisecond.
@@ -94607,11 +94608,6 @@ const looseHtmlEntityConstruct = {
94607
94608
  name: 'looseHtmlEntity',
94608
94609
  tokenize: tokenizeLooseHtmlEntity,
94609
94610
  };
94610
- function resolveEntity(name) {
94611
- const input = `&${name};`;
94612
- const decoded = decode_decodeHTMLStrict(input);
94613
- return decoded !== input ? decoded : undefined;
94614
- }
94615
94611
  function tokenizeLooseHtmlEntity(effects, ok, nok) {
94616
94612
  let length = 0;
94617
94613
  const start = (code) => {
@@ -94678,28 +94674,9 @@ function tokenizeLooseHtmlEntity(effects, ok, nok) {
94678
94674
  }
94679
94675
  function exitLooseHtmlEntity(token) {
94680
94676
  const raw = this.sliceSerialize(token);
94681
- const entityChars = raw.slice(1);
94682
- if (entityChars.startsWith('#')) {
94683
- const decoded = resolveEntity(entityChars);
94684
- if (decoded) {
94685
- this.enter({ type: 'text', value: decoded }, token);
94686
- this.exit(token);
94687
- return;
94688
- }
94689
- }
94690
- else {
94691
- for (let len = entityChars.length; len >= 2; len -= 1) {
94692
- const candidate = entityChars.slice(0, len);
94693
- const decoded = resolveEntity(candidate);
94694
- if (decoded) {
94695
- const remainder = entityChars.slice(len);
94696
- this.enter({ type: 'text', value: decoded + remainder }, token);
94697
- this.exit(token);
94698
- return;
94699
- }
94700
- }
94701
- }
94702
- this.enter({ type: 'text', value: raw }, token);
94677
+ // `decodeHTML` follows the HTML spec's legacy rules, where only a small
94678
+ // whitelist of names may omit the semicolon, so `&partner_key` stays intact.
94679
+ this.enter({ type: 'text', value: esm_decode_decodeHTML(raw) }, token);
94703
94680
  this.exit(token);
94704
94681
  }
94705
94682
  function looseHtmlEntity() {
@@ -94719,10 +94696,11 @@ function looseHtmlEntityFromMarkdown() {
94719
94696
  /**
94720
94697
  * Micromark extension for HTML entities without semicolons.
94721
94698
  *
94722
- * Handles named entities (e.g. `&nbsp`, `&amp`, `&copy`), decimal numeric
94723
- * references (e.g. `&#160`, `&#169`), and hex numeric references (e.g. `&#xa0`,
94724
- * `&#xA0`). Entities that already include the semicolon are left for the
94725
- * standard parser to handle.
94699
+ * Handles the named entities the HTML spec lets authors write without a
94700
+ * semicolon (e.g. `&nbsp`, `&amp`, `&copy`), decimal numeric references (e.g.
94701
+ * `&#160`, `&#169`), and hex numeric references (e.g. `&#xa0`, `&#xA0`).
94702
+ * Entities that already include the semicolon are left for the standard parser
94703
+ * to handle.
94726
94704
  */
94727
94705
 
94728
94706
 
@@ -100447,7 +100425,7 @@ const processTableNode = (node, index, parent, documentPosition) => {
100447
100425
  ((candidate.type === 'mdxJsxFlowElement' || candidate.type === 'mdxJsxTextElement') &&
100448
100426
  candidate.name === 'HTMLBlock'), () => {
100449
100427
  tableHasFlowContent = true;
100450
- return EXIT;
100428
+ return lib_EXIT;
100451
100429
  });
100452
100430
  // Re-parse text-only cells through markdown and detect flow content
100453
100431
  lib_visit(node, isTableCell, (cell) => {
@@ -100661,7 +100639,7 @@ const mdxish_tables_mdxishTables = () => tree => {
100661
100639
  if (tableNode.name !== 'Table' && tableNode.name !== 'table')
100662
100640
  return undefined;
100663
100641
  processTableNode(tableNode, index, parent, node.position);
100664
- return EXIT;
100642
+ return lib_EXIT;
100665
100643
  });
100666
100644
  }
100667
100645
  else if (node.value.startsWith('<table')) {
@@ -101147,13 +101125,13 @@ const visitor = (table, index, parent) => {
101147
101125
  let hasFlowContent = false;
101148
101126
  const tableCellVisitor = (cell) => {
101149
101127
  if (cell.children.length === 0)
101150
- return EXIT;
101128
+ return lib_EXIT;
101151
101129
  const content = cell.children.length === 1 && cell.children[0].type === 'paragraph'
101152
101130
  ? cell.children[0].children[0]
101153
101131
  : cell.children[0];
101154
101132
  // If cell is empty there's nothing to visit
101155
101133
  if (!content)
101156
- return EXIT;
101134
+ return lib_EXIT;
101157
101135
  // @note: Compatibility with RDMD. Ideally, I'd put this in a separate
101158
101136
  // transformer, but then there'd be some duplication.
101159
101137
  lib_visit(cell, 'break', (_, breakIndex, breakParent) => {
@@ -101161,12 +101139,12 @@ const visitor = (table, index, parent) => {
101161
101139
  });
101162
101140
  if (!(lib_phrasing(content) || content.type === 'plain') && content.type !== 'escape') {
101163
101141
  hasFlowContent = true;
101164
- return EXIT;
101142
+ return lib_EXIT;
101165
101143
  }
101166
101144
  lib_visit(cell, isLiteral, (node) => {
101167
101145
  if (node.value.match(/\n/)) {
101168
101146
  hasFlowContent = true;
101169
- return EXIT;
101147
+ return lib_EXIT;
101170
101148
  }
101171
101149
  });
101172
101150
  };
@@ -119381,7 +119359,7 @@ function media(state, node) {
119381
119359
  lib_visit(fragment, function (node) {
119382
119360
  if (node.type === 'link') {
119383
119361
  linkInFallbackContent = true
119384
- return EXIT
119362
+ return lib_EXIT
119385
119363
  }
119386
119364
  })
119387
119365
 
@@ -120905,7 +120883,7 @@ const trimEmphasis = (node, index, parent) => {
120905
120883
  trimmed = true;
120906
120884
  child.value = newValue;
120907
120885
  }
120908
- return EXIT;
120886
+ return lib_EXIT;
120909
120887
  });
120910
120888
  lib_visit(node, 'text', (child) => {
120911
120889
  const newValue = child.value.trimEnd();
@@ -120913,7 +120891,7 @@ const trimEmphasis = (node, index, parent) => {
120913
120891
  trimmed = true;
120914
120892
  child.value = newValue;
120915
120893
  }
120916
- return EXIT;
120894
+ return lib_EXIT;
120917
120895
  }, true);
120918
120896
  if (trimmed) {
120919
120897
  addSpaceBefore(index, parent);
@@ -126500,9 +126478,9 @@ const resolveDeferredAttributeExpressionProps = () => (tree, file) => {
126500
126478
  properties[name] = name === 'style' && style_object_to_css_isPlainObject(result) ? styleObjectToCssText(result) : result;
126501
126479
  }
126502
126480
  catch {
126503
- // Evaluation failed — fall back to the raw expression source so the attribute
126504
- // renders as readable text rather than disappearing.
126505
- properties[name] = source;
126481
+ // Evaluation failed — keep the literal `{...}`, matching how `evaluateExpressions` falls
126482
+ // back in body text. Variable references like `{user.name}` stay resolvable at render time.
126483
+ properties[name] = `{${source}}`;
126506
126484
  }
126507
126485
  });
126508
126486
  delete node.data.deferredExpressions;
@@ -126593,6 +126571,7 @@ const restoreBooleanProperties = () => tree => {
126593
126571
 
126594
126572
 
126595
126573
 
126574
+
126596
126575
  const SELF_CLOSING_JSX_REGEX = /^\s*<[A-Z][^>]*\/>\s*$/;
126597
126576
  const mdxish_tables_to_jsx_alignToStyle = (align) => {
126598
126577
  if (!align || align === 'left')
@@ -126608,6 +126587,38 @@ const mdxish_tables_to_jsx_alignToStyle = (align) => {
126608
126587
  };
126609
126588
  const mdxish_tables_to_jsx_isTableCell = (node) => ['tableHead', 'tableCell'].includes(node.type);
126610
126589
  const mdxish_tables_to_jsx_isLiteral = (node) => 'value' in node;
126590
+ /**
126591
+ * Block-level content that a single-line GFM cell cannot hold. `phrasing()` returns true
126592
+ * for inline types (text, emphasis, strong, link…), which are safe to keep.
126593
+ */
126594
+ const isFlowChild = (child) => {
126595
+ if (child.type === 'paragraph' || child.type === 'plain' || child.type === 'escape')
126596
+ return false;
126597
+ if (child.type === NodeTypes.variable)
126598
+ return false;
126599
+ if (phrasing(child))
126600
+ return false;
126601
+ if (child.type === 'html')
126602
+ return SELF_CLOSING_JSX_REGEX.test(child.value);
126603
+ return true;
126604
+ };
126605
+ /** A newline in a normalized cell (e.g. inside `inlineCode`) has no inline equivalent. */
126606
+ const containsLiteralNewline = (nodes) => nodes.some(node => (mdxish_tables_to_jsx_isLiteral(node) && node.value.includes('\n')) || (hasChildren(node) && containsLiteralNewline(node.children)));
126607
+ /** True when normalized cell content survives a single-line GFM pipe cell without losing structure. */
126608
+ const canCellBeGfm = (children) => {
126609
+ // Multiple paragraphs are distinct blocks; a single-line cell cannot keep them apart.
126610
+ if (children.filter(child => child.type === 'paragraph').length > 1)
126611
+ return false;
126612
+ if (children.some(isFlowChild))
126613
+ return false;
126614
+ return !containsLiteralNewline(children);
126615
+ };
126616
+ /** On the promote path a `break` would serialize as a dangling `\`, so collapse it to a newline. */
126617
+ const flattenBreaksToNewlines = (cell) => {
126618
+ visit(cell, 'break', (_, index, parent) => {
126619
+ parent.children.splice(index, 1, { type: 'text', value: '\n' });
126620
+ });
126621
+ };
126611
126622
  /**
126612
126623
  * Mdxish-specific version of `tablesToJsx`. Differs from the shared MDX version:
126613
126624
  *
@@ -126618,52 +126629,25 @@ const mdxish_tables_to_jsx_isLiteral = (node) => 'value' in node;
126618
126629
  */
126619
126630
  const mdxish_tables_to_jsx_mdxishTablesToJsx = () => tree => {
126620
126631
  visit(tree, (node) => ['table', 'tableau'].includes(node.type), (table, index, parent) => {
126621
- let hasFlowContent = false;
126632
+ const gfmCells = [];
126633
+ let requiresJsxTable = false;
126622
126634
  visit(table, mdxish_tables_to_jsx_isTableCell, (cell) => {
126623
- if (hasFlowContent || cell.children.length === 0)
126624
- return;
126625
- visit(cell, 'break', (_, breakIndex, breakParent) => {
126626
- breakParent.children.splice(breakIndex, 1, { type: 'text', value: '\n' });
126627
- });
126628
- // A cell with more than one paragraph child cannot be serialized as GFM
126629
- // (pipe tables are single-line per cell), so force JSX <Table> output to
126630
- // preserve paragraph separation.
126631
- const paragraphCount = cell.children.filter(child => child.type === 'paragraph').length;
126632
- if (paragraphCount > 1) {
126633
- hasFlowContent = true;
126634
- return;
126635
- }
126636
- // Check if any child is "flow" content (block-level) that requires JSX <Table>
126637
- // serialization instead of GFM. `phrasing()` from mdast-util-phrasing returns
126638
- // true for inline node types (text, emphasis, strong, link, etc.) which are
126639
- // safe to keep in GFM cells.
126640
- const hasFlowChild = cell.children.some(child => {
126641
- if (child.type === 'paragraph' || child.type === 'plain' || child.type === 'escape')
126642
- return false;
126643
- if (child.type === NodeTypes.variable)
126644
- return false;
126645
- if (phrasing(child))
126646
- return false;
126647
- if (child.type === 'html') {
126648
- return SELF_CLOSING_JSX_REGEX.test(child.value);
126649
- }
126650
- return true;
126651
- });
126652
- if (hasFlowChild) {
126653
- hasFlowContent = true;
126654
- }
126655
- if (!hasFlowContent) {
126656
- visit(cell, mdxish_tables_to_jsx_isLiteral, (node) => {
126657
- if (node.value.match(/\n/)) {
126658
- hasFlowContent = true;
126659
- }
126660
- });
126635
+ const normalized = normalizeCellChildrenForGfm(cell);
126636
+ if (!canCellBeGfm(normalized)) {
126637
+ requiresJsxTable = true;
126638
+ return EXIT;
126661
126639
  }
126640
+ gfmCells.push([cell, normalized]);
126641
+ return undefined;
126662
126642
  });
126663
- if (!hasFlowContent) {
126643
+ if (!requiresJsxTable) {
126644
+ gfmCells.forEach(([cell, children]) => {
126645
+ cell.children = children;
126646
+ });
126664
126647
  table.type = 'table';
126665
126648
  return;
126666
126649
  }
126650
+ visit(table, mdxish_tables_to_jsx_isTableCell, flattenBreaksToNewlines);
126667
126651
  const styles = table.align.map(mdxish_tables_to_jsx_alignToStyle);
126668
126652
  const head = {
126669
126653
  attributes: [],
@@ -127313,6 +127297,24 @@ const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }
127313
127297
  };
127314
127298
  /* harmony default export */ const contexts = (Contexts);
127315
127299
 
127300
+ ;// ./utils/user.ts
127301
+ const User = (variables) => {
127302
+ const { user = {}, defaults = [] } = variables || {};
127303
+ return new Proxy(user, {
127304
+ get(target, attribute) {
127305
+ if (typeof attribute === 'symbol') {
127306
+ return '';
127307
+ }
127308
+ if (attribute in target) {
127309
+ return target[attribute];
127310
+ }
127311
+ const def = defaults.find((d) => d.name === attribute);
127312
+ return def ? def.default : attribute.toUpperCase();
127313
+ },
127314
+ });
127315
+ };
127316
+ /* harmony default export */ const user = (User);
127317
+
127316
127318
  ;// ./lib/utils/makeUseMdxComponents.ts
127317
127319
 
127318
127320
 
@@ -127343,6 +127345,35 @@ const makeUseMDXComponents = (more = {}) => {
127343
127345
  };
127344
127346
  /* harmony default export */ const makeUseMdxComponents = (makeUseMDXComponents);
127345
127347
 
127348
+ ;// ./lib/utils/mdxish/mdxish-variables.ts
127349
+
127350
+ // The `$` guard skips template-literal interpolation: `${user.name}` embeds `{user.name}`, and
127351
+ // substituting it would leave a mangled `` `Hi $Name` `` behind. Those belong to an expression,
127352
+ // which either evaluated already or is meant to stay literal.
127353
+ const MDX_VARIABLE_REGEX = new RegExp(`(?<!\\$)${variable_dist.MDX_VARIABLE_REGEXP}`, 'gu');
127354
+ // Bracket notation names the same variable as dot notation, so normalize it before substituting.
127355
+ // Escaped and `$`-prefixed forms are left alone so a reference that stays literal keeps its source.
127356
+ // A closing escape needs no lookahead: requiring a literal `]}` already rules out `]\}`.
127357
+ const BRACKET_NOTATION_REGEX = /(?<![$\\])\{user\[['"](\w+)['"]\]\}/gu;
127358
+ /**
127359
+ * Resolve `{user.*}` in a JSX attribute value against the same `user` binding the rmdx engine gets,
127360
+ * so both engines agree. Body text differs on empty values: `Variable` falls back to the default.
127361
+ *
127362
+ * Legacy `<<...>>` is valid inside a quoted attribute but deliberately left literal — attributes are
127363
+ * an MDX surface, and `{user.*}` is the syntax authors use there.
127364
+ */
127365
+ function resolveAttributeVariables(value, user) {
127366
+ if (!value.includes('{user'))
127367
+ return value;
127368
+ return value
127369
+ .replace(BRACKET_NOTATION_REGEX, '{user.$1}')
127370
+ .replace(MDX_VARIABLE_REGEX, (source, escapePrefix, name, escapeSuffix) => {
127371
+ if (escapePrefix || escapeSuffix)
127372
+ return source;
127373
+ return user[name];
127374
+ });
127375
+ }
127376
+
127346
127377
  ;// ./lib/utils/mdxish/mdxish-render-utils.tsx
127347
127378
 
127348
127379
 
@@ -127351,6 +127382,8 @@ const makeUseMDXComponents = (more = {}) => {
127351
127382
 
127352
127383
 
127353
127384
 
127385
+
127386
+
127354
127387
  /** Flatten CustomComponents into a component map for rehype-react */
127355
127388
  function exportComponentsForRehype(components) {
127356
127389
  const exported = Object.entries(components).reduce((memo, [tag, mod]) => {
@@ -127378,6 +127411,28 @@ function exportComponentsForRehype(components) {
127378
127411
  result.variable = (variable_dist_default());
127379
127412
  return result;
127380
127413
  }
127414
+ /**
127415
+ * Code rides on a `value` prop, and `variablesCodeResolver` owns it at parse time where it
127416
+ * deliberately leaves mermaid alone; resolving it again here would override that.
127417
+ */
127418
+ const CODE_TAG_NAMES = new Set(['code']);
127419
+ /** Raw markup injected with `dangerouslySetInnerHTML` by HTMLBlock and Embed — never interpolate. */
127420
+ const RAW_HTML_PROP_NAMES = new Set(['html']);
127421
+ /**
127422
+ * Resolve `{user.*}` in string-valued props. Body text is handled by the `Variable` component, but
127423
+ * attributes are plain strings, so they are substituted here — at render time, so that a
127424
+ * server-parsed (user-agnostic) tree resolves against the current reader's variables.
127425
+ */
127426
+ function resolveVariablesInProps(props, user, tagName) {
127427
+ const isCodeTag = Boolean(tagName && CODE_TAG_NAMES.has(tagName));
127428
+ const resolvedEntries = Object.entries(props).map(([key, value]) => {
127429
+ const isDocumentContent = RAW_HTML_PROP_NAMES.has(key) || (isCodeTag && key === 'value');
127430
+ if (typeof value !== 'string' || isDocumentContent)
127431
+ return [key, value];
127432
+ return [key, resolveAttributeVariables(value, user)];
127433
+ });
127434
+ return Object.fromEntries(resolvedEntries);
127435
+ }
127381
127436
  /**
127382
127437
  * Custom React.createElement wrapper that recovers real JS prop values for
127383
127438
  * custom components. rehype-react v6 uses hast-to-hyperscript, which stringifies
@@ -127389,7 +127444,7 @@ function exportComponentsForRehype(components) {
127389
127444
  * Only arrays win over `rest`, overwriting other shapes would undo correct
127390
127445
  * React conversions like `style="color:red"` → `{ color: 'red' }`.
127391
127446
  */
127392
- function createElementPreservingHastProps(type, props, ...children) {
127447
+ const makeCreateElementPreservingHastProps = (user) => function createElementPreservingHastProps(type, props, ...children) {
127393
127448
  if (props?.node?.properties) {
127394
127449
  const { node, ...rest } = props;
127395
127450
  const mergedProps = { ...rest };
@@ -127399,15 +127454,16 @@ function createElementPreservingHastProps(type, props, ...children) {
127399
127454
  });
127400
127455
  // Strip undefined so positional args don't shadow node.properties.children
127401
127456
  const definedChildren = children.filter(c => c !== undefined);
127402
- return external_react_default().createElement(type, mergedProps, ...definedChildren);
127457
+ const withVariables = resolveVariablesInProps(mergedProps, user, node.tagName);
127458
+ return external_react_default().createElement(type, withVariables, ...definedChildren);
127403
127459
  }
127404
- return external_react_default().createElement(type, props, ...children);
127405
- }
127460
+ return external_react_default().createElement(type, props && resolveVariablesInProps(props, user), ...children);
127461
+ };
127406
127462
  /** Create a rehype-react processor */
127407
- function createRehypeReactProcessor(components) {
127463
+ function createRehypeReactProcessor(components, variables) {
127408
127464
  // @ts-expect-error - rehype-react types are incompatible with React.Fragment return type
127409
127465
  return lib_unified().use((rehype_react_default()), {
127410
- createElement: createElementPreservingHastProps,
127466
+ createElement: makeCreateElementPreservingHastProps(user(variables)),
127411
127467
  Fragment: (external_react_default()).Fragment,
127412
127468
  components,
127413
127469
  passNode: true,
@@ -127422,7 +127478,7 @@ function createTocComponent(tocHast) {
127422
127478
  components: { p: (external_react_default()).Fragment },
127423
127479
  });
127424
127480
  const tocReactElement = tocProcessor.stringify(tocHast);
127425
- const TocComponent = () => tocReactElement ? (external_react_default().createElement(components_TableOfContents, null, tocReactElement)) : null;
127481
+ const TocComponent = () => tocReactElement ? external_react_default().createElement(components_TableOfContents, null, tocReactElement) : null;
127426
127482
  TocComponent.displayName = 'Toc';
127427
127483
  return TocComponent;
127428
127484
  }
@@ -127471,7 +127527,7 @@ const renderMdxish = (tree, opts = {}) => {
127471
127527
  Object.entries(localScope).forEach(([name, value]) => {
127472
127528
  componentsForRehype[name] = value;
127473
127529
  });
127474
- const processor = createRehypeReactProcessor(componentsForRehype);
127530
+ const processor = createRehypeReactProcessor(componentsForRehype, variables);
127475
127531
  const content = processor.stringify(tree);
127476
127532
  const tocHast = headings.length > 0 ? tocToHast(headings, variables) : null;
127477
127533
  return buildRMDXModule(content, headings, tocHast, { ...contextOpts, variables });
@@ -127527,24 +127583,6 @@ function runSync(code, options) {
127527
127583
  // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js
127528
127584
  var jsx_runtime = __webpack_require__(4848);
127529
127585
  var jsx_runtime_namespaceObject = /*#__PURE__*/__webpack_require__.t(jsx_runtime, 2);
127530
- ;// ./utils/user.ts
127531
- const User = (variables) => {
127532
- const { user = {}, defaults = [] } = variables || {};
127533
- return new Proxy(user, {
127534
- get(target, attribute) {
127535
- if (typeof attribute === 'symbol') {
127536
- return '';
127537
- }
127538
- if (attribute in target) {
127539
- return target[attribute];
127540
- }
127541
- const def = defaults.find((d) => d.name === attribute);
127542
- return def ? def.default : attribute.toUpperCase();
127543
- },
127544
- });
127545
- };
127546
- /* harmony default export */ const user = (User);
127547
-
127548
127586
  ;// ./lib/run.tsx
127549
127587
 
127550
127588