File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -625,8 +625,10 @@ class HtmlParser extends StatelessWidget {
625625 parentAfterText = parentAfter? .text ?? " " ;
626626 }
627627 /// If the text is the first element in the current tree node list, it
628- /// starts with a whitespace, it isn't a line break, and either the
629- /// whitespace is unnecessary or it is a block element, delete it.
628+ /// starts with a whitespace, it isn't a line break, either the
629+ /// whitespace is unnecessary or it is a block element, and either it is
630+ /// first element in the parent node list or the previous element
631+ /// in the parent node list ends with a whitespace, delete it.
630632 ///
631633 /// We should also delete the whitespace at any point in the node list
632634 /// if the previous element is a <br> because that tag makes the element
@@ -636,6 +638,10 @@ class HtmlParser extends StatelessWidget {
636638 && tree.element? .localName != "br"
637639 && (! keepLeadingSpace.data
638640 || BLOCK_ELEMENTS .contains (tree.element? .localName ?? "" ))
641+ && (elementIndex < 1
642+ || (elementIndex >= 1
643+ && parentNodes? [elementIndex - 1 ] is dom.Text
644+ && parentNodes! [elementIndex - 1 ].text! .endsWith (" " )))
639645 ) {
640646 tree.text = tree.text! .replaceFirst (' ' , '' );
641647 } else if (textIndex >= 1
You can’t perform that action at this time.
0 commit comments