diff options
-rw-r--r-- | .classpath | 8 | ||||
-rw-r--r-- | NOTICE | 18 | ||||
-rw-r--r-- | build.moxie | 2 | ||||
-rw-r--r-- | gitblit.iml | 72 | ||||
-rw-r--r-- | releases.moxie | 1 | ||||
-rw-r--r-- | src/main/java/com/gitblit/GitBlit.java | 3 | ||||
-rw-r--r-- | src/main/java/com/gitblit/utils/MarkdownUtils.java | 40 | ||||
-rw-r--r-- | src/main/java/com/gitblit/wicket/pages/MarkdownPage.java | 4 | ||||
-rw-r--r-- | src/main/java/com/gitblit/wicket/pages/RepositoryPage.java | 2 | ||||
-rw-r--r-- | src/main/java/com/gitblit/wicket/pages/SummaryPage.java | 4 | ||||
-rw-r--r-- | src/site/design.mkd | 2 | ||||
-rw-r--r-- | src/test/java/com/gitblit/tests/MarkdownUtilsTest.java | 14 |
12 files changed, 108 insertions, 62 deletions
@@ -20,7 +20,13 @@ <classpathentry kind="lib" path="ext/lucene-memory-3.6.1.jar" sourcepath="ext/src/lucene-memory-3.6.1.jar" /> <classpathentry kind="lib" path="ext/lucene-queries-3.6.1.jar" sourcepath="ext/src/lucene-queries-3.6.1.jar" /> <classpathentry kind="lib" path="ext/jakarta-regexp-1.4.jar" /> - <classpathentry kind="lib" path="ext/markdownpapers-core-1.3.2.jar" sourcepath="ext/src/markdownpapers-core-1.3.2.jar" /> + <classpathentry kind="lib" path="ext/pegdown-1.4.1.jar" sourcepath="ext/src/pegdown-1.4.1.jar" /> + <classpathentry kind="lib" path="ext/parboiled-java-1.1.5.jar" sourcepath="ext/src/parboiled-java-1.1.5.jar" /> + <classpathentry kind="lib" path="ext/parboiled-core-1.1.5.jar" sourcepath="ext/src/parboiled-core-1.1.5.jar" /> + <classpathentry kind="lib" path="ext/asm-4.1.jar" sourcepath="ext/src/asm-4.1.jar" /> + <classpathentry kind="lib" path="ext/asm-tree-4.1.jar" sourcepath="ext/src/asm-tree-4.1.jar" /> + <classpathentry kind="lib" path="ext/asm-analysis-4.1.jar" sourcepath="ext/src/asm-analysis-4.1.jar" /> + <classpathentry kind="lib" path="ext/asm-util-4.1.jar" sourcepath="ext/src/asm-util-4.1.jar" /> <classpathentry kind="lib" path="ext/org.eclipse.jgit-3.1.0.201310021548-r.jar" sourcepath="ext/src/org.eclipse.jgit-3.1.0.201310021548-r.jar" /> <classpathentry kind="lib" path="ext/jsch-0.1.46.jar" sourcepath="ext/src/jsch-0.1.46.jar" /> <classpathentry kind="lib" path="ext/JavaEWAH-0.5.6.jar" sourcepath="ext/src/JavaEWAH-0.5.6.jar" /> @@ -56,14 +56,6 @@ WicketStuff GoogleCharts https://github.com/wicketstuff/core/wiki/GoogleCharts
---------------------------------------------------------------------------
-MarkdownPapers
----------------------------------------------------------------------------
- MarkdownPapers, released under the
- Apache Software License, Version 2.0.
-
- http://markdown.tautua.org
-
----------------------------------------------------------------------------
Jetty
---------------------------------------------------------------------------
Jetty, released under the
@@ -318,4 +310,12 @@ commons-codec Apache License 2.0.
http://commons.apache.org/proper/commons-codec
-
\ No newline at end of file +
+---------------------------------------------------------------------------
+pegdown
+---------------------------------------------------------------------------
+ pegdown, release under the
+ Apache License 2.0.
+
+ https://github.com/sirthias/pegdown
+
\ No newline at end of file diff --git a/build.moxie b/build.moxie index df0a36d1..44f6d059 100644 --- a/build.moxie +++ b/build.moxie @@ -135,7 +135,7 @@ dependencies: - compile 'org.apache.lucene:lucene-core:${lucene.version}' :war :fedclient - compile 'org.apache.lucene:lucene-highlighter:${lucene.version}' :war :fedclient - compile 'org.apache.lucene:lucene-memory:${lucene.version}' :war :fedclient -- compile 'org.tautua.markdownpapers:markdownpapers-core:1.3.2' :war +- compile 'org.pegdown:pegdown:1.4.1' :war - compile 'org.eclipse.jgit:org.eclipse.jgit:${jgit.version}' :war :fedclient :manager :authority - compile 'org.eclipse.jgit:org.eclipse.jgit.http.server:${jgit.version}' :war :fedclient :manager :authority - compile 'org.bouncycastle:bcprov-jdk15on:${bouncycastle.version}' :war :authority diff --git a/gitblit.iml b/gitblit.iml index 736376b3..c31d1e9e 100644 --- a/gitblit.iml +++ b/gitblit.iml @@ -196,13 +196,79 @@ </library> </orderEntry> <orderEntry type="module-library"> - <library name="markdownpapers-core-1.3.2.jar"> + <library name="pegdown-1.4.1.jar"> <CLASSES> - <root url="jar://$MODULE_DIR$/ext/markdownpapers-core-1.3.2.jar!/" /> + <root url="jar://$MODULE_DIR$/ext/pegdown-1.4.1.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES> - <root url="jar://$MODULE_DIR$/ext/src/markdownpapers-core-1.3.2.jar!/" /> + <root url="jar://$MODULE_DIR$/ext/src/pegdown-1.4.1.jar!/" /> + </SOURCES> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library name="parboiled-java-1.1.5.jar"> + <CLASSES> + <root url="jar://$MODULE_DIR$/ext/parboiled-java-1.1.5.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES> + <root url="jar://$MODULE_DIR$/ext/src/parboiled-java-1.1.5.jar!/" /> + </SOURCES> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library name="parboiled-core-1.1.5.jar"> + <CLASSES> + <root url="jar://$MODULE_DIR$/ext/parboiled-core-1.1.5.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES> + <root url="jar://$MODULE_DIR$/ext/src/parboiled-core-1.1.5.jar!/" /> + </SOURCES> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library name="asm-4.1.jar"> + <CLASSES> + <root url="jar://$MODULE_DIR$/ext/asm-4.1.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES> + <root url="jar://$MODULE_DIR$/ext/src/asm-4.1.jar!/" /> + </SOURCES> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library name="asm-tree-4.1.jar"> + <CLASSES> + <root url="jar://$MODULE_DIR$/ext/asm-tree-4.1.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES> + <root url="jar://$MODULE_DIR$/ext/src/asm-tree-4.1.jar!/" /> + </SOURCES> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library name="asm-analysis-4.1.jar"> + <CLASSES> + <root url="jar://$MODULE_DIR$/ext/asm-analysis-4.1.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES> + <root url="jar://$MODULE_DIR$/ext/src/asm-analysis-4.1.jar!/" /> + </SOURCES> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library name="asm-util-4.1.jar"> + <CLASSES> + <root url="jar://$MODULE_DIR$/ext/asm-util-4.1.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES> + <root url="jar://$MODULE_DIR$/ext/src/asm-util-4.1.jar!/" /> </SOURCES> </library> </orderEntry> diff --git a/releases.moxie b/releases.moxie index e086f43e..a48473da 100644 --- a/releases.moxie +++ b/releases.moxie @@ -32,6 +32,7 @@ r20: { dependencyChanges: - updated to Jetty 7.6.13 - updated to JGit 3.1.0 + - replaced MarkdownPapers with pegdown 1.4.1 settings: - { name: 'git.createRepositoriesShared', defaultValue: 'false' } - { name: 'git.allowAnonymousPushes', defaultValue: 'false' } diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java index 7f82432d..a23dd8c2 100644 --- a/src/main/java/com/gitblit/GitBlit.java +++ b/src/main/java/com/gitblit/GitBlit.java @@ -32,7 +32,6 @@ import java.net.URISyntaxException; import java.nio.charset.Charset; import java.security.Principal; import java.text.MessageFormat; -import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -2713,7 +2712,7 @@ public class GitBlit implements ServletContextListener { try { String prepared = processCommitMessageRegex(repository.name, text); return MarkdownUtils.transformMarkdown(prepared); - } catch (ParseException e) { + } catch (Exception e) { logger.error("Failed to render commit message as markdown", e); } break; diff --git a/src/main/java/com/gitblit/utils/MarkdownUtils.java b/src/main/java/com/gitblit/utils/MarkdownUtils.java index 15242364..33d7a6ae 100644 --- a/src/main/java/com/gitblit/utils/MarkdownUtils.java +++ b/src/main/java/com/gitblit/utils/MarkdownUtils.java @@ -15,14 +15,14 @@ */
package com.gitblit.utils;
+import static org.pegdown.Extensions.ALL;
+
import java.io.IOException;
import java.io.Reader;
-import java.io.StringReader;
import java.io.StringWriter;
-import org.slf4j.LoggerFactory;
-import org.tautua.markdownpapers.Markdown;
-import org.tautua.markdownpapers.parser.ParseException;
+import org.apache.commons.io.IOUtils;
+import org.pegdown.PegDownProcessor;
/**
* Utility methods for transforming raw markdown text to html.
@@ -39,17 +39,10 @@ public class MarkdownUtils { * @return html version of markdown text
* @throws java.text.ParseException
*/
- public static String transformMarkdown(String markdown) throws java.text.ParseException {
- try {
- StringReader reader = new StringReader(markdown);
- String html = transformMarkdown(reader);
- reader.close();
- return html;
- } catch (IllegalArgumentException e) {
- throw new java.text.ParseException(e.getMessage(), 0);
- } catch (NullPointerException p) {
- throw new java.text.ParseException("Markdown string is null!", 0);
- }
+ public static String transformMarkdown(String markdown) {
+ PegDownProcessor pd = new PegDownProcessor(ALL);
+ String html = pd.markdownToHtml(markdown);
+ return html;
}
/**
@@ -60,22 +53,13 @@ public class MarkdownUtils { * @return html version of the markdown text
* @throws java.text.ParseException
*/
- public static String transformMarkdown(Reader markdownReader) throws java.text.ParseException {
+ public static String transformMarkdown(Reader markdownReader) throws IOException {
// Read raw markdown content and transform it to html
StringWriter writer = new StringWriter();
try {
- Markdown md = new Markdown();
- md.transform(markdownReader, writer);
- return writer.toString().trim();
- } catch (StringIndexOutOfBoundsException e) {
- LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!", e);
- throw new java.text.ParseException(e.getMessage(), 0);
- } catch (ParseException p) {
- LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!", p);
- throw new java.text.ParseException(p.getMessage(), 0);
- } catch (Exception e) {
- LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!", e);
- throw new java.text.ParseException(e.getMessage(), 0);
+ IOUtils.copy(markdownReader, writer);
+ String markdown = writer.toString();
+ return transformMarkdown(markdown);
} finally {
try {
writer.close();
diff --git a/src/main/java/com/gitblit/wicket/pages/MarkdownPage.java b/src/main/java/com/gitblit/wicket/pages/MarkdownPage.java index 5aa80294..188a5b4b 100644 --- a/src/main/java/com/gitblit/wicket/pages/MarkdownPage.java +++ b/src/main/java/com/gitblit/wicket/pages/MarkdownPage.java @@ -16,7 +16,6 @@ package com.gitblit.wicket.pages;
import java.text.MessageFormat;
-import java.text.ParseException;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
@@ -60,7 +59,8 @@ public class MarkdownPage extends RepositoryPage { String htmlText;
try {
htmlText = MarkdownUtils.transformMarkdown(markdownText);
- } catch (ParseException p) {
+ } catch (Exception e) {
+ logger.error("failed to transform markdown", e);
markdownText = MessageFormat.format("<div class=\"alert alert-error\"><strong>{0}:</strong> {1}</div>{2}", getString("gb.error"), getString("gb.markdownFailure"), markdownText);
htmlText = StringUtils.breakLinesForHtml(markdownText);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java index e5ce22a1..dabaed03 100644 --- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java @@ -75,7 +75,7 @@ import com.gitblit.wicket.panels.RefsPanel; public abstract class RepositoryPage extends RootPage {
- private final Logger logger = LoggerFactory.getLogger(getClass());
+ protected final Logger logger = LoggerFactory.getLogger(getClass());
private final String PARAM_STAR = "star";
diff --git a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java index 00d77a4e..cc9697c6 100644 --- a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java @@ -18,7 +18,6 @@ package com.gitblit.wicket.pages; import java.awt.Color;
import java.awt.Dimension;
import java.text.MessageFormat;
-import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
@@ -166,7 +165,8 @@ public class SummaryPage extends RepositoryPage { markdownText = JGitUtils.getStringContent(r, head.getTree(), readme, encodings);
htmlText = MarkdownUtils.transformMarkdown(markdownText);
}
- } catch (ParseException p) {
+ } catch (Exception e) {
+ logger.error("failed to transform markdown", e);
markdownText = MessageFormat.format("<div class=\"alert alert-error\"><strong>{0}:</strong> {1}</div>{2}", getString("gb.error"), getString("gb.markdownFailure"), markdownText);
htmlText = StringUtils.breakLinesForHtml(markdownText);
}
diff --git a/src/site/design.mkd b/src/site/design.mkd index ce676201..1f1635a4 100644 --- a/src/site/design.mkd +++ b/src/site/design.mkd @@ -29,7 +29,6 @@ The following dependencies are automatically downloaded by Gitblit GO (or alread - [JGit][jgit] (EDL 1.0)
- [Wicket](http://wicket.apache.org) (Apache 2.0)
- [WicketStuff GoogleCharts](https://github.com/wicketstuff/core/wiki/GoogleCharts) (Apache 2.0)
-- [MarkdownPapers](http://markdown.tautua.org) (Apache 2.0)
- [Jetty](http://eclipse.org/jetty) (Apache 2.0, EPL 1.0)
- [SLF4J](http://www.slf4j.org) (MIT/X11)
- [Log4j](http://logging.apache.org/log4j) (Apache 2.0)
@@ -53,6 +52,7 @@ The following dependencies are automatically downloaded by Gitblit GO (or alread - [Guava](https://code.google.com/p/guava-libraries) (Apache 2.0)
- [libpam4j](https://github.com/kohsuke/libpam4j) (MIT)
- [commons-codec](http://commons.apache.org/proper/commons-codec) (Apache 2.0)
+- [pegdown](https://github.com/sirthias/pegdown) (Apache 2.0)
### Other Build Dependencies
- [Fancybox image viewer](http://fancybox.net) (MIT and GPL dual-licensed)
diff --git a/src/test/java/com/gitblit/tests/MarkdownUtilsTest.java b/src/test/java/com/gitblit/tests/MarkdownUtilsTest.java index cd7ca020..34583747 100644 --- a/src/test/java/com/gitblit/tests/MarkdownUtilsTest.java +++ b/src/test/java/com/gitblit/tests/MarkdownUtilsTest.java @@ -16,9 +16,6 @@ package com.gitblit.tests;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.text.ParseException;
import org.junit.Test;
@@ -28,8 +25,8 @@ public class MarkdownUtilsTest { @Test
public void testMarkdown() throws Exception {
- assertEquals("<h1> H1</h1>", MarkdownUtils.transformMarkdown("# H1"));
- assertEquals("<h2> H2</h2>", MarkdownUtils.transformMarkdown("## H2"));
+ assertEquals("<h1>H1</h1>", MarkdownUtils.transformMarkdown("# H1"));
+ assertEquals("<h2>H2</h2>", MarkdownUtils.transformMarkdown("## H2"));
assertEquals("<p><strong>THIS</strong> is a test</p>",
MarkdownUtils.transformMarkdown("**THIS** is a test"));
assertEquals("<p>** THIS ** is a test</p>",
@@ -43,12 +40,5 @@ public class MarkdownUtilsTest { MarkdownUtils.transformMarkdown("<table><tr><td>test</td></tr></table>"));
assertEquals("<table><tr><td><test></td></tr></table>",
MarkdownUtils.transformMarkdown("<table><tr><td><test></td></tr></table>"));
-
- try {
- MarkdownUtils.transformMarkdown((String) null);
- assertTrue(false);
- } catch (ParseException p) {
- assertTrue(p != null);
- }
}
}
\ No newline at end of file |