Improve location displays
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user