Add line endings to HTML blocks (dart-lang/markdown#512)
* Add trailing line endings to HTML blocks
* Update stats
diff --git a/pkgs/markdown/lib/src/block_syntaxes/blockquote_syntax.dart b/pkgs/markdown/lib/src/block_syntaxes/blockquote_syntax.dart
index 439af43..afbe23a 100644
--- a/pkgs/markdown/lib/src/block_syntaxes/blockquote_syntax.dart
+++ b/pkgs/markdown/lib/src/block_syntaxes/blockquote_syntax.dart
@@ -91,6 +91,7 @@
// block quote.
// https://spec.commonmark.org/0.30/#example-93
disabledSetextHeading: _lazyContinuation,
+ parentSyntax: this,
);
return Element('blockquote', children);
diff --git a/pkgs/markdown/lib/src/block_syntaxes/html_block_syntax.dart b/pkgs/markdown/lib/src/block_syntaxes/html_block_syntax.dart
index a69cc3f..ff00850 100644
--- a/pkgs/markdown/lib/src/block_syntaxes/html_block_syntax.dart
+++ b/pkgs/markdown/lib/src/block_syntaxes/html_block_syntax.dart
@@ -7,6 +7,7 @@
import '../line.dart';
import '../patterns.dart';
import 'block_syntax.dart';
+import 'list_syntax.dart';
/// Parse HTML blocks.
// There are seven kinds of HTML block defined in the CommonMark spec:
@@ -89,8 +90,11 @@
final childLines = parseChildLines(parser);
var text = childLines.map((e) => e.content).join('\n').trimRight();
- if (parser.previousSyntax != null) {
+ if (parser.previousSyntax != null || parser.parentSyntax != null) {
text = '\n$text';
+ if (parser.parentSyntax is ListSyntax) {
+ text = '$text\n';
+ }
}
return Text(text);
diff --git a/pkgs/markdown/test/common_mark/html_blocks.unit b/pkgs/markdown/test/common_mark/html_blocks.unit
index 9986356..3a01cd0 100644
--- a/pkgs/markdown/test/common_mark/html_blocks.unit
+++ b/pkgs/markdown/test/common_mark/html_blocks.unit
@@ -251,7 +251,8 @@
bar
<<<
-<blockquote><div>
+<blockquote>
+<div>
foo
</blockquote>
<p>bar</p>
@@ -260,7 +261,9 @@
- foo
<<<
<ul>
-<li><div></li>
+<li>
+<div>
+</li>
<li>foo</li>
</ul>
>>> HTML blocks - 176
diff --git a/pkgs/markdown/test/gfm/html_blocks.unit b/pkgs/markdown/test/gfm/html_blocks.unit
index 0799464..1af6420 100644
--- a/pkgs/markdown/test/gfm/html_blocks.unit
+++ b/pkgs/markdown/test/gfm/html_blocks.unit
@@ -235,7 +235,8 @@
bar
<<<
-<blockquote><div>
+<blockquote>
+<div>
foo
</blockquote>
<p>bar</p>
@@ -244,7 +245,9 @@
- foo
<<<
<ul>
-<li><div></li>
+<li>
+<div>
+</li>
<li>foo</li>
</ul>
>>> HTML blocks - 145
diff --git a/pkgs/markdown/tool/common_mark_stats.json b/pkgs/markdown/tool/common_mark_stats.json
index 46a84ed..1ab5e64 100644
--- a/pkgs/markdown/tool/common_mark_stats.json
+++ b/pkgs/markdown/tool/common_mark_stats.json
@@ -336,8 +336,8 @@
"171": "strict",
"172": "strict",
"173": "strict",
- "174": "loose",
- "175": "loose",
+ "174": "strict",
+ "175": "strict",
"176": "strict",
"177": "strict",
"178": "strict",
diff --git a/pkgs/markdown/tool/common_mark_stats.txt b/pkgs/markdown/tool/common_mark_stats.txt
index 541bd6a..ad18014 100644
--- a/pkgs/markdown/tool/common_mark_stats.txt
+++ b/pkgs/markdown/tool/common_mark_stats.txt
@@ -25,4 +25,4 @@
3 of 3 – 100.0% Textual content
19 of 19 – 100.0% Thematic breaks
652 of 652 – 100.0% TOTAL
- 644 of 652 – 98.8% TOTAL Strict
+ 646 of 652 – 99.1% TOTAL Strict
diff --git a/pkgs/markdown/tool/gfm_stats.json b/pkgs/markdown/tool/gfm_stats.json
index e6409e6..93c0cab 100644
--- a/pkgs/markdown/tool/gfm_stats.json
+++ b/pkgs/markdown/tool/gfm_stats.json
@@ -351,8 +351,8 @@
"140": "strict",
"141": "strict",
"142": "strict",
- "143": "loose",
- "144": "loose",
+ "143": "strict",
+ "144": "strict",
"145": "strict",
"146": "strict",
"147": "strict",
diff --git a/pkgs/markdown/tool/gfm_stats.txt b/pkgs/markdown/tool/gfm_stats.txt
index 4f0014e..06e240b 100644
--- a/pkgs/markdown/tool/gfm_stats.txt
+++ b/pkgs/markdown/tool/gfm_stats.txt
@@ -29,4 +29,4 @@
3 of 3 – 100.0% Textual content
19 of 19 – 100.0% Thematic breaks
670 of 670 – 100.0% TOTAL
- 658 of 670 – 98.2% TOTAL Strict
+ 660 of 670 – 98.5% TOTAL Strict