Fix regex pattern.

This commit is contained in:
takezoe
2013-06-22 22:34:00 +09:00
parent 2881df65a7
commit 66499024e9
2 changed files with 3 additions and 3 deletions

View File

@@ -78,7 +78,7 @@ class GitBucketHtmlSerializer(
val html = super.toHtml(rootNode) val html = super.toHtml(rootNode)
if(enableIssueLink){ if(enableIssueLink){
// convert marked issue id to link. // convert marked issue id to link.
html.replaceAll("#\\{\\{\\{\\{([0-9]+)\\}\\}\\}\\}", html.replaceAll("#\\{\\{\\{\\{(\\d+)\\}\\}\\}\\}",
"<a href=\"%s/%s/%s/issue/$1\">#$1</a>".format(context.path, repository.owner, repository.name)) "<a href=\"%s/%s/%s/issue/$1\">#$1</a>".format(context.path, repository.owner, repository.name))
} else html } else html
} }
@@ -113,7 +113,7 @@ class GitBucketHtmlSerializer(
// mark issue id to link // mark issue id to link
val startIndex = node.getStartIndex val startIndex = node.getStartIndex
val text2 = if(enableIssueLink && startIndex > 0 && markdown.charAt(startIndex - 1) == '#'){ val text2 = if(enableIssueLink && startIndex > 0 && markdown.charAt(startIndex - 1) == '#'){
text1.replaceFirst("^([0-9]+)", "{{{{$0}}}}") text1.replaceFirst("^(\\d+)", "{{{{$0}}}}")
} else text1 } else text1
if (abbreviations.isEmpty) { if (abbreviations.isEmpty) {

View File

@@ -34,7 +34,7 @@ object helpers {
// escape HTML tags // escape HTML tags
.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;") .replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;")
// convert issue id to link // convert issue id to link
.replaceAll("(^|\\W)#([0-9]+)(\\W|$)", "$1<a href=\"%s/%s/%s/issues/$2\">#$2</a>$3".format(context.path, repository.owner, repository.name)) .replaceAll("(^|\\W)#(\\d+)(\\W|$)", "$1<a href=\"%s/%s/%s/issues/$2\">#$2</a>$3".format(context.path, repository.owner, repository.name))
// convert commit id to link // convert commit id to link
.replaceAll("(^|\\W)([a-f0-9]{40})(\\W|$)", "$1<a href=\"%s/%s/%s/commit/$2\">$2</a>$3").format(context.path, repository.owner, repository.name)) .replaceAll("(^|\\W)([a-f0-9]{40})(\\W|$)", "$1<a href=\"%s/%s/%s/commit/$2\">$2</a>$3").format(context.path, repository.owner, repository.name))