mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
[MDX] Syntax highlighting after user plugins (#6050)
* fix: load MDX syntax highlighting after user plugins * chore: changeset
This commit is contained in:
parent
474ecc7be6
commit
2ab32b59ef
2 changed files with 14 additions and 6 deletions
5
.changeset/orange-carpets-greet.md
Normal file
5
.changeset/orange-carpets-greet.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@astrojs/mdx': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix: load syntax highlighters after MDX remark plugins. This keeps MDX consistent with Astro's markdown behavior.
|
|
@ -129,12 +129,7 @@ export async function getRemarkPlugins(
|
||||||
config: AstroConfig
|
config: AstroConfig
|
||||||
): Promise<MdxRollupPluginOptions['remarkPlugins']> {
|
): Promise<MdxRollupPluginOptions['remarkPlugins']> {
|
||||||
let remarkPlugins: PluggableList = [];
|
let remarkPlugins: PluggableList = [];
|
||||||
if (mdxOptions.syntaxHighlight === 'shiki') {
|
|
||||||
remarkPlugins.push([await remarkShiki(mdxOptions.shikiConfig)]);
|
|
||||||
}
|
|
||||||
if (mdxOptions.syntaxHighlight === 'prism') {
|
|
||||||
remarkPlugins.push(remarkPrism);
|
|
||||||
}
|
|
||||||
if (mdxOptions.gfm) {
|
if (mdxOptions.gfm) {
|
||||||
remarkPlugins.push(remarkGfm);
|
remarkPlugins.push(remarkGfm);
|
||||||
}
|
}
|
||||||
|
@ -144,6 +139,14 @@ export async function getRemarkPlugins(
|
||||||
|
|
||||||
remarkPlugins = [...remarkPlugins, ...ignoreStringPlugins(mdxOptions.remarkPlugins)];
|
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
|
// Apply last in case user plugins resolve relative image paths
|
||||||
remarkPlugins.push(toRemarkContentRelImageError(config));
|
remarkPlugins.push(toRemarkContentRelImageError(config));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue