Skip to content

Commit

Permalink
Fix for urls inside tags on the first line.
Browse files Browse the repository at this point in the history
  • Loading branch information
Twipped committed Mar 16, 2011
1 parent db97dce commit 28cd3e6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions showdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ Attacklab.showdown.converter = function () {
text = text.replace(/~T/g, "~");

// ** GFM ** Auto-link URLs and emails
text = text.replace(/https?\:\/\/[^"\s<>]*[^.,;'">\:\s<>\)\]\!]/g, function (wholeMatch, matchIndex){
var left = text.slice(text.lastIndexOf('\n',matchIndex), matchIndex);
text = text.replace(/https?\:\/\/[^"\s<>]*[^.,;'">\:\s<>\)\]\!]/g, function (wholeMatch, matchIndex){
var left = text.slice(Math.max(0,text.lastIndexOf('\n',matchIndex)), matchIndex);
var right = text.slice(matchIndex);
if (left.match(/<([a-z]+)\s[^>]+$/) && right.match(/^[^>]*>/)) {return wholeMatch;}
return "<a href='" + wholeMatch + "'>" + wholeMatch + "</a>";
Expand Down
6 changes: 2 additions & 4 deletions wmd.combined.js
Original file line number Diff line number Diff line change
Expand Up @@ -2362,8 +2362,8 @@ Attacklab.showdown.converter = function () {
text = text.replace(/~T/g, "~");

// ** GFM ** Auto-link URLs and emails
text = text.replace(/https?\:\/\/[^"\s<>]*[^.,;'">\:\s<>\)\]\!]/g, function (wholeMatch, matchIndex){
var left = text.slice(text.lastIndexOf('\n',matchIndex), matchIndex);
text = text.replace(/https?\:\/\/[^"\s<>]*[^.,;'">\:\s<>\)\]\!]/g, function (wholeMatch, matchIndex){
var left = text.slice(Math.max(0,text.lastIndexOf('\n',matchIndex)), matchIndex);
var right = text.slice(matchIndex);
if (left.match(/<([a-z]+)\s[^>]+$/) && right.match(/^[^>]*>/)) {return wholeMatch;}
return "<a href='" + wholeMatch + "'>" + wholeMatch + "</a>";
Expand Down Expand Up @@ -3182,8 +3182,6 @@ Attacklab.showdown.converter = function () {
return m1 + "<strike>" + c + "</strike>";
});

console.log(text);

return text;
};

Expand Down
4 changes: 2 additions & 2 deletions wmd.combined.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 28cd3e6

Please sign in to comment.