mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 00:50:13 +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
|
|
@ -26,7 +26,6 @@ import (
|
|||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/html"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
|
|
@ -124,6 +123,8 @@ func getNodeRefText(node *ast.Node) string {
|
|||
|
||||
func GetBlockRefIDs(id string) (refIDs, refTexts, defIDs []string) {
|
||||
refIDs = []string{}
|
||||
refTexts = []string{}
|
||||
defIDs = []string{}
|
||||
bt := treenode.GetBlockTree(id)
|
||||
if nil == bt {
|
||||
return
|
||||
|
|
@ -237,9 +238,9 @@ func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string) (ret []*BlockPa
|
|||
fc = fc.Next
|
||||
}
|
||||
|
||||
name := html.EscapeHTMLStr(parent.IALAttr("name"))
|
||||
name := util.EscapeHTML(parent.IALAttr("name"))
|
||||
if ast.NodeDocument == parent.Type {
|
||||
name = html.EscapeHTMLStr(path.Join(boxName, hPath))
|
||||
name = util.EscapeHTML(path.Join(boxName, hPath))
|
||||
} else {
|
||||
if "" == name {
|
||||
if ast.NodeListItem == parent.Type {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/88250/lute/render"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func renderOutline(node *ast.Node, luteEngine *lute.Lute) (ret string) {
|
||||
|
|
@ -71,7 +72,7 @@ func renderBlockText(node *ast.Node, excludeTypes []string) (ret string) {
|
|||
ret = treenode.NodeStaticContent(node, excludeTypes)
|
||||
ret = strings.TrimSpace(ret)
|
||||
ret = strings.ReplaceAll(ret, "\n", "")
|
||||
ret = html.EscapeString(ret)
|
||||
ret = util.EscapeHTML(ret)
|
||||
ret = strings.TrimSpace(ret)
|
||||
if "" == ret {
|
||||
// 复制内容为空的块作为块引用时粘贴无效 https://github.com/siyuan-note/siyuan/issues/4962
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/html"
|
||||
"github.com/emirpasic/gods/sets/hashset"
|
||||
"github.com/facette/natsort"
|
||||
"github.com/siyuan-note/logging"
|
||||
|
|
@ -360,7 +359,7 @@ func buildTags(root Tags, labels []string, depth int) Tags {
|
|||
}
|
||||
}
|
||||
if i == len(root) {
|
||||
root = append(root, &Tag{Name: html.EscapeHTMLStr(labels[0]), Type: "tag", Depth: depth})
|
||||
root = append(root, &Tag{Name: util.EscapeHTML(labels[0]), Type: "tag", Depth: depth})
|
||||
}
|
||||
depth++
|
||||
root[i].tags = buildTags(root[i].tags, labels[1:], depth)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue