review 3.0.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-win.yml +39 -0
  3. data/.github/workflows/ruby.yml +27 -0
  4. data/.rubocop.yml +50 -12
  5. data/.travis.yml +17 -8
  6. data/Dockerfile +21 -5
  7. data/NEWS.ja.md +358 -0
  8. data/NEWS.md +358 -1
  9. data/README.md +11 -8
  10. data/appveyor.yml +1 -3
  11. data/bin/review-catalog-converter +4 -4
  12. data/bin/review-check +8 -8
  13. data/bin/review-checkdep +1 -1
  14. data/bin/review-compile +12 -12
  15. data/bin/review-epubmaker +3 -35
  16. data/bin/review-idgxmlmaker +16 -0
  17. data/bin/review-index +2 -89
  18. data/bin/review-preproc +14 -19
  19. data/bin/review-validate +3 -3
  20. data/bin/review-vol +4 -78
  21. data/doc/LICENSE +1 -1
  22. data/doc/config.yml.sample +46 -12
  23. data/doc/config.yml.sample-simple +4 -2
  24. data/doc/format.ja.md +37 -13
  25. data/doc/format.md +35 -20
  26. data/doc/pdfmaker.ja.md +43 -1
  27. data/doc/pdfmaker.md +42 -1
  28. data/doc/quickstart.ja.md +46 -26
  29. data/doc/quickstart.md +38 -17
  30. data/lib/epubmaker/epubcommon.rb +10 -5
  31. data/lib/epubmaker/epubv2.rb +1 -1
  32. data/lib/epubmaker/epubv3.rb +1 -0
  33. data/lib/epubmaker/producer.rb +4 -2
  34. data/lib/review/book.rb +1 -1
  35. data/lib/review/book/base.rb +38 -79
  36. data/lib/review/book/chapter.rb +18 -3
  37. data/lib/review/book/compilable.rb +6 -5
  38. data/lib/review/book/index.rb +69 -101
  39. data/lib/review/book/index/item.rb +40 -0
  40. data/lib/review/book/page_metric.rb +7 -7
  41. data/lib/review/book/part.rb +28 -5
  42. data/lib/review/book/volume.rb +3 -4
  43. data/lib/review/builder.rb +105 -44
  44. data/lib/review/catalog.rb +13 -16
  45. data/lib/review/compiler.rb +84 -72
  46. data/lib/review/configure.rb +19 -8
  47. data/lib/review/epub2html.rb +37 -4
  48. data/lib/review/epubmaker.rb +62 -7
  49. data/lib/review/extentions/string.rb +0 -4
  50. data/lib/review/htmlbuilder.rb +102 -115
  51. data/lib/review/htmlutils.rb +2 -3
  52. data/lib/review/i18n.rb +2 -2
  53. data/lib/review/i18n.yml +9 -0
  54. data/lib/review/idgxmlbuilder.rb +153 -74
  55. data/lib/review/idgxmlmaker.rb +191 -0
  56. data/lib/review/init-web/finish.html +10 -0
  57. data/lib/review/init-web/index.html +190 -0
  58. data/lib/review/init-web/review-layout-design.js +691 -0
  59. data/lib/review/init.rb +125 -34
  60. data/lib/review/latexbuilder.rb +199 -88
  61. data/lib/review/lineinput.rb +1 -1
  62. data/lib/review/location.rb +32 -0
  63. data/lib/review/logger.rb +4 -8
  64. data/lib/review/makerhelper.rb +24 -5
  65. data/lib/review/markdownbuilder.rb +31 -37
  66. data/lib/review/md2inaobuilder.rb +3 -5
  67. data/lib/review/pdfmaker.rb +44 -22
  68. data/lib/review/plaintextbuilder.rb +106 -85
  69. data/lib/review/preprocessor.rb +32 -41
  70. data/lib/review/rstbuilder.rb +33 -33
  71. data/lib/review/textmaker.rb +19 -3
  72. data/lib/review/textutils.rb +76 -2
  73. data/lib/review/tocprinter.rb +231 -102
  74. data/lib/review/topbuilder.rb +114 -61
  75. data/lib/review/update.rb +19 -19
  76. data/lib/review/version.rb +1 -1
  77. data/lib/review/volumeprinter.rb +99 -0
  78. data/lib/review/webmaker.rb +11 -4
  79. data/lib/review/webtocprinter.rb +38 -35
  80. data/lib/review/yamlloader.rb +26 -16
  81. data/review.gemspec +6 -4
  82. data/samples/sample-book/README.md +7 -2
  83. data/samples/sample-book/src/.gitignore +154 -0
  84. data/samples/sample-book/src/config-ebook.yml +4 -0
  85. data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
  86. data/samples/sample-book/src/config-jlreq.yml +6 -0
  87. data/samples/sample-book/src/config.yml +2 -2
  88. data/samples/sample-book/src/lib/tasks/review.rake +29 -14
  89. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
  90. data/samples/syntax-book/ch01.re +4 -2
  91. data/samples/syntax-book/ch02.re +8 -16
  92. data/samples/syntax-book/ch03.re +3 -6
  93. data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
  94. data/samples/syntax-book/config-jlreq.yml +5 -0
  95. data/samples/syntax-book/config-print.yml +3 -0
  96. data/samples/syntax-book/config.yml +1 -1
  97. data/samples/syntax-book/lib/tasks/review.rake +30 -15
  98. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
  99. data/templates/latex/config.erb +16 -0
  100. data/templates/latex/layout.tex.erb +4 -0
  101. data/templates/latex/review-jlreq/review-base.sty +150 -61
  102. data/templates/latex/review-jlreq/review-jlreq.cls +74 -8
  103. data/templates/latex/review-jlreq/review-style.sty +4 -1
  104. data/templates/latex/review-jsbook/README.md +39 -0
  105. data/templates/latex/review-jsbook/review-base.sty +101 -23
  106. data/templates/latex/review-jsbook/review-jsbook.cls +28 -5
  107. data/templates/latex/review-jsbook/review-style.sty +5 -2
  108. data/templates/opf/epubv3.opf.erb +1 -0
  109. data/templates/web/html/layout-html5.html.erb +2 -2
  110. data/test/assets/test_template.tex +24 -3
  111. data/test/assets/test_template_backmatter.tex +24 -3
  112. data/test/test_book.rb +75 -21
  113. data/test/test_book_chapter.rb +4 -2
  114. data/test/test_book_part.rb +3 -3
  115. data/test/test_builder.rb +16 -0
  116. data/test/test_catalog.rb +24 -42
  117. data/test/test_catalog_converter_cmd.rb +1 -1
  118. data/test/test_epubmaker_cmd.rb +14 -7
  119. data/test/test_helper.rb +15 -7
  120. data/test/test_htmlbuilder.rb +909 -159
  121. data/test/test_i18n.rb +25 -25
  122. data/test/test_idgxmlbuilder.rb +395 -38
  123. data/test/test_idgxmlmaker_cmd.rb +46 -0
  124. data/test/test_image_finder.rb +52 -70
  125. data/test/test_index.rb +50 -10
  126. data/test/test_latexbuilder.rb +1194 -106
  127. data/test/test_latexbuilder_v2.rb +628 -97
  128. data/test/test_logger.rb +14 -1
  129. data/test/test_makerhelper.rb +3 -3
  130. data/test/test_markdownbuilder.rb +134 -16
  131. data/test/test_md2inaobuilder.rb +32 -9
  132. data/test/test_pdfmaker.rb +18 -1
  133. data/test/test_pdfmaker_cmd.rb +100 -6
  134. data/test/test_plaintextbuilder.rb +371 -25
  135. data/test/test_preprocessor.rb +2 -16
  136. data/test/test_rstbuilder.rb +249 -26
  137. data/test/test_textmaker_cmd.rb +54 -0
  138. data/test/test_textutils.rb +109 -2
  139. data/test/test_topbuilder.rb +546 -31
  140. data/test/test_update.rb +17 -8
  141. data/test/test_webtocprinter.rb +66 -34
  142. data/test/test_yamlloader.rb +13 -0
  143. data/vendor/jsclasses/LICENSE +1 -1
  144. data/vendor/jsclasses/jis/jsarticle.cls +53 -14
  145. data/vendor/jsclasses/jis/jsbook.cls +53 -14
  146. data/vendor/jsclasses/jis/jsclasses.dtx +84 -25
  147. data/vendor/jsclasses/jis/jslogo.dtx +4 -4
  148. data/vendor/jsclasses/jis/jslogo.sty +3 -3
  149. data/vendor/jsclasses/jis/jspf.cls +52 -13
  150. data/vendor/jsclasses/jis/jsreport.cls +53 -14
  151. data/vendor/jsclasses/jis/kiyou.cls +53 -14
  152. data/vendor/jsclasses/jis/okumacro.dtx +4 -5
  153. data/vendor/jsclasses/jis/okumacro.sty +3 -4
  154. data/vendor/jsclasses/jsarticle.cls +53 -14
  155. data/vendor/jsclasses/jsbook.cls +53 -14
  156. data/vendor/jsclasses/jsclasses.dtx +84 -25
  157. data/vendor/jsclasses/jsclasses.pdf +0 -0
  158. data/vendor/jsclasses/jslogo.dtx +4 -4
  159. data/vendor/jsclasses/jslogo.pdf +0 -0
  160. data/vendor/jsclasses/jslogo.sty +3 -3
  161. data/vendor/jsclasses/jspf.cls +52 -13
  162. data/vendor/jsclasses/jsreport.cls +53 -14
  163. data/vendor/jsclasses/kiyou.cls +53 -14
  164. data/vendor/jsclasses/okumacro.dtx +4 -5
  165. data/vendor/jsclasses/okumacro.pdf +0 -0
  166. data/vendor/jsclasses/okumacro.sty +3 -4
  167. metadata +55 -10
  168. data/lib/review/tocparser.rb +0 -271
  169. data/samples/syntax-book/review-ext.rb +0 -14
  170. data/test/test_tocparser.rb +0 -25
