[flutter_markdown] Require pkg:markdown v7.0.0 ()

* [flutter_markdown] Require pkg:markdown v7.0.0

Remove code that supports markdown ^6.0.0

Closes https://github.com/flutter/flutter/issues/120486

* remove comment

* whitespace silly
This commit is contained in:
Kevin Moore
2023-02-11 15:31:28 -08:00
committed by GitHub
parent 6e00c2b7e2
commit 0fe1b4448f
8 changed files with 59 additions and 176 deletions

@ -1,3 +1,7 @@
## 0.6.14
* Require `markdown: ^7.0.0`
## 0.6.13+1 ## 0.6.13+1
* Adjusts code to account for nullability change in Flutter SDK. * Adjusts code to account for nullability change in Flutter SDK.

@ -11,7 +11,7 @@ dependencies:
sdk: flutter sdk: flutter
flutter_markdown: flutter_markdown:
path: ../ path: ../
markdown: ^6.0.0 markdown: ^7.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

@ -470,11 +470,6 @@ class MarkdownBuilder implements md.NodeVisitor {
current.children.add(_buildRichText(const TextSpan(text: '\n'))); current.children.add(_buildRichText(const TextSpan(text: '\n')));
} else if (tag == 'th' || tag == 'td') { } else if (tag == 'th' || tag == 'td') {
TextAlign? align; TextAlign? align;
// `style` was using in pkg:markdown <= 6.0.1
// Can be removed when min pkg:markedwn > 6.0.1
final String? style = element.attributes['style'];
if (style == null) {
// `align` is using in pkg:markdown > 6.0.1
final String? alignAttribute = element.attributes['align']; final String? alignAttribute = element.attributes['align'];
if (alignAttribute == null) { if (alignAttribute == null) {
align = tag == 'th' ? styleSheet.tableHeadAlign : TextAlign.left; align = tag == 'th' ? styleSheet.tableHeadAlign : TextAlign.left;
@ -491,21 +486,6 @@ class MarkdownBuilder implements md.NodeVisitor {
break; break;
} }
} }
} else {
final RegExp regExp = RegExp(r'text-align: (left|center|right)');
final Match match = regExp.matchAsPrefix(style)!;
switch (match[1]) {
case 'left':
align = TextAlign.left;
break;
case 'center':
align = TextAlign.center;
break;
case 'right':
align = TextAlign.right;
break;
}
}
final Widget child = _buildTableCell( final Widget child = _buildTableCell(
_mergeInlineChildren(current.children, align), _mergeInlineChildren(current.children, align),
textAlign: align, textAlign: align,

@ -4,7 +4,7 @@ description: A Markdown renderer for Flutter. Create rich text output,
formatted with simple Markdown tags. formatted with simple Markdown tags.
repository: https://github.com/flutter/packages/tree/main/packages/flutter_markdown 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 issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_markdown%22
version: 0.6.13+1 version: 0.6.14
environment: environment:
sdk: ">=2.12.0 <3.0.0" sdk: ">=2.12.0 <3.0.0"
@ -13,7 +13,7 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
markdown: ^6.0.0 markdown: ^7.0.0
meta: ^1.3.0 meta: ^1.3.0
path: ^1.8.0 path: ^1.8.0

@ -629,13 +629,7 @@ void defineTests() {
); );
expectValidLink('link'); expectValidLink('link');
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expectLinkTap(linkTapResults, const MarkdownLink('link', 'foo\bar'));
} else {
// For pkg:markdown > v6.0.1
expectLinkTap(linkTapResults, const MarkdownLink('link', 'foo%08ar')); expectLinkTap(linkTapResults, const MarkdownLink('link', 'foo%08ar'));
}
}, },
); );
@ -656,15 +650,8 @@ void defineTests() {
); );
expectValidLink('link'); expectValidLink('link');
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expectLinkTap(
linkTapResults, const MarkdownLink('link', 'foo%20b&auml;'));
} else {
// For pkg:markdown > v6.0.1
expectLinkTap( expectLinkTap(
linkTapResults, const MarkdownLink('link', 'foo%20b%C3%A4')); linkTapResults, const MarkdownLink('link', 'foo%20b%C3%A4'));
}
}, },
); );
@ -773,15 +760,8 @@ void defineTests() {
); );
expectValidLink('link'); expectValidLink('link');
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url', 'title %22&quot;'));
} else {
// For pkg:markdown > v6.0.1
expectLinkTap(linkTapResults, expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url', 'title &quot;&quot;')); const MarkdownLink('link', '/url', 'title &quot;&quot;'));
}
}, },
); );
@ -802,15 +782,8 @@ void defineTests() {
); );
expectValidLink('link'); expectValidLink('link');
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url\u{C2A0}%22title%22'));
} else {
// For pkg:markdown > v6.0.1
expectLinkTap(linkTapResults, expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url%EC%8A%A0%22title%22')); const MarkdownLink('link', '/url%EC%8A%A0%22title%22'));
}
}, },
); );
@ -853,17 +826,10 @@ void defineTests() {
); );
expectValidLink('link'); expectValidLink('link');
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url', 'title %22and%22 title'));
} else {
// For pkg:markdown > v6.0.1
expectLinkTap( expectLinkTap(
linkTapResults, linkTapResults,
const MarkdownLink('link', '/url', 'title &quot;and&quot; title'), const MarkdownLink('link', '/url', 'title &quot;and&quot; title'),
); );
}
}, },
); );

