@readme/markdown 7.10.3 → 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 +16 -5
- package/dist/main.node.js +16 -5
- package/package.json +1 -1
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
|
-
|
|
65550
|
-
if (
|
|
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:
|
|
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
|
|
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
|
|
package/dist/main.node.js
CHANGED
|
@@ -66623,11 +66623,22 @@ const readmeToMdx = () => tree => {
|
|
|
66623
66623
|
|
|
66624
66624
|
const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
66625
66625
|
visit(tree, (node, index, parent) => {
|
|
66626
|
+
var _a, _b;
|
|
66626
66627
|
if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
|
|
66627
66628
|
return;
|
|
66628
|
-
|
|
66629
|
-
if (
|
|
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))
|
|
66630
66638
|
return;
|
|
66639
|
+
const name = expression.expression.property.type === 'Identifier'
|
|
66640
|
+
? expression.expression.property.name
|
|
66641
|
+
: expression.expression.property.value;
|
|
66631
66642
|
let variable = asMdx
|
|
66632
66643
|
? {
|
|
66633
66644
|
type: 'mdxJsxTextElement',
|
|
@@ -66636,7 +66647,7 @@ const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
|
66636
66647
|
{
|
|
66637
66648
|
type: 'mdxJsxAttribute',
|
|
66638
66649
|
name: 'name',
|
|
66639
|
-
value:
|
|
66650
|
+
value: name,
|
|
66640
66651
|
},
|
|
66641
66652
|
],
|
|
66642
66653
|
children: [],
|
|
@@ -66647,7 +66658,7 @@ const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
|
66647
66658
|
data: {
|
|
66648
66659
|
hName: 'Variable',
|
|
66649
66660
|
hProperties: {
|
|
66650
|
-
name
|
|
66661
|
+
name,
|
|
66651
66662
|
},
|
|
66652
66663
|
},
|
|
66653
66664
|
value: `{${node.value}}`,
|
|
@@ -84474,7 +84485,7 @@ const variable = (node) => {
|
|
|
84474
84485
|
// @note: coming from RDMD, it's set as `variable`. But when mdx is parsed,
|
|
84475
84486
|
// it's set as `name`
|
|
84476
84487
|
const name = node.data.hProperties.variable || node.data.hProperties.name;
|
|
84477
|
-
return `{user.${name}}`;
|
|
84488
|
+
return name.toString().match(/ /) ? `{user[${JSON.stringify(name)}]}` : `{user.${name}}`;
|
|
84478
84489
|
};
|
|
84479
84490
|
/* harmony default export */ const compile_variable = (variable);
|
|
84480
84491
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@readme/markdown",
|
|
3
3
|
"description": "ReadMe's React-based Markdown parser",
|
|
4
4
|
"author": "Rafe Goldberg <rafe@readme.io>",
|
|
5
|
-
"version": "7.10.
|
|
5
|
+
"version": "7.10.4",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|