Improve handling of multiple linebreaks

This commit is contained in:
Tulir Asokan
2019-04-07 22:54:55 +03:00
parent e6180c9b6f
commit 5d7c1a4caa
4 changed files with 54 additions and 30 deletions

View File

@ -289,7 +289,7 @@ func (parser *htmlParser) tagNodeToEntity(node *html.Node, stripLinebreak bool)
case "h1", "h2", "h3", "h4", "h5", "h6":
return parser.headerToEntity(node, stripLinebreak)
case "br":
return &messages.BaseHTMLEntity{Tag: "br", Block: true}
return messages.NewBreakEntity()
case "b", "strong", "i", "em", "s", "del", "u", "ins", "font":
return parser.basicFormatToEntity(node, stripLinebreak)
case "a":

View File

@ -113,7 +113,7 @@ func ParseMessage(matrix ifc.MatrixContainer, room *rooms.Room, evt *mautrix.Eve
replyToEvt.Content.FormattedBody = html.EscapeString(replyToEvt.Content.Body)
}
evt.Content.FormattedBody = fmt.Sprintf(
"In reply to <a href='https://matrix.to/#/%[1]s'>%[1]s</a><blockquote>%[2]s</blockquote><br/>%[3]s",
"In reply to <a href='https://matrix.to/#/%[1]s'>%[1]s</a><blockquote>%[2]s</blockquote><br/><br/>%[3]s",
replyToEvt.Sender, replyToEvt.Content.FormattedBody, evt.Content.FormattedBody)
} else {
evt.Content.FormattedBody = fmt.Sprintf(