Skip to content

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

:art: Improve list item, super block and blockquote backlink propagation https://github.com/siyuan-note/siyuan/issues/13776

Daniel1d77cdefc25a
diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go
index 1b04c55509..c69945c6ff 100644
--- a/kernel/model/backlink.go
+++ b/kernel/model/backlink.go
@@ -588,18 +588,41 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keywords []string) (ret []
sqlParagraphParents := sql.GetBlocks(paragraphParentIDs)
paragraphParents := fromSQLBlocks(&sqlParagraphParents, "", 12)
+ luteEngine := util.NewLute()
originalRefBlockIDs = map[string]string{}
processedParagraphs := hashset.New()
for _, parent := range paragraphParents {
if "NodeListItem" == parent.Type || "NodeBlockquote" == parent.Type || "NodeSuperBlock" == parent.Type {
+ paragraphUseParentLi := true
if refBlock := parentRefParagraphs[parent.ID]; nil != refBlock {
- processedParagraphs.Add(parent.ID)
+ if "NodeListItem" == parent.Type && parent.FContent != refBlock.Content {
+ if inlineTree := parse.Inline("", []byte(refBlock.Markdown), luteEngine.ParseOptions); nil != inlineTree {
+ for c := inlineTree.Root.FirstChild.FirstChild; c != nil; c = c.Next {
+ if treenode.IsBlockRef(c) {
+ continue
+ }
+
+ if "" != strings.TrimSpace(c.Text()) {
+ paragraphUseParentLi = false
+ break
+ }
+ }
+ }
+ }
+
+ if paragraphUseParentLi {
+ processedParagraphs.Add(parent.ID)
+ }
+
originalRefBlockIDs[parent.ID] = refBlock.ID
if !matchBacklinkKeyword(parent, keywords) {
refsCount--
continue
}
- ret = append(ret, parent)
+
+ if paragraphUseParentLi {
+ ret = append(ret, parent)
+ }
}
}
}
diff --git a/kernel/treenode/node.go b/kernel/treenode/node.go
index f0048e173d..8b0a76114f 100644
--- a/kernel/treenode/node.go
+++ b/kernel/treenode/node.go
@@ -100,7 +100,7 @@ func IsBlockRef(n *ast.Node) bool {
if nil == n {
return false
}
- return ast.NodeTextMark == n.Type && n.IsTextMarkType("block-ref")
+ return (ast.NodeTextMark == n.Type && n.IsTextMarkType("block-ref")) || ast.NodeBlockRef == n.Type
}
func IsBlockLink(n *ast.Node) bool {