diff options
Diffstat (limited to 'matrix/matrix.go')
-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{ |