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

This commit is contained in:
Daniel 2024-12-06 09:47:00 +08:00
parent ee1043514b
commit a1fdad7e0a
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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
}