From 35cb60247915bca63e152baa97c431d0df472d68 Mon Sep 17 00:00:00 2001 From: Arjan Mels Date: Fri, 19 May 2023 13:12:44 +0200 Subject: [PATCH 1/2] Mark Summary and Details as block items --- lib/src/builtins/styled_element_builtin.dart | 10 ++++++++ test/whitespace_test.dart | 26 ++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/lib/src/builtins/styled_element_builtin.dart b/lib/src/builtins/styled_element_builtin.dart index 08a9f49db1..56eeb6f5ae 100644 --- a/lib/src/builtins/styled_element_builtin.dart +++ b/lib/src/builtins/styled_element_builtin.dart @@ -172,6 +172,11 @@ class StyledElementBuiltIn extends HtmlExtension { textDecoration: TextDecoration.lineThrough, ); break; + case "details": + styledElement.style = Style( + display: Display.block, + ); + break; case "dfn": continue italics; case "div": @@ -392,6 +397,11 @@ class StyledElementBuiltIn extends HtmlExtension { verticalAlign: VerticalAlign.sub, ); break; + case "summary": + styledElement.style = Style( + display: Display.block, + ); + break; case "sup": styledElement.style = Style( fontSize: FontSize.smaller, diff --git a/test/whitespace_test.dart b/test/whitespace_test.dart index 39fe5fc42e..640ceed929 100644 --- a/test/whitespace_test.dart +++ b/test/whitespace_test.dart @@ -66,6 +66,32 @@ void main() { }, ); + //See https://github.com/Sub6Resources/flutter_html/issues/1275 + testWidgets( + "test that extra newlines aren't added unnecessarily for details/summary tags", + (tester) async { + final tree = await generateStyledElementTreeFromHtml( + tester, + html: """ + + + +
+

Header

+

These are the details.

+
+ + +""", + ); + + expect( + tree.getWhitespace(), + equals( + "

Header

These◦are◦the◦details.

")); + }, + ); + // See https://github.com/Sub6Resources/flutter_html/issues/1251 testWidgets( 'test that preserved whitespace is actually preserved', From 6b7c7b2dac11d94bcea359e737e52e39cf50fd79 Mon Sep 17 00:00:00 2001 From: Arjan Mels Date: Thu, 25 May 2023 20:51:16 +0200 Subject: [PATCH 2/2] Removed styled for summary --- lib/src/builtins/styled_element_builtin.dart | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/src/builtins/styled_element_builtin.dart b/lib/src/builtins/styled_element_builtin.dart index 56eeb6f5ae..48ba02fc64 100644 --- a/lib/src/builtins/styled_element_builtin.dart +++ b/lib/src/builtins/styled_element_builtin.dart @@ -172,11 +172,6 @@ class StyledElementBuiltIn extends HtmlExtension { textDecoration: TextDecoration.lineThrough, ); break; - case "details": - styledElement.style = Style( - display: Display.block, - ); - break; case "dfn": continue italics; case "div":