diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js index 66a3ca911..ca2c9f178 100644 --- a/src/services/search/services/search.js +++ b/src/services/search/services/search.js @@ -123,6 +123,7 @@ function highlightSearchResults(searchResults, highlightedTokens) { // we remove < signs because they can cause trouble in matching and overwriting existing highlighted chunks // which would make the resulting HTML string invalid. // { and } are used for marking and tag (to avoid matches on single 'b' character) + // < and > are used for marking and highlightedTokens = highlightedTokens.map(token => token.replace('/[<\{\}]/g', '')); // sort by the longest so we first highlight longest matches @@ -131,19 +132,19 @@ function highlightSearchResults(searchResults, highlightedTokens) { for (const result of searchResults) { const note = noteCache.notes[result.noteId]; - result.highlightedNotePathTitle = result.notePathTitle; + result.highlightedNotePathTitle = result.notePathTitle.replace('/[<\{\}]/g', ''); if (highlightedTokens.find(token => note.type.includes(token))) { - result.highlightedNotePathTitle += ` type: ${note.type}`; + result.highlightedNotePathTitle += ` `; } if (highlightedTokens.find(token => note.mime.includes(token))) { - result.highlightedNotePathTitle += ` mime: ${note.mime}`; + result.highlightedNotePathTitle += ` `; } for (const attr of note.attributes) { if (highlightedTokens.find(token => attr.name.includes(token) || attr.value.includes(token))) { - result.highlightedNotePathTitle += ` ${formatAttribute(attr)}`; + result.highlightedNotePathTitle += ` <${formatAttribute(attr)}>`; } } } @@ -158,6 +159,8 @@ function highlightSearchResults(searchResults, highlightedTokens) { for (const result of searchResults) { result.highlightedNotePathTitle = result.highlightedNotePathTitle + .replace(/") + .replace(/>/g, "") .replace(/{/g, "") .replace(/}/g, ""); }