diff options
| -rw-r--r-- | ui.go | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -147,14 +147,24 @@ func (m model) View() string { } func formatDefinitionForDisplay(policy bluemonday.Policy, definition string, maxWidth int) string { + // Add a hypher to the start of each definition str := strings.ReplaceAll(definition, "<li class=sense>", "<li class=sense>- ") + + // Italicize examples str = strings.ReplaceAll(str, "\t<ul><li><i>", "\n\t<ul><li><i>\x1b[3;39;49m") str = strings.ReplaceAll(str, "</i></li></ul></li>", "</i></li></ul></li>\x1b[0m") + + // Remove all HTML tags str = policy.Sanitize(str) + + // Add some colour to the start of each definition str = strings.ReplaceAll(str, "\t- ", "\x1b[0;33;49m•\x1b[0m ") - width := min(maxWidth, 80) + // Replace common HTML entities + str = strings.ReplaceAll(str, "'", "’") + // Wrap + width := min(maxWidth, 80) return wordwrap.String(str, width) } |
