File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -523,13 +523,23 @@ class HtmlParser extends StatelessWidget {
523523 /// If the text is the first element in the current tree node list, it
524524 /// starts with a whitespace, it isn't a line break, and either the
525525 /// whitespace is unnecessary or it is a block element, delete it.
526+ ///
527+ /// We should also delete the whitespace at any point in the node list
528+ /// if the previous element is a <br> because that tag makes the element
529+ /// act like a block element.
526530 if (textIndex < 1
527531 && tree.text! .startsWith (' ' )
528532 && tree.element? .localName != "br"
529533 && (! keepLeadingSpace.data
530534 || BLOCK_ELEMENTS .contains (tree.element? .localName ?? "" ))
531535 ) {
532536 tree.text = tree.text! .replaceFirst (' ' , '' );
537+ } else if (textIndex >= 1
538+ && tree.text! .startsWith (' ' )
539+ && tree.element? .nodes[textIndex - 1 ] is dom.Element
540+ && (tree.element? .nodes[textIndex - 1 ] as dom.Element ).localName == "br"
541+ ) {
542+ tree.text = tree.text! .replaceFirst (' ' , '' );
533543 }
534544 /// If the text is the last element in the current tree node list, it isn't
535545 /// a line break, and the next text node starts with a whitespace,
You can’t perform that action at this time.
0 commit comments