// load the document\r
String [] encodings = GitBlit.getEncodings();\r
markdown = JGitUtils.getStringContent(r, head.getTree(), doc, encodings);\r
- html = MarkdownUtils.transformMarkdown(markdown, getLinkRenderer());\r
+ html = MarkdownUtils.transformMarkdown(markdown, getMarkdownLinkRenderer());\r
}\r
\r
Fragment fragment = null;\r
\r
String htmlText;\r
try {\r
- htmlText = MarkdownUtils.transformMarkdown(markdownText, getLinkRenderer());\r
+ htmlText = MarkdownUtils.transformMarkdown(markdownText, getMarkdownLinkRenderer());\r
} catch (Exception e) {\r
logger.error("failed to transform markdown", e);\r
if (markdownText == null) {\r
*\r
* @return a link renderer\r
*/\r
- protected LinkRenderer getLinkRenderer() {\r
+ protected LinkRenderer getMarkdownLinkRenderer() {\r
RevCommit head = JGitUtils.getCommit(r, "HEAD");\r
final String id = getBestCommitId(head);\r
LinkRenderer renderer = new LinkRenderer() {\r
try {\r
String fsc = GitBlit.getString(Keys.web.forwardSlashCharacter, "/");\r
String path = URLEncoder.encode(node.getText().replace(' ', '-'), "UTF-8").replace("%2F", fsc);\r
+\r
+ // extract document name\r
String name = node.getText();\r
if (name.indexOf('/') > -1) {\r
name = name.substring(name.lastIndexOf('/') + 1);\r
}\r
+\r
+ // strip Markdown extension\r
+ for (String ext : GitBlit.getStrings(Keys.web.markdownExtensions)) {\r
+ String x = "." + ext;\r
+ if (name.endsWith(x)) {\r
+ name = name.substring(0, name.length() - x.length());\r
+ break;\r
+ }\r
+ }\r
String url = urlFor(MarkdownPage.class, WicketUtils.newPathParameter(repositoryName, id, path)).toString();\r
return new Rendering(url, name);\r
} catch (UnsupportedEncodingException e) {\r
String [] encodings = GitBlit.getEncodings();\r
markdownText = JGitUtils.getStringContent(r, head.getTree(), readme, encodings);\r
if (isMarkdown) {\r
- htmlText = MarkdownUtils.transformMarkdown(markdownText, getLinkRenderer());\r
+ htmlText = MarkdownUtils.transformMarkdown(markdownText, getMarkdownLinkRenderer());\r
} else {\r
htmlText = MarkdownUtils.transformPlainText(markdownText);\r
}\r