Nested brackets (#215)
Support nested brackets in links
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bff8268..d1eaab8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,11 +7,13 @@
* **Breaking change:** Make all of the fields on `Document` read-only.
* Overhaul support for emphasis (`*foo*` and `_foo_`) and strong emphasis
(`**foo**` and `__foo__`), dramatically improving CommonMark compliance.
+* Overhaul support for links and images, again dramatically improving CommonMark
+ compliance.
* Improve support for tab characters, and horizontal rules.
* Add support for GitHub Flavored Markdown's Strikethrough extension. See the
[GFM spec][strikethrough].
-* The above fixes raise compliance with the CommonMark specs to 90%, and
- compliance with the GFM specs to 87%.
+* The above fixes raise compliance with the CommonMark specs to 93%, and
+ compliance with the GFM specs to 92%.
* Allow the binary script to take a `--extension-set` option.
A reminder: You can [run `bin/markdown.dart` from anywhere][pub-global] via:
diff --git a/lib/src/inline_parser.dart b/lib/src/inline_parser.dart
index 4242d0b..29c8a5d 100644
--- a/lib/src/inline_parser.dart
+++ b/lib/src/inline_parser.dart
@@ -1176,14 +1176,16 @@
// If the stack is empty now, this is the special "results" node.
if (parser._stack.length == 0) return children;
+ var endMatchIndex = parser.pos;
// We are still parsing, so add this to its parent's children.
if (syntax.onMatchEnd(parser, endMatch, this)) {
parser.consume(endMatch[0].length);
} else {
// Didn't close correctly so revert to text.
- parser.start = startPos;
- parser.pos = parser.start;
+ parser.writeTextRange(startPos, endPos);
+ parser._stack.last.children.addAll(children);
+ parser.pos = endMatchIndex;
parser.advanceBy(endMatch[0].length);
}
diff --git a/tool/common_mark_stats.json b/tool/common_mark_stats.json
index 4916da7..505167a 100644
--- a/tool/common_mark_stats.json
+++ b/tool/common_mark_stats.json
@@ -431,7 +431,7 @@
"480": "fail",
"481": "strict",
"482": "strict",
- "483": "fail",
+ "483": "strict",
"484": "strict",
"485": "strict",
"486": "strict",
@@ -439,7 +439,7 @@
"488": "loose",
"489": "strict",
"490": "strict",
- "491": "fail",
+ "491": "loose",
"492": "fail",
"493": "strict",
"494": "strict",
@@ -447,7 +447,7 @@
"496": "strict",
"497": "strict",
"498": "strict",
- "499": "loose",
+ "499": "strict",
"500": "strict",
"501": "strict",
"502": "loose",
diff --git a/tool/common_mark_stats.txt b/tool/common_mark_stats.txt
index 3692c47..7950e3f 100644
--- a/tool/common_mark_stats.txt
+++ b/tool/common_mark_stats.txt
@@ -13,7 +13,7 @@
11 of 12 – 91.7% Indented code blocks
1 of 1 – 100.0% Inlines
21 of 23 – 91.3% Link reference definitions
- 75 of 84 – 89.3% Links
+ 76 of 84 – 90.5% Links
44 of 48 – 91.7% List items
18 of 24 – 75.0% Lists
8 of 8 – 100.0% Paragraphs
@@ -24,4 +24,4 @@
11 of 11 – 100.0% Tabs
3 of 3 – 100.0% Textual content
19 of 19 – 100.0% Thematic breaks
- 579 of 624 – 92.8% TOTAL
+ 580 of 624 – 92.9% TOTAL
diff --git a/tool/gfm_stats.json b/tool/gfm_stats.json
index 2fae2fb..c1b3892 100644
--- a/tool/gfm_stats.json
+++ b/tool/gfm_stats.json
@@ -447,7 +447,7 @@
"493": "fail",
"494": "strict",
"495": "strict",
- "496": "fail",
+ "496": "strict",
"497": "strict",
"498": "strict",
"499": "strict",
@@ -455,7 +455,7 @@
"501": "loose",
"502": "strict",
"503": "strict",
- "504": "fail",
+ "504": "loose",
"505": "fail",
"506": "strict",
"507": "strict",
@@ -463,7 +463,7 @@
"509": "strict",
"510": "strict",
"511": "strict",
- "512": "loose",
+ "512": "strict",
"513": "strict",
"514": "strict",
"515": "loose",
diff --git a/tool/gfm_stats.txt b/tool/gfm_stats.txt
index 848e96f..1a0ef35 100644
--- a/tool/gfm_stats.txt
+++ b/tool/gfm_stats.txt
@@ -15,7 +15,7 @@
11 of 12 – 91.7% Indented code blocks
1 of 1 – 100.0% Inlines
21 of 23 – 91.3% Link reference definitions
- 75 of 84 – 89.3% Links
+ 76 of 84 – 90.5% Links
44 of 48 – 91.7% List items
18 of 24 – 75.0% Lists
8 of 8 – 100.0% Paragraphs
@@ -28,4 +28,4 @@
11 of 11 – 100.0% Tabs
3 of 3 – 100.0% Textual content
19 of 19 – 100.0% Thematic breaks
- 595 of 647 – 92.0% TOTAL
+ 596 of 647 – 92.1% TOTAL