From 186684b183d709015979c2ef681b6995c11df7f6 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 8 Oct 2025 17:00:19 +0800 Subject: [PATCH] :art: Improve exporting block ref style https://github.com/siyuan-note/siyuan/issues/16017 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/export.go | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/kernel/model/export.go b/kernel/model/export.go index 77c7df7cd..34ccac57a 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -2288,24 +2288,9 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool, n.InsertBefore(blockRefLink) unlinks = append(unlinks, n) case 3: // 仅锚文本 - var blockRefLink *ast.Node - if 0 < len(n.KramdownIAL) { - blockRefLink = &ast.Node{Type: ast.NodeTextMark, TextMarkType: "text", TextMarkTextContent: linkText} - blockRefLink.KramdownIAL = n.KramdownIAL - - if n.IsTextMarkType("inline-memo") { - blockRefLink.TextMarkInlineMemoContent = n.TextMarkInlineMemoContent - blockRefLink.TextMarkType = "text inline-memo" - } - } else { - blockRefLink = &ast.Node{Type: ast.NodeText, Tokens: []byte(linkText)} - if "block-ref" != n.TextMarkType { - blockRefLink.Type = ast.NodeTextMark - blockRefLink.TextMarkType = strings.TrimSpace(strings.ReplaceAll(n.TextMarkType, "block-ref", "")) - blockRefLink.TextMarkTextContent = linkText - blockRefLink.TextMarkInlineMemoContent = n.TextMarkInlineMemoContent - } - } + blockRefLink := &ast.Node{Type: ast.NodeTextMark, TextMarkType: strings.TrimSpace(strings.ReplaceAll(n.TextMarkType, "block-ref", "")), TextMarkTextContent: linkText} + blockRefLink.KramdownIAL = n.KramdownIAL + blockRefLink.TextMarkInlineMemoContent = n.TextMarkInlineMemoContent n.InsertBefore(blockRefLink) unlinks = append(unlinks, n) case 4: // 脚注+锚点哈希 @@ -2999,7 +2984,7 @@ func blockLink2Ref0(currentTree *parse.Tree, node *ast.Node, treeCache map[strin } if treenode.IsBlockLink(n) { - n.TextMarkType = "block-ref" + n.TextMarkType = strings.TrimSpace(strings.TrimPrefix(n.TextMarkType, "a") + " block-ref") n.TextMarkBlockRefID = strings.TrimPrefix(n.TextMarkAHref, "siyuan://blocks/") n.TextMarkBlockRefSubtype = "s"