in cqlprotodoc/spec/spec.go [168:196]
func checkSectionStart(toc []TOCEntry, tocIdx int, line string) (bool, int, Section) {
mh := headingRegexp.FindStringSubmatch(line)
if len(mh) != 4 || tocIdx >= len(toc) {
return false, tocIdx, Section{}
}
if mh[mhSpaces] == "" {
if mh[mhNumber] == toc[tocIdx].Number {
tocIdx++
}
return true, tocIdx, Section{
Number: mh[mhNumber],
Title: mh[mhTitle],
}
}
t := strings.ToLower(mh[3])
for i := tocIdx; i < len(toc); i++ {
t2 := strings.ToLower(toc[i].Title)
if mh[mhNumber] == toc[i].Number && (strings.Contains(t, t2) || strings.Contains(t2, t)) {
return true, i + 1, Section{
Number: mh[mhNumber],
Title: mh[mhTitle],
}
}
}
return false, tocIdx, Section{}
}