@@ -143,32 +143,88 @@ 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
155
177
  actual = compile_block("foo\nbar\n")
156
178
  assert_equal %Q(foobar\n), actual
179
+
180
+ @book.config['join_lines_by_lang'] = true
181
+ actual = compile_block("foo\nbar\n")
182
+ assert_equal %Q(foo bar\n), actual
157
183
  end
158
184
 
159
185
  def test_tabbed_paragraph
160
186
  actual = compile_block("\tfoo\nbar\n")
161
187
  assert_equal %Q(\tfoobar\n), actual
188
+
189
+ @book.config['join_lines_by_lang'] = true
190
+ actual = compile_block("\tfoo\nbar\n")
191
+ assert_equal %Q(\tfoo bar\n), actual
162
192
  end
163
193
 
164
194
  def test_flushright
165
195
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
166
- assert_equal %Q(foobar\nbuz\n\n), actual
196
+ expected = <<-EOS
197
+ foobar
198
+ buz
199
+
200
+ EOS
201
+ assert_equal expected, actual
202
+
203
+ @book.config['join_lines_by_lang'] = true
204
+ actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
205
+ expected = <<-EOS
206
+ foo bar
207
+ buz
208
+
209
+ EOS
210
+ assert_equal expected, actual
167
211
  end
168
212
 
