From 54571268e514402102f52ce6a1576a1eb3b19d62 Mon Sep 17 00:00:00 2001 From: Alex Harrison Date: Thu, 9 Feb 2012 23:30:28 +0100 Subject: [PATCH] Added a post conversion hook to PageDown to add target="_blank" (fixes #2792) --- public/javascripts/app/helpers/text_formatter.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/javascripts/app/helpers/text_formatter.js b/public/javascripts/app/helpers/text_formatter.js index d977414f3..51bc72b4a 100644 --- a/public/javascripts/app/helpers/text_formatter.js +++ b/public/javascripts/app/helpers/text_formatter.js @@ -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) };