#201 fix for hr (horizontal rule) when alongside other markup (#216)

This commit is contained in:
app17
2020-05-19 06:37:34 +01:00
committed by GitHub
parent 2ae7b6080a
commit 24066c45ec
2 changed files with 81 additions and 6 deletions

View File

@ -297,9 +297,8 @@ class MarkdownBuilder implements md.NodeVisitor {
child: child,
);
} else if (tag == 'hr') {
child = DecoratedBox(
decoration: styleSheet.horizontalRuleDecoration,
child: child,
child = Container(
decoration: styleSheet.horizontalRuleDecoration
);
}

View File

@ -148,11 +148,87 @@ void main() {
]);
});
testWidgets('Horizontal Rule', (WidgetTester tester) async {
await tester.pumpWidget(_boilerplate(const MarkdownBody(data: '-----')));
testWidgets('Horizontal Rule - 3 hyphen', (WidgetTester tester) async {
await tester.pumpWidget(
_boilerplate(MarkdownBody(
data: '---'))
);
final Iterable<Widget> widgets = tester.allWidgets;
_expectWidgetTypes(widgets, <Type>[Directionality, MarkdownBody, DecoratedBox, SizedBox]);
_expectWidgetTypes(widgets, <Type>[
Directionality,
MarkdownBody,
Container,
DecoratedBox,
Padding,
LimitedBox,
ConstrainedBox
]);
});
testWidgets('Horizontal Rule - 5 hyphen', (WidgetTester tester) async {
await tester.pumpWidget(
_boilerplate(MarkdownBody(
data: '-----'))
);
final Iterable<Widget> widgets = tester.allWidgets;
_expectWidgetTypes(widgets, <Type>[
Directionality,
MarkdownBody,
Container,
DecoratedBox,
Padding,
LimitedBox,
ConstrainedBox
]);
});
testWidgets('Horizontal Rule - 3 asterisk', (WidgetTester tester) async {
await tester.pumpWidget(
_boilerplate(MarkdownBody(
data: '* * *'))
);
final Iterable<Widget> widgets = tester.allWidgets;
_expectWidgetTypes(widgets, <Type>[
Directionality,
MarkdownBody,
Container,
DecoratedBox,
Padding,
LimitedBox,
ConstrainedBox
]);
});
testWidgets('Horizontal Rule * * * alongside text Markdown', (WidgetTester tester) async {
await tester.pumpWidget(_boilerplate(
MarkdownBody(data: '# h1\n ## h2\n* * *')));
final Iterable<Widget> widgets = tester.allWidgets;
_expectWidgetTypes(widgets, <Type>[
Directionality,
MarkdownBody,
Column,
Column,
Wrap,
RichText,
SizedBox,
Column,
Wrap,
RichText,
SizedBox,
Container,
DecoratedBox,
Padding,
LimitedBox,
ConstrainedBox]);
});
testWidgets('Scrollable wrapping', (WidgetTester tester) async {