</SOURCES>
</library>
</orderEntry>
+ <orderEntry type="module-library">
+ <library name="wikitext-core-1.4.jar">
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/ext/wikitext-core-1.4.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$MODULE_DIR$/ext/src/wikitext-core-1.4.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library name="twiki-core-1.4.jar">
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/ext/twiki-core-1.4.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$MODULE_DIR$/ext/src/twiki-core-1.4.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library name="textile-core-1.4.jar">
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/ext/textile-core-1.4.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$MODULE_DIR$/ext/src/textile-core-1.4.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library name="tracwiki-core-1.4.jar">
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/ext/tracwiki-core-1.4.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$MODULE_DIR$/ext/src/tracwiki-core-1.4.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library name="mediawiki-core-1.4.jar">
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/ext/mediawiki-core-1.4.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$MODULE_DIR$/ext/src/mediawiki-core-1.4.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library name="confluence-core-1.4.jar">
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/ext/confluence-core-1.4.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$MODULE_DIR$/ext/src/confluence-core-1.4.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
<orderEntry type="module-library">
<library name="org.eclipse.jgit-3.1.0.201310021548-r.jar">
<CLASSES>
package com.gitblit.wicket;\r
\r
import java.io.Serializable;\r
+import java.io.StringWriter;\r
import java.io.UnsupportedEncodingException;\r
import java.net.URLEncoder;\r
import java.text.MessageFormat;\r
import org.apache.wicket.RequestCycle;\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
+import org.eclipse.mylyn.wikitext.confluence.core.ConfluenceLanguage;\r
+import org.eclipse.mylyn.wikitext.core.parser.Attributes;\r
+import org.eclipse.mylyn.wikitext.core.parser.MarkupParser;\r
+import org.eclipse.mylyn.wikitext.core.parser.builder.HtmlDocumentBuilder;\r
+import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;\r
+import org.eclipse.mylyn.wikitext.mediawiki.core.MediaWikiLanguage;\r
+import org.eclipse.mylyn.wikitext.textile.core.TextileLanguage;\r
+import org.eclipse.mylyn.wikitext.tracwiki.core.TracWikiLanguage;\r
+import org.eclipse.mylyn.wikitext.twiki.core.TWikiLanguage;\r
import org.pegdown.LinkRenderer;\r
import org.pegdown.ast.WikiLinkNode;\r
import org.slf4j.Logger;\r
import com.gitblit.utils.MarkdownUtils;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.pages.DocPage;\r
+import com.gitblit.wicket.pages.RawPage;\r
\r
/**\r
* Processes markup content and generates html with repository-relative page and\r
public class MarkupProcessor {\r
\r
public enum MarkupSyntax {\r
- PLAIN, MARKDOWN\r
+ PLAIN, MARKDOWN, TWIKI, TRACWIKI, TEXTILE, MEDIAWIKI, CONFLUENCE\r
}\r
\r
private Logger logger = LoggerFactory.getLogger(getClass());\r
\r
public List<String> getMarkupExtensions() {\r
List<String> list = new ArrayList<String>();\r
+ list.addAll(settings.getStrings(Keys.web.confluenceExtensions));\r
list.addAll(settings.getStrings(Keys.web.markdownExtensions));\r
+ list.addAll(settings.getStrings(Keys.web.mediawikiExtensions));\r
+ list.addAll(settings.getStrings(Keys.web.textileExtensions));\r
+ list.addAll(settings.getStrings(Keys.web.tracwikiExtensions));\r
+ list.addAll(settings.getStrings(Keys.web.twikiExtensions));\r
return list;\r
}\r
\r
return MarkupSyntax.PLAIN;\r
}\r
\r
- if (settings.getStrings(Keys.web.markdownExtensions).contains(ext)) {\r
+ if (settings.getStrings(Keys.web.confluenceExtensions).contains(ext)) {\r
+ return MarkupSyntax.CONFLUENCE;\r
+ } else if (settings.getStrings(Keys.web.markdownExtensions).contains(ext)) {\r
return MarkupSyntax.MARKDOWN;\r
+ } else if (settings.getStrings(Keys.web.mediawikiExtensions).contains(ext)) {\r
+ return MarkupSyntax.MEDIAWIKI;\r
+ } else if (settings.getStrings(Keys.web.textileExtensions).contains(ext)) {\r
+ return MarkupSyntax.TEXTILE;\r
+ } else if (settings.getStrings(Keys.web.tracwikiExtensions).contains(ext)) {\r
+ return MarkupSyntax.TRACWIKI;\r
+ } else if (settings.getStrings(Keys.web.twikiExtensions).contains(ext)) {\r
+ return MarkupSyntax.TWIKI;\r
}\r
\r
return MarkupSyntax.PLAIN;\r
if (markupText != null) {\r
try {\r
switch (syntax){\r
+ case CONFLUENCE:\r
+ parse(doc, repositoryName, commitId, new ConfluenceLanguage());\r
+ break;\r
case MARKDOWN:\r
parse(doc, repositoryName, commitId);\r
break;\r
+ case MEDIAWIKI:\r
+ parse(doc, repositoryName, commitId, new MediaWikiLanguage());\r
+ break;\r
+ case TEXTILE:\r
+ parse(doc, repositoryName, commitId, new TextileLanguage());\r
+ break;\r
+ case TRACWIKI:\r
+ parse(doc, repositoryName, commitId, new TracWikiLanguage());\r
+ break;\r
+ case TWIKI:\r
+ parse(doc, repositoryName, commitId, new TWikiLanguage());\r
+ break;\r
default:\r
doc.html = MarkdownUtils.transformPlainText(markupText);\r
break;\r
return doc;\r
}\r
\r
+ /**\r
+ * Parses the markup using the specified markup language\r
+ *\r
+ * @param doc\r
+ * @param repositoryName\r
+ * @param commitId\r
+ * @param lang\r
+ */\r
+ private void parse(final MarkupDocument doc, final String repositoryName, final String commitId, MarkupLanguage lang) {\r
+ StringWriter writer = new StringWriter();\r
+ HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer) {\r
+\r
+ @Override\r
+ public void image(Attributes attributes, String imagePath) {\r
+ String url;\r
+ if (imagePath.indexOf("://") == -1) {\r
+ // relative image\r
+ String path = doc.getRelativePath(imagePath);\r
+ url = getWicketUrl(RawPage.class, repositoryName, commitId, path);\r
+ } else {\r
+ // absolute image\r
+ url = imagePath;\r
+ }\r
+ super.image(attributes, url);\r
+ }\r
+\r
+ @Override\r
+ public void link(Attributes attributes, String hrefOrHashName, String text) {\r
+ String url;\r
+ if (hrefOrHashName.charAt(0) != '#') {\r
+ if (hrefOrHashName.indexOf("://") == -1) {\r
+ // relative link\r
+ String path = doc.getRelativePath(hrefOrHashName);\r
+ url = getWicketUrl(DocPage.class, repositoryName, commitId, path);\r
+ } else {\r
+ // absolute link\r
+ url = hrefOrHashName;\r
+ }\r
+ } else {\r
+ // page-relative hash link\r
+ url = hrefOrHashName;\r
+ }\r
+ super.link(attributes, url, text);\r
+ }\r
+ };\r
+\r
+ // avoid the <html> and <body> tags\r
+ builder.setEmitAsDocument(false);\r
+\r
+ MarkupParser parser = new MarkupParser(lang);\r
+ parser.setBuilder(builder);\r
+ parser.parse(doc.markup);\r
+ doc.html = writer.toString();\r
+ }\r
+\r
/**\r
* Parses the document as Markdown using Pegdown.\r
*\r