fix(markdown): escape when mode == 'md' (#2971)

* Fix rehype escape

* Changeset
This commit is contained in:
Juan Martín Seery 2022-04-03 14:32:12 -03:00 committed by GitHub
parent 75919537be
commit ad3c391696
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/markdown-remark': patch
---
Escape expressions when mode == 'md'

View file

@ -50,8 +50,7 @@ export async function renderMarkdown(content: string, opts?: MarkdownRenderingOp
let parser = unified()
.use(markdown)
.use(isMDX ? [remarkJsx] : [])
.use(isMDX ? [remarkExpressions] : [])
.use(isMDX ? [remarkJsx, remarkExpressions] : [])
.use([remarkUnwrap]);
if (remarkPlugins.length === 0 && rehypePlugins.length === 0) {
@ -91,10 +90,8 @@ export async function renderMarkdown(content: string, opts?: MarkdownRenderingOp
});
parser
.use(isMDX ? [rehypeJsx] : [])
.use(isMDX ? [rehypeExpressions] : [])
.use(isMDX ? [] : [rehypeRaw])
.use(isMDX ? [rehypeEscape] : [])
.use(isMDX ? [rehypeJsx, rehypeExpressions] : [rehypeRaw])
.use(rehypeEscape)
.use(rehypeIslands);
let result: string;