🎨 Block ref elements retain their original styles when exported https://github.com/siyuan-note/siyuan/issues/15698

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2025-09-11 17:54:25 +08:00
parent ee4ddf89c1
commit 8476ddd18c
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -2271,11 +2271,11 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
switch blockRefMode { switch blockRefMode {
case 2: // 锚文本块链 case 2: // 锚文本块链
blockRefLink := &ast.Node{Type: ast.NodeTextMark, TextMarkType: "a", TextMarkTextContent: linkText, TextMarkAHref: "siyuan://blocks/" + defID} blockRefLink := &ast.Node{Type: ast.NodeTextMark, TextMarkTextContent: linkText, TextMarkAHref: "siyuan://blocks/" + defID}
blockRefLink.KramdownIAL = n.KramdownIAL blockRefLink.KramdownIAL = n.KramdownIAL
if n.IsTextMarkType("inline-memo") { if "block-ref" != n.TextMarkType { // 除了块引还有其他元素 https://github.com/siyuan-note/siyuan/issues/15698
blockRefLink.TextMarkType = strings.TrimSpace(strings.ReplaceAll(n.TextMarkType, "block-ref", "a"))
blockRefLink.TextMarkInlineMemoContent = n.TextMarkInlineMemoContent blockRefLink.TextMarkInlineMemoContent = n.TextMarkInlineMemoContent
blockRefLink.TextMarkType = "a inline-memo"
} }
n.InsertBefore(blockRefLink) n.InsertBefore(blockRefLink)
unlinks = append(unlinks, n) unlinks = append(unlinks, n)
@ -2291,11 +2291,11 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
} }
} else { } else {
blockRefLink = &ast.Node{Type: ast.NodeText, Tokens: []byte(linkText)} blockRefLink = &ast.Node{Type: ast.NodeText, Tokens: []byte(linkText)}
if n.IsTextMarkType("inline-memo") { if "block-ref" != n.TextMarkType {
blockRefLink.Type = ast.NodeTextMark blockRefLink.Type = ast.NodeTextMark
blockRefLink.TextMarkInlineMemoContent = n.TextMarkInlineMemoContent blockRefLink.TextMarkType = strings.TrimSpace(strings.ReplaceAll(n.TextMarkType, "block-ref", ""))
blockRefLink.TextMarkType = "inline-memo"
blockRefLink.TextMarkTextContent = linkText blockRefLink.TextMarkTextContent = linkText
blockRefLink.TextMarkInlineMemoContent = n.TextMarkInlineMemoContent
} }
} }
n.InsertBefore(blockRefLink) n.InsertBefore(blockRefLink)
@ -2315,13 +2315,13 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
} }
text := &ast.Node{Type: ast.NodeText, Tokens: []byte(linkText)} text := &ast.Node{Type: ast.NodeText, Tokens: []byte(linkText)}
n.InsertBefore(text) if "block-ref" != n.TextMarkType {
if n.IsTextMarkType("inline-memo") {
text.Type = ast.NodeTextMark text.Type = ast.NodeTextMark
text.TextMarkType = "inline-memo" text.TextMarkType = strings.TrimSpace(strings.ReplaceAll(n.TextMarkType, "block-ref", ""))
text.TextMarkTextContent = linkText text.TextMarkTextContent = linkText
text.TextMarkInlineMemoContent = n.TextMarkInlineMemoContent text.TextMarkInlineMemoContent = n.TextMarkInlineMemoContent
} }
n.InsertBefore(text)
n.InsertBefore(&ast.Node{Type: ast.NodeFootnotesRef, Tokens: []byte("^" + refFoot.refNum), FootnotesRefId: refFoot.refNum, FootnotesRefLabel: []byte("^" + refFoot.refNum)}) n.InsertBefore(&ast.Node{Type: ast.NodeFootnotesRef, Tokens: []byte("^" + refFoot.refNum), FootnotesRefId: refFoot.refNum, FootnotesRefLabel: []byte("^" + refFoot.refNum)})
unlinks = append(unlinks, n) unlinks = append(unlinks, n)
} }