@readme/markdown 7.10.4 → 7.12.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/main.node.js CHANGED
@@ -27700,7 +27700,7 @@ function toResult(value) {
27700
27700
  * @template {Test} Check
27701
27701
  * `unist-util-is`-compatible test.
27702
27702
  */
27703
- function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
27703
+ function lib_visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
27704
27704
  /** @type {boolean | null | undefined} */
27705
27705
  let reverse
27706
27706
  /** @type {Test} */
@@ -27755,7 +27755,7 @@ function formatHeadingAsSetext(node, state) {
27755
27755
 
27756
27756
  // Look for literals with a line break.
27757
27757
  // Note that this also
27758
- visit(node, function (node) {
27758
+ lib_visit(node, function (node) {
27759
27759
  if (
27760
27760
  ('value' in node && /\r?\n|\r/.test(node.value)) ||
27761
27761
  node.type === 'break'
@@ -40591,7 +40591,7 @@ const lib_SKIP = Symbol('skip')
40591
40591
  * @returns {undefined}
40592
40592
  * Nothing.
40593
40593
  */
40594
- function lib_visit(tree, visitor) {
40594
+ function estree_util_visit_lib_visit(tree, visitor) {
40595
40595
  /** @type {Visitor | undefined} */
40596
40596
  let enter
40597
40597
  /** @type {Visitor | undefined} */
@@ -40894,7 +40894,7 @@ function eventsToAcorn(events, options) {
40894
40894
  estree.comments = comments;
40895
40895
 
40896
40896
  // @ts-expect-error: acorn looks enough like estree.
40897
- lib_visit(estree, function (esnode, field, index, parents) {
40897
+ estree_util_visit_lib_visit(estree, function (esnode, field, index, parents) {
40898
40898
  let context = /** @type {AcornNode | Array<AcornNode>} */
40899
40899
  parents[parents.length - 1];
40900
40900
  /** @type {number | string | undefined} */
@@ -49020,7 +49020,7 @@ var NodeTypes;
49020
49020
  const regex = `^(${emoji_regex().source}|⚠)(\\s+|$)`;
49021
49021
  const calloutTransformer = () => {
49022
49022
  return (tree) => {
49023
- visit(tree, 'blockquote', (node) => {
49023
+ lib_visit(tree, 'blockquote', (node) => {
49024
49024
  if (!(node.children[0].type === 'paragraph' && node.children[0].children[0].type === 'text'))
49025
49025
  return;
49026
49026
  const startText = node.children[0].children[0].value;
@@ -49050,13 +49050,13 @@ const calloutTransformer = () => {
49050
49050
 
49051
49051
  const isCode = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'code';
49052
49052
  const codeTabsTransformer = ({ copyButtons } = {}) => (tree) => {
49053
- visit(tree, 'code', (node) => {
49053
+ lib_visit(tree, 'code', (node) => {
49054
49054
  const { lang, meta, value } = node;
49055
49055
  node.data = {
49056
49056
  hProperties: { lang, meta, value, copyButtons },
49057
49057
  };
49058
49058
  });
49059
- visit(tree, 'code', (node, index, parent) => {
49059
+ lib_visit(tree, 'code', (node, index, parent) => {
49060
49060
  if (parent.type === 'code-tabs' || !('children' in parent))
49061
49061
  return;
49062
49062
  const length = parent.children.length;
@@ -49099,7 +49099,7 @@ const codeTabsTransformer = ({ copyButtons } = {}) => (tree) => {
49099
49099
 
49100
49100
  const embedTransformer = () => {
49101
49101
  return (tree) => {
49102
- visit(tree, 'paragraph', (node, i, parent) => {
49102
+ lib_visit(tree, 'paragraph', (node, i, parent) => {
49103
49103
  var _a, _b, _c;
49104
49104
  const [{ url, title, children = [] }] = node.children;
49105
49105
  if (title !== '@embed')
@@ -49126,12 +49126,12 @@ const embedTransformer = () => {
49126
49126
 
49127
49127
  ;// ./lib/mdast.ts
49128
49128
 
49129
- const mdast = (text, opts = {}) => {
49129
+ const mdast_mdast = (text, opts = {}) => {
49130
49130
  const processor = ast_processor(opts);
49131
49131
  const tree = processor.parse(text);
49132
49132
  return processor.runSync(tree);
49133
49133
  };
49134
- /* harmony default export */ const lib_mdast = (mdast);
49134
+ /* harmony default export */ const lib_mdast = (mdast_mdast);
49135
49135
 
49136
49136
  ;// ./processor/utils.ts
49137
49137
 
@@ -49223,11 +49223,20 @@ const utils_getChildren = (jsx) => jsx.children.reduce((memo, child, i) => {
49223
49223
  * TODO: Make this more extensible to all types of nodes. isElement(node, 'type' or ['type1', 'type2']), say
49224
49224
  *
49225
49225
  * @param {Node} node
49226
- * @returns {(node is MdxJsxFlowElement | MdxJsxTextElement)}
49226
+ * @returns {(node is MdxJsxFlowElement | MdxJsxTextElement | MdxjsEsm)}
49227
49227
  */
49228
49228
  const isMDXElement = (node) => {
49229
49229
  return ['mdxJsxFlowElement', 'mdxJsxTextElement'].includes(node.type);
49230
49230
  };
49231
+ /**
49232
+ * Tests if a node is an MDX ESM element (i.e. import or export).
49233
+ *
49234
+ * @param {Node} node
49235
+ * @returns {boolean}
49236
+ */
49237
+ const utils_isMDXEsm = (node) => {
49238
+ return node.type === 'mdxjsEsm';
49239
+ };
49231
49240
  /**
49232
49241
  * Takes an HTML string and formats it for display in the editor. Removes leading/trailing newlines
49233
49242
  * and unindents the HTML.
@@ -49314,7 +49323,7 @@ const toAttributes = (object, keys = []) => {
49314
49323
 
49315
49324
 
49316
49325
  const imageTransformer = () => (tree) => {
49317
- visit(tree, 'paragraph', (node, i, parent) => {
49326
+ lib_visit(tree, 'paragraph', (node, i, parent) => {
49318
49327
  var _a;
49319
49328
  // check if inline
49320
49329
  if (parent.type !== 'root' || ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 || node.children[0].type !== 'image')
@@ -49338,7 +49347,7 @@ const imageTransformer = () => (tree) => {
49338
49347
  parent.children.splice(i, 1, newNode);
49339
49348
  });
49340
49349
  const isImage = (node) => node.name === 'Image';
49341
- visit(tree, isImage, (node) => {
49350
+ lib_visit(tree, isImage, (node) => {
49342
49351
  const attrs = getAttrs(node);
49343
49352
  if (attrs.caption) {
49344
49353
  node.children = lib_mdast(attrs.caption).children;
@@ -66332,6 +66341,31 @@ const gemojiTransformer = () => (tree) => {
66332
66341
  };
66333
66342
  /* harmony default export */ const gemoji_ = (gemojiTransformer);
66334
66343
 
66344
+ ;// ./processor/transform/compatability.ts
66345
+
66346
+
66347
+ const strongTest = (node) => ['emphasis', 'strong'].includes(node.type);
66348
+ const compatibilityTransfomer = () => tree => {
66349
+ const trimEmphasis = (node) => {
66350
+ lib_visit(node, 'text', child => {
66351
+ child.value = child.value.trim();
66352
+ return EXIT;
66353
+ });
66354
+ return node;
66355
+ };
66356
+ lib_visit(tree, strongTest, node => {
66357
+ trimEmphasis(node);
66358
+ return SKIP;
66359
+ });
66360
+ lib_visit(tree, 'image', (node, index, parent) => {
66361
+ if (phrasing(parent) || !parent.children.every(child => child.type === 'image' || !phrasing(child)))
66362
+ return;
66363
+ parent.children.splice(index, 1, { type: 'paragraph', children: [node] });
66364
+ });
66365
+ return tree;
66366
+ };
66367
+ /* harmony default export */ const compatability = (compatibilityTransfomer);
66368
+
66335
66369
  ;// ./processor/transform/div.ts
66336
66370
  var div_rest = (undefined && undefined.__rest) || function (s, e) {
66337
66371
  var t = {};
@@ -66347,7 +66381,7 @@ var div_rest = (undefined && undefined.__rest) || function (s, e) {
66347
66381
 
66348
66382
 
66349
66383
  const divTransformer = () => tree => {
66350
- visit(tree, 'div', (node, index, parent) => {
66384
+ lib_visit(tree, 'div', (node, index, parent) => {
66351
66385
  var _a;
66352
66386
  const type = (_a = node.data) === null || _a === void 0 ? void 0 : _a.hName;
66353
66387
  switch (type) {
@@ -66375,11 +66409,46 @@ const inject = ({ components } = {}) => (node, index, parent) => {
66375
66409
  parent.children.splice(index, children.length, ...children);
66376
66410
  };
66377
66411
  const injectComponents = (opts) => () => tree => {
66378
- visit(tree, isMDXElement, inject(opts));
66412
+ lib_visit(tree, isMDXElement, inject(opts));
66379
66413
  return tree;
66380
66414
  };
66381
66415
  /* harmony default export */ const inject_components = (injectComponents);
66382
66416
 
66417
+ ;// ./processor/transform/mdx-to-hast.ts
66418
+
66419
+
66420
+
66421
+ const setData = (node, index, parent) => {
66422
+ if (!node.name)
66423
+ return;
66424
+ if (!(node.name in components_namespaceObject))
66425
+ return;
66426
+ parent.children[index] = Object.assign(Object.assign({}, node), { data: {
66427
+ hName: node.name,
66428
+ hProperties: getAttrs(node),
66429
+ } });
66430
+ };
66431
+ const mdxToHast = () => tree => {
66432
+ lib_visit(tree, isMDXElement, setData);
66433
+ return tree;
66434
+ };
66435
+ /* harmony default export */ const mdx_to_hast = (mdxToHast);
66436
+
66437
+ ;// ./processor/transform/mermaid.ts
66438
+
66439
+ const mermaidTransformer = () => (tree) => {
66440
+ lib_visit(tree, 'element', (node) => {
66441
+ if (node.tagName !== 'pre' || node.children.length !== 1)
66442
+ return;
66443
+ const [child] = node.children;
66444
+ if (child.type === 'element' && child.tagName === 'code' && child.properties.lang === 'mermaid') {
66445
+ node.properties = Object.assign(Object.assign({}, node.properties), { className: ['mermaid', ...(node.properties.className || [])] });
66446
+ }
66447
+ });
66448
+ return tree;
66449
+ };
66450
+ /* harmony default export */ const transform_mermaid = (mermaidTransformer);
66451
+
66383
66452
  ;// ./processor/transform/readme-components.ts
66384
66453
 
66385
66454
 
@@ -66457,9 +66526,9 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
66457
66526
  const { position } = node;
66458
66527
  const { align = [...new Array(node.children.length)].map(() => null) } = getAttrs(node);
66459
66528
  let children = [];
66460
- visit(node, { name: 'tr' }, row => {
66529
+ lib_visit(node, { name: 'tr' }, row => {
66461
66530
  let rowChildren = [];
66462
- visit(row, isTableCell, ({ name, children, position }) => {
66531
+ lib_visit(row, isTableCell, ({ name, children, position }) => {
66463
66532
  rowChildren.push({
66464
66533
  type: tableTypes[name],
66465
66534
  children,
@@ -66478,7 +66547,7 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
66478
66547
  position,
66479
66548
  children,
66480
66549
  };
66481
- visit(mdNode, isMDXElement, coerceJsxToMd({ components, html }));
66550
+ lib_visit(mdNode, isMDXElement, coerceJsxToMd({ components, html }));
66482
66551
  parent.children[index] = mdNode;
66483
66552
  return SKIP;
66484
66553
  }
@@ -66521,8 +66590,8 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
66521
66590
  }
66522
66591
  };
66523
66592
  const readmeComponents = (opts) => () => tree => {
66524
- visit(tree, isMDXElement, coerceJsxToMd(opts));
66525
- visit(tree, 'paragraph', (node, index, parent) => {
66593
+ lib_visit(tree, isMDXElement, coerceJsxToMd(opts));
66594
+ lib_visit(tree, 'paragraph', (node, index, parent) => {
66526
66595
  // @ts-ignore
66527
66596
  if (parent.type !== 'tableRow')
66528
66597
  return;
@@ -66540,11 +66609,11 @@ const readmeComponents = (opts) => () => tree => {
66540
66609
  const imageAttrs = ['align', 'alt', 'caption', 'border', 'height', 'src', 'title', 'width', 'lazy', 'className'];
66541
66610
  const readmeToMdx = () => tree => {
66542
66611
  // Unwrap pinned nodes, replace rdme-pin with its child node
66543
- visit(tree, 'rdme-pin', (node, i, parent) => {
66612
+ lib_visit(tree, 'rdme-pin', (node, i, parent) => {
66544
66613
  const newNode = node.children[0];
66545
66614
  parent.children.splice(i, 1, newNode);
66546
66615
  });
66547
- visit(tree, NodeTypes.tutorialTile, (tile, index, parent) => {
66616
+ lib_visit(tree, NodeTypes.tutorialTile, (tile, index, parent) => {
66548
66617
  parent.children.splice(index, 1, {
66549
66618
  type: 'mdxJsxFlowElement',
66550
66619
  name: 'TutorialTile',
@@ -66552,7 +66621,7 @@ const readmeToMdx = () => tree => {
66552
66621
  children: [],
66553
66622
  });
66554
66623
  });
66555
- visit(tree, 'figure', (figure, index, parent) => {
66624
+ lib_visit(tree, 'figure', (figure, index, parent) => {
66556
66625
  const [image, caption] = figure.children;
66557
66626
  const { align, width } = image.data.hProperties;
66558
66627
  const border = image.data.hProperties.className === 'border';
@@ -66564,7 +66633,7 @@ const readmeToMdx = () => tree => {
66564
66633
  });
66565
66634
  });
66566
66635
  const hasExtra = (attributes) => !!attributes.find(attr => !['alt', 'src', 'title'].includes(attr.name));
66567
- visit(tree, 'image', (image, index, parent) => {
66636
+ lib_visit(tree, 'image', (image, index, parent) => {
66568
66637
  if (!('data' in image))
66569
66638
  return;
66570
66639
  if ('url' in image)
@@ -66586,7 +66655,7 @@ const readmeToMdx = () => tree => {
66586
66655
  });
66587
66656
  }
66588
66657
  });
66589
- visit(tree, NodeTypes.imageBlock, (image, index, parent) => {
66658
+ lib_visit(tree, NodeTypes.imageBlock, (image, index, parent) => {
66590
66659
  const attributes = toAttributes(image.data.hProperties, imageAttrs);
66591
66660
  if (hasExtra(attributes)) {
66592
66661
  parent.children.splice(index, 1, {
@@ -66600,7 +66669,7 @@ const readmeToMdx = () => tree => {
66600
66669
  parent.children.splice(index, 1, Object.assign(Object.assign(Object.assign({ type: 'image', children: [] }, (image.src && { url: image.src })), (image.title && { title: image.title })), (image.alt && { alt: image.alt })));
66601
66670
  }
66602
66671
  });
66603
- visit(tree, 'html', (node, index, parent) => {
66672
+ lib_visit(tree, 'html', (node, index, parent) => {
66604
66673
  const html = node.value;
66605
66674
  const isScriptOrStyleTag = [!!html.match(/^<(?:style|script)/i), !!html.match(/<\/(?:style|script)>$/i)];
66606
66675
  if (!isScriptOrStyleTag.includes(true))
@@ -66618,58 +66687,6 @@ const readmeToMdx = () => tree => {
66618
66687
  };
66619
66688
  /* harmony default export */ const readme_to_mdx = (readmeToMdx);
66620
66689
 
66621
- ;// ./processor/transform/variables.ts
66622
-
66623
-
66624
- const variables = ({ asMdx } = { asMdx: true }) => tree => {
66625
- visit(tree, (node, index, parent) => {
66626
- var _a, _b;
66627
- if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
66628
- return;
66629
- // @ts-expect-error - estree is not defined on our mdx types?!
66630
- if (node.data.estree.type !== 'Program')
66631
- return;
66632
- // @ts-expect-error - estree is not defined on our mdx types?!
66633
- const [expression] = node.data.estree.body;
66634
- if (!expression ||
66635
- expression.type !== 'ExpressionStatement' ||
66636
- ((_a = expression.expression.object) === null || _a === void 0 ? void 0 : _a.name) !== 'user' ||
66637
- !['Literal', 'Identifier'].includes((_b = expression.expression.property) === null || _b === void 0 ? void 0 : _b.type))
66638
- return;
66639
- const name = expression.expression.property.type === 'Identifier'
66640
- ? expression.expression.property.name
66641
- : expression.expression.property.value;
66642
- let variable = asMdx
66643
- ? {
66644
- type: 'mdxJsxTextElement',
66645
- name: 'Variable',
66646
- attributes: [
66647
- {
66648
- type: 'mdxJsxAttribute',
66649
- name: 'name',
66650
- value: name,
66651
- },
66652
- ],
66653
- children: [],
66654
- position: node.position,
66655
- }
66656
- : {
66657
- type: NodeTypes.variable,
66658
- data: {
66659
- hName: 'Variable',
66660
- hProperties: {
66661
- name,
66662
- },
66663
- },
66664
- value: `{${node.value}}`,
66665
- position: node.position,
66666
- };
66667
- parent.children.splice(index, 1, variable);
66668
- });
66669
- return tree;
66670
- };
66671
- /* harmony default export */ const transform_variables = (variables);
66672
-
66673
66690
  ;// ./processor/transform/tables-to-jsx.ts
66674
66691
 
66675
66692
 
@@ -66695,21 +66712,21 @@ const visitor = (table, index, parent) => {
66695
66712
  : cell.children[0];
66696
66713
  // @note: Compatibility with RDMD. Ideally, I'd put this in a separate
66697
66714
  // transformer, but then there'd be some duplication.
66698
- visit(cell, 'break', (_, index, parent) => {
66715
+ lib_visit(cell, 'break', (_, index, parent) => {
66699
66716
  parent.children.splice(index, 1, { type: 'text', value: '\n' });
66700
66717
  });
66701
- if (!phrasing(content)) {
66718
+ if (!phrasing(content) && content.type !== 'escape') {
66702
66719
  hasFlowContent = true;
66703
66720
  return EXIT;
66704
66721
  }
66705
- visit(cell, isLiteral, (node) => {
66722
+ lib_visit(cell, isLiteral, (node) => {
66706
66723
  if (node.value.match(/\n/)) {
66707
66724
  hasFlowContent = true;
66708
66725
  return EXIT;
66709
66726
  }
66710
66727
  });
66711
66728
  };
66712
- visit(table, tables_to_jsx_isTableCell, tableCellVisitor);
66729
+ lib_visit(table, tables_to_jsx_isTableCell, tableCellVisitor);
66713
66730
  if (!hasFlowContent) {
66714
66731
  table.type = 'table';
66715
66732
  return;
@@ -66757,50 +66774,62 @@ const visitor = (table, index, parent) => {
66757
66774
  };
66758
66775
  const isTable = (node) => ['table', 'tableau'].includes(node.type);
66759
66776
  const tablesToJsx = () => tree => {
66760
- visit(tree, isTable, visitor);
66777
+ lib_visit(tree, isTable, visitor);
66761
66778
  return tree;
66762
66779
  };
66763
66780
  /* harmony default export */ const tables_to_jsx = (tablesToJsx);
66764
66781
 
66765
- ;// ./processor/transform/compatability.ts
66782
+ ;// ./processor/transform/variables.ts
66766
66783
 
66767
66784
 
66768
- const strongTest = (node) => ['emphasis', 'strong'].includes(node.type);
66769
- const compatibilityTransfomer = () => tree => {
66770
- const trimEmphasis = (node) => {
66771
- visit(node, 'text', child => {
66772
- child.value = child.value.trim();
66773
- return EXIT;
66774
- });
66775
- return node;
66776
- };
66777
- visit(tree, strongTest, node => {
66778
- trimEmphasis(node);
66779
- return SKIP;
66780
- });
66781
- visit(tree, 'image', (node, index, parent) => {
66782
- if (phrasing(parent) || !parent.children.every(child => child.type === 'image' || !phrasing(child)))
66785
+ const variables = ({ asMdx } = { asMdx: true }) => tree => {
66786
+ lib_visit(tree, (node, index, parent) => {
66787
+ var _a, _b;
66788
+ if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
66783
66789
  return;
66784
- parent.children.splice(index, 1, { type: 'paragraph', children: [node] });
66785
- });
66786
- return tree;
66787
- };
66788
- /* harmony default export */ const compatability = (compatibilityTransfomer);
66789
-
66790
- ;// ./processor/transform/mermaid.ts
66791
-
66792
- const mermaidTransformer = () => (tree) => {
66793
- visit(tree, 'element', (node) => {
66794
- if (node.tagName !== 'pre' || node.children.length !== 1)
66790
+ // @ts-expect-error - estree is not defined on our mdx types?!
66791
+ if (node.data.estree.type !== 'Program')
66795
66792
  return;
66796
- const [child] = node.children;
66797
- if (child.type === 'element' && child.tagName === 'code' && child.properties.lang === 'mermaid') {
66798
- node.properties = Object.assign(Object.assign({}, node.properties), { className: ['mermaid', ...(node.properties.className || [])] });
66799
- }
66793
+ // @ts-expect-error - estree is not defined on our mdx types?!
66794
+ const [expression] = node.data.estree.body;
66795
+ if (!expression ||
66796
+ expression.type !== 'ExpressionStatement' ||
66797
+ ((_a = expression.expression.object) === null || _a === void 0 ? void 0 : _a.name) !== 'user' ||
66798
+ !['Literal', 'Identifier'].includes((_b = expression.expression.property) === null || _b === void 0 ? void 0 : _b.type))
66799
+ return;
66800
+ const name = expression.expression.property.type === 'Identifier'
66801
+ ? expression.expression.property.name
66802
+ : expression.expression.property.value;
66803
+ let variable = asMdx
66804
+ ? {
66805
+ type: 'mdxJsxTextElement',
66806
+ name: 'Variable',
66807
+ attributes: [
66808
+ {
66809
+ type: 'mdxJsxAttribute',
66810
+ name: 'name',
66811
+ value: name,
66812
+ },
66813
+ ],
66814
+ children: [],
66815
+ position: node.position,
66816
+ }
66817
+ : {
66818
+ type: NodeTypes.variable,
66819
+ data: {
66820
+ hName: 'Variable',
66821
+ hProperties: {
66822
+ name,
66823
+ },
66824
+ },
66825
+ value: `{${node.value}}`,
66826
+ position: node.position,
66827
+ };
66828
+ parent.children.splice(index, 1, variable);
66800
66829
  });
66801
66830
  return tree;
66802
66831
  };
66803
- /* harmony default export */ const transform_mermaid = (mermaidTransformer);
66832
+ /* harmony default export */ const transform_variables = (variables);
66804
66833
 
66805
66834
  ;// ./processor/transform/index.ts
66806
66835
 
@@ -66817,6 +66846,7 @@ const mermaidTransformer = () => (tree) => {
66817
66846
 
66818
66847
 
66819
66848
 
66849
+
66820
66850
  const defaultTransforms = {
66821
66851
  calloutTransformer: callouts,
66822
66852
  codeTabsTransformer: code_tabs,
@@ -67033,7 +67063,7 @@ function rehypeSlug(options) {
67033
67063
  return function (tree) {
67034
67064
  slugs.reset()
67035
67065
 
67036
- visit(tree, 'element', function (node) {
67066
+ lib_visit(tree, 'element', function (node) {
67037
67067
  if (headingRank(node) && !node.properties.id) {
67038
67068
  node.properties.id = prefix + slugs.slug(hast_util_to_string_lib_toString(node))
67039
67069
  }
@@ -75156,7 +75186,7 @@ function state_createState(tree, options) {
75156
75186
  wrap: state_wrap
75157
75187
  }
75158
75188
 
75159
- visit(tree, function (node) {
75189
+ lib_visit(tree, function (node) {
75160
75190
  if (node.type === 'definition' || node.type === 'footnoteDefinition') {
75161
75191
  const map = node.type === 'definition' ? definitionById : footnoteById
75162
75192
  const id = String(node.identifier).toUpperCase()
@@ -77817,7 +77847,7 @@ function rehypeRemoveRaw() {
77817
77847
  * Nothing.
77818
77848
  */
77819
77849
  return function (tree) {
77820
- visit(tree, 'raw', function (_, index, parent) {
77850
+ lib_visit(tree, 'raw', function (_, index, parent) {
77821
77851
  if (parent && typeof index === 'number') {
77822
77852
  parent.children.splice(index, 1)
77823
77853
  return index
@@ -77941,7 +77971,7 @@ function remarkMarkAndUnravel() {
77941
77971
  * Nothing.
77942
77972
  */
77943
77973
  return function (tree) {
77944
- visit(tree, function (node, index, parent) {
77974
+ lib_visit(tree, function (node, index, parent) {
77945
77975
  let offset = -1
77946
77976
  let all = true
77947
77977
  let oneOrMore = false
@@ -79560,7 +79590,7 @@ const tocToHast = (headings = []) => {
79560
79590
  };
79561
79591
  const tocToMdx = (toc, components) => {
79562
79592
  const tree = { type: 'root', children: toc };
79563
- visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
79593
+ lib_visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
79564
79594
  const toc = components[node.name].toc || [];
79565
79595
  parent.children.splice(index, 1, ...toc);
79566
79596
  });
@@ -79616,9 +79646,10 @@ const compile_compile = (text, _a = {}) => {
79616
79646
  remarkGfm,
79617
79647
  ...Object.values(transforms),
79618
79648
  [compile_codeTabsTransformer, { copyButtons }],
79619
- transform_variables,
79620
79649
  ], rehypePlugins: [...rehypePlugins, [rehypeToc, { components }]] }, opts));
79621
- return String(vfile).replace(/await import\(_resolveDynamicMdxSpecifier\(('react'|"react")\)\)/, 'arguments[0].imports.React');
79650
+ return String(vfile)
79651
+ .replace(/await import\(_resolveDynamicMdxSpecifier\(('react'|"react")\)\)/, 'arguments[0].imports.React')
79652
+ .replace('"use strict";', '"use strict";\nconst { user } = arguments[0].imports;');
79622
79653
  }
79623
79654
  catch (error) {
79624
79655
  throw error.line ? new MdxSyntaxError(error, text) : error;
@@ -79626,6 +79657,24 @@ const compile_compile = (text, _a = {}) => {
79626
79657
  };
79627
79658
  /* harmony default export */ const lib_compile = (compile_compile);
79628
79659
 
79660
+ ;// ./lib/exports.ts
79661
+
79662
+
79663
+
79664
+ const EXPORT_NAME_REGEX = /export\s+(?:const|let|var|function)\s+(\w+)/;
79665
+ const exports_exports = (doc) => {
79666
+ const set = new Set();
79667
+ visit(mdast(doc), isMDXEsm, (node) => {
79668
+ var _a;
79669
+ if ((_a = node.value) === null || _a === void 0 ? void 0 : _a.match(EXPORT_NAME_REGEX)) {
79670
+ const [, name] = node.value.match(EXPORT_NAME_REGEX);
79671
+ set.add(name);
79672
+ }
79673
+ });
79674
+ return Array.from(set);
79675
+ };
79676
+ /* harmony default export */ const lib_exports = ((/* unused pure expression or super */ null && (exports_exports)));
79677
+
79629
79678
  ;// ./lib/hast.ts
79630
79679
 
79631
79680
 
@@ -79636,7 +79685,11 @@ const hast = (text, opts = {}) => {
79636
79685
  memo[name] = lib_mdast(doc);
79637
79686
  return memo;
79638
79687
  }, {});
79639
- const processor = ast_processor(opts).use(inject_components({ components })).use(remarkRehype).use(rehypePlugins);
79688
+ const processor = ast_processor(opts)
79689
+ .use(inject_components({ components }))
79690
+ .use(mdx_to_hast)
79691
+ .use(remarkRehype)
79692
+ .use(rehypePlugins);
79640
79693
  return processor.runSync(processor.parse(text));
79641
79694
  };
79642
79695
  /* harmony default export */ const lib_hast = (hast);
@@ -79663,7 +79716,7 @@ const addSpaceAfter = (index, parent) => {
79663
79716
  };
79664
79717
  const trimEmphasis = (node, index, parent) => {
79665
79718
  let trimmed = false;
79666
- visit(node, 'text', (child) => {
79719
+ lib_visit(node, 'text', (child) => {
79667
79720
  const newValue = child.value.trimStart();
79668
79721
  if (newValue !== child.value) {
79669
79722
  trimmed = true;
@@ -79671,7 +79724,7 @@ const trimEmphasis = (node, index, parent) => {
79671
79724
  }
79672
79725
  return EXIT;
79673
79726
  });
79674
- visit(node, 'text', (child) => {
79727
+ lib_visit(node, 'text', (child) => {
79675
79728
  const newValue = child.value.trimEnd();
79676
79729
  if (newValue !== child.value) {
79677
79730
  trimmed = true;
@@ -79685,7 +79738,7 @@ const trimEmphasis = (node, index, parent) => {
79685
79738
  }
79686
79739
  };
79687
79740
  const emphasisTransfomer = () => (tree) => {
79688
- visit(tree, emphasis_strongTest, trimEmphasis);
79741
+ lib_visit(tree, emphasis_strongTest, trimEmphasis);
79689
79742
  return tree;
79690
79743
  };
79691
79744
  /* harmony default export */ const migration_emphasis = (emphasisTransfomer);
@@ -79693,7 +79746,7 @@ const emphasisTransfomer = () => (tree) => {
79693
79746
  ;// ./processor/migration/images.ts
79694
79747
 
79695
79748
  const images_imageTransformer = () => tree => {
79696
- visit(tree, 'image', (image) => {
79749
+ lib_visit(tree, 'image', (image) => {
79697
79750
  var _a, _b;
79698
79751
  if (((_b = (_a = image.data) === null || _a === void 0 ? void 0 : _a.hProperties) === null || _b === void 0 ? void 0 : _b.className) === 'border') {
79699
79752
  image.data.hProperties.border = true;
@@ -79705,9 +79758,9 @@ const images_imageTransformer = () => tree => {
79705
79758
  ;// ./processor/migration/linkReference.ts
79706
79759
 
79707
79760
  const linkReferenceTransformer = () => (tree) => {
79708
- visit(tree, 'linkReference', (node, index, parent) => {
79761
+ lib_visit(tree, 'linkReference', (node, index, parent) => {
79709
79762
  const definitions = {};
79710
- visit(tree, 'definition', (def) => {
79763
+ lib_visit(tree, 'definition', (def) => {
79711
79764
  definitions[def.identifier] = def;
79712
79765
  });
79713
79766
  if (node.label === node.identifier && parent) {
@@ -79770,8 +79823,8 @@ const migrateTableCells = (vfile, rdmd) => (table) => {
79770
79823
  */
79771
79824
  // console.error(err);
79772
79825
  }
79773
- visit(table, 'tableRow', (row, i) => {
79774
- visit(row, 'tableCell', (cell, j) => {
79826
+ lib_visit(table, 'tableRow', (row, i) => {
79827
+ lib_visit(row, 'tableCell', (cell, j) => {
79775
79828
  let children = cell.children;
79776
79829
  if (json && json.data[magicIndex(i, j)]) {
79777
79830
  const string = json.data[magicIndex(i, j)].replace(psuedoListRegex, '$<ws>- $<item>');
@@ -79785,7 +79838,7 @@ const migrateTableCells = (vfile, rdmd) => (table) => {
79785
79838
  });
79786
79839
  return SKIP;
79787
79840
  });
79788
- visit(table, 'inlineCode', (code) => {
79841
+ lib_visit(table, 'inlineCode', (code) => {
79789
79842
  if (code.value.includes('\n')) {
79790
79843
  // eslint-disable-next-line no-param-reassign
79791
79844
  code.type = 'code';
@@ -79795,7 +79848,7 @@ const migrateTableCells = (vfile, rdmd) => (table) => {
79795
79848
  function tableCellTransformer() {
79796
79849
  const rdmd = this.data('rdmd');
79797
79850
  return (tree, vfile) => {
79798
- visit(tree, 'table', migrateTableCells(vfile, rdmd));
79851
+ lib_visit(tree, 'table', migrateTableCells(vfile, rdmd));
79799
79852
  return tree;
79800
79853
  };
79801
79854
  }
@@ -79806,12 +79859,7 @@ function tableCellTransformer() {
79806
79859
 
79807
79860
 
79808
79861
 
79809
- const transformers = [
79810
- migration_emphasis,
79811
- migration_images,
79812
- migration_linkReference,
79813
- table_cell,
79814
- ];
79862
+ const transformers = [migration_emphasis, migration_images, migration_linkReference, table_cell];
79815
79863
  /* harmony default export */ const migration = (transformers);
79816
79864
 
79817
79865
  ;// ./lib/mdastV6.ts
@@ -82895,7 +82943,7 @@ function media(state, node) {
82895
82943
  /** @type {Root} */
82896
82944
  const fragment = {type: 'root', children: nodes}
82897
82945
 
82898
- visit(fragment, function (node) {
82946
+ lib_visit(fragment, function (node) {
82899
82947
  if (node.type === 'link') {
82900
82948
  linkInFallbackContent = true
82901
82949
  return EXIT
@@ -83366,7 +83414,7 @@ function inspect(node) {
83366
83414
  let rowIndex = 0
83367
83415
  let cellIndex = 0
83368
83416
 
83369
- visit(node, function (child) {
83417
+ lib_visit(node, function (child) {
83370
83418
  if (child.type === 'element') {
83371
83419
  // Don’t enter nested tables.
83372
83420
  if (child.tagName === 'table' && node !== child) {
@@ -84188,7 +84236,7 @@ function toMdast(tree, options) {
84188
84236
  // @ts-expect-error: fine to pass an arbitrary node.
84189
84237
  transformWhitespace(cleanTree)
84190
84238
 
84191
- visit(cleanTree, function (node) {
84239
+ lib_visit(cleanTree, function (node) {
84192
84240
  if (node && node.type === 'element' && node.properties) {
84193
84241
  const id = String(node.properties.id || '') || undefined
84194
84242
 
@@ -84216,7 +84264,7 @@ function toMdast(tree, options) {
84216
84264
  // we’re generating some whitespace too, and some nodes are in the end
84217
84265
  // ignored.
84218
84266
  // So clean up.
84219
- visit(mdast, function (node, index, parent) {
84267
+ lib_visit(mdast, function (node, index, parent) {
84220
84268
  if (node.type === 'text' && index !== undefined && parent) {
84221
84269
  const previous = parent.children[index - 1]
84222
84270
 
@@ -84556,11 +84604,19 @@ const mdx_mdx = (tree, _a = {}) => {
84556
84604
  };
84557
84605
  /* harmony default export */ const lib_mdx = (mdx_mdx);
84558
84606
 
84607
+ ;// ./lib/migrate.ts
84608
+
84609
+
84610
+ const migrate = (doc, { rdmd }) => {
84611
+ return lib_mdx(lib_mdastV6(doc, { rdmd })).replaceAll(/&#x20;/g, ' ');
84612
+ };
84613
+ /* harmony default export */ const lib_migrate = (migrate);
84614
+
84559
84615
  ;// ./lib/plain.ts
84560
84616
 
84561
84617
  const STRIP_TAGS = ['script', 'style'];
84562
84618
  function plain_one(node, opts) {
84563
- var _a, _b;
84619
+ var _a, _b, _c;
84564
84620
  if (node.type === 'comment')
84565
84621
  return '';
84566
84622
  if ('type' in node && node.type === 'text') {
@@ -84569,27 +84625,37 @@ function plain_one(node, opts) {
84569
84625
  if ('tagName' in node) {
84570
84626
  if (STRIP_TAGS.includes(node.tagName))
84571
84627
  return '';
84572
- if (node.tagName === 'html-block') {
84573
- if (!node.properties.html)
84574
- return '';
84575
- return plain_all(lib_hast(node.properties.html.toString()), opts);
84576
- }
84577
- if (node.tagName === 'rdme-callout') {
84578
- const { icon, title } = node.properties;
84579
- const children = (_a = node === null || node === void 0 ? void 0 : node.children) === null || _a === void 0 ? void 0 : _a.slice(title ? 1 : 0);
84580
- const body = children ? plain_all({ type: 'root', children }, opts) : '';
84581
- return [icon, ' ', title, title && body && ': ', body].filter(Boolean).join('');
84582
- }
84583
- if (node.tagName === 'readme-glossary-item') {
84584
- return node.properties.term;
84585
- }
84586
- if (node.tagName === 'readme-variable') {
84587
- const key = node.properties.variable.toString();
84588
- const val = opts.variables[key];
84589
- return val || `<<${key}>>`;
84590
- }
84591
- if (node.tagName === 'img') {
84592
- return ((_b = node.properties) === null || _b === void 0 ? void 0 : _b.title) || '';
84628
+ switch (node.tagName) {
84629
+ case 'html-block': {
84630
+ if (!node.properties.html)
84631
+ return '';
84632
+ return plain_all(lib_hast(node.properties.html.toString()), opts);
84633
+ }
84634
+ case 'rdme-callout': {
84635
+ const { icon, title } = node.properties;
84636
+ const children = (_a = node === null || node === void 0 ? void 0 : node.children) === null || _a === void 0 ? void 0 : _a.slice(title ? 1 : 0);
84637
+ const body = children ? plain_all({ type: 'root', children }, opts) : '';
84638
+ return [icon, ' ', title, title && body && ': ', body].filter(Boolean).join('');
84639
+ }
84640
+ case 'readme-glossary-item': {
84641
+ return node.properties.term;
84642
+ }
84643
+ case 'readme-variable': {
84644
+ const key = node.properties.variable.toString();
84645
+ const val = opts.variables[key];
84646
+ return val || `<<${key}>>`;
84647
+ }
84648
+ case 'img': {
84649
+ return ((_b = node.properties) === null || _b === void 0 ? void 0 : _b.title) || '';
84650
+ }
84651
+ case 'Accordion':
84652
+ case 'Card':
84653
+ case 'Tab': {
84654
+ const title = ((_c = node.properties) === null || _c === void 0 ? void 0 : _c.title) || '';
84655
+ const children = node === null || node === void 0 ? void 0 : node.children;
84656
+ const body = children ? plain_all({ type: 'root', children }, opts) : '';
84657
+ return [title, body].filter(Boolean).join(' ');
84658
+ }
84593
84659
  }
84594
84660
  }
84595
84661
  if ('value' in node) {
@@ -84678,6 +84744,24 @@ const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }
84678
84744
  };
84679
84745
  /* harmony default export */ const contexts = (Contexts);
84680
84746
 
84747
+ ;// ./utils/user.ts
84748
+ const User = (variables) => {
84749
+ const { user = {}, defaults = [] } = variables || {};
84750
+ return new Proxy(user, {
84751
+ get(target, attribute) {
84752
+ if (typeof attribute === 'symbol') {
84753
+ return '';
84754
+ }
84755
+ if (attribute in target) {
84756
+ return target[attribute];
84757
+ }
84758
+ const def = defaults.find((d) => d.name === attribute);
84759
+ return def ? def.default : attribute.toUpperCase();
84760
+ },
84761
+ });
84762
+ };
84763
+ /* harmony default export */ const user = (User);
84764
+
84681
84765
  ;// ./lib/run.tsx
84682
84766
  var run_rest = (undefined && undefined.__rest) || function (s, e) {
84683
84767
  var t = {};
@@ -84698,6 +84782,7 @@ var run_rest = (undefined && undefined.__rest) || function (s, e) {
84698
84782
 
84699
84783
 
84700
84784
 
84785
+
84701
84786
  const makeUseMDXComponents = (more = {}) => {
84702
84787
  const headings = Array.from({ length: 6 }).reduce((map, _, index) => {
84703
84788
  map[`h${index + 1}`] = components_Heading((index + 1));
@@ -84709,21 +84794,26 @@ const makeUseMDXComponents = (more = {}) => {
84709
84794
  const run_run = async (string, _opts = {}) => {
84710
84795
  const { Fragment } = jsx_runtime_namespaceObject;
84711
84796
  const { components = {}, terms, variables, baseUrl } = _opts, opts = run_rest(_opts, ["components", "terms", "variables", "baseUrl"]);
84712
- const defaults = Object.fromEntries(Object.entries(components).map(([tag, module]) => [tag, 'default' in module ? module.default : module]));
84713
- const exec = (text, { useMDXComponents = makeUseMDXComponents(defaults) } = {}) => {
84714
- return run(text, Object.assign(Object.assign(Object.assign({}, jsx_runtime_namespaceObject), { Fragment, baseUrl: "file:///home/runner/work/markdown/markdown/lib/run.tsx", imports: { React: (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default()) }, useMDXComponents }), opts));
84797
+ const executedComponents = Object.entries(components).reduce((memo, [tag, mod]) => {
84798
+ const { default: Content, toc, Toc } = mod, rest = run_rest(mod, ["default", "toc", "Toc"]);
84799
+ memo[tag] = Content;
84800
+ if (rest) {
84801
+ Object.entries(rest).forEach(([subTag, component]) => {
84802
+ memo[subTag] = component;
84803
+ });
84804
+ }
84805
+ return memo;
84806
+ }, {});
84807
+ const exec = (text, { useMDXComponents = makeUseMDXComponents(executedComponents) } = {}) => {
84808
+ return run(text, Object.assign(Object.assign(Object.assign({}, jsx_runtime_namespaceObject), { Fragment, baseUrl: "file:///home/runner/work/markdown/markdown/lib/run.tsx", imports: { React: (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default()), user: user(variables) }, useMDXComponents }), opts));
84715
84809
  };
84716
- const { toc, default: Content } = await exec(string);
84810
+ const _a = await exec(string), { Toc: _Toc, toc, default: Content } = _a, exports = run_rest(_a, ["Toc", "toc", "default"]);
84717
84811
  const tocMdx = tocToMdx(toc, components);
84718
84812
  const { default: Toc } = await exec(lib_compile(tocMdx), { useMDXComponents: () => ({ p: Fragment }) });
84719
- return {
84720
- default: () => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(contexts, { terms: terms, variables: variables, baseUrl: baseUrl },
84721
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Content, null))),
84722
- toc,
84723
- Toc: () => tocMdx &&
84813
+ return Object.assign({ default: () => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(contexts, { terms: terms, baseUrl: baseUrl, variables: variables },
84814
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Content, null))), toc, Toc: () => tocMdx &&
84724
84815
  Toc && (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(components_TableOfContents, null,
84725
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Toc, null))),
84726
- };
84816
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Toc, null))) }, exports);
84727
84817
  };
84728
84818
  /* harmony default export */ const lib_run = (run_run);
84729
84819
 
@@ -84733,8 +84823,9 @@ const run_run = async (string, _opts = {}) => {
84733
84823
 
84734
84824
  const tags = (doc) => {
84735
84825
  const set = new Set();
84736
- visit(lib_mdast(doc), isMDXElement, (node) => {
84737
- if (node.name.match(/^[A-Z]/)) {
84826
+ lib_visit(lib_mdast(doc), isMDXElement, (node) => {
84827
+ var _a;
84828
+ if ((_a = node.name) === null || _a === void 0 ? void 0 : _a.match(/^[A-Z]/)) {
84738
84829
  set.add(node.name);
84739
84830
  }
84740
84831
  });
@@ -84742,14 +84833,6 @@ const tags = (doc) => {
84742
84833
  };
84743
84834
  /* harmony default export */ const lib_tags = (tags);
84744
84835
 
84745
- ;// ./lib/migrate.ts
84746
-
84747
-
84748
- const migrate = (doc, { rdmd }) => {
84749
- return lib_mdx(lib_mdastV6(doc, { rdmd })).replaceAll(/&#x20;/g, ' ');
84750
- };
84751
- /* harmony default export */ const lib_migrate = (migrate);
84752
-
84753
84836
  ;// ./lib/index.ts
84754
84837
 
84755
84838
 
@@ -84762,6 +84845,7 @@ const migrate = (doc, { rdmd }) => {
84762
84845
 
84763
84846
 
84764
84847
 
84848
+
84765
84849
  ;// ./index.tsx
84766
84850
 
84767
84851