site/node_modules/rehype-pretty-code/dist/index.d.ts

39 lines
1.4 KiB
TypeScript
Raw Permalink Normal View History

2024-10-14 06:09:33 +00:00
import { Element, Properties, Text, Root } from 'hast';
import { BuiltinTheme, ThemeRegistrationRaw, ShikiTransformer, BundledHighlighterOptions, Highlighter } from 'shiki';
import { Transformer } from 'unified';
type LineElement = Omit<Element, 'properties'> & {
properties: Properties & {
className?: string[];
};
};
type CharsElement = Omit<Element, 'properties' | 'children'> & {
properties: Properties & {
className?: string[];
};
children: Array<Element | Text>;
};
type Theme = BuiltinTheme | ThemeRegistrationRaw;
interface Options {
grid?: boolean;
theme?: Theme | Record<string, Theme>;
keepBackground?: boolean;
defaultLang?: string | {
block?: string;
inline?: string;
};
tokensMap?: Record<string, string>;
transformers?: ShikiTransformer[];
filterMetaString?(str: string): string;
getHighlighter?(options: BundledHighlighterOptions<any, any>): Promise<Highlighter>;
onVisitLine?(element: LineElement): void;
onVisitHighlightedLine?(element: LineElement, id: string | undefined): void;
onVisitHighlightedChars?(element: CharsElement, id: string | undefined): void;
onVisitTitle?(element: Element): void;
onVisitCaption?(element: Element): void;
}
declare function rehypePrettyCode(options?: Options): void | Transformer<Root, Root>;
export { type CharsElement, type LineElement, type Options, type Theme, rehypePrettyCode as default };