✨ Enhance search highlighting by replacing regex usage with replaceAll for improved readability and consistency
This commit is contained in:
@@ -411,11 +411,9 @@ function getHighlightedContent(lineContent) {
|
||||
if (!searchQuery.value.trim()) return lineContent;
|
||||
|
||||
const searchTerm = searchQuery.value;
|
||||
const regex = new RegExp(
|
||||
`(${searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`,
|
||||
'gi'
|
||||
);
|
||||
return lineContent.replace(regex, '<mark>$1</mark>');
|
||||
const escapedTerm = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
|
||||
const regex = new RegExp(`(${escapedTerm})`, 'gi');
|
||||
return lineContent.replaceAll(regex, '<mark>$1</mark>');
|
||||
}
|
||||
|
||||
// URL state sync
|
||||
|
||||
Reference in New Issue
Block a user