Skip to content

Commit

Permalink
fix: load MDX syntax highlighting after user plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Jan 30, 2023
1 parent 43ec7f3 commit d48971f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/integrations/mdx/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,7 @@ export async function getRemarkPlugins(
config: AstroConfig
): Promise<MdxRollupPluginOptions['remarkPlugins']> {
let remarkPlugins: PluggableList = [];
if (mdxOptions.syntaxHighlight === 'shiki') {
remarkPlugins.push([await remarkShiki(mdxOptions.shikiConfig)]);
}
if (mdxOptions.syntaxHighlight === 'prism') {
remarkPlugins.push(remarkPrism);
}

if (mdxOptions.gfm) {
remarkPlugins.push(remarkGfm);
}
Expand All @@ -144,6 +139,14 @@ export async function getRemarkPlugins(

remarkPlugins = [...remarkPlugins, ...ignoreStringPlugins(mdxOptions.remarkPlugins)];

// Apply syntax highlighters after user plugins to match `markdown/remark` behavior
if (mdxOptions.syntaxHighlight === 'shiki') {
remarkPlugins.push([await remarkShiki(mdxOptions.shikiConfig)]);
}
if (mdxOptions.syntaxHighlight === 'prism') {
remarkPlugins.push(remarkPrism);
}

// Apply last in case user plugins resolve relative image paths
remarkPlugins.push(toRemarkContentRelImageError(config));

Expand Down

0 comments on commit d48971f

Please sign in to comment.