Skip to content
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

Fix links #241

Merged
merged 3 commits into from
Mar 26, 2019
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
6 changes: 3 additions & 3 deletions lib/src/inline_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 &&
Expand All @@ -944,7 +945,6 @@ class LinkSyntax extends TagSyntax {
return;
}
parser.advanceBy(1);
if (parser.isDone) return;
}
}

Expand Down
8 changes: 8 additions & 0 deletions test/markdown_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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](
''', '''
<p>5 Ethernet ([Music](</p>
''');
});

group('Resolver', () {
Node nyanResolver(String text, [_]) =>
text.isEmpty ? null : Text('~=[,,_${text}_,,]:3');
Expand Down
4 changes: 4 additions & 0 deletions test/original/inline_links.unit
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ links [are *awesome*]
<a href="(yes-a-link)">a</a>
[a](\(not-a-link))
<a href="(yes-a-link))">a</a></p>
>>> links with unbalanced parentheses
[foo](link(1.png) (what?)
<<<
<p>[foo](link(1.png) (what?)</p>