UNPKG

svelte-highlight

Version:

Svelte component library for highlighting code using highlight.js

52 lines (45 loc) 1.24 kB
import type { SvelteComponentTyped } from "svelte"; import type { HTMLAttributes } from "svelte/elements"; import type { LangtagProps } from "./Highlight.svelte"; import type { LanguageName } from "./languages"; export type HighlightAutoProps = HTMLAttributes<HTMLPreElement> & LangtagProps & { /** * Specify the text to highlight. */ code: any; /** * Specify a subset of language names to restrict language auto-detection to. * This can improve performance and accuracy. * @example ["javascript", "typescript"] */ languageNames?: (LanguageName | (string & {}))[]; }; export type HighlightAutoEvents = { highlight: CustomEvent<{ /** * The highlighted HTML as a string. * @example "<span>...</span>" */ highlighted: string; /** * The language name inferred by `highlight.js`. * @example "css" */ language: string; }>; }; export type HighlightAutoSlots = { default: { /** * The highlighted HTML as a string. * @example "<span>...</span>" */ highlighted: string; }; }; export default class HighlightAuto extends SvelteComponentTyped< HighlightAutoProps, HighlightAutoEvents, HighlightAutoSlots > {}