Forráskód Böngészése

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

Daniel 11 hónapja
szülő
commit
ff19cc08af
1 módosított fájl, 7 hozzáadás és 8 törlés
  1. 7 8
      kernel/filesys/json_parser.go

+ 7 - 8
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]