Skip to content

Mark Summary and Details as block items #1276

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 3 commits into from
May 26, 2023
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
5 changes: 5 additions & 0 deletions lib/src/builtins/styled_element_builtin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,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,
Expand Down
26 changes: 26 additions & 0 deletions test/whitespace_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: """
<!DOCTYPE html>
<html>
<body>
<details>
<summary><h1>Header</h1></summary>
<p>These are the details.</p>
</details>
</body>
</html>
""",
);

expect(
tree.getWhitespace(),
equals(
"<body><details><summary><h1>Header</h1></summary><p>These◦are◦the◦details.</p></details></body>"));
},
);

// See https://github.com/Sub6Resources/flutter_html/issues/1251
testWidgets(
'test that preserved whitespace is actually preserved',
Expand Down