ITADN

[v4] `codeToHast` with multiple `themes` throws "Language `ansi` not found"

#1257Opendan-lee 创建于 2026-03-05
D
dan-leecommented
### Validations - [x] Follow our [Code of Conduct](https://github.com/shikijs/shiki/blob/main/CODE_OF_CONDUCT.md) - [x] Read the [Contributing Guide](https://github.com/shikijs/shiki/blob/main/CONTRIBUTING.md). - [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. ### Describe the bug Since the latest v4 using `codeToHast` with `lang: "ansi"` and the multiple `themes` throws `Language 'ansi' not found, you may need to load it first`. This worked in v3. Using a single `theme` instead of `themes` still works correctly. Here's a minimal reproduction on StackBlitz: https://stackblitz.com/edit/stackblitz-starters-elc9xxmf ### Reproduction ```ts import { getSingletonHighlighterCore } from "shiki/core"; import { createJavaScriptRegexEngine } from "shiki/engine/javascript"; const highlighter = await getSingletonHighlighterCore({ engine: createJavaScriptRegexEngine(), }); await highlighter.loadTheme( import("@shikijs/themes/github-dark"), import("@shikijs/themes/github-light") ); highlighter.codeToHast("\x1b[32mhello\x1b[0m", { lang: "ansi", themes: { light: "github-light", dark: "github-dark" }, }); ``` ### Contributes - [x] I am willing to submit a PR to fix this issue - [ ] I am willing to submit a PR with failing tests
0 条评论