Merge pull request #2881 from beardedninja/master
Added a post conversion hook to PageDown + amended test for autolinking, fixes #2792
This commit is contained in:
commit
4f2783487d
2 changed files with 8 additions and 1 deletions
|
|
@ -12,6 +12,11 @@
|
|||
|
||||
textFormatter.markdownify = function markdownify(text){
|
||||
var converter = Markdown.getSanitizingConverter();
|
||||
|
||||
converter.hooks.chain("postConversion", function (text) {
|
||||
return text.replace(/(\"(?:(?:http|https):\/\/)?[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(?:\/\S*)?\")(\>)/g, '$1 target="_blank">')
|
||||
});
|
||||
|
||||
return converter.makeHtml(text)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@ describe("app.helpers.textFormatter", function(){
|
|||
var wrapper = $("<div>").html(formattedText);
|
||||
|
||||
_.each(links, function(link) {
|
||||
expect(wrapper.find("a[href='" + link + "']").text()).toContain(link)
|
||||
var linkElement = wrapper.find("a[href='" + link + "']");
|
||||
expect(linkElement.text()).toContain(link);
|
||||
expect(linkElement.attr("target")).toContain("_blank");
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue