diff --git a/packages/rehype/src/core.ts b/packages/rehype/src/core.ts index 15c439b0f..3a838a5dd 100644 --- a/packages/rehype/src/core.ts +++ b/packages/rehype/src/core.ts @@ -6,6 +6,7 @@ import type { Root } from 'hast' import type { Transformer } from 'unified' import type { RehypeShikiHandler } from './handlers' import type { RehypeShikiCoreOptions } from './types' +import { isSpecialLang } from 'shiki/core' import { visit } from 'unist-util-visit' import { InlineCodeHandlers, PreHandler } from './handlers' @@ -92,7 +93,7 @@ function rehypeShikiFromHighlighter( if (!lang) return defaultLanguage - if (highlighter.getLoadedLanguages().includes(lang)) + if (highlighter.getLoadedLanguages().includes(lang) || isSpecialLang(lang)) return lang if (lazy) { diff --git a/packages/rehype/test/fixtures/a.core.out.html b/packages/rehype/test/fixtures/a.core.out.html index d3bde0c59..29dc0724b 100644 --- a/packages/rehype/test/fixtures/a.core.out.html +++ b/packages/rehype/test/fixtures/a.core.out.html @@ -4,4 +4,5 @@
Should fallback to default language
\ No newline at end of file
+Should fallback to default language
+Special languages should be styled
\ No newline at end of file
diff --git a/packages/rehype/test/fixtures/a.md b/packages/rehype/test/fixtures/a.md
index b9894b044..244fc3744 100644
--- a/packages/rehype/test/fixtures/a.md
+++ b/packages/rehype/test/fixtures/a.md
@@ -11,4 +11,8 @@ console.log(a)
```
Should fallback to default language
+```
+
+```plaintext
+Special languages should be styled
```
\ No newline at end of file
diff --git a/packages/rehype/test/fixtures/a.out.html b/packages/rehype/test/fixtures/a.out.html
index 0484fac46..67530087f 100644
--- a/packages/rehype/test/fixtures/a.out.html
+++ b/packages/rehype/test/fixtures/a.out.html
@@ -4,4 +4,5 @@ Should fallback to default language
\ No newline at end of file
+Should fallback to default language
+Special languages should be styled
\ No newline at end of file