svelte-rune-highlight
Version:
A highlight library for Svelte 5 with Rune
64 lines (63 loc) • 2.11 kB
TypeScript
import type { LanguageFn } from 'highlight.js';
import type { HTMLAttributes } from 'svelte/elements';
import type { Component } from 'svelte';
export declare const SUPPORTED_LANGUAGES: readonly ["md", "ts", "js", "javascript", "json", "yaml", "css"];
export type SupportedLanguage = 'svelte' | (typeof SUPPORTED_LANGUAGES)[number];
export type HighlightLanguage = {
name: string;
register: LanguageFn;
};
export interface HighlightDisplayOptions {
langtag?: boolean;
numberLine?: boolean;
hideBorder?: boolean;
wrapLines?: boolean;
startingLineNumber?: number;
highlightedLines?: number[];
highlightedRanges?: [number, number][];
backgroundColor?: string;
position?: 'static' | 'relative' | 'absolute' | 'sticky' | undefined;
}
export interface LibReplaceOption {
replaceLib?: string | false;
}
export interface ClassOption {
class?: string;
}
export interface ExampleWrapperProps extends HTMLAttributes<HTMLDivElement>, LibReplaceOption {
name?: string;
component?: Component;
code?: string;
components?: Record<string, Component>;
modules?: Record<string, string>;
innerClass?: string;
codeClass?: string;
lang?: SupportedLanguage;
showCopy?: boolean;
class?: string;
}
export interface HighlightProps extends HighlightDisplayOptions, LibReplaceOption, ClassOption {
language: HighlightLanguage;
code: string;
}
export interface HighlightAutoProps extends HighlightDisplayOptions, LibReplaceOption, ClassOption {
code?: string;
languages?: string[];
}
export interface HighlightCompoProps extends HighlightDisplayOptions, LibReplaceOption, ClassOption {
code: string;
contentClass?: string;
lang?: SupportedLanguage;
showCopy?: boolean;
showExpand?: boolean;
}
export interface HighlightSvelteProps extends HighlightDisplayOptions, LibReplaceOption, ClassOption {
code?: string;
}
export interface LangTagProps extends HTMLAttributes<HTMLPreElement> {
code?: string;
highlighted?: string;
languageName?: string;
langtag?: boolean;
codeClass?: string;
}