From ad3c391696c5b9cc350a22831717682e73e25776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Seery?= Date: Sun, 3 Apr 2022 14:32:12 -0300 Subject: [PATCH] fix(markdown): escape when mode == 'md' (#2971) * Fix rehype escape * Changeset --- .changeset/silent-cows-shave.md | 5 +++++ packages/markdown/remark/src/index.ts | 9 +++------ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 .changeset/silent-cows-shave.md diff --git a/.changeset/silent-cows-shave.md b/.changeset/silent-cows-shave.md new file mode 100644 index 000000000..93b4f2120 --- /dev/null +++ b/.changeset/silent-cows-shave.md @@ -0,0 +1,5 @@ +--- +'@astrojs/markdown-remark': patch +--- + +Escape expressions when mode == 'md' diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index c15cf502d..dd9f95d58 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -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;