test/parser_test.rb in trac-wiki-0.0.1 vs test/parser_test.rb in trac-wiki-0.0.2
- old
+ new
@@ -44,10 +44,28 @@
# Bold should be able to cross lines
tc "<p>This <strong>is bold</strong></p>", "This **is\nbold**"
end
+ it 'should parse bolditalic' do
+ tc '<p>This is <strong><em>bolditallic</em></strong>.</p>', "This is '''''bolditallic'''''."
+ tc '<p>This is <strong> <em>bolditallic</em> </strong>.</p>', "This is ''' ''bolditallic'' '''."
+ tc '<p>This is <em> <strong>bolditallic</strong> </em>.</p>', "This is '' '''bolditallic''' ''."
+ tc '<p>This is <strong>bold</strong>.</p>', "This is '''bold'''."
+ #fuj tc '<p>This is <strong><em>bolditallic</em></strong>.</p>', "This is **''bolditallic**''."
+ end
+ it 'should parse monospace' do
+ tc "<p>This is <tt>monospace</tt>.</p>", "This is {{{monospace}}}."
+ tc "<p>This is <tt>mon**o**space</tt>.</p>", "This is {{{mon**o**space}}}."
+ tc "<p>This is <tt>mon<o>space</tt>.</p>", "This is {{{mon<o>space}}}."
+ tc "<p>This is <tt>mon''o''space</tt>.</p>", "This is {{{mon''o''space}}}."
+ tc "<p>This is <tt>mon''o''space</tt>.</p>", "This is `mon''o''space`."
+ tc "<p>This is <tt>mon{{o}}space</tt>.</p>", "This is {{{mon{{o}}space}}}."
+ tc "<p>This is <tt>mon``o''space</tt>.</p>", "This is {{{mon``o''space}}}."
+ tc "<p>This is <tt>mon{{o}}space</tt>.</p>", "This is `mon{{o}}space`."
+ end
+
it 'should parse italic' do
# Italic can be used inside paragraphs
tc("<p>This <em>is</em> italic</p>",
"This ''is'' italic")
tc("<p>This <em>is</em> italic and <em>italic</em>ish</p>",
@@ -154,11 +172,11 @@
tc("<p><a href=\"http://www.example.org/\">Visit the Example website</a></p>",
"[[http://www.example.org/|Visit the Example website]]")
# WRNING: Parsing markup within a link is optional
tc "<p><a href=\"Weird+Stuff\"><strong>Weird</strong> <em>Stuff</em></a></p>", "[[Weird Stuff|**Weird** ''Stuff'']]"
- tc("<p><a href=\"http://example.org/\"><img src=\"image.jpg\"/></a></p>", "[[http://example.org/|{{image.jpg}}]]")
+ #tc("<p><a href=\"http://example.org/\"><img src='image.jpg'/></a></p>", "[[http://example.org/|{{image.jpg}}]]")
# Inside bold
tc "<p><strong><a href=\"link\">link</a></strong></p>", "**[[link]]**"
# Whitespace inside [[ ]] should be ignored
@@ -208,23 +226,39 @@
end
it 'should parse linebreaks' do
# \\ (wiki-style) for line breaks.
tc "<p>This is the first line,<br/>and this is the second.</p>", "This is the first line,\\\\and this is the second."
+ tc "<p>This is the first line,<br/>and this is the second.</p>", "This is the first line,[[br]]and this is the second."
+ tc "<p>This is the first line,<br/>and this is the second.</p>", "This is the first line,[[Br]]and this is the second."
end
+ it 'should parse blockquote' do
+ tc "<p><blockquote>Monty Python</blockquote></p>", "> Monty Python\n"
+ tc "<p><blockquote>Monty Python q2</blockquote></p>", "> Monty Python\n> q2\n"
+ tc "<p><blockquote>Monty Python q2</blockquote></p>", "> Monty Python\n>q2\n"
+ tc "<p><blockquote>Monty Python <strong>q2</strong></blockquote></p>", "> Monty Python\n>**q2**\n"
+ tc "<p><blockquote>Monty Python<blockquote>q2</blockquote></blockquote></p>", "> Monty Python\n> > q2\n"
+ tc "<p><blockquote>Monty Python<blockquote>q2 q3</blockquote></blockquote></p>", "> Monty Python\n> > q2\n>>q3\n"
+ tc "<p><blockquote>Monty Python<blockquote><em>q2</em></blockquote>q1</blockquote></p>", ">Monty Python\n> > ''q2''\n>q1"
+ tc "<p><blockquote>Monty Python rules</blockquote></p>", " Monty Python\n rules\n"
+ end
+ it 'should parse definition list' do
+ # FIXME: trailing space
+ tc "<dl><dt>Monty Python</dt><dd> definition</dd></dl>", "Monty Python:: \n definition\n"
+ end
it 'should parse unordered_lists' do
# List items begin with a * at the beginning of a line.
# An item ends at the next *
- tc "<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>", "* Item 1\n *Item 2\n *\t\tItem 3\n"
+ tc "<ul><li>Item 1 next</li></ul>", "* Item 1\n next\n"
+
# Whitespace is optional before and after the *.
tc("<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>",
- " * Item 1\n*Item 2\n \t*\t\tItem 3\n")
+ " * Item 1\n * Item 2\n *\t\tItem 3\n")
# A space is required if if the list element starts with bold text.
- tc("<ul><li><ul><li><ul><li>Item 1</li></ul></li></ul></li></ul>", "***Item 1")
tc("<ul><li><strong>Item 1</strong></li></ul>", "* **Item 1")
# An item ends at blank line
tc("<ul><li>Item</li></ul><p>Par</p>", "* Item\n\nPar\n")
@@ -237,111 +271,114 @@
# An item ends at a nowiki block
tc("<ul><li>Item</li></ul><pre>Code</pre>", "* Item\n{{{\nCode\n}}}\n")
# An item can span multiple lines
tc("<ul><li>The quick brown fox jumps over lazy dog.</li><li>Humpty Dumpty sat on a wall.</li></ul>",
- "* The quick\nbrown fox\n\tjumps over\nlazy dog.\n*Humpty Dumpty\nsat\t\non a wall.")
+ "* The quick\nbrown fox\n\tjumps over\nlazy dog.\n* Humpty Dumpty\nsat\t\non a wall.")
# An item can contain line breaks
tc("<ul><li>The quick brown<br/>fox jumps over lazy dog.</li></ul>",
"* The quick brown\\\\fox jumps over lazy dog.")
# Nested
- tc "<ul><li>Item 1<ul><li>Item 2</li></ul></li><li>Item 3</li></ul>", "* Item 1\n **Item 2\n *\t\tItem 3\n"
+ tc "<ul><li>Item 1<ul><li>Item 2</li></ul></li><li>Item 3</li></ul>", "* Item 1\n * Item 2\n*\t\tItem 3\n"
# Nested up to 5 levels
tc("<ul><li>Item 1<ul><li>Item 2<ul><li>Item 3<ul><li>Item 4<ul><li>Item 5</li></ul></li></ul></li></ul></li></ul></li></ul>",
- "*Item 1\n**Item 2\n***Item 3\n****Item 4\n*****Item 5\n")
+ "* Item 1\n * Item 2\n * Item 3\n * Item 4\n * Item 5\n")
+ tc("<ul><li>Item 1<ul><li>Item 2<ul><li>Item 3<ul><li>Item 4</li></ul></li></ul></li></ul></li><li>Item 5</li></ul>",
+ "* Item 1\n * Item 2\n * Item 3\n * Item 4\n* Item 5\n")
+
# ** immediatly following a list element will be treated as a nested unordered element.
tc("<ul><li>Hello, World!<ul><li>Not bold</li></ul></li></ul>",
- "*Hello,\nWorld!\n**Not bold\n")
+ "* Hello,\n World!\n * Not bold\n")
# ** immediatly following a list element will be treated as a nested unordered element.
tc("<ol><li>Hello, World!<ul><li>Not bold</li></ul></li></ol>",
- "#Hello,\nWorld!\n**Not bold\n")
+ "1. Hello,\n World!\n * Not bold\n")
# [...] otherwise it will be treated as the beginning of bold text.
tc("<ul><li>Hello, World!</li></ul><p><strong>Not bold</strong></p>",
- "*Hello,\nWorld!\n\n**Not bold\n")
+ "* Hello,\nWorld!\n\n**Not bold\n")
end
it 'should parse ordered lists' do
# List items begin with a * at the beginning of a line.
# An item ends at the next *
- tc "<ol><li>Item 1</li><li>Item 2</li><li>Item 3</li></ol>", "# Item 1\n #Item 2\n #\t\tItem 3\n"
+ tc "<ol><li>Item 1</li><li>Item 2</li><li>Item 3</li></ol>", "1. Item 1\n2. Item 2\n3. \t\tItem 3\n"
# Whitespace is optional before and after the #.
tc("<ol><li>Item 1</li><li>Item 2</li><li>Item 3</li></ol>",
- " # Item 1\n#Item 2\n \t#\t\tItem 3\n")
+ "1. Item 1\n1. Item 2\n4.\t\tItem 3\n")
# A space is required if if the list element starts with bold text.
- tc("<ol><li><ol><li><ol><li>Item 1</li></ol></li></ol></li></ol>", "###Item 1")
- tc("<ol><li><strong>Item 1</strong></li></ol>", "# **Item 1")
+# tc("<ol><li><ol><li><ol><li>Item 1</li></ol></li></ol></li></ol>", "###Item 1")
+ tc("<ol><li><strong>Item 1</strong></li></ol>", "1. **Item 1")
# An item ends at blank line
- tc("<ol><li>Item</li></ol><p>Par</p>", "# Item\n\nPar\n")
+ tc("<ol><li>Item</li></ol><p>Par</p>", "1. Item\n\nPar\n")
# An item ends at a heading
- tc("<ol><li>Item</li></ol><h1>Heading</h1>", "# Item\n= Heading =\n")
+ tc("<ol><li>Item</li></ol><h1>Heading</h1>", "1. Item\n= Heading =\n")
# An item ends at a table
- tc("<ol><li>Item</li></ol><table><tr><td>Cell</td></tr></table>", "# Item\n||Cell||\n")
+ tc("<ol><li>Item</li></ol><table><tr><td>Cell</td></tr></table>", "1. Item\n||Cell||\n")
# An item ends at a nowiki block
- tc("<ol><li>Item</li></ol><pre>Code</pre>", "# Item\n{{{\nCode\n}}}\n")
+ tc("<ol><li>Item</li></ol><pre>Code</pre>", "1. Item\n{{{\nCode\n}}}\n")
# An item can span multiple lines
tc("<ol><li>The quick brown fox jumps over lazy dog.</li><li>Humpty Dumpty sat on a wall.</li></ol>",
- "# The quick\nbrown fox\n\tjumps over\nlazy dog.\n#Humpty Dumpty\nsat\t\non a wall.")
+ "1. The quick\nbrown fox\n\tjumps over\nlazy dog.\n2. Humpty Dumpty\nsat\t\non a wall.")
# An item can contain line breaks
tc("<ol><li>The quick brown<br/>fox jumps over lazy dog.</li></ol>",
- "# The quick brown\\\\fox jumps over lazy dog.")
+ "1. The quick brown\\\\fox jumps over lazy dog.")
# Nested
- tc "<ol><li>Item 1<ol><li>Item 2</li></ol></li><li>Item 3</li></ol>", "# Item 1\n ##Item 2\n #\t\tItem 3\n"
+ tc "<ol><li>Item 1<ol><li>Item 2</li></ol></li><li>Item 3</li></ol>", "1. Item 1\n 1. Item 2\n2.\t\tItem 3\n"
# Nested up to 5 levels
tc("<ol><li>Item 1<ol><li>Item 2<ol><li>Item 3<ol><li>Item 4<ol><li>Item 5</li></ol></li></ol></li></ol></li></ol></li></ol>",
- "#Item 1\n##Item 2\n###Item 3\n####Item 4\n#####Item 5\n")
+ "1. Item 1\n 1. Item 2\n 1. Item 3\n 1. Item 4\n 1. Item 5\n")
# The two-bullet rule only applies to **.
- tc("<ol><li><ol><li>Item</li></ol></li></ol>", "##Item")
+# tc("<ol><li><ol><li>Item</li></ol></li></ol>", "##Item")
end
it 'should parse ordered lists #2' do
- tc "<ol><li>Item 1</li><li>Item 2</li><li>Item 3</li></ol>", "# Item 1\n #Item 2\n #\t\tItem 3\n"
+ tc "<ol><li>Item 1</li><li>Item 2</li><li>Item 3</li></ol>", "1. Item 1\n1. Item 2\n1.\t\tItem 3\n"
# Nested
- tc "<ol><li>Item 1<ol><li>Item 2</li></ol></li><li>Item 3</li></ol>", "# Item 1\n ##Item 2\n #\t\tItem 3\n"
+ tc "<ol><li>Item 1<ol><li>Item 2</li></ol></li><li>Item 3</li></ol>", "1. Item 1\n 1. Item 2\n1.\t\tItem 3\n"
# Multiline
- tc "<ol><li>Item 1 on multiple lines</li></ol>", "# Item 1\non multiple lines"
+ tc "<ol><li>Item 1 on multiple lines</li></ol>", "1. Item 1\non multiple lines"
end
it 'should parse ambiguious mixed lists' do
# ol following ul
- tc("<ul><li>uitem</li></ul><ol><li>oitem</li></ol>", "*uitem\n#oitem\n")
+ tc("<ul><li>uitem</li></ul><ol><li>oitem</li></ol>", "* uitem\n1. oitem\n")
# ul following ol
- tc("<ol><li>uitem</li></ol><ul><li>oitem</li></ul>", "#uitem\n*oitem\n")
+ tc("<ol><li>uitem</li></ol><ul><li>oitem</li></ul>", "1. uitem\n* oitem\n")
# 2ol following ul
- tc("<ul><li>uitem<ol><li>oitem</li></ol></li></ul>", "*uitem\n##oitem\n")
+ tc("<ul><li>uitem<ol><li>oitem</li></ol></li></ul>", "* uitem\n 1. oitem\n")
# 2ul following ol
- tc("<ol><li>uitem<ul><li>oitem</li></ul></li></ol>", "#uitem\n**oitem\n")
+ tc("<ol><li>uitem<ul><li>oitem</li></ul></li></ol>", "1. uitem\n * oitem\n")
# 3ol following 3ul
- tc("<ul><li><ul><li><ul><li>uitem</li></ul><ol><li>oitem</li></ol></li></ul></li></ul>", "***uitem\n###oitem\n")
+# tc("<ul><li><ul><li><ul><li>uitem</li></ul><ol><li>oitem</li></ol></li></ul></li></ul>", "***uitem\n###oitem\n")
# 2ul following 2ol
- tc("<ol><li><ol><li>uitem</li></ol><ul><li>oitem</li></ul></li></ol>", "##uitem\n**oitem\n")
+# tc("<ol><li><ol><li>uitem</li></ol><ul><li>oitem</li></ul></li></ol>", "##uitem\n**oitem\n")
# ol following 2ol
- tc("<ol><li><ol><li>oitem1</li></ol></li><li>oitem2</li></ol>", "##oitem1\n#oitem2\n")
+# tc("<ol><li><ol><li>oitem1</li></ol></li><li>oitem2</li></ol>", "##oitem1\n#oitem2\n")
# ul following 2ol
- tc("<ol><li><ol><li>oitem1</li></ol></li></ol><ul><li>oitem2</li></ul>", "##oitem1\n*oitem2\n")
+# tc("<ol><li><ol><li>oitem1</li></ol></li></ol><ul><li>oitem2</li></ul>", "##oitem1\n*oitem2\n")
end
it 'should parse ambiguious italics and url' do
# Uncommon URL schemes should not be parsed as URLs
tc("<p>This is what can go wrong:<em>this should be an italic text</em>.</p>",
@@ -356,27 +393,28 @@
"Formatted fruits, for example:''apples'', oranges, **pears** ...")
end
it 'should parse ambiguious bold and lists' do
tc "<p><strong> bold text </strong></p>", "** bold text **"
- tc "<p> <strong> bold text </strong></p>", " ** bold text **"
+ tc "<p><blockquote><strong> bold text </strong></blockquote></p>", " ** bold text **"
end
it 'should parse nowiki' do
# ... works as block
tc "<pre>Hello</pre>", "{{{\nHello\n}}}\n"
+ tc "<p><tt>{{{-}}}</tt></p>", "`{{{-}}}`\n"
# ... works inline
tc "<p>Hello <tt>world</tt>.</p>", "Hello {{{world}}}."
tc "<p><tt>Hello</tt> <tt>world</tt>.</p>", "{{{Hello}}} {{{world}}}."
# No wiki markup is interpreted inbetween
tc "<pre>**Hello**</pre>", "{{{\n**Hello**\n}}}\n"
# Leading whitespaces are not permitted
- tc("<p> {{{ Hello }}}</p>", " {{{\nHello\n}}}")
- tc("<p>{{{ Hello }}}</p>", "{{{\nHello\n }}}")
+# tc("<p>{{{ Hello }}}</p>", " {{{\nHello\n}}}")
+ tc("<p>{{{ Hello<blockquote>}}}</blockquote></p>", "{{{\nHello\n }}}")
# Assumed: Should preserve whitespace
tc("<pre> \t Hello, \t \n \t World \t </pre>",
"{{{\n \t Hello, \t \n \t World \t \n}}}\n")
@@ -393,11 +431,12 @@
it 'should escape html' do
# Special HTML chars should be escaped
tc("<p><b>not bold</b></p>", "<b>not bold</b>")
# Image tags should be escape
- tc("<p><img src=\"image.jpg\" alt=\""tag"\"/></p>", "{{image.jpg|\"tag\"}}")
+ tc("<p><img src='image.jpg'/></p>", "[[Image(image.jpg)]]")
+ tc("<p><img src='image.jpg' alt='"tag"'/></p>", "[[Image(image.jpg|\"tag\")]]")
# Malicious links should not be converted.
tc("<p><a href=\"javascript%3Aalert%28%22Boo%21%22%29\">Click</a></p>", "[[javascript:alert(\"Boo!\")|Click]]")
end
@@ -405,11 +444,13 @@
tc "<p>** Not Bold **</p>", "!** Not Bold !**"
tc "<p>// Not Italic //</p>", "!// Not Italic !//"
tc "<p>* Not Bullet</p>", "!* Not Bullet"
# Following char is not a blank (space or line feed)
tc "<p>Hello ~ world</p>", "Hello ~ world\n"
- tc "<p>Hello ~ world</p>", "Hello ~\nworld\n"
+ tc "<p>Hello ! world</p>", "Hello ! world\n"
+ tc "<p>Hello ! world</p>", "Hello ! world\n"
+ tc "<p>Hello ! world</p>", "Hello !\nworld\n"
# Not escaping inside URLs
tc "<p><a href=\"http://example.org/~user/\">http://example.org/~user/</a></p>", "http://example.org/~user/"
# Escaping links
tc "<p>http://www.example.org/</p>", "~http://www.example.org/"
@@ -428,15 +469,26 @@
# Nothing else than hyphens and whitespace is "allowed"
tc "<p>foo ----</p>", "foo ----\n"
tc "<p>---- foo</p>", "---- foo\n"
# [...] no whitespace is allowed between them
- tc "<p> -- -- </p>", " -- -- "
- tc "<p> -- -- </p>", " --\t-- "
+ tc "<p>-- -- </p>", "-- -- "
+ tc "<p>-- -- </p>", "--\t-- "
end
it 'should parse table' do
+ tc "<table><tr><td>Hello</td><td>World!</td></tr></table>", "||Hello||World!||"
+ tc "<table><tr><td>Hello</td><td>World!</td></tr></table>", "||Hello||\\\n||World!||"
+ tc "<table><tr><td>He</td><td>llo</td><td>World!</td></tr></table>", "||He||llo||\\\n||World!||"
+ tc "<table><tr><td>Hello</td><td colspan='2'>World!</td></tr></table>", "||Hello||||World!||"
+ tc "<table><tr><td>Hello</td><td colspan='2'>kuk</td><td>World!</td></tr></table>", "||Hello||||kuk||\\\n||World!||"
+ tc "<table><tr><td>1</td><td>2</td><td>3</td></tr><tr><td colspan='2'>1-2</td><td>3</td></tr><tr><td>1</td><td colspan='2'>2-3</td></tr><tr><td colspan='3'>1-2-3</td></tr></table>", "|| 1 || 2 || 3 ||\n|||| 1-2 || 3 ||\n|| 1 |||| 2-3 ||\n|||||| 1-2-3 ||\n"
+
+ tc "<table><tr><td>table</td><td style='text-align:center'>center</td></tr></table>", "||table|| center ||"
+ tc "<table><tr><td>table</td><td style='text-align:right'>right</td></tr></table>", "||table|| right||"
+ tc "<table><tr><td>table</td><td style='text-align:center'>center</td><td style='text-align:right'>right</td></tr></table>", "||table|| center || right||"
+
tc "<table><tr><td>Hello, World!</td></tr></table>", "||Hello, World!||"
tc "<table><tr><td style='text-align:right'>Hello, Right World!</td></tr></table>", "|| Hello, Right World!||"
tc "<table><tr><th style='text-align:right'>Hello, Right World!</th></tr></table>", "||= Hello, Right World!=||"
tc "<table><tr><td style='text-align:center'>Hello, Centered World!</td></tr></table>", "|| Hello, Centered World! ||"
tc "<table><tr><th style='text-align:center'>Hello, Centered World!</th></tr></table>", "||= Hello, Centered World! =||"
@@ -455,26 +507,26 @@
tc "<table><tr><td>c1</td><td>c2|</td></tr></table>", "||c1||c2!|"
tc "<table><tr><td>c1</td><td>c2|</td><td></td></tr></table>", "||c1||c2| || ||"
# Equal sign after pipe make a header
tc "<table><tr><th>Header</th></tr></table>", "||=Header=||"
- tc "<table><tr><td>c1</td><td><a href=\"Link\">Link text</a></td><td><img src=\"Image\" alt=\"Image text\"/></td></tr></table>", "||c1||[[Link|Link text]]||{{Image|Image text}}||"
+ tc "<table><tr><td>c1</td><td><a href=\"Link\">Link text</a></td><td><img src='Image'/></td></tr></table>", "||c1||[[Link|Link text]]||[[Image(Image)]]||"
end
it 'should parse following table' do
# table followed by heading
tc("<table><tr><td>table</td></tr></table><h1>heading</h1>", "||table||\n=heading=\n")
tc("<table><tr><td>table</td></tr></table><h1>heading</h1>", "||table||\n\n=heading=\n")
# table followed by paragraph
tc("<table><tr><td>table</td></tr></table><p>par</p>", "||table||\npar\n")
tc("<table><tr><td>table</td></tr></table><p>par</p>", "||table||\n\npar\n")
# table followed by unordered list
- tc("<table><tr><td>table</td></tr></table><ul><li>item</li></ul>", "||table||\n*item\n")
- tc("<table><tr><td>table</td></tr></table><ul><li>item</li></ul>", "||table||\n\n*item\n")
+ tc("<table><tr><td>table</td></tr></table><ul><li>item</li></ul>", "||table||\n* item\n")
+ tc("<table><tr><td>table</td></tr></table><ul><li>item</li></ul>", "||table||\n\n* item\n")
# table followed by ordered list
- tc("<table><tr><td>table</td></tr></table><ol><li>item</li></ol>", "||table||\n#item\n")
- tc("<table><tr><td>table</td></tr></table><ol><li>item</li></ol>", "||table||\n\n#item\n")
+ tc("<table><tr><td>table</td></tr></table><ol><li>item</li></ol>", "||table||\n1. item\n")
+ tc("<table><tr><td>table</td></tr></table><ol><li>item</li></ol>", "||table||\n\n1. item\n")
# table followed by horizontal rule
tc("<table><tr><td>table</td></tr></table><hr/>", "||table||\n----\n")
tc("<table><tr><td>table</td></tr></table><hr/>", "||table||\n\n----\n")
# table followed by nowiki block
tc("<table><tr><td>table</td></tr></table><pre>pre</pre>", "||table||\n{{{\npre\n}}}\n")
@@ -490,15 +542,15 @@
tc("<h1>heading1</h1><h1>heading2</h1>", "=heading1=\n\n=heading2\n")
# paragraph
tc("<h1>heading</h1><p>par</p>", "=heading=\npar\n")
tc("<h1>heading</h1><p>par</p>", "=heading=\n\npar\n")
# unordered list
- tc("<h1>heading</h1><ul><li>item</li></ul>", "=heading=\n*item\n")
- tc("<h1>heading</h1><ul><li>item</li></ul>", "=heading=\n\n*item\n")
+ tc("<h1>heading</h1><ul><li>item</li></ul>", "=heading=\n* item\n")
+ tc("<h1>heading</h1><ul><li>item</li></ul>", "=heading=\n\n* item\n")
# ordered list
- tc("<h1>heading</h1><ol><li>item</li></ol>", "=heading=\n#item\n")
- tc("<h1>heading</h1><ol><li>item</li></ol>", "=heading=\n\n#item\n")
+ tc("<h1>heading</h1><ol><li>item</li></ol>", "=heading=\n1. item\n")
+ tc("<h1>heading</h1><ol><li>item</li></ol>", "=heading=\n\n1. item\n")
# horizontal rule
tc("<h1>heading</h1><hr/>", "=heading=\n----\n")
tc("<h1>heading</h1><hr/>", "=heading=\n\n----\n")
# nowiki block
tc("<h1>heading</h1><pre>nowiki</pre>", "=heading=\n{{{\nnowiki\n}}}\n")
@@ -514,15 +566,15 @@
tc("<p>par</p><h1>heading</h1>", "par\n\n=heading=")
# paragraph
tc("<p>par par</p>", "par\npar\n")
tc("<p>par</p><p>par</p>", "par\n\npar\n")
# unordered
- tc("<p>par</p><ul><li>item</li></ul>", "par\n*item")
- tc("<p>par</p><ul><li>item</li></ul>", "par\n\n*item")
+ tc("<p>par</p><ul><li>item</li></ul>", "par\n* item")
+ tc("<p>par</p><ul><li>item</li></ul>", "par\n\n* item")
# ordered
- tc("<p>par</p><ol><li>item</li></ol>", "par\n#item\n")
- tc("<p>par</p><ol><li>item</li></ol>", "par\n\n#item\n")
+ tc("<p>par</p><ol><li>item</li></ol>", "par\n1. item\n")
+ tc("<p>par</p><ol><li>item</li></ol>", "par\n\n1. item\n")
# horizontal
tc("<p>par</p><hr/>", "par\n----\n")
tc("<p>par</p><hr/>", "par\n\n----\n")
# nowiki
tc("<p>par</p><pre>nowiki</pre>", "par\n{{{\nnowiki\n}}}\n")
@@ -532,69 +584,72 @@
tc("<p>par</p><table><tr><td>table</td></tr></table>", "par\n\n||table||\n")
end
it 'should parse following unordered list' do
# heading
- tc("<ul><li>item</li></ul><h1>heading</h1>", "*item\n=heading=")
- tc("<ul><li>item</li></ul><h1>heading</h1>", "*item\n\n=heading=")
+ tc("<ul><li>item</li></ul><h1>heading</h1>", "* item\n=heading=")
+ tc("<ul><li>item</li></ul><h1>heading</h1>", "* item\n\n=heading=")
# paragraph
- tc("<ul><li>item par</li></ul>", "*item\npar\n") # items may span multiple lines
- tc("<ul><li>item</li></ul><p>par</p>", "*item\n\npar\n")
+ tc("<ul><li>item par</li></ul>", "* item\npar\n") # items may span multiple lines
+ tc("<ul><li>item</li></ul><p>par</p>", "* item\n\npar\n")
# unordered
- tc("<ul><li>item</li><li>item</li></ul>", "*item\n*item\n")
- tc("<ul><li>item</li></ul><ul><li>item</li></ul>", "*item\n\n*item\n")
+ tc("<ul><li>item</li><li>item</li></ul>", "* item\n* item\n")
+ tc("<ul><li>item</li></ul><ul><li>item</li></ul>", "* item\n\n* item\n")
# ordered
- tc("<ul><li>item</li></ul><ol><li>item</li></ol>", "*item\n#item\n")
- tc("<ul><li>item</li></ul><ol><li>item</li></ol>", "*item\n\n#item\n")
+ tc("<ul><li>item</li></ul><ol><li>item</li></ol>", "* item\n1. item\n")
+ tc("<ul><li>item</li></ul><ol><li>item</li></ol>", "* item\n\n1. item\n")
# horizontal rule
- tc("<ul><li>item</li></ul><hr/>", "*item\n----\n")
- tc("<ul><li>item</li></ul><hr/>", "*item\n\n----\n")
+ tc("<ul><li>item</li></ul><hr/>", "* item\n----\n")
+ tc("<ul><li>item</li></ul><hr/>", "* item\n\n----\n")
# nowiki
- tc("<ul><li>item</li></ul><pre>nowiki</pre>", "*item\n{{{\nnowiki\n}}}\n")
- tc("<ul><li>item</li></ul><pre>nowiki</pre>", "*item\n\n{{{\nnowiki\n}}}\n")
+ tc("<ul><li>item</li></ul><pre>nowiki</pre>", "* item\n{{{\nnowiki\n}}}\n")
+ tc("<ul><li>item</li></ul><pre>nowiki</pre>", "* item\n\n{{{\nnowiki\n}}}\n")
# table
- tc("<ul><li>item</li></ul><table><tr><td>table</td></tr></table>", "*item\n||table||\n")
- tc("<ul><li>item</li></ul><table><tr><td>table</td></tr></table>", "*item\n\n||table||\n")
+ tc("<ul><li>item</li></ul><table><tr><td>table</td></tr></table>", "* item\n||table||\n")
+ tc("<ul><li>item</li></ul><table><tr><td>table</td></tr></table>", "* item\n\n||table||\n")
end
it 'should parse following ordered list' do
# heading
- tc("<ol><li>item</li></ol><h1>heading</h1>", "#item\n=heading=")
- tc("<ol><li>item</li></ol><h1>heading</h1>", "#item\n\n=heading=")
+ tc("<ol><li>item</li></ol><h1>heading</h1>", "1. item\n=heading=")
+ tc("<ol><li>item</li></ol><h1>heading</h1>", "1. item\n\n=heading=")
# paragraph
- tc("<ol><li>item par</li></ol>", "#item\npar\n") # items may span multiple lines
- tc("<ol><li>item</li></ol><p>par</p>", "#item\n\npar\n")
+ tc("<ol><li>item par</li></ol>", "1. item\npar\n") # items may span multiple lines
+ tc("<ol><li>item</li></ol><p>par</p>", "1. item\n\npar\n")
# unordered
- tc("<ol><li>item</li></ol><ul><li>item</li></ul>", "#item\n*item\n")
- tc("<ol><li>item</li></ol><ul><li>item</li></ul>", "#item\n\n*item\n")
+ tc("<ol><li>item</li></ol><ul><li>item</li></ul>", "1. item\n* item\n")
+ tc("<ol><li>item</li></ol><ul><li>item</li></ul>", "1. item\n\n* item\n")
# ordered
- tc("<ol><li>item</li><li>item</li></ol>", "#item\n#item\n")
- tc("<ol><li>item</li></ol><ol><li>item</li></ol>", "#item\n\n#item\n")
+ tc("<ol><li>item</li><li>item</li></ol>", "1. item\n2. item\n")
+ tc("<ol><li>item</li></ol><ol><li>item</li></ol>", "1. item\n\n1. item\n")
# horizontal role
- tc("<ol><li>item</li></ol><hr/>", "#item\n----\n")
- tc("<ol><li>item</li></ol><hr/>", "#item\n\n----\n")
+ tc("<ol><li>item</li></ol><hr/>", "1. item\n----\n")
+ tc("<ol><li>item</li></ol><hr/>", "1. item\n\n----\n")
# nowiki
- tc("<ol><li>item</li></ol><pre>nowiki</pre>", "#item\n{{{\nnowiki\n}}}\n")
- tc("<ol><li>item</li></ol><pre>nowiki</pre>", "#item\n\n{{{\nnowiki\n}}}\n")
+ tc("<ol><li>item</li></ol><pre>nowiki</pre>", "1. item\n{{{\nnowiki\n}}}\n")
+ tc("<ol><li>item</li></ol><pre>nowiki</pre>", "1. item\n\n{{{\nnowiki\n}}}\n")
# table
- tc("<ol><li>item</li></ol><table><tr><td>table</td></tr></table>", "#item\n||table||\n")
- tc("<ol><li>item</li></ol><table><tr><td>table</td></tr></table>", "#item\n\n||table||\n")
+ tc("<ol><li>item</li></ol><table><tr><td>table</td></tr></table>", "1. item\n||table||\n")
+ tc("<ol><li>item</li></ol><table><tr><td>table</td></tr></table>", "1. item\n\n||table||\n")
end
it 'should parse following horizontal rule' do
# heading
tc("<hr/><h1>heading</h1>", "----\n=heading=")
tc("<hr/><h1>heading</h1>", "----\n\n=heading=")
# paragraph
tc("<hr/><p>par</p>", "----\npar\n")
tc("<hr/><p>par</p>", "----\n\npar\n")
# unordered
- tc("<hr/><ul><li>item</li></ul>", "----\n*item")
- tc("<hr/><ul><li>item</li></ul>", "----\n*item")
+ tc("<hr/><ul><li>item</li></ul>", "----\n* item")
+ tc("<hr/><ul><li>item</li></ul>", "----\n* item")
+ tc("<hr/><ul><li>item</li></ul>", "----\n- item")
+ tc("<hr/><ul><li>item</li></ul>", "----\n- item")
+ tc("<hr/><ul><li>item</li></ul>", "----\n - item")
# ordered
- tc("<hr/><ol><li>item</li></ol>", "----\n#item")
- tc("<hr/><ol><li>item</li></ol>", "----\n#item")
+ tc("<hr/><ol><li>item</li></ol>", "----\n1. item")
+ tc("<hr/><ol><li>item</li></ol>", "----\n1. item")
# horizontal
tc("<hr/><hr/>", "----\n----\n")
tc("<hr/><hr/>", "----\n\n----\n")
# nowiki
tc("<hr/><pre>nowiki</pre>", "----\n{{{\nnowiki\n}}}\n")
@@ -610,15 +665,15 @@
tc("<pre>nowiki</pre><h1>heading</h1>", "{{{\nnowiki\n}}}\n\n=heading=")
# paragraph
tc("<pre>nowiki</pre><p>par</p>", "{{{\nnowiki\n}}}\npar")
tc("<pre>nowiki</pre><p>par</p>", "{{{\nnowiki\n}}}\n\npar")
# unordered
- tc("<pre>nowiki</pre><ul><li>item</li></ul>", "{{{\nnowiki\n}}}\n*item\n")
- tc("<pre>nowiki</pre><ul><li>item</li></ul>", "{{{\nnowiki\n}}}\n\n*item\n")
+ tc("<pre>nowiki</pre><ul><li>item</li></ul>", "{{{\nnowiki\n}}}\n* item\n")
+ tc("<pre>nowiki</pre><ul><li>item</li></ul>", "{{{\nnowiki\n}}}\n\n* item\n")
# ordered
- tc("<pre>nowiki</pre><ol><li>item</li></ol>", "{{{\nnowiki\n}}}\n#item\n")
- tc("<pre>nowiki</pre><ol><li>item</li></ol>", "{{{\nnowiki\n}}}\n\n#item\n")
+ tc("<pre>nowiki</pre><ol><li>item</li></ol>", "{{{\nnowiki\n}}}\n1. item\n")
+ tc("<pre>nowiki</pre><ol><li>item</li></ol>", "{{{\nnowiki\n}}}\n\n1. item\n")
# horizontal
tc("<pre>nowiki</pre><hr/>", "{{{\nnowiki\n}}}\n----\n")
tc("<pre>nowiki</pre><hr/>", "{{{\nnowiki\n}}}\n\n----\n")
# nowiki
tc("<pre>nowiki</pre><pre>nowiki</pre>", "{{{\nnowiki\n}}}\n{{{\nnowiki\n}}}\n")
@@ -627,13 +682,13 @@
tc("<pre>nowiki</pre><table><tr><td>table</td></tr></table>", "{{{\nnowiki\n}}}\n||table||\n")
tc("<pre>nowiki</pre><table><tr><td>table</td></tr></table>", "{{{\nnowiki\n}}}\n\n||table||\n")
end
it 'should parse image' do
- tc("<p><img src=\"image.jpg\"/></p>", "{{image.jpg}}")
- tc("<p><img src=\"image.jpg\" alt=\"tag\"/></p>", "{{image.jpg|tag}}")
- tc("<p><img src=\"http://example.org/image.jpg\"/></p>", "{{http://example.org/image.jpg}}")
+ tc("<p><img src='image.jpg'/></p>", "[[Image(image.jpg)]]")
+ tc("<p><img src='image.jpg' alt='tag'/></p>", "[[Image(image.jpg|tag)]]")
+ tc("<p><img src='http://example.org/image.jpg'/></p>", "[[Image(http://example.org/image.jpg)]]")
end
it 'should parse bold combo' do
tc("<p><strong>bold and</strong></p><table><tr><td>table</td></tr></table><p>end<strong></strong></p>",
"**bold and\n||table||\nend**")
@@ -645,11 +700,11 @@
tce("<p>This is <del>deleted</del></p>",
"This is ~~deleted~~")
tce("<p>This is <sup>super</sup></p>",
- "This is ^^super^^")
+ "This is ^super^")
tce("<p>This is <sub>sub</sub></p>",
"This is ,,sub,,")
tce("<p>®</p>", "(R)")
@@ -661,5 +716,6 @@
it 'should support no_escape' do
tc("<p><a href=\"a%2Fb%2Fc\">a/b/c</a></p>", "[[a/b/c]]")
tc("<p><a href=\"a/b/c\">a/b/c</a></p>", "[[a/b/c]]", :no_escape => true)
end
end
+# vim: tw=0