Skip to content

Commit

Permalink
fix(markdown): escape when mode == 'md' (#2971)
Browse files Browse the repository at this point in the history
* Fix rehype escape

* Changeset
  • Loading branch information
JuanM04 authored Apr 3, 2022
1 parent 7591953 commit ad3c391
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-cows-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/markdown-remark': patch
---

Escape expressions when mode == 'md'
9 changes: 3 additions & 6 deletions packages/markdown/remark/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ad3c391

Please sign in to comment.