diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-08-16 16:06:32 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-16 16:06:32 +0200 |
commit | 7bafbe463c7b85b817437df14fadc4c6b37022d9 (patch) | |
tree | abcf8247f4ac5e12a32ff102dd4c8616181b86a0 | |
parent | a130b843a9ae7533c650c05bc371650147cd4441 (diff) |
-rw-r--r-- | matrix/matrix.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/matrix/matrix.go b/matrix/matrix.go index f7f308b..88ec406 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -17,6 +17,7 @@ package matrix import ( + "strings" "context" "crypto/tls" "encoding/gob" @@ -819,7 +820,26 @@ func (c *Container) MarkRead(roomID id.RoomID, eventID id.EventID) { }() } +func greentext(text string) string { + var result strings.Builder + for i, line := range strings.Split(text, "\n") { + if i > 0 { + result.WriteByte('\n') + } + if len(line) > 0 && line[0] == '>' { + result.WriteString("<font color=\"#789922\">") + result.WriteString(line) + result.WriteString("</font>") + } else { + result.WriteString(line) + } + } + return result.String() +} + func (c *Container) PrepareMarkdownMessage(roomID id.RoomID, msgtype event.MessageType, text, html string, rel *ifc.Relation) *muksevt.Event { + text = greentext(text) + var content event.MessageEventContent if html != "" { content = event.MessageEventContent{ |