summaryrefslogtreecommitdiff
path: root/ui.go
diff options
context:
space:
mode:
authorDavid Schlachter <t480-debian-git@schlachter.ca>2026-01-08 11:35:55 -0500
committerDavid Schlachter <t480-debian-git@schlachter.ca>2026-01-08 11:35:55 -0500
commit4be46ea1449222be87c8ba4aa4d1d02187e5a6d8 (patch)
treeaa03e2d6163a899a94db327b30add194982a85ee /ui.go
parentc6ebb73c3ed6eefc9298a50397434e0fd0ace781 (diff)
Replace apostrophe HTML entity with apostrophe
Diffstat (limited to 'ui.go')
-rw-r--r--ui.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/ui.go b/ui.go
index e4eb311..7857216 100644
--- a/ui.go
+++ b/ui.go
@@ -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, "&#39;", "’")
+ // Wrap
+ width := min(maxWidth, 80)
return wordwrap.String(str, width)
}