refactor(keyword-highlighting): drop the HTML-string path left unused after rebase

This commit is contained in:
2026-08-24 16:56:40 +02:00
parent 27c6e2f9da
commit e5774870df
@@ -83,8 +83,6 @@ export function keywordTooltip(
const WORD_CHAR = '[\\w\\u00C0-\\u024F]';
export const KW_MARK_CLASS = 'kw-mark';
export interface KeywordSegment {
text: string;
match: KeywordColor | null;
@@ -143,29 +141,6 @@ export function splitByKeywords(
return segments;
}
export function highlightKeywords(
text: string,
keywordColors: readonly KeywordColor[],
): string {
return splitByKeywords(text, keywordColors)
.map(({ text: value, match }) => {
if (!match) {
return escapeHtml(value);
}
const tooltip = escapeHtml(
keywordTooltip(match.keyword, match.topicNames),
);
return (
`<mark class="${KW_MARK_CLASS}" style="--t:${match.color}"` +
` data-kw="${escapeHtml(match.keyword)}" title="${tooltip}">` +
`${escapeHtml(value)}</mark>`
);
})
.join('');
}
export interface SnippetSegment {
text: string;
isSearchMatch: boolean;
@@ -227,14 +202,6 @@ export function decodeHtml(text: string): string {
.replace(/&amp;/g, '&');
}
export function escapeHtml(text: string): string {
return text
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
}
function escapeRegex(text: string): string {
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}