Fix newlines between link dest and title
diff --git a/pkgs/markdown/CHANGELOG.md b/pkgs/markdown/CHANGELOG.md index 65b05b5..5d6b84a 100644 --- a/pkgs/markdown/CHANGELOG.md +++ b/pkgs/markdown/CHANGELOG.md
@@ -8,6 +8,7 @@ * Inline HTML syntax support; This is also considered an extension (#18). * The text `[foo] (bar)` no longer renders as an inline link (#53). * The text `[foo]()` now renders as an inline link. +* Whitespace now allowed between a link's destination and title (#65). * Header identifier support in the HeaderWithIdSyntax and SetextHeaderWithIdSyntax extensions. * Implement backslash-escaping so that Markdown syntax can be escaped, such as
diff --git a/pkgs/markdown/lib/src/inline_parser.dart b/pkgs/markdown/lib/src/inline_parser.dart index 2e8f42f..77a947c 100644 --- a/pkgs/markdown/lib/src/inline_parser.dart +++ b/pkgs/markdown/lib/src/inline_parser.dart
@@ -276,9 +276,9 @@ /// inline-style links as well as optional titles for inline links. To make that /// a bit more palatable, this breaks it into pieces. static get linkPattern { - var refLink = r'\[([^\]]*)\]'; // "[id]" reflink id. - var title = r'(?:[ ]*"([^"]+)"|)'; // Optional title in quotes. - var inlineLink = '\\(([^ )]*)$title\\)'; // "(url "title")" link. + var refLink = r'\[([^\]]*)\]'; // `[id]` reflink id. + var title = r'(?:\s*"([^"]+)"|)'; // Optional title in quotes. + var inlineLink = '\\((\\S*)$title\\)'; // `(url "title")` link. return '\](?:($refLink|$inlineLink)|)'; // The groups matched by this are:
diff --git a/pkgs/markdown/test/original/inline_links.unit b/pkgs/markdown/test/original/inline_links.unit index 5ab3549..d6e6d77 100644 --- a/pkgs/markdown/test/original/inline_links.unit +++ b/pkgs/markdown/test/original/inline_links.unit
@@ -23,6 +23,19 @@ <<< <p>links <a href="http://example.com">are</a> awesome</p> +>>> multi-line link +links [are +awesome](<http://example.com>). + +<<< +<p>links <a href="http://example.com">are +awesome</a>.</p> +>>> multi-line link with a title +links [are](http://foo.com +"woo") awesome + +<<< +<p>links <a href="http://foo.com" title="woo">are</a> awesome</p> >>> not a real link links [are] (http://foo.com) awesome