print_children func works
This commit is contained in:
parent
8b4e9a9e22
commit
0e61abb6cc
16
main.go
16
main.go
@ -71,6 +71,16 @@ func get_parents(headings []heading) {
|
||||
}
|
||||
}
|
||||
|
||||
func print_children(heading *heading, headings []heading) {
|
||||
fmt.Printf("pointer of parent: %p\n", heading)
|
||||
|
||||
for index, _ := range headings {
|
||||
if headings[index].parent == heading {
|
||||
fmt.Printf("Header of parent %p: %s\n", heading, headings[index].text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
file_content_raw, err := os.ReadFile(os.Args[1])
|
||||
|
||||
@ -93,6 +103,12 @@ func main() {
|
||||
|
||||
get_parents(headings)
|
||||
|
||||
// print all children that do not have a parent
|
||||
//print_children(nil, headings)
|
||||
|
||||
// print all children of the second header
|
||||
print_children(&headings[1], headings)
|
||||
|
||||
fmt.Printf("%v\n", headings)
|
||||
|
||||
header_level_count := count_levels(headings)
|
||||
|
Loading…
Reference in New Issue
Block a user