]> source.dussan.org Git - gitblit.git/commitdiff
Replaced MarkdownPapers with pegdown
authorJames Moger <james.moger@gitblit.com>
Fri, 18 Oct 2013 21:46:22 +0000 (17:46 -0400)
committerJames Moger <james.moger@gitblit.com>
Fri, 18 Oct 2013 21:46:22 +0000 (17:46 -0400)
Change-Id: I11eb50ba1ef0bef8ac47bf6f7b17e0f79ecd3f2d

12 files changed:
.classpath
NOTICE
build.moxie
gitblit.iml
releases.moxie
src/main/java/com/gitblit/GitBlit.java
src/main/java/com/gitblit/utils/MarkdownUtils.java
src/main/java/com/gitblit/wicket/pages/MarkdownPage.java
src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
src/main/java/com/gitblit/wicket/pages/SummaryPage.java
src/site/design.mkd
src/test/java/com/gitblit/tests/MarkdownUtilsTest.java

index ba81e42f81d660e1ac30322c106d68b6a52f0df6..08039d6f04913da95d145c8134c33a21b51b50bf 100644 (file)
        <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" />
diff --git a/NOTICE b/NOTICE
index 6468c497fc03fbc98502d3723d84bb0e0fa6b775..750af00d9e1331415a0d7f81906686b9467e770d 100644 (file)
--- a/NOTICE
+++ b/NOTICE
@@ -55,14 +55,6 @@ WicketStuff GoogleCharts
 \r
    https://github.com/wicketstuff/core/wiki/GoogleCharts   \r
    \r
----------------------------------------------------------------------------\r
-MarkdownPapers\r
----------------------------------------------------------------------------\r
-   MarkdownPapers, released under the\r
-   Apache Software License, Version 2.0.\r
-\r
-   http://markdown.tautua.org\r
-   \r
 ---------------------------------------------------------------------------\r
 Jetty\r
 ---------------------------------------------------------------------------\r
@@ -318,4 +310,12 @@ commons-codec
    Apache License 2.0.\r
    \r
    http://commons.apache.org/proper/commons-codec\r
-    
\ No newline at end of file
+\r
+---------------------------------------------------------------------------\r
+pegdown\r
+---------------------------------------------------------------------------\r
+   pegdown, release under the\r
+   Apache License 2.0.\r
+   \r
+   https://github.com/sirthias/pegdown\r
+        
\ No newline at end of file
index df0a36d1d59471755e741f375ad4376accab94cd..44f6d059235cb3f69a56ac44ab06ed1b8697632b 100644 (file)
@@ -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
index 736376b3131bb6c5ece6aed090a2effffefced97..c31d1e9e56ab92cf8b970be5bd27b1d8e4ff7515 100644 (file)
       </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>
index e086f43ef0253675426e7119bb0f1255f8cc5992..a48473dad923a5cf10b8a2dc3f138c77cf98de17 100644 (file)
@@ -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' }
index 7f82432d32679abf3bc307462a552ab502b17c76..a23dd8c275e2676dbbfdb2bae70bb890b17e2a87 100644 (file)
@@ -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;
index 152423646a551813bfb80b15e6e5e87fa7efe0e5..33d7a6ae1877f7d519da7814b7c620481e2c36fa 100644 (file)
  */\r
 package com.gitblit.utils;\r
 \r
+import static org.pegdown.Extensions.ALL;\r
+\r
 import java.io.IOException;\r
 import java.io.Reader;\r
-import java.io.StringReader;\r
 import java.io.StringWriter;\r
 \r
-import org.slf4j.LoggerFactory;\r
-import org.tautua.markdownpapers.Markdown;\r
-import org.tautua.markdownpapers.parser.ParseException;\r
+import org.apache.commons.io.IOUtils;\r
+import org.pegdown.PegDownProcessor;\r
 \r
 /**\r
  * Utility methods for transforming raw markdown text to html.\r
@@ -39,17 +39,10 @@ public class MarkdownUtils {
         * @return html version of markdown text\r
         * @throws java.text.ParseException\r
         */\r
