astro
astro copied to clipboard
🐛 BUG: JSON wrapped in apostrophes (raw and escaped) breaks Markdown parsing
What version of astro
are you using?
0.22.9
What package manager are you using?
npm
What operating system are you using?
Linux
Describe the Bug
The following text strings break the Markdown parsing.
'{"first": "John"}'
'{"first":"John"}'
The first is a JSON quoted with apostrophes. The second is the HTML-escaped version of the same JSON. The error in both the cases is similar (complaining about encountering different characters).
/home/projects/github-jh8snw-ambf8a/src/pages/posts/index.md: Expected "}" but found ":"
Error: Transform failed with 1 error:
/home/projects/github-jh8snw-ambf8a/src/pages/posts/index.md:30:127: error: Expected "}" but found ":"
at failureErrorWithLog (/home/projects/github-jh8snw-ambf8a/node_modules/esbuild/lib/main.js:1493:15)
at eval (/home/projects/github-jh8snw-ambf8a/node_modules/esbuild/lib/main.js:1282:29)
at eval (/home/projects/github-jh8snw-ambf8a/node_modules/esbuild/lib/main.js:629:9)
at handleIncomingPacket (/home/projects/github-jh8snw-ambf8a/node_modules/esbuild/lib/main.js:726:9)
at Socket.readFromStdout (/home/projects/github-jh8snw-ambf8a/node_modules/esbuild/lib/main.js:596:7)
at Socket.EventEmitter.emit (https://github-jh8snw-ambf8a.w.staticblitz.com/blitz.4bc445b0bf2f24de41719bcf76515e3a7b66a071.js:6:126633)
at addChunk (https://github-jh8snw-ambf8a.w.staticblitz.com/blitz.4bc445b0bf2f24de41719bcf76515e3a7b66a071.js:6:516009)
at readableAddChunk (https://github-jh8snw-ambf8a.w.staticblitz.com/blitz.4bc445b0bf2f24de41719bcf76515e3a7b66a071.js:6:515730)
at Socket.Readable.push (https://github-jh8snw-ambf8a.w.staticblitz.com/blitz.4bc445b0bf2f24de41719bcf76515e3a7b66a071.js:6:516397)
at _0x198a4d.onStreamRead [as onread] (https://github-jh8snw-ambf8a.w.staticblitz.com/blitz.4bc445b0bf2f24de41719bcf76515e3a7b66a071.js:6:543527)
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-jh8snw-ambf8a?file=src/pages/posts/index.md
Could this be a compiler issue, @natemoo-re?
Same error, but the symbol is \p{…}
.
Reproduce link: https://stackblitz.com/edit/github-xi4toi?devtoolsheight=33&file=src/pages/index.md
I came across a similar issue it seems to be not just JSONs but all {}
everywhere even if they are escaped \{\}
. The same is again true if the characters are used as HTML entities
This is still a thing in 0.25.2 https://stackblitz.com/edit/github-a1ruci?file=src/pages/posts/index.md
This has since been fixed, here's it working in 1.0: https://stackblitz.com/edit/github-a1ruci-5fm9ki?file=astro.config.mjs,package.json,src%2Fpages%2Findex.astro,src%2Fpages%2Fposts%2Findex.md