|
|
@@ -1,11 +1,11 @@
|
|
|
import type { HighlighterCore, DecorationItem } from "shiki/core";
|
|
|
import { createHighlighterCore } from "shiki/core";
|
|
|
+import { createOnigurumaEngine } from "shiki/engine/oniguruma";
|
|
|
import javascript from "shiki/langs/javascript.mjs";
|
|
|
import json from "shiki/langs/json.mjs";
|
|
|
import solidity from "shiki/langs/solidity.mjs";
|
|
|
import darkPlus from "shiki/themes/dark-plus.mjs";
|
|
|
import lightPlus from "shiki/themes/light-plus.mjs";
|
|
|
-import loadWasm from "shiki/wasm";
|
|
|
|
|
|
import type { SupportedLanguage } from "./supported-language";
|
|
|
|
|
|
@@ -13,7 +13,7 @@ export type Highlighter = {
|
|
|
highlight: (
|
|
|
lang: SupportedLanguage | undefined,
|
|
|
code: string,
|
|
|
- options?: HighlightOptions | undefined,
|
|
|
+ options?: HighlightOptions,
|
|
|
) => string;
|
|
|
};
|
|
|
|
|
|
@@ -22,17 +22,17 @@ export type HighlightOptions = {
|
|
|
};
|
|
|
|
|
|
export const getHighlighter = async (): Promise<Highlighter> => {
|
|
|
- const highlighterCore = await shikiGetHighlighterCore({
|
|
|
+ const highlighterCore = await createHighlighterCore({
|
|
|
langs: [javascript, solidity, json],
|
|
|
themes: [darkPlus, lightPlus],
|
|
|
- loadWasm,
|
|
|
+ engine: createOnigurumaEngine(() => import("shiki/wasm")),
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
highlight: (
|
|
|
lang: SupportedLanguage | undefined,
|
|
|
code: string,
|
|
|
- options?: HighlightOptions | undefined,
|
|
|
+ options?: HighlightOptions,
|
|
|
) => highlight(highlighterCore, lang, code, options),
|
|
|
};
|
|
|
};
|
|
|
@@ -41,7 +41,7 @@ const highlight = (
|
|
|
highlighter: HighlighterCore,
|
|
|
lang: SupportedLanguage | undefined,
|
|
|
code: string,
|
|
|
- options?: HighlightOptions | undefined,
|
|
|
+ options?: HighlightOptions,
|
|
|
) =>
|
|
|
highlighter.codeToHtml(code, {
|
|
|
lang: lang ?? "text",
|