Fix md mode comment (#3880)
* fix: fix a bug where md mode markdown breaks on comments * chore: add changeset
This commit is contained in:
parent
c2b14d5253
commit
402c4181dc
2 changed files with 11 additions and 4 deletions
5
.changeset/ten-frogs-mate.md
Normal file
5
.changeset/ten-frogs-mate.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix rendering HTML comments in `mode="md"` configuration
|
|
@ -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.
|
||||
markdownContent = markdownContent.replace(
|
||||
/<\s*!--([^-->]*)(.*?)-->/gs,
|
||||
(whole) => `{/*${whole.replace(/\*\//g, '*\u200b/')}*/}`
|
||||
);
|
||||
if (renderOpts.mode === 'mdx') {
|
||||
markdownContent = markdownContent.replace(
|
||||
/<\s*!--([^-->]*)(.*?)-->/gs,
|
||||
(whole) => `{/*${whole.replace(/\*\//g, '*\u200b/')}*/}`
|
||||
);
|
||||
}
|
||||
|
||||
let renderResult = await renderMarkdown(markdownContent, {
|
||||
...renderOpts,
|
||||
|
|
Loading…
Reference in a new issue