@ -5,6 +5,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'utils.dart'; import 'utils.dart';
void main() => defineTests(); void main() => defineTests();
@ -86,22 +87,6 @@ void defineTests() {
); );
final Iterable<Widget> widgets = tester.allWidgets; final Iterable<Widget> widgets = tester.allWidgets;
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expectTextStrings(widgets, <String>[
'1.',
'Item 1',
'2.',
'Item 2',
'3.',
'Item 3',
'10.',
'Item 10',
'11.',
'Item 11'
]);
} else {
// For pkg:markdown > v6.0.1
expectTextStrings(widgets, <String>[ expectTextStrings(widgets, <String>[
'1.', '1.',
'Item 1', 'Item 1',
@ -114,7 +99,6 @@ void defineTests() {
'5.', '5.',
'Item 11' 'Item 11'
]); ]);
}
}, },
); );

@ -391,29 +391,6 @@ void defineTests() {
expectTableSize(3, 2); expectTableSize(3, 2);
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expect(find.byType(RichText), findsNWidgets(6));
final List<String?> text = find
.byType(RichText)
.evaluate()
.map((Element e) => e.widget)
.cast<RichText>()
.map((RichText richText) => richText.text)
.cast<TextSpan>()
.map((TextSpan e) => e.text)
.toList();
expect(text[0], 'abc');
expect(text[1], 'def');
expect(text[2], 'bar');
expect(text[3], 'baz');
expect(text[4], 'bar');
expect(table.defaultColumnWidth, columnWidth);
// Paragraph text
expect(text[5], 'bar');
} else {
// For pkg:markdown > v6.0.1
expect(find.byType(RichText), findsNWidgets(7)); expect(find.byType(RichText), findsNWidgets(7));
final List<String?> text = find final List<String?> text = find
.byType(RichText) .byType(RichText)
@ -424,10 +401,8 @@ void defineTests() {
.cast<TextSpan>() .cast<TextSpan>()
.map((TextSpan e) => e.text) .map((TextSpan e) => e.text)
.toList(); .toList();
expect( expect(text, <String>['abc', 'def', 'bar', 'baz', 'bar', '', 'bar']);
text, <String>['abc', 'def', 'bar', 'baz', 'bar', '', 'bar']);
expect(table.defaultColumnWidth, columnWidth); expect(table.defaultColumnWidth, columnWidth);
}
}, },
); );
@ -460,7 +435,6 @@ void defineTests() {
.toList(); .toList();
expect(text[0], '| abc | def | | --- | | bar |'); expect(text[0], '| abc | def | | --- | | bar |');
}, },
skip: !newMarkdown,
); );
testWidgets( testWidgets(
@ -485,26 +459,6 @@ void defineTests() {
expectTableSize(3, 2); expectTableSize(3, 2);
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expect(find.byType(RichText), findsNWidgets(5));
final List<String?> cellText = find
.byType(RichText)
.evaluate()
.map((Element e) => e.widget)
.cast<RichText>()
.map((RichText richText) => richText.text)
.cast<TextSpan>()
.map((TextSpan e) => e.text)
.toList();
expect(cellText[0], 'abc');
expect(cellText[1], 'def');
expect(cellText[2], 'bar');
expect(cellText[3], 'bar');
expect(cellText[4], 'baz');
expect(table.defaultColumnWidth, columnWidth);
} else {
// For pkg:markdown > v6.0.1
expect(find.byType(RichText), findsNWidgets(6)); expect(find.byType(RichText), findsNWidgets(6));
final List<String?> cellText = find final List<String?> cellText = find
.byType(RichText) .byType(RichText)
@ -517,7 +471,6 @@ void defineTests() {
.toList(); .toList();
expect(cellText, <String>['abc', 'def', 'bar', '', 'bar', 'baz']); expect(cellText, <String>['abc', 'def', 'bar', '', 'bar', 'baz']);
expect(table.defaultColumnWidth, columnWidth); expect(table.defaultColumnWidth, columnWidth);
}
}, },
); );

@ -9,10 +9,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:markdown/markdown.dart' as md show version;
// TODO(Zhiguang): delete this once the min version of pkg:markdown is updated
final bool newMarkdown = md.version.compareTo('6.0.1') > 0;
final TextTheme textTheme = Typography.material2018() final TextTheme textTheme = Typography.material2018()
.black .black