markdown-to-jsx icon indicating copy to clipboard operation
markdown-to-jsx copied to clipboard

Parse component props uncorrectly

Open xwchris opened this issue 4 years ago • 4 comments

I'm using a string like this

'<CodeBlock data={[{ a: [{ b: 1 }] }]} />'

I expect data is [{ a: [{ b: 1 }] }], unfortunately the result is {[{ a: [{ b: 1 }] } which ]} in the end is missing.

In the origin code I found this regexp, and this cause the problem

const ATTR_EXTRACTOR_R = /([-A-Z0-9_:]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|(?:\{((?:\\.|{[^}]*?}|[^}])*)\})))?/gi;

xwchris avatar Nov 17 '20 06:11 xwchris

Can you add a failing test?

quantizor avatar Nov 23 '20 19:11 quantizor

@probablyup I made a demo in code sandbox, maybe you can get it. https://codesandbox.io/s/inspiring-wildflower-o2b0x?file=/src/App.js

xwchris avatar Dec 02 '20 03:12 xwchris

Any solution to this?

DannyvanderJagt avatar Apr 22 '21 20:04 DannyvanderJagt

@quantizor any movement here?

Kwoly avatar Feb 26 '24 20:02 Kwoly