refactor: Make converting linebreaks in markdowntohtml optional

Element actually does not do
this and use the linebreaks
inside of their <p> tags. It
works for our new html
rendering as well which is
already in FluffyChat.
This commit is contained in:
Krille 2025-02-03 11:48:10 +01:00
parent 0960e350db
commit 776e941b6e
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
2 changed files with 7 additions and 0 deletions

View File

@ -107,6 +107,8 @@ class Client extends MatrixApi {
String? get syncFilterId => _syncFilterId; String? get syncFilterId => _syncFilterId;
final bool convertLinebreaksInFormatting;
final ComputeCallback? compute; final ComputeCallback? compute;
@Deprecated('Use [nativeImplementations] instead') @Deprecated('Use [nativeImplementations] instead')
@ -233,6 +235,10 @@ class Client extends MatrixApi {
/// support. /// support.
this.customRefreshTokenLifetime, this.customRefreshTokenLifetime,
this.typingIndicatorTimeout = const Duration(seconds: 30), this.typingIndicatorTimeout = const Duration(seconds: 30),
/// When sending a formatted message, converting linebreaks in markdown to
/// <br/> tags:
this.convertLinebreaksInFormatting = true,
}) : syncFilter = syncFilter ?? }) : syncFilter = syncFilter ??
Filter( Filter(
room: RoomFilter( room: RoomFilter(

View File

@ -646,6 +646,7 @@ class Room {
event['body'], event['body'],
getEmotePacks: () => getImagePacksFlat(ImagePackUsage.emoticon), getEmotePacks: () => getImagePacksFlat(ImagePackUsage.emoticon),
getMention: getMention, 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 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'<br />\n?'), '\n')) != if (HtmlUnescape().convert(html.replaceAll(RegExp(r'<br />\n?'), '\n')) !=