169
213
  def test_noindent
170
214
  actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
171
- assert_equal %Q(foobar\nfoo2bar2\n), actual
215
+ expected = <<-EOS
216
+ foobar
217
+ foo2bar2
218
+ EOS
219
+ assert_equal expected, actual
220
+
221
+ @book.config['join_lines_by_lang'] = true
222
+ actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
223
+ expected = <<-EOS
224
+ foo bar
225
+ foo2 bar2
226
+ EOS
227
+ assert_equal expected, actual
172
228
  end
173
229
 
174
230
  def test_comment
@@ -184,28 +240,206 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
184
240
 
185
241
  def test_list
186
242
  def @chapter.list(_id)
187
- Book::ListIndex::Item.new('test', 1)
243
+ Book::Index::Item.new('test', 1)
188
244
  end
189
245
  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
246
+ expected = <<-EOS
247
+ リスト1.1 this is test<&>_
248
+
249
+ foo
250
+ bar
251
+
252
+ EOS
253
+ assert_equal expected, actual
254
+
255
+ @config['caption_position']['list'] = 'bottom'
256
+ actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
257
+ expected = <<-EOS
258
+ foo
259
+ bar
260
+
261
+ リスト1.1 this is test<&>_
262
+
263
+ EOS
264
+ assert_equal expected, actual
191
265
  end
192
266
 
193
267
  def test_listnum
194
268
  def @chapter.list(_id)
195
- Book::ListIndex::Item.new('test', 1)
269
+ Book::Index::Item.new('test', 1)
196
270
  end
197
271
  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
