review 3.1.0 → 3.2.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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +11 -1
  3. data/.travis.yml +16 -15
  4. data/NEWS.ja.md +75 -0
  5. data/NEWS.md +75 -0
  6. data/appveyor.yml +20 -2
  7. data/bin/review-catalog-converter +3 -3
  8. data/bin/review-check +3 -3
  9. data/bin/review-compile +6 -6
  10. data/bin/review-epubmaker +3 -35
  11. data/bin/review-index +5 -5
  12. data/bin/review-preproc +4 -4
  13. data/bin/review-vol +5 -5
  14. data/doc/format.ja.md +6 -4
  15. data/doc/format.md +3 -1
  16. data/lib/epubmaker/epubcommon.rb +1 -2
  17. data/lib/epubmaker/epubv2.rb +1 -1
  18. data/lib/epubmaker/epubv3.rb +1 -0
  19. data/lib/epubmaker/producer.rb +2 -1
  20. data/lib/review/book/base.rb +5 -5
  21. data/lib/review/book/index.rb +18 -5
  22. data/lib/review/builder.rb +8 -2
  23. data/lib/review/compiler.rb +11 -34
  24. data/lib/review/epub2html.rb +37 -4
  25. data/lib/review/epubmaker.rb +40 -3
  26. data/lib/review/htmlbuilder.rb +2 -2
  27. data/lib/review/idgxmlbuilder.rb +9 -8
  28. data/lib/review/init.rb +7 -7
  29. data/lib/review/latexbuilder.rb +36 -14
  30. data/lib/review/location.rb +32 -0
  31. data/lib/review/markdownbuilder.rb +8 -1
  32. data/lib/review/plaintextbuilder.rb +9 -9
  33. data/lib/review/preprocessor.rb +2 -24
  34. data/lib/review/topbuilder.rb +4 -4
  35. data/lib/review/update.rb +3 -3
  36. data/lib/review/version.rb +1 -1
  37. data/lib/review/yamlloader.rb +23 -16
  38. data/review.gemspec +3 -2
  39. data/templates/latex/config.erb +4 -0
  40. data/templates/latex/review-jlreq/review-base.sty +45 -22
  41. data/templates/latex/review-jsbook/review-base.sty +20 -15
  42. data/templates/latex/review-jsbook/review-jsbook.cls +3 -3
  43. data/templates/opf/epubv3.opf.erb +1 -0
  44. data/test/assets/test_template.tex +4 -0
  45. data/test/assets/test_template_backmatter.tex +4 -0
  46. data/test/test_book.rb +1 -1
  47. data/test/test_builder.rb +16 -0
  48. data/test/test_catalog.rb +5 -0
  49. data/test/test_htmlbuilder.rb +471 -96
  50. data/test/test_idgxmlbuilder.rb +132 -17
  51. data/test/test_index.rb +40 -0
  52. data/test/test_latexbuilder.rb +668 -72
  53. data/test/test_latexbuilder_v2.rb +597 -68
  54. data/test/test_markdownbuilder.rb +90 -13
  55. data/test/test_md2inaobuilder.rb +20 -7
  56. data/test/test_plaintextbuilder.rb +241 -19
  57. data/test/test_preprocessor.rb +2 -16
  58. data/test/test_rstbuilder.rb +216 -22
  59. data/test/test_topbuilder.rb +334 -22
  60. metadata +20 -6
@@ -2,22 +2,8 @@ require 'test_helper'
2
2
  require 'review/preprocessor'
3
3
  require 'stringio'
4
4
 
5
- class PreprocessorStripTest < Test::Unit::TestCase
5
+ class PreprocessorTest < Test::Unit::TestCase
6
6
  include ReVIEW
7
7
 
