review 3.1.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-win.yml +45 -0
  3. data/.github/workflows/ruby.yml +27 -0
  4. data/.rubocop.yml +161 -34
  5. data/.travis.yml +16 -15
  6. data/Dockerfile +21 -5
  7. data/NEWS.ja.md +394 -0
  8. data/NEWS.md +395 -1
  9. data/README.md +10 -7
  10. data/appveyor.yml +1 -3
  11. data/bin/review-catalog-converter +5 -5
  12. data/bin/review-check +10 -12
  13. data/bin/review-checkdep +2 -2
  14. data/bin/review-compile +17 -23
  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 +13 -13
  19. data/bin/review-validate +4 -4
  20. data/bin/review-vol +4 -78
  21. data/doc/config.yml.sample +47 -12
  22. data/doc/config.yml.sample-simple +3 -2
  23. data/doc/format.ja.md +120 -17
  24. data/doc/format.md +119 -27
  25. data/doc/makeindex.ja.md +2 -2
  26. data/doc/pdfmaker.ja.md +43 -1
  27. data/doc/pdfmaker.md +42 -1
  28. data/doc/quickstart.ja.md +45 -25
  29. data/doc/quickstart.md +37 -16
  30. data/lib/epubmaker/content.rb +3 -2
  31. data/lib/epubmaker/epubcommon.rb +34 -27
  32. data/lib/epubmaker/epubv2.rb +5 -6
  33. data/lib/epubmaker/epubv3.rb +21 -18
  34. data/lib/epubmaker/producer.rb +2 -1
  35. data/lib/review/book.rb +2 -2
  36. data/lib/review/book/base.rb +91 -96
  37. data/lib/review/book/bib.rb +21 -0
  38. data/lib/review/book/book_unit.rb +155 -0
  39. data/lib/review/book/chapter.rb +48 -29
  40. data/lib/review/book/index.rb +46 -240
  41. data/lib/review/book/index/item.rb +46 -0
  42. data/lib/review/book/page_metric.rb +7 -7
  43. data/lib/review/book/part.rb +45 -10
  44. data/lib/review/book/volume.rb +4 -5
  45. data/lib/review/builder.rb +172 -56
  46. data/lib/review/catalog.rb +14 -17
  47. data/lib/review/compiler.rb +219 -121
  48. data/lib/review/configure.rb +39 -7
  49. data/lib/review/converter.rb +1 -1
  50. data/lib/review/epub2html.rb +43 -5
  51. data/lib/review/epubmaker.rb +69 -27
  52. data/lib/review/extentions/string.rb +0 -4
  53. data/lib/review/htmlbuilder.rb +112 -101
  54. data/lib/review/htmlutils.rb +9 -13
  55. data/lib/review/i18n.rb +3 -3
  56. data/lib/review/idgxmlbuilder.rb +202 -78
  57. data/lib/review/idgxmlmaker.rb +186 -0
  58. data/lib/review/index_builder.rb +653 -0
  59. data/lib/review/init-web/finish.html +10 -0
  60. data/lib/review/init-web/index.html +190 -0
  61. data/lib/review/init-web/review-layout-design.js +691 -0
  62. data/lib/review/init.rb +129 -46
  63. data/lib/review/latexbuilder.rb +255 -92
  64. data/lib/review/lineinput.rb +1 -1
  65. data/lib/review/location.rb +32 -0
  66. data/lib/review/logger.rb +4 -8
  67. data/lib/review/makerhelper.rb +35 -5
  68. data/lib/review/markdownbuilder.rb +50 -38
  69. data/lib/review/md2inaobuilder.rb +3 -5
  70. data/lib/review/pdfmaker.rb +60 -57
  71. data/lib/review/plaintextbuilder.rb +154 -87
  72. data/lib/review/preprocessor.rb +20 -42
  73. data/lib/review/rstbuilder.rb +57 -38
  74. data/lib/review/sec_counter.rb +13 -0
  75. data/lib/review/textmaker.rb +23 -15
  76. data/lib/review/textutils.rb +76 -2
  77. data/lib/review/tocprinter.rb +230 -102
  78. data/lib/review/topbuilder.rb +139 -60
  79. data/lib/review/update.rb +24 -24
  80. data/lib/review/version.rb +1 -1
  81. data/lib/review/volumeprinter.rb +98 -0
  82. data/lib/review/webmaker.rb +20 -24
  83. data/lib/review/webtocprinter.rb +38 -35
  84. data/lib/review/yamlloader.rb +26 -16
  85. data/review.gemspec +6 -4
  86. data/samples/sample-book/README.md +7 -2
  87. data/samples/sample-book/src/.gitignore +154 -0
  88. data/samples/sample-book/src/config-ebook.yml +4 -0
  89. data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
  90. data/samples/sample-book/src/config-jlreq.yml +6 -0
  91. data/samples/sample-book/src/config.yml +2 -2
  92. data/samples/sample-book/src/lib/tasks/review.rake +29 -14
  93. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
  94. data/samples/syntax-book/Gemfile +1 -1
  95. data/samples/syntax-book/ch01.re +4 -2
  96. data/samples/syntax-book/ch02.re +8 -16
  97. data/samples/syntax-book/ch03.re +3 -6
  98. data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
  99. data/samples/syntax-book/config-jlreq.yml +5 -0
  100. data/samples/syntax-book/config-print.yml +3 -0
  101. data/samples/syntax-book/config.yml +1 -1
  102. data/samples/syntax-book/lib/tasks/review.rake +30 -15
  103. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
  104. data/templates/latex/config.erb +39 -25
  105. data/templates/latex/layout.tex.erb +1 -0
  106. data/templates/latex/review-jlreq/README.md +3 -1
  107. data/templates/latex/review-jlreq/review-base.sty +161 -50
  108. data/templates/latex/review-jlreq/review-jlreq.cls +21 -22
  109. data/templates/latex/review-jlreq/review-style.sty +4 -1
  110. data/templates/latex/review-jsbook/README.md +46 -5
  111. data/templates/latex/review-jsbook/review-base.sty +123 -35
  112. data/templates/latex/review-jsbook/review-jsbook.cls +10 -4
  113. data/templates/latex/review-jsbook/review-style.sty +5 -2
  114. data/templates/opf/epubv3.opf.erb +1 -0
  115. data/templates/web/html/layout-html5.html.erb +3 -3
  116. data/test/assets/test_template.tex +19 -7
  117. data/test/assets/test_template_backmatter.tex +19 -7
  118. data/test/book_test_helper.rb +11 -5
  119. data/test/test_book.rb +124 -79
  120. data/test/test_book_chapter.rb +97 -54
  121. data/test/test_book_part.rb +3 -3
  122. data/test/test_builder.rb +38 -13
  123. data/test/test_catalog.rb +24 -42
  124. data/test/test_catalog_converter_cmd.rb +1 -1
  125. data/test/test_converter.rb +1 -0
  126. data/test/test_epub3maker.rb +2 -2
  127. data/test/test_epubmaker.rb +8 -0
  128. data/test/test_epubmaker_cmd.rb +14 -7
  129. data/test/test_helper.rb +18 -7
  130. data/test/test_htmlbuilder.rb +1491 -205
  131. data/test/test_htmlutils.rb +0 -12
  132. data/test/test_i18n.rb +37 -37
  133. data/test/test_idgxmlbuilder.rb +744 -42
  134. data/test/test_idgxmlmaker_cmd.rb +46 -0
  135. data/test/test_image_finder.rb +52 -70
  136. data/test/test_index.rb +94 -44
  137. data/test/test_indexbuilder.rb +52 -0
  138. data/test/test_latexbuilder.rb +1784 -161
  139. data/test/test_latexbuilder_v2.rb +671 -102
  140. data/test/test_logger.rb +17 -4
  141. data/test/test_makerhelper.rb +2 -14
  142. data/test/test_markdownbuilder.rb +137 -16
  143. data/test/test_md2inaobuilder.rb +32 -9
  144. data/test/test_pdfmaker.rb +30 -12
  145. data/test/test_pdfmaker_cmd.rb +100 -6
  146. data/test/test_plaintextbuilder.rb +791 -30
  147. data/test/test_preprocessor.rb +2 -16
  148. data/test/test_review_ext.rb +2 -1
  149. data/test/test_rstbuilder.rb +274 -27
  150. data/test/test_sec_counter.rb +156 -0
  151. data/test/test_textmaker_cmd.rb +54 -0
  152. data/test/test_textutils.rb +109 -2
  153. data/test/test_topbuilder.rb +724 -34
  154. data/test/test_update.rb +20 -11
  155. data/test/test_webtocprinter.rb +75 -43
  156. data/test/test_yamlloader.rb +13 -0
  157. data/vendor/gentombow/LICENSE +1 -1
  158. data/vendor/gentombow/Makefile +0 -1
  159. data/vendor/gentombow/bounddvi-en.pdf +0 -0
  160. data/vendor/gentombow/bounddvi-en.tex +1 -0
  161. data/vendor/gentombow/bounddvi.pdf +0 -0
  162. data/vendor/gentombow/bounddvi.sty +30 -7
  163. data/vendor/gentombow/bounddvi.tex +1 -0
  164. data/vendor/gentombow/create_archive.sh +1 -0
  165. data/vendor/gentombow/gentombow-ja.pdf +0 -0
  166. data/vendor/gentombow/gentombow-ja.tex +9 -0
  167. data/vendor/gentombow/gentombow.pdf +0 -0
  168. data/vendor/gentombow/gentombow.sty +32 -10
  169. data/vendor/gentombow/gentombow.tex +8 -0
  170. data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
  171. data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
  172. data/vendor/jsclasses/LICENSE +1 -1
  173. data/vendor/jsclasses/Makefile +3 -2
  174. data/vendor/jsclasses/create_archive.sh +5 -5
  175. data/vendor/jsclasses/jis/Makefile +3 -2
  176. data/vendor/jsclasses/jis/jsarticle.cls +74 -31
  177. data/vendor/jsclasses/jis/jsbook.cls +74 -31
  178. data/vendor/jsclasses/jis/jsclasses.dtx +176 -36
  179. data/vendor/jsclasses/jis/jsclasses.ins +15 -5
  180. data/vendor/jsclasses/jis/jslogo.dtx +4 -4
  181. data/vendor/jsclasses/jis/jslogo.ins +9 -0
  182. data/vendor/jsclasses/jis/jslogo.sty +4 -16
  183. data/vendor/jsclasses/jis/jspf.cls +73 -30
  184. data/vendor/jsclasses/jis/jsreport.cls +74 -31
  185. data/vendor/jsclasses/jis/jsverb.ins +9 -0
  186. data/vendor/jsclasses/jis/jsverb.sty +1 -13
  187. data/vendor/jsclasses/jis/kiyou.cls +74 -31
  188. data/vendor/jsclasses/jis/minijs.sty +65 -22
  189. data/vendor/jsclasses/jis/okumacro.dtx +4 -5
  190. data/vendor/jsclasses/jis/okumacro.ins +9 -0
  191. data/vendor/jsclasses/jis/okumacro.sty +4 -17
  192. data/vendor/jsclasses/jis/okuverb.ins +9 -0
  193. data/vendor/jsclasses/jis/okuverb.sty +1 -13
  194. data/vendor/jsclasses/jis/winjis.sty +23 -19
  195. data/vendor/jsclasses/jsarticle.cls +74 -31
  196. data/vendor/jsclasses/jsbook.cls +74 -31
  197. data/vendor/jsclasses/jsclasses.dtx +176 -36
  198. data/vendor/jsclasses/jsclasses.ins +15 -5
  199. data/vendor/jsclasses/jsclasses.pdf +0 -0
  200. data/vendor/jsclasses/jslogo.dtx +4 -4
  201. data/vendor/jsclasses/jslogo.ins +9 -0
  202. data/vendor/jsclasses/jslogo.pdf +0 -0
  203. data/vendor/jsclasses/jslogo.sty +4 -16
  204. data/vendor/jsclasses/jspf.cls +73 -30
  205. data/vendor/jsclasses/jsreport.cls +74 -31
  206. data/vendor/jsclasses/jsverb.ins +9 -0
  207. data/vendor/jsclasses/jsverb.pdf +0 -0
  208. data/vendor/jsclasses/jsverb.sty +1 -13
  209. data/vendor/jsclasses/kiyou.cls +74 -31
  210. data/vendor/jsclasses/minijs.sty +68 -22
  211. data/vendor/jsclasses/okumacro.dtx +4 -5
  212. data/vendor/jsclasses/okumacro.ins +9 -0
  213. data/vendor/jsclasses/okumacro.pdf +0 -0
  214. data/vendor/jsclasses/okumacro.sty +4 -17
  215. data/vendor/jsclasses/okuverb.ins +9 -0
  216. data/vendor/jsclasses/okuverb.pdf +0 -0
  217. data/vendor/jsclasses/okuverb.sty +1 -13
  218. data/vendor/jsclasses/tests/relfont.tex +10 -0
  219. data/vendor/jsclasses/winjis.sty +23 -19
  220. metadata +65 -12
  221. data/.rubocop_todo.yml +0 -7
  222. data/lib/review/book/compilable.rb +0 -173
  223. data/lib/review/tocparser.rb +0 -271
  224. data/samples/syntax-book/review-ext.rb +0 -14
  225. 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,268 @@ 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
 
