diff --git a/.changeset/pretty-rice-heal.md b/.changeset/pretty-rice-heal.md new file mode 100644 index 00000000..98a63382 --- /dev/null +++ b/.changeset/pretty-rice-heal.md @@ -0,0 +1,5 @@ +--- +"vocs": patch +--- + +Fixed inline code highlighter. diff --git a/src/vite/plugins/rehype/inline-shiki.ts b/src/vite/plugins/rehype/inline-shiki.ts index 6955b0cd..067497d8 100644 --- a/src/vite/plugins/rehype/inline-shiki.ts +++ b/src/vite/plugins/rehype/inline-shiki.ts @@ -1,7 +1,13 @@ import type { RehypeShikiCoreOptions } from '@shikijs/rehype/core' import type { Root } from 'hast' -import type { BuiltinLanguage, BuiltinTheme, Highlighter } from 'shiki' -import { bundledLanguages, createHighlighter } from 'shiki' +import type { + BuiltinLanguage, + BuiltinTheme, + BundledLanguage, + BundledTheme, + HighlighterGeneric, +} from 'shiki' +import { bundledLanguages, getSingletonHighlighter } from 'shiki' import type { LanguageInput } from 'shiki/core' import type { Plugin } from 'unified' import { visit } from 'unist-util-visit' @@ -17,7 +23,7 @@ export type RehypeInlineShikiOptions = RehypeShikiCoreOptions & { langs?: Array } -let promise: Promise +let promise: Promise> export const rehypeInlineShiki: Plugin<[RehypeInlineShikiOptions], Root> = function ( options = {} as any, @@ -29,7 +35,7 @@ export const rehypeInlineShiki: Plugin<[RehypeInlineShikiOptions], Root> = funct return async function (tree) { if (!promise) - promise = createHighlighter({ + promise = getSingletonHighlighter({ themes: themeNames, langs, })