diff --git a/app/coffee/utils.coffee b/app/coffee/utils.coffee index f9ec5c14..85fce1bc 100644 --- a/app/coffee/utils.coffee +++ b/app/coffee/utils.coffee @@ -259,7 +259,10 @@ getMatches = (string, regex, index) -> match = null while match = regex.exec(string) - matches.push(match[index]) + if index == -1 + matches.push(match) + else + matches.push(match[index]) return matches diff --git a/app/modules/components/wysiwyg/wysiwyg.service.coffee b/app/modules/components/wysiwyg/wysiwyg.service.coffee index 271dc349..218a0fc1 100644 --- a/app/modules/components/wysiwyg/wysiwyg.service.coffee +++ b/app/modules/components/wysiwyg/wysiwyg.service.coffee @@ -70,6 +70,15 @@ class WysiwygService return text + pipeLinks: (text) -> + return text.replace /\[\[(.*?)\]\]/g, (match, p1, offset, str) -> + linkParams = p1.split('|') + + link = linkParams[0] + title = linkParams[1] || linkParams[0] + + return '[' + title + '](' + link + ')' + replaceUrls: (html) -> el = document.createElement( 'html' ) el.innerHTML = html @@ -146,7 +155,9 @@ class WysiwygService options = { breaks: true } + text = @.replaceEmojiNameByImgs(text) + text = @.pipeLinks(text) md = window.markdownit({ breaks: true