Skip to content

Commit 0741f49

Browse files
authored
Allow newlines in props when parsing JSX (#404)
1 parent b9bf054 commit 0741f49

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/remark-mdx/tag.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const attributeName = '[a-zA-Z_:][a-zA-Z0-9:._-]*'
77
const unquoted = '[^"\'=<>`\\u0000-\\u0020]+'
88
const singleQuoted = "'[^']*'"
99
const doubleQuoted = '"[^"]*"'
10-
const jsProps = '{[^\n]*}'
10+
const jsProps = '{.*}'
1111
const attributeValue =
1212
'(?:' +
1313
unquoted +
@@ -42,5 +42,6 @@ exports.tag = new RegExp(
4242
declaration +
4343
'|' +
4444
cdata +
45-
')'
45+
')',
46+
's'
4647
)

packages/remark-mdx/test/fixtures/inline-parsing.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,20 @@ module.exports = [
6464
{
6565
description: 'Handles links',
6666
mdx: 'Hello, <Component>{props.world}</Component> and a moustache! }: <https://johno.com>'
67+
},
68+
{
69+
description: 'Handles multiline JSX blocks',
70+
mdx: `
71+
<Image
72+
src={asset(\`\${SOME_CONSTANT}/some.png\`)}
73+
width="123"
74+
height="456"
75+
caption={
76+
<span>
77+
Here's a caption
78+
</span>
79+
}
80+
/>
81+
`.trim()
6782
}
6883
]

0 commit comments

Comments
 (0)