8
- def test_gets
9
- f = StringIO.new '= Header'
10
- s = Preprocessor::Strip.new(f)
11
- expect = '= Header'
12
- actual = s.gets
13
- assert_equal expect, actual
14
- end
15
-
16
- def test_gets_with_comment
17
- f = StringIO.new '#@warn(write it later)'
18
- s = Preprocessor::Strip.new(f)
19
- expect = '#@#' + "\n"
20
- actual = s.gets
21
- assert_equal expect, actual
22
- end
8
+ ## TODO: add tests
23
9
  end
@@ -30,29 +30,66 @@ class RSTBuidlerTest < Test::Unit::TestCase
30
30
 
31
31
  def test_headline_level1
32
32
  actual = compile_block("={test} this is test.\n")
33
- assert_equal %Q(.. _test:\n\n==========================\nthis is test.\n==========================\n\n), actual
33
+ expected = <<-EOS
34
+ .. _test:
35
+
36
+ ==========================
37
+ this is test.
38
+ ==========================
39
+
40
+ EOS
41
+ assert_equal expected, actual
34
42
  end
35
43
 
36
44
  def test_headline_level1_without_secno
37
45
  @config['secnolevel'] = 0
38
46
  actual = compile_block("={test} this is test.\n")
39
- assert_equal %Q(.. _test:\n\n==========================\nthis is test.\n==========================\n\n), actual
47
+ expected = <<-EOS
48
+ .. _test:
49
+
50
+ ==========================
51
+ this is test.
52
+ ==========================
53
+
54
+ EOS
55
+ assert_equal expected, actual
40
56
  end
41
57
 
42
58
  def test_headline_level2
43
59
  actual = compile_block("=={test} this is test.\n")
44
- assert_equal %Q(.. _test:\n\nthis is test.\n==========================\n\n), actual
60
+ expected = <<-EOS
61
+ .. _test:
62
+
63
+ this is test.
64
+ ==========================
65
+
66
+ EOS
67
+ assert_equal expected, actual
45
68
  end
46
69
 
47
70
  def test_headline_level3
48
71
  actual = compile_block("==={test} this is test.\n")
49
- assert_equal %Q(.. _test:\n\nthis is test.\n--------------------------\n\n), actual
72
+ expected = <<-EOS
73
+ .. _test:
74
+
75
+ this is test.
76
+ --------------------------
77
+
78
+ EOS
79
+ assert_equal expected, actual
50
80
  end
51
81
 
52
82
  def test_headline_level3_with_secno
53
83
  @config['secnolevel'] = 3
54
84
  actual = compile_block("==={test} this is test.\n")
55
- assert_equal %Q(.. _test:\n\nthis is test.\n--------------------------\n\n), actual
85
+ expected = <<-EOS
86
+ .. _test:
87
+
88
+ this is test.
89
+ --------------------------
90
+
91
+ EOS
92
+ assert_equal expected, actual
56
93
  end
57
94
 
58
95
  def test_href
@@ -143,12 +180,28 @@ class RSTBuidlerTest < Test::Unit::TestCase
143
180
 
144
181
  def test_inline_in_table
145
182
  actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
146
- assert_equal %Q( * - ★1☆\n - ▲2☆\n * - ★3☆\n - ▲4☆<>&\n\n), actual
183
+ expected = <<-EOS
184
+ * - ★1☆
185
+ - ▲2☆
186
+ * - ★3☆
187
+ - ▲4☆<>&
188
+
189
+ EOS
190
+ assert_equal expected, actual
147
191
  end
148
192
 
149
193
  def test_emtable
150
194
  actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
151
- assert_equal %Q(.. list-table:: foo\n :header-rows: 1\n\n * - A\n\n * - A\n\n), actual
195
+ expected = <<-EOS
196
+ .. list-table:: foo
197
+ :header-rows: 1
198
+
199
+ * - A
200
+
201
+ * - A
202
+
203
+ EOS
204
+ assert_equal expected, actual
152
205
  end
153
206
 
154
207
  def test_paragraph
@@ -163,12 +216,25 @@ class RSTBuidlerTest < Test::Unit::TestCase
163
216
 
