Skip to content

Commit 7f64980

Browse files
committed
fixed section title whitespace
1 parent c840365 commit 7f64980

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

lib/markup/widget/section.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SectionWrap extends StatelessWidget {
2424
header: Padding(
2525
padding: const EdgeInsets.all(8),
2626
child: Text(
27-
title?.replaceAll('\n', ' ') ?? '',
27+
title?.replaceAll(RegExp(r'\s+'), ' ').trim() ?? '',
2828
maxLines: 1,
2929
overflow: TextOverflow.ellipsis,
3030
style: const TextStyle(fontSize: 16),

test/markup/widgets/dtext_body_test.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,25 @@ void main() {
122122
expect(find.textContaining('inside'), findsOneWidget);
123123
});
124124

125+
testWidgets('section title collapses whitespace', (tester) async {
126+
await tester.pumpWidget(
127+
_wrap(
128+
const DTextBody(
129+
content: DTextDocument([
130+
DTextSection(
131+
title: ' Ember pre-rust (2024)\n - by tester ',
132+
expanded: true,
133+
children: [
134+
DTextParagraph([DTextText('inside')]),
135+
],
136+
),
137+
]),
138+
),
139+
),
140+
);
141+
expect(find.text('Ember pre-rust (2024) - by tester'), findsOneWidget);
142+
});
143+
125144
testWidgets('list renders each item with bullet', (tester) async {
126145
await tester.pumpWidget(
127146
_wrap(

0 commit comments

Comments
 (0)