Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extra space with consecutive <br> tags #1286

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/core/lib/src/internal/ops/tag_br.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ class TagBrBit extends BuildBit {
BuildBit copyWith({BuildTree? parent}) => TagBrBit(parent ?? this.parent);

@override
void flatten(Flattened f) => f.write(text: '\n');
void flatten(Flattened f) {
final previousBit = parent.bits.isNotEmpty ? parent.bits.last : null;
if (previousBit is TagBrBit) {
// Do not add extra space if the previous bit is also a <br> tag
return;
}

f.write(text: '\n');
}

@override
String toString() => '<BR />';
Expand Down
Loading