An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve block ref anchor text rendering in templates https://github.com/siyuan-note/siyuan/issues/14457
Daniel98c51a8fd0ac
diff --git a/kernel/model/template.go b/kernel/model/template.goindex 0f6596a1ca..6849a3e992 100644--- a/kernel/model/template.go+++ b/kernel/model/template.go@@ -355,7 +355,6 @@ func RenderTemplate(p, id string, preview bool) (tree *parse.Tree, dom string, enodesNeedAppendChild = append(nodesNeedAppendChild, n)}- // 块引缺失锚文本情况下自动补全 https://github.com/siyuan-note/siyuan/issues/6087if n.IsTextMarkType("block-ref") {if refText := n.Text(); "" == refText {refText = strings.TrimSpace(sql.GetRefText(n.TextMarkBlockRefID))@@ -365,6 +364,17 @@ func RenderTemplate(p, id string, preview bool) (tree *parse.Tree, dom string, eunlinks = append(unlinks, n)}}+ } else if ast.NodeBlockRef == n.Type {+ if refText := n.Text(); "" == refText {+ if refID := n.ChildByType(ast.NodeBlockRefID); nil != refID {+ refText = strings.TrimSpace(sql.GetRefText(refID.TokensStr()))+ if "" != refText {+ treenode.SetDynamicBlockRefText(n, refText)+ } else {+ unlinks = append(unlinks, n)+ }+ }+ }} else if n.IsTextMarkType("inline-math") {if n.ParentIs(ast.NodeTableCell) {// 表格中的公式中带有管道符时使用 HTML 实体替换管道符 Improve the handling of inline-math containing `|` in the table https://github.com/siyuan-note/siyuan/issues/9227diff --git a/kernel/treenode/node.go b/kernel/treenode/node.goindex dfa13f7742..c7a4c7a73f 100644--- a/kernel/treenode/node.go+++ b/kernel/treenode/node.go@@ -469,6 +469,14 @@ func SetDynamicBlockRefText(blockRef *ast.Node, refText string) {return}+ if ast.NodeBlockRef == blockRef.Type {+ if refID := blockRef.ChildByType(ast.NodeBlockRefID); nil != refID {+ refID.InsertAfter(&ast.Node{Type: ast.NodeBlockRefDynamicText, Tokens: []byte(refText)})+ refID.InsertAfter(&ast.Node{Type: ast.NodeBlockRefSpace})+ }+ return+ }+refText = strings.TrimSpace(refText)if "" == refText {refText = blockRef.TextMarkBlockRefID