Improve location displays

This commit is contained in:
2026-03-05 01:44:43 -06:00
parent 7a92805d79
commit b20d68c9f0
2 changed files with 78 additions and 7 deletions

View File

@@ -37,14 +37,32 @@ Examples:
if pageSection != "" {
idx := wiki.FindSectionIndex(page.Sections, pageSection)
if idx == -1 {
needle := strings.ToLower(pageSection)
// Case-insensitive exact match
for _, s := range page.Sections {
if strings.EqualFold(s.Line, pageSection) {
i := 0
fmt.Sscanf(s.Index, "%d", &i)
idx = i
if strings.ToLower(s.Line) == needle {
fmt.Sscanf(s.Index, "%d", &idx)
break
}
}
// Case-insensitive prefix match (e.g. "Location" → "Locations")
if idx == -1 {
for _, s := range page.Sections {
if strings.HasPrefix(strings.ToLower(s.Line), needle) {
fmt.Sscanf(s.Index, "%d", &idx)
break
}
}
}
// Case-insensitive contains match
if idx == -1 {
for _, s := range page.Sections {
if strings.Contains(strings.ToLower(s.Line), needle) {
fmt.Sscanf(s.Index, "%d", &idx)
break
}
}
}
}
if idx == -1 {
return fmt.Errorf("section %q not found. Available sections: %s",