diff --git a/showdown.js b/showdown.js index 0efa6c5..ab3377e 100644 --- a/showdown.js +++ b/showdown.js @@ -149,6 +149,18 @@ this.makeHtml = function(text) { // attacklab: Restore tildes text = text.replace(/~T/g,"~"); + // ** GFM ** Auto-link URLs and emails + text = text.replace(/https?\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!]/g, function(wholeMatch){ + var left = RegExp.leftContext + var right = RegExp.rightContext + if (left.match(/<[^>]+$/) && right.match(/^[^>]*>/)) {return wholeMatch} + return "" + wholeMatch + ""; + }); + text = text.replace(/[a-z0-9_\-+=.]+@[a-z0-9\-]+(\.[a-z0-9-]+)+/ig, function(wholeMatch){ + return "" + wholeMatch + ""; + }); + + return text; } @@ -351,8 +363,8 @@ var _RunBlockGamut = function(text) { // Do Horizontal Rules: var key = hashBlock("
"); str += "
" grafsOut.push(str); @@ -1303,4 +1318,4 @@ var Showdown = Attacklab.showdown; // If anyone's interested, tell the world that this file's been loaded if (Attacklab.fileLoaded) { Attacklab.fileLoaded("showdown.js"); -} \ No newline at end of file +}