Skip to content

Commit

Permalink
(refs #34)@xxxx in markdown as link.
Browse files Browse the repository at this point in the history
  • Loading branch information
takezoe committed Jul 11, 2013
1 parent 5dbeabc commit 991f60c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/scala/view/Markdown.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ class GitBucketHtmlSerializer(
}

override def visit(node: TextNode) {
// convert commit id to link.
val text = if(enableCommitLink) node.getText.replaceAll("(^|\\W)([0-9a-f]{40})(\\W|$)",
s"""<a href="${context.path}/${repository.owner}/${repository.name}/commit/$$2">$$2</a>""")
// convert commit id and username to link.
val text = if(enableCommitLink) node.getText
.replaceAll("(^|\\W)([0-9a-f]{40})(\\W|$)", s"""$$1<a href="${context.path}/${repository.owner}/${repository.name}/commit/$$2">$$2</a>$$3""")
.replaceAll("(^|\\W)@([a-zA-Z0-9\\-_]+)(\\W|$)", s"""$$1<a href="${context.path}/$$2">@$$2</a>$$3""")
else node.getText

println(text)

if (abbreviations.isEmpty) {
printer.print(text)
} else {
Expand Down

0 comments on commit 991f60c

Please sign in to comment.