From 27413a9745aa239ea0cb8916b13cdda37486b474 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?=
Date: Fri, 29 Oct 2021 16:46:32 +0200
Subject: [PATCH] [Messages] Fix HTML line break decoding and encoding.
---
.../java/pl/szczodrzynski/edziennik/utils/html/BetterHtml.kt | 4 ++++
.../edziennik/utils/managers/TextStylingManager.kt | 5 ++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/html/BetterHtml.kt b/app/src/main/java/pl/szczodrzynski/edziennik/utils/html/BetterHtml.kt
index 1be6264c..2e3bc072 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/html/BetterHtml.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/html/BetterHtml.kt
@@ -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("", "
")
+ // this is used only in Notes and Events
if (nl2br) {
text = text.replace("\n", "
")
}
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/TextStylingManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/TextStylingManager.kt
index 54cf2b38..7a96c270 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/TextStylingManager.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/TextStylingManager.kt
@@ -200,13 +200,16 @@ class TextStylingManager(private val app: App) {
if (htmlMode == COMPATIBLE) {
textHtml = textHtml
- .replace("
", "
")
+ .substringBeforeLast("
")
+ .replace("", "")
+ .replace("
", "
")
.replace("", "")
.replace("", "")
.replace("", "")
.replace("", "")
.replace("", "")
.replace("", "")
+ textHtml = "$textHtml
"
}
return textHtml