164
217
  def test_flushright
165
218
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
166
- assert_equal %Q(.. flushright::\n\n foobar\nbuz\n\n), actual
219
+ expected = <<-EOS
220
+ .. flushright::
221
+
222
+ foobar
223
+ buz
224
+
225
+ EOS
226
+ assert_equal expected, actual
167
227
  end
168
228
 
169
229
  def test_noindent
170
230
  actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
171
- assert_equal %Q(foobar\n\nfoo2bar2\n\n), actual
231
+ expected = <<-EOS
232
+ foobar
233
+
234
+ foo2bar2
235
+
236
+ EOS
237
+ assert_equal expected, actual
172
238
  end
173
239
 
174
240
  def test_comment
@@ -187,7 +253,13 @@ class RSTBuidlerTest < Test::Unit::TestCase
187
253
  Book::ListIndex::Item.new('test', 1)
188
254
  end
189
255
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
190
- assert_equal %Q(.. _samplelist:\n\n-foo\n-bar\n), actual
256
+ expected = <<-EOS
257
+ .. _samplelist:
258
+
259
+ -foo
260
+ -bar
261
+ EOS
262
+ assert_equal expected, actual
191
263
  end
192
264
 
193
265
  def test_listnum
@@ -195,45 +267,150 @@ class RSTBuidlerTest < Test::Unit::TestCase
195
267
  Book::ListIndex::Item.new('test', 1)
196
268
  end
197
269
  actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
198
- assert_equal %Q(.. _test:\n\n1\n2\n\n), actual
270
+ expected = <<-EOS
271
+ .. _test:
272
+
273
+ 1
274
+ 2
275
+
276
+ EOS
277
+ assert_equal expected, actual
199
278
  end
200
279
 
201
280
  def test_emlistnum
202
281
  actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
203
- assert_equal %Q(this is @<b>{test}<&>_\n\n.. code-block:: none\n :linenos:\n\n foo\n bar\n\n), actual
282
+ expected = <<-EOS
283
+ this is @<b>{test}<&>_
284
+
285
+ .. code-block:: none
286
+ :linenos:
287
+
288
+ foo
289
+ bar
290
+
291
+ EOS
292
+ assert_equal expected, actual
204
293
  end
205
294
 
206
295
  def test_major_blocks
207
296
  actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
208
- expected = %Q(.. note::\n\n A\nB\n\n.. note::\n\n caption\n A\n\n)
297
+ expected = <<-EOS
298
+ .. note::
299
+
300
+ A
301
+ B
302
+
303
+ .. note::
304
+
305
+ caption
306
+ A
307
+
308
+ EOS
209
309
  assert_equal expected, actual
210
310
 
211
311
  actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
212
- expected = %Q(.. memo::\n\n A\nB\n\n.. memo::\n\n caption\n A\n\n)
312
+ expected = <<-EOS
313
+ .. memo::
314
+
315
+ A
316
+ B
317
+
318
+ .. memo::
319
+
320
+ caption
321
+ A
322
+
323
+ EOS
213
324
  assert_equal expected, actual
214
325
 
215
326
  actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
216
- expected = %Q(.. info::\n\n A\nB\n\n.. info::\n\n caption\n A\n\n)
327
+ expected = <<-EOS
328
+ .. info::
329
+
330
+ A
331
+ B
332
+
333
+ .. info::
334
+
335
+ caption
336
+ A
337
+
338
+ EOS
217
339
  assert_equal expected, actual
218
340
 
219
341
  actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
220
- expected = %Q(.. important::\n\n A\nB\n\n.. important::\n\n caption\n A\n\n)
342
+ expected = <<-EOS
343
+ .. important::
344
+
345
+ A
346
+ B
347
+
348
+ .. important::
349
+
350
+ caption
351
+ A
352
+
353
+ EOS
221
354
  assert_equal expected, actual
222
355
 
