wikitext 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/h1_spec.rb ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright 2007-2008 Wincent Colaiuta
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require File.join(File.dirname(__FILE__), 'spec_helper.rb')
17
+ require 'wikitext'
18
+
19
+ describe Wikitext::Parser, 'parsing <h1> blocks' do
20
+ before do
21
+ @parser = Wikitext::Parser.new
22
+ end
23
+
24
+ it 'should recognize paired <h1> and </h1> tags' do
25
+ @parser.parse('=foo=').should == "<h1>foo</h1>\n"
26
+ end
27
+
28
+ it 'should strip leading and trailing whitespace from the title' do
29
+ @parser.parse('= foo =').should == "<h1>foo</h1>\n"
30
+ @parser.parse('= foo =').should == "<h1>foo</h1>\n"
31
+ @parser.parse('= foo =').should == "<h1>foo</h1>\n"
32
+ end
33
+
34
+ it 'should accept titles with missing closing tags' do
35
+ @parser.parse('= foo').should == "<h1>foo</h1>\n"
36
+ end
37
+
38
+ it 'should allow header tags to appear within titles' do
39
+ @parser.parse('= foo = bar =').should == "<h1>foo = bar</h1>\n"
40
+ @parser.parse('= foo == bar =').should == "<h1>foo == bar</h1>\n"
41
+ @parser.parse('= foo === bar =').should == "<h1>foo === bar</h1>\n"
42
+ @parser.parse('= foo ==== bar =').should == "<h1>foo ==== bar</h1>\n"
43
+ @parser.parse('= foo ===== bar =').should == "<h1>foo ===== bar</h1>\n"
44
+ @parser.parse('= foo ====== bar =').should == "<h1>foo ====== bar</h1>\n"
45
+ end
46
+
47
+ it 'should show excess characters in closing tags' do
48
+ # the visual feedback alerts the user to the error
49
+ @parser.parse('= foo ==').should == "<h1>foo ==</h1>\n"
50
+ end
51
+
52
+ it 'should be nestable inside blockquote blocks' do
53
+ @parser.parse('> = foo =').should == "<blockquote>\n <h1>foo</h1>\n</blockquote>\n"
54
+ end
55
+
56
+ it 'should have no special meaning inside <nowiki> spans' do
57
+ @parser.parse("<nowiki>\n= foo =</nowiki>").should == "<p>\n= foo =</p>\n"
58
+ end
59
+ end
data/spec/h2_spec.rb ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright 2007-2008 Wincent Colaiuta
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require File.join(File.dirname(__FILE__), 'spec_helper.rb')
17
+ require 'wikitext'
18
+
19
+ describe Wikitext::Parser, 'parsing <h2> blocks' do
20
+ before do
21
+ @parser = Wikitext::Parser.new
22
+ end
23
+
24
+ it 'should recognize paired <h2> and </h2> tags' do
25
+ @parser.parse('==foo==').should == "<h2>foo</h2>\n"
26
+ end
27
+
28
+ it 'should strip leading and trailing whitespace from the title' do
29
+ @parser.parse('== foo ==').should == "<h2>foo</h2>\n"
30
+ @parser.parse('== foo ==').should == "<h2>foo</h2>\n"
31
+ @parser.parse('== foo ==').should == "<h2>foo</h2>\n"
32
+ end
33
+
34
+ it 'should accept titles with missing closing tags' do
35
+ @parser.parse('== foo').should == "<h2>foo</h2>\n"
36
+ end
37
+
38
+ it 'should allow header tags to appear within titles' do
39
+ @parser.parse('== foo = bar ==').should == "<h2>foo = bar</h2>\n"
40
+ @parser.parse('== foo == bar ==').should == "<h2>foo == bar</h2>\n"
41
+ @parser.parse('== foo === bar ==').should == "<h2>foo === bar</h2>\n"
42
+ @parser.parse('== foo ==== bar ==').should == "<h2>foo ==== bar</h2>\n"
43
+ @parser.parse('== foo ===== bar ==').should == "<h2>foo ===== bar</h2>\n"
44
+ @parser.parse('== foo ====== bar ==').should == "<h2>foo ====== bar</h2>\n"
45
+ end
46
+
47
+ it 'should show excess characters in closing tags' do
48
+ # the visual feedback alerts the user to the error
49
+ @parser.parse('== foo ===').should == "<h2>foo ===</h2>\n"
50
+ end
51
+
52
+ it 'should be nestable inside blockquote blocks' do
53
+ @parser.parse('> == foo ==').should == "<blockquote>\n <h2>foo</h2>\n</blockquote>\n"
54
+ end
55
+
56
+ it 'should have no special meaning inside <nowiki> spans' do
57
+ @parser.parse("<nowiki>\n== foo ==</nowiki>").should == "<p>\n== foo ==</p>\n"
58
+ end
59
+ end
data/spec/h3_spec.rb ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright 2007-2008 Wincent Colaiuta
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require File.join(File.dirname(__FILE__), 'spec_helper.rb')
17
+ require 'wikitext'
18
+
19
+ describe Wikitext::Parser, 'parsing <h3> blocks' do
20
+ before do
21
+ @parser = Wikitext::Parser.new
22
+ end
23
+
24
+ it 'should recognize paired <h3> and </h3> tags' do
25
+ @parser.parse('===foo===').should == "<h3>foo</h3>\n"
26
+ end
27
+
28
+ it 'should strip leading and trailing whitespace from the title' do
29
+ @parser.parse('=== foo ===').should == "<h3>foo</h3>\n"
30
+ @parser.parse('=== foo ===').should == "<h3>foo</h3>\n"
31
+ @parser.parse('=== foo ===').should == "<h3>foo</h3>\n"
32
+ end
33
+
34
+ it 'should accept titles with missing closing tags' do
35
+ @parser.parse('=== foo').should == "<h3>foo</h3>\n"
36
+ end
37
+
38
+ it 'should allow header tags to appear within titles' do
39
+ @parser.parse('=== foo = bar ===').should == "<h3>foo = bar</h3>\n"
40
+ @parser.parse('=== foo == bar ===').should == "<h3>foo == bar</h3>\n"
41
+ @parser.parse('=== foo === bar ===').should == "<h3>foo === bar</h3>\n"
42
+ @parser.parse('=== foo ==== bar ===').should == "<h3>foo ==== bar</h3>\n"
43
+ @parser.parse('=== foo ===== bar ===').should == "<h3>foo ===== bar</h3>\n"
44
+ @parser.parse('=== foo ====== bar ===').should == "<h3>foo ====== bar</h3>\n"
45
+ end
46
+
47
+ it 'should show excess characters in closing tags' do
48
+ # the visual feedback alerts the user to the error
49
+ @parser.parse('=== foo ====').should == "<h3>foo ====</h3>\n"
50
+ end
51
+
52
+ it 'should be nestable inside blockquote blocks' do
53
+ @parser.parse('> === foo ===').should == "<blockquote>\n <h3>foo</h3>\n</blockquote>\n"
54
+ end
55
+
56
+ it 'should have no special meaning inside <nowiki> spans' do
57
+ @parser.parse("<nowiki>\n=== foo ===</nowiki>").should == "<p>\n=== foo ===</p>\n"
58
+ end
59
+ end
data/spec/h4_spec.rb ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright 2007-2008 Wincent Colaiuta
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require File.join(File.dirname(__FILE__), 'spec_helper.rb')
17
+ require 'wikitext'
18
+
19
+ describe Wikitext::Parser, 'parsing <h4> blocks' do
20
+ before do
21
+ @parser = Wikitext::Parser.new
22
+ end
23
+
24
+ it 'should recognize paired <h4> and </h4> tags' do
25
+ @parser.parse('====foo====').should == "<h4>foo</h4>\n"
26
+ end
27
+
28
+ it 'should strip leading and trailing whitespace from the title' do
29
+ @parser.parse('==== foo ====').should == "<h4>foo</h4>\n"
30
+ @parser.parse('==== foo ====').should == "<h4>foo</h4>\n"
31
+ @parser.parse('==== foo ====').should == "<h4>foo</h4>\n"
32
+ end
33
+
34
+ it 'should accept titles with missing closing tags' do
35
+ @parser.parse('==== foo').should == "<h4>foo</h4>\n"
36
+ end
37
+
38
+ it 'should allow header tags to appear within titles' do
39
+ @parser.parse('==== foo = bar ====').should == "<h4>foo = bar</h4>\n"
40
+ @parser.parse('==== foo == bar ====').should == "<h4>foo == bar</h4>\n"
41
+ @parser.parse('==== foo === bar ====').should == "<h4>foo === bar</h4>\n"
42
+ @parser.parse('==== foo ==== bar ====').should == "<h4>foo ==== bar</h4>\n"
43
+ @parser.parse('==== foo ===== bar ====').should == "<h4>foo ===== bar</h4>\n"
44
+ @parser.parse('==== foo ====== bar ====').should == "<h4>foo ====== bar</h4>\n"
45
+ end
46
+
47
+ it 'should show excess characters in closing tags' do
48
+ # the visual feedback alerts the user to the error
49
+ @parser.parse('==== foo =====').should == "<h4>foo =====</h4>\n"
50
+ end
51
+
52
+ it 'should be nestable inside blockquote blocks' do
53
+ @parser.parse('> ==== foo ====').should == "<blockquote>\n <h4>foo</h4>\n</blockquote>\n"
54
+ end
55
+
56
+ it 'should have no special meaning inside <nowiki> spans' do
57
+ @parser.parse("<nowiki>\n==== foo ====</nowiki>").should == "<p>\n==== foo ====</p>\n"
58
+ end
59
+ end
data/spec/h5_spec.rb ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright 2007-2008 Wincent Colaiuta
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require File.join(File.dirname(__FILE__), 'spec_helper.rb')
17
+ require 'wikitext'
18
+
19
+ describe Wikitext::Parser, 'parsing <h5> blocks' do
20
+ before do
21
+ @parser = Wikitext::Parser.new
22
+ end
23
+
24
+ it 'should recognize paired <h5> and </h5> tags' do
25
+ @parser.parse('=====foo=====').should == "<h5>foo</h5>\n"
26
+ end
27
+
28
+ it 'should strip leading and trailing whitespace from the title' do
29
+ @parser.parse('===== foo =====').should == "<h5>foo</h5>\n"
30
+ @parser.parse('===== foo =====').should == "<h5>foo</h5>\n"
31
+ @parser.parse('===== foo =====').should == "<h5>foo</h5>\n"
32
+ end
33
+
34
+ it 'should accept titles with missing closing tags' do
35
+ @parser.parse('===== foo').should == "<h5>foo</h5>\n"
36
+ end
37
+
38
+ it 'should allow header tags to appear within titles' do
39
+ @parser.parse('===== foo = bar =====').should == "<h5>foo = bar</h5>\n"
40
+ @parser.parse('===== foo == bar =====').should == "<h5>foo == bar</h5>\n"
41
+ @parser.parse('===== foo === bar =====').should == "<h5>foo === bar</h5>\n"
42
+ @parser.parse('===== foo ==== bar =====').should == "<h5>foo ==== bar</h5>\n"
43
+ @parser.parse('===== foo ===== bar =====').should == "<h5>foo ===== bar</h5>\n"
44
+ @parser.parse('===== foo ====== bar =====').should == "<h5>foo ====== bar</h5>\n"
45
+ end
46
+
47
+ it 'should show excess characters in closing tags' do
48
+ # the visual feedback alerts the user to the error
49
+ @parser.parse('===== foo ======').should == "<h5>foo ======</h5>\n"
50
+ end
51
+
52
+ it 'should be nestable inside blockquote blocks' do
53
+ @parser.parse('> ===== foo =====').should == "<blockquote>\n <h5>foo</h5>\n</blockquote>\n"
54
+ end
55
+
56
+ it 'should have no special meaning inside <nowiki> spans' do
57
+ @parser.parse("<nowiki>\n===== foo =====</nowiki>").should == "<p>\n===== foo =====</p>\n"
58
+ end
59
+ end
data/spec/h6_spec.rb ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright 2007-2008 Wincent Colaiuta
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require File.join(File.dirname(__FILE__), 'spec_helper.rb')
17
+ require 'wikitext'
18
+
19
+ describe Wikitext::Parser, 'parsing <h6> blocks' do
20
+ before do
21
+ @parser = Wikitext::Parser.new
22
+ end
23
+
24
+ it 'should recognize paired <h6> and </h6> tags' do
25
+ @parser.parse('======foo======').should == "<h6>foo</h6>\n"
26
+ end
27
+
28
+ it 'should strip leading and trailing whitespace from the title' do
29
+ @parser.parse('====== foo ======').should == "<h6>foo</h6>\n"
30
+ @parser.parse('====== foo ======').should == "<h6>foo</h6>\n"
31
+ @parser.parse('====== foo ======').should == "<h6>foo</h6>\n"
32
+ end
33
+
34
+ it 'should accept titles with missing closing tags' do
35
+ @parser.parse('====== foo').should == "<h6>foo</h6>\n"
36
+ end
37
+
38
+ it 'should allow header tags to appear within titles' do
39
+ @parser.parse('====== foo = bar ======').should == "<h6>foo = bar</h6>\n"
40
+ @parser.parse('====== foo == bar ======').should == "<h6>foo == bar</h6>\n"
41
+ @parser.parse('====== foo === bar ======').should == "<h6>foo === bar</h6>\n"
42
+ @parser.parse('====== foo ==== bar ======').should == "<h6>foo ==== bar</h6>\n"
43
+ @parser.parse('====== foo ===== bar ======').should == "<h6>foo ===== bar</h6>\n"
44
+ @parser.parse('====== foo ====== bar ======').should == "<h6>foo ====== bar</h6>\n"
45
+ end
46
+
47
+ it 'should show excess characters in closing tags' do
48
+ # in this case only one excess char, then the H6_END matches
49
+ @parser.parse('====== foo =======').should == "<h6>foo =</h6>\n"
50
+ end
51
+
52
+ it 'should be nestable inside blockquote blocks' do
53
+ @parser.parse('> ====== foo ======').should == "<blockquote>\n <h6>foo</h6>\n</blockquote>\n"
54
+ end
55
+
56
+ it 'should have no special meaning inside <nowiki> spans' do
57
+ @parser.parse("<nowiki>\n====== foo ======</nowiki>").should == "<p>\n====== foo ======</p>\n"
58
+ end
59
+ end
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright 2008 Wincent Colaiuta
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require File.join(File.dirname(__FILE__), 'spec_helper.rb')
17
+ require 'wikitext'
18
+
19
+ # this is the inverse of the dedent method in spec_helper.rb
20
+ # it's only in this file because it isn't needed anywhere else
21
+ def indent spaces, string
22
+ string.gsub /^/, ' ' * spaces
23
+ end
24
+
25
+ describe Wikitext::Parser, 'indentation' do
26
+ before do
27
+ @parser = Wikitext::Parser.new
28
+ @input = '* foo'
29
+ @default_output = dedent <<-END
30
+ <ul>
31
+ <li>foo</li>
32
+ </ul>
33
+ END
34
+ end
35
+
36
+ it 'should default to no additional indentation' do
37
+ @parser.parse('* foo').should == @default_output
38
+ end
39
+
40
+ it 'should add additional indentation as indicated by the "indent" option' do
41
+ @parser.parse('* foo', :indent => 1).should == indent(1, @default_output)
42
+ @parser.parse('* foo', :indent => 2).should == indent(2, @default_output)
43
+ @parser.parse('* foo', :indent => 3).should == indent(3, @default_output)
44
+ @parser.parse('* foo', :indent => 4).should == indent(4, @default_output)
45
+ @parser.parse('* foo', :indent => 5).should == indent(5, @default_output)
46
+ @parser.parse('* foo', :indent => 6).should == indent(6, @default_output)
47
+ end
48
+
49
+ it 'should complain if the "indent" option is nil' do
50
+ lambda { @parser.parse('* foo', :default => nil) }.should raise_error(TypeError)
51
+ end
52
+
53
+ it 'should complain if the "indent" options is not an integer' do
54
+ lambda { @parser.parse('* foo', :default => 'bar') }.should raise_error(TypeError)
55
+ lambda { @parser.parse('* foo', :default => /baz/) }.should raise_error(TypeError)
56
+ end
57
+
58
+ it 'should treat a negative "indent" as though it were zero' do
59
+ @parser.parse('* foo', :indent => -4).should == @default_output
60
+ end
61
+
62
+ it 'should coerce a float "indent" into an integer' do
63
+ @parser.parse('* foo', :indent => 0.0).should == @default_output
64
+ @parser.parse('* foo', :indent => 2.0).should == <<-END
65
+ <ul>
66
+ <li>foo</li>
67
+ </ul>
68
+ END
69
+ end
70
+ end
@@ -0,0 +1,265 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright 2007-2008 Wincent Colaiuta
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require File.join(File.dirname(__FILE__), 'spec_helper.rb')
17
+ require 'wikitext'
18
+
19
+ describe Wikitext::Parser, 'with large slab of input text' do
20
+ before do
21
+ @parser = Wikitext::Parser.new
22
+ end
23
+
24
+ # the integration spec is designed to test all aspects of the parser at once
25
+ it 'should handle complex input containing nested structures, syntax errors, and exercising a wide variety features' do
26
+ input = dedent <<-END
27
+ paragraph
28
+ second line
29
+
30
+ new paragraph
31
+
32
+ literal &quot; HTML &copy; entities
33
+
34
+ UTF-8 characters: € etc
35
+
36
+ characters which have <special> meaning in "HTML" & all that
37
+
38
+ = a heading =
39
+
40
+ > a blockquote
41
+ > second line of blockquote
42
+ >
43
+ > new paragraph within blockquote. this one features ''an
44
+ > unclosed em span (should be automatically closed).
45
+ >
46
+ > Note how the optional space following the blockquote marker
47
+ >has no effect.
48
+
49
+ Now check out the alternative blockquote syntax:
50
+
51
+ <blockquote>
52
+ This type of syntax is useful for
53
+ when you have a large number of lines
54
+ in the blockquote and it would be tedious
55
+ to prefix every line with a ">".
56
+
57
+ Note that I can divide things up into
58
+ paragraphs.
59
+
60
+ <blockquote>And I can nest other
61
+ blockquotes</blockquote>
62
+ * and
63
+ *# nest
64
+ *# lists
65
+ * too
66
+
67
+ <pre>and include pre blocks as well.
68
+ This uses the alternative pre block
69
+ syntax as you can see.</pre>
70
+ </blockquote>
71
+
72
+ == another heading ==
73
+
74
+ paragraph within ''multiple '''styles''''' and <tt>tt span</tt>
75
+
76
+ similar, but with '''styles in ''different'' order'''
77
+
78
+ again, a '''different ''order'''''
79
+
80
+ * list item 1 [http://google.com/ unterminated
81
+ ** nested list item 1 with [[bad link
82
+ ** nested list item 2 with unclosed <tt>span
83
+ ** nested list item 3
84
+ * list item 2
85
+
86
+ // this is a code block
87
+ notice how it can contain ''markup''
88
+ which would '''otherwise''' have <tt>special</tt> meaning
89
+ although explicit entities &copy; are passed through unchanged
90
+
91
+ a normal paragraph again
92
+
93
+ > This is another blockquote which demonstrates that we
94
+ > can nest other structures inside of it. For example, here
95
+ > we have a code sample:
96
+ >
97
+ > line 1
98
+ > line 2
99
+ >
100
+ > And now back to the normal blockquote again.
101
+ >
102
+ > * here
103
+ > * is
104
+ > * a
105
+ > * list
106
+ >
107
+ > And here is a link to [[something]], and some ''other''
108
+ > `styled` '''spans'''.
109
+ >
110
+ > > Finally we have
111
+ > > a nested blockquote.
112
+ > > # Which itself contains
113
+ > > ## a nested list
114
+
115
+ This is where we show a link to an article on [[GCC]].
116
+ Related to that, [[GCC|a link]] to the same
117
+ article but with custom link text.
118
+
119
+ External links [http://example.com work too].
120
+ As well as autolinks as seen http://example.com/
121
+ here.
122
+
123
+ Look at how we handle bad syntax. [[This is an unterminated
124
+ link. And [http://example.com/ is another.
125
+
126
+ # this is an ordered list
127
+ # which continues
128
+ ## and has another ordered list
129
+ ## nested inside it
130
+ # and then falls back
131
+ #* and then nests another list
132
+ #* this time an unordered one
133
+ #** itself containing a nested list
134
+ #** which continues
135
+ #**# and finally nests yet another ordered list
136
+ #**# which continues
137
+ #* drops back quite a way
138
+ # and finally all the way
139
+ #****** and finishes with an invalid item
140
+
141
+ === heading with missing closing tag
142
+ * list
143
+ # new list
144
+ END
145
+
146
+ expected = dedent <<-END
147
+ <p>paragraph second line</p>
148
+ <p>new paragraph</p>
149
+ <p>literal &quot; HTML &copy; entities</p>
150
+ <p>UTF-8 characters: &#x20ac; etc</p>
151
+ <p>characters which have &lt;special&gt; meaning in &quot;HTML&quot; &amp; all that</p>
152
+ <h1>a heading</h1>
153
+ <blockquote>
154
+ <p>a blockquote second line of blockquote</p>
155
+ <p>new paragraph within blockquote. this one features <em>an</em> unclosed em span (should be automatically closed).</p>
156
+ <p>Note how the optional space following the blockquote marker has no effect.</p>
157
+ </blockquote>
158
+ <p>Now check out the alternative blockquote syntax:</p>
159
+ <blockquote>
160
+ <p>This type of syntax is useful for when you have a large number of lines in the blockquote and it would be tedious to prefix every line with a &quot;&gt;&quot;.</p>
161
+ <p>Note that I can divide things up into paragraphs.</p>
162
+ <blockquote>
163
+ <p>And I can nest other blockquotes</p>
164
+ </blockquote>
165
+ <ul>
166
+ <li>and
167
+ <ol>
168
+ <li>nest</li>
169
+ <li>lists</li>
170
+ </ol>
171
+ </li>
172
+ <li>too</li>
173
+ </ul>
174
+ <pre>and include pre blocks as well.
175
+ This uses the alternative pre block
176
+ syntax as you can see.</pre>
177
+ </blockquote>
178
+ <h2>another heading</h2>
179
+ <p>paragraph within <em>multiple <strong>styles</strong></em> and <tt>tt span</tt></p>
180
+ <p>similar, but with <strong>styles in <em>different</em> order</strong></p>
181
+ <p>again, a <strong>different <em>order</em></strong></p>
182
+ <ul>
183
+ <li>list item 1 [<a href="http://google.com/" class="external">http://google.com/</a> unterminated
184
+ <ul>
185
+ <li>nested list item 1 with [[bad link</li>
186
+ <li>nested list item 2 with unclosed <tt>span</tt></li>
187
+ <li>nested list item 3</li>
188
+ </ul>
189
+ </li>
190
+ <li>list item 2</li>
191
+ </ul>
192
+ <pre>// this is a code block
193
+ notice how it can contain ''markup''
194
+ which would '''otherwise''' have &lt;tt&gt;special&lt;/tt&gt; meaning
195
+ although explicit entities &copy; are passed through unchanged</pre>
196
+ <p>a normal paragraph again</p>
197
+ <blockquote>
198
+ <p>This is another blockquote which demonstrates that we can nest other structures inside of it. For example, here we have a code sample:</p>
199
+ <pre>line 1
200
+ line 2</pre>
201
+ <p>And now back to the normal blockquote again.</p>
202
+ <ul>
203
+ <li>here</li>
204
+ <li>is</li>
205
+ <li>a</li>
206
+ <li>list</li>
207
+ </ul>
208
+ <p>And here is a link to <a href="/wiki/something">something</a>, and some <em>other</em> <tt>styled</tt> <strong>spans</strong>.</p>
209
+ <blockquote>
210
+ <p>Finally we have a nested blockquote.</p>
211
+ <ol>
212
+ <li>Which itself contains
213
+ <ol>
214
+ <li>a nested list</li>
215
+ </ol>
216
+ </li>
217
+ </ol>
218
+ </blockquote>
219
+ </blockquote>
220
+ <p>This is where we show a link to an article on <a href="/wiki/GCC">GCC</a>. Related to that, <a href="/wiki/GCC">a link</a> to the same article but with custom link text.</p>
221
+ <p>External links <a href="http://example.com" class="external">work too</a>. As well as autolinks as seen <a href="http://example.com/" class="external">http://example.com/</a> here.</p>
222
+ <p>Look at how we handle bad syntax. [[This is an unterminated link. And [<a href="http://example.com/" class="external">http://example.com/</a> is another.</p>
223
+ <ol>
224
+ <li>this is an ordered list</li>
225
+ <li>which continues
226
+ <ol>
227
+ <li>and has another ordered list</li>
228
+ <li>nested inside it</li>
229
+ </ol>
230
+ </li>
231
+ <li>and then falls back
232
+ <ul>
233
+ <li>and then nests another list</li>
234
+ <li>this time an unordered one
235
+ <ul>
236
+ <li>itself containing a nested list</li>
237
+ <li>which continues
238
+ <ol>
239
+ <li>and finally nests yet another ordered list</li>
240
+ <li>which continues</li>
241
+ </ol>
242
+ </li>
243
+ </ul>
244
+ </li>
245
+ <li>drops back quite a way</li>
246
+ </ul>
247
+ </li>
248
+ <li>and finally all the way
249
+ <ul>
250
+ <li>***** and finishes with an invalid item</li>
251
+ </ul>
252
+ </li>
253
+ </ol>
254
+ <h3>heading with missing closing tag</h3>
255
+ <ul>
256
+ <li>list</li>
257
+ </ul>
258
+ <ol>
259
+ <li>new list</li>
260
+ </ol>
261
+ END
262
+
263
+ @parser.parse(input).should == expected
264
+ end
265
+ end