diff --git a/tree.go b/tree.go index e71505e..1855082 100644 --- a/tree.go +++ b/tree.go @@ -37,6 +37,10 @@ func get_child_indices(header_index int, headings []heading) []int { parent_level := get_heading_level(headings[header_index].text) + if header_index >= (len(headings) - 1) { + return nil + } + next_level := get_heading_level(headings[header_index+1].text) child_level := 0