From 776e941b6ec8f624d6185ee6abbbfe4da31ebb72 Mon Sep 17 00:00:00 2001 From: Krille Date: Mon, 3 Feb 2025 11:48:10 +0100 Subject: [PATCH] refactor: Make converting linebreaks in markdowntohtml optional Element actually does not do this and use the linebreaks inside of their

tags. It works for our new html rendering as well which is already in FluffyChat. --- lib/src/client.dart | 6 ++++++ lib/src/room.dart | 1 + 2 files changed, 7 insertions(+) diff --git a/lib/src/client.dart b/lib/src/client.dart index c9ed118a..dcce1069 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -107,6 +107,8 @@ class Client extends MatrixApi { String? get syncFilterId => _syncFilterId; + final bool convertLinebreaksInFormatting; + final ComputeCallback? compute; @Deprecated('Use [nativeImplementations] instead') @@ -233,6 +235,10 @@ class Client extends MatrixApi { /// support. this.customRefreshTokenLifetime, this.typingIndicatorTimeout = const Duration(seconds: 30), + + /// When sending a formatted message, converting linebreaks in markdown to + ///
tags: + this.convertLinebreaksInFormatting = true, }) : syncFilter = syncFilter ?? Filter( room: RoomFilter( diff --git a/lib/src/room.dart b/lib/src/room.dart index a5600619..59cff938 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -646,6 +646,7 @@ class Room { event['body'], getEmotePacks: () => getImagePacksFlat(ImagePackUsage.emoticon), getMention: getMention, + convertLinebreaks: client.convertLinebreaksInFormatting, ); // if the decoded html is the same as the body, there is no need in sending a formatted message if (HtmlUnescape().convert(html.replaceAll(RegExp(r'
\n?'), '\n')) !=