mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 01:20:12 +01:00
🎨 搜索结果高亮支持大部分行级元素 https://github.com/siyuan-note/siyuan/issues/6745
This commit is contained in:
parent
92b88154fb
commit
7c40b44a15
9 changed files with 35 additions and 17 deletions
|
|
@ -31,7 +31,6 @@ import (
|
|||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/html"
|
||||
"github.com/88250/lute/lex"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/jinzhu/copier"
|
||||
|
|
@ -228,7 +227,7 @@ func FindReplace(keyword, replacement string, ids []string, method int) (err err
|
|||
}
|
||||
case ast.NodeTextMark:
|
||||
if n.IsTextMarkType("code") {
|
||||
escapedKey := html.EscapeString(keyword)
|
||||
escapedKey := util.EscapeHTML(keyword)
|
||||
if 0 == method {
|
||||
if strings.Contains(n.TextMarkTextContent, escapedKey) {
|
||||
n.TextMarkTextContent = strings.ReplaceAll(n.TextMarkTextContent, escapedKey, replacement)
|
||||
|
|
@ -692,7 +691,7 @@ func markSearch(text string, keyword string, beforeLen int) (marked string, scor
|
|||
marked = text
|
||||
|
||||
if strings.Contains(marked, search.SearchMarkLeft) { // 使用 FTS snippet() 处理过高亮片段,这里简单替换后就返回
|
||||
marked = html.EscapeString(text)
|
||||
marked = util.EscapeHTML(text)
|
||||
marked = strings.ReplaceAll(marked, search.SearchMarkLeft, "<mark>")
|
||||
marked = strings.ReplaceAll(marked, search.SearchMarkRight, "</mark>")
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue