diff --git a/bun.lockb b/bun.lockb index 3d289a09a..0907f2309 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 660278c26..e4d295fd1 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "remark-rehype": "^11.1.0", "rison": "^0.1.1", "server-only": "^0.0.1", - "shikiji": "^0.8.0", + "shiki": "^1.2.0", "swagger2openapi": "^7.0.8", "tailwind-merge": "^2.2.0", "tailwind-shades": "^1.1.2", diff --git a/src/components/DocumentView/CodeBlock/CodeBlock.tsx b/src/components/DocumentView/CodeBlock/CodeBlock.tsx index be7156509..95ad716b6 100644 --- a/src/components/DocumentView/CodeBlock/CodeBlock.tsx +++ b/src/components/DocumentView/CodeBlock/CodeBlock.tsx @@ -283,5 +283,5 @@ function CodeHighlightToken(props: { return <>{token.token.content}; } - return {token.token.content}; + return {token.token.content}; } diff --git a/src/components/DocumentView/CodeBlock/highlight.ts b/src/components/DocumentView/CodeBlock/highlight.ts index 67694f45b..9bbd78114 100644 --- a/src/components/DocumentView/CodeBlock/highlight.ts +++ b/src/components/DocumentView/CodeBlock/highlight.ts @@ -1,7 +1,13 @@ import { DocumentBlockCode, DocumentBlockCodeLine, DocumentInlineAnnotation } from '@gitbook/api'; -import { getHighlighter, loadWasm, bundledLanguages, Highlighter, ThemedToken } from 'shikiji'; +import { + loadWasm, + bundledLanguages, + ThemedToken, + getHighlighter, + createCssVariablesTheme, +} from 'shiki'; // @ts-ignore - onigWasm is a Wasm module -import onigWasm from 'shikiji/onig.wasm?module'; +import onigWasm from 'shiki/onig.wasm?module'; import { singleton } from '@/lib/async'; import { getNodeText } from '@/lib/document'; @@ -55,11 +61,10 @@ export async function highlight(block: DocumentBlockCode): Promise { // Otherwise for Vercel/Cloudflare, we need to load it ourselves. await loadWasm((obj) => WebAssembly.instantiate(onigWasm, obj)); } - const instance = await getHighlighter(); - await instance.loadTheme('css-variables'); - return instance; + const highlighter = await getHighlighter({ + themes: [createCssVariablesTheme()], + langs: [], + }); + return highlighter; });