commit 4be46ea1449222be87c8ba4aa4d1d02187e5a6d8
parent c6ebb73c3ed6eefc9298a50397434e0fd0ace781
Author: David Schlachter <t480-debian-git@schlachter.ca>
Date: Thu, 8 Jan 2026 11:35:55 -0500
Replace apostrophe HTML entity with apostrophe
Diffstat:
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git 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, "'", "’")
+ // Wrap
+ width := min(maxWidth, 80)
return wordwrap.String(str, width)
}