Skip to content

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

:bug: Markdown import fails when tag is empty https://github.com/siyuan-note/siyuan/issues/13382

Daniela1fdad7e0abd
diff --git a/kernel/model/box.go b/kernel/model/box.go
index 2425af4e24..56ba8cb36c 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
}