chore: removes colorization from search

Deprecates `mgutz/ansi` and removes colorization from search as a first
step toward improving the functionality.
This commit is contained in:
Chris Lane
2020-02-15 10:01:44 -05:00
parent 3e4c1818a9
commit e0c35a74d4
18 changed files with 2 additions and 1632 deletions

View File

@ -3,13 +3,11 @@ package sheet
import (
"regexp"
"strings"
"github.com/mgutz/ansi"
)
// Search searches for regexp matches in a cheatsheet's text, and optionally
// colorizes matching strings.
func (s *Sheet) Search(reg *regexp.Regexp, colorize bool) []Match {
func (s *Sheet) Search(reg *regexp.Regexp) []Match {
// record matches
matches := []Match{}
@ -30,13 +28,6 @@ func (s *Sheet) Search(reg *regexp.Regexp, colorize bool) []Match {
Text: strings.TrimSpace(line),
}
// colorize the matching text if so configured
if colorize {
m.Text = reg.ReplaceAllStringFunc(m.Text, func(matched string) string {
return ansi.Color(matched, "red+b")
})
}
// record the match
matches = append(matches, m)
}