From d0532bb9a902611bb7b85260693a7c24baab5433 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 2 Sep 2020 09:06:34 +0200 Subject: [PATCH] Revert some change from #2002 --- CHANGES.md | 1 - .../internal/session/room/send/MarkdownParser.kt | 13 ++++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 86b796869e..9a41f3c4ef 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,7 +10,6 @@ Improvements 🙌: Bugfix 🐛: - Display name not shown under Settings/General (#1926) - - Wrong markdown parsing (#350, #1375, #1939, #1982) - Words containing my name should not trigger notifications (#1781) - Fix changing language issue - Fix FontSize issue (#1483, #1787) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParser.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParser.kt index 39ae35faa1..6ae3df187a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParser.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParser.kt @@ -53,7 +53,7 @@ internal class MarkdownParser @Inject constructor( // According to https://matrix.org/docs/spec/client_server/latest#m-room-message-msgtypes: // The plain text version of the HTML should be provided in the body. // But it caused too many problems so it has been removed in #2002 - TextContent(text, cleanHtmlText.trim()) + TextContent(text, cleanHtmlText.postTreatment()) } else { TextContent(text) } @@ -61,4 +61,15 @@ internal class MarkdownParser @Inject constructor( private fun isFormattedTextPertinent(text: String, htmlText: String?) = text != htmlText && htmlText != "

${text.trim()}

\n" + + /** + * The parser makes some mistakes, so deal with it here + */ + private fun String.postTreatment(): String { + return this + // Remove extra space before and after the content + .trim() + // There is no need to include new line in an html-like source + .replace("\n", "") + } }