599
+ def test_minicolumn_blocks
600
+ %w[note memo tip info warning important caution notice].each do |type|
601
+ @builder.doc_status.clear
602
+ src = <<-EOS
603
+ //#{type}[#{type}1]{
604
+
605
+ //}
606
+
607
+ //#{type}[#{type}2]{
608
+ //}
609
+ EOS
610
+
611
+ expected = <<-EOS
612
+ #{type}1
613
+
614
+ #{type}2
615
+
616
+ EOS
617
+ assert_equal expected, compile_block(src)
618
+
619
+ src = <<-EOS
620
+ //#{type}[#{type}2]{
621
+
622
+ //}
623
+
624
+ //#{type}[#{type}3]{
625
+
626
+ //}
627
+
628
+ //#{type}[#{type}4]{
629
+
630
+ //}
631
+
632
+ //#{type}[#{type}5]{
633
+
634
+ //}
635
+
636
+ //#{type}[#{type}6]{
637
+
638
+ //}
639
+ EOS
640
+
641
+ expected = <<-EOS
642
+ #{type}2
643
+
644
+ #{type}3
645
+
646
+ #{type}4
647
+
648
+ #{type}5
649
+
650
+ #{type}6
651
+
652
+ EOS
653
+ assert_equal expected, compile_block(src)
654
+
655
+ src = <<-EOS
656
+ //#{type}{
657
+
658
+ * A
659
+
660
+ 1. B
661
+
662
+ //}
663
+
664
+ //#{type}[OMITEND1]{
665
+
666
+ //emlist{
667
+ LIST
668
+ //}
669
+
670
+ //}
671
+ //#{type}[OMITEND2]{
672
+ //}
673
+ EOS
674
+
675
+ expected = <<-EOS
676
+ A
677
+
678
+ 1 B
679
+
680
+ OMITEND1
681
+
682
+ LIST
683
+
684
+ OMITEND2
685
+
686
+ EOS
687
+ assert_equal expected, compile_block(src)
688
+ end
689
+ end
690
+
691
+ def test_minicolumn_blocks_nest_error1
692
+ %w[note memo tip info warning important caution notice].each do |type|
693
+ @builder.doc_status.clear
694
+ src = <<-EOS
695
+ //#{type}{
696
+
697
+ //#{type}{
698
+ //}
699
+
700
+ //}
701
+ EOS
702
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
703
+ assert_match(/minicolumn cannot be nested:/, e.message)
704
+ end
705
+ end
706
+
707
+ def test_minicolumn_blocks_nest_error2
708
+ %w[note memo tip info warning important caution notice].each do |type|
709
+ @builder.doc_status.clear
710
+ src = <<-EOS
711
+ //#{type}{
712
+
713
+ //#{type}{
714
+
715
+ //}
716
+
717
+ //}
718
+ EOS
719
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
720
+ assert_match(/minicolumn cannot be nested:/, e.message)
721
+ end
722
+ end
723
+
724
+ def test_minicolumn_blocks_nest_error3
725
+ %w[memo tip info warning important caution notice].each do |type|
726
+ @builder.doc_status.clear
727
+ src = <<-EOS
728
+ //#{type}{
729
+
730
+ //note{
731
+ //}
732
+
733
+ //}
734
+ EOS
735
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
736
+ assert_match(/minicolumn cannot be nested:/, e.message)
737
+ end
738
+ end
739
+
268
740
  def test_image