223
356
  actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
224
- expected = %Q(.. caution::\n\n A\nB\n\n.. caution::\n\n caption\n A\n\n)
357
+ expected = <<-EOS
358
+ .. caution::
359
+
360
+ A
361
+ B
362
+
363
+ .. caution::
364
+
365
+ caption
366
+ A
367
+
368
+ EOS
225
369
  assert_equal expected, actual
226
370
 
227
371
  actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
228
- expected = %Q(.. notice::\n\n A\nB\n\n.. notice::\n\n caption\n A\n\n)
372
+ expected = <<-EOS
373
+ .. notice::
374
+
375
+ A
376
+ B
377
+
378
+ .. notice::
379
+
380
+ caption
381
+ A
382
+
383
+ EOS
229
384
  assert_equal expected, actual
230
385
 
231
386
  actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
232
- expected = %Q(.. warning::\n\n A\nB\n\n.. warning::\n\n caption\n A\n\n)
387
+ expected = <<-EOS
388
+ .. warning::
389
+
390
+ A
391
+ B
392
+
393
+ .. warning::
394
+
395
+ caption
396
+ A
397
+
398
+ EOS
233
399
  assert_equal expected, actual
234
400
 
235
401
  actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
236
- expected = %Q(.. tip::\n\n A\nB\n\n.. tip::\n\n caption\n A\n\n)
402
+ expected = <<-EOS
403
+ .. tip::
404
+
405
+ A
406
+ B
407
+
408
+ .. tip::
409
+
410
+ caption
411
+ A
412
+
413
+ EOS
237
414
  assert_equal expected, actual
238
415
  end
239
416
 
@@ -245,7 +422,15 @@ class RSTBuidlerTest < Test::Unit::TestCase
245
422
  end
246
423
 
247
424
  actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
248
- assert_equal %Q(.. _sampleimg:\n\n.. figure:: images/-/sampleimg.png\n\n sample photo\n\n), actual
425
+ expected = <<-EOS
426
+ .. _sampleimg:
427
+
428
+ .. figure:: images/-/sampleimg.png
429
+
430
+ sample photo
431
+
432
+ EOS
433
+ assert_equal expected, actual
249
434
  end
250
435
 
251
436
  def test_image_with_metric
@@ -256,7 +441,16 @@ class RSTBuidlerTest < Test::Unit::TestCase
256
441
  end
257
442
 
258
443
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\nfoo\n//}\n")
259
- assert_equal %Q(.. _sampleimg:\n\n.. figure:: images/-/sampleimg.png\n :scale:120.0%\n\n sample photo\n\n), actual
444
+ expected = <<-EOS
445
+ .. _sampleimg:
446
+
447
+ .. figure:: images/-/sampleimg.png
448
+ :scale:120.0%
449
+
450
+ sample photo
451
+
452
+ EOS
453
+ assert_equal expected, actual
260
454
  end
261
455
 
262
456
  def test_texequation
@@ -142,12 +142,36 @@ class TOPBuidlerTest < Test::Unit::TestCase
142
142
 
143
143
  def test_inline_in_table
144
144
  actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
145
- assert_equal %Q(◆→開始:表←◆\n★★1☆☆\t★▲2☆☆\n★3☆\t▲4☆<>&\n◆→終了:表←◆\n\n), actual
145
+ expected = <<-EOS
146
+ ◆→開始:表←◆
147
+ ★★1☆☆\t★▲2☆☆
148
+ ★3☆\t▲4☆<>&
149
+ ◆→終了:表←◆
150
+
151
+ EOS
152
+ assert_equal expected, actual
146
153
  end
147
154
 
148
155
  def test_dlist_beforeulol
149
156
  actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
