@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.js CHANGED
@@ -26117,7 +26117,7 @@ function toResult(value) {
26117
26117
  * @template {Test} Check
26118
26118
  * `unist-util-is`-compatible test.
26119
26119
  */
26120
- function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
26120
+ function lib_visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
26121
26121
  /** @type {boolean | null | undefined} */
26122
26122
  let reverse
26123
26123
  /** @type {Test} */
@@ -26172,7 +26172,7 @@ function formatHeadingAsSetext(node, state) {
26172
26172
 
26173
26173
  // Look for literals with a line break.
26174
26174
  // Note that this also
26175
- visit(node, function (node) {
26175
+ lib_visit(node, function (node) {
26176
26176
  if (
26177
26177
  ('value' in node && /\r?\n|\r/.test(node.value)) ||
26178
26178
  node.type === 'break'
@@ -39512,7 +39512,7 @@ const lib_SKIP = Symbol('skip')
39512
39512
  * @returns {undefined}
39513
39513
  * Nothing.
39514
39514
  */
39515
- function lib_visit(tree, visitor) {
39515
+ function estree_util_visit_lib_visit(tree, visitor) {
39516
39516
  /** @type {Visitor | undefined} */
39517
39517
  let enter
39518
39518
  /** @type {Visitor | undefined} */
@@ -39815,7 +39815,7 @@ function eventsToAcorn(events, options) {
39815
39815
  estree.comments = comments;
39816
39816
 
39817
39817
  // @ts-expect-error: acorn looks enough like estree.
39818
- lib_visit(estree, function (esnode, field, index, parents) {
39818
+ estree_util_visit_lib_visit(estree, function (esnode, field, index, parents) {
39819
39819
  let context = /** @type {AcornNode | Array<AcornNode>} */
39820
39820
  parents[parents.length - 1];
39821
39821
  /** @type {number | string | undefined} */
@@ -47941,7 +47941,7 @@ var NodeTypes;
47941
47941
  const regex = `^(${emoji_regex().source}|⚠)(\\s+|$)`;
47942
47942
  const calloutTransformer = () => {
47943
47943
  return (tree) => {
47944
- visit(tree, 'blockquote', (node) => {
47944
+ lib_visit(tree, 'blockquote', (node) => {
47945
47945
  if (!(node.children[0].type === 'paragraph' && node.children[0].children[0].type === 'text'))
47946
47946
  return;
47947
47947
  const startText = node.children[0].children[0].value;
@@ -47971,13 +47971,13 @@ const calloutTransformer = () => {
47971
47971
 
47972
47972
  const isCode = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'code';
47973
47973
  const codeTabsTransformer = ({ copyButtons } = {}) => (tree) => {
47974
- visit(tree, 'code', (node) => {
47974
+ lib_visit(tree, 'code', (node) => {
47975
47975
  const { lang, meta, value } = node;
47976
47976
  node.data = {
47977
47977
  hProperties: { lang, meta, value, copyButtons },
47978
47978
  };
47979
47979
  });
47980
- visit(tree, 'code', (node, index, parent) => {
47980
+ lib_visit(tree, 'code', (node, index, parent) => {
47981
47981
  if (parent.type === 'code-tabs' || !('children' in parent))
47982
47982
  return;
47983
47983
  const length = parent.children.length;
@@ -48020,7 +48020,7 @@ const codeTabsTransformer = ({ copyButtons } = {}) => (tree) => {
48020
48020
 
48021
48021
  const embedTransformer = () => {
48022
48022
  return (tree) => {
48023
- visit(tree, 'paragraph', (node, i, parent) => {
48023
+ lib_visit(tree, 'paragraph', (node, i, parent) => {
48024
48024
  var _a, _b, _c;
48025
48025
  const [{ url, title, children = [] }] = node.children;
48026
48026
  if (title !== '@embed')
@@ -48047,12 +48047,12 @@ const embedTransformer = () => {
48047
48047
 
48048
48048
  ;// ./lib/mdast.ts
48049
48049
 
48050
- const mdast = (text, opts = {}) => {
48050
+ const mdast_mdast = (text, opts = {}) => {
48051
48051
  const processor = ast_processor(opts);
48052
48052
  const tree = processor.parse(text);
48053
48053
  return processor.runSync(tree);
48054
48054
  };
48055
- /* harmony default export */ const lib_mdast = (mdast);
48055
+ /* harmony default export */ const lib_mdast = (mdast_mdast);
48056
48056
 
48057
48057
  ;// ./processor/utils.ts
48058
48058
 
@@ -48144,11 +48144,20 @@ const getChildren = (jsx) => jsx.children.reduce((memo, child, i) => {
48144
48144
  * TODO: Make this more extensible to all types of nodes. isElement(node, 'type' or ['type1', 'type2']), say
48145
48145
  *
48146
48146
  * @param {Node} node
48147
- * @returns {(node is MdxJsxFlowElement | MdxJsxTextElement)}
48147
+ * @returns {(node is MdxJsxFlowElement | MdxJsxTextElement | MdxjsEsm)}
48148
48148
  */
48149
48149
  const isMDXElement = (node) => {
48150
48150
  return ['mdxJsxFlowElement', 'mdxJsxTextElement'].includes(node.type);
48151
48151
  };
48152
+ /**
48153
+ * Tests if a node is an MDX ESM element (i.e. import or export).
48154
+ *
48155
+ * @param {Node} node
48156
+ * @returns {boolean}
48157
+ */
48158
+ const utils_isMDXEsm = (node) => {
48159
+ return node.type === 'mdxjsEsm';
48160
+ };
48152
48161
  /**
48153
48162
  * Takes an HTML string and formats it for display in the editor. Removes leading/trailing newlines
48154
48163
  * and unindents the HTML.
@@ -48235,7 +48244,7 @@ const toAttributes = (object, keys = []) => {
48235
48244
 
48236
48245
 
48237
48246
  const imageTransformer = () => (tree) => {
48238
- visit(tree, 'paragraph', (node, i, parent) => {
48247
+ lib_visit(tree, 'paragraph', (node, i, parent) => {
48239
48248
  var _a;
48240
48249
  // check if inline
48241
48250
  if (parent.type !== 'root' || ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 || node.children[0].type !== 'image')
@@ -48259,7 +48268,7 @@ const imageTransformer = () => (tree) => {
48259
48268
  parent.children.splice(i, 1, newNode);
48260
48269
  });
48261
48270
  const isImage = (node) => node.name === 'Image';
48262
- visit(tree, isImage, (node) => {
48271
+ lib_visit(tree, isImage, (node) => {
48263
48272
  const attrs = getAttrs(node);
48264
48273
  if (attrs.caption) {
48265
48274
  node.children = lib_mdast(attrs.caption).children;
@@ -65253,6 +65262,31 @@ const gemojiTransformer = () => (tree) => {
65253
65262
  };
65254
65263
  /* harmony default export */ const gemoji_ = (gemojiTransformer);
65255
65264
 
65265
+ ;// ./processor/transform/compatability.ts
65266
+
65267
+
65268
+ const strongTest = (node) => ['emphasis', 'strong'].includes(node.type);
65269
+ const compatibilityTransfomer = () => tree => {
65270
+ const trimEmphasis = (node) => {
65271
+ lib_visit(node, 'text', child => {
65272
+ child.value = child.value.trim();
65273
+ return EXIT;
65274
+ });
65275
+ return node;
65276
+ };
65277
+ lib_visit(tree, strongTest, node => {
65278
+ trimEmphasis(node);
65279
+ return SKIP;
65280
+ });
65281
+ lib_visit(tree, 'image', (node, index, parent) => {
65282
+ if (phrasing(parent) || !parent.children.every(child => child.type === 'image' || !phrasing(child)))
65283
+ return;
65284
+ parent.children.splice(index, 1, { type: 'paragraph', children: [node] });
65285
+ });
65286
+ return tree;
65287
+ };
65288
+ /* harmony default export */ const compatability = (compatibilityTransfomer);
65289
+
65256
65290
  ;// ./processor/transform/div.ts
65257
65291
  var div_rest = (undefined && undefined.__rest) || function (s, e) {
65258
65292
  var t = {};
@@ -65268,7 +65302,7 @@ var div_rest = (undefined && undefined.__rest) || function (s, e) {
65268
65302
 
65269
65303
 
65270
65304
  const divTransformer = () => tree => {
65271
- visit(tree, 'div', (node, index, parent) => {
65305
+ lib_visit(tree, 'div', (node, index, parent) => {
65272
65306
  var _a;
65273
65307
  const type = (_a = node.data) === null || _a === void 0 ? void 0 : _a.hName;
65274
65308
  switch (type) {
@@ -65296,11 +65330,46 @@ const inject = ({ components } = {}) => (node, index, parent) => {
65296
65330
  parent.children.splice(index, children.length, ...children);
65297
65331
  };
65298
65332
  const injectComponents = (opts) => () => tree => {
65299
- visit(tree, isMDXElement, inject(opts));
65333
+ lib_visit(tree, isMDXElement, inject(opts));
65300
65334
  return tree;
65301
65335
  };
65302
65336
  /* harmony default export */ const inject_components = (injectComponents);
65303
65337
 
65338
+ ;// ./processor/transform/mdx-to-hast.ts
65339
+
65340
+
65341
+
65342
+ const setData = (node, index, parent) => {
65343
+ if (!node.name)
65344
+ return;
65345
+ if (!(node.name in components_namespaceObject))
65346
+ return;
65347
+ parent.children[index] = Object.assign(Object.assign({}, node), { data: {
65348
+ hName: node.name,
65349
+ hProperties: getAttrs(node),
65350
+ } });
65351
+ };
65352
+ const mdxToHast = () => tree => {
65353
+ lib_visit(tree, isMDXElement, setData);
65354
+ return tree;
65355
+ };
65356
+ /* harmony default export */ const mdx_to_hast = (mdxToHast);
65357
+
65358
+ ;// ./processor/transform/mermaid.ts
65359
+
65360
+ const mermaidTransformer = () => (tree) => {
65361
+ lib_visit(tree, 'element', (node) => {
65362
+ if (node.tagName !== 'pre' || node.children.length !== 1)
65363
+ return;
65364
+ const [child] = node.children;
65365
+ if (child.type === 'element' && child.tagName === 'code' && child.properties.lang === 'mermaid') {
65366
+ node.properties = Object.assign(Object.assign({}, node.properties), { className: ['mermaid', ...(node.properties.className || [])] });
65367
+ }
65368
+ });
65369
+ return tree;
65370
+ };
65371
+ /* harmony default export */ const transform_mermaid = (mermaidTransformer);
65372
+
65304
65373
  ;// ./processor/transform/readme-components.ts
65305
65374
 
65306
65375
 
@@ -65378,9 +65447,9 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
65378
65447
  const { position } = node;
65379
65448
  const { align = [...new Array(node.children.length)].map(() => null) } = getAttrs(node);
65380
65449
  let children = [];
65381
- visit(node, { name: 'tr' }, row => {
65450
+ lib_visit(node, { name: 'tr' }, row => {
65382
65451
  let rowChildren = [];
65383
- visit(row, isTableCell, ({ name, children, position }) => {
65452
+ lib_visit(row, isTableCell, ({ name, children, position }) => {
65384
65453
  rowChildren.push({
65385
65454
  type: tableTypes[name],
65386
65455
  children,
@@ -65399,7 +65468,7 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
65399
65468
  position,
65400
65469
  children,
65401
65470
  };
65402
- visit(mdNode, isMDXElement, coerceJsxToMd({ components, html }));
65471
+ lib_visit(mdNode, isMDXElement, coerceJsxToMd({ components, html }));
65403
65472
  parent.children[index] = mdNode;
65404
65473
  return SKIP;
65405
65474
  }
@@ -65442,8 +65511,8 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
65442
65511
  }
65443
65512
  };
65444
65513
  const readmeComponents = (opts) => () => tree => {
65445
- visit(tree, isMDXElement, coerceJsxToMd(opts));
65446
- visit(tree, 'paragraph', (node, index, parent) => {
65514
+ lib_visit(tree, isMDXElement, coerceJsxToMd(opts));
65515
+ lib_visit(tree, 'paragraph', (node, index, parent) => {
65447
65516
  // @ts-ignore
65448
65517
  if (parent.type !== 'tableRow')
65449
65518
  return;
@@ -65461,11 +65530,11 @@ const readmeComponents = (opts) => () => tree => {
65461
65530
  const imageAttrs = ['align', 'alt', 'caption', 'border', 'height', 'src', 'title', 'width', 'lazy', 'className'];
65462
65531
  const readmeToMdx = () => tree => {
65463
65532
  // Unwrap pinned nodes, replace rdme-pin with its child node
65464
- visit(tree, 'rdme-pin', (node, i, parent) => {
65533
+ lib_visit(tree, 'rdme-pin', (node, i, parent) => {
65465
65534
  const newNode = node.children[0];
65466
65535
  parent.children.splice(i, 1, newNode);
65467
65536
  });
65468
- visit(tree, NodeTypes.tutorialTile, (tile, index, parent) => {
65537
+ lib_visit(tree, NodeTypes.tutorialTile, (tile, index, parent) => {
65469
65538
  parent.children.splice(index, 1, {
65470
65539
  type: 'mdxJsxFlowElement',
65471
65540
  name: 'TutorialTile',
@@ -65473,7 +65542,7 @@ const readmeToMdx = () => tree => {
65473
65542
  children: [],
65474
65543
  });
65475
65544
  });
65476
- visit(tree, 'figure', (figure, index, parent) => {
65545
+ lib_visit(tree, 'figure', (figure, index, parent) => {
65477
65546
  const [image, caption] = figure.children;
65478
65547
  const { align, width } = image.data.hProperties;
65479
65548
  const border = image.data.hProperties.className === 'border';
@@ -65485,7 +65554,7 @@ const readmeToMdx = () => tree => {
65485
65554
  });
65486
65555
  });
65487
65556
  const hasExtra = (attributes) => !!attributes.find(attr => !['alt', 'src', 'title'].includes(attr.name));
65488
- visit(tree, 'image', (image, index, parent) => {
65557
+ lib_visit(tree, 'image', (image, index, parent) => {
65489
65558
  if (!('data' in image))
65490
65559
  return;
65491
65560
  if ('url' in image)
@@ -65507,7 +65576,7 @@ const readmeToMdx = () => tree => {
65507
65576
  });
65508
65577
  }
65509
65578
  });
65510
- visit(tree, NodeTypes.imageBlock, (image, index, parent) => {
65579
+ lib_visit(tree, NodeTypes.imageBlock, (image, index, parent) => {
65511
65580
  const attributes = toAttributes(image.data.hProperties, imageAttrs);
65512
65581
  if (hasExtra(attributes)) {
65513
65582
  parent.children.splice(index, 1, {
@@ -65521,7 +65590,7 @@ const readmeToMdx = () => tree => {
65521
65590
  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 })));
65522
65591
  }
65523
65592
  });
65524
- visit(tree, 'html', (node, index, parent) => {
65593
+ lib_visit(tree, 'html', (node, index, parent) => {
65525
65594
  const html = node.value;
65526
65595
  const isScriptOrStyleTag = [!!html.match(/^<(?:style|script)/i), !!html.match(/<\/(?:style|script)>$/i)];
65527
65596
  if (!isScriptOrStyleTag.includes(true))
@@ -65539,58 +65608,6 @@ const readmeToMdx = () => tree => {
65539
65608
  };
65540
65609
  /* harmony default export */ const readme_to_mdx = (readmeToMdx);
65541
65610
 
65542
- ;// ./processor/transform/variables.ts
65543
-
65544
-
65545
- const variables = ({ asMdx } = { asMdx: true }) => tree => {
65546
- visit(tree, (node, index, parent) => {
65547
- var _a, _b;
65548
- if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
65549
- return;
65550
- // @ts-expect-error - estree is not defined on our mdx types?!
65551
- if (node.data.estree.type !== 'Program')
65552
- return;
65553
- // @ts-expect-error - estree is not defined on our mdx types?!
65554
- const [expression] = node.data.estree.body;
65555
- if (!expression ||
65556
- expression.type !== 'ExpressionStatement' ||
65557
- ((_a = expression.expression.object) === null || _a === void 0 ? void 0 : _a.name) !== 'user' ||
65558
- !['Literal', 'Identifier'].includes((_b = expression.expression.property) === null || _b === void 0 ? void 0 : _b.type))
65559
- return;
65560
- const name = expression.expression.property.type === 'Identifier'
65561
- ? expression.expression.property.name
65562
- : expression.expression.property.value;
65563
- let variable = asMdx
65564
- ? {
65565
- type: 'mdxJsxTextElement',
65566
- name: 'Variable',
65567
- attributes: [
65568
- {
65569
- type: 'mdxJsxAttribute',
65570
- name: 'name',
65571
- value: name,
65572
- },
65573
- ],
65574
- children: [],
65575
- position: node.position,
65576
- }
65577
- : {
65578
- type: NodeTypes.variable,
65579
- data: {
65580
- hName: 'Variable',
65581
- hProperties: {
65582
- name,
65583
- },
65584
- },
65585
- value: `{${node.value}}`,
65586
- position: node.position,
65587
- };
65588
- parent.children.splice(index, 1, variable);
65589
- });
65590
- return tree;
65591
- };
65592
- /* harmony default export */ const transform_variables = (variables);
65593
-
65594
65611
  ;// ./processor/transform/tables-to-jsx.ts
65595
65612
 
65596
65613
 
@@ -65616,21 +65633,21 @@ const visitor = (table, index, parent) => {
65616
65633
  : cell.children[0];
65617
65634
  // @note: Compatibility with RDMD. Ideally, I'd put this in a separate
65618
65635
  // transformer, but then there'd be some duplication.
65619
- visit(cell, 'break', (_, index, parent) => {
65636
+ lib_visit(cell, 'break', (_, index, parent) => {
65620
65637
  parent.children.splice(index, 1, { type: 'text', value: '\n' });
65621
65638
  });
65622
- if (!phrasing(content)) {
65639
+ if (!phrasing(content) && content.type !== 'escape') {
65623
65640
  hasFlowContent = true;
65624
65641
  return EXIT;
65625
65642
  }
65626
- visit(cell, isLiteral, (node) => {
65643
+ lib_visit(cell, isLiteral, (node) => {
65627
65644
  if (node.value.match(/\n/)) {
65628
65645
  hasFlowContent = true;
65629
65646
  return EXIT;
65630
65647
  }
65631
65648
  });
65632
65649
  };
65633
- visit(table, tables_to_jsx_isTableCell, tableCellVisitor);
65650
+ lib_visit(table, tables_to_jsx_isTableCell, tableCellVisitor);
65634
65651
  if (!hasFlowContent) {
65635
65652
  table.type = 'table';
65636
65653
  return;
@@ -65678,50 +65695,62 @@ const visitor = (table, index, parent) => {
65678
65695
  };
65679
65696
  const isTable = (node) => ['table', 'tableau'].includes(node.type);
65680
65697
  const tablesToJsx = () => tree => {
65681
- visit(tree, isTable, visitor);
65698
+ lib_visit(tree, isTable, visitor);
65682
65699
  return tree;
65683
65700
  };
65684
65701
  /* harmony default export */ const tables_to_jsx = (tablesToJsx);
65685
65702
 
65686
- ;// ./processor/transform/compatability.ts
65703
+ ;// ./processor/transform/variables.ts
65687
65704
 
65688
65705
 
65689
- const strongTest = (node) => ['emphasis', 'strong'].includes(node.type);
65690
- const compatibilityTransfomer = () => tree => {
65691
- const trimEmphasis = (node) => {
65692
- visit(node, 'text', child => {
65693
- child.value = child.value.trim();
65694
- return EXIT;
65695
- });
65696
- return node;
65697
- };
65698
- visit(tree, strongTest, node => {
65699
- trimEmphasis(node);
65700
- return SKIP;
65701
- });
65702
- visit(tree, 'image', (node, index, parent) => {
65703
- if (phrasing(parent) || !parent.children.every(child => child.type === 'image' || !phrasing(child)))
65706
+ const variables = ({ asMdx } = { asMdx: true }) => tree => {
65707
+ lib_visit(tree, (node, index, parent) => {
65708
+ var _a, _b;
65709
+ if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
65704
65710
  return;
65705
- parent.children.splice(index, 1, { type: 'paragraph', children: [node] });
65706
- });
65707
- return tree;
65708
- };
65709
- /* harmony default export */ const compatability = (compatibilityTransfomer);
65710
-
65711
- ;// ./processor/transform/mermaid.ts
65712
-
65713
- const mermaidTransformer = () => (tree) => {
65714
- visit(tree, 'element', (node) => {
65715
- if (node.tagName !== 'pre' || node.children.length !== 1)
65711
+ // @ts-expect-error - estree is not defined on our mdx types?!
65712
+ if (node.data.estree.type !== 'Program')
65716
65713
  return;
65717
- const [child] = node.children;
65718
- if (child.type === 'element' && child.tagName === 'code' && child.properties.lang === 'mermaid') {
65719
- node.properties = Object.assign(Object.assign({}, node.properties), { className: ['mermaid', ...(node.properties.className || [])] });
65720
- }
65714
+ // @ts-expect-error - estree is not defined on our mdx types?!
65715
+ const [expression] = node.data.estree.body;
65716
+ if (!expression ||
65717
+ expression.type !== 'ExpressionStatement' ||
65718
+ ((_a = expression.expression.object) === null || _a === void 0 ? void 0 : _a.name) !== 'user' ||
65719
+ !['Literal', 'Identifier'].includes((_b = expression.expression.property) === null || _b === void 0 ? void 0 : _b.type))
65720
+ return;
65721
+ const name = expression.expression.property.type === 'Identifier'
65722
+ ? expression.expression.property.name
65723
+ : expression.expression.property.value;
65724
+ let variable = asMdx
65725
+ ? {
65726
+ type: 'mdxJsxTextElement',
65727
+ name: 'Variable',
65728
+ attributes: [
65729
+ {
65730
+ type: 'mdxJsxAttribute',
65731
+ name: 'name',
65732
+ value: name,
65733
+ },
65734
+ ],
65735
+ children: [],
65736
+ position: node.position,
65737
+ }
65738
+ : {
65739
+ type: NodeTypes.variable,
65740
+ data: {
65741
+ hName: 'Variable',
65742
+ hProperties: {
65743
+ name,
65744
+ },
65745
+ },
65746
+ value: `{${node.value}}`,
65747
+ position: node.position,
65748
+ };
65749
+ parent.children.splice(index, 1, variable);
65721
65750
  });
65722
65751
  return tree;
65723
65752
  };
65724
- /* harmony default export */ const transform_mermaid = (mermaidTransformer);
65753
+ /* harmony default export */ const transform_variables = (variables);
65725
65754
 
65726
65755
  ;// ./processor/transform/index.ts
65727
65756
 
@@ -65738,6 +65767,7 @@ const mermaidTransformer = () => (tree) => {
65738
65767
 
65739
65768
 
65740
65769
 
65770
+
65741
65771
  const defaultTransforms = {
65742
65772
  calloutTransformer: callouts,
65743
65773
  codeTabsTransformer: code_tabs,
@@ -65954,7 +65984,7 @@ function rehypeSlug(options) {
65954
65984
  return function (tree) {
65955
65985
  slugs.reset()
65956
65986
 
65957
- visit(tree, 'element', function (node) {
65987
+ lib_visit(tree, 'element', function (node) {
65958
65988
  if (headingRank(node) && !node.properties.id) {
65959
65989
  node.properties.id = prefix + slugs.slug(hast_util_to_string_lib_toString(node))
65960
65990
  }
@@ -74077,7 +74107,7 @@ function state_createState(tree, options) {
74077
74107
  wrap: state_wrap
74078
74108
  }
74079
74109
 
74080
- visit(tree, function (node) {
74110
+ lib_visit(tree, function (node) {
74081
74111
  if (node.type === 'definition' || node.type === 'footnoteDefinition') {
74082
74112
  const map = node.type === 'definition' ? definitionById : footnoteById
74083
74113
  const id = String(node.identifier).toUpperCase()
@@ -76738,7 +76768,7 @@ function rehypeRemoveRaw() {
76738
76768
  * Nothing.
76739
76769
  */
76740
76770
  return function (tree) {
76741
- visit(tree, 'raw', function (_, index, parent) {
76771
+ lib_visit(tree, 'raw', function (_, index, parent) {
76742
76772
  if (parent && typeof index === 'number') {
76743
76773
  parent.children.splice(index, 1)
76744
76774
  return index
@@ -76862,7 +76892,7 @@ function remarkMarkAndUnravel() {
76862
76892
  * Nothing.
76863
76893
  */
76864
76894
  return function (tree) {
76865
- visit(tree, function (node, index, parent) {
76895
+ lib_visit(tree, function (node, index, parent) {
76866
76896
  let offset = -1
76867
76897
  let all = true
76868
76898
  let oneOrMore = false
@@ -78481,7 +78511,7 @@ const tocToHast = (headings = []) => {
78481
78511
  };
78482
78512
  const tocToMdx = (toc, components) => {
78483
78513
  const tree = { type: 'root', children: toc };
78484
- visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
78514
+ lib_visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
78485
78515
  const toc = components[node.name].toc || [];
78486
78516
  parent.children.splice(index, 1, ...toc);
78487
78517
  });
@@ -78537,9 +78567,10 @@ const compile_compile = (text, _a = {}) => {
78537
78567
  remarkGfm,
78538
78568
  ...Object.values(transforms),
78539
78569
  [compile_codeTabsTransformer, { copyButtons }],
78540
- transform_variables,
78541
78570
  ], rehypePlugins: [...rehypePlugins, [rehypeToc, { components }]] }, opts));
78542
- return String(vfile).replace(/await import\(_resolveDynamicMdxSpecifier\(('react'|"react")\)\)/, 'arguments[0].imports.React');
78571
+ return String(vfile)
78572
+ .replace(/await import\(_resolveDynamicMdxSpecifier\(('react'|"react")\)\)/, 'arguments[0].imports.React')
78573
+ .replace('"use strict";', '"use strict";\nconst { user } = arguments[0].imports;');
78543
78574
  }
78544
78575
  catch (error) {
78545
78576
  throw error.line ? new MdxSyntaxError(error, text) : error;
@@ -78547,6 +78578,24 @@ const compile_compile = (text, _a = {}) => {
78547
78578
  };
78548
78579
  /* harmony default export */ const lib_compile = (compile_compile);
78549
78580
 
78581
+ ;// ./lib/exports.ts
78582
+
78583
+
78584
+
78585
+ const EXPORT_NAME_REGEX = /export\s+(?:const|let|var|function)\s+(\w+)/;
78586
+ const exports_exports = (doc) => {
78587
+ const set = new Set();
78588
+ visit(mdast(doc), isMDXEsm, (node) => {
78589
+ var _a;
78590
+ if ((_a = node.value) === null || _a === void 0 ? void 0 : _a.match(EXPORT_NAME_REGEX)) {
78591
+ const [, name] = node.value.match(EXPORT_NAME_REGEX);
78592
+ set.add(name);
78593
+ }
78594
+ });
78595
+ return Array.from(set);
78596
+ };
78597
+ /* harmony default export */ const lib_exports = ((/* unused pure expression or super */ null && (exports_exports)));
78598
+
78550
78599
  ;// ./lib/hast.ts
78551
78600
 
78552
78601
 
@@ -78557,7 +78606,11 @@ const hast = (text, opts = {}) => {
78557
78606
  memo[name] = lib_mdast(doc);
78558
78607
  return memo;
78559
78608
  }, {});
78560
- const processor = ast_processor(opts).use(inject_components({ components })).use(remarkRehype).use(rehypePlugins);
78609
+ const processor = ast_processor(opts)
78610
+ .use(inject_components({ components }))
78611
+ .use(mdx_to_hast)
78612
+ .use(remarkRehype)
78613
+ .use(rehypePlugins);
78561
78614
  return processor.runSync(processor.parse(text));
78562
78615
  };
78563
78616
  /* harmony default export */ const lib_hast = (hast);
@@ -78584,7 +78637,7 @@ const addSpaceAfter = (index, parent) => {
78584
78637
  };
78585
78638
  const trimEmphasis = (node, index, parent) => {
78586
78639
  let trimmed = false;
78587
- visit(node, 'text', (child) => {
78640
+ lib_visit(node, 'text', (child) => {
78588
78641
  const newValue = child.value.trimStart();
78589
78642
  if (newValue !== child.value) {
78590
78643
  trimmed = true;
@@ -78592,7 +78645,7 @@ const trimEmphasis = (node, index, parent) => {
78592
78645
  }
78593
78646
  return EXIT;
78594
78647
  });
78595
- visit(node, 'text', (child) => {
78648
+ lib_visit(node, 'text', (child) => {
78596
78649
  const newValue = child.value.trimEnd();
78597
78650
  if (newValue !== child.value) {
78598
78651
  trimmed = true;
@@ -78606,7 +78659,7 @@ const trimEmphasis = (node, index, parent) => {
78606
78659
  }
78607
78660
  };
78608
78661
  const emphasisTransfomer = () => (tree) => {
78609
- visit(tree, emphasis_strongTest, trimEmphasis);
78662
+ lib_visit(tree, emphasis_strongTest, trimEmphasis);
78610
78663
  return tree;
78611
78664
  };
78612
78665
  /* harmony default export */ const migration_emphasis = (emphasisTransfomer);
@@ -78614,7 +78667,7 @@ const emphasisTransfomer = () => (tree) => {
78614
78667
  ;// ./processor/migration/images.ts
78615
78668
 
78616
78669
  const images_imageTransformer = () => tree => {
78617
- visit(tree, 'image', (image) => {
78670
+ lib_visit(tree, 'image', (image) => {
78618
78671
  var _a, _b;
78619
78672
  if (((_b = (_a = image.data) === null || _a === void 0 ? void 0 : _a.hProperties) === null || _b === void 0 ? void 0 : _b.className) === 'border') {
78620
78673
  image.data.hProperties.border = true;
@@ -78626,9 +78679,9 @@ const images_imageTransformer = () => tree => {
78626
78679
  ;// ./processor/migration/linkReference.ts
78627
78680
 
78628
78681
  const linkReferenceTransformer = () => (tree) => {
78629
- visit(tree, 'linkReference', (node, index, parent) => {
78682
+ lib_visit(tree, 'linkReference', (node, index, parent) => {
78630
78683
  const definitions = {};
78631
- visit(tree, 'definition', (def) => {
78684
+ lib_visit(tree, 'definition', (def) => {
78632
78685
  definitions[def.identifier] = def;
78633
78686
  });
78634
78687
  if (node.label === node.identifier && parent) {
@@ -78691,8 +78744,8 @@ const migrateTableCells = (vfile, rdmd) => (table) => {
78691
78744
  */
78692
78745
  // console.error(err);
78693
78746
  }
78694
- visit(table, 'tableRow', (row, i) => {
78695
- visit(row, 'tableCell', (cell, j) => {
78747
+ lib_visit(table, 'tableRow', (row, i) => {
78748
+ lib_visit(row, 'tableCell', (cell, j) => {
78696
78749
  let children = cell.children;
78697
78750
  if (json && json.data[magicIndex(i, j)]) {
78698
78751
  const string = json.data[magicIndex(i, j)].replace(psuedoListRegex, '$<ws>- $<item>');
@@ -78706,7 +78759,7 @@ const migrateTableCells = (vfile, rdmd) => (table) => {
78706
78759
  });
78707
78760
  return SKIP;
78708
78761
  });
78709
- visit(table, 'inlineCode', (code) => {
78762
+ lib_visit(table, 'inlineCode', (code) => {
78710
78763
  if (code.value.includes('\n')) {
78711
78764
  // eslint-disable-next-line no-param-reassign
78712
78765
  code.type = 'code';
@@ -78716,7 +78769,7 @@ const migrateTableCells = (vfile, rdmd) => (table) => {
78716
78769
  function tableCellTransformer() {
78717
78770
  const rdmd = this.data('rdmd');
78718
78771
  return (tree, vfile) => {
78719
- visit(tree, 'table', migrateTableCells(vfile, rdmd));
78772
+ lib_visit(tree, 'table', migrateTableCells(vfile, rdmd));
78720
78773
  return tree;
78721
78774
  };
78722
78775
  }
@@ -78727,12 +78780,7 @@ function tableCellTransformer() {
78727
78780
 
78728
78781
 
78729
78782
 
78730
- const transformers = [
78731
- migration_emphasis,
78732
- migration_images,
78733
- migration_linkReference,
78734
- table_cell,
78735
- ];
78783
+ const transformers = [migration_emphasis, migration_images, migration_linkReference, table_cell];
78736
78784
  /* harmony default export */ const migration = (transformers);
78737
78785
 
78738
78786
  ;// ./lib/mdastV6.ts
@@ -81816,7 +81864,7 @@ function media(state, node) {
81816
81864
  /** @type {Root} */
81817
81865
  const fragment = {type: 'root', children: nodes}
81818
81866
 
81819
- visit(fragment, function (node) {
81867
+ lib_visit(fragment, function (node) {
81820
81868
  if (node.type === 'link') {
81821
81869
  linkInFallbackContent = true
81822
81870
  return EXIT
@@ -82287,7 +82335,7 @@ function inspect(node) {
82287
82335
  let rowIndex = 0
82288
82336
  let cellIndex = 0
82289
82337
 
82290
- visit(node, function (child) {
82338
+ lib_visit(node, function (child) {
82291
82339
  if (child.type === 'element') {
82292
82340
  // Don’t enter nested tables.
82293
82341
  if (child.tagName === 'table' && node !== child) {
@@ -83109,7 +83157,7 @@ function toMdast(tree, options) {
83109
83157
  // @ts-expect-error: fine to pass an arbitrary node.
83110
83158
  transformWhitespace(cleanTree)
83111
83159
 
83112
- visit(cleanTree, function (node) {
83160
+ lib_visit(cleanTree, function (node) {
83113
83161
  if (node && node.type === 'element' && node.properties) {
83114
83162
  const id = String(node.properties.id || '') || undefined
83115
83163
 
@@ -83137,7 +83185,7 @@ function toMdast(tree, options) {
83137
83185
  // we’re generating some whitespace too, and some nodes are in the end
83138
83186
  // ignored.
83139
83187
  // So clean up.
83140
- visit(mdast, function (node, index, parent) {
83188
+ lib_visit(mdast, function (node, index, parent) {
83141
83189
  if (node.type === 'text' && index !== undefined && parent) {
83142
83190
  const previous = parent.children[index - 1]
83143
83191
 
@@ -83477,11 +83525,19 @@ const mdx_mdx = (tree, _a = {}) => {
83477
83525
  };
83478
83526
  /* harmony default export */ const lib_mdx = (mdx_mdx);
83479
83527
 
83528
+ ;// ./lib/migrate.ts
83529
+
83530
+
83531
+ const migrate = (doc, { rdmd }) => {
83532
+ return lib_mdx(lib_mdastV6(doc, { rdmd })).replaceAll(/&#x20;/g, ' ');
83533
+ };
83534
+ /* harmony default export */ const lib_migrate = (migrate);
83535
+
83480
83536
  ;// ./lib/plain.ts
83481
83537
 
83482
83538
  const STRIP_TAGS = ['script', 'style'];
83483
83539
  function plain_one(node, opts) {
83484
- var _a, _b;
83540
+ var _a, _b, _c;
83485
83541
  if (node.type === 'comment')
83486
83542
  return '';
83487
83543
  if ('type' in node && node.type === 'text') {
@@ -83490,27 +83546,37 @@ function plain_one(node, opts) {
83490
83546
  if ('tagName' in node) {
83491
83547
  if (STRIP_TAGS.includes(node.tagName))
83492
83548
  return '';
83493
- if (node.tagName === 'html-block') {
83494
- if (!node.properties.html)
83495
- return '';
83496
- return plain_all(lib_hast(node.properties.html.toString()), opts);
83497
- }
83498
- if (node.tagName === 'rdme-callout') {
83499
- const { icon, title } = node.properties;
83500
- const children = (_a = node === null || node === void 0 ? void 0 : node.children) === null || _a === void 0 ? void 0 : _a.slice(title ? 1 : 0);
83501
- const body = children ? plain_all({ type: 'root', children }, opts) : '';
83502
- return [icon, ' ', title, title && body && ': ', body].filter(Boolean).join('');
83503
- }
83504
- if (node.tagName === 'readme-glossary-item') {
83505
- return node.properties.term;
83506
- }
83507
- if (node.tagName === 'readme-variable') {
83508
- const key = node.properties.variable.toString();
83509
- const val = opts.variables[key];
83510
- return val || `<<${key}>>`;
83511
- }
83512
- if (node.tagName === 'img') {
83513
- return ((_b = node.properties) === null || _b === void 0 ? void 0 : _b.title) || '';
83549
+ switch (node.tagName) {
83550
+ case 'html-block': {
83551
+ if (!node.properties.html)
83552
+ return '';
83553
+ return plain_all(lib_hast(node.properties.html.toString()), opts);
83554
+ }
83555
+ case 'rdme-callout': {
83556
+ const { icon, title } = node.properties;
83557
+ const children = (_a = node === null || node === void 0 ? void 0 : node.children) === null || _a === void 0 ? void 0 : _a.slice(title ? 1 : 0);
83558
+ const body = children ? plain_all({ type: 'root', children }, opts) : '';
83559
+ return [icon, ' ', title, title && body && ': ', body].filter(Boolean).join('');
83560
+ }
83561
+ case 'readme-glossary-item': {
83562
+ return node.properties.term;
83563
+ }
83564
+ case 'readme-variable': {
83565
+ const key = node.properties.variable.toString();
83566
+ const val = opts.variables[key];
83567
+ return val || `<<${key}>>`;
83568
+ }
83569
+ case 'img': {
83570
+ return ((_b = node.properties) === null || _b === void 0 ? void 0 : _b.title) || '';
83571
+ }
83572
+ case 'Accordion':
83573
+ case 'Card':
83574
+ case 'Tab': {
83575
+ const title = ((_c = node.properties) === null || _c === void 0 ? void 0 : _c.title) || '';
83576
+ const children = node === null || node === void 0 ? void 0 : node.children;
83577
+ const body = children ? plain_all({ type: 'root', children }, opts) : '';
83578
+ return [title, body].filter(Boolean).join(' ');
83579
+ }
83514
83580
  }
83515
83581
  }
83516
83582
  if ('value' in node) {
@@ -83599,6 +83665,24 @@ const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }
83599
83665
  };
83600
83666
  /* harmony default export */ const contexts = (Contexts);
83601
83667
 
83668
+ ;// ./utils/user.ts
83669
+ const User = (variables) => {
83670
+ const { user = {}, defaults = [] } = variables || {};
83671
+ return new Proxy(user, {
83672
+ get(target, attribute) {
83673
+ if (typeof attribute === 'symbol') {
83674
+ return '';
83675
+ }
83676
+ if (attribute in target) {
83677
+ return target[attribute];
83678
+ }
83679
+ const def = defaults.find((d) => d.name === attribute);
83680
+ return def ? def.default : attribute.toUpperCase();
83681
+ },
83682
+ });
83683
+ };
83684
+ /* harmony default export */ const user = (User);
83685
+
83602
83686
  ;// ./lib/run.tsx
83603
83687
  var run_rest = (undefined && undefined.__rest) || function (s, e) {
83604
83688
  var t = {};
@@ -83619,6 +83703,7 @@ var run_rest = (undefined && undefined.__rest) || function (s, e) {
83619
83703
 
83620
83704
 
83621
83705
 
83706
+
83622
83707
  const makeUseMDXComponents = (more = {}) => {
83623
83708
  const headings = Array.from({ length: 6 }).reduce((map, _, index) => {
83624
83709
  map[`h${index + 1}`] = components_Heading((index + 1));
@@ -83630,21 +83715,26 @@ const makeUseMDXComponents = (more = {}) => {
83630
83715
  const run_run = async (string, _opts = {}) => {
83631
83716
  const { Fragment } = jsx_runtime_namespaceObject;
83632
83717
  const { components = {}, terms, variables, baseUrl } = _opts, opts = run_rest(_opts, ["components", "terms", "variables", "baseUrl"]);
83633
- const defaults = Object.fromEntries(Object.entries(components).map(([tag, module]) => [tag, 'default' in module ? module.default : module]));
83634
- const exec = (text, { useMDXComponents = makeUseMDXComponents(defaults) } = {}) => {
83635
- 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));
83718
+ const executedComponents = Object.entries(components).reduce((memo, [tag, mod]) => {
83719
+ const { default: Content, toc, Toc } = mod, rest = run_rest(mod, ["default", "toc", "Toc"]);
83720
+ memo[tag] = Content;
83721
+ if (rest) {
83722
+ Object.entries(rest).forEach(([subTag, component]) => {
83723
+ memo[subTag] = component;
83724
+ });
83725
+ }
83726
+ return memo;
83727
+ }, {});
83728
+ const exec = (text, { useMDXComponents = makeUseMDXComponents(executedComponents) } = {}) => {
83729
+ 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));
83636
83730
  };
83637
- const { toc, default: Content } = await exec(string);
83731
+ const _a = await exec(string), { Toc: _Toc, toc, default: Content } = _a, exports = run_rest(_a, ["Toc", "toc", "default"]);
83638
83732
  const tocMdx = tocToMdx(toc, components);
83639
83733
  const { default: Toc } = await exec(lib_compile(tocMdx), { useMDXComponents: () => ({ p: Fragment }) });
83640
- return {
83641
- default: () => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(contexts, { terms: terms, variables: variables, baseUrl: baseUrl },
83642
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Content, null))),
83643
- toc,
83644
- Toc: () => tocMdx &&
83734
+ return Object.assign({ default: () => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(contexts, { terms: terms, baseUrl: baseUrl, variables: variables },
83735
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Content, null))), toc, Toc: () => tocMdx &&
83645
83736
  Toc && (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(components_TableOfContents, null,
83646
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Toc, null))),
83647
- };
83737
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Toc, null))) }, exports);
83648
83738
  };
83649
83739
  /* harmony default export */ const lib_run = (run_run);
83650
83740
 
@@ -83654,8 +83744,9 @@ const run_run = async (string, _opts = {}) => {
83654
83744
 
83655
83745
  const tags = (doc) => {
83656
83746
  const set = new Set();
83657
- visit(lib_mdast(doc), isMDXElement, (node) => {
83658
- if (node.name.match(/^[A-Z]/)) {
83747
+ lib_visit(lib_mdast(doc), isMDXElement, (node) => {
83748
+ var _a;
83749
+ if ((_a = node.name) === null || _a === void 0 ? void 0 : _a.match(/^[A-Z]/)) {
83659
83750
  set.add(node.name);
83660
83751
  }
83661
83752
  });
@@ -83663,14 +83754,6 @@ const tags = (doc) => {
83663
83754
  };
83664
83755
  /* harmony default export */ const lib_tags = (tags);
83665
83756
 
83666
- ;// ./lib/migrate.ts
83667
-
83668
-
83669
- const migrate = (doc, { rdmd }) => {
83670
- return lib_mdx(lib_mdastV6(doc, { rdmd })).replaceAll(/&#x20;/g, ' ');
83671
- };
83672
- /* harmony default export */ const lib_migrate = (migrate);
83673
-
83674
83757
  ;// ./lib/index.ts
83675
83758
 
83676
83759
 
@@ -83683,6 +83766,7 @@ const migrate = (doc, { rdmd }) => {
83683
83766
 
83684
83767
 
83685
83768
 
83769
+
83686
83770
  ;// ./index.tsx
83687
83771
 
83688
83772