UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

45 lines 1.88 kB
/** * Strip HTML tags from a string * SSR-safe: uses DOMParser in browser, iterative fallback on server * * @param html - String that may contain HTML tags * @returns String with HTML tags removed * * @example * stripHtmlTags('<p>Hello <strong>World</strong></p>') // 'Hello World' * stripHtmlTags('No tags here') // 'No tags here' */ export declare function stripHtmlTags(html: string): string; /** * Normalize a string for case- and accent-insensitive comparison. * Decomposes characters via NFD, strips diacritic marks, then lowercases. * * @param value - The string to normalize * @returns Normalized string suitable for comparison * * @example * normalizeText('Matemática') // 'matematica' * normalizeText('Ação') // 'acao' */ export declare function normalizeText(value: string): string; /** * Wrap every occurrence of a search term in a highlight `<span>` inside an HTML string. * * Traverses only text nodes so HTML tags, attributes, and entities are never touched. * Matching is case-insensitive and regex special characters in the term are escaped. * SSR-safe: returns the original HTML unchanged when running outside a browser context. * * @param html - The HTML string to annotate (e.g. a question statement) * @param term - The search term to highlight * @returns HTML string with match occurrences wrapped in highlight spans, * or the original string when `term`/`html` is empty or in an SSR environment * * @example * highlightSearchTerm('<p>Hello World</p>', 'world') * // '<p>Hello <span style="color:#2883D7;font-weight:600">World</span></p>' * * highlightSearchTerm('<span class="katex">math</span>', 'katex') * // '<span class="katex">math</span>' ← tag/attribute left intact */ export declare function highlightSearchTerm(html: string, term: string): string; //# sourceMappingURL=stringUtils.d.ts.map