150
- assert_equal %Q(★foo☆\n\tfoo.\n\npara\n\n★foo☆\n\tfoo.\n\n1\tbar\n\n★foo☆\n\tfoo.\n\n●\tbar\n\n), actual
157
+ expected = <<-EOS
158
+ ★foo☆
159
+ \tfoo.
160
+
161
+ para
162
+
163
+ ★foo☆
164
+ \tfoo.
165
+
166
+ 1\tbar
167
+
168
+ ★foo☆
169
+ \tfoo.
170
+
171
+ ●\tbar
172
+
173
+ EOS
174
+ assert_equal expected, actual
151
175
  end
152
176
 
153
177
  def test_paragraph
@@ -162,7 +186,14 @@ class TOPBuidlerTest < Test::Unit::TestCase
162
186
 
163
187
  def test_flushright
164
188
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
165
- assert_equal %Q(◆→開始:右寄せ←◆\nfoobar\nbuz\n◆→終了:右寄せ←◆\n\n), actual
189
+ expected = <<-EOS
190
+ ◆→開始:右寄せ←◆
191
+ foobar
192
+ buz
193
+ ◆→終了:右寄せ←◆
194
+
195
+ EOS
196
+ assert_equal expected, actual
166
197
  end
167
198
 
168
199
  def test_blankline
@@ -172,7 +203,12 @@ class TOPBuidlerTest < Test::Unit::TestCase
172
203
 
173
204
  def test_noindent
174
205
  actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
175
- assert_equal %Q(◆→DTP連絡:次の1行インデントなし←◆\nfoobar\nfoo2bar2\n), actual
206
+ expected = <<-EOS
207
+ ◆→DTP連絡:次の1行インデントなし←◆
208
+ foobar
209
+ foo2bar2
210
+ EOS
211
+ assert_equal expected, actual
176
212
  end
177
213
 
178
214
  def test_comment
@@ -193,7 +229,16 @@ class TOPBuidlerTest < Test::Unit::TestCase
193
229
  Book::ListIndex::Item.new('test', 1)
194
230
  end
195
231
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
196
- assert_equal %Q(◆→開始:リスト←◆\nリスト1.1 this is ★test☆<&>_\n\nfoo\nbar\n◆→終了:リスト←◆\n\n), actual
232
+ expected = <<-EOS
233
+ ◆→開始:リスト←◆
234
+ リスト1.1 this is ★test☆<&>_
235
+
236
+ foo
237
+ bar
238
+ ◆→終了:リスト←◆
239
+
240
+ EOS
241
+ assert_equal expected, actual
197
242
  end
198
243
 
199
244
  def test_listnum
@@ -201,12 +246,129 @@ class TOPBuidlerTest < Test::Unit::TestCase
201
246
  Book::ListIndex::Item.new('test', 1)
202
247
  end
203
248
  actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
