raf 0.1.1 → 1.0.0
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +6 -1
- data/History.rdoc +2 -20
- data/LICENSE.txt +1 -1
- data/README.rdoc +6 -16
- data/RELEASE +1 -1
- data/VERSION +1 -1
- data/raf.gemspec +3 -1
- metadata +32 -63
- data/.document +0 -5
- data/bin/raf +0 -19
- data/bin/raf2html +0 -29
- data/lib/parserutility.rb +0 -21
- data/lib/raf.rb +0 -7
- data/lib/raf2html.rb +0 -157
- data/lib/raf2html_element.rb +0 -198
- data/lib/rafblockparser.output +0 -670
- data/lib/rafblockparser.ry +0 -358
- data/lib/rafblockparser.tab.rb +0 -715
- data/lib/rafelement.rb +0 -229
- data/lib/rafinlineparser.output +0 -1804
- data/lib/rafinlineparser.ry +0 -415
- data/lib/rafinlineparser.tab.rb +0 -972
- data/sample.raf +0 -4
- data/test/helper.rb +0 -18
- data/test/test_descblock.rb +0 -88
- data/test/test_emphasis.rb +0 -76
- data/test/test_erb.rb +0 -23
- data/test/test_footnote.rb +0 -38
- data/test/test_headline.rb +0 -43
- data/test/test_helper.rb +0 -2
- data/test/test_image.rb +0 -81
- data/test/test_italic.rb +0 -76
- data/test/test_itemlistblock.rb +0 -151
- data/test/test_numlistblock.rb +0 -342
- data/test/test_paragraph.rb +0 -76
- data/test/test_quoteblock.rb +0 -109
- data/test/test_reference.rb +0 -47
- data/test/test_ruby.rb +0 -66
- data/test/test_strike.rb +0 -76
- data/test/test_tableblock.rb +0 -63
- data/test/test_verb.rb +0 -86
- data/test/ts_block.rb +0 -10
- data/test/ts_inline.rb +0 -8
- data/test/ts_rafparser.rb +0 -4
data/sample.raf
DELETED
data/test/helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'test/unit'
|
11
|
-
require 'shoulda'
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
-
require 'raf'
|
16
|
-
|
17
|
-
class Test::Unit::TestCase
|
18
|
-
end
|
data/test/test_descblock.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
3
|
-
require 'test_helper'
|
4
|
-
require 'rafblockparser.tab'
|
5
|
-
|
6
|
-
class TestRafDescBlock < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@raf = Raf::BlockParser.new
|
9
|
-
@desc = DescString.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_desc_is_desc
|
13
|
-
nodes = @raf.parse(@desc.single)
|
14
|
-
assert_kind_of Raf::Desc, nodes[0]
|
15
|
-
assert_kind_of String, nodes[0].contents[0]
|
16
|
-
assert_kind_of Array, nodes[0].contents[1]
|
17
|
-
assert_kind_of Raf::Plain, nodes[0].contents[1][0]
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_desc_multi
|
21
|
-
nodes = @raf.parse(@desc.multi)
|
22
|
-
assert_kind_of Raf::Desc, nodes[0]
|
23
|
-
assert_kind_of String, nodes[0].contents[0]
|
24
|
-
assert_kind_of Array, nodes[0].contents[1]
|
25
|
-
assert_kind_of Raf::Plain, nodes[0].contents[1][0]
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_desc_no_descline
|
29
|
-
nodes = @raf.parse(@desc.non_descline)
|
30
|
-
assert_kind_of Raf::Desc, nodes[0]
|
31
|
-
assert_kind_of String, nodes[0].contents[0]
|
32
|
-
assert_kind_of Array, nodes[0].contents[1]
|
33
|
-
assert_kind_of Raf::Plain, nodes[0].contents[1][0]
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_desc_inline_element
|
37
|
-
nodes = @raf.parse(@desc.inline_element)
|
38
|
-
assert_kind_of Raf::Desc, nodes[0]
|
39
|
-
assert_equal [Raf::Emphasis, Raf::Plain, Raf::Italic, Raf::Plain], nodes[0].contents[1].map {|c| c.class }
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_desc_title_only
|
43
|
-
res = @raf.parse(@desc.title_only)
|
44
|
-
assert_kind_of Raf::Desc, res[0]
|
45
|
-
assert_equal ":aaa\n", res[0].apply
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
class DescString
|
51
|
-
def single
|
52
|
-
<<EOL
|
53
|
-
:aaa
|
54
|
-
bbb
|
55
|
-
EOL
|
56
|
-
end
|
57
|
-
|
58
|
-
def multi
|
59
|
-
<<EOL
|
60
|
-
:aaa
|
61
|
-
bbb
|
62
|
-
|
63
|
-
ccc
|
64
|
-
EOL
|
65
|
-
end
|
66
|
-
|
67
|
-
def non_descline
|
68
|
-
<<EOL
|
69
|
-
:aaa
|
70
|
-
|
71
|
-
ee
|
72
|
-
EOL
|
73
|
-
end
|
74
|
-
|
75
|
-
def inline_element
|
76
|
-
<<EOL
|
77
|
-
:aaa
|
78
|
-
((*bbb*))
|
79
|
-
((_ccc_))
|
80
|
-
EOL
|
81
|
-
end
|
82
|
-
|
83
|
-
def title_only
|
84
|
-
<<EOL
|
85
|
-
:aaa
|
86
|
-
EOL
|
87
|
-
end
|
88
|
-
end
|
data/test/test_emphasis.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
3
|
-
require 'test_helper'
|
4
|
-
require 'rafinlineparser.tab'
|
5
|
-
|
6
|
-
class TestRafEmphasis < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@raf = Raf::InlineParser.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_emphasis_is_emphasis
|
12
|
-
str = '((*aaa*))'
|
13
|
-
res = @raf.parse(str)
|
14
|
-
assert_kind_of Raf::Emphasis, res[0]
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_emphasis_apply
|
18
|
-
str = '((*aaa*))'
|
19
|
-
res = @raf.parse(str)
|
20
|
-
assert_respond_to res[0], 'apply'
|
21
|
-
assert_equal '<Emphasis>aaa</Emphasis>', res[0].apply
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_emphasis_in_element
|
25
|
-
str1 = '((*((_aaa_))*))'
|
26
|
-
res = @raf.parse(str1)
|
27
|
-
assert_equal [Raf::Italic], res[0].contents.map {|c| c.class }
|
28
|
-
assert_equal '<Emphasis><Italic>aaa</Italic></Emphasis>', res[0].apply
|
29
|
-
|
30
|
-
str2 = '((*a((*a*))a*))'
|
31
|
-
res = @raf.parse(str2)
|
32
|
-
assert_equal [Raf::Plain, Raf::Emphasis, Raf::Plain], res[0].contents.map {|c| c.class }
|
33
|
-
assert_equal '<Emphasis>a<Emphasis>a</Emphasis>a</Emphasis>', res[0].apply
|
34
|
-
|
35
|
-
str3 = '((*a((_a_))a*))'
|
36
|
-
res = @raf.parse(str3)
|
37
|
-
assert_equal [Raf::Plain, Raf::Italic, Raf::Plain], res[0].contents.map {|c| c.class }
|
38
|
-
assert_equal '<Emphasis>a<Italic>a</Italic>a</Emphasis>', res[0].apply
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_emphasis_raise_non_terminate
|
42
|
-
str = '((*aaa))'
|
43
|
-
assert_raise Racc::ParseError do
|
44
|
-
@raf.parse(str)
|
45
|
-
end
|
46
|
-
|
47
|
-
str = '((*aaa'
|
48
|
-
assert_raise Racc::ParseError do
|
49
|
-
@raf.parse(str)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_emphasis_raise_different_terminate
|
54
|
-
str = '((*aaa-))'
|
55
|
-
assert_raise Racc::ParseError do
|
56
|
-
@raf.parse(str)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_emphasis_linefeed
|
61
|
-
str = <<EOL
|
62
|
-
((*a
|
63
|
-
aa*))
|
64
|
-
EOL
|
65
|
-
res = @raf.parse(str)
|
66
|
-
assert_kind_of Raf::Emphasis, res[0]
|
67
|
-
assert_equal "<Emphasis>a\naa</Emphasis>", res[0].apply
|
68
|
-
|
69
|
-
str = '((*a
|
70
|
-
|
71
|
-
aa*))'
|
72
|
-
res = @raf.parse(str)
|
73
|
-
assert_kind_of Raf::Emphasis, res[0]
|
74
|
-
assert_equal "<Emphasis>a\n\naa</Emphasis>", res[0].apply
|
75
|
-
end
|
76
|
-
end
|
data/test/test_erb.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
3
|
-
require 'test_helper'
|
4
|
-
require 'rafinlineparser.tab'
|
5
|
-
|
6
|
-
class TestRafErb < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@raf = Raf::InlineParser.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_erb_is_erb
|
12
|
-
str = "<%= 'aaa' %>"
|
13
|
-
res = @raf.parse(str)
|
14
|
-
assert_kind_of Raf::Plain, res[0]
|
15
|
-
assert_equal "aaa", res[0].apply
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_erb_variable
|
19
|
-
str = "<%= val = 'aaa' ; val %>"
|
20
|
-
res = @raf.parse(str)
|
21
|
-
assert_equal "aaa", res[0].apply
|
22
|
-
end
|
23
|
-
end
|
data/test/test_footnote.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
3
|
-
require 'test_helper'
|
4
|
-
require 'rafinlineparser.tab'
|
5
|
-
|
6
|
-
class TestRafFootnote < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@raf = Raf::InlineParser.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_footnote_is_footnote
|
12
|
-
str = '(([aaa]))'
|
13
|
-
res = @raf.parse(str)
|
14
|
-
assert_kind_of Raf::Footnote, res[0]
|
15
|
-
assert_equal '<Footnote>aaa</Footnote>', res[0].apply
|
16
|
-
assert_equal "aaa", @raf.index[:footnote][0][:content][0].apply
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def test_footnote_multi
|
21
|
-
str = '(([aaa]))(([bbb]))(([ccc]))'
|
22
|
-
res = @raf.parse(str)
|
23
|
-
assert_kind_of Raf::Footnote, res[0]
|
24
|
-
assert_kind_of Raf::Footnote, res[1]
|
25
|
-
assert_kind_of Raf::Footnote, res[2]
|
26
|
-
|
27
|
-
assert_equal "aaa", @raf.index[:footnote][0][:content][0].apply
|
28
|
-
assert_equal "bbb", @raf.index[:footnote][1][:content][0].apply
|
29
|
-
assert_equal "ccc", @raf.index[:footnote][2][:content][0].apply
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_footnote_in_element
|
33
|
-
str = '(([((*aaa*))]))'
|
34
|
-
res = @raf.parse(str)
|
35
|
-
|
36
|
-
assert_equal "<Emphasis>aaa</Emphasis>", @raf.index[:footnote][0][:content][0].apply
|
37
|
-
end
|
38
|
-
end
|
data/test/test_headline.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
3
|
-
require 'test_helper'
|
4
|
-
require 'rafblockparser.tab'
|
5
|
-
|
6
|
-
class TestRafHeadLine < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@raf = Raf::BlockParser.new
|
9
|
-
@headline = StringHeadLine.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_headline_is_headline
|
13
|
-
res = @raf.parse(@headline.single)
|
14
|
-
assert_kind_of Raf::HeadLine, res[0]
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_headline_all
|
19
|
-
res = @raf.parse(@headline.all)
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
class StringHeadLine
|
26
|
-
def single
|
27
|
-
<<EOL
|
28
|
-
= title
|
29
|
-
EOL
|
30
|
-
end
|
31
|
-
|
32
|
-
def all
|
33
|
-
<<EOL
|
34
|
-
= head1
|
35
|
-
== head2
|
36
|
-
=== head3
|
37
|
-
==== head4
|
38
|
-
+ head5
|
39
|
-
++ head6
|
40
|
-
EOL
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
data/test/test_helper.rb
DELETED
data/test/test_image.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
3
|
-
require 'test_helper'
|
4
|
-
require 'rafinlineparser.tab'
|
5
|
-
|
6
|
-
class TestRafImage < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@raf = Raf::InlineParser.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_image_is_image
|
12
|
-
str = '(($aaa.png$))'
|
13
|
-
res = @raf.parse(str)
|
14
|
-
assert_kind_of Raf::Image, res[0]
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_image_apply
|
18
|
-
str1 = '(($aaa.png$))'
|
19
|
-
res = @raf.parse(str1)
|
20
|
-
assert_respond_to res[0], 'apply'
|
21
|
-
assert_equal '<Image>aaa.png</Image>', res[0].apply
|
22
|
-
|
23
|
-
str2 = '(($AAA|aaa.png$))'
|
24
|
-
res = @raf.parse(str2)
|
25
|
-
assert_respond_to res[0], 'apply'
|
26
|
-
assert_equal '<Image>AAA|aaa.png</Image>', res[0].apply
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_image_in_element
|
30
|
-
str1 = '(($((*aaa*))$))'
|
31
|
-
res = @raf.parse(str1)
|
32
|
-
assert_kind_of Raf::Image, res[0]
|
33
|
-
assert_equal '<Image>((*aaa*))</Image>', res[0].apply
|
34
|
-
|
35
|
-
# str2 = '(($a(($a$))a$))'
|
36
|
-
# res = @raf.parse(str2)
|
37
|
-
# assert_equal [Raf::Plain, Raf::Image, Raf::Plain], res[0].contents.map {|c| c.class }
|
38
|
-
# assert_equal '<Image>a<Image>a</Image>a</Image>', res[0].apply
|
39
|
-
|
40
|
-
# str3 = '(($a((*a*))a$))'
|
41
|
-
# res = @raf.parse(str3)
|
42
|
-
# assert_equal [Raf::Plain, Raf::Emphasis, Raf::Plain], res[0].contents.map {|c| c.class }
|
43
|
-
# assert_equal '<Image>a<Emphasis>a</Emphasis>a</Image>', res[0].apply
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_image_raise_non_terminate
|
47
|
-
str = '(($aaa))'
|
48
|
-
assert_raise Racc::ParseError do
|
49
|
-
@raf.parse(str)
|
50
|
-
end
|
51
|
-
|
52
|
-
str = '(($aaa'
|
53
|
-
assert_raise Racc::ParseError do
|
54
|
-
@raf.parse(str)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_image_raise_different_terminate
|
59
|
-
str = '(($aaa*))'
|
60
|
-
assert_raise Racc::ParseError do
|
61
|
-
@raf.parse(str)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_image_linefeed
|
66
|
-
str1 = <<EOL
|
67
|
-
(($a
|
68
|
-
aa$))
|
69
|
-
EOL
|
70
|
-
res = @raf.parse(str1)
|
71
|
-
assert_kind_of Raf::Image, res[0]
|
72
|
-
assert_equal "<Image>a\naa</Image>", res[0].apply
|
73
|
-
|
74
|
-
str2 = '(($a
|
75
|
-
|
76
|
-
aa$))'
|
77
|
-
res = @raf.parse(str2)
|
78
|
-
assert_kind_of Raf::Image, res[0]
|
79
|
-
assert_equal "<Image>a\n\naa</Image>", res[0].apply
|
80
|
-
end
|
81
|
-
end
|
data/test/test_italic.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
3
|
-
require 'test_helper'
|
4
|
-
require 'rafinlineparser.tab'
|
5
|
-
|
6
|
-
class TestRafItalic < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@raf = Raf::InlineParser.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_italic_is_italic
|
12
|
-
str = '((_aaa_))'
|
13
|
-
res = @raf.parse(str)
|
14
|
-
assert_kind_of Raf::Italic, res[0]
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_italic_apply
|
18
|
-
str = '((_aaa_))'
|
19
|
-
res = @raf.parse(str)
|
20
|
-
assert_respond_to res[0], 'apply'
|
21
|
-
assert_equal '<Italic>aaa</Italic>', res[0].apply
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_italic_in_element
|
25
|
-
str1 = '((_((_aaa_))_))'
|
26
|
-
res = @raf.parse(str1)
|
27
|
-
assert_equal [Raf::Italic], res[0].contents.map {|c| c.class }
|
28
|
-
assert_equal '<Italic><Italic>aaa</Italic></Italic>', res[0].apply
|
29
|
-
|
30
|
-
str2 = '((_a((_a_))a_))'
|
31
|
-
res = @raf.parse(str2)
|
32
|
-
assert_equal [Raf::Plain, Raf::Italic, Raf::Plain], res[0].contents.map {|c| c.class }
|
33
|
-
assert_equal '<Italic>a<Italic>a</Italic>a</Italic>', res[0].apply
|
34
|
-
|
35
|
-
str3 = '((_a((*a*))a_))'
|
36
|
-
res = @raf.parse(str3)
|
37
|
-
assert_equal [Raf::Plain, Raf::Emphasis, Raf::Plain], res[0].contents.map {|c| c.class }
|
38
|
-
assert_equal '<Italic>a<Emphasis>a</Emphasis>a</Italic>', res[0].apply
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_italic_raise_non_terminate
|
42
|
-
str = '((_aaa))'
|
43
|
-
assert_raise Racc::ParseError do
|
44
|
-
@raf.parse(str)
|
45
|
-
end
|
46
|
-
|
47
|
-
str = '((_aaa'
|
48
|
-
assert_raise Racc::ParseError do
|
49
|
-
@raf.parse(str)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_italic_raise_different_terminate
|
54
|
-
str = '((_aaa*))'
|
55
|
-
assert_raise Racc::ParseError do
|
56
|
-
@raf.parse(str)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_italic_linefeed
|
61
|
-
str1 = <<EOL
|
62
|
-
((_a
|
63
|
-
aa_))
|
64
|
-
EOL
|
65
|
-
res = @raf.parse(str1)
|
66
|
-
assert_kind_of Raf::Italic, res[0]
|
67
|
-
assert_equal "<Italic>a\naa</Italic>", res[0].apply
|
68
|
-
|
69
|
-
str2 = '((_a
|
70
|
-
|
71
|
-
aa_))'
|
72
|
-
res = @raf.parse(str2)
|
73
|
-
assert_kind_of Raf::Italic, res[0]
|
74
|
-
assert_equal "<Italic>a\n\naa</Italic>", res[0].apply
|
75
|
-
end
|
76
|
-
end
|
data/test/test_itemlistblock.rb
DELETED
@@ -1,151 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), "../lib")
|
3
|
-
require 'test_helper'
|
4
|
-
require 'rafblockparser.tab'
|
5
|
-
|
6
|
-
class TestRafItemListBlock < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@raf = Raf::BlockParser.new
|
9
|
-
@itemlist = ListString.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_list_is_list
|
13
|
-
nodes = @raf.parse(@itemlist.single)
|
14
|
-
assert_kind_of Raf::ItemList, nodes[0]
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_list_is_plain_text_block
|
18
|
-
nodes = @raf.parse(@itemlist.single)
|
19
|
-
assert_kind_of Raf::ItemList, nodes[0]
|
20
|
-
assert_equal [Raf::PlainTextBlock], nodes[0].contents.map {|n| n.class }
|
21
|
-
assert_equal "<ItemList><ItemListItem>aaa</ItemListItem></ItemList>", nodes[0].apply
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_list_multi_line
|
25
|
-
nodes = @raf.parse(@itemlist.multi)
|
26
|
-
assert_kind_of Raf::ItemList, nodes[0]
|
27
|
-
assert_equal [Raf::PlainTextBlock, Raf::PlainTextBlock], nodes[0].contents.map {|n| n.class }
|
28
|
-
assert_equal "<ItemList><ItemListItem>aaa</ItemListItem><ItemListItem>bbb</ItemListItem></ItemList>", nodes[0].apply
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_list_nest
|
32
|
-
nodes = @raf.parse(@itemlist.nest)
|
33
|
-
assert_kind_of Raf::ItemList, nodes[0]
|
34
|
-
assert_equal [Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Symbol], nodes[0].contents.map {|n| n.class }
|
35
|
-
assert_equal "<ItemList><ItemListItem>aaa</ItemListItem><INDENT/><ItemListItem>bbb</ItemListItem><DEDENT/></ItemList>", nodes[0].apply
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_list_nest_and_unnest
|
39
|
-
nodes = @raf.parse(@itemlist.nest_and_unnest_multi_line)
|
40
|
-
assert_kind_of Raf::ItemList, nodes[0]
|
41
|
-
assert_equal [Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Symbol, Symbol, Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock], nodes[0].contents.map {|n| n.class }
|
42
|
-
assert_equal "<ItemList><ItemListItem>aaa</ItemListItem><INDENT/><ItemListItem>bbb</ItemListItem><ItemListItem>ccc</ItemListItem><INDENT/><ItemListItem>ddd</ItemListItem><ItemListItem>eee</ItemListItem><INDENT/><ItemListItem>fff</ItemListItem><DEDENT/><DEDENT/><ItemListItem>ggg</ItemListItem><DEDENT/><ItemListItem>hhh</ItemListItem></ItemList>", nodes[0].apply
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_list_with_inline_element
|
46
|
-
nodes = @raf.parse(@itemlist.inline_element)
|
47
|
-
assert_kind_of Raf::ItemList, nodes[0]
|
48
|
-
assert_equal [Raf::PlainTextBlock, Raf::PlainTextBlock, Raf::PlainTextBlock], nodes[0].contents.map {|n| n.class }
|
49
|
-
assert_kind_of Raf::Emphasis, nodes[0].contents[0].contents[1]
|
50
|
-
assert_equal "<ItemList><ItemListItem>aaa<Emphasis>AAA</Emphasis></ItemListItem><ItemListItem>bbb</ItemListItem><ItemListItem><Italic>ccc</Italic></ItemListItem></ItemList>", nodes[0].apply
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_list_multi_block
|
54
|
-
nodes = @raf.parse(@itemlist.multi_block)
|
55
|
-
assert_equal 3, nodes.size # [itemblock, whiteline, itemblock]
|
56
|
-
assert_kind_of Raf::ItemList, nodes[0]
|
57
|
-
assert_kind_of Raf::ItemList, nodes[2]
|
58
|
-
assert_equal [Raf::PlainTextBlock,Raf::PlainTextBlock], nodes[0].contents.map {|n| n.class }
|
59
|
-
assert_equal [Raf::PlainTextBlock,Raf::PlainTextBlock], nodes[2].contents.map {|n| n.class }
|
60
|
-
assert_equal "<ItemList><ItemListItem>aaa</ItemListItem><ItemListItem>bbb</ItemListItem></ItemList>", nodes[0].apply
|
61
|
-
assert_equal "<ItemList><ItemListItem>ccc</ItemListItem><ItemListItem>ddd</ItemListItem></ItemList>", nodes[2].apply
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_list_with_br
|
65
|
-
nodes = @raf.parse(@itemlist.with_br)
|
66
|
-
assert_equal "<ItemList><ItemListItem>aaa\nbbb</ItemListItem></ItemList>", nodes[0].apply
|
67
|
-
assert_equal "<ItemList><ItemListItem>aaa</ItemListItem></ItemList>", nodes[2].apply
|
68
|
-
assert_equal "bbb", nodes[4].apply
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_list_and_quote
|
72
|
-
nodes = @raf.parse(@itemlist.and_quote)
|
73
|
-
assert_kind_of Raf::ItemList, nodes[0]
|
74
|
-
assert_kind_of Raf::WhiteLine, nodes[1]
|
75
|
-
assert_kind_of Raf::Quote, nodes[2]
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
class ListString
|
80
|
-
def single
|
81
|
-
"* aaa"
|
82
|
-
end
|
83
|
-
|
84
|
-
def multi
|
85
|
-
<<EOL
|
86
|
-
* aaa
|
87
|
-
* bbb
|
88
|
-
EOL
|
89
|
-
end
|
90
|
-
|
91
|
-
def nest
|
92
|
-
<<EOL
|
93
|
-
* aaa
|
94
|
-
* bbb
|
95
|
-
EOL
|
96
|
-
end
|
97
|
-
|
98
|
-
def nest_and_unnest_multi_line
|
99
|
-
<<EOL
|
100
|
-
* aaa
|
101
|
-
* bbb
|
102
|
-
* ccc
|
103
|
-
* ddd
|
104
|
-
* eee
|
105
|
-
* fff
|
106
|
-
* ggg
|
107
|
-
* hhh
|
108
|
-
EOL
|
109
|
-
end
|
110
|
-
|
111
|
-
def inline_element
|
112
|
-
<<EOL
|
113
|
-
* aaa((*AAA*))
|
114
|
-
* bbb
|
115
|
-
* ((_ccc_))
|
116
|
-
EOL
|
117
|
-
end
|
118
|
-
|
119
|
-
def multi_block
|
120
|
-
<<EOL
|
121
|
-
* aaa
|
122
|
-
* bbb
|
123
|
-
|
124
|
-
* ccc
|
125
|
-
* ddd
|
126
|
-
EOL
|
127
|
-
end
|
128
|
-
|
129
|
-
def and_quote
|
130
|
-
<<EOL
|
131
|
-
* aaa
|
132
|
-
* bbb
|
133
|
-
|
134
|
-
ccc
|
135
|
-
ddd
|
136
|
-
EOL
|
137
|
-
end
|
138
|
-
|
139
|
-
# 空行がなればリスト、あれば引用
|
140
|
-
def with_br
|
141
|
-
<<EOL
|
142
|
-
* aaa
|
143
|
-
bbb
|
144
|
-
|
145
|
-
* aaa
|
146
|
-
|
147
|
-
bbb
|
148
|
-
EOL
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|