Created
July 13, 2010 20:26
-
-
Save jbr/474471 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From e22317131b97d0faa5510b528ef515ccbbbd3e8e Mon Sep 17 00:00:00 2001 | |
From: Jacob Rothstein <[email protected]> | |
Date: Tue, 13 Jul 2010 13:24:34 -0700 | |
Subject: [PATCH] fix showdown to work in chrome (don't use RegExp.leftContext and RegExp.rightContext globals) | |
--- | |
scripts/showdown.js | 10 ++++------ | |
1 files changed, 4 insertions(+), 6 deletions(-) | |
diff --git a/scripts/showdown.js b/scripts/showdown.js | |
index e8772af..582a40f 100644 | |
--- a/scripts/showdown.js | |
+++ b/scripts/showdown.js | |
@@ -188,20 +188,18 @@ this.makeHtml = function(text) { | |
}); | |
// ** GFM ** Auto-link #issue if GitHub.nameWithOwner is defined | |
- text = text.replace(/#([0-9]+)/ig, function(wholeMatch,issue){ | |
+ text = text.replace(/#([0-9]+)/ig, function(wholeMatch,issue,matchIndex){ | |
if (typeof(GitHub) == "undefined" || typeof(GitHub.nameWithOwner) == "undefined") {return wholeMatch;} | |
- var left = RegExp.leftContext | |
- var right = RegExp.rightContext | |
+ var left = text.slice(0, matchIndex), right = text.slice(matchIndex) | |
if (left == "" || left.match(/[a-z0-9_\-+=.]$/) || (left.match(/<[^>]+$/) && right.match(/^[^>]*>/))) {return wholeMatch;} | |
return "<a href='http://github.com/" + GitHub.nameWithOwner + "/issues/#issue/" + issue + "'>" + wholeMatch + "</a>"; | |
}); | |
// ** GFM ** Auto-link user#issue if GitHub.nameWithOwner is defined | |
- text = text.replace(/([a-z0-9_\-+=.]+)#([0-9]+)/ig, function(wholeMatch,username,issue){ | |
+ text = text.replace(/([a-z0-9_\-+=.]+)#([0-9]+)/ig, function(wholeMatch,username,issue,matchIndex){ | |
if (typeof(GitHub) == "undefined" || typeof(GitHub.nameWithOwner) == "undefined") {return wholeMatch;} | |
GitHub.repoName = GitHub.repoName || _GetRepoName() | |
- var left = RegExp.leftContext | |
- var right = RegExp.rightContext | |
+ var left = text.slice(0, matchIndex), right = text.slice(matchIndex) | |
if (left.match(/\/$/) || (left.match(/<[^>]+$/) && right.match(/^[^>]*>/))) {return wholeMatch;} | |
return "<a href='http://github.com/" + username + "/" + GitHub.repoName + "/issues/#issue/" + issue + "'>" + wholeMatch + "</a>"; | |
}); | |
-- | |
1.7.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this. Saved my life :)