fix link and image definition to allow trailing space
diff --git a/core/src/main/jjtree/Markdown.jjt b/core/src/main/jjtree/Markdown.jjt
index 1cfc3e3..604e70c 100644
--- a/core/src/main/jjtree/Markdown.jjt
+++ b/core/src/main/jjtree/Markdown.jjt
@@ -478,12 +478,13 @@
(
(
(
- t = <AMPERSAND>
+ t = <CHAR_SEQUENCE>
+ | t = <SPACE>
+ | t = <AMPERSAND>
| t = <BACKTICK>
| t = <BACKSLASH>
| t = <BANG>
| t = <CHAR_ENTITY_REF>
- | t = <CHAR_SEQUENCE>
| t = <CODE_SPAN>
| t = <COMMENT_OPEN>
| t = <COMMENT_CLOSE>
@@ -504,7 +505,6 @@
| t = <SHARP>
| t = <SINGLE_QUOTE>
| t = <SLASH>
- | t = <SPACE>
| t = <STAR>
| t = <UNDERSCORE>
) { jjtThis.append(t.image); }
@@ -523,6 +523,7 @@
( <SPACE> )? ":"
( Whitespace() )?
resource = Resource() { jjtThis.setResource(resource); }
+ ( Whitespace() )?
}
void List() #List : {
@@ -712,8 +713,8 @@
"]"
|
"("
- ( resource = Resource() )?
( Whitespace() )?
+ ( resource = Resource() ( Whitespace() )? )?
{ jjtThis.setResource(resource); }
")"
)
@@ -734,8 +735,9 @@
"]"
|
"("
- (resource = Resource() { jjtThis.setResource(resource); })?
( Whitespace() )?
+ (resource = Resource() ( Whitespace() )? )?
+ { jjtThis.setResource(resource); }
")"
)?
}
@@ -796,7 +798,9 @@
} {
(
(
- t = <AMPERSAND>
+ t = <CHAR_SEQUENCE>
+ | t = <SPACE>
+ | t = <AMPERSAND>
| t = <BACKSLASH>
| t = <COLON>
| t = <EQ>
@@ -806,9 +810,7 @@
| t = <LT>
| t = <RPAREN>
| t = <SLASH>
- | t = <SPACE>
| t = <TAB>
- | t = <CHAR_SEQUENCE>
| t = <UNDERSCORE>
) { buff.append(t.image); }
)+
@@ -822,7 +824,7 @@
url = url()
(
Whitespace()
- hint = title()
+ ( hint = title() )?
)?
{ return new Resource(url, hint); }
}
@@ -847,16 +849,16 @@
(
(
t = <CHAR_SEQUENCE>
- | t = "&"
+ | t = <AMPERSAND>
+ | t = <BACKSLASH>
+ | t = <COLON>
| t = <EQ>
- | t = "(" { parentheses++; }
- | LOOKAHEAD({parentheses > 0}) t = ")" { parentheses--; }
- | t = "["
- | t = "]"
- | t = ":"
- | t = "/"
- | t = "\\"
- | t = "#"
+ | t = <LBRACKET>
+ | t = <LPAREN> { parentheses++; }
+ | t = <RBRACKET>
+ | LOOKAHEAD({parentheses > 0}) t = <RPAREN> { parentheses--; }
+ | t = <SHARP>
+ | t = <SLASH>
| t = <UNDERSCORE>
) { buff.append(t.image); }
) +
@@ -891,14 +893,14 @@
(
t = <CHAR_SEQUENCE>
| t = <SPACE>
+ | t = <AMPERSAND>
+ | t = <BACKSLASH>
+ | t = <DOUBLE_QUOTE>
+ | t = <LPAREN>
+ | t = <RPAREN>
+ | t = <SINGLE_QUOTE>
+ | t = <SLASH>
| t = <TAB>
- | t = "&"
- | t = "("
- | t = ")"
- | t = "/"
- | t = "\\"
- | t = "'"
- | t = "\""
| t = <UNDERSCORE>
) { buff.append(t.image); }
)*
diff --git a/core/src/test/resources/others/links.html b/core/src/test/resources/others/links.html
index 63805b3..a4a9d2f 100644
--- a/core/src/test/resources/others/links.html
+++ b/core/src/test/resources/others/links.html
@@ -1,3 +1,9 @@
<p><a href="http://localhost/path_to#id">text</a></p>
-<p><a href="http://localhost/path_to_file#id">text 2</a></p>
\ No newline at end of file
+<p><a href="http://localhost/path_to_file#id" title="title">text 2</a></p>
+
+<p><a href="http://localhost/path#id">text 3</a></p>
+
+<p><a href="http://localhost/path#id">text 4</a></p>
+
+<p><a href="http://localhost/path#id" title="title">text 5</a></p>
\ No newline at end of file
diff --git a/core/src/test/resources/others/links.text b/core/src/test/resources/others/links.text
index 9b6b1c8..d3e7045 100644
--- a/core/src/test/resources/others/links.text
+++ b/core/src/test/resources/others/links.text
@@ -1,7 +1,13 @@
[text][id]
[text 2][id_2]
-
-[id]: http://localhost/path_to#id
-[id_2]: http://localhost/path_to_file#id
+
+[text 3](http://localhost/path#id)
+
+[text 4](http://localhost/path#id )
+
+[text 5]( http://localhost/path#id "title" )
+
+[id]: http://localhost/path_to#id
+[id_2]: http://localhost/path_to_file#id "title"
diff --git a/doxia-module/src/test/java/org/tautua/markdownpapers/doxia/MarkdownParserTest.java b/doxia-module/src/test/java/org/tautua/markdownpapers/doxia/SinkEventEmitterTest.java
similarity index 96%
rename from doxia-module/src/test/java/org/tautua/markdownpapers/doxia/MarkdownParserTest.java
rename to doxia-module/src/test/java/org/tautua/markdownpapers/doxia/SinkEventEmitterTest.java
index 49b1769..27a0312 100644
--- a/doxia-module/src/test/java/org/tautua/markdownpapers/doxia/MarkdownParserTest.java
+++ b/doxia-module/src/test/java/org/tautua/markdownpapers/doxia/SinkEventEmitterTest.java
@@ -12,7 +12,7 @@
/**
* @author Larry Ruiz, Aug 26, 2010
*/
-public class MarkdownParserTest extends AbstractParserTest {
+public class SinkEventEmitterTest extends AbstractParserTest {
private MarkdownParser parser;
protected void setUp() throws Exception {
diff --git a/doxia-module/src/test/resources/paragraph.md b/doxia-module/src/test/resources/paragraph.md
index 86de2cc..9598d0d 100644
--- a/doxia-module/src/test/resources/paragraph.md
+++ b/doxia-module/src/test/resources/paragraph.md
@@ -1,10 +1,13 @@
This page offers a brief overview of what it's like to use Markdown.
-The [syntax page] [s] provides complete, detailed documentation for
+The [syntax page][syntax] provides complete, detailed documentation for
every feature, but Markdown should be very easy to pick up simply by
looking at a few examples of it in action. The examples on this page
are written in a before/after style, showing example syntax and the
HTML output produced by Markdown.
-It's also helpful to simply try Markdown out; the [Dingus] [d] is a
+It's also helpful to simply try Markdown out; the [Dingus] is a
web application that allows you type your own Markdown-formatted text
-and translate it to XHTML.
\ No newline at end of file
+and translate it to XHTML.
+
+[syntax]: http://markdown.tautua.com/syntax
+[Dingus]: http://dingus.com
\ No newline at end of file