add the ability to recognize man page sections
This commit is contained in:
parent
414d55afdc
commit
7a7b23d489
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user