204
- assert_equal %Q(◆→開始:リスト←◆\nリスト1.1 this is ★test☆<&>_\n\n 1: foo\n 2: bar\n◆→終了:リスト←◆\n\n), actual
249
+ expected = <<-EOS
250
+ ◆→開始:リスト←◆
251
+ リスト1.1 this is ★test☆<&>_
252
+
253
+ 1: foo
254
+ 2: bar
255
+ ◆→終了:リスト←◆
256
+
257
+ EOS
258
+ assert_equal expected, actual
259
+ end
260
+
261
+ def test_source
262
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
263
+ expected = <<-EOS
264
+ ◆→開始:ソースコードリスト←◆
265
+ ■foo/bar/test.rb
266
+ foo
267
+ bar
268
+
269
+ buz
270
+ ◆→終了:ソースコードリスト←◆
271
+
272
+ EOS
273
+ assert_equal expected, actual
274
+ end
275
+
276
+ def test_source_empty_caption
277
+ actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
278
+ expected = <<-EOS
279
+ ◆→開始:ソースコードリスト←◆
280
+ foo
281
+ bar
282
+
283
+ buz
284
+ ◆→終了:ソースコードリスト←◆
285
+
286
+ EOS
287
+ assert_equal expected, actual
288
+ end
289
+
290
+ def test_box
291
+ actual = compile_block("//box{\nfoo\nbar\n//}\n")
292
+ expected = <<-EOS
293
+ ◆→開始:書式←◆
294
+ foo
295
+ bar
296
+ ◆→終了:書式←◆
297
+
298
+ EOS
299
+ assert_equal expected, actual
300
+
301
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
302
+ expected = <<-EOS
303
+ ◆→開始:書式←◆
304
+ ■FOO
305
+ foo
306
+ bar
307
+ ◆→終了:書式←◆
308
+
309
+ EOS
310
+ assert_equal expected, actual
311
+ end
312
+
313
+ def test_cmd
314
+ actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
315
+ expected = <<-EOS
316
+ ◆→開始:コマンド←◆
317
+ lineA
318
+ lineB
319
+ ◆→終了:コマンド←◆
320
+
321
+ EOS
322
+ assert_equal expected, actual
323
+
324
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
325
+ expected = <<-EOS
326
+ ◆→開始:コマンド←◆
327
+ ■cap1
328
+ lineA
329
+ lineB
330
+ ◆→終了:コマンド←◆
331
+
332
+ EOS
333
+ assert_equal expected, actual
334
+ end
335
+
336
+ def test_emlist
337
+ actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
338
+ expected = <<-EOS
339
+ ◆→開始:インラインリスト←◆
340
+ lineA
341
+ lineB
342
+ ◆→終了:インラインリスト←◆
343
+
344
+ EOS
345
+ assert_equal expected, actual
346
+ end
347
+
348
+ def test_emlist_caption
349
+ actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
350
+ expected = <<-EOS
351
+ ◆→開始:インラインリスト←◆
352
+ ■cap1
353
+ lineA
354
+ lineB
355
+ ◆→終了:インラインリスト←◆
356
+
357
+ EOS
358
+ assert_equal expected, actual
205
359
  end
206
360
 
207
361
  def test_emlistnum
208
362
  actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
209
- assert_equal %Q(◆→開始:インラインリスト←◆\n■this is ★test☆<&>_\n 1: foo\n 2: bar\n◆→終了:インラインリスト←◆\n\n), actual
363
+ expected = <<-EOS
364
+ ◆→開始:インラインリスト←◆
365
+ ■this is ★test☆<&>_
366
+ 1: foo
367
+ 2: bar
368
+ ◆→終了:インラインリスト←◆
369
+
370
+ EOS
371
+ assert_equal expected, actual
210
372
  end
211
373
 
212
374
  def test_bib
@@ -219,8 +381,34 @@ class TOPBuidlerTest < Test::Unit::TestCase
219
381
 
220
382
  def test_table
221
383
  actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
222
- assert_equal %Q(◆→開始:表←◆\n★aaa☆\t★bbb☆\nccc\tddd<>&\n◆→終了:表←◆\n\n),
223
- actual
384
+ expected = <<-EOS
385
+ ◆→開始:表←◆
386
+ ★aaa☆\t★bbb☆
387
+ ccc\tddd<>&
388
+ ◆→終了:表←◆
389
+
390
+ EOS
391
+ assert_equal expected, actual
392
+
393
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
394
+ expected = <<-EOS
395
+ ◆→開始:表←◆
396
+ 表1.1 FOO
397
+
398
+ ★aaa☆\t★bbb☆
399
+ ccc\tddd<>&
400
+ ◆→終了:表←◆
401
+
402
+ EOS
403
+ assert_equal expected, actual
404
+ end
405
+
406
+ def test_empty_table
407
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
408
+ assert_equal ':2: error: no rows in the table', e.message
409
+
410
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
411
+ assert_equal ':3: error: no rows in the table', e.message
224
412
  end
225
413
 
226
414
  def test_inline_table
@@ -233,41 +421,142 @@ class TOPBuidlerTest < Test::Unit::TestCase
233
421
 
234
422
  def test_emtable
