line numbers are also printed

This commit is contained in:
bjt-user 2024-05-06 01:40:29 +02:00
parent 7a998e6cbf
commit 43d72938b1
2 changed files with 3 additions and 10 deletions

View File

@ -6,11 +6,6 @@ This seems intended by the creators of the language.
#### TODO
- print header tree
- delph deeper into different Markdown implementations (like CommonMark)
- add support for "Setext-style headers"
#### logic ideas
For a tree structure you will probably need parent/child relationships.\
You might need to create a parent and a child field in the header struct.
- maybe remove pound signs infront of headers

View File

@ -93,15 +93,13 @@ func get_child_indices(header_index int, headings []heading) []int {
func tree(index int, prefix string, headings []heading) {
children := get_child_indices(index, headings)
//fmt.Printf("children: %v\n", children)
for index, child_index := range children {
//fmt.Printf("child_index: %d\n", child_index)
if index == (len(children) - 1) {
fmt.Println(prefix+"`--", headings[child_index].text)
fmt.Printf("%s %s (%d)\n", prefix+"`--", headings[child_index].text, headings[child_index].line)
tree(child_index, prefix+" ", headings)
} else {
fmt.Println(prefix+"|--", headings[child_index].text)
fmt.Printf("%s %s (%d)\n", prefix+"|--", headings[child_index].text, headings[child_index].line)
tree(child_index, prefix+"| ", headings)
}
}