Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions packages/flutter_markdown/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.18+2

* Removes leading whitespace from list items.

## 0.6.18+1

* Fixes a typo in README.
Expand Down
3 changes: 2 additions & 1 deletion packages/flutter_markdown/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ class MarkdownBuilder implements md.NodeVisitor {
// Leading spaces in paragraph or list item are ignored
// https://github.github.com/gfm/#example-192
// https://github.github.com/gfm/#example-236
if (const <String>['ul', 'ol', 'p', 'br'].contains(_lastVisitedTag)) {
if (const <String>['ul', 'ol', 'li', 'p', 'br']
.contains(_lastVisitedTag)) {
text = text.replaceAll(leadingSpacesPattern, '');
}

Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_markdown/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A Markdown renderer for Flutter. Create rich text output,
formatted with simple Markdown tags.
repository: https://github.com/flutter/packages/tree/main/packages/flutter_markdown
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_markdown%22
version: 0.6.18+1
version: 0.6.18+2

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down
22 changes: 22 additions & 0 deletions packages/flutter_markdown/test/list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ void defineTests() {
'two',
]);
});

testWidgets(
'leading spaces are ignored (non-paragraph test case)',
(WidgetTester tester) async {
const String data = '- one\n- two\n- three';
await tester.pumpWidget(
boilerplate(
const MarkdownBody(data: data),
),
);

final Iterable<Widget> widgets = tester.allWidgets;
expectTextStrings(widgets, <String>[
'•',
'one',
'•',
'two',
'•',
'three',
]);
},
);
});

group('Ordered List', () {
Expand Down