@readme/markdown 7.10.2 → 7.10.4

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
@@ -65544,11 +65544,22 @@ const readmeToMdx = () => tree => {
65544
65544
 
65545
65545
  const variables = ({ asMdx } = { asMdx: true }) => tree => {
65546
65546
  visit(tree, (node, index, parent) => {
65547
+ var _a, _b;
65547
65548
  if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
65548
65549
  return;
65549
- const match = node.value.match(/^user\.(?<value>.*)$/);
65550
- if (!match)
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))
65551
65559
  return;
65560
+ const name = expression.expression.property.type === 'Identifier'
65561
+ ? expression.expression.property.name
65562
+ : expression.expression.property.value;
65552
65563
  let variable = asMdx
65553
65564
  ? {
65554
65565
  type: 'mdxJsxTextElement',
@@ -65557,7 +65568,7 @@ const variables = ({ asMdx } = { asMdx: true }) => tree => {
65557
65568
  {
65558
65569
  type: 'mdxJsxAttribute',
65559
65570
  name: 'name',
65560
- value: match.groups.value,
65571
+ value: name,
65561
65572
  },
65562
65573
  ],
65563
65574
  children: [],
@@ -65568,7 +65579,7 @@ const variables = ({ asMdx } = { asMdx: true }) => tree => {
65568
65579
  data: {
65569
65580
  hName: 'Variable',
65570
65581
  hProperties: {
65571
- name: match.groups.value,
65582
+ name,
65572
65583
  },
65573
65584
  },
65574
65585
  value: `{${node.value}}`,
@@ -83395,7 +83406,7 @@ const variable = (node) => {
83395
83406
  // @note: coming from RDMD, it's set as `variable`. But when mdx is parsed,
83396
83407
  // it's set as `name`
83397
83408
  const name = node.data.hProperties.variable || node.data.hProperties.name;
83398
- return `{user.${name}}`;
83409
+ return name.toString().match(/ /) ? `{user[${JSON.stringify(name)}]}` : `{user.${name}}`;
83399
83410
  };
83400
83411
  /* harmony default export */ const compile_variable = (variable);
83401
83412