-
-
Notifications
You must be signed in to change notification settings - Fork 493
Open
Description
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Describe the bug
Initially reported here, https://bsky.app/profile/nullvoxpopuli.com/post/3ls7ipbjtzk27, which, I admit is not the best place for bug reports 🙈
Here is what I'm experiencing:
which, could be due to whatever default set of embedded languages are configured for markdown.
Here is the code I'm using
import type { HighlighterGeneric } from 'shiki';
let HIGHLIGHT: HighlighterGeneric<never, never>;
let promise: Promise<HighlighterGeneric<never, never>>;
export async function getHighlighter(): Promise<HighlighterGeneric<never, never>> {
if (promise) {
await promise;
}
if (HIGHLIGHT) return HIGHLIGHT;
const [{ createHighlighterCore }, { createOnigurumaEngine }, wasm, markdown, dark, oneDarkPro] =
await Promise.all([
import('shiki/core'),
import('shiki/engine/oniguruma'),
import('shiki/wasm'),
import('shiki/langs/markdown.mjs'),
import('shiki/themes/github-dark.mjs'),
import('shiki/themes/one-dark-pro.mjs'),
]);
promise = createHighlighterCore({
themes: [
{
...dark.default,
colors: {
...dark.default.colors,
'editor.background': 'var(--code-bg)',
},
},
{
...oneDarkPro.default,
colors: {
...oneDarkPro.default.colors,
'editor.background': 'var(--code-bg)',
},
},
// import('shiki/themes/github-light.mjs'),
],
langs: [
import('shiki/langs/javascript.mjs'),
import('shiki/langs/css.mjs'),
import('shiki/langs/html.mjs'),
import('shiki/langs/glimmer-js.mjs'),
import('shiki/langs/handlebars.mjs'),
import('shiki/langs/jsonc.mjs'),
import('shiki/langs/svelte.mjs'),
{
...markdown.default[0]!,
embeddedLangs: [
'javascript',
'css',
'html',
'glimmer-js',
'handlebars',
'jsonc',
'svelte',
'vue',
'jsx',
'mermaid',
],
},
import('shiki/langs/vue.mjs'),
import('shiki/langs/jsx.mjs'),
import('shiki/langs/mermaid.mjs'),
],
langAlias: {
gjs: 'glimmer-js',
gts: 'glimmer-ts',
glimdown: 'markdown',
gmd: 'markdown',
gdm: 'markdown',
json: 'jsonc',
},
engine: createOnigurumaEngine(() => wasm),
});
const highlighter = await promise;
HIGHLIGHT = highlighter;
return highlighter;
}Reproduction
https://stackblitz.com/edit/vitejs-vite-oxjywzwm?file=src%2Fmain.js
Contributes
- I am willing to submit a PR to fix this issue
- I am willing to submit a PR with failing tests
Metadata
Metadata
Assignees
Labels
No labels
