aboutsummaryrefslogtreecommitdiff
path: root/renderer
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2022-01-27 10:53:18 +0000
committerr <r@freesoftwareextremist.com>2022-01-27 10:53:18 +0000
commitb8bab6fcf337e6c48437d45cf192e085e19cdf49 (patch)
tree538ef85d8a13a9f6a7fd470d9f637cfd841a73b5 /renderer
parentfcb88c8a85fd2918c4c9e30c3ef49e716d77f2b0 (diff)
downloadbloat-b8bab6fcf337e6c48437d45cf192e085e19cdf49.tar.gz
bloat-b8bab6fcf337e6c48437d45cf192e085e19cdf49.zip
Highlight quotes
Diffstat (limited to 'renderer')
-rw-r--r--renderer/renderer.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/renderer/renderer.go b/renderer/renderer.go
index ec328dc..4911db9 100644
--- a/renderer/renderer.go
+++ b/renderer/renderer.go
@@ -3,6 +3,7 @@ package renderer
import (
"fmt"
"io"
+ "regexp"
"strconv"
"strings"
"text/template"
@@ -49,6 +50,8 @@ func emojiFilter(content string, emojis []mastodon.Emoji) string {
return strings.NewReplacer(replacements...).Replace(content)
}
+var quoteRE = regexp.MustCompile("(?mU)(^|> *|\n)(&gt;.*)(<br|$)")
+
func statusContentFilter(spoiler string, content string,
emojis []mastodon.Emoji, mentions []mastodon.Mention) string {
@@ -57,6 +60,7 @@ func statusContentFilter(spoiler string, content string,
if len(spoiler) > 0 {
content = spoiler + "<br />" + content
}
+ content = quoteRE.ReplaceAllString(content, "$1<span class=\"quote\">$2</span>$3")
for _, e := range emojis {
r = fmt.Sprintf("<img class=\"emoji\" src=\"%s\" alt=\":%s:\" title=\":%s:\" height=\"32\" />",
e.URL, e.ShortCode, e.ShortCode)