review 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -9,10 +9,7 @@ class MARKDOWNBuilderTest < Test::Unit::TestCase
9
9
 
10
10
  def setup
11
11
  @builder = MARKDOWNBuilder.new
12
- @config = {
13
- 'secnolevel' => 2,
14
- 'stylesheet' => nil
15
- }
12
+ @config = ReVIEW::Configure.values
16
13
  @book = Book::Base.new('.')
17
14
  @book.config = @config
18
15
  @compiler = ReVIEW::Compiler.new(@builder)
@@ -23,17 +20,37 @@ class MARKDOWNBuilderTest < Test::Unit::TestCase
23
20
 
24
21
  def test_quote
25
22
  actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
26
- assert_equal %Q(\n> foobar\n> \n> buz\n\n), actual
23
+ expected = <<-EOS
24
+
25
+ > foobar
26
+ >
27
+ > buz
28
+
29
+ EOS
30
+ assert_equal expected, actual
27
31
  end
28
32
 
29
33
  def test_memo
30
34
  actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
31
- assert_equal %Q(<div class="memo">\n<p class="caption">this is **test**<&>_</p>\ntest1\ntest*2*\n</div>\n), actual
35
+ expected = <<-EOS
36
+ <div class="memo">
37
+ <p class="caption">this is **test**<&>_</p>
38
+ test1
39
+ test*2*
40
+ </div>
41
+ EOS
42
+ assert_equal expected, actual
32
43
  end
33
44
 
34
45
  def test_noindent
35
46
  actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
36
- assert_equal %Q(<p class="noindent">foobar</p>\n\nfoo2bar2\n\n), actual
47
+ expected = <<-EOS
48
+ <p class="noindent">foobar</p>
49
+
50
+ foo2bar2
51
+
52
+ EOS
53
+ assert_equal expected, actual
37
54
  end
38
55
 
39
56
  def test_inline_em
@@ -78,23 +95,49 @@ EOS
78
95
 
79
96
  def test_cmd
80
97
  actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
81
- assert_equal "```shell-session\nlineA\nlineB\n```\n", actual
98
+ expected = <<-EOS
99
+ ```shell-session
100
+ lineA
101
+ lineB
102
+ ```
103
+ EOS
104
+ assert_equal expected, actual
82
105
  end
83
106
 
84
107
  def test_dlist
85
108
  actual = compile_block(": foo\n foo.\n bar.\n")
86
- assert_equal %Q(<dl>\n<dt>foo</dt>\n<dd>foo.bar.</dd>\n</dl>\n), actual
109
+ expected = <<-EOS
110
+ <dl>
111
+ <dt>foo</dt>
112
+ <dd>foo.bar.</dd>
113
+ </dl>
114
+ EOS
115
+ assert_equal expected, actual
87
116
  end
88
117
 
89
118
  def test_dlist_with_bracket
90
119
  actual = compile_block(": foo[bar]\n foo.\n bar.\n")
91
- assert_equal %Q(<dl>\n<dt>foo[bar]</dt>\n<dd>foo.bar.</dd>\n</dl>\n), actual
120
+ expected = <<-EOS
121
+ <dl>
122
+ <dt>foo[bar]</dt>
123
+ <dd>foo.bar.</dd>
124
+ </dl>
125
+ EOS
126
+ assert_equal expected, actual
92
127
  end
93
128
 
94
129
  def test_dlist_with_comment
95
130
  source = ": title\n body\n\#@ comment\n\#@ comment\n: title2\n body2\n"
96
131
  actual = compile_block(source)
97
- assert_equal %Q(<dl>\n<dt>title</dt>\n<dd>body</dd>\n<dt>title2</dt>\n<dd>body2</dd>\n</dl>\n), actual
132
+ expected = <<-EOS
133
+ <dl>
134
+ <dt>title</dt>
135
+ <dd>body</dd>
136
+ <dt>title2</dt>
137
+ <dd>body2</dd>
138
+ </dl>
139
+ EOS
140
+ assert_equal expected, actual
98
141
  end
99
142
 
100
143
  def test_comment
@@ -144,6 +187,23 @@ BBB
144
187
  EOS
145
188
  end
146
189
 
