@@ -304,23 +304,24 @@ class HtmlRichTextParser extends StatelessWidget {
304
304
305
305
// we might want to preserve internal whitespace
306
306
// empty strings of whitespace might be significant or not, condense it by default
307
- String finalText = parseContext.condenseWhitespace
308
- ? condenseHtmlWhitespace (node.text)
309
- : node.text;
310
-
311
- // if this is part of a string of spans, we will preserve leading
312
- // and trailing whitespace unless the previous character is whitespace
313
- if (parseContext.parentElement == null )
314
- finalText = finalText.trimLeft ();
315
- else if (parseContext.parentElement is TextSpan ||
316
- parseContext.parentElement is LinkTextSpan ) {
317
- String lastString = parseContext.parentElement.text ?? '' ;
318
- if (! parseContext.parentElement.children.isEmpty) {
319
- lastString = parseContext.parentElement.children.last.text;
307
+ String finalText = node.text;
308
+ if (parseContext.condenseWhitespace) {
309
+ finalText = condenseHtmlWhitespace (node.text);
310
+
311
+ // if this is part of a string of spans, we will preserve leading
312
+ // and trailing whitespace unless the previous character is whitespace
313
+ if (parseContext.parentElement == null )
314
+ finalText = finalText.trimLeft ();
315
+ else if (parseContext.parentElement is TextSpan ||
316
+ parseContext.parentElement is LinkTextSpan ) {
317
+ String lastString = parseContext.parentElement.text ?? '' ;
318
+ if (! parseContext.parentElement.children.isEmpty) {
319
+ lastString = parseContext.parentElement.children.last.text;
320
+ }
321
+ if (lastString == '' ||
322
+ lastString.endsWith (' ' ) ||
323
+ lastString.endsWith ('\n ' )) finalText = finalText.trimLeft ();
320
324
}
321
- if (lastString == '' ||
322
- lastString.endsWith (' ' ) ||
323
- lastString.endsWith ('\n ' )) finalText = finalText.trimLeft ();
324
325
}
325
326
326
327
// if the finalText is actually empty, just return
@@ -403,7 +404,7 @@ class HtmlRichTextParser extends StatelessWidget {
403
404
// OTHER ELEMENT NODES
404
405
else if (node is dom.Element ) {
405
406
assert (() {
406
- debugPrint ("Found ${node .localName }" );
407
+ // debugPrint("Found ${node.localName}");
407
408
// debugPrint(node.outerHtml);
408
409
return true ;
409
410
}());
0 commit comments