Skip to content
Open
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
7 changes: 5 additions & 2 deletions src/dialects/gruber.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define(['../markdown_helpers', './dialect_helpers', '../parser'], function (Mark
inline_until_char = DialectHelpers.inline_until_char;

// A robust regexp for matching URLs. Thanks: https://gist.github.com/dperini/729294
var urlRegexp = /(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?/i.source;
var urlRegexp = /(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?/i.source;

/**
* Gruber dialect
Expand Down Expand Up @@ -563,8 +563,11 @@ define(['../markdown_helpers', './dialect_helpers', '../parser'], function (Mark
//
// First attempt to use a strong URL regexp to catch things like parentheses. If it misses, use the
// old one.
var origMatcher = /^!\[(.*?)\][ \t]*\([ \t]*([^")]*?)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/;
var m = text.match(new RegExp("^!\\[(.*?)][ \\t]*\\((" + urlRegexp + ")\\)([ \\t])*([\"'].*[\"'])?")) ||
text.match( /^!\[(.*?)\][ \t]*\([ \t]*([^")]*?)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/ );
text.match(origMatcher);

if (m && m[2].indexOf(")]") !== -1) { m = text.match(origMatcher); }

if ( m ) {
if ( m[2] && m[2][0] === "<" && m[2][m[2].length-1] === ">" )
Expand Down
11 changes: 11 additions & 0 deletions test/features/images/inside_long_link.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
["html",
["p",
["a",
{ "href": "http://company.com/" },
["img", {
"alt": "company logo",
"src": "http://company.com/images/company-colour.png"
} ]
]
]
]
1 change: 1 addition & 0 deletions test/features/images/inside_long_link.text
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[![company logo](http://company.com/images/company-colour.png)](http://company.com/)