print file name as root and removed func count_levels
This commit is contained in:
parent
67b64d113d
commit
2c52f950ca
33
main.go
33
main.go
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,29 +33,6 @@ func get_heading_level(heading_text string) int {
|
|||||||
return level
|
return level
|
||||||
}
|
}
|
||||||
|
|
||||||
func count_levels(headings []heading) [6]int {
|
|
||||||
level_count := [6]int{}
|
|
||||||
|
|
||||||
for index, _ := range headings {
|
|
||||||
switch headings[index].level {
|
|
||||||
case 1:
|
|
||||||
level_count[0]++
|
|
||||||
case 2:
|
|
||||||
level_count[1]++
|
|
||||||
case 3:
|
|
||||||
level_count[2]++
|
|
||||||
case 4:
|
|
||||||
level_count[3]++
|
|
||||||
case 5:
|
|
||||||
level_count[4]++
|
|
||||||
case 6:
|
|
||||||
level_count[5]++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return level_count
|
|
||||||
}
|
|
||||||
|
|
||||||
func get_parents(headings []heading) {
|
func get_parents(headings []heading) {
|
||||||
for index, _ := range headings {
|
for index, _ := range headings {
|
||||||
if index == 0 {
|
if index == 0 {
|
||||||
@ -123,13 +101,6 @@ func main() {
|
|||||||
|
|
||||||
fmt.Printf("%v\n", headings)
|
fmt.Printf("%v\n", headings)
|
||||||
|
|
||||||
header_level_count := count_levels(headings)
|
fmt.Println(path.Base(file_name))
|
||||||
|
|
||||||
for i := 0; i < 6; i++ {
|
|
||||||
if header_level_count[i] != 0 {
|
|
||||||
fmt.Printf("Header %d occurs %d times.\n", (i + 1), header_level_count[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tree(-1, "", headings)
|
tree(-1, "", headings)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user