diff --git a/lib/html_parser.dart b/lib/html_parser.dart index 562833981f..2b8d68f0f2 100644 --- a/lib/html_parser.dart +++ b/lib/html_parser.dart @@ -888,7 +888,9 @@ class HtmlParser extends StatelessWidget { tree.children.forEach((child) { if (child is EmptyContentElement || child is EmptyLayoutElement) { toRemove.add(child); - } else if (child is TextContentElement && (child.text!.trim().isEmpty)) { + } else if (child is TextContentElement + && child.text!.trim().isEmpty + && child.style.whiteSpace != WhiteSpace.PRE) { toRemove.add(child); } else if (child is TextContentElement && child.style.whiteSpace != WhiteSpace.PRE &&