diff --git a/packages/shiki/src/highlighter.ts b/packages/shiki/src/highlighter.ts index 73b5258f2..b93919408 100644 --- a/packages/shiki/src/highlighter.ts +++ b/packages/shiki/src/highlighter.ts @@ -64,7 +64,7 @@ export async function getHighlighter(options: HighlighterOptions): Promise = { + let COLOR_REPLACEMENTS: Record = { '#000001': 'var(--shiki-color-text)', '#000002': 'var(--shiki-color-background)', '#000004': 'var(--shiki-token-constant)', @@ -77,7 +77,9 @@ export async function getHighlighter(options: HighlighterOptions): Promise) { + COLOR_REPLACEMENTS = map + } function fixCssVariablesTheme(theme: IShikiTheme, colorMap: string[]) { theme.bg = COLOR_REPLACEMENTS[theme.bg] || theme.bg theme.fg = COLOR_REPLACEMENTS[theme.fg] || theme.fg @@ -96,7 +98,7 @@ export async function getHighlighter(options: HighlighterOptions): Promise): string + setColorReplacements(map: Record): void + // codeToRawHtml?(code: string): string // getRawCSS?(): string @@ -147,7 +149,7 @@ export interface IShikiTheme extends IRawTheme { /** * @description light/dark theme */ - type: 'light' | 'dark' + type: 'light' | 'dark' | 'css' /** * @description tokenColors of the theme file diff --git a/packages/shiki/themes/css-variables.json b/packages/shiki/themes/css-variables.json index d46297a38..b6ba2a308 100644 --- a/packages/shiki/themes/css-variables.json +++ b/packages/shiki/themes/css-variables.json @@ -1,6 +1,6 @@ { "name": "css-variables", - "type": "light", + "type": "css", "colors": { "editor.foreground": "#000001", "editor.background": "#000002"