Merge pull request #2016 from famedly/krille/make-convert-linebreaks-optional

refactor: Make converting linebreaks in markdowntohtml optional
This commit is contained in:
Krille-chan 2025-02-03 12:05:21 +01:00 committed by GitHub
commit 3353518cad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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')) !=