@@ -849,7 +849,7 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
849
849
fcontent = NodeStaticContent (fc , nil , true , false , true )
850
850
851
851
parentID = n .Parent .ID
852
- if h := heading (n ); nil != h { // 如果在标题块下方,则将标题块作为父节点
852
+ if h := treenode . HeadingParent (n ); nil != h { // 如果在标题块下方,则将标题块作为父节点
853
853
parentID = h .ID
854
854
}
855
855
length = utf8 .RuneCountInString (fcontent )
@@ -861,7 +861,7 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
861
861
content = NodeStaticContent (n , nil , true , indexAssetPath , true )
862
862
863
863
parentID = n .Parent .ID
864
- if h := heading (n ); nil != h {
864
+ if h := treenode . HeadingParent (n ); nil != h {
865
865
parentID = h .ID
866
866
}
867
867
length = utf8 .RuneCountInString (content )
@@ -945,26 +945,6 @@ func tagFromNode(node *ast.Node) (ret string) {
945
945
return strings .TrimSpace (tagBuilder .String ())
946
946
}
947
947
948
- func heading (node * ast.Node ) * ast.Node {
949
- if nil == node {
950
- return nil
951
- }
952
-
953
- currentLevel := 16
954
- if ast .NodeHeading == node .Type {
955
- currentLevel = node .HeadingLevel
956
- }
957
-
958
- for prev := node .Previous ; nil != prev ; prev = prev .Previous {
959
- if ast .NodeHeading == prev .Type {
960
- if prev .HeadingLevel < currentLevel {
961
- return prev
962
- }
963
- }
964
- }
965
- return nil
966
- }
967
-
968
948
func deleteByBoxTx (tx * sql.Tx , box string ) (err error ) {
969
949
if err = deleteBlocksByBoxTx (tx , box ); err != nil {
970
950
return
0 commit comments