diff --git a/lib/src/inline_parser.dart b/lib/src/inline_parser.dart index d7e711d5..bf959667 100644 --- a/lib/src/inline_parser.dart +++ b/lib/src/inline_parser.dart @@ -895,7 +895,8 @@ class LinkSyntax extends TagSyntax { case $ff: var destination = buffer.toString(); var title = _parseTitle(parser); - if (title == null && parser.charAt(parser.pos) != $rparen) { + if (title == null && + (parser.isDone || parser.charAt(parser.pos) != $rparen)) { // This looked like an inline link, until we found this $space // followed by mystery characters; no longer a link. return null; @@ -933,7 +934,7 @@ class LinkSyntax extends TagSyntax { // Walk the parser forward through any whitespace. void _moveThroughWhitespace(InlineParser parser) { - while (true) { + while (!parser.isDone) { var char = parser.charAt(parser.pos); if (char != $space && char != $tab && @@ -944,7 +945,6 @@ class LinkSyntax extends TagSyntax { return; } parser.advanceBy(1); - if (parser.isDone) return; } } diff --git a/test/markdown_test.dart b/test/markdown_test.dart index 87b50936..0c8d598c 100644 --- a/test/markdown_test.dart +++ b/test/markdown_test.dart @@ -23,6 +23,14 @@ void main() { testFile('extensions/emojis.unit', inlineSyntaxes: [EmojiSyntax()]); testFile('extensions/inline_html.unit', inlineSyntaxes: [InlineHtmlSyntax()]); + group('Corner cases', () { + validateCore('Incorrect Links', ''' +5 Ethernet ([Music]( +''', ''' +
5 Ethernet ([Music](
+'''); + }); + group('Resolver', () { Node nyanResolver(String text, [_]) => text.isEmpty ? null : Text('~=[,,_${text}_,,]:3'); diff --git a/test/original/inline_links.unit b/test/original/inline_links.unit index e62cddd1..74afe5af 100644 --- a/test/original/inline_links.unit +++ b/test/original/inline_links.unit @@ -76,3 +76,7 @@ links [are *awesome*] a [a](\(not-a-link)) a +>>> links with unbalanced parentheses +[foo](link(1.png) (what?) +<<< +[foo](link(1.png) (what?)