-
Notifications
You must be signed in to change notification settings - Fork 627
Closed
Description
I'm trying to pretty print a markdown file. The file uses {{ some-text }}
in it for indicating variables, im removing the {{
/}}
and underline the inner text, and i'm also making the entire line cyan. But it seems, cyan get's removed after the first occurrence of the underlined word.
An example image:
The part of the code is somewhat like this
var underline = color.New(color.Underline).Sprint
line = highLightVariable(line)
line = color.CyanString(line)
fmt.Println(line)
func highLightVariable(line string) string {
lines := strings.Split(line, "}}")
lines = lo.Map(lines, func(line string, _ int) string {
l := strings.Split(line, "{{")
if len(l) > 1 {
l[1] = underline(l[1])
}
return strings.Join(l, "{{")
})
line = strings.Join(lines, "}}")
line = strings.ReplaceAll(line, "{{", "")
line = strings.ReplaceAll(line, "}}", "")
return line
}
the cyan colors stops after the first underlined word, even tho consequent words to have underlines.
In case, the full code is needed, check this
Metadata
Metadata
Assignees
Labels
No labels