235
423
  actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
236
- assert_equal %Q(◆→開始:表←◆\nfoo\n\n★aaa☆\t★bbb☆\nccc\tddd<>&\n◆→終了:表←◆\n\n◆→開始:表←◆\n★aaa☆\t★bbb☆\nccc\tddd<>&\n◆→終了:表←◆\n\n),
237
- actual
424
+ expected = <<-EOS
425
+ ◆→開始:表←◆
426
+ foo
427
+
428
+ ★aaa☆\t★bbb☆
429
+ ccc\tddd<>&
430
+ ◆→終了:表←◆
431
+
432
+ ◆→開始:表←◆
433
+ ★aaa☆\t★bbb☆
434
+ ccc\tddd<>&
435
+ ◆→終了:表←◆
436
+
437
+ EOS
438
+ assert_equal expected, actual
238
439
  end
239
440
 
240
441
  def test_major_blocks
241
442
  actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
242
- expected = %Q(◆→開始:ノート←◆\nA\nB\n◆→終了:ノート←◆\n\n◆→開始:ノート←◆\n■caption\nA\n◆→終了:ノート←◆\n\n)
443
+ expected = <<-EOS
444
+ ◆→開始:ノート←◆
445
+ A
446
+ B
447
+ ◆→終了:ノート←◆
448
+
449
+ ◆→開始:ノート←◆
450
+ ■caption
451
+ A
452
+ ◆→終了:ノート←◆
453
+
454
+ EOS
243
455
  assert_equal expected, actual
244
456
 
245
457
  actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
246
- expected = %Q(◆→開始:メモ←◆\nA\nB\n◆→終了:メモ←◆\n\n◆→開始:メモ←◆\n■caption\nA\n◆→終了:メモ←◆\n\n)
458
+ expected = <<-EOS
459
+ ◆→開始:メモ←◆
460
+ A
461
+ B
462
+ ◆→終了:メモ←◆
463
+
464
+ ◆→開始:メモ←◆
465
+ ■caption
466
+ A
467
+ ◆→終了:メモ←◆
468
+
469
+ EOS
247
470
  assert_equal expected, actual
248
471
 
249
472
  actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
250
- expected = %Q(◆→開始:情報←◆\nA\nB\n◆→終了:情報←◆\n\n◆→開始:情報←◆\n■caption\nA\n◆→終了:情報←◆\n\n)
473
+ expected = <<-EOS
474
+ ◆→開始:情報←◆
475
+ A
476
+ B
477
+ ◆→終了:情報←◆
478
+
479
+ ◆→開始:情報←◆
480
+ ■caption
481
+ A
482
+ ◆→終了:情報←◆
483
+
484
+ EOS
251
485
  assert_equal expected, actual
252
486
 
253
487
  actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
254
- expected = %Q(◆→開始:重要←◆\nA\nB\n◆→終了:重要←◆\n\n◆→開始:重要←◆\n■caption\nA\n◆→終了:重要←◆\n\n)
488
+ expected = <<-EOS
489
+ ◆→開始:重要←◆
490
+ A
491
+ B
492
+ ◆→終了:重要←◆
493
+
494
+ ◆→開始:重要←◆
495
+ ■caption
496
+ A
497
+ ◆→終了:重要←◆
498
+
499
+ EOS
255
500
  assert_equal expected, actual
256
501
 
257
502
  actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
258
- expected = %Q(◆→開始:警告←◆\nA\nB\n◆→終了:警告←◆\n\n◆→開始:警告←◆\n■caption\nA\n◆→終了:警告←◆\n\n)
503
+ expected = <<-EOS
504
+ ◆→開始:警告←◆
505
+ A
506
+ B
507
+ ◆→終了:警告←◆
508
+
509
+ ◆→開始:警告←◆
510
+ ■caption
511
+ A
512
+ ◆→終了:警告←◆
513
+
514
+ EOS
259
515
  assert_equal expected, actual
260
516
 
261
517
  actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
262
- expected = %Q(◆→開始:注意←◆\nA\nB\n◆→終了:注意←◆\n\n◆→開始:注意←◆\n■caption\nA\n◆→終了:注意←◆\n\n)
518
+ expected = <<-EOS
519
+ ◆→開始:注意←◆
520
+ A
521
+ B
522
+ ◆→終了:注意←◆
523
+
524
+ ◆→開始:注意←◆
525
+ ■caption
526
+ A
527
+ ◆→終了:注意←◆
528
+
529
+ EOS
263
530
  assert_equal expected, actual
264
531
 
265
532
  actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
266
- expected = %Q(◆→開始:危険←◆\nA\nB\n◆→終了:危険←◆\n\n◆→開始:危険←◆\n■caption\nA\n◆→終了:危険←◆\n\n)
533
+ expected = <<-EOS
534
+ ◆→開始:危険←◆
535
+ A
536
+ B
537
+ ◆→終了:危険←◆
538
+
539
+ ◆→開始:危険←◆
540
+ ■caption
541
+ A
542
+ ◆→終了:危険←◆
543
+
544
+ EOS
267
545
  assert_equal expected, actual
268
546
 
269
547
  actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
270
- expected = %Q(◆→開始:TIP←◆\nA\nB\n◆→終了:TIP←◆\n\n◆→開始:TIP←◆\n■caption\nA\n◆→終了:TIP←◆\n\n)
548
+ expected = <<-EOS
549
+ ◆→開始:TIP←◆
550
+ A
551
+ B
552
+ ◆→終了:TIP←◆
553
+
554
+ ◆→開始:TIP←◆
555
+ ■caption
556
+ A
557
+ ◆→終了:TIP←◆
558
+
559
+ EOS
271
560
  assert_equal expected, actual
272
561
  end
273
562
 
@@ -279,7 +568,15 @@ class TOPBuidlerTest < Test::Unit::TestCase
279
568
  end
280
569
 
281
570
  actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
282
- assert_equal %Q(◆→開始:図←◆\n図1.1 sample photo\n\n◆→./images/chap1-sampleimg.png←◆\n◆→終了:図←◆\n\n), actual
571
+ expected = <<-EOS
572
+ ◆→開始:図←◆
573
+ 図1.1 sample photo
574
+
575
+ ◆→./images/chap1-sampleimg.png←◆
576
+ ◆→終了:図←◆
577
+
578
+ EOS
579
+ assert_equal expected, actual
283
580
  end
284
581
 
285
582
  def test_image_with_metric
@@ -290,12 +587,27 @@ class TOPBuidlerTest < Test::Unit::TestCase
290
587
  end
291
588
 
292
589
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\nfoo\n//}\n")
293
- assert_equal %Q(◆→開始:図←◆\n図1.1 sample photo\n\n◆→./images/chap1-sampleimg.png scale=1.2←◆\n◆→終了:図←◆\n\n), actual
590
+ expected = <<-EOS
591
+ ◆→開始:図←◆
592
+ 図1.1 sample photo
593
+
594
+ ◆→./images/chap1-sampleimg.png scale=1.2←◆
595
+ ◆→終了:図←◆
596
+
597
+ EOS
598
+ assert_equal expected, actual
294
599
  end
295
600
 
296
601
  def test_texequation
297
602
  actual = compile_block("//texequation{\n\\sin\n1^{2}\n//}\n")
298
- assert_equal %Q(◆→開始:TeX式←◆\n\\sin\n1^{2}\n◆→終了:TeX式←◆\n\n), actual
603
+ expected = <<-EOS
604
+ ◆→開始:TeX式←◆
605
+ \\sin
606
+ 1^{2}
607
+ ◆→終了:TeX式←◆
608
+
609
+ EOS
610
+ assert_equal expected, actual
299
611
  end
300
612
 
301
613
  def test_inline_w