raf 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/test/test_numlistblock.rb
DELETED
@@ -1,342 +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 TestRafNumListBlock < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@raf = Raf::BlockParser.new
|
9
|
-
@numlist1 = NumlistString1.new
|
10
|
-
@numlist2 = NumlistString2.new
|
11
|
-
@numlistmix = NumlistStringMix.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_numlist_is_numlist
|
15
|
-
res1 = @raf.parse(@numlist1.single)
|
16
|
-
assert_kind_of Raf::NumList, res1[0]
|
17
|
-
|
18
|
-
res2 = @raf.parse(@numlist2.single)
|
19
|
-
assert_kind_of Raf::NumList, res2[0]
|
20
|
-
|
21
|
-
res3 = @raf.parse(@numlistmix.single)
|
22
|
-
assert_kind_of Raf::NumList, res3[0]
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_numlist_is_plain_text_block
|
26
|
-
res1 = @raf.parse(@numlist1.single)
|
27
|
-
assert_kind_of Raf::NumList, res1[0]
|
28
|
-
assert_equal [Raf::PlainTextBlock], res1[0].contents.map {|n| n.class }
|
29
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem></NumList>", res1[0].apply
|
30
|
-
|
31
|
-
res2 = @raf.parse(@numlist2.single)
|
32
|
-
assert_kind_of Raf::NumList, res2[0]
|
33
|
-
assert_equal [Raf::PlainTextBlock], res2[0].contents.map {|n| n.class }
|
34
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem></NumList>", res2[0].apply
|
35
|
-
|
36
|
-
res3 = @raf.parse(@numlistmix.single)
|
37
|
-
assert_kind_of Raf::NumList, res3[0]
|
38
|
-
assert_equal [Raf::PlainTextBlock], res3[0].contents.map {|n| n.class }
|
39
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem></NumList>", res3[0].apply
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_numlist_multi_line
|
43
|
-
res1 = @raf.parse(@numlist1.multi)
|
44
|
-
assert_kind_of Raf::NumList, res1[0]
|
45
|
-
assert_equal [Raf::PlainTextBlock, Raf::PlainTextBlock], res1[0].contents.map {|n| n.class }
|
46
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem><NumListItem>2. bbb</NumListItem></NumList>", res1[0].apply
|
47
|
-
|
48
|
-
res2 = @raf.parse(@numlist2.multi)
|
49
|
-
assert_kind_of Raf::NumList, res2[0]
|
50
|
-
assert_equal [Raf::PlainTextBlock, Raf::PlainTextBlock], res2[0].contents.map {|n| n.class }
|
51
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem><NumListItem>2. bbb</NumListItem></NumList>", res2[0].apply
|
52
|
-
|
53
|
-
res3 = @raf.parse(@numlistmix.multi)
|
54
|
-
assert_kind_of Raf::NumList, res3[0]
|
55
|
-
assert_equal [Raf::PlainTextBlock, Raf::PlainTextBlock], res3[0].contents.map {|n| n.class }
|
56
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem><NumListItem>2. bbb</NumListItem></NumList>", res3[0].apply
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_numlist_nest
|
60
|
-
res1 = @raf.parse(@numlist1.nest)
|
61
|
-
assert_kind_of Raf::NumList, res1[0]
|
62
|
-
assert_equal [Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Symbol], res1[0].contents.map {|n| n.class }
|
63
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem><INDENT/><NumListItem>2. bbb</NumListItem><DEDENT/></NumList>", res1[0].apply
|
64
|
-
|
65
|
-
res2 = @raf.parse(@numlist2.nest)
|
66
|
-
assert_kind_of Raf::NumList, res2[0]
|
67
|
-
assert_equal [Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Symbol], res2[0].contents.map {|n| n.class }
|
68
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem><INDENT/><NumListItem>2. bbb</NumListItem><DEDENT/></NumList>", res2[0].apply
|
69
|
-
|
70
|
-
res3 = @raf.parse(@numlistmix.nest)
|
71
|
-
assert_kind_of Raf::NumList, res3[0]
|
72
|
-
assert_equal [Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Symbol], res3[0].contents.map {|n| n.class }
|
73
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem><INDENT/><NumListItem>2. bbb</NumListItem><DEDENT/></NumList>", res3[0].apply
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_numlist_nest_and_unnest
|
77
|
-
res1 = @raf.parse(@numlist1.nest_and_unnest_multi_line)
|
78
|
-
assert_kind_of Raf::NumList, res1[0]
|
79
|
-
assert_equal [Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Symbol, Symbol, Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock], res1[0].contents.map {|n| n.class }
|
80
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem><INDENT/><NumListItem>2. bbb</NumListItem><NumListItem>3. ccc</NumListItem><INDENT/><NumListItem>4. ddd</NumListItem><NumListItem>5. eee</NumListItem><INDENT/><NumListItem>6. fff</NumListItem><DEDENT/><DEDENT/><NumListItem>7. ggg</NumListItem><DEDENT/><NumListItem>8. hhh</NumListItem></NumList>", res1[0].apply
|
81
|
-
|
82
|
-
res2 = @raf.parse(@numlist2.nest_and_unnest_multi_line)
|
83
|
-
assert_kind_of Raf::NumList, res2[0]
|
84
|
-
assert_equal [Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Symbol, Symbol, Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock], res2[0].contents.map {|n| n.class }
|
85
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem><INDENT/><NumListItem>2. bbb</NumListItem><NumListItem>3. ccc</NumListItem><INDENT/><NumListItem>4. ddd</NumListItem><NumListItem>5. eee</NumListItem><INDENT/><NumListItem>6. fff</NumListItem><DEDENT/><DEDENT/><NumListItem>7. ggg</NumListItem><DEDENT/><NumListItem>8. hhh</NumListItem></NumList>", res2[0].apply
|
86
|
-
|
87
|
-
res3 = @raf.parse(@numlistmix.nest_and_unnest_multi_line)
|
88
|
-
assert_kind_of Raf::NumList, res3[0]
|
89
|
-
assert_equal [Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock, Symbol, Symbol, Raf::PlainTextBlock, Symbol, Raf::PlainTextBlock], res3[0].contents.map {|n| n.class }
|
90
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem><INDENT/><NumListItem>2. bbb</NumListItem><NumListItem>3. ccc</NumListItem><INDENT/><NumListItem>4. ddd</NumListItem><NumListItem>5. eee</NumListItem><INDENT/><NumListItem>6. fff</NumListItem><DEDENT/><DEDENT/><NumListItem>7. ggg</NumListItem><DEDENT/><NumListItem>8. hhh</NumListItem></NumList>", res3[0].apply
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_numlist_with_inline_element
|
94
|
-
res1 = @raf.parse(@numlist1.inline_element)
|
95
|
-
assert_kind_of Raf::NumList, res1[0]
|
96
|
-
assert_equal [Raf::PlainTextBlock, Raf::PlainTextBlock, Raf::PlainTextBlock], res1[0].contents.map {|n| n.class }
|
97
|
-
assert_kind_of Raf::Emphasis, res1[0].contents[0].contents[1]
|
98
|
-
assert_equal "<NumList><NumListItem>1. aaa<Emphasis>AAA</Emphasis></NumListItem><NumListItem>2. bbb</NumListItem><NumListItem>3. <Italic>ccc</Italic></NumListItem></NumList>", res1[0].apply
|
99
|
-
|
100
|
-
res2 = @raf.parse(@numlist2.inline_element)
|
101
|
-
assert_kind_of Raf::NumList, res2[0]
|
102
|
-
assert_equal [Raf::PlainTextBlock, Raf::PlainTextBlock, Raf::PlainTextBlock], res2[0].contents.map {|n| n.class }
|
103
|
-
assert_kind_of Raf::Emphasis, res2[0].contents[0].contents[1]
|
104
|
-
assert_equal "<NumList><NumListItem>1. aaa<Emphasis>AAA</Emphasis></NumListItem><NumListItem>2. bbb</NumListItem><NumListItem>3. <Italic>ccc</Italic></NumListItem></NumList>", res2[0].apply
|
105
|
-
|
106
|
-
res3 = @raf.parse(@numlistmix.inline_element)
|
107
|
-
assert_kind_of Raf::NumList, res3[0]
|
108
|
-
assert_equal [Raf::PlainTextBlock, Raf::PlainTextBlock, Raf::PlainTextBlock], res3[0].contents.map {|n| n.class }
|
109
|
-
assert_kind_of Raf::Emphasis, res3[0].contents[0].contents[1]
|
110
|
-
assert_equal "<NumList><NumListItem>1. aaa<Emphasis>AAA</Emphasis></NumListItem><NumListItem>2. bbb</NumListItem><NumListItem>3. <Italic>ccc</Italic></NumListItem></NumList>", res3[0].apply
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_numlist_multi_block
|
114
|
-
res1 = @raf.parse(@numlist1.multi_block)
|
115
|
-
assert_equal 3, res1.size # [itemblock, whiteline, itemblock]
|
116
|
-
assert_kind_of Raf::NumList, res1[0]
|
117
|
-
assert_kind_of Raf::NumList, res1[2]
|
118
|
-
assert_equal [Raf::PlainTextBlock,Raf::PlainTextBlock], res1[0].contents.map {|n| n.class }
|
119
|
-
assert_equal [Raf::PlainTextBlock,Raf::PlainTextBlock], res1[2].contents.map {|n| n.class }
|
120
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem><NumListItem>2. bbb</NumListItem></NumList>", res1[0].apply
|
121
|
-
assert_equal "<NumList><NumListItem>1. ccc</NumListItem><NumListItem>2. ddd</NumListItem></NumList>", res1[2].apply
|
122
|
-
|
123
|
-
res2 = @raf.parse(@numlist2.multi_block)
|
124
|
-
assert_equal 3, res2.size # [itemblock, whiteline, itemblock]
|
125
|
-
assert_kind_of Raf::NumList, res2[0]
|
126
|
-
assert_kind_of Raf::NumList, res2[2]
|
127
|
-
assert_equal [Raf::PlainTextBlock,Raf::PlainTextBlock], res2[0].contents.map {|n| n.class }
|
128
|
-
assert_equal [Raf::PlainTextBlock,Raf::PlainTextBlock], res2[2].contents.map {|n| n.class }
|
129
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem><NumListItem>2. bbb</NumListItem></NumList>", res2[0].apply
|
130
|
-
assert_equal "<NumList><NumListItem>1. ccc</NumListItem><NumListItem>2. ddd</NumListItem></NumList>", res2[2].apply
|
131
|
-
|
132
|
-
res3 = @raf.parse(@numlistmix.multi_block)
|
133
|
-
assert_equal 3, res3.size # [itemblock, whiteline, itemblock]
|
134
|
-
assert_kind_of Raf::NumList, res3[0]
|
135
|
-
assert_kind_of Raf::NumList, res3[2]
|
136
|
-
assert_equal [Raf::PlainTextBlock,Raf::PlainTextBlock], res3[0].contents.map {|n| n.class }
|
137
|
-
assert_equal [Raf::PlainTextBlock,Raf::PlainTextBlock], res3[2].contents.map {|n| n.class }
|
138
|
-
assert_equal "<NumList><NumListItem>1. aaa</NumListItem><NumListItem>2. bbb</NumListItem></NumList>", res3[0].apply
|
139
|
-
assert_equal "<NumList><NumListItem>1. ccc</NumListItem><NumListItem>2. ddd</NumListItem></NumList>", res3[2].apply
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_numlist_and_quote
|
143
|
-
res1 = @raf.parse(@numlist1.and_quote)
|
144
|
-
assert_kind_of Raf::NumList, res1[0]
|
145
|
-
assert_kind_of Raf::WhiteLine, res1[1]
|
146
|
-
assert_kind_of Raf::Quote, res1[2]
|
147
|
-
|
148
|
-
res2 = @raf.parse(@numlist2.and_quote)
|
149
|
-
assert_kind_of Raf::NumList, res2[0]
|
150
|
-
assert_kind_of Raf::WhiteLine, res2[1]
|
151
|
-
assert_kind_of Raf::Quote, res2[2]
|
152
|
-
|
153
|
-
res3 = @raf.parse(@numlistmix.and_quote)
|
154
|
-
assert_kind_of Raf::NumList, res3[0]
|
155
|
-
assert_kind_of Raf::WhiteLine, res3[1]
|
156
|
-
assert_kind_of Raf::Quote, res3[2]
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
class NumlistString1
|
161
|
-
def single
|
162
|
-
"(1) aaa"
|
163
|
-
end
|
164
|
-
|
165
|
-
def multi
|
166
|
-
<<EOL
|
167
|
-
(1) aaa
|
168
|
-
(2) bbb
|
169
|
-
EOL
|
170
|
-
end
|
171
|
-
|
172
|
-
def nest
|
173
|
-
<<EOL
|
174
|
-
(1) aaa
|
175
|
-
(1) bbb
|
176
|
-
EOL
|
177
|
-
end
|
178
|
-
|
179
|
-
def nest_and_unnest_multi_line
|
180
|
-
<<EOL
|
181
|
-
(1) aaa
|
182
|
-
(2) bbb
|
183
|
-
(3) ccc
|
184
|
-
(4) ddd
|
185
|
-
(5) eee
|
186
|
-
(6) fff
|
187
|
-
(7) ggg
|
188
|
-
(8) hhh
|
189
|
-
EOL
|
190
|
-
end
|
191
|
-
|
192
|
-
def inline_element
|
193
|
-
<<EOL
|
194
|
-
(1) aaa((*AAA*))
|
195
|
-
(2) bbb
|
196
|
-
(3) ((_ccc_))
|
197
|
-
EOL
|
198
|
-
end
|
199
|
-
|
200
|
-
def multi_block
|
201
|
-
<<EOL
|
202
|
-
(1) aaa
|
203
|
-
(2) bbb
|
204
|
-
|
205
|
-
(3) ccc
|
206
|
-
(4) ddd
|
207
|
-
EOL
|
208
|
-
end
|
209
|
-
|
210
|
-
def and_quote
|
211
|
-
<<EOL
|
212
|
-
(1) aaa
|
213
|
-
(2) bbb
|
214
|
-
|
215
|
-
ccc
|
216
|
-
ddd
|
217
|
-
EOL
|
218
|
-
end
|
219
|
-
|
220
|
-
end
|
221
|
-
|
222
|
-
class NumlistString2
|
223
|
-
def single
|
224
|
-
"1. aaa"
|
225
|
-
end
|
226
|
-
|
227
|
-
def multi
|
228
|
-
<<EOL
|
229
|
-
1. aaa
|
230
|
-
2. bbb
|
231
|
-
EOL
|
232
|
-
end
|
233
|
-
|
234
|
-
def nest
|
235
|
-
<<EOL
|
236
|
-
1. aaa
|
237
|
-
1. bbb
|
238
|
-
EOL
|
239
|
-
end
|
240
|
-
|
241
|
-
def nest_and_unnest_multi_line
|
242
|
-
<<EOL
|
243
|
-
1. aaa
|
244
|
-
2. bbb
|
245
|
-
3. ccc
|
246
|
-
4. ddd
|
247
|
-
5. eee
|
248
|
-
6. fff
|
249
|
-
7. ggg
|
250
|
-
8. hhh
|
251
|
-
EOL
|
252
|
-
end
|
253
|
-
|
254
|
-
def inline_element
|
255
|
-
<<EOL
|
256
|
-
1. aaa((*AAA*))
|
257
|
-
2. bbb
|
258
|
-
3. ((_ccc_))
|
259
|
-
EOL
|
260
|
-
end
|
261
|
-
|
262
|
-
def multi_block
|
263
|
-
<<EOL
|
264
|
-
1. aaa
|
265
|
-
2. bbb
|
266
|
-
|
267
|
-
3. ccc
|
268
|
-
4. ddd
|
269
|
-
EOL
|
270
|
-
end
|
271
|
-
|
272
|
-
def and_quote
|
273
|
-
<<EOL
|
274
|
-
1. aaa
|
275
|
-
2. bbb
|
276
|
-
|
277
|
-
ccc
|
278
|
-
ddd
|
279
|
-
EOL
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
class NumlistStringMix
|
284
|
-
def single
|
285
|
-
"1. aaa"
|
286
|
-
end
|
287
|
-
|
288
|
-
def multi
|
289
|
-
<<EOL
|
290
|
-
(1) aaa
|
291
|
-
2. bbb
|
292
|
-
EOL
|
293
|
-
end
|
294
|
-
|
295
|
-
def nest
|
296
|
-
<<EOL
|
297
|
-
(1) aaa
|
298
|
-
2. bbb
|
299
|
-
EOL
|
300
|
-
end
|
301
|
-
|
302
|
-
def nest_and_unnest_multi_line
|
303
|
-
<<EOL
|
304
|
-
1. aaa
|
305
|
-
(2) bbb
|
306
|
-
3. ccc
|
307
|
-
(4) ddd
|
308
|
-
(5) eee
|
309
|
-
6. fff
|
310
|
-
7. ggg
|
311
|
-
(8) hhh
|
312
|
-
EOL
|
313
|
-
end
|
314
|
-
|
315
|
-
def inline_element
|
316
|
-
<<EOL
|
317
|
-
1. aaa((*AAA*))
|
318
|
-
(2) bbb
|
319
|
-
3. ((_ccc_))
|
320
|
-
EOL
|
321
|
-
end
|
322
|
-
|
323
|
-
def multi_block
|
324
|
-
<<EOL
|
325
|
-
1. aaa
|
326
|
-
2. bbb
|
327
|
-
|
328
|
-
(3) ccc
|
329
|
-
4. ddd
|
330
|
-
EOL
|
331
|
-
end
|
332
|
-
|
333
|
-
def and_quote
|
334
|
-
<<EOL
|
335
|
-
1. aaa
|
336
|
-
(2) bbb
|
337
|
-
|
338
|
-
ccc
|
339
|
-
ddd
|
340
|
-
EOL
|
341
|
-
end
|
342
|
-
end
|
data/test/test_paragraph.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 'rafblockparser.tab'
|
5
|
-
|
6
|
-
class TestRafBlockParser < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@raf = Raf::BlockParser.new
|
9
|
-
@single_line_str = "aaa"
|
10
|
-
@multi_line_str = <<EOL
|
11
|
-
aaa bbb ccc
|
12
|
-
ddd eee fff
|
13
|
-
EOL
|
14
|
-
@multi_block_str = <<EOL
|
15
|
-
aaa bbb ccc
|
16
|
-
ddd eee fff
|
17
|
-
|
18
|
-
ggg hhh iii
|
19
|
-
jjj kkk lll
|
20
|
-
EOL
|
21
|
-
|
22
|
-
@single_line_with_inline_elements_str = <<EOL
|
23
|
-
aaa ((*bbb*)) ((*ccc*))
|
24
|
-
EOL
|
25
|
-
|
26
|
-
@one_space = <<EOL
|
27
|
-
aaa
|
28
|
-
EOL
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_paragraph_is_paragraph
|
32
|
-
nodes = @raf.parse(@single_line_str)
|
33
|
-
assert_kind_of Raf::Paragraph, nodes[0]
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_paragraph_single_line_node_is_plain_text
|
37
|
-
nodes = @raf.parse(@single_line_str)
|
38
|
-
nodes.each do |node|
|
39
|
-
assert_kind_of Raf::Plain, node.contents.first
|
40
|
-
assert_kind_of String, node.apply
|
41
|
-
assert_equal node.apply, @single_line_str
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_paragraph_multi_line
|
46
|
-
nodes = @raf.parse(@multi_line_str)
|
47
|
-
assert_kind_of String, nodes.first.apply
|
48
|
-
assert_equal nodes.first.apply, @multi_line_str
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_paragraph_multi_block
|
52
|
-
nodes = @raf.parse(@multi_block_str)
|
53
|
-
assert_equal 3, nodes.size # textblock, whiteline, textblock
|
54
|
-
assert_kind_of Raf::Plain, nodes[0].contents[0]
|
55
|
-
assert_kind_of String, nodes[0].apply
|
56
|
-
assert_kind_of Raf::WhiteLine, nodes[1]
|
57
|
-
assert_kind_of String, nodes[1].apply
|
58
|
-
assert_kind_of Raf::Plain, nodes[2].contents[0]
|
59
|
-
assert_kind_of String, nodes[2].apply
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_paragraph_with_inline_elements
|
63
|
-
# nodes = plain emphasis plain(space) emphasis
|
64
|
-
nodes = @raf.parse(@single_line_with_inline_elements_str)
|
65
|
-
assert_kind_of Raf::Emphasis, nodes[0].contents[1]
|
66
|
-
assert_kind_of Raf::Emphasis, nodes[0].contents[3]
|
67
|
-
|
68
|
-
assert_equal "aaa <Emphasis>bbb</Emphasis> <Emphasis>ccc</Emphasis>\n", nodes[0].apply
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_paragraph_one_space
|
72
|
-
res = @raf.parse(@one_space)
|
73
|
-
assert_kind_of Raf::Paragraph, res[0]
|
74
|
-
assert_equal " aaa\n", res[0].apply
|
75
|
-
end
|
76
|
-
end
|
data/test/test_quoteblock.rb
DELETED
@@ -1,109 +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 TestRafQuoteBlock < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@raf = Raf::BlockParser.new
|
10
|
-
@quote = QuoteString.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_quote_is_quote
|
14
|
-
nodes = @raf.parse(@quote.single)
|
15
|
-
assert_kind_of Raf::Quote, nodes[0]
|
16
|
-
assert_equal delete_indent(@quote.single), nodes[0].apply
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_quote_multi
|
20
|
-
nodes = @raf.parse(@quote.multi)
|
21
|
-
assert_equal nodes.size, 1, "ホワイトリストがあっても1ブロック" # [quote]
|
22
|
-
assert_kind_of Raf::Quote, nodes[0]
|
23
|
-
assert_equal delete_indent(@quote.multi), nodes[0].apply
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_quote_inline_element
|
27
|
-
nodes = @raf.parse(@quote.inline_element)
|
28
|
-
assert_kind_of Raf::Quote, nodes[0]
|
29
|
-
# インラインエレメントは変換しないでそのまま
|
30
|
-
assert_equal delete_indent(@quote.inline_element), nodes[0].apply
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_quote_multi_indent
|
34
|
-
nodes = @raf.parse(@quote.multi_indent)
|
35
|
-
assert_kind_of Raf::Quote, nodes[0]
|
36
|
-
# インデントを無視する
|
37
|
-
assert_equal "aaa\n bbb\n ccc\n ddd\nfff", nodes[0].apply
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_quote_space
|
41
|
-
res1 = @raf.parse(@quote.space)
|
42
|
-
assert_kind_of Raf::Quote, res1[0]
|
43
|
-
assert_equal "aaa\nbbb",res1[0].apply
|
44
|
-
|
45
|
-
res2 = @raf.parse(@quote.space2)
|
46
|
-
assert_kind_of Raf::Quote, res2[0]
|
47
|
-
assert_equal "aaa\nbbb",res2[0].apply
|
48
|
-
end
|
49
|
-
|
50
|
-
def delete_indent(str)
|
51
|
-
str.map {|s| s.sub(/^ /, "") }.to_s.strip
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
class QuoteString
|
57
|
-
def single
|
58
|
-
<<EOL
|
59
|
-
aaa
|
60
|
-
bbb
|
61
|
-
EOL
|
62
|
-
end
|
63
|
-
|
64
|
-
def multi
|
65
|
-
<<EOL
|
66
|
-
aaa
|
67
|
-
bbb
|
68
|
-
|
69
|
-
ccc
|
70
|
-
ddd
|
71
|
-
EOL
|
72
|
-
end
|
73
|
-
|
74
|
-
def inline_element
|
75
|
-
<<EOL
|
76
|
-
((*aaa*))
|
77
|
-
((_bbb_))
|
78
|
-
EOL
|
79
|
-
end
|
80
|
-
|
81
|
-
def multi_indent
|
82
|
-
<<EOL
|
83
|
-
aaa
|
84
|
-
bbb
|
85
|
-
ccc
|
86
|
-
ddd
|
87
|
-
fff
|
88
|
-
EOL
|
89
|
-
end
|
90
|
-
|
91
|
-
def space
|
92
|
-
<<EOL
|
93
|
-
aaa
|
94
|
-
bbb
|
95
|
-
|
96
|
-
ccc
|
97
|
-
EOL
|
98
|
-
end
|
99
|
-
|
100
|
-
def space2
|
101
|
-
<<EOL
|
102
|
-
aaa
|
103
|
-
bbb
|
104
|
-
|
105
|
-
|
106
|
-
ccc
|
107
|
-
EOL
|
108
|
-
end
|
109
|
-
end
|
data/test/test_reference.rb
DELETED
@@ -1,47 +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 TestRafReference < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@raf = Raf::InlineParser.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_reference_is_reference
|
12
|
-
res = @raf.parse('((<aaa>))')
|
13
|
-
assert_kind_of Raf::Reference, res[0]
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_reference_label_only
|
17
|
-
str = '((<aaa>))'
|
18
|
-
res = @raf.parse(str)
|
19
|
-
assert_kind_of Raf::Reference, res[0]
|
20
|
-
assert_equal "aaa", res[0].contents[0] # title
|
21
|
-
assert_equal "#" + "aaa".to_code, res[0].contents[1] # label
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_reference_title_and_label
|
25
|
-
str = '((<aaa|hoge>))'
|
26
|
-
res = @raf.parse(str)
|
27
|
-
assert_kind_of Raf::Reference, res[0]
|
28
|
-
assert_equal "aaa", res[0].contents[0] # title
|
29
|
-
assert_equal "#" + "hoge".to_code, res[0].contents[1] # label
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_reference_uri_only
|
33
|
-
str = '((<http://example.com>))'
|
34
|
-
res = @raf.parse(str)
|
35
|
-
assert_kind_of Raf::Reference, res[0]
|
36
|
-
assert_equal "http://example.com", res[0].contents[0] # title
|
37
|
-
assert_equal "http://example.com", res[0].contents[1] # label
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_reference_title_and_uri
|
41
|
-
str = '((<aaa|http://example.com>))'
|
42
|
-
res = @raf.parse(str)
|
43
|
-
assert_kind_of Raf::Reference, res[0]
|
44
|
-
assert_equal "aaa", res[0].contents[0] # title
|
45
|
-
assert_equal "http://example.com", res[0].contents[1] # label
|
46
|
-
end
|
47
|
-
end
|
data/test/test_ruby.rb
DELETED
@@ -1,66 +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 TestRafRuby < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@raf = Raf::InlineParser.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_ruby_is_ruby
|
12
|
-
str = '((^AAA|aaa^))'
|
13
|
-
res = @raf.parse(str)
|
14
|
-
assert_kind_of Raf::Ruby, res[0]
|
15
|
-
assert_equal ["AAA","aaa"], res[0].contents
|
16
|
-
assert_equal '<Ruby>Base:AAA,Text:aaa</Ruby>', res[0].apply
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_ruby_base_only
|
20
|
-
str = '((^AAA|^))'
|
21
|
-
res = @raf.parse(str)
|
22
|
-
assert_kind_of Raf::Ruby, res[0]
|
23
|
-
assert_equal '<Ruby>Base:AAA,Text:</Ruby>', res[0].apply
|
24
|
-
|
25
|
-
str2 = '((^AAA^))'
|
26
|
-
res = @raf.parse(str2)
|
27
|
-
assert_kind_of Raf::Ruby, res[0]
|
28
|
-
assert_equal '<Ruby>Base:AAA,Text:AAA</Ruby>', res[0].apply
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_ruby_text_only
|
32
|
-
str = '((^|aaa^))'
|
33
|
-
res = @raf.parse(str)
|
34
|
-
assert_kind_of Raf::Ruby, res[0]
|
35
|
-
assert_equal '<Ruby>Base:,Text:aaa</Ruby>', res[0].apply
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_ruby_in_element
|
39
|
-
str1 = '((^((*AAA*))|aaa^))'
|
40
|
-
res = @raf.parse(str1)
|
41
|
-
assert_equal '<Ruby>Base:((*AAA*)),Text:aaa</Ruby>', res[0].apply
|
42
|
-
|
43
|
-
str2 = '((*aaa|((^AAA|bbb^))*))'
|
44
|
-
res = @raf.parse(str2)
|
45
|
-
assert_equal '<Emphasis>aaa|<Ruby>Base:AAA,Text:bbb</Ruby></Emphasis>', res[0].apply
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_emphasis_raise_non_terminate
|
49
|
-
str = '((^aaa))'
|
50
|
-
assert_raise Racc::ParseError do
|
51
|
-
@raf.parse(str)
|
52
|
-
end
|
53
|
-
|
54
|
-
str = '((^aaa'
|
55
|
-
assert_raise Racc::ParseError do
|
56
|
-
@raf.parse(str)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_emphasis_raise_different_terminate
|
61
|
-
str = '((^aaa-))'
|
62
|
-
assert_raise Racc::ParseError do
|
63
|
-
@raf.parse(str)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|