272
+ expected = <<-EOS
273
+ リスト1.1 this is test<&>_
274
+
275
+ 1: foo
276
+ 2: bar
277
+
278
+ EOS
279
+ assert_equal expected, actual
280
+
281
+ @config['caption_position']['list'] = 'bottom'
282
+ actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
283
+ expected = <<-EOS
284
+ 1: foo
285
+ 2: bar
286
+
287
+ リスト1.1 this is test<&>_
288
+
289
+ EOS
290
+ assert_equal expected, actual
291
+ end
292
+
293
+ def test_source
294
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
295
+ expected = <<-EOS
296
+ foo/bar/test.rb
297
+ foo
298
+ bar
299
+
300
+ buz
301
+
302
+ EOS
303
+ assert_equal expected, actual
304
+
305
+ @config['caption_position']['list'] = 'bottom'
306
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
307
+ expected = <<-EOS
308
+ foo
309
+ bar
310
+
311
+ buz
312
+ foo/bar/test.rb
313
+
314
+ EOS
315
+ assert_equal expected, actual
316
+ end
317
+
318
+ def test_source_empty_caption
319
+ actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
320
+ expected = <<-EOS
321
+ foo
322
+ bar
323
+
324
+ buz
325
+
326
+ EOS
327
+ assert_equal expected, actual
328
+ end
329
+
330
+ def test_box
331
+ actual = compile_block("//box{\nfoo\nbar\n//}\n")
332
+ expected = <<-EOS
333
+ foo
334
+ bar
335
+
336
+ EOS
337
+ assert_equal expected, actual
338
+
339
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
340
+ expected = <<-EOS
341
+ FOO
342
+ foo
343
+ bar
344
+
345
+ EOS
346
+ assert_equal expected, actual
347
+
348
+ @config['caption_position']['list'] = 'bottom'
349
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
350
+ expected = <<-EOS
351
+ foo
352
+ bar
353
+ FOO
354
+
355
+ EOS
356
+ assert_equal expected, actual
357
+ end
358
+
359
+ def test_cmd
360
+ actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
361
+ expected = <<-EOS
362
+ lineA
363
+ lineB
364
+
365
+ EOS
366
+ assert_equal expected, actual
367
+
368
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
369
+ expected = <<-EOS
370
+ cap1
371
+ lineA
372
+ lineB
373
+
374
+ EOS
375
+ assert_equal expected, actual
376
+
377
+ @config['caption_position']['list'] = 'bottom'
378
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
379
+ expected = <<-EOS
380
+ lineA
381
+ lineB
382
+ cap1
383
+
384
+ EOS
385
+ assert_equal expected, actual
386
+ end
387
+
388
+ def test_emlist
389
+ actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
390
+ expected = <<-EOS
391
+ lineA
392
+ lineB
393
+
394
+ EOS
395
+ assert_equal expected, actual
396
+ end
397
+
398
+ def test_emlist_caption
399
+ actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
400
+ expected = <<-EOS
401
+ cap1
402
+ lineA
403
+ lineB
404
+
405
+ EOS
406
+ assert_equal expected, actual
407
+
408
+ @config['caption_position']['list'] = 'bottom'
409
+ actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
410
+ expected = <<-EOS
411
+ lineA
412
+ lineB
413
+ cap1
414
+
415
+ EOS
416
+ assert_equal expected, actual
199
417
  end
200
418
 
201
419
  def test_emlistnum
202
420
  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
421
+ expected = <<-EOS
422
+ this is test<&>_
423
+ 1: foo
424
+ 2: bar
425
+
426
+ EOS
427
+ assert_equal expected, actual
428
+
429
+ @config['caption_position']['list'] = 'bottom'
430
+ actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
431
+ expected = <<-EOS
432
+ 1: foo
433
+ 2: bar
434
+ this is test<&>_
435
+
436
+ EOS
437
+ assert_equal expected, actual
204
438
  end
205
439
 
206
440
  def test_bib
207
441
  def @chapter.bibpaper(_id)
208
- Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
442
+ Book::Index::Item.new('samplebib', 1, 'sample bib')
209
443
  end
210
444
 
211
445
  assert_equal '1 ', compile_inline('@<bib>{samplebib}')
@@ -213,13 +447,45 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
213
447
 
214
448
  def test_table
215
449
  actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
216
- assert_equal %Q(aaa\tbbb\nccc\tddd<>&\n\n),
217
- actual
450
+ expected = <<-EOS
451
+ aaa\tbbb
452
+ ccc\tddd<>&
453
+
454
+ EOS
455
+ assert_equal expected, actual
456
+
457
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
458
+ expected = <<-EOS
459
+ 表1.1 FOO
460
+
461
+ aaa\tbbb
462
+ ccc\tddd<>&
463
+
464
+ EOS
465
+ assert_equal expected, actual
466
+
467
+ @config['caption_position']['table'] = 'bottom'
468
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
469
+ expected = <<-EOS
470
+ aaa\tbbb
471
+ ccc\tddd<>&
472
+
473
+ 表1.1 FOO
474
+ EOS
475
+ assert_equal expected, actual
476
+ end
477
+
478
+ def test_empty_table
479
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
480
+ assert_equal ':2: error: no rows in the table', e.message
481
+
482
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
483
+ assert_equal ':3: error: no rows in the table', e.message
218
484
  end
