Skip to content

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

:art: Improve parsing tree https://ld246.com/article/1722826829447

Danielff19cc08afbe
diff --git a/kernel/filesys/json_parser.go b/kernel/filesys/json_parser.go
index ca9e7d1c72..186a1ba7bf 100644
--- a/kernel/filesys/json_parser.go
+++ b/kernel/filesys/json_parser.go
@@ -113,14 +113,6 @@ func genTreeByJSON(node *ast.Node, tree *parse.Tree, idMap *map[string]bool, nee
node.Children = nil
}
- if node.IsBlock() {
- if node.ID != node.IALAttr("id") {
- //某些情况下会导致 ID 和属性 id 不相同 https://ld246.com/article/1722826829447
- *needFix = true
- node.SetIALAttr("id", node.ID)
- }
- }
-
switch node.Type {
case ast.NodeList:
if 1 > len(node.Children) {
@@ -191,6 +183,13 @@ func fixLegacyData(tip, node *ast.Node, idMap *map[string]bool, needFix, needMig
node.SetIALAttr("id", node.ID)
*needFix = true
}
+
+ if node.ID != node.IALAttr("id") {
+ //某些情况下会导致 ID 和属性 id 不相同 https://ld246.com/article/1722826829447
+ *needFix = true
+ node.SetIALAttr("id", node.ID)
+ }
+
if 0 < len(node.Children) && ast.NodeBr.String() == node.Children[len(node.Children)-1].TypeStr {
// 剔除块尾多余的软换行 https://github.com/siyuan-note/siyuan/issues/6191
node.Children = node.Children[:len(node.Children)-1]