fix issue 5011 - support to pipe markdownn links

stable
Juanfran 2017-03-16 08:10:24 +01:00
parent 37b909e005
commit b2af789412
2 changed files with 15 additions and 1 deletions

View File

@ -259,7 +259,10 @@ getMatches = (string, regex, index) ->
match = null match = null
while match = regex.exec(string) while match = regex.exec(string)
matches.push(match[index]) if index == -1
matches.push(match)
else
matches.push(match[index])
return matches return matches

View File

@ -70,6 +70,15 @@ class WysiwygService
return text 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) -> replaceUrls: (html) ->
el = document.createElement( 'html' ) el = document.createElement( 'html' )
el.innerHTML = html el.innerHTML = html
@ -146,7 +155,9 @@ class WysiwygService
options = { options = {
breaks: true breaks: true
} }
text = @.replaceEmojiNameByImgs(text) text = @.replaceEmojiNameByImgs(text)
text = @.pipeLinks(text)
md = window.markdownit({ md = window.markdownit({
breaks: true breaks: true