-       public static String transformMarkdown(String markdown) throws java.text.ParseException {\r
-               try {\r
-                       StringReader reader = new StringReader(markdown);\r
-                       String html = transformMarkdown(reader);\r
-                       reader.close();\r
-                       return html;\r
-               } catch (IllegalArgumentException e) {\r
-                       throw new java.text.ParseException(e.getMessage(), 0);\r
-               } catch (NullPointerException p) {\r
-                       throw new java.text.ParseException("Markdown string is null!", 0);\r
-               }\r
+       public static String transformMarkdown(String markdown) {\r
+               PegDownProcessor pd = new PegDownProcessor(ALL);\r
+               String html = pd.markdownToHtml(markdown);\r
+               return html;\r
        }\r
 \r
        /**\r
@@ -60,22 +53,13 @@ public class MarkdownUtils {
         * @return html version of the markdown text\r
         * @throws java.text.ParseException\r
         */\r
-       public static String transformMarkdown(Reader markdownReader) throws java.text.ParseException {\r
+       public static String transformMarkdown(Reader markdownReader) throws IOException {\r
                // Read raw markdown content and transform it to html\r
                StringWriter writer = new StringWriter();\r
                try {\r
-                       Markdown md = new Markdown();\r
-                       md.transform(markdownReader, writer);\r
-                       return writer.toString().trim();\r
-               } catch (StringIndexOutOfBoundsException e) {\r
-                       LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!", e);\r
-                       throw new java.text.ParseException(e.getMessage(), 0);\r
-               } catch (ParseException p) {\r
-                       LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!", p);\r
-                       throw new java.text.ParseException(p.getMessage(), 0);\r
-               } catch (Exception e) {\r
-                       LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!", e);\r
-                       throw new java.text.ParseException(e.getMessage(), 0);\r
+                       IOUtils.copy(markdownReader, writer);\r
+                       String markdown = writer.toString();\r
+                       return transformMarkdown(markdown);\r
                } finally {\r
                        try {\r
                                writer.close();\r
index 5aa8029450f60288426319c46d16549e879d0fb7..188a5b4b5ebeb8f4898e80ec11c224e1e40b0e74 100644 (file)
@@ -16,7 +16,6 @@
 package com.gitblit.wicket.pages;\r
 \r
 import java.text.MessageFormat;\r
-import java.text.ParseException;\r
 \r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.markup.html.basic.Label;\r
@@ -60,7 +59,8 @@ public class MarkdownPage extends RepositoryPage {
                String htmlText;\r
                try {\r
                        htmlText = MarkdownUtils.transformMarkdown(markdownText);\r
-               } catch (ParseException p) {\r
+               } catch (Exception e) {\r
+                       logger.error("failed to transform markdown", e);\r
                        markdownText = MessageFormat.format("<div class=\"alert alert-error\"><strong>{0}:</strong> {1}</div>{2}", getString("gb.error"), getString("gb.markdownFailure"), markdownText);\r
                        htmlText = StringUtils.breakLinesForHtml(markdownText);\r
                }\r
index e5ce22a1e3063b383b71fa48a45b110a155d6bc3..dabaed037f3eeb8b6826c57aa1d1f2afb77d38a3 100644 (file)
@@ -75,7 +75,7 @@ import com.gitblit.wicket.panels.RefsPanel;
 \r
 public abstract class RepositoryPage extends RootPage {\r
 \r
-       private final Logger logger = LoggerFactory.getLogger(getClass());\r
+       protected final Logger logger = LoggerFactory.getLogger(getClass());\r
 \r
        private final String PARAM_STAR = "star";\r
 \r
index 00d77a4ee666a1a2c1910758ae8699f1fd3adf72..cc9697c6f6460705838912132480e645f300ad26 100644 (file)
@@ -18,7 +18,6 @@ package com.gitblit.wicket.pages;
 import java.awt.Color;\r
 import java.awt.Dimension;\r
 import java.text.MessageFormat;\r
-import java.text.ParseException;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
 \r
@@ -166,7 +165,8 @@ public class SummaryPage extends RepositoryPage {
                                        markdownText = JGitUtils.getStringContent(r, head.getTree(), readme, encodings);\r
                                        htmlText = MarkdownUtils.transformMarkdown(markdownText);\r
                                }\r
-                       } catch (ParseException p) {\r
+                       } catch (Exception e) {\r
+                               logger.error("failed to transform markdown", e);\r
                                markdownText = MessageFormat.format("<div class=\"alert alert-error\"><strong>{0}:</strong> {1}</div>{2}", getString("gb.error"), getString("gb.markdownFailure"), markdownText);\r
                                htmlText = StringUtils.breakLinesForHtml(markdownText);\r
                        }\r
index ce676201c4798cbe5928a2b6fdb68b4c559fca99..1f1635a4cc409a0ebbd1b165b8582069e70cd314 100644 (file)
@@ -29,7 +29,6 @@ The following dependencies are automatically downloaded by Gitblit GO (or alread
 - [JGit][jgit] (EDL 1.0)\r
 - [Wicket](http://wicket.apache.org) (Apache 2.0)\r
 - [WicketStuff GoogleCharts](https://github.com/wicketstuff/core/wiki/GoogleCharts) (Apache 2.0)\r
-- [MarkdownPapers](http://markdown.tautua.org) (Apache 2.0)\r
 - [Jetty](http://eclipse.org/jetty) (Apache 2.0, EPL 1.0)\r
 - [SLF4J](http://www.slf4j.org) (MIT/X11)\r
 - [Log4j](http://logging.apache.org/log4j) (Apache 2.0)\r
@@ -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)\r
 - [libpam4j](https://github.com/kohsuke/libpam4j) (MIT)\r
 - [commons-codec](http://commons.apache.org/proper/commons-codec) (Apache 2.0)\r
+- [pegdown](https://github.com/sirthias/pegdown) (Apache 2.0)\r
 \r
 ### Other Build Dependencies\r
 - [Fancybox image viewer](http://fancybox.net) (MIT and GPL dual-licensed)\r
index cd7ca0201406d3bb73900efff8145cabc7ce7e44..3458374799becb0e1ffaa6b5c7f80b6f40b79e82 100644 (file)
@@ -16,9 +16,6 @@
 package com.gitblit.tests;\r
 \r
 import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import java.text.ParseException;\r
 \r
 import org.junit.Test;\r
 \r
@@ -28,8 +25,8 @@ public class MarkdownUtilsTest {
 \r
        @Test\r
        public void testMarkdown() throws Exception {\r
-               assertEquals("<h1> H1</h1>", MarkdownUtils.transformMarkdown("# H1"));\r
-               assertEquals("<h2> H2</h2>", MarkdownUtils.transformMarkdown("## H2"));\r
+               assertEquals("<h1>H1</h1>", MarkdownUtils.transformMarkdown("# H1"));\r
+               assertEquals("<h2>H2</h2>", MarkdownUtils.transformMarkdown("## H2"));\r
                assertEquals("<p><strong>THIS</strong> is a test</p>",\r
                                MarkdownUtils.transformMarkdown("**THIS** is a test"));\r
                assertEquals("<p>** THIS ** is a test</p>",\r
@@ -43,12 +40,5 @@ public class MarkdownUtilsTest {
                                MarkdownUtils.transformMarkdown("<table><tr><td>test</td></tr></table>"));\r
                assertEquals("<table><tr><td>&lt;test&gt;</td></tr></table>",\r
                                MarkdownUtils.transformMarkdown("<table><tr><td>&lt;test&gt;</td></tr></table>"));\r
-\r
-               try {\r
-                       MarkdownUtils.transformMarkdown((String) null);\r
-                       assertTrue(false);\r
-               } catch (ParseException p) {\r
-                       assertTrue(p != null);\r
-               }\r
        }\r
 }
\ No newline at end of file