[Messages] Fix HTML line break decoding and encoding.

This commit is contained in:
Kuba Szczodrzyński 2021-10-29 16:46:32 +02:00
parent 49a093201b
commit 27413a9745
No known key found for this signature in database
GPG Key ID: 70CB8A85BA1633CB
2 changed files with 8 additions and 1 deletions

View File

@ -47,7 +47,11 @@ object BetterHtml {
var text = html
.replace("\\[META:[A-z0-9]+;[0-9-]+]".toRegex(), "")
.replace("background-color: ?$hexPattern;".toRegex(), "")
// treat paragraphs as if they had no margin
.replace("<p", "<span")
.replace("</p>", "</span><br>")
// this is used only in Notes and Events
if (nl2br) {
text = text.replace("\n", "<br>")
}

View File

@ -200,13 +200,16 @@ class TextStylingManager(private val app: App) {
if (htmlMode == COMPATIBLE) {
textHtml = textHtml
.replace("<br>", "<p>&nbsp;</p>")
.substringBeforeLast("</p>")
.replace("<p>", "")
.replace("</p>", "<br>")
.replace("<b>", "<strong>")
.replace("</b>", "</strong>")
.replace("<i>", "<em>")
.replace("</i>", "</em>")
.replace("<u>", "<span style=\"text-decoration: underline;\">")
.replace("</u>", "</span>")
textHtml = "<p>$textHtml</p>"
}
return textHtml