From ea4a99d393f20adab274c941ddb0826df5bb6371 Mon Sep 17 00:00:00 2001 From: Juanfran Date: Thu, 30 Mar 2017 08:18:01 +0200 Subject: [PATCH] [Backport] regex find links with spaces and format them --- app/modules/components/wysiwyg/wysiwyg.service.coffee | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/modules/components/wysiwyg/wysiwyg.service.coffee b/app/modules/components/wysiwyg/wysiwyg.service.coffee index ee372337..a28fbed3 100644 --- a/app/modules/components/wysiwyg/wysiwyg.service.coffee +++ b/app/modules/components/wysiwyg/wysiwyg.service.coffee @@ -79,6 +79,13 @@ class WysiwygService return '[' + title + '](' + link + ')' + + linkTitleWithSpaces: (text) -> + link = /\[[^\]]*\]\(([^\)]*)\)/g # [Title-with-spaces](Title with spaces) + + return text.replace link, (match, p1, offset, str) -> + return match.replace /\(.*\)/, '(' + taiga.slugify(p1) + ')' + replaceUrls: (html) -> el = document.createElement( 'html' ) el.innerHTML = html @@ -213,7 +220,8 @@ class WysiwygService } text = @.replaceEmojiNameByImgs(text) - text = @.pipeLinks(text) + text = @.linkTitleWithSpaces(text) + text = @.pipeLinks(text) md = window.markdownit({ breaks: true