raf 0.0.0 → 0.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/COPYING +674 -0
- data/Gemfile.lock +20 -0
- data/History.rdoc +2 -0
- data/LICENSE.txt +11 -17
- data/README.rdoc +2 -13
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/bin/raf2html +18 -0
- data/lib/default.css +116 -0
- data/lib/parserutility.rb +18 -0
- data/lib/raf2html.rb +167 -0
- data/lib/raf2html_element.rb +195 -0
- data/lib/rafblockparser.output +670 -0
- data/lib/rafblockparser.ry +356 -0
- data/lib/rafblockparser.tab.rb +717 -0
- data/lib/rafelement.rb +219 -0
- data/lib/rafinlineparser.output +1804 -0
- data/lib/rafinlineparser.ry +451 -0
- data/lib/rafinlineparser.tab.rb +1117 -0
- data/raf.gemspec +118 -0
- data/test/test_descblock.rb +88 -0
- data/test/test_emphasis.rb +76 -0
- data/test/test_erb.rb +23 -0
- data/test/test_footnote.rb +38 -0
- data/test/test_headline.rb +43 -0
- data/test/test_headline_and_itemlist.rb +40 -0
- data/test/test_helper.rb +2 -0
- data/test/test_image.rb +81 -0
- data/test/test_italic.rb +76 -0
- data/test/test_itemlistblock.rb +151 -0
- data/test/test_numlistblock.rb +342 -0
- data/test/test_paragraph.rb +76 -0
- data/test/test_quoteblock.rb +109 -0
- data/test/test_reference.rb +47 -0
- data/test/test_ruby.rb +66 -0
- data/test/test_strike.rb +76 -0
- data/test/test_tableblock.rb +63 -0
- data/test/test_verb.rb +86 -0
- data/test/ts_block.rb +9 -0
- data/test/ts_inline.rb +8 -0
- data/test/ts_rafparser.rb +4 -0
- metadata +67 -12
- data/lib/raf.rb +0 -0
- data/test/test_raf.rb +0 -7
data/raf.gemspec
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{raf}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["garin"]
|
12
|
+
s.date = %q{2011-04-07}
|
13
|
+
s.default_executable = %q{raf2html}
|
14
|
+
s.description = %q{raf is simple document format}
|
15
|
+
s.email = %q{garin54@gmail.com}
|
16
|
+
s.executables = ["raf2html"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
"COPYING",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"History.rdoc",
|
27
|
+
"LICENSE.txt",
|
28
|
+
"README.rdoc",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"bin/raf2html",
|
32
|
+
"lib/default.css",
|
33
|
+
"lib/parserutility.rb",
|
34
|
+
"lib/raf2html.rb",
|
35
|
+
"lib/raf2html_element.rb",
|
36
|
+
"lib/rafblockparser.output",
|
37
|
+
"lib/rafblockparser.ry",
|
38
|
+
"lib/rafblockparser.tab.rb",
|
39
|
+
"lib/rafelement.rb",
|
40
|
+
"lib/rafinlineparser.output",
|
41
|
+
"lib/rafinlineparser.ry",
|
42
|
+
"lib/rafinlineparser.tab.rb",
|
43
|
+
"raf.gemspec",
|
44
|
+
"test/helper.rb",
|
45
|
+
"test/test_descblock.rb",
|
46
|
+
"test/test_emphasis.rb",
|
47
|
+
"test/test_erb.rb",
|
48
|
+
"test/test_footnote.rb",
|
49
|
+
"test/test_headline.rb",
|
50
|
+
"test/test_headline_and_itemlist.rb",
|
51
|
+
"test/test_helper.rb",
|
52
|
+
"test/test_image.rb",
|
53
|
+
"test/test_italic.rb",
|
54
|
+
"test/test_itemlistblock.rb",
|
55
|
+
"test/test_numlistblock.rb",
|
56
|
+
"test/test_paragraph.rb",
|
57
|
+
"test/test_quoteblock.rb",
|
58
|
+
"test/test_reference.rb",
|
59
|
+
"test/test_ruby.rb",
|
60
|
+
"test/test_strike.rb",
|
61
|
+
"test/test_tableblock.rb",
|
62
|
+
"test/test_verb.rb",
|
63
|
+
"test/ts_block.rb",
|
64
|
+
"test/ts_inline.rb",
|
65
|
+
"test/ts_rafparser.rb"
|
66
|
+
]
|
67
|
+
s.homepage = %q{http://github.com/garin/raf}
|
68
|
+
s.licenses = ["GPL"]
|
69
|
+
s.require_paths = ["lib"]
|
70
|
+
s.rubygems_version = %q{1.6.2}
|
71
|
+
s.summary = %q{raf is simple document format}
|
72
|
+
s.test_files = [
|
73
|
+
"test/helper.rb",
|
74
|
+
"test/test_descblock.rb",
|
75
|
+
"test/test_emphasis.rb",
|
76
|
+
"test/test_erb.rb",
|
77
|
+
"test/test_footnote.rb",
|
78
|
+
"test/test_headline.rb",
|
79
|
+
"test/test_headline_and_itemlist.rb",
|
80
|
+
"test/test_helper.rb",
|
81
|
+
"test/test_image.rb",
|
82
|
+
"test/test_italic.rb",
|
83
|
+
"test/test_itemlistblock.rb",
|
84
|
+
"test/test_numlistblock.rb",
|
85
|
+
"test/test_paragraph.rb",
|
86
|
+
"test/test_quoteblock.rb",
|
87
|
+
"test/test_reference.rb",
|
88
|
+
"test/test_ruby.rb",
|
89
|
+
"test/test_strike.rb",
|
90
|
+
"test/test_tableblock.rb",
|
91
|
+
"test/test_verb.rb",
|
92
|
+
"test/ts_block.rb",
|
93
|
+
"test/ts_inline.rb",
|
94
|
+
"test/ts_rafparser.rb"
|
95
|
+
]
|
96
|
+
|
97
|
+
if s.respond_to? :specification_version then
|
98
|
+
s.specification_version = 3
|
99
|
+
|
100
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
101
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
102
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
103
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
104
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
105
|
+
else
|
106
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
107
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
108
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
109
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
110
|
+
end
|
111
|
+
else
|
112
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
113
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
114
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
115
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
@@ -0,0 +1,88 @@
|
|
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
|
@@ -0,0 +1,76 @@
|
|
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
ADDED
@@ -0,0 +1,23 @@
|
|
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
|
@@ -0,0 +1,38 @@
|
|
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>Contents:aaa,Id:1</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
|
@@ -0,0 +1,43 @@
|
|
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
|
@@ -0,0 +1,40 @@
|
|
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
|
+
@hi = StringHeadLineItemlist.new
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_headline_is_headline
|
14
|
+
res = @raf.parse(@hi.single)
|
15
|
+
#assert_kind_of Raf::HeadLine, res[0]
|
16
|
+
p res.size
|
17
|
+
puts "4 is error"
|
18
|
+
# p res[0].contents
|
19
|
+
# p res[1].contents
|
20
|
+
# p res[2].contents
|
21
|
+
# p res[3].contents
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
class StringHeadLineItemlist
|
29
|
+
def single
|
30
|
+
<<EOL
|
31
|
+
== aaa
|
32
|
+
aaa
|
33
|
+
|
34
|
+
* list
|
35
|
+
|
36
|
+
=== bbb
|
37
|
+
BBB
|
38
|
+
EOL
|
39
|
+
end
|
40
|
+
end
|
data/test/test_helper.rb
ADDED
data/test/test_image.rb
ADDED
@@ -0,0 +1,81 @@
|
|
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::Strike, 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
ADDED
@@ -0,0 +1,76 @@
|
|
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
|