Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 搜索结果高亮支持大部分行级元素 https://github.com/siyuan-note/siyuan/issues/6745

Liang Ding3d92974f9e93
diff --git a/kernel/model/file.go b/kernel/model/file.go
index a6b2375402..c50236e315 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -644,25 +644,23 @@ func GetDoc(startID, endID, id string, index int, keyword string, mode int, size
n.Tokens = gulu.Str.ToBytes(text)
}
- if ast.NodeText == n.Type {
- if 0 < len(keywords) {
- hitBlock := false
- for p := n.Parent; nil != p; p = p.Parent {
- if p.ID == id {
- hitBlock = true
- break
- }
+ if 0 < len(keywords) {
+ hitBlock := false
+ for p := n.Parent; nil != p; p = p.Parent {
+ if p.ID == id {
+ hitBlock = true
+ break
}
- if hitBlock {
- if markReplaceSpan(n, &unlinks, keywords, searchMarkDataType, luteEngine) {
- return ast.WalkContinue
- }
+ }
+ if hitBlock {
+ if markReplaceSpan(n, &unlinks, keywords, searchMarkDataType, luteEngine) {
+ return ast.WalkContinue
}
}
+ }
- if processVirtualRef(n, &unlinks, virtualBlockRefKeywords, refCount, luteEngine) {
- return ast.WalkContinue
- }
+ if processVirtualRef(n, &unlinks, virtualBlockRefKeywords, refCount, luteEngine) {
+ return ast.WalkContinue
}
return ast.WalkContinue
})
diff --git a/kernel/model/history.go b/kernel/model/history.go
index 19070ae9cc..7372df72e1 100644
--- a/kernel/model/history.go
+++ b/kernel/model/history.go
@@ -177,11 +177,9 @@ func GetDocHistoryContent(historyPath, keyword string) (id, rootID, content stri
n.RemoveIALAttr("heading-fold")
n.RemoveIALAttr("fold")
- if ast.NodeText == n.Type {
- if 0 < len(keywords) {
- if markReplaceSpan(n, &unlinks, keywords, searchMarkDataType, luteEngine) {
- return ast.WalkContinue
- }
+ if 0 < len(keywords) {
+ if markReplaceSpan(n, &unlinks, keywords, searchMarkDataType, luteEngine) {
+ return ast.WalkContinue
}
}
return ast.WalkContinue
diff --git a/kernel/model/search.go b/kernel/model/search.go
index b17e21bb69..9d92063e47 100644
--- a/kernel/model/search.go
+++ b/kernel/model/search.go
@@ -893,6 +893,7 @@ func markReplaceSpan(n *ast.Node, unlinks *[]*ast.Node, keywords []string, markS
}
} else if ast.NodeTextMark == n.Type {
// TODO 搜索结果高亮支持大部分行级元素 https://github.com/siyuan-note/siyuan/issues/6745
+
}
return false
}
diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.go
index a897bdd8e5..7ca3db9666 100644
--- a/kernel/model/virutalref.go
+++ b/kernel/model/virutalref.go
@@ -35,6 +35,10 @@ func processVirtualRef(n *ast.Node, unlinks *[]*ast.Node, virtualBlockRefKeyword
return false
}
+ if ast.NodeText != n.Type {
+ return false
+ }
+
parentBlock := treenode.ParentBlock(n)
if nil == parentBlock || 0 < refCount[parentBlock.ID] {
return false