269
741
  def @chapter.image(_id)
270
- item = Book::ImageIndex::Item.new('sampleimg', 1)
742
+ item = Book::Index::Item.new('sampleimg', 1)
271
743
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
272
744
  item
273
745
  end
274
746
 
275
747
  actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
276
748
  assert_equal %Q(図1.1 sample photo\n\n), actual
749
+
750
+ @config['caption_position']['image'] = 'top'
751
+ actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
752
+ assert_equal %Q(図1.1 sample photo\n\n), actual
277
753
  end
278
754
 
279
755
  def test_image_with_metric
280
756
  def @chapter.image(_id)
281
- item = Book::ImageIndex::Item.new('sampleimg', 1)
757
+ item = Book::Index::Item.new('sampleimg', 1)
282
758
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
283
759
  item
284
760
  end
@@ -293,18 +769,18 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
293
769
  end
294
770
 
295
771
  def test_inline_unknown
296
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<img>{n}\n" }
772
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
297
773
  assert_equal ':1: error: unknown image: n', e.message
298
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<fn>{n}\n" }
774
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
299
775
  assert_equal ':1: error: unknown footnote: n', e.message
300
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<hd>{n}\n" }
776
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
301
777
  assert_equal ':1: error: unknown headline: n', e.message
302
778
  %w[list table column].each do |name|
