From 9bbab6e64ead87e77cb33e4e622c5c5bbd94be09 Mon Sep 17 00:00:00 2001 From: David McClure Date: Sat, 29 Oct 2016 17:30:36 -0700 Subject: [PATCH] FIX: Auto-link URLs that are inside parentheses --- .../pretty-text/engines/discourse-markdown.js.es6 | 2 +- test/javascripts/lib/pretty-text-test.js.es6 | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown.js.es6 index fbc58934b60..7555bebdf3c 100644 --- a/app/assets/javascripts/pretty-text/engines/discourse-markdown.js.es6 +++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown.js.es6 @@ -500,7 +500,7 @@ function invalidBoundary(args, prev) { if (args.wordBoundary && (!last.match(/\W$/))) { return true; } if (args.spaceBoundary && (!last.match(/\s$/))) { return true; } - if (args.spaceOrTagBoundary && (!last.match(/(\s|\>)$/))) { return true; } + if (args.spaceOrTagBoundary && (!last.match(/(\s|\>|\()$/))) { return true; } } function countLines(str) { diff --git a/test/javascripts/lib/pretty-text-test.js.es6 b/test/javascripts/lib/pretty-text-test.js.es6 index af6486b33a9..fb9c04f0ed9 100644 --- a/test/javascripts/lib/pretty-text-test.js.es6 +++ b/test/javascripts/lib/pretty-text-test.js.es6 @@ -159,10 +159,19 @@ test("Links", function() { "

http://google.com ... wat

", "it supports links within links"); + cooked("[http://google.com](http://discourse.org)", + "

http://google.com

", + "it supports markdown links where the name and link match"); + + cooked("[Link](http://www.example.com) (with an outer \"description\")", "

Link (with an outer \"description\")

", "it doesn't consume closing parens as part of the url"); + cooked("A link inside parentheses (http://www.example.com)", + "

A link inside parentheses (http://www.example.com)

", + "it auto-links a url within parentheses"); + cooked("[ul][1]\n\n[1]: http://eviltrout.com", "

ul

", "it can use `ul` as a link name");