add the ability to recognize man page sections

This commit is contained in:
Aaron Bieber 2020-02-05 07:55:39 -07:00
parent 414d55afdc
commit 7a7b23d489

View File

@ -13,12 +13,20 @@ type OpenBSDMan struct {
} }
func (h *OpenBSDMan) fix(msg string) string { func (h *OpenBSDMan) fix(msg string) string {
re := regexp.MustCompile(`(?i)^man: `) re := regexp.MustCompile(`(?i)^man: (\d?)\s?(\w+)$`)
return re.ReplaceAllString(msg, "$1") resp := ""
section := re.ReplaceAllString(msg, "$1")
if section != "" {
resp = re.ReplaceAllString(msg, "$2.$1")
} else {
resp = re.ReplaceAllString(msg, "$2")
}
return resp
} }
func (h *OpenBSDMan) match(msg string) bool { func (h *OpenBSDMan) match(msg string) bool {
re := regexp.MustCompile(`(?i)^man: `) re := regexp.MustCompile(`(?i)^man: (\d?)\s?(\w+)$`)
return re.MatchString(msg) return re.MatchString(msg)
} }