0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Fix md mode comment (#3880)

* fix: fix a bug where md mode markdown breaks on comments

* chore: add changeset
This commit is contained in:
Corbin Crutchley 2022-07-12 08:15:53 -07:00 committed by GitHub
parent c2b14d5253
commit 402c4181dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix rendering HTML comments in `mode="md"` configuration

View file

@ -148,10 +148,12 @@ export default function markdown({ config }: AstroPluginOptions): Plugin {
// Turn HTML comments into JS comments while preventing nested `*/` sequences
// from ending the JS comment by injecting a zero-width space
// Inside code blocks, this is removed during renderMarkdown by the remark-escape plugin.
if (renderOpts.mode === 'mdx') {
markdownContent = markdownContent.replace(
/<\s*!--([^-->]*)(.*?)-->/gs,
(whole) => `{/*${whole.replace(/\*\//g, '*\u200b/')}*/}`
);
}
let renderResult = await renderMarkdown(markdownContent, {
...renderOpts,