UNPKG

@mantine/code-highlight

Version:

Code highlight with Mantine theme

33 lines (32 loc) 1.26 kB
interface HighlighterInput { colorScheme: 'light' | 'dark'; code: string; language?: string; } type Highlighter = (input: HighlighterInput) => { /** Highlighted code (html markup) */ highlightedCode: string; /** `true` if the code is represented with html string, `false` for plain text string */ isHighlighted: boolean; /** Props to pass down to `<code>` tag */ codeElementProps?: Record<string, any>; }; export interface CodeHighlightAdapter { loadContext?: () => Promise<any>; getHighlighter: (ctx: any) => Highlighter; } interface CodeHighlightProviderContext { adapter: CodeHighlightAdapter; highlight: Highlighter; } export declare const CodeHighlightProvider: ({ children, value }: { value: CodeHighlightProviderContext; children: React.ReactNode; }) => import("react/jsx-runtime").JSX.Element, useCodeHighlight: () => CodeHighlightProviderContext | null; export interface CodeHighlightAdapterProviderProps { adapter: CodeHighlightAdapter; children: React.ReactNode; } export declare function CodeHighlightAdapterProvider({ adapter, children, }: CodeHighlightAdapterProviderProps): import("react/jsx-runtime").JSX.Element; export declare function useHighlight(): Highlighter; export {};