Skip to content

Commit 78775b6

Browse files
fix: Search plugin: matched text is replaced with search text (#1298)
* Fix search plugin will replace matching text * Fix bug that will replace a unexpected text * Fix bug that will replace a unexpected text * Optimized Co-authored-by: 沈唁 <[email protected]>
1 parent 9f4f79e commit 78775b6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: src/plugins/search/search.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ export function search(query) {
170170
'...' +
171171
escapeHtml(postContent)
172172
.substring(start, end)
173-
.replace(regEx, `<em class="search-keyword">${keyword}</em>`) +
173+
.replace(
174+
regEx,
175+
word => `<em class="search-keyword">${word}</em>`
176+
) +
174177
'...';
175178

176179
resultStr += matchContent;

0 commit comments

Comments
 (0)