mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 14:05:52 +01:00
Fix link detection.
This commit is contained in:
@@ -79,7 +79,7 @@ class GitBucketHtmlSerializer(
|
|||||||
if(enableIssueLink){
|
if(enableIssueLink){
|
||||||
// convert marked issue id to link.
|
// convert marked issue id to link.
|
||||||
html.replaceAll("#\\{\\{\\{\\{(\\d+)\\}\\}\\}\\}",
|
html.replaceAll("#\\{\\{\\{\\{(\\d+)\\}\\}\\}\\}",
|
||||||
"<a href=\"%s/%s/%s/issue/$1\">#$1</a>".format(context.path, repository.owner, repository.name))
|
"<a href=\"%s/%s/%s/issues/$1\">#$1</a>".format(context.path, repository.owner, repository.name))
|
||||||
} else html
|
} else html
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,14 +106,14 @@ class GitBucketHtmlSerializer(
|
|||||||
|
|
||||||
override def visit(node: TextNode) {
|
override def visit(node: TextNode) {
|
||||||
// convert commit id to link.
|
// convert commit id to link.
|
||||||
val text1 = if(enableCommitLink) node.getText.replaceAll("[0-9a-f]{40}",
|
val text1 = if(enableCommitLink) node.getText.replaceAll("(^|\\W)([0-9a-f]{40})(\\W|$)",
|
||||||
"<a href=\"%s/%s/%s/commit/$0\">$0</a>".format(context.path, repository.owner, repository.name))
|
"<a href=\"%s/%s/%s/commit/$2\">$2</a>".format(context.path, repository.owner, repository.name))
|
||||||
else node.getText
|
else node.getText
|
||||||
|
|
||||||
// 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("^(\\d+)", "{{{{$0}}}}")
|
text1.replaceFirst("^(\\d+)(\\W|$)", "{{{{$1}}}}")
|
||||||
} else text1
|
} else text1
|
||||||
|
|
||||||
if (abbreviations.isEmpty) {
|
if (abbreviations.isEmpty) {
|
||||||
|
|||||||
Reference in New Issue
Block a user