219
485
 
220
486
  def test_inline_table
221
487
  def @chapter.table(_id)
222
- Book::TableIndex::Item.new('sampletable', 1)
488
+ Book::Index::Item.new('sampletable', 1)
223
489
  end
224
490
  actual = compile_block("@<table>{sampletest}\n")
225
491
  assert_equal "表1.1\n", actual
@@ -227,58 +493,127 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
227
493
 
228
494
  def test_emtable
229
495
  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
496
+ expected = <<-EOS
497
+ foo
498
+
499
+ aaa\tbbb
500
+ ccc\tddd<>&
501
+
502
+ aaa\tbbb
503
+ ccc\tddd<>&
504
+
505
+ EOS
506
+ assert_equal expected, actual
232
507
  end
233
508
 
234
509
  def test_major_blocks
235
510
  actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
236
- expected = %Q(A\nB\n\ncaption\nA\n\n)
511
+ expected = <<-EOS
512
+ A
513
+ B
514
+
515
+ caption
516
+ A
517
+
518
+ EOS
237
519
  assert_equal expected, actual
238
520
 
239
521
  actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
240
- expected = %Q(A\nB\n\ncaption\nA\n\n)
522
+ expected = <<-EOS
523
+ A
524
+ B
525
+
526
+ caption
527
+ A
528
+
529
+ EOS
241
530
  assert_equal expected, actual
242
531
 
243
532
  actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
244
- expected = %Q(A\nB\n\ncaption\nA\n\n)
533
+ expected = <<-EOS
534
+ A
535
+ B
536
+
537
+ caption
538
+ A
539
+
540
+ EOS
245
541
  assert_equal expected, actual
246
542
 
247
543
  actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
248
- expected = %Q(A\nB\n\ncaption\nA\n\n)
544
+ expected = <<-EOS
545
+ A
546
+ B
547
+
548
+ caption
549
+ A
550
+
551
+ EOS
249
552
  assert_equal expected, actual
250
553
 
251
554
  actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
252
- expected = %Q(A\nB\n\ncaption\nA\n\n)
555
+ expected = <<-EOS
556
+ A
557
+ B
558
+
559
+ caption
560
+ A
561
+
562
+ EOS
253
563
  assert_equal expected, actual
254
564
 
255
565
  actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
256
- expected = %Q(A\nB\n\ncaption\nA\n\n)
566
+ expected = <<-EOS
567
+ A
568
+ B
569
+
570
+ caption
571
+ A
572
+
573
+ EOS
257
574
  assert_equal expected, actual
258
575
 
259
576
  actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
260
- expected = %Q(A\nB\n\ncaption\nA\n\n)
577
+ expected = <<-EOS
578
+ A
579
+ B
580
+
581
+ caption
582
+ A
583
+
584
+ EOS
261
585
  assert_equal expected, actual
262
586
 
263
587
  actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
264
- expected = %Q(A\nB\n\ncaption\nA\n\n)
588
+ expected = <<-EOS
589
+ A
590
+ B
591
+
592
+ caption
593
+ A
594
+
595
+ EOS
265
596
  assert_equal expected, actual
266
597
  end
267
598
 
268
599
  def test_image
269
600
  def @chapter.image(_id)
270
- item = Book::ImageIndex::Item.new('sampleimg', 1)
601
+ item = Book::Index::Item.new('sampleimg', 1)
271
602
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
272
603
  item
273
604
  end
274
605
 
275
606
  actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
276
607
  assert_equal %Q(図1.1 sample photo\n\n), actual
608
+
609
+ @config['caption_position']['image'] = 'top'
610
+ actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
611
+ assert_equal %Q(図1.1 sample photo\n\n), actual
277
612
  end
278
613
 
279
614
  def test_image_with_metric
280
615
  def @chapter.image(_id)
281
- item = Book::ImageIndex::Item.new('sampleimg', 1)
616
+ item = Book::Index::Item.new('sampleimg', 1)
282
617
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
283
618
  item
284
619
  end
@@ -402,6 +737,17 @@ EOS
402
737
  式1.1 The Equivalence of Mass and Energy
403
738
  e=mc^2
404
739
 
740
+ EOS
741
+ actual = compile_block(src)
742
+ assert_equal expected, actual
743
+
744
+ @config['caption_position']['equation'] = 'bottom'
745
+ expected = <<-EOS
746
+ 式1.1
747
+
748
+ e=mc^2
749
+ 式1.1 The Equivalence of Mass and Energy
750
+
405
751
  EOS
406
752
  actual = compile_block(src)
407
753
  assert_equal expected, actual