You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

21 lines
591 B

package utils
import (
"html"
"regexp"
mevt "maunium.net/go/mautrix/event"
)
var htmlRegex = regexp.MustCompile("<[^<]+?>")
// StrippedHTMLMessage returns a MessageEventContent with the body set to a stripped version of the provided HTML,
// in addition to the provided HTML.
func StrippedHTMLMessage(msgtype mevt.MessageType, htmlText string) mevt.MessageEventContent {
return mevt.MessageEventContent{
Body: html.UnescapeString(htmlRegex.ReplaceAllLiteralString(htmlText, "")),
MsgType: msgtype,
Format: mevt.FormatHTML,
FormattedBody: htmlText,
}
}