Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev authored and astrobot-houston committed Jul 21, 2022
1 parent 399d7e2 commit 476766b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
14 changes: 8 additions & 6 deletions packages/astro/src/vite-plugin-markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,21 @@ 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();

// Wrap with set:html fragment to skip
// JSX expressions and components in "plain" md mode
if (!isMDX) {
astroResult = `<Fragment set:html={${JSON.stringify(astroResult)}} />`
astroResult = `<Fragment set:html={${JSON.stringify(astroResult)}} />`;
}

// If the user imported "Layout", wrap the content in a Layout
Expand Down
30 changes: 15 additions & 15 deletions packages/markdown/remark/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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',
]
: [],
},
],
]);
Expand All @@ -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;
Expand Down

0 comments on commit 476766b

Please sign in to comment.