mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-12-02 12:10:04 +08:00
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: 沈唁 <52o@qq52o.cn>
This commit is contained in:
parent
9f4f79e0f7
commit
78775b6ee7
@ -170,7 +170,10 @@ export function search(query) {
|
||||
'...' +
|
||||
escapeHtml(postContent)
|
||||
.substring(start, end)
|
||||
.replace(regEx, `<em class="search-keyword">${keyword}</em>`) +
|
||||
.replace(
|
||||
regEx,
|
||||
word => `<em class="search-keyword">${word}</em>`
|
||||
) +
|
||||
'...';
|
||||
|
||||
resultStr += matchContent;
|
||||
|
Loading…
Reference in New Issue
Block a user