mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 10:03:31 +00:00
Fix code highlighting in Cloudflare (#27)
* Try calling WebAssembly.instantiate directly * Load from shikiji/onig.wasm instead
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { DocumentBlockCode, DocumentBlockCodeLine, DocumentInlineAnnotation } from '@gitbook/api';
|
||||
import { getHighlighter, loadWasm, bundledLanguages, Highlighter, ThemedToken } from 'shikiji';
|
||||
// @ts-ignore - onigWasm is a Wasm module
|
||||
import onigWasm from 'vscode-oniguruma/release/onig.wasm?module';
|
||||
import onigWasm from 'shikiji/onig.wasm?module';
|
||||
|
||||
import { getNodeText } from '@/lib/document';
|
||||
|
||||
@@ -301,7 +301,7 @@ async function loadHighlighter() {
|
||||
// loads it on its own.
|
||||
//
|
||||
// Otherwise for Vercel/Cloudflare, we need to load it ourselves.
|
||||
await loadWasm(onigWasm);
|
||||
await loadWasm(obj => WebAssembly.instantiate(onigWasm, obj))
|
||||
}
|
||||
const instance = await getHighlighter();
|
||||
await instance.loadTheme('css-variables');
|
||||
|
||||
Reference in New Issue
Block a user