diff --git a/src/main/scala/view/Markdown.scala b/src/main/scala/view/Markdown.scala index 3100173..c8eb148 100644 --- a/src/main/scala/view/Markdown.scala +++ b/src/main/scala/view/Markdown.scala @@ -74,15 +74,6 @@ Map[String, VerbatimSerializer](VerbatimSerializer.DEFAULT -> new GitBucketVerbatimSerializer).asJava ) { - override def toHtml(rootNode: RootNode): String = { - val html = super.toHtml(rootNode) - if(enableIssueLink){ - // convert marked issue id to link. - html.replaceAll("#\\{\\{\\{\\{(\\d+)\\}\\}\\}\\}", - "#$1".format(context.path, repository.owner, repository.name)) - } else html - } - override protected def printImageTag(imageNode: SuperNode, url: String): Unit = printer.print("\"").printEncoded(printChildrenToString(imageNode)).print("\"/") @@ -109,27 +100,23 @@ override def visit(node: TextNode) { // convert commit id to link. - val text1 = if(enableCommitLink) node.getText.replaceAll("(^|\\W)([0-9a-f]{40})(\\W|$)", + val text = if(enableCommitLink) node.getText.replaceAll("(^|\\W)([0-9a-f]{40})(\\W|$)", "$2".format(context.path, repository.owner, repository.name)) else node.getText - // mark issue id to link - val startIndex = node.getStartIndex - val text2 = if(enableIssueLink && startIndex > 0 && markdown.charAt(startIndex - 1) == '#'){ - text1.replaceFirst("^(\\d+)(\\W|$)", "{{{{$1}}}}") - } else text1 - if (abbreviations.isEmpty) { - printer.print(text2) + printer.print(text) } else { - printWithAbbreviations(text2) + printWithAbbreviations(text) } } override def visit(node: HeaderNode) { - if(enableIssueLink && markdown.substring(node.getStartIndex, node.getEndIndex - 1).startsWith("#")){ - printer.print("#" * node.getLevel) - visitChildren(node) + val text = markdown.substring(node.getStartIndex, node.getEndIndex - 1).trim + if(enableIssueLink && text.matches("#[\\d]+")){ + // convert issue id to link + val issueId = text.substring(1).toInt + printer.print("#%d".format(context.path, repository.owner, repository.name, issueId, issueId)) } else { printTag(node, "h" + node.getLevel) }