From a1fdad7e0abdc0a13eeb4645c5a65f324a57d737 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 6 Dec 2024 09:47:00 +0800 Subject: [PATCH] :bug: Markdown import fails when tag is empty https://github.com/siyuan-note/siyuan/issues/13382 --- kernel/model/box.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/model/box.go b/kernel/model/box.go index 2425af4e24b..56ba8cb36c0 100644 --- a/kernel/model/box.go +++ b/kernel/model/box.go @@ -596,7 +596,7 @@ func normalizeTree(tree *parse.Tree) (yfmRootID, yfmTitle, yfmUpdated string) { } continue } - if "tags" == attrK { + if "tags" == attrK && nil != attrV { var tags string if str, ok := attrV.(string); ok { tags = strings.TrimSpace(str) @@ -614,7 +614,10 @@ func normalizeTree(tree *parse.Tree) (yfmRootID, yfmTitle, yfmUpdated string) { tags += tagStr + "," } tags = strings.TrimRight(tags, ",") - tree.Root.SetIALAttr("tags", tags) + tags = strings.TrimSpace(tags) + if "" != tags { + tree.Root.SetIALAttr("tags", tags) + } continue }