Skip to content

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

:art: Referenced blocks support rendering virtual references https://github.com/siyuan-note/siyuan/issues/10960

Daniel5e116a16d277
diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.go
index 668bb204eb..9ff20fbbda 100644
--- a/kernel/model/virutalref.go
+++ b/kernel/model/virutalref.go
@@ -144,7 +144,7 @@ func AddVirtualBlockRefExclude(keyword []string) {
}
func processVirtualRef(n *ast.Node, unlinks *[]*ast.Node, virtualBlockRefKeywords []string, refCount map[string]int, luteEngine *lute.Lute) bool {
- if !Conf.Editor.VirtualBlockRef {
+ if !Conf.Editor.VirtualBlockRef || 1 > len(virtualBlockRefKeywords) {
return false
}
@@ -153,12 +153,15 @@ func processVirtualRef(n *ast.Node, unlinks *[]*ast.Node, virtualBlockRefKeyword
}
parentBlock := treenode.ParentBlock(n)
- if nil == parentBlock || 0 < refCount[parentBlock.ID] {
+ if nil == parentBlock {
return false
}
- if 1 > len(virtualBlockRefKeywords) {
- return false
+ if 0 < refCount[parentBlock.ID] {
+ // 如果块被引用过,则将其自身的文本排除在虚拟引用关键字之外
+ // Referenced blocks support rendering virtual references https://github.com/siyuan-note/siyuan/issues/10960
+ parentText := getNodeRefText(parentBlock)
+ virtualBlockRefKeywords = gulu.Str.RemoveElem(virtualBlockRefKeywords, parentText)
}
content := string(n.Tokens)