67 lines
2.3 KiB
TypeScript
67 lines
2.3 KiB
TypeScript
import { BuiltinTheme, Highlighter as Highlighter$1, ShikiTransformer, HighlighterCore } from 'shiki';
|
|
import { Processor } from 'unified';
|
|
import { ElementContent } from 'hast';
|
|
|
|
type MdcThemeOptions = BuiltinTheme | string | Record<string, BuiltinTheme | string>;
|
|
interface HighlighterOptions {
|
|
highlights?: number[];
|
|
meta?: string;
|
|
}
|
|
interface HighlightResult {
|
|
tree: ElementContent[];
|
|
className?: string;
|
|
style?: string;
|
|
inlineStyle?: string;
|
|
}
|
|
type Highlighter = (code: string, lang: string, theme: MdcThemeOptions, options: Partial<HighlighterOptions>) => Promise<HighlightResult>;
|
|
interface RehypeHighlightOption {
|
|
theme?: MdcThemeOptions;
|
|
highlighter?: Highlighter;
|
|
}
|
|
|
|
type Awaitable<T> = T | Promise<T>;
|
|
interface MdcConfig {
|
|
/**
|
|
* Hooks for the unified markdown pipeline
|
|
*/
|
|
unified?: {
|
|
/**
|
|
* Custom setup for unified processor before other plugins
|
|
*/
|
|
pre?: (processor: Processor) => Awaitable<void | Processor>;
|
|
/**
|
|
* Custom setup for unified processor after remark but before rehype
|
|
*/
|
|
remark?: (processor: Processor) => Awaitable<void | Processor>;
|
|
/**
|
|
* Custom setup for unified processor after rehype
|
|
*/
|
|
rehype?: (processor: Processor) => Awaitable<void | Processor>;
|
|
/**
|
|
* Custom setup for unified processor after all plugins
|
|
*/
|
|
post?: (processor: Processor) => Awaitable<void | Processor>;
|
|
};
|
|
/**
|
|
* Custom hightlighter, available when `highlighter` is set to `custom`
|
|
*/
|
|
highlighter?: Highlighter$1;
|
|
/**
|
|
* Hooks for shiki
|
|
*/
|
|
shiki?: {
|
|
/**
|
|
* Get transformers for shiki
|
|
*/
|
|
transformers?: ShikiTransformer[] | ((code: string, lang: string, theme: MdcThemeOptions, options: Partial<HighlighterOptions>) => Awaitable<ShikiTransformer[]>);
|
|
/**
|
|
* Custom setup for shiki instance, only called once on server or client
|
|
*/
|
|
setup?: (highlighter: HighlighterCore) => Awaitable<void>;
|
|
};
|
|
}
|
|
|
|
declare function defineConfig(config: MdcConfig): MdcConfig;
|
|
|
|
export { type Awaitable as A, type HighlighterOptions as H, type MdcConfig as M, type RehypeHighlightOption as R, type MdcThemeOptions as a, type HighlightResult as b, type Highlighter as c, defineConfig as d };
|