diff --git a/packages/astro/src/vite-plugin-markdown/index.ts b/packages/astro/src/vite-plugin-markdown/index.ts index 3d70aba72..027407d34 100644 --- a/packages/astro/src/vite-plugin-markdown/index.ts +++ b/packages/astro/src/vite-plugin-markdown/index.ts @@ -177,11 +177,13 @@ function $$slug(value) { return slugger.slug(value); } -const $$content = ${JSON.stringify(isMDX - ? content - // Avoid stripping "setup" and "components" - // in plain MD mode - : { ...content, setup, components })} +const $$content = ${JSON.stringify( + isMDX + ? content + : // Avoid stripping "setup" and "components" + // in plain MD mode + { ...content, setup, components } + )} ---`; const imports = `${layout ? `import Layout from '${layout}';` : ''} ${isMDX ? setup : ''}`.trim(); @@ -189,7 +191,7 @@ ${isMDX ? setup : ''}`.trim(); // Wrap with set:html fragment to skip // JSX expressions and components in "plain" md mode if (!isMDX) { - astroResult = `` + astroResult = ``; } // If the user imported "Layout", wrap the content in a Layout diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index 6c72ba981..1d0d1f946 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -46,7 +46,7 @@ export async function renderMarkdown( let parser = unified() .use(markdown) - .use(isMDX ? [remarkMdxish, remarkMarkAndUnravel, remarkUnwrap, remarkEscape] : []) + .use(isMDX ? [remarkMdxish, remarkMarkAndUnravel, remarkUnwrap, remarkEscape] : []); if (remarkPlugins.length === 0 && rehypePlugins.length === 0) { remarkPlugins = [...DEFAULT_REMARK_PLUGINS]; @@ -75,13 +75,15 @@ export async function renderMarkdown( markdownToHtml as any, { allowDangerousHtml: true, - passThrough: isMDX ? [ - 'raw', - 'mdxFlowExpression', - 'mdxJsxFlowElement', - 'mdxJsxTextElement', - 'mdxTextExpression', - ] : [], + passThrough: isMDX + ? [ + 'raw', + 'mdxFlowExpression', + 'mdxJsxFlowElement', + 'mdxJsxTextElement', + 'mdxTextExpression', + ] + : [], }, ], ]); @@ -91,13 +93,11 @@ export async function renderMarkdown( }); parser - .use(isMDX ? [ - rehypeJsx, - rehypeExpressions, - rehypeEscape, - rehypeIslands, - rehypeCollectHeaders, - ] : [rehypeCollectHeaders, rehypeRaw]) + .use( + isMDX + ? [rehypeJsx, rehypeExpressions, rehypeEscape, rehypeIslands, rehypeCollectHeaders] + : [rehypeCollectHeaders, rehypeRaw] + ) .use(rehypeStringify, { allowDangerousHtml: true }); let result: string;