From bddf5874d441dcdf20e4e6826601978a770d7514 Mon Sep 17 00:00:00 2001 From: Rico Berger Date: Sat, 2 Dec 2023 17:58:44 +0100 Subject: [PATCH] [core] Fix Converting of HTML to Plain Text in Description (#96) This commit fixes the conversion of HTML to plain text in the description for an item. Until now it could happen, that the there was no whitespace between some words after the conversion. This is now fixed so that there is always a whitespace between words in the plain text. --- app/lib/widgets/item/details/utils/item_description.dart | 4 +++- app/lib/widgets/item/preview/utils/item_description.dart | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/lib/widgets/item/details/utils/item_description.dart b/app/lib/widgets/item/details/utils/item_description.dart index 9741eae..017dd0b 100644 --- a/app/lib/widgets/item/details/utils/item_description.dart +++ b/app/lib/widgets/item/details/utils/item_description.dart @@ -158,7 +158,9 @@ class ItemDescription extends StatelessWidget { if (sourceFormat == DescriptionFormat.html && tagetFormat == DescriptionFormat.plain) { return _buildPlain( - itemDescription!.replaceAll(RegExp(r'<[^>]*>|&[^;]+;'), ''), + itemDescription! + .replaceAll(RegExp(r'<[^>]*>|&[^;]+;'), ' ') + .replaceAll(RegExp('\\s+'), ' '), ); } diff --git a/app/lib/widgets/item/preview/utils/item_description.dart b/app/lib/widgets/item/preview/utils/item_description.dart index 8147304..051ff40 100644 --- a/app/lib/widgets/item/preview/utils/item_description.dart +++ b/app/lib/widgets/item/preview/utils/item_description.dart @@ -125,7 +125,9 @@ class ItemDescription extends StatelessWidget { if (sourceFormat == DescriptionFormat.html && tagetFormat == DescriptionFormat.plain) { return _buildPlain( - itemDescription!.replaceAll(RegExp(r'<[^>]*>|&[^;]+;'), ''), + itemDescription! + .replaceAll(RegExp(r'<[^>]*>|&[^;]+;'), ' ') + .replaceAll(RegExp('\\s+'), ' '), ); }