Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Eclipse project files
.settings
.project
.classpath

# Maven target directory
target/
84 changes: 0 additions & 84 deletions build.xml

This file was deleted.

Binary file removed lib/core-renderer.jar
Binary file not shown.
Binary file removed lib/freemarker.jar
Binary file not shown.
Binary file removed lib/groovy-all-1.6.7.jar
Binary file not shown.
Binary file removed lib/iText-2.0.8.jar
Binary file not shown.
Binary file removed lib/jdom.jar
Binary file not shown.
Binary file removed lib/tagsoup-1.2.jar
Binary file not shown.
95 changes: 95 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nineci</groupId>
<artifactId>markdownplus</artifactId>
<version>0.0.1-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.8.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.ccil.cowan.tagsoup</groupId>
<artifactId>tagsoup</artifactId>
<version>1.2</version>
<!-- <version>1.2.1</version> -->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.16</version>
<!-- <version>2.3.19</version> -->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>core-renderer</artifactId>
<version>R8</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.0.8</version>
<!-- <version>2.1.7</version> -->
<scope>compile</scope>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<verbose>true</verbose>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.6.0-01</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
46 changes: 46 additions & 0 deletions src/main/assembly/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>assembly</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>README*</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/templates</directory>
<outputDirectory>templates</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/site</directory>
<outputDirectory>docs</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<source>mdp</source>
<outputDirectory>/</outputDirectory>
<filtered>true</filtered>
</file>
</files>
<dependencySets>
<!-- Put all the required dependencies (minus any test scoped deps) in the lib folder -->
<dependencySet>
<outputDirectory>/lib</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
Authors: Joshua Burnett
http://www.9ci.com/markdownplus

Regex adapted from markdownj
Regex adapted from markdownj
Copyright (c) 2005, Martian Software
Authors: Pete Bevin, John Mutchek
http://www.martiansoftware.com/markdownj

Regex adapted from from PHP Markdown & Extra
Copyright (c) 2004-2009 Michel Fortin
Copyright (c) 2004-2009 Michel Fortin
<http://michelf.com/projects/php-markdown/>
*/

Expand All @@ -19,11 +19,11 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;

class ListParser {

MarkdownPlus markdownPlus

int listLevel=0

MarkdownText parse(MarkdownText text) {
int lessThanTab = MarkdownText.TAB_WIDTH - 1

Expand All @@ -50,15 +50,15 @@ class ListParser {
String list = m.group(1)
String listStart = m.group(3)
String listType = listStart.matches("[*+-]") ? 'ul':'ol'
//turn 2 line feeds to 3 so that last items will be turned to a paragraph

//turn 2 line feeds to 3 so that last items will be turned to a paragraph
list = list.replaceAll(/\n{2,}/, "\n\n\n");

String result = processListItems(list);

def isUL
String linefeed = ""

if(listLevel>0){
result = result.replaceAll(/\s+$/, "");
isUL = "ul" == listType
Expand All @@ -67,7 +67,7 @@ class ListParser {
linefeed ="\n"
}

return "<$listType>${linefeed}${result}</$listType>\n".toString()
return "<$listType>${linefeed}${result}</$listType>\n".toString()
}
def pat = (listLevel>0) ? "^" : /(?:(?<=\n\n)|\A\n?)/
Pattern matchStartOfLine = Pattern.compile(pat + wholeList, Pattern.MULTILINE);
Expand All @@ -77,10 +77,10 @@ class ListParser {

String processListItems(String list) {
listLevel++;

// Trim trailing blank lines:
list = list.replaceAll(/\n{2,}\z/, '\n');

String listMarker = /[-+\*]|\d+[.]/
String pat = /(?m)(\n)?/ +
/^([ \t]*)/ + //indentSpace
Expand All @@ -89,7 +89,7 @@ class ListParser {
/(\n{1,2}))/ + //tailing blank lines
/(?=\n*(\z|\2(${listMarker})[ \t]+))/

list = list.replaceAll(pat){ String[] group->
list = list.replaceAll(pat){ List group-> //Groovy 1.8.6 now passes a List<String> rather than a String[]
String text = group[4];
MarkdownText item = new MarkdownText(text);
String indentSpace = group[1];
Expand Down
Loading