190
+ def test_listnum
191
+ def @chapter.list(_id)
192
+ Book::ListIndex::Item.new('test', 1)
193
+ end
194
+ actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n\tbuz\n//}\n")
195
+ expected = <<-EOS
196
+ リスト1.1 this is **test**<&>_
197
+
198
+ ```
199
+ 1: foo
200
+ 2: bar
201
+ 3: buz
202
+ ```
203
+ EOS
204
+ assert_equal expected, actual
205
+ end
206
+
147
207
  def test_emlist_lang
148
208
  actual = compile_block(<<-EOS)
149
209
  //emlist[caption][ruby]{
@@ -166,11 +226,28 @@ BBB
166
226
 
167
227
  def test_table
168
228
  actual = compile_block("//table{\ntestA\ttestB\n------------\ncontentA\tcontentB\n//}\n")
169
- assert_equal "|testA|testB|\n|:--|:--|\n|contentA|contentB|\n\n", actual
229
+ expected = <<-EOS
230
+ |testA|testB|
231
+ |:--|:--|
232
+ |contentA|contentB|
233
+
234
+ EOS
235
+ assert_equal expected, actual
236
+
237
+ actual = compile_block("//table[foo][FOO]{\ntestA\ttestB\n------------\ncontentA\tcontentB\n//}\n")
238
+ expected = <<-EOS
239
+ 表1.1: FOO
240
+
241
+ |testA|testB|
242
+ |:--|:--|
243
+ |contentA|contentB|
244
+
245
+ EOS
246
+ assert_equal expected, actual
170
247
  end
171
248
 
172
249
  def test_ruby
173
250
  actual = compile_block('@<ruby>{謳,うた}い文句')
174
- assert_equal "<ruby><rb>謳</rb><rp>(</rp><rt>うた</rt><rp>)</rp></ruby>い文句\n\n", actual
251
+ assert_equal "<ruby>謳<rp>(</rp><rt>うた</rt><rp>)</rp></ruby>い文句\n\n", actual
175
252
  end
176
253
  end
@@ -9,10 +9,7 @@ class MD2INAOBuilderTest < Test::Unit::TestCase
9
9
 
10
10
  def setup
11
11
  @builder = MD2INAOBuilder.new
12
- @config = {
13
- 'secnolevel' => 2,
14
- 'stylesheet' => nil
15
- }
12
+ @config = ReVIEW::Configure.values
16
13
  @book = Book::Base.new('.')
17
14
  @book.config = @config
18
15
  @compiler = ReVIEW::Compiler.new(@builder)
@@ -24,17 +21,33 @@ class MD2INAOBuilderTest < Test::Unit::TestCase
24
21
 
25
22
  def test_paragraph
26
23
  actual = compile_block('Hello, world!')
27
- assert_equal " Hello, world!\n\n", actual
24
+ expected = <<-EOS
25
+  Hello, world!
26
+
27
+ EOS
28
+ assert_equal expected, actual
28
29
  end
29
30
 
30
31
  def test_cmd
31
32
  actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
32
- assert_equal "!!! cmd\nlineA\nlineB\n\n", actual
33
+ expected = <<-EOS
34
+ !!! cmd
35
+ lineA
36
+ lineB
37
+
38
+ EOS
39
+ assert_equal expected, actual
33
40
  end
34
41
 
35
42
  def test_dlist
36
43
  actual = compile_block(": foo\n foo.\n bar.\n")
37
- assert_equal "<dl>\n<dt>foo</dt>\n<dd>foo.bar.</dd>\n</dl>\n", actual
44
+ expected = <<-EOS
45
+ <dl>
46
+ <dt>foo</dt>
47
+ <dd>foo.bar.</dd>
48
+ </dl>
49
+ EOS
50
+ assert_equal expected, actual
38
51
  end
39
52
 
40
53
  def test_list
@@ -143,12 +143,34 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
143
143
 
144
144
  def test_inline_in_table
145
145
  actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
146
- assert_equal %Q(★1☆\t▲2☆\n★3☆\t▲4☆<>&\n\n), actual
146
+ expected = <<-EOS
147
+ ★1☆\t▲2☆
148
+ ★3☆\t▲4☆<>&
149
+
150
+ EOS
151
+ assert_equal expected, actual
147
152
  end
