From 0a8432645d3d23a3bacc0d66ed1f49e1f217e159 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 21 Jan 2014 11:04:49 -0500 Subject: [PATCH] FIX: Updated Markdown-js to include my latest FIX from upstream: https://github.com/evilstreak/markdown-js/pull/164 --- vendor/assets/javascripts/better_markdown.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vendor/assets/javascripts/better_markdown.js b/vendor/assets/javascripts/better_markdown.js index 7c0e7523f98..8e4e742e4f9 100644 --- a/vendor/assets/javascripts/better_markdown.js +++ b/vendor/assets/javascripts/better_markdown.js @@ -681,6 +681,9 @@ isEmpty = MarkdownHelpers.isEmpty, inline_until_char = DialectHelpers.inline_until_char; + // A robust regexp for matching URLs. Thakns: 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; + /** * Gruber dialect * @@ -1222,7 +1225,7 @@ // // First attempt to use a strong URL regexp to catch things like parentheses. If it misses, use the // old one. - var m = text.match( /^!\[(.*?)][ \t]*\(((?:https?:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.])(?:[^\s()<>]+|\([^\s()<>]+\))+(?:\([^\s()<>]+\)|[^`!()\[\]{};:'".,<>?«»“”‘’\s]))\)([ \t])*(["'].*["'])?/ ) || + var m = text.match(new RegExp("^!\\[(.*?)][ \\t]*\\((" + urlRegexp + ")\\)([ \\t])*([\"'].*[\"'])?")) || text.match( /^!\[(.*?)\][ \t]*\([ \t]*([^")]*?)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/ ); if ( m ) { @@ -1324,10 +1327,16 @@ return [ consumed, link ]; } + m = text.match(new RegExp("^\\((" + urlRegexp + ")\\)")); + if (m && m[1]) { + consumed += m[0].length; + link = ["link", {href: m[1]}].concat(children); + return [consumed, link]; + } + // [Alt text][id] // [Alt text] [id] m = text.match( /^\s*\[(.*?)\]/ ); - if ( m ) { consumed += m[ 0 ].length;