fumadocs-core
Version:
The React.js library for building a documentation website
49 lines • 2.17 kB
TypeScript
import { t as Components } from "./hast-to-jsx-ezp6bh3J.js";
import { ReactNode } from "react";
import { Root } from "hast";
import { BundledLanguage, BundledTheme, CodeOptionsMeta, CodeOptionsThemes, CodeToHastOptionsCommon, LanguageRegistration, ThemeRegistrationAny } from "shiki";
/**
* A syntax highlighter, like Shiki or Highlights.
*/
interface Highlighter {
/** Load languages before highlighting, for highlighters loading them on demand. Unsupported languages are highlighted as plain text. */
loadLanguage?: (...langs: string[]) => Promise<void>;
/** Highlight code into `pre > code > span.line`, with `meta` added to `<pre>`. */
codeToHast: (code: string, options: HighlightCodeOptions) => Root;
}
interface HighlightCodeOptions {
lang: string;
/**
* `inline` renders the content of `<code>` only.
*
* @defaultValue 'classic'
*/
structure?: 'classic' | 'inline';
/** Attributes of the code block, like its title. */
meta?: Record<string, unknown>;
}
type HighlightOptions = HighlightHastOptions & {
components?: Partial<Components>;
};
type HighlightHastOptions = CodeToHastOptionsCommon<BundledLanguage> & CodeOptionsMeta & {
fallbackLanguage?: BundledLanguage | (string & {});
/**
* The Regex Engine for Shiki
*
* @defaultValue 'js'
*/
engine?: 'js' | 'oniguruma';
} & (CodeOptionsThemes<BundledTheme> | Record<never, never>);
declare function highlightHast(code: string, options: HighlightHastOptions): Promise<Root>;
/**
* 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.
*/
declare function getHighlighter(engineType: 'js' | 'oniguruma', options?: {
langs?: (BundledLanguage | LanguageRegistration)[];
themes?: (BundledTheme | ThemeRegistrationAny)[];
}): Promise<import("shiki").HighlighterCore>;
declare function highlight(code: string, options: HighlightOptions): Promise<ReactNode>;
export { getHighlighter as a, Highlighter as i, HighlightHastOptions as n, highlight as o, HighlightOptions as r, highlightHast as s, HighlightCodeOptions as t };