line numbers are also printed
This commit is contained in:
parent
7a998e6cbf
commit
43d72938b1
@ -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
|
||||
|
6
tree.go
6
tree.go
@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user