Skip to content

[flutter_markdown] Soft wrapping in blockquotes #7848

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

Merged
merged 4 commits into from
Oct 13, 2024
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.7.4

* Makes paragraphs in blockquotes soft-wrap like a normal `<blockquote>` instead of hard-wrapping like a `<pre>` block.

## 0.7.3+2

* Resolves an issue where code blocks in markdown were not highlighted during selection.
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_markdown/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class MarkdownBuilder implements md.NodeVisitor {
style: _isInBlockquote
? styleSheet.blockquote!.merge(_inlines.last.style)
: _inlines.last.style,
text: _isInBlockquote ? text.text : trimText(text.text),
text: trimText(text.text),
recognizer: _linkHandlers.isNotEmpty ? _linkHandlers.last : null,
),
textAlign: _textAlignForBlockTag(_currentBlockTag),
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.7.3+2
version: 0.7.4

environment:
sdk: ^3.3.0
Expand Down
14 changes: 14 additions & 0 deletions packages/flutter_markdown/test/blockquote_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ void defineTests() {
},
);

testWidgets(
'soft wrapping in blockquote',
(WidgetTester tester) async {
await tester.pumpWidget(
boilerplate(
const MarkdownBody(data: '> soft\n> wrap'),
),
);

final Iterable<Widget> widgets = tester.allWidgets;
expectTextStrings(widgets, <String>['soft wrap']);
},
);

testWidgets(
'should work with styling',
(WidgetTester tester) async {
Expand Down