303
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<#{name}>{n}\n" }
779
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
304
780
  assert_equal ":1: error: unknown #{name}: n", e.message
305
781
  end
306
782
  %w[chap chapref title].each do |name|
307
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<#{name}>{n}\n" }
783
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
308
784
  assert_equal ':1: error: key not found: "n"', e.message
309
785
  end
310
786
  end
@@ -405,5 +881,290 @@ e=mc^2
405
881
  EOS
406
882
  actual = compile_block(src)
407
883
  assert_equal expected, actual
884
+
885
+ @config['caption_position']['equation'] = 'bottom'
886
+ expected = <<-EOS
887
+ 式1.1
888
+
889
+ e=mc^2
890
+ 式1.1 The Equivalence of Mass and Energy
891
+
892
+ EOS
893
+ actual = compile_block(src)
894
+ assert_equal expected, actual
895
+ end
896
+
897
+ def test_nest_error_open
898
+ src = <<-EOS
899
+ //endchild
900
+ EOS
901
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
902
+ assert_equal ":1: error: //endchild is shown, but any opened //beginchild doesn't exist", e.message
903
+ end
904
+
905
+ def test_nest_error_close1
906
+ src = <<-EOS
907
+ //beginchild
908
+ EOS
909
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
910
+ assert_equal ":1: error: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
911
+ end
912
+
913
+ def test_nest_error_close2
914
+ src = <<-EOS
915
+ * foo
916
+
917
+ //beginchild
918
+
919
+ 1. foo
920
+
921
+ //beginchild
922
+
923
+ : foo
924
+
925
+ //beginchild
926
+ EOS
927
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
928
+ assert_equal ':12: error: //beginchild of dl,ol,ul misses //endchild', e.message
929
+ end
930
+
931
+ def test_nest_error_close3
932
+ src = <<-EOS
933
+ * foo
934
+
935
+ //beginchild
936
+
937
+ 1. foo
938
+
939
+ //beginchild
940
+
941
+ : foo
942
+
943
+ //beginchild
944
+
945
+ //endchild
946
+ EOS
947
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
948
+ assert_equal ':14: error: //beginchild of ol,ul misses //endchild', e.message
949
+ end
950
+
951
+ def test_nest_ul
952
+ src = <<-EOS
953
+ * UL1
954
+
955
+ //beginchild
956
+
957
+ 1. UL1-OL1
958
+ 2. UL1-OL2
959
+
960
+ * UL1-UL1
961
+ * UL1-UL2
962
+
963
+ : UL1-DL1
964
+ UL1-DD1
965
+ : UL1-DL2
966
+ UL1-DD2
967
+
968
+ //endchild
969
+
970
+ * UL2
971
+
972
+ //beginchild
973
+
974
+ UL2-PARA
975
+
976
+ //endchild
977
+ EOS
978
+
979
+ expected = <<-EOS
980
+ UL1
981
+
982
+ 1 UL1-OL1
983
+ 2 UL1-OL2
984
+
985
+ UL1-UL1
986
+ UL1-UL2
987
+
988
+ UL1-DL1
989
+ UL1-DD1
990
+ UL1-DL2
991
+ UL1-DD2
992
+
993
+ UL2
994
+ UL2-PARA
995
+ EOS
996
+
997
+ actual = compile_block(src)
998
+ assert_equal expected, actual
999
+ end
1000
+
1001
+ def test_nest_ol
1002
+ src = <<-EOS
1003
+ 1. OL1
1004
+
1005
+ //beginchild
1006
+
1007
+ 1. OL1-OL1
1008
+ 2. OL1-OL2
1009
+
1010
+ * OL1-UL1
1011
+ * OL1-UL2
1012
+
1013
+ : OL1-DL1
1014
+ OL1-DD1
1015
+ : OL1-DL2
1016
+ OL1-DD2
1017
+
1018
+ //endchild
1019
+
1020
+ 2. OL2
1021
+
1022
+ //beginchild
1023
+
1024
+ OL2-PARA
1025
+
1026
+ //endchild
1027
+ EOS
1028
+
1029
+ expected = <<-EOS
1030
+ 1 OL1
1031
+
1032
+ 1 OL1-OL1
1033
+ 2 OL1-OL2
1034
+
1035
+ OL1-UL1
1036
+ OL1-UL2
1037
+
1038
+ OL1-DL1
1039
+ OL1-DD1
1040
+ OL1-DL2
1041
+ OL1-DD2
1042
+
1043
+ 2 OL2
1044
+ OL2-PARA
1045
+ EOS
1046
+
1047
+ actual = compile_block(src)
1048
+ assert_equal expected, actual
1049
+ end
1050
+
1051
+ def test_nest_dl
1052
+ src = <<-EOS
1053
+ : DL1
1054
+
1055
+ //beginchild
1056
+
1057
+ 1. DL1-OL1
1058
+ 2. DL1-OL2
1059
+
1060
+ * DL1-UL1
1061
+ * DL1-UL2
1062
+
1063
+ : DL1-DL1
1064
+ DL1-DD1
1065
+ : DL1-DL2
1066
+ DL1-DD2
1067
+
1068
+ //endchild
1069
+
1070
+ : DL2
1071
+ DD2
1072
+
1073
+ //beginchild
1074
+
1075
+ * DD2-UL1
1076
+ * DD2-UL2
1077
+
1078
+ DD2-PARA
1079
+
1080
+ //endchild
1081
+ EOS
1082
+
1083
+ expected = <<-EOS
1084
+ DL1
1085
+
1086
+ 1 DL1-OL1
1087
+ 2 DL1-OL2
1088
+
1089
+ DL1-UL1
1090
+ DL1-UL2
1091
+
1092
+ DL1-DL1
1093
+ DL1-DD1
1094
+ DL1-DL2
1095
+ DL1-DD2
1096
+
1097
+ DL2
1098
+ DD2
1099
+
1100
+ DD2-UL1
1101
+ DD2-UL2
1102
+
1103
+ DD2-PARA
1104
+ EOS
1105
+
1106
+ actual = compile_block(src)
1107
+ assert_equal expected, actual
1108
+ end
1109
+
1110
+ def test_nest_multi
1111
+ src = <<-EOS
1112
+ 1. OL1
1113
+
1114
+ //beginchild
1115
+
1116
+ 1. OL1-OL1
1117
+
1118
+ //beginchild
1119
+
1120
+ * OL1-OL1-UL1
1121
+
1122
+ OL1-OL1-PARA
1123
+
1124
+ //endchild
1125
+
1126
+ 2. OL1-OL2
1127
+
1128
+ * OL1-UL1
1129
+
1130
+ //beginchild
1131
+
1132
+ : OL1-UL1-DL1
1133
+ OL1-UL1-DD1
1134
+
1135
+ OL1-UL1-PARA
1136
+
1137
+ //endchild
1138
+
1139
+ * OL1-UL2
1140
+
1141
+ //endchild
1142
+ EOS
1143
+ expected = <<-EOS
1144
+ 1 OL1
1145
+
1146
+ 1 OL1-OL1
1147
+
1148
+
1149
+ OL1-OL1-UL1
1150
+
1151
+ OL1-OL1-PARA
1152
+
1153
+ 2 OL1-OL2
1154
+
1155
+ OL1-UL1
1156
+
1157
+
1158
+ OL1-UL1-DL1
1159
+ OL1-UL1-DD1
1160
+
1161
+ OL1-UL1-PARA
1162
+
1163
+ OL1-UL2
1164
+
1165
+ EOS
1166
+
1167
+ actual = compile_block(src)
1168
+ assert_equal expected, actual
408
1169
  end
409
1170
  end