UNPKG

fumadocs-core

Version:

The React.js library for building a documentation website

24 lines (23 loc) • 1.23 kB
import { defaultShikiFactory, wasmShikiFactory } from "./shiki/full.js"; import { toJsx } from "../utils/hast-to-jsx.js"; import { i as applyDefaultThemes, o as loadMissingLanguage, r as highlightHast$1, s as loadMissingTheme } from "../shiki-DL5DIaX-.js"; // src/highlight/index.ts async function highlightHast(code, options) { const instance = await ((options.engine ?? "js") === "js" ? defaultShikiFactory : wasmShikiFactory).getOrInit(); return highlightHast$1(instance, code, applyDefaultThemes(options)); } /** * Get Shiki highlighter instance of Fumadocs (mostly for internal use, you should use Shiki directly over this). * * @param engineType - Shiki Regex engine to use. * @param options - Shiki options. */ async function getHighlighter(engineType, options = {}) { const instance = await (engineType === "js" ? defaultShikiFactory : wasmShikiFactory).getOrInit(); await Promise.all([options.langs && loadMissingLanguage(instance, options.langs), options.themes && loadMissingTheme(instance, options.themes)]); return instance; } async function highlight(code, options) { return toJsx(await highlightHast(code, options), { components: options.components }); } export { getHighlighter, highlight, highlightHast };