Closed cyucelen closed 5 years ago
Are you wanting to replace the old Mark function with this new version? Edit: Are you wanting to expect a slice of strings in return?
Sorry for the lack of information about the task.
I am expecting a new variadic Mark function to take a string, a color and an arbitrary number of Matchers and return a colorized string that all Matchers applied to it.
No worries.
I think what I submitted may not be exactly what you want, so I will come back to that after work.
Waiting for your commits. Thanks!
@cyucelen If you have free time, would you review pull request #14 and let me know what changes you would want to see. I missed that you have a builder.go file, so I didn't add the new function to that file.
I made this a separate function to avoid breaking any code. We can go in and restructure Mark into being MarkMany then make the original Mark a private function.
Currently it is setup like: marker.go
func MarkMany(str string, c *color.Color, matcherFuncs ...MatcherFunc) string
How to use:
str := MarkMany("Skydome is Skydome. Give yourself freedom.", myColor, MatchAll("Skydome"), MatchAll("yourself"))
builder.go
func (m *MarkBuilder) MarkMany(c *color.Color, matcherFuncs ...MatcherFunc) *MarkBuilder
How to use:
b := MarkBuilder{}
actualString := b.SetString("Skydome is a data company.").
MarkMany(redFg, MatchAll("data"), MatchAll("company")).
Build()
Create a variadic Mark function that can take an arbitrary number of Matchers and colorizes the matches.