Fix leading whitespace after hard break (#348)
diff --git a/lib/src/html_renderer.dart b/lib/src/html_renderer.dart
index 78ce279..761442d 100644
--- a/lib/src/html_renderer.dart
+++ b/lib/src/html_renderer.dart
@@ -37,7 +37,7 @@
}
/// Renders [nodes] to HTML.
-String renderToHtml(List<Node?> nodes) => HtmlRenderer().render(nodes);
+String renderToHtml(List<Node> nodes) => HtmlRenderer().render(nodes);
const _blockTags = [
'blockquote',
@@ -82,12 +82,12 @@
HtmlRenderer();
- String render(List<Node?> nodes) {
+ String render(List<Node> nodes) {
buffer = StringBuffer();
uniqueIds = <String>{};
for (final node in nodes) {
- node!.accept(this);
+ node.accept(this);
}
return buffer.toString();
@@ -96,7 +96,7 @@
@override
void visitText(Text text) {
var content = text.text;
- if (const ['p', 'li'].contains(_lastVisitedTag)) {
+ if (const ['br', 'p', 'li'].contains(_lastVisitedTag)) {
var lines = LineSplitter.split(content);
content = content.contains('<pre>')
? lines.join('\n')
diff --git a/test/common_mark/hard_line_breaks.unit b/test/common_mark/hard_line_breaks.unit
index ebf2c4b..a8de1e7 100644
--- a/test/common_mark/hard_line_breaks.unit
+++ b/test/common_mark/hard_line_breaks.unit
@@ -21,13 +21,13 @@
bar
<<<
<p>foo<br />
- bar</p>
+bar</p>
>>> Hard line breaks - 634
foo\
bar
<<<
<p>foo<br />
- bar</p>
+bar</p>
>>> Hard line breaks - 635
*foo
bar*
diff --git a/test/gfm/hard_line_breaks.unit b/test/gfm/hard_line_breaks.unit
index 17c31f0..13e42a5 100644
--- a/test/gfm/hard_line_breaks.unit
+++ b/test/gfm/hard_line_breaks.unit
@@ -21,13 +21,13 @@
bar
<<<
<p>foo<br />
- bar</p>
+bar</p>
>>> Hard line breaks - 658
foo\
bar
<<<
<p>foo<br />
- bar</p>
+bar</p>
>>> Hard line breaks - 659
*foo
bar*
diff --git a/tool/common_mark_stats.json b/tool/common_mark_stats.json
index 1248096..46f7044 100644
--- a/tool/common_mark_stats.json
+++ b/tool/common_mark_stats.json
@@ -296,8 +296,8 @@
"630": "strict",
"631": "strict",
"632": "strict",
- "633": "loose",
- "634": "loose",
+ "633": "strict",
+ "634": "strict",
"635": "strict",
"636": "strict",
"637": "strict",
diff --git a/tool/common_mark_stats.txt b/tool/common_mark_stats.txt
index 1523784..2a5cc91 100644
--- a/tool/common_mark_stats.txt
+++ b/tool/common_mark_stats.txt
@@ -25,4 +25,4 @@
3 of 3 – 100.0% Textual content
19 of 19 – 100.0% Thematic breaks
610 of 649 – 94.0% TOTAL
- 541 of 610 – 88.7% TOTAL Strict
+ 543 of 610 – 89.0% TOTAL Strict
diff --git a/tool/gfm_stats.json b/tool/gfm_stats.json
index 465a830..91699ff 100644
--- a/tool/gfm_stats.json
+++ b/tool/gfm_stats.json
@@ -312,8 +312,8 @@
"654": "strict",
"655": "strict",
"656": "strict",
- "657": "loose",
- "658": "loose",
+ "657": "strict",
+ "658": "strict",
"659": "strict",
"660": "strict",
"661": "strict",
diff --git a/tool/gfm_stats.txt b/tool/gfm_stats.txt
index 4e04e48..c1e1819 100644
--- a/tool/gfm_stats.txt
+++ b/tool/gfm_stats.txt
@@ -29,4 +29,4 @@
3 of 3 – 100.0% Textual content
19 of 19 – 100.0% Thematic breaks
625 of 671 – 93.1% TOTAL
- 547 of 625 – 87.5% TOTAL Strict
+ 549 of 625 – 87.8% TOTAL Strict