148
153
 
149
154
  def test_dlist_beforeulol
150
155
  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")
151
- assert_equal %Q(foo\nfoo.\n\npara\n\nfoo\nfoo.\n\n1 bar\n\nfoo\nfoo.\n\nbar\n\n), actual
156
+ expected = <<-EOS
157
+ foo
158
+ foo.
159
+
160
+ para
161
+
162
+ foo
163
+ foo.
164
+
165
+ 1 bar
166
+
167
+ foo
168
+ foo.
169
+
170
+ bar
171
+
172
+ EOS
173
+ assert_equal expected, actual
152
174
  end
153
175
 
154
176
  def test_paragraph
@@ -163,12 +185,21 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
163
185
 
164
186
  def test_flushright
165
187
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
166
- assert_equal %Q(foobar\nbuz\n\n), actual
188
+ expected = <<-EOS
189
+ foobar
190
+ buz
191
+
192
+ EOS
193
+ assert_equal expected, actual
167
194
  end
168
195
 
169
196
  def test_noindent
170
197
  actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
171
- assert_equal %Q(foobar\nfoo2bar2\n), actual
198
+ expected = <<-EOS
199
+ foobar
200
+ foo2bar2
201
+ EOS
202
+ assert_equal expected, actual
172
203
  end
173
204
 
174
205
  def test_comment
@@ -187,7 +218,14 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
187
218
  Book::ListIndex::Item.new('test', 1)
188
219
  end
189
220
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
190
- assert_equal %Q(リスト1.1 this is test<&>_\n\nfoo\nbar\n\n), actual
221
+ expected = <<-EOS
222
+ リスト1.1 this is test<&>_
223
+
224
+ foo
225
+ bar
226
+
227
+ EOS
228
+ assert_equal expected, actual
191
229
  end
192
230
 
193
231
  def test_listnum
@@ -195,12 +233,109 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
195
233
  Book::ListIndex::Item.new('test', 1)
196
234
  end
197
235
  actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
198
- assert_equal %Q(リスト1.1 this is test<&>_\n\n 1: foo\n 2: bar\n\n), actual
236
+ expected = <<-EOS
237
+ リスト1.1 this is test<&>_
238
+
239
+ 1: foo
240
+ 2: bar
241
+
242
+ EOS
243
+ assert_equal expected, actual
244
+ end
245
+
246
+ def test_source
247
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
248
+ expected = <<-EOS
249
+ foo/bar/test.rb
250
+ foo
251
+ bar
252
+
253
+ buz
254
+
255
+ EOS
256
+ assert_equal expected, actual
257
+ end
258
+
259
+ def test_source_empty_caption
260
+ actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
261
+ expected = <<-EOS
262
+ foo
263
+ bar
264
+
265
+ buz
266
+
267
+ EOS
268
+ assert_equal expected, actual
269
+ end
270
+
271
+ def test_box
272
+ actual = compile_block("//box{\nfoo\nbar\n//}\n")
273
+ expected = <<-EOS
274
+ foo
275
+ bar
276
+
277
+ EOS
278
+ assert_equal expected, actual
279
+
280
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
281
+ expected = <<-EOS
282
+ FOO
283
+ foo
284
+ bar
285
+
286
+ EOS
287
+ assert_equal expected, actual
288
+ end
289
+
290
+ def test_cmd
291
+ actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
292
+ expected = <<-EOS
293
+ lineA
294
+ lineB
295
+
296
+ EOS
297
+ assert_equal expected, actual
298
+
299
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
300
+ expected = <<-EOS
301
+ cap1
302
+ lineA
303
+ lineB
304
+
305
+ EOS
306
+ assert_equal expected, actual
307
+ end
308
+
309
+ def test_emlist
310
+ actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
311
+ expected = <<-EOS
312
+ lineA
313
+ lineB
314
+
315
+ EOS
316
+ assert_equal expected, actual
317
+ end
318
+
319
+ def test_emlist_caption
320
+ actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
321
+ expected = <<-EOS
322
+ cap1
323
+ lineA
324
+ lineB
325
+
326
+ EOS
327
+ assert_equal expected, actual
199
328
  end
200
329
 
201
330
  def test_emlistnum
202
331
  actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
