diff options
author | 2025-03-12 21:58:33 +0800 | |
---|---|---|
committer | 2025-03-12 13:58:33 +0000 | |
commit | a3327ffbe6373228339824684eaa6f340a20a32e (patch) | |
tree | ba7f6f83ece1b2abff967ce42583f8f5ba41438d /packages/integrations | |
parent | 4e78b4d10d2214c94752a1fef74db325053cf071 (diff) | |
download | astro-a3327ffbe6373228339824684eaa6f340a20a32e.tar.gz astro-a3327ffbe6373228339824684eaa6f340a20a32e.tar.zst astro-a3327ffbe6373228339824684eaa6f340a20a32e.zip |
feat(markdown): add `excludeLangs` configuration to syntax highlighting (#13311)
* demonstrative implementation of excludeLangs
* add tests
* add changset
* clean up exclude languages into a const
* update changeset to include astro minor
* update jsdoc
* first cut in moving the config into markdown settings
* format code
* update test
* update changset
* remove old incorrect doc change
* make test stronger yet simplifying it
* refactor tests
* refactor logic for readability
* add syntax highlight defaults
* improve changset doc
* add more documentation
* add more defaults to each part of schema
* attempt to fix js doc parsing
* attempt to fix test
* Extremely draft syntax of what docs should look like!
* Update .changeset/large-dolphins-roll.md
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
* one pass on the documentation
* remove unused import
* gentle change
* use different approach
---------
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Diffstat (limited to 'packages/integrations')
-rw-r--r-- | packages/integrations/mdx/src/plugins.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/packages/integrations/mdx/src/plugins.ts b/packages/integrations/mdx/src/plugins.ts index 77c76243c..e1640238f 100644 --- a/packages/integrations/mdx/src/plugins.ts +++ b/packages/integrations/mdx/src/plugins.ts @@ -65,12 +65,17 @@ function getRehypePlugins(mdxOptions: MdxOptions): PluggableList { [rehypeRaw, { passThrough: nodeTypes }], ]; - if (!isPerformanceBenchmark) { + const syntaxHighlight = mdxOptions.syntaxHighlight; + if (syntaxHighlight && !isPerformanceBenchmark) { + const syntaxHighlightType = + typeof syntaxHighlight === 'string' ? syntaxHighlight : syntaxHighlight?.type; + const excludeLangs = + typeof syntaxHighlight === 'object' ? syntaxHighlight?.excludeLangs : undefined; // Apply syntax highlighters after user plugins to match `markdown/remark` behavior - if (mdxOptions.syntaxHighlight === 'shiki') { - rehypePlugins.push([rehypeShiki, mdxOptions.shikiConfig]); - } else if (mdxOptions.syntaxHighlight === 'prism') { - rehypePlugins.push(rehypePrism); + if (syntaxHighlightType === 'shiki') { + rehypePlugins.push([rehypeShiki, mdxOptions.shikiConfig, excludeLangs]); + } else if (syntaxHighlightType === 'prism') { + rehypePlugins.push([rehypePrism, excludeLangs]); } } |