From 2bc54cb1af52c4295b1c339c824eaf40bd8f7021 Mon Sep 17 00:00:00 2001 From: olorin99 Date: Wed, 2 Sep 2026 13:28:37 +1000 Subject: [PATCH] Skip parsing post as markdown if content is too long and has no whitespace. --- lib/src/widgets/content_item/content_item.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/src/widgets/content_item/content_item.dart b/lib/src/widgets/content_item/content_item.dart index 58bdd850..0b5e9647 100644 --- a/lib/src/widgets/content_item/content_item.dart +++ b/lib/src/widgets/content_item/content_item.dart @@ -651,9 +651,15 @@ class _ContentItemState extends State { widget.isNSFW && context.read().profile.coverMediaMarkedSensitive; + // If post body is long and has no whitespace just skip markdown rendering. It gets bogged down parsing it otherwise. + final renderAsMarkdown = + !widget.isPreview && + !((widget.body?.length ?? 0) > 10000 && + !RegExp(r'\s').hasMatch(widget.body ?? '')); + return widget.translation != null // A translation is available - ? widget.isPreview + ? !renderAsMarkdown ? Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -703,7 +709,7 @@ class _ContentItemState extends State { ], ) // No translation is available - : widget.isPreview + : !renderAsMarkdown ? Text(widget.body!, maxLines: 4, overflow: TextOverflow.ellipsis) : Markdown(widget.body!, widget.originInstance, nsfw: isNSFW); }