203
- assert_equal %Q(this is test<&>_\n 1: foo\n 2: bar\n\n), actual
332
+ expected = <<-EOS
333
+ this is test<&>_
334
+ 1: foo
335
+ 2: bar
336
+
337
+ EOS
338
+ assert_equal expected, actual
204
339
  end
205
340
 
206
341
  def test_bib
@@ -213,8 +348,30 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
213
348
 
214
349
  def test_table
215
350
  actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
216
- assert_equal %Q(aaa\tbbb\nccc\tddd<>&\n\n),
217
- actual
351
+ expected = <<-EOS
352
+ aaa\tbbb
353
+ ccc\tddd<>&
354
+
355
+ EOS
356
+ assert_equal expected, actual
357
+
358
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
359
+ expected = <<-EOS
360
+ 表1.1 FOO
361
+
362
+ aaa\tbbb
363
+ ccc\tddd<>&
364
+
365
+ EOS
366
+ assert_equal expected, actual
367
+ end
368
+
369
+ def test_empty_table
370
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
371
+ assert_equal ':2: error: no rows in the table', e.message
372
+
373
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
374
+ assert_equal ':3: error: no rows in the table', e.message
218
375
  end
219
376
 
220
377
  def test_inline_table
@@ -227,41 +384,106 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
227
384
 
228
385
  def test_emtable
229
386
  actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
230
- assert_equal %Q(foo\n\naaa\tbbb\nccc\tddd<>&\n\naaa\tbbb\nccc\tddd<>&\n\n),
231
- actual
387
+ expected = <<-EOS
388
+ foo
389
+
390
+ aaa\tbbb
391
+ ccc\tddd<>&
392
+
393
+ aaa\tbbb
394
+ ccc\tddd<>&
395
+
396
+ EOS
397
+ assert_equal expected, actual
232
398
  end
233
399
 
234
400
  def test_major_blocks
235
401
  actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
236
- expected = %Q(A\nB\n\ncaption\nA\n\n)
402
+ expected = <<-EOS
403
+ A
404
+ B
405
+
406
+ caption
407
+ A
408
+
409
+ EOS
237
410
  assert_equal expected, actual
238
411
 
239
412
  actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
240
- expected = %Q(A\nB\n\ncaption\nA\n\n)
413
+ expected = <<-EOS
414
+ A
415
+ B
416
+
417
+ caption
418
+ A
419
+
420
+ EOS
241
421
  assert_equal expected, actual
242
422
 
243
423
  actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
244
- expected = %Q(A\nB\n\ncaption\nA\n\n)
424
+ expected = <<-EOS
425
+ A
426
+ B
427
+
428
+ caption
429
+ A
430
+
431
+ EOS
245
432
  assert_equal expected, actual
246
433
 
247
434
  actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
248
- expected = %Q(A\nB\n\ncaption\nA\n\n)
435
+ expected = <<-EOS
436
+ A
437
+ B
438
+
439
+ caption
440
+ A
441
+
442
+ EOS
249
443
  assert_equal expected, actual
250
444
 
251
445
  actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
252
- expected = %Q(A\nB\n\ncaption\nA\n\n)
446
+ expected = <<-EOS
447
+ A
448
+ B
449
+
450
+ caption
451
+ A
452
+
453
+ EOS
253
454
  assert_equal expected, actual
254
455
 
255
456
  actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
256
- expected = %Q(A\nB\n\ncaption\nA\n\n)
457
+ expected = <<-EOS
458
+ A
459
+ B
460
+
461
+ caption
462
+ A
463
+
464
+ EOS
257
465
  assert_equal expected, actual
258
466
 
259
467
  actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
260
- expected = %Q(A\nB\n\ncaption\nA\n\n)
468
+ expected = <<-EOS
469
+ A
470
+ B
471
+
472
+ caption
473
+ A
474
+
475
+ EOS
261
476
  assert_equal expected, actual
262
477
 
263
478
  actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
264
- expected = %Q(A\nB\n\ncaption\nA\n\n)
479
+ expected = <<-EOS
480
+ A
481
+ B
482
+
483
+ caption
484
+ A
485
+
486
+ EOS
265
487
  assert_equal expected, actual
266
488
  end
267
489