MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / getHighlighter

Function getHighlighter

docs/components/shiki.js:8–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6
7let hlPromise = null
8function getHighlighter() {
9 if (!hlPromise) {
10 // Core + JS RegExp engine instead of the `shiki` bundle: skips the multi-MB Oniguruma WASM engine and every other grammar/theme, shipping only python + the two themes we render. This is the dominant payload of the first Run.
11 // Import via shiki's public re-exports, not @shikijs/* transitive deps that break under strict installs.
12 hlPromise = Promise.all([
13 import('shiki/core'),
14 import('shiki/engine/javascript'),
15 ]).then(([{ createHighlighterCore }, { createJavaScriptRegexEngine }]) =>
16 createHighlighterCore({
17 themes: [import('shiki/themes/github-light.mjs'), import('shiki/themes/github-dark.mjs')],
18 langs: [import('shiki/langs/python.mjs')],
19 // forgiving: skip untranslatable grammar patterns instead of throwing and killing the highlighter.
20 engine: createJavaScriptRegexEngine({ forgiving: true }),
21 }),
22 )
23 }
24 return hlPromise
25}
26
27const isDark = () =>
28 typeof document !== 'undefined' && document.documentElement.classList.contains('dark')

Callers 1

createHighlightFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected