Add enrichment function for post bodies

This commit is contained in:
Dominic Ferrando
2025-04-18 17:00:39 -04:00
parent edd16bcd94
commit f881d7df0a
4 changed files with 36 additions and 5 deletions
+19
View File
@@ -0,0 +1,19 @@
package util
import (
"html/template"
"strings"
)
func EnrichPost(body string) string {
lines := strings.Split(body, "\n")
for i, line := range lines {
if strings.HasPrefix(line, ">") {
escaped := template.HTMLEscapeString(line)
lines[i] = `<span class="greentext">` + escaped + `</span>`
} else {
lines[i] = template.HTMLEscapeString(line)
}
}
return strings.Join(lines, "<br />")
}