mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
fix: use Shiki's isSpecialLang
to allow ansi
codeblocks (#10540)
* fix: use `isSpecialLang` instead of hardcode Hardcoding this value makes it impossible to use Shiki's `ansi` feature * Add changeset
This commit is contained in:
parent
1cd2a74022
commit
c585528f44
2 changed files with 8 additions and 2 deletions
6
.changeset/eighty-pumpkins-float.md
Normal file
6
.changeset/eighty-pumpkins-float.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
"@astrojs/markdown-remark": patch
|
||||
---
|
||||
|
||||
This patch allows Shiki to use all of its reserved languages instead of the
|
||||
previous behavior of forcing unknown languages to plaintext.
|
|
@ -1,5 +1,5 @@
|
|||
import type { Properties } from 'hast';
|
||||
import { bundledLanguages, createCssVariablesTheme, getHighlighter } from 'shiki';
|
||||
import { bundledLanguages, createCssVariablesTheme, getHighlighter, isSpecialLang } from 'shiki';
|
||||
import { visit } from 'unist-util-visit';
|
||||
import type { ShikiConfig } from './types.js';
|
||||
|
||||
|
@ -51,7 +51,7 @@ export async function createShikiHighlighter({
|
|||
|
||||
return {
|
||||
highlight(code, lang = 'plaintext', options) {
|
||||
if (lang !== 'plaintext' && !loadedLanguages.includes(lang)) {
|
||||
if (!isSpecialLang(lang) && !loadedLanguages.includes(lang)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`[Shiki] The language "${lang}" doesn't exist, falling back to "plaintext".`);
|
||||
lang = 'plaintext';
|
||||
|
|
Loading…
Add table
Reference in a new issue