Replace tabs with spaces so that they get rendered

This commit is contained in:
Tulir Asokan 2018-04-24 22:08:57 +03:00
parent 2a0145db88
commit 49cd74c548
2 changed files with 3 additions and 0 deletions

View File

@ -180,6 +180,7 @@ func (parser *MatrixHTMLProcessor) Postprocess() {
// ParseHTMLMessage parses a HTML-formatted Matrix event into a UIMessage.
func ParseHTMLMessage(room *rooms.Room, evt *gomatrix.Event, senderDisplayname string) tstring.TString {
htmlData, _ := evt.Content["formatted_body"].(string)
htmlData = strings.Replace(htmlData, "\t", " ", -1)
msgtype, _ := evt.Content["msgtype"].(string)
processor := &MatrixHTMLProcessor{

View File

@ -18,6 +18,7 @@ package parser
import (
"fmt"
"strings"
"time"
"maunium.net/go/gomatrix"
@ -64,6 +65,7 @@ func ParseMessage(matrix ifc.MatrixContainer, room *rooms.Room, evt *gomatrix.Ev
return messages.NewExpandedTextMessage(evt.ID, evt.Sender, displayname, msgtype, text, ts)
}
text, _ := evt.Content["body"].(string)
text = strings.Replace(text, "\t", " ", -1)
return messages.NewTextMessage(evt.ID, evt.Sender, displayname, msgtype, text, ts)
case "m.image":
url, _ := evt.Content["url"].(string)