Skip to content

Commit

Permalink
Merge pull request #2016 from famedly/krille/make-convert-linebreaks-…
Browse files Browse the repository at this point in the history
…optional

refactor: Make converting linebreaks in markdowntohtml optional
  • Loading branch information
krille-chan authored Feb 3, 2025
2 parents 0960e35 + 776e941 commit 3353518
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class Client extends MatrixApi {

String? get syncFilterId => _syncFilterId;

final bool convertLinebreaksInFormatting;

final ComputeCallback? compute;

@Deprecated('Use [nativeImplementations] instead')
Expand Down Expand Up @@ -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
/// <br/> tags:
this.convertLinebreaksInFormatting = true,
}) : syncFilter = syncFilter ??
Filter(
room: RoomFilter(
Expand Down
1 change: 1 addition & 0 deletions lib/src/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'<br />\n?'), '\n')) !=
Expand Down

0 comments on commit 3353518

Please sign in to comment.