Permalink
Browse files

Merge branch 'release/1.0.2'

  • Loading branch information...
2 parents ae222a6 + 64276bf commit 979326f75735eead64df2f09dd96f74c8093396e @sirthias committed Jul 5, 2011
View
17 .idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,17 @@
+<component name="InspectionProjectProfileManager">
+ <profile version="1.0" is_locked="false">
+ <option name="myName" value="Project Default" />
+ <option name="myLocal" value="false" />
+ <inspection_tool class="Fix shebang" enabled="true" level="WARNING" enabled_by_default="true">/bin/sh#/bin/bash</inspection_tool>
+ <inspection_tool class="NullableProblems" enabled="false" level="WARNING" enabled_by_default="false">
+ <option name="REPORT_NULLABLE_METHOD_OVERRIDES_NOTNULL" value="true" />
+ <option name="REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL" value="true" />
+ <option name="REPORT_NOTNULL_PARAMETER_OVERRIDES_NULLABLE" value="true" />
+ <option name="REPORT_NOT_ANNOTATED_PARAMETER_OVERRIDES_NOTNULL" value="true" />
+ <option name="REPORT_NOT_ANNOTATED_GETTER" value="true" />
+ <option name="REPORT_NOT_ANNOTATED_SETTER_PARAMETER" value="true" />
+ <option name="REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS" value="true" />
+ <option name="REPORT_NULLS_PASSED_TO_NON_ANNOTATED_METHOD" value="true" />
+ </inspection_tool>
+ </profile>
+</component>
View
7 .idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,7 @@
+<component name="InspectionProjectProfileManager">
+ <settings>
+ <option name="PROJECT_PROFILE" value="Project Default" />
+ <option name="USE_PROJECT_PROFILE" value="true" />
+ <version value="1.0" />
+ </settings>
+</component>
View
11 CHANGELOG
@@ -1,6 +1,15 @@
+Version 1.0.2 (2011-07-05)
+--------------------------
+- Simplify custom extensions by making `private` fields/methods of ToHtmlSerializer and Parser `protected`
+- Fixed #20 (support GFM fenced code blocks)
+- Fixed #21 (simplify integration of custom code transformers)
+- Fixed #22 (some characters/sequences break links when AutoLinks extensions is on)
+- Fixed broken Java 1.5 compatibility (thx to Julien Nicoulaud)
+- Fixed maven build: add testng and jtidy deps for tests, and configure the compiler plugin for java 5 (thx to Lukas Theussl)
+
Version 1.0.1 (2011-05-17)
--------------------------
-- Fixed #18 (code blocks in list items split by lines)
+- Fixed #18 (code blocks in list items split by lines)
Version 1.0.0 (2011-05-13)
--------------------------
View
8 buildfile
@@ -2,13 +2,13 @@ repositories.remote << 'http://repo1.maven.org/maven2'
repositories.remote << 'http://scala-tools.org/repo-releases'
#repositories.remote << 'http://scala-tools.org/repo-snapshots'
-upload_to = 'scala_tools_releases'
-#upload_to = 'scala_tools_snapshots'
+#upload_to = 'scala_tools_releases'
+upload_to = 'scala_tools_snapshots'
#upload_to = 'silo'
url, user, pass = Buildr.settings.user[upload_to].values_at('url', 'user', 'pass')
repositories.release_to = { :url => url, :username => user, :password => pass }
-VERSION_NUMBER = '1.0.1'
+VERSION_NUMBER = '1.0.2'
desc 'The pegdown project'
define 'pegdown' do
@@ -32,7 +32,7 @@ define 'pegdown' do
meta_inf << file('NOTICE')
- PARBOILED_VERSION = '1.0.0'
+ PARBOILED_VERSION = '1.0.1'
PARBOILED = [
"org.parboiled:parboiled-core:jar:#{PARBOILED_VERSION}",
"org.parboiled:parboiled-core:jar:sources:#{PARBOILED_VERSION}",
View
33 pom.xml
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.pegdown</groupId>
<artifactId>pegdown</artifactId>
- <version>1.0.1</version>
+ <version>1.0.2</version>
<inceptionYear>2010</inceptionYear>
<licenses>
<license>
@@ -12,16 +12,43 @@
<distribution>repo</distribution>
</license>
</licenses>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
<dependencies>
<dependency>
<groupId>org.parboiled</groupId>
<artifactId>parboiled-core</artifactId>
- <version>1.0.0</version>
+ <version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.parboiled</groupId>
<artifactId>parboiled-java</artifactId>
- <version>1.0.0</version>
+ <version>1.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.jtidy</groupId>
+ <artifactId>jtidy</artifactId>
+ <version>r938</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.14.10</version>
+ <scope>test</scope>
</dependency>
</dependencies>
<repositories>
View
34 src/main/java/org/pegdown/Parser.java
@@ -47,14 +47,14 @@
@SuppressWarnings( {"InfiniteRecursion"})
public class Parser extends BaseParser<Object> implements Extensions {
- private static final char CROSSED_OUT = '\uffff';
+ protected static final char CROSSED_OUT = '\uffff';
public interface ParseRunnerProvider {
ParseRunner<Node> get(Rule rule);
}
- private final int options;
- private final ParseRunnerProvider parseRunnerProvider;
+ protected final int options;
+ protected final ParseRunnerProvider parseRunnerProvider;
final List<AbbreviationNode> abbreviations = new ArrayList<AbbreviationNode>();
final List<ReferenceNode> references = new ArrayList<ReferenceNode>();
@@ -169,10 +169,12 @@ public Rule FencedCodeBlock() {
@Cached
public Rule CodeFence(Var<Integer> markerLength) {
return Sequence(
- NOrMore('~', 3),
+ FirstOf(NOrMore('~', 3), NOrMore('`', 3)),
(markerLength.isSet() && matchLength() == markerLength.get()) ||
(markerLength.isNotSet() && markerLength.set(matchLength())),
- Sp(), Newline()
+ Sp(),
+ ZeroOrMore(TestNot(Newline()), ANY), // GFM code type identifier
+ Newline()
);
}
@@ -527,7 +529,7 @@ public boolean isHtmlTag(String string) {
return Arrays.binarySearch(HTML_TAGS, string) >= 0;
}
- private static final String[] HTML_TAGS = new String[] {
+ protected static final String[] HTML_TAGS = new String[] {
"address", "blockquote", "center", "dd", "dir", "div", "dl", "dt", "fieldset", "form", "frameset", "h1",
"h2", "h3", "h4", "h5", "h6", "hr", "isindex", "li", "menu", "noframes", "noscript", "ol", "p", "pre",
"script", "style", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "ul"
@@ -552,8 +554,16 @@ public Rule InlineOrIntermediateEndline() {
@MemoMismatches
public Rule Inline() {
+ return FirstOf(Link(), NonLinkInline());
+ }
+
+ public Rule NonAutoLinkInline() {
+ return FirstOf(NonAutoLink(), NonLinkInline());
+ }
+
+ public Rule NonLinkInline() {
return FirstOf(new ArrayBuilder<Rule>()
- .add(Link(), Str(), Endline(), UlOrStarLine(), Space(), StrongOrEmph(), Image(), Code(), InlineHtml(),
+ .add(Str(), Endline(), UlOrStarLine(), Space(), StrongOrEmph(), Image(), Code(), InlineHtml(),
Entity(), EscapedChar())
.addNonNulls(ext(QUOTES) ? new Rule[] {SingleQuoted(), DoubleQuoted(), DoubleAngleQuoted()} : null)
.addNonNulls(ext(SMARTS) ? new Rule[] {Smarts()} : null)
@@ -680,6 +690,10 @@ public Rule Link() {
);
}
+ public Rule NonAutoLink() {
+ return NodeSequence(Sequence(Label(), FirstOf(ExplicitLink(), ReferenceLink())));
+ }
+
public Rule ExplicitLink() {
Var<ExpLinkNode> node = new Var<ExpLinkNode>();
return Sequence(
@@ -783,7 +797,7 @@ public Rule Label() {
return Sequence(
'[',
push(new SuperNode()),
- OneOrMore(TestNot(']'), Inline(), addAsChild()),
+ OneOrMore(TestNot(']'), NonAutoLinkInline(), addAsChild()),
']'
);
}
@@ -1247,7 +1261,7 @@ public RootNode parseInternal(StringBuilderVar block) {
return rootNode;
}
- private void fixIndices(Node node, int[] ixMap) {
+ protected void fixIndices(Node node, int[] ixMap) {
((AbstractNode) node).mapIndices(ixMap);
for (Node subNode : node.getChildren()) {
fixIndices(subNode, ixMap);
@@ -1270,7 +1284,7 @@ public RootNode parseInternal(char[] source) {
return parseRunnerProvider.get(Root()).run(source);
}
- private interface SuperNodeCreator {
+ protected interface SuperNodeCreator {
SuperNode create(Node child);
}
}
View
42 src/main/java/org/pegdown/ToHtmlSerializer.java
@@ -29,14 +29,14 @@
import static org.parboiled.common.Preconditions.checkArgNotNull;
public class ToHtmlSerializer implements Visitor, Printer.Encoder {
- private Printer printer = new Printer();
- private final Map<String, ReferenceNode> references = new HashMap<String, ReferenceNode>();
- private final Map<String, String> abbreviations = new HashMap<String, String>();
+ protected Printer printer = new Printer();
+ protected final Map<String, ReferenceNode> references = new HashMap<String, ReferenceNode>();
+ protected final Map<String, String> abbreviations = new HashMap<String, String>();
- private TableNode currentTableNode;
- private int currentTableColumn;
- private boolean inTableHeader;
- private Random random = new Random(0x2626); // for email obfuscation
+ protected TableNode currentTableNode;
+ protected int currentTableColumn;
+ protected boolean inTableHeader;
+ protected Random random = new Random(0x2626); // for email obfuscation
public String toHtml(RootNode astRoot) {
checkArgNotNull(astRoot, "astRoot");
@@ -125,7 +125,7 @@ public void visit(HeaderNode node) {
public void visit(HtmlBlockNode node) {
String text = node.getText();
- if (!text.isEmpty()) printer.println();
+ if (text.length() > 0) printer.println();
printer.print(text);
}
@@ -302,12 +302,18 @@ public void visit(TableRowNode node) {
public void visit(VerbatimNode node) {
printer.println().print("<pre><code>");
String text = node.getText();
+ text = transformVerbatimText(text);
+ printer.printEncoded(text, this);
+ printer.print("</code></pre>");
+ }
+
+ public String transformVerbatimText(String text) {
+ // transform all initial newlines to HTML breaks
while(text.charAt(0) == '\n') {
printer.print("<br/>");
text = text.substring(1);
}
- printer.printEncoded(text, this);
- printer.print("</code></pre>");
+ return text;
}
public void visit(TextNode node) {
@@ -351,32 +357,32 @@ public String encode(char c) {
// helpers
- private void visitChildren(SuperNode node) {
+ protected void visitChildren(SuperNode node) {
for (Node child : node.getChildren()) {
child.accept(this);
}
}
- private void printTag(TextNode node, String tag) {
+ protected void printTag(TextNode node, String tag) {
printer
.print('<').print(tag).print('>')
.printEncoded(node.getText(), this)
.print('<').print('/').print(tag).print('>');
}
- private void printTag(SuperNode node, String tag) {
+ protected void printTag(SuperNode node, String tag) {
printer.print('<').print(tag).print('>');
visitChildren(node);
printer.print('<').print('/').print(tag).print('>');
}
- private void printIndentedTag(SuperNode node, String tag) {
+ protected void printIndentedTag(SuperNode node, String tag) {
printer.println().print('<').print(tag).print('>').indent(+2);
visitChildren(node);
printer.indent(-2).println().print('<').print('/').print(tag).print('>');
}
- private String printToString(Runnable runnable) {
+ protected String printToString(Runnable runnable) {
Printer priorPrinter = printer;
printer = new Printer();
runnable.run();
@@ -385,7 +391,7 @@ private String printToString(Runnable runnable) {
return result;
}
- private String normalize(String string) {
+ protected String normalize(String string) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < string.length(); i++) {
char c = string.charAt(i);
@@ -400,7 +406,7 @@ private String normalize(String string) {
return sb.toString();
}
- private String obfuscate(String email) {
+ protected String obfuscate(String email) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < email.length(); i++) {
char c = email.charAt(i);
@@ -421,7 +427,7 @@ private String obfuscate(String email) {
return sb.toString();
}
- public void printWithAbbreviations(String string) {
+ protected void printWithAbbreviations(String string) {
Map<Integer, Map.Entry<String, String>> expansions = null;
for (Map.Entry<String, String> entry : abbreviations.entrySet()) {
View
5 src/test/java/org/pegdown/CustomPegDownTest.java
@@ -48,11 +48,12 @@ public PegDownProcessor getProcessor() {
@Test
public void customPegDownTests() {
- /*test("pegdown/Abbreviations");
+ test("pegdown/Abbreviations");
test("pegdown/Autolinks");
test("pegdown/Bug_in_0.8.5.1");
- test("pegdown/Bug_in_0.8.5.4");*/
+ test("pegdown/Bug_in_0.8.5.4");
test("pegdown/Bug_in_1.0.0");
+ test("pegdown/GFM_Fenced_Code_Blocks");
test("pegdown/Linebreaks");
test("pegdown/Parens_in_URL");
test("pegdown/Quoted Blockquote");
View
7 src/test/resources/pegdown/Autolinks.html
@@ -7,4 +7,9 @@
and URI links (<a href="mailto:joe@somewhere.com">joe@somewhere.com</a>
is such an example).<br/>
<a href="ftp://somesite.org:1234">ftp://somesite.org:1234</a>: this would be another one!</p>
-
+<p>The following links should work just normally:</p>
+<ul>
+<li><a href="http://example">example</a></li>
+<li><a href="http://example">ex@mple</a></li>
+<li><a href="http://example">example://</a></li>
+</ul>
View
6 src/test/resources/pegdown/Autolinks.md
@@ -7,3 +7,9 @@ pegdown tries to be smart and not include trailing
punctuation marks like commas and such in the email
and URI links (joe@somewhere.com is such an example).
ftp://somesite.org:1234: this would be another one!
+
+The following links should work just normally:
+
+* [example](http://example)
+* [ex@mple](http://example)
+* [example://](http://example)
View
7 src/test/resources/pegdown/GFM_Fenced_Code_Blocks.html
@@ -0,0 +1,7 @@
+<pre>
+<code>
+class Example(name: String) {
+ val field: Option[Int] = None
+}
+</code>
+</pre>
View
5 src/test/resources/pegdown/GFM_Fenced_Code_Blocks.md
@@ -0,0 +1,5 @@
+```scala
+class Example(name: String) {
+ val field: Option[Int] = None
+}
+```

0 comments on commit 979326f

Please sign in to comment.