spotmark
Version:
A lightweight, customizable text highlighting library that illuminates matches in a content.
28 lines (25 loc) • 1.01 kB
text/typescript
/**
* Options for configuring text highlighting behavior
*/
interface HighlightOptions {
/** Whether the search should be case sensitive */
readonly caseSensitive: boolean;
/** CSS class name to apply to highlighted text */
readonly className: string;
/** Whether to match diacritics (accented characters) */
readonly diacritics: boolean;
/** Whether to ignore punctuation when matching */
readonly ignorePunctuation: boolean;
/** Whether to match all occurrences or just the first one */
readonly matchAll: boolean;
/** Whether to match separate words of the query */
readonly separateWordSearch: boolean;
/** HTML tag to wrap highlighted text (e.g., 'span', 'mark') */
readonly tag: string;
}
/**
* The highlighter function
*/
type Highlighter = (text: string, query: string) => string;
declare const createHighlighter: (config?: Partial<HighlightOptions>) => Highlighter;
export { type HighlightOptions, type Highlighter, createHighlighter };