review 4.1.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-tex.yml +35 -0
  3. data/.github/workflows/ruby-win.yml +19 -9
  4. data/.github/workflows/ruby.yml +7 -3
  5. data/.rubocop.yml +138 -34
  6. data/NEWS.ja.md +285 -0
  7. data/NEWS.md +285 -1
  8. data/README.md +7 -6
  9. data/Rakefile +7 -2
  10. data/bin/review +2 -4
  11. data/bin/review-catalog-converter +4 -4
  12. data/bin/review-check +8 -12
  13. data/bin/review-checkdep +2 -5
  14. data/bin/review-compile +18 -34
  15. data/bin/review-epub2html +1 -4
  16. data/bin/review-epubmaker +3 -4
  17. data/bin/review-idgxmlmaker +1 -3
  18. data/bin/review-index +5 -86
  19. data/bin/review-init +1 -4
  20. data/bin/review-pdfmaker +1 -3
  21. data/bin/review-preproc +30 -38
  22. data/bin/review-textmaker +1 -3
  23. data/bin/review-update +1 -4
  24. data/bin/review-validate +4 -4
  25. data/bin/review-vol +5 -82
  26. data/bin/review-webmaker +1 -3
  27. data/doc/config.yml.sample +45 -11
  28. data/doc/config.yml.sample-simple +3 -3
  29. data/doc/format.ja.md +103 -13
  30. data/doc/format.md +104 -16
  31. data/doc/makeindex.ja.md +2 -2
  32. data/doc/pdfmaker.ja.md +42 -0
  33. data/doc/pdfmaker.md +41 -0
  34. data/doc/quickstart.ja.md +19 -6
  35. data/doc/quickstart.md +18 -6
  36. data/doc/writing_vertical.ja.md +6 -0
  37. data/lib/review.rb +1 -1
  38. data/lib/review/book.rb +2 -2
  39. data/lib/review/book/base.rb +67 -29
  40. data/lib/review/book/bib.rb +21 -0
  41. data/lib/review/book/book_unit.rb +158 -0
  42. data/lib/review/book/chapter.rb +33 -26
  43. data/lib/review/book/index.rb +24 -185
  44. data/lib/review/book/index/item.rb +7 -1
  45. data/lib/review/book/page_metric.rb +7 -7
  46. data/lib/review/book/part.rb +26 -11
  47. data/lib/review/book/volume.rb +5 -5
  48. data/lib/review/builder.rb +121 -52
  49. data/lib/review/call_hook.rb +20 -0
  50. data/lib/review/catalog.rb +3 -2
  51. data/lib/review/compiler.rb +230 -111
  52. data/lib/review/configure.rb +91 -7
  53. data/lib/review/converter.rb +1 -1
  54. data/lib/review/epub2html.rb +6 -1
  55. data/lib/review/epubmaker.rb +124 -152
  56. data/lib/review/epubmaker/content.rb +113 -0
  57. data/lib/review/epubmaker/epubcommon.rb +372 -0
  58. data/lib/review/epubmaker/epubv2.rb +178 -0
  59. data/lib/review/epubmaker/epubv3.rb +231 -0
  60. data/lib/review/epubmaker/producer.rb +167 -0
  61. data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
  62. data/lib/review/epubmaker/zip_exporter.rb +84 -0
  63. data/lib/review/exception.rb +13 -0
  64. data/lib/review/htmlbuilder.rb +176 -89
  65. data/lib/review/htmlutils.rb +8 -11
  66. data/lib/review/i18n.rb +2 -1
  67. data/lib/review/idgxmlbuilder.rb +165 -75
  68. data/lib/review/idgxmlmaker.rb +24 -28
  69. data/lib/review/img_math.rb +238 -0
  70. data/lib/review/index_builder.rb +645 -0
  71. data/lib/review/init.rb +9 -17
  72. data/lib/review/latexbox.rb +58 -0
  73. data/lib/review/latexbuilder.rb +193 -75
  74. data/lib/review/latexutils.rb +9 -1
  75. data/lib/review/lineinput.rb +112 -2
  76. data/lib/review/loggable.rb +27 -0
  77. data/lib/review/logger.rb +90 -3
  78. data/lib/review/makerhelper.rb +17 -188
  79. data/lib/review/markdownbuilder.rb +54 -4
  80. data/lib/review/pdfmaker.rb +76 -84
  81. data/lib/review/plaintextbuilder.rb +106 -22
  82. data/lib/review/preprocessor.rb +107 -303
  83. data/lib/review/preprocessor/directive.rb +35 -0
  84. data/lib/review/preprocessor/line.rb +34 -0
  85. data/lib/review/preprocessor/repository.rb +177 -0
  86. data/lib/review/rstbuilder.rb +27 -8
  87. data/lib/review/sec_counter.rb +14 -0
  88. data/lib/review/template.rb +11 -1
  89. data/lib/review/textmaker.rb +27 -32
  90. data/lib/review/textutils.rb +3 -12
  91. data/lib/review/tocprinter.rb +242 -97
  92. data/lib/review/topbuilder.rb +98 -31
  93. data/lib/review/update.rb +12 -13
  94. data/lib/review/version.rb +1 -1
  95. data/lib/review/volumeprinter.rb +97 -0
  96. data/lib/review/webmaker.rb +40 -47
  97. data/lib/review/webtocprinter.rb +39 -35
  98. data/lib/review/yamlloader.rb +2 -1
  99. data/review.gemspec +5 -3
  100. data/samples/sample-book/src/config-epub2.yml +1 -1
  101. data/samples/sample-book/src/config.yml +3 -3
  102. data/samples/sample-book/src/lib/tasks/review.rake +19 -1
  103. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +2 -1
  104. data/samples/syntax-book/Gemfile +1 -1
  105. data/samples/syntax-book/ch01.re +1 -1
  106. data/samples/syntax-book/ch02.re +21 -6
  107. data/samples/syntax-book/ch03.re +1 -1
  108. data/samples/syntax-book/config.yml +1 -1
  109. data/samples/syntax-book/images/img3-2.png +0 -0
  110. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +2 -1
  111. data/templates/html/_colophon.html.erb +23 -0
  112. data/templates/html/_colophon_history.html.erb +9 -0
  113. data/templates/html/_cover.html.erb +10 -0
  114. data/templates/html/_part_body.html.erb +6 -0
  115. data/templates/html/_titlepage.html.erb +20 -0
  116. data/templates/html/layout-html5.html.erb +6 -0
  117. data/templates/html/layout-xhtml1.html.erb +6 -0
  118. data/templates/latex/config.erb +35 -23
  119. data/templates/latex/review-jlreq/README.md +3 -1
  120. data/templates/latex/review-jlreq/review-base.sty +36 -23
  121. data/templates/latex/review-jlreq/review-jlreq.cls +18 -25
  122. data/templates/latex/review-jlreq/review-style.sty +6 -1
  123. data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
  124. data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
  125. data/templates/latex/review-jsbook/README.md +7 -5
  126. data/templates/latex/review-jsbook/review-base.sty +40 -24
  127. data/templates/latex/review-jsbook/review-jsbook.cls +13 -3
  128. data/templates/latex/review-jsbook/review-style.sty +6 -1
  129. data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
  130. data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
  131. data/templates/opf/epubv2.opf.erb +7 -7
  132. data/templates/opf/epubv3.opf.erb +7 -7
  133. data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
  134. data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
  135. data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
  136. data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
  137. data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
  138. data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
  139. data/templates/web/html/layout-html5.html.erb +9 -8
  140. data/templates/web/html/layout-xhtml1.html.erb +6 -0
  141. data/test/assets/header_listener.html +35 -0
  142. data/test/assets/img_math/img1.png +0 -0
  143. data/test/assets/img_math/img2.png +0 -0
  144. data/test/assets/img_math/img3.png +0 -0
  145. data/test/assets/syntax_book_index_detail.txt +58 -0
  146. data/test/assets/test_template.tex +6 -3
  147. data/test/assets/test_template_backmatter.tex +6 -3
  148. data/test/book_test_helper.rb +11 -5
  149. data/test/run_test.rb +1 -1
  150. data/test/test_book.rb +54 -63
  151. data/test/test_book_chapter.rb +95 -54
  152. data/test/test_book_part.rb +3 -3
  153. data/test/test_builder.rb +29 -20
  154. data/test/test_catalog_converter_cmd.rb +1 -1
  155. data/test/test_converter.rb +1 -0
  156. data/test/test_epub3maker.rb +170 -126
  157. data/test/test_epubmaker.rb +254 -129
  158. data/test/test_epubmaker_cmd.rb +15 -4
  159. data/test/test_helper.rb +12 -5
  160. data/test/test_htmlbuilder.rb +926 -76
  161. data/test/test_htmlutils.rb +0 -12
  162. data/test/test_i18n.rb +33 -33
  163. data/test/test_idgxmlbuilder.rb +531 -20
  164. data/test/test_idgxmlmaker_cmd.rb +7 -3
  165. data/test/test_img_math.rb +111 -0
  166. data/test/test_index.rb +62 -52
  167. data/test/test_indexbuilder.rb +52 -0
  168. data/test/test_latexbuilder.rb +891 -20
  169. data/test/test_latexbuilder_v2.rb +56 -10
  170. data/test/test_lineinput.rb +20 -93
  171. data/test/test_logger.rb +7 -7
  172. data/test/test_makerhelper.rb +0 -12
  173. data/test/test_markdownbuilder.rb +32 -0
  174. data/test/test_pdfmaker.rb +100 -11
  175. data/test/test_pdfmaker_cmd.rb +3 -3
  176. data/test/test_plaintextbuilder.rb +546 -32
  177. data/test/test_preprocessor.rb +188 -1
  178. data/test/test_review_ext.rb +2 -1
  179. data/test/test_reviewheaderlistener.rb +49 -0
  180. data/test/test_rstbuilder.rb +25 -1
  181. data/test/test_sec_counter.rb +156 -0
  182. data/test/test_template.rb +12 -2
  183. data/test/test_textmaker_cmd.rb +5 -1
  184. data/test/test_tocprinter.rb +46 -0
  185. data/test/test_topbuilder.rb +324 -20
  186. data/test/test_update.rb +44 -44
  187. data/test/test_webtocprinter.rb +75 -43
  188. data/test/test_zip_exporter.rb +5 -6
  189. data/vendor/gentombow/LICENSE +1 -1
  190. data/vendor/gentombow/Makefile +0 -1
  191. data/vendor/gentombow/bounddvi-en.pdf +0 -0
  192. data/vendor/gentombow/bounddvi-en.tex +1 -0
  193. data/vendor/gentombow/bounddvi.pdf +0 -0
  194. data/vendor/gentombow/bounddvi.sty +30 -7
  195. data/vendor/gentombow/bounddvi.tex +1 -0
  196. data/vendor/gentombow/create_archive.sh +1 -0
  197. data/vendor/gentombow/gentombow-ja.pdf +0 -0
  198. data/vendor/gentombow/gentombow-ja.tex +9 -0
  199. data/vendor/gentombow/gentombow.pdf +0 -0
  200. data/vendor/gentombow/gentombow.sty +32 -10
  201. data/vendor/gentombow/gentombow.tex +8 -0
  202. data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
  203. data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
  204. data/vendor/jsclasses/Makefile +3 -2
  205. data/vendor/jsclasses/create_archive.sh +5 -5
  206. data/vendor/jsclasses/jis/Makefile +3 -2
  207. data/vendor/jsclasses/jis/jsarticle.cls +22 -18
  208. data/vendor/jsclasses/jis/jsbook.cls +22 -18
  209. data/vendor/jsclasses/jis/jsclasses.dtx +94 -13
  210. data/vendor/jsclasses/jis/jsclasses.ins +15 -5
  211. data/vendor/jsclasses/jis/jslogo.ins +9 -0
  212. data/vendor/jsclasses/jis/jslogo.sty +1 -13
  213. data/vendor/jsclasses/jis/jspf.cls +22 -18
  214. data/vendor/jsclasses/jis/jsreport.cls +22 -18
  215. data/vendor/jsclasses/jis/jsverb.ins +9 -0
  216. data/vendor/jsclasses/jis/jsverb.sty +1 -13
  217. data/vendor/jsclasses/jis/kiyou.cls +22 -18
  218. data/vendor/jsclasses/jis/minijs.sty +65 -22
  219. data/vendor/jsclasses/jis/okumacro.ins +9 -0
  220. data/vendor/jsclasses/jis/okumacro.sty +1 -13
  221. data/vendor/jsclasses/jis/okuverb.ins +9 -0
  222. data/vendor/jsclasses/jis/okuverb.sty +1 -13
  223. data/vendor/jsclasses/jis/winjis.sty +23 -19
  224. data/vendor/jsclasses/jsarticle.cls +22 -18
  225. data/vendor/jsclasses/jsbook.cls +22 -18
  226. data/vendor/jsclasses/jsclasses.dtx +94 -13
  227. data/vendor/jsclasses/jsclasses.ins +15 -5
  228. data/vendor/jsclasses/jsclasses.pdf +0 -0
  229. data/vendor/jsclasses/jslogo.ins +9 -0
  230. data/vendor/jsclasses/jslogo.pdf +0 -0
  231. data/vendor/jsclasses/jslogo.sty +1 -13
  232. data/vendor/jsclasses/jspf.cls +22 -18
  233. data/vendor/jsclasses/jsreport.cls +22 -18
  234. data/vendor/jsclasses/jsverb.ins +9 -0
  235. data/vendor/jsclasses/jsverb.pdf +0 -0
  236. data/vendor/jsclasses/jsverb.sty +1 -13
  237. data/vendor/jsclasses/kiyou.cls +22 -18
  238. data/vendor/jsclasses/minijs.sty +68 -22
  239. data/vendor/jsclasses/okumacro.ins +9 -0
  240. data/vendor/jsclasses/okumacro.pdf +0 -0
  241. data/vendor/jsclasses/okumacro.sty +1 -13
  242. data/vendor/jsclasses/okuverb.ins +9 -0
  243. data/vendor/jsclasses/okuverb.pdf +0 -0
  244. data/vendor/jsclasses/okuverb.sty +1 -13
  245. data/vendor/jsclasses/tests/relfont.tex +10 -0
  246. data/vendor/jsclasses/winjis.sty +23 -19
  247. metadata +106 -22
  248. data/.rubocop_todo.yml +0 -7
  249. data/lib/epubmaker.rb +0 -23
  250. data/lib/epubmaker/content.rb +0 -110
  251. data/lib/epubmaker/epubcommon.rb +0 -441
  252. data/lib/epubmaker/epubv2.rb +0 -143
  253. data/lib/epubmaker/epubv3.rb +0 -233
  254. data/lib/epubmaker/producer.rb +0 -375
  255. data/lib/epubmaker/zip_exporter.rb +0 -81
  256. data/lib/lineinput.rb +0 -155
  257. data/lib/review/book/compilable.rb +0 -178
  258. data/lib/review/tocparser.rb +0 -275
  259. data/test/test_tocparser.rb +0 -25
@@ -20,6 +20,8 @@ class LATEXBuidlerTest < Test::Unit::TestCase
20
20
  @config['pdfmaker']['image_scale2width'] = nil
21
21
  @book = Book::Base.new
22
22
  @book.config = @config
23
+ @log_io = StringIO.new
24
+ ReVIEW.logger = ReVIEW::Logger.new(@log_io)
23
25
  @compiler = ReVIEW::Compiler.new(@builder)
24
26
  @chapter = Book::Chapter.new(@book, 1, 'chap1', nil, StringIO.new)
25
27
  location = Location.new(nil, nil)
@@ -197,6 +199,16 @@ EOS
197
199
  assert_equal 'abc\\reviewunderline{def}ghi', actual
198
200
  end
199
201
 
202
+ def test_inline_ins
203
+ actual = compile_inline('abc@<ins>{def}ghi')
204
+ assert_equal 'abc\\reviewinsert{def}ghi', actual
205
+ end
206
+
207
+ def test_inline_del
208
+ actual = compile_inline('abc@<del>{def}ghi')
209
+ assert_equal 'abc\\reviewstrike{def}ghi', actual
210
+ end
211
+
200
212
  def test_inline_bou
201
213
  actual = compile_inline('傍点の@<bou>{テスト}です。')
202
214
  assert_equal '傍点の\\reviewbou{テスト}です。', actual
@@ -255,6 +267,10 @@ EOS
255
267
 
256
268
  @config['secnolevel'] = 3
257
269
  actual = compile_inline('test @<hd>{chap1|test} test2')
270
+ assert_equal 'test \reviewsecref{「1.1.1 te\\textunderscore{}st」}{sec:1-1-1} test2', actual
271
+
272
+ @config['chapterlink'] = nil
273
+ actual = compile_inline('test @<hd>{chap1|test} test2')
258
274
  assert_equal 'test 「1.1.1 te\\textunderscore{}st」 test2', actual
259
275
  end
260
276
 
@@ -292,13 +308,65 @@ EOS
292
308
  return true
293
309
  end
294
310
  tmpdir = Dir.mktmpdir
295
- File.write(File.join(tmpdir, 'sample.dic'), "強運\tはーどらっく\n")
311
+ File.write(File.join(tmpdir, 'sample.dic'), "強運\tはーどらっく\nmain(ブロック)\tmain{|}\n")
296
312
  @book.config['pdfmaker']['makeindex'] = true
297
313
  @book.config['pdfmaker']['makeindex_dic'] = "#{tmpdir}/sample.dic"
298
314
  @builder.setup_index
299
315
  actual = compile_inline('@<hidx>{漢字}@<hidx>{強運}@<hidx>{項目@1<<>>項目@2}')
300
- FileUtils.remove_entry_secure(tmpdir)
301
316
  assert_equal %Q(\\index{かんじ@漢字}\\index{はーどらっく@強運}\\index{こうもく"@1@項目"@1!こうもく"@2@項目"@2}), actual
317
+ actual = compile_inline('@<hidx>{main(ブロック)}@<hidx>{あいうえお{\}}')
318
+ FileUtils.remove_entry_secure(tmpdir)
319
+ assert_equal %Q(\\index{main{|}@main(ブロック)}\\index{あいうえお{}@あいうえお\\reviewleftcurlybrace{}\\reviewrightcurlybrace{}}), actual
320
+ end
321
+
322
+ def test_inline_idx_escape
323
+ # as is
324
+ %w[a あ ' ( ) = ` + ; * : , . ? /].each do |c|
325
+ actual = @builder.index(c)
326
+ assert_equal %Q(\\index{#{c}}), actual
327
+ end
328
+ actual = @builder.index('[')
329
+ assert_equal %Q(\\index{[}), actual
330
+ actual = @builder.index(']')
331
+ assert_equal %Q(\\index{]}), actual
332
+
333
+ # escape display string by "
334
+ %w[! " @].each do |c|
335
+ actual = @builder.index(c)
336
+ assert_equal %Q(\\index{"#{c}@"#{c}}), actual
337
+ end
338
+
339
+ # escape display string by \
340
+ %w[# % &].each do |c|
341
+ actual = @builder.index(c)
342
+ assert_equal %Q(\\index{#{c}@\\#{c}}), actual
343
+ end
344
+
345
+ # escape display string by macro
346
+ actual = @builder.index('$')
347
+ assert_equal %Q(\\index{$@\\textdollar{}}), actual
348
+ actual = @builder.index('-')
349
+ assert_equal %Q(\\index{-@{-}}), actual
350
+ actual = @builder.index('~')
351
+ assert_equal %Q(\\index{~@\\textasciitilde{}}), actual
352
+ actual = @builder.index('^')
353
+ assert_equal %Q(\\index{^@\\textasciicircum{}}), actual
354
+ actual = @builder.index('\\')
355
+ assert_equal %Q(\\index{\\@\\reviewbackslash{}}), actual
356
+ actual = @builder.index('<')
357
+ assert_equal %Q(\\index{<@\\textless{}}), actual
358
+ actual = @builder.index('>')
359
+ assert_equal %Q(\\index{>@\\textgreater{}}), actual
360
+ actual = @builder.index('_')
361
+ assert_equal %Q(\\index{_@\\textunderscore{}}), actual
362
+
363
+ # escape both sort key and display string
364
+ actual = @builder.index('{')
365
+ assert_equal %Q(\\index{{@\\reviewleftcurlybrace{}}), actual
366
+ actual = @builder.index('|')
367
+ assert_equal %Q(\\index{|@\\textbar{}}), actual
368
+ actual = @builder.index('}')
369
+ assert_equal %Q(\\index{}@\\reviewrightcurlybrace{}}), actual
302
370
  end
303
371
 
304
372
  def test_jis_x_0201_kana
@@ -389,9 +457,7 @@ EOS
389
457
  end
390
458
 
391
459
  def test_dt_inline
392
- fn = Book::FootnoteIndex.parse(['//footnote[bar][bar]'])
393
- @chapter.instance_eval { @footnote_index = fn }
394
- actual = compile_block(" : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
460
+ actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
395
461
 
396
462
  expected = <<-EOS
397
463
 
@@ -432,6 +498,22 @@ bar
432
498
  buz
433
499
  \\end{reviewcmd}
434
500
  \\end{reviewlistblock}
501
+ EOS
502
+ assert_equal expected, actual
503
+
504
+ @config['caption_position']['list'] = 'bottom'
505
+ actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
506
+ expected = <<-EOS
507
+
508
+ \\begin{reviewlistblock}
509
+ \\begin{reviewcmd}
510
+ foo
511
+ bar
512
+
513
+ buz
514
+ \\end{reviewcmd}
515
+ \\reviewcmdcaption{cap1}
516
+ \\end{reviewlistblock}
435
517
  EOS
436
518
  assert_equal expected, actual
437
519
  end
@@ -507,6 +589,22 @@ bar
507
589
  buz
508
590
  \\end{reviewemlist}
509
591
  \\end{reviewlistblock}
592
+ EOS
593
+ assert_equal expected, actual
594
+
595
+ @config['caption_position']['list'] = 'bottom'
596
+ actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
597
+ expected = <<-EOS
598
+
599
+ \\begin{reviewlistblock}
600
+ \\begin{reviewemlist}
601
+ foo
602
+ bar
603
+
604
+ buz
605
+ \\end{reviewemlist}
606
+ \\reviewemlistcaption{cap1}
607
+ \\end{reviewlistblock}
510
608
  EOS
511
609
  assert_equal expected, actual
512
610
  end
@@ -573,6 +671,22 @@ EOS
573
671
  4: buz
574
672
  \\end{reviewemlist}
575
673
  \\end{reviewlistblock}
674
+ EOS
675
+ assert_equal expected, actual
676
+
677
+ @config['caption_position']['list'] = 'bottom'
678
+ actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
679
+ expected = <<-EOS
680
+
681
+ \\begin{reviewlistblock}
682
+ \\begin{reviewemlist}
683
+ 1: foo
684
+ 2: bar
685
+ 3:
686
+ 4: buz
687
+ \\end{reviewemlist}
688
+ \\reviewemlistcaption{cap1}
689
+ \\end{reviewlistblock}
576
690
  EOS
577
691
  assert_equal expected, actual
578
692
  end
@@ -589,6 +703,21 @@ bar
589
703
  buz
590
704
  \\end{reviewlist}
591
705
  \\end{reviewlistblock}
706
+ EOS
707
+ assert_equal expected, actual
708
+
709
+ @config['caption_position']['list'] = 'bottom'
710
+ actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
711
+ expected = <<-EOS
712
+ \\begin{reviewlistblock}
713
+ \\begin{reviewlist}
714
+ foo
715
+ bar
716
+
717
+ buz
718
+ \\end{reviewlist}
719
+ \\reviewlistcaption{リスト1.1: cap1}
720
+ \\end{reviewlistblock}
592
721
  EOS
593
722
  assert_equal expected, actual
594
723
  end
@@ -601,6 +730,16 @@ EOS
601
730
  \\begin{reviewlistlst}[caption={cap1},language={sql}]
602
731
  SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
603
732
  \\end{reviewlistlst}
733
+ EOS
734
+ assert_equal expected, actual
735
+
736
+ @config['caption_position']['list'] = 'bottom'
737
+ # XXX: caption_position won't work with highlight
738
+ actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
739
+ expected = <<-EOS
740
+ \\begin{reviewlistlst}[caption={cap1},language={sql}]
741
+ SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
742
+ \\end{reviewlistlst}
604
743
  EOS
605
744
  assert_equal expected, actual
606
745
  end
@@ -633,6 +772,24 @@ EOS
633
772
  7: end
634
773
  \\end{reviewlist}
635
774
  \\end{reviewlistblock}
775
+ EOS
776
+ assert_equal expected, actual
777
+
778
+ @config['caption_position']['list'] = 'bottom'
779
+ actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
780
+ expected = <<-EOS
781
+ \\begin{reviewlistblock}
782
+ \\begin{reviewlist}
783
+ 1: class Foo
784
+ 2: def foo
785
+ 3: bar
786
+ 4:
787
+ 5: buz
788
+ 6: end
789
+ 7: end
790
+ \\end{reviewlist}
791
+ \\reviewlistcaption{リスト1.1: ruby}
792
+ \\end{reviewlistblock}
636
793
  EOS
637
794
  assert_equal expected, actual
638
795
  end
@@ -670,6 +827,22 @@ class Foo
670
827
  end
671
828
  end
672
829
  \\end{reviewlistnumlst}
830
+ EOS
831
+ assert_equal expected, actual
832
+
833
+ @config['caption_position']['list'] = 'bottom'
834
+ # XXX: caption_position won't work with highlight
835
+ actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
836
+ expected = <<-EOS
837
+ \\begin{reviewlistnumlst}[caption={ruby},language={}]
838
+ class Foo
839
+ def foo
840
+ bar
841
+
842
+ buz
843
+ end
844
+ end
845
+ \\end{reviewlistnumlst}
673
846
  EOS
674
847
  assert_equal expected, actual
675
848
  end
@@ -704,6 +877,21 @@ bar
704
877
  buz
705
878
  \\end{reviewsource}
706
879
  \\end{reviewlistblock}
880
+ EOS
881
+ assert_equal expected, actual
882
+
883
+ @config['caption_position']['list'] = 'bottom'
884
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
885
+ expected = <<-EOS
886
+ \\begin{reviewlistblock}
887
+ \\begin{reviewsource}
888
+ foo
889
+ bar
890
+
891
+ buz
892
+ \\end{reviewsource}
893
+ \\reviewsourcecaption{foo/bar/test.rb}
894
+ \\end{reviewlistblock}
707
895
  EOS
708
896
  assert_equal expected, actual
709
897
  end
@@ -732,6 +920,19 @@ EOS
732
920
  foo
733
921
  bar
734
922
 
923
+ buz
924
+ \\end{reviewsourcelst}
925
+ EOS
926
+ assert_equal expected, actual
927
+
928
+ @config['caption_position']['list'] = 'bottom'
929
+ # XXX: caption_position won't work with highlight
930
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
931
+ expected = <<-EOS
932
+ \\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]
933
+ foo
934
+ bar
935
+
735
936
  buz
736
937
  \\end{reviewsourcelst}
737
938
  EOS
@@ -767,9 +968,11 @@ EOS
767
968
  actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
768
969
  expected = <<-EOS
769
970
  \\begin{reviewmemo}[this is \\reviewbold{test}\\textless{}\\&\\textgreater{}\\textunderscore{}]
971
+
770
972
  test1
771
973
 
772
974
  test\\reviewit{2}
975
+
773
976
  \\end{reviewmemo}
774
977
  EOS
775
978
  assert_equal expected, actual
@@ -888,6 +1091,31 @@ EOS
888
1091
 
889
1092
  actual = compile_block("//image[sampleimg][sample photo][]{\n//}\n")
890
1093
  assert_equal expected, actual
1094
+
1095
+ @book.config['pdfmaker']['use_original_image_size'] = nil
1096
+ @config['caption_position']['image'] = 'top'
1097
+ actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
1098
+ expected = <<-EOS
1099
+ \\begin{reviewimage}%%sampleimg
1100
+ \\reviewimagecaption{sample photo}
1101
+ \\label{image:chap1:sampleimg}
1102
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1103
+ \\end{reviewimage}
1104
+ EOS
1105
+ assert_equal expected, actual
1106
+
1107
+ actual = compile_block("//image[sampleimg][]{\n//}\n")
1108
+ expected = <<-EOS
1109
+ \\begin{reviewimage}%%sampleimg
1110
+ \\reviewimagecaption{}
1111
+ \\label{image:chap1:sampleimg}
1112
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1113
+ \\end{reviewimage}
1114
+ EOS
1115
+ assert_equal expected, actual
1116
+
1117
+ actual = compile_block("//image[sampleimg][][]{\n//}\n")
1118
+ assert_equal expected, actual
891
1119
  end
892
1120
 
893
1121
  def test_image_with_metric
@@ -1008,6 +1236,17 @@ EOS
1008
1236
 
1009
1237
  actual = compile_block("//indepimage[sampleimg][sample photo][]\n")
1010
1238
  assert_equal expected, actual
1239
+
1240
+ @book.config['pdfmaker']['use_original_image_size'] = nil
1241
+ @config['caption_position']['image'] = 'top'
1242
+ actual = compile_block("//indepimage[sampleimg][sample photo]\n")
1243
+ expected = <<-EOS
1244
+ \\begin{reviewimage}%%sampleimg
1245
+ \\reviewindepimagecaption{図: sample photo}
1246
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1247
+ \\end{reviewimage}
1248
+ EOS
1249
+ assert_equal expected, actual
1011
1250
  end
1012
1251
 
1013
1252
  def test_indepimage_without_caption
@@ -1025,6 +1264,12 @@ EOS
1025
1264
  \\end{reviewimage}
1026
1265
  EOS
1027
1266
  assert_equal expected, actual
1267
+
1268
+ actual = compile_block("//indepimage[sampleimg][]\n")
1269
+ assert_equal expected, actual
1270
+
1271
+ actual = compile_block("//indepimage[sampleimg][][]\n")
1272
+ assert_equal expected, actual
1028
1273
  end
1029
1274
 
1030
1275
  def test_indepimage_with_metric
@@ -1112,6 +1357,31 @@ EOS
1112
1357
  assert_equal expected, actual
1113
1358
  end
1114
1359
 
1360
+ def test_indepimage_nofile
1361
+ def @chapter.image(_id)
1362
+ item = Book::Index::Item.new('sample_img_nofile_', 1)
1363
+ item.instance_eval do
1364
+ def path
1365
+ nil
1366
+ end
1367
+ end
1368
+ item
1369
+ end
1370
+
1371
+ io = StringIO.new
1372
+ @builder.instance_eval { @logger = ReVIEW::Logger.new(io) }
1373
+
1374
+ actual = compile_block("//indepimage[sample_img_nofile_][sample photo]\n")
1375
+ expected = <<-EOS
1376
+ \\begin{reviewdummyimage}
1377
+ {-}{-}[[path = sample\\reviewbackslash{}textunderscore\\{\\}img\\reviewbackslash{}textunderscore\\{\\}nofile\\reviewbackslash{}textunderscore\\{\\} (not exist)]]{-}{-}
1378
+ \\reviewindepimagecaption{図: sample photo}
1379
+ \\end{reviewdummyimage}
1380
+ EOS
1381
+ assert_equal expected, actual
1382
+ assert_match(/WARN --: :1: image not bound: sample_img_nofile_/, io.string)
1383
+ end
1384
+
1115
1385
  def test_table
1116
1386
  actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1117
1387
  expected = <<-EOS
@@ -1134,16 +1404,41 @@ EOS
1134
1404
  ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1135
1405
  \\end{reviewtable}
1136
1406
  \\end{table}
1407
+ EOS
1408
+ assert_equal expected, actual
1409
+
1410
+ actual = compile_block("//table[foo][]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1411
+ expected = <<-EOS
1412
+ \\begin{reviewtable}{|l|l|}
1413
+ \\hline
1414
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1415
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1416
+ \\end{reviewtable}
1417
+ EOS
1418
+ assert_equal expected, actual
1419
+
1420
+ @config['caption_position']['table'] = 'bottom'
1421
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1422
+ expected = <<-EOS
1423
+ \\begin{table}%%foo
1424
+ \\begin{reviewtable}{|l|l|}
1425
+ \\hline
1426
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1427
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1428
+ \\end{reviewtable}
1429
+ \\reviewtablecaption{FOO}
1430
+ \\label{table:chap1:foo}
1431
+ \\end{table}
1137
1432
  EOS
1138
1433
  assert_equal expected, actual
1139
1434
  end
1140
1435
 
1141
1436
  def test_empty_table
1142
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
1143
- assert_equal ':2: error: no rows in the table', e.message
1437
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
1438
+ assert_equal 'no rows in the table', e.message
1144
1439
 
1145
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
1146
- assert_equal ':3: error: no rows in the table', e.message
1440
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
1441
+ assert_equal 'no rows in the table', e.message
1147
1442
  end
1148
1443
 
1149
1444
  def test_customize_cellwidth
@@ -1240,6 +1535,26 @@ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1240
1535
  \\end{reviewtable}
1241
1536
  \\end{table}
1242
1537
 
1538
+ \\begin{reviewtable}{|l|l|}
1539
+ \\hline
1540
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1541
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1542
+ \\end{reviewtable}
1543
+ EOS
1544
+ assert_equal expected, actual
1545
+
1546
+ @config['caption_position']['table'] = 'bottom'
1547
+ actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1548
+ expected = <<-EOS
1549
+ \\begin{table}%%
1550
+ \\begin{reviewtable}{|l|l|}
1551
+ \\hline
1552
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1553
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1554
+ \\end{reviewtable}
1555
+ \\reviewtablecaption*{foo}
1556
+ \\end{table}
1557
+
1243
1558
  \\begin{reviewtable}{|l|l|}
1244
1559
  \\hline
1245
1560
  \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
@@ -1269,6 +1584,18 @@ EOS
1269
1584
  EOS
1270
1585
  assert_equal expected, actual
1271
1586
 
1587
+ actual = compile_block("//imgtable[sampleimg][]{\n//}\n")
1588
+ expected = <<-EOS
1589
+ \\label{table:chap1:sampleimg}
1590
+ \\begin{reviewimage}%%sampleimg
1591
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1592
+ \\end{reviewimage}
1593
+ EOS
1594
+ assert_equal expected, actual
1595
+
1596
+ actual = compile_block("//imgtable[sampleimg][][]{\n//}\n")
1597
+ assert_equal expected, actual
1598
+
1272
1599
  @book.config['pdfmaker']['use_original_image_size'] = true
1273
1600
  actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
1274
1601
 
@@ -1285,6 +1612,21 @@ EOS
1285
1612
 
1286
1613
  actual = compile_block("//imgtable[sampleimg][test for imgtable][]{\n//}\n")
1287
1614
  assert_equal expected, actual
1615
+
1616
+ @book.config['pdfmaker']['use_original_image_size'] = nil
1617
+ @config['caption_position']['table'] = 'bottom'
1618
+ actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
1619
+
1620
+ expected = <<-EOS
1621
+ \\begin{table}[h]%%sampleimg
1622
+ \\label{table:chap1:sampleimg}
1623
+ \\begin{reviewimage}%%sampleimg
1624
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1625
+ \\end{reviewimage}
1626
+ \\reviewimgtablecaption{test for imgtable}
1627
+ \\end{table}
1628
+ EOS
1629
+ assert_equal expected, actual
1288
1630
  end
1289
1631
 
1290
1632
  def test_imgtable_with_metrics
@@ -1664,12 +2006,16 @@ EOS
1664
2006
  actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
1665
2007
  expected = <<-EOS
1666
2008
  \\begin{reviewnote}
2009
+
1667
2010
  A
1668
2011
 
1669
2012
  B
2013
+
1670
2014
  \\end{reviewnote}
1671
2015
  \\begin{reviewnote}[caption]
2016
+
1672
2017
  A
2018
+
1673
2019
  \\end{reviewnote}
1674
2020
  EOS
1675
2021
  assert_equal expected, actual
@@ -1677,12 +2023,16 @@ EOS
1677
2023
  actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
1678
2024
  expected = <<-EOS
1679
2025
  \\begin{reviewmemo}
2026
+
1680
2027
  A
1681
2028
 
1682
2029
  B
2030
+
1683
2031
  \\end{reviewmemo}
1684
2032
  \\begin{reviewmemo}[caption]
2033
+
1685
2034
  A
2035
+
1686
2036
  \\end{reviewmemo}
1687
2037
  EOS
1688
2038
  assert_equal expected, actual
@@ -1690,12 +2040,16 @@ EOS
1690
2040
  actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
1691
2041
  expected = <<-EOS
1692
2042
  \\begin{reviewinfo}
2043
+
1693
2044
  A
1694
2045
 
1695
2046
  B
2047
+
1696
2048
  \\end{reviewinfo}
1697
2049
  \\begin{reviewinfo}[caption]
2050
+
1698
2051
  A
2052
+
1699
2053
  \\end{reviewinfo}
1700
2054
  EOS
1701
2055
  assert_equal expected, actual
@@ -1703,12 +2057,16 @@ EOS
1703
2057
  actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
1704
2058
  expected = <<-EOS
1705
2059
  \\begin{reviewimportant}
2060
+
1706
2061
  A
1707
2062
 
1708
2063
  B
2064
+
1709
2065
  \\end{reviewimportant}
1710
2066
  \\begin{reviewimportant}[caption]
2067
+
1711
2068
  A
2069
+
1712
2070
  \\end{reviewimportant}
1713
2071
  EOS
1714
2072
  assert_equal expected, actual
@@ -1716,12 +2074,16 @@ EOS
1716
2074
  actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
1717
2075
  expected = <<-EOS
1718
2076
  \\begin{reviewcaution}
2077
+
1719
2078
  A
1720
2079
 
1721
2080
  B
2081
+
1722
2082
  \\end{reviewcaution}
1723
2083
  \\begin{reviewcaution}[caption]
2084
+
1724
2085
  A
2086
+
1725
2087
  \\end{reviewcaution}
1726
2088
  EOS
1727
2089
  assert_equal expected, actual
@@ -1729,12 +2091,16 @@ EOS
1729
2091
  actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
1730
2092
  expected = <<-EOS
1731
2093
  \\begin{reviewnotice}
2094
+
1732
2095
  A
1733
2096
 
1734
2097
  B
2098
+
1735
2099
  \\end{reviewnotice}
1736
2100
  \\begin{reviewnotice}[caption]
2101
+
1737
2102
  A
2103
+
1738
2104
  \\end{reviewnotice}
1739
2105
  EOS
1740
2106
  assert_equal expected, actual
@@ -1742,12 +2108,16 @@ EOS
1742
2108
  actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
1743
2109
  expected = <<-EOS
1744
2110
  \\begin{reviewwarning}
2111
+
1745
2112
  A
1746
2113
 
1747
2114
  B
2115
+
1748
2116
  \\end{reviewwarning}
1749
2117
  \\begin{reviewwarning}[caption]
2118
+
1750
2119
  A
2120
+
1751
2121
  \\end{reviewwarning}
1752
2122
  EOS
1753
2123
  assert_equal expected, actual
@@ -1755,17 +2125,173 @@ EOS
1755
2125
  actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
1756
2126
  expected = <<-EOS
1757
2127
  \\begin{reviewtip}
2128
+
1758
2129
  A
1759
2130
 
1760
2131
  B
2132
+
1761
2133
  \\end{reviewtip}
1762
2134
  \\begin{reviewtip}[caption]
2135
+
1763
2136
  A
2137
+
1764
2138
  \\end{reviewtip}
1765
2139
  EOS
1766
2140
  assert_equal expected, actual
1767
2141
  end
1768
2142
 
2143
+ def test_minicolumn_blocks
2144
+ %w[note memo tip info warning important caution notice].each do |type|
2145
+ src = <<-EOS
2146
+ //#{type}[#{type}1]{
2147
+
2148
+ //}
2149
+
2150
+ //#{type}[#{type}2]{
2151
+ //}
2152
+ EOS
2153
+
2154
+ expected = <<-EOS
2155
+ \\begin{review#{type}}[#{type}1]
2156
+ \\end{review#{type}}
2157
+ \\begin{review#{type}}[#{type}2]
2158
+ \\end{review#{type}}
2159
+ EOS
2160
+ assert_equal expected, compile_block(src)
2161
+
2162
+ src = <<-EOS
2163
+ //#{type}[#{type}2]{
2164
+
2165
+ //}
2166
+
2167
+ //#{type}[#{type}3]{
2168
+
2169
+ //}
2170
+
2171
+ //#{type}[#{type}4]{
2172
+
2173
+ //}
2174
+
2175
+ //#{type}[#{type}5]{
2176
+
2177
+ //}
2178
+
2179
+ //#{type}[#{type}6]{
2180
+
2181
+ //}
2182
+ EOS
2183
+
2184
+ expected = <<-EOS
2185
+ \\begin{review#{type}}[#{type}2]
2186
+ \\end{review#{type}}
2187
+ \\begin{review#{type}}[#{type}3]
2188
+ \\end{review#{type}}
2189
+ \\begin{review#{type}}[#{type}4]
2190
+ \\end{review#{type}}
2191
+ \\begin{review#{type}}[#{type}5]
2192
+ \\end{review#{type}}
2193
+ \\begin{review#{type}}[#{type}6]
2194
+ \\end{review#{type}}
2195
+ EOS
2196
+ assert_equal expected, compile_block(src)
2197
+
2198
+ src = <<-EOS
2199
+ //#{type}{
2200
+
2201
+ * A
2202
+
2203
+ 1. B
2204
+
2205
+ //}
2206
+
2207
+ //#{type}[OMITEND1]{
2208
+
2209
+ //emlist{
2210
+ LIST
2211
+ //}
2212
+
2213
+ //}
2214
+ //#{type}[OMITEND2]{
2215
+ //}
2216
+ EOS
2217
+
2218
+ expected = <<-EOS
2219
+ \\begin{review#{type}}
2220
+
2221
+ \\begin{itemize}
2222
+ \\item A
2223
+ \\end{itemize}
2224
+
2225
+ \\begin{enumerate}
2226
+ \\item B
2227
+ \\end{enumerate}
2228
+
2229
+ \\end{review#{type}}
2230
+ \\begin{review#{type}}[OMITEND1]
2231
+
2232
+ \\begin{reviewlistblock}
2233
+ \\begin{reviewemlist}
2234
+ LIST
2235
+ \\end{reviewemlist}
2236
+ \\end{reviewlistblock}
2237
+
2238
+ \\end{review#{type}}
2239
+ \\begin{review#{type}}[OMITEND2]
2240
+ \\end{review#{type}}
2241
+ EOS
2242
+ assert_equal expected, compile_block(src)
2243
+ end
2244
+ end
2245
+
2246
+ def test_minicolumn_blocks_nest_error1
2247
+ %w[note memo tip info warning important caution notice].each do |type|
2248
+ @builder.doc_status.clear
2249
+ src = <<-EOS
2250
+ //#{type}{
2251
+
2252
+ //#{type}{
2253
+ //}
2254
+
2255
+ //}
2256
+ EOS
2257
+ assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
2258
+ assert_match(/minicolumn cannot be nested:/, @log_io.string)
2259
+ end
2260
+ end
2261
+
2262
+ def test_minicolumn_blocks_nest_error2
2263
+ %w[note memo tip info warning important caution notice].each do |type|
2264
+ @builder.doc_status.clear
2265
+ src = <<-EOS
2266
+ //#{type}{
2267
+
2268
+ //#{type}{
2269
+
2270
+ //}
2271
+
2272
+ //}
2273
+ EOS
2274
+ assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
2275
+ assert_match(/minicolumn cannot be nested:/, @log_io.string)
2276
+ end
2277
+ end
2278
+
2279
+ def test_minicolumn_blocks_nest_error3
2280
+ %w[memo tip info warning important caution notice].each do |type|
2281
+ @builder.doc_status.clear
2282
+ src = <<-EOS
2283
+ //#{type}{
2284
+
2285
+ //note{
2286
+ //}
2287
+
2288
+ //}
2289
+ EOS
2290
+ assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
2291
+ assert_match(/minicolumn cannot be nested:/, @log_io.string)
2292
+ end
2293
+ end
2294
+
1769
2295
  def test_inline_raw0
1770
2296
  assert_equal 'normal', compile_inline('@<raw>{normal}')
1771
2297
  end
@@ -1891,7 +2417,7 @@ EOB
1891
2417
  @book.config['words_file'] = File.join(dir, 'words.csv')
1892
2418
 
1893
2419
  io = StringIO.new
1894
- @builder.instance_eval{ @logger = ReVIEW::Logger.new(io) }
2420
+ @builder.instance_eval { @logger = ReVIEW::Logger.new(io) }
1895
2421
  actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
1896
2422
  expected = <<-EOS
1897
2423
 
@@ -1903,19 +2429,25 @@ EOS
1903
2429
  end
1904
2430
 
1905
2431
  def test_inline_unknown
1906
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<img>{n}\n" }
1907
- assert_equal ':1: error: unknown image: n', e.message
1908
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<fn>{n}\n" }
1909
- assert_equal ':1: error: unknown footnote: n', e.message
1910
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<hd>{n}\n" }
1911
- assert_equal ':1: error: unknown headline: n', e.message
2432
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
2433
+ assert_match(/unknown image: n/, @log_io.string)
2434
+
2435
+ @log_io.string = ''
2436
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
2437
+ assert_match(/unknown footnote: n/, @log_io.string)
2438
+
2439
+ @log_io.string = ''
2440
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
2441
+ assert_match(/unknown headline: n/, @log_io.string)
1912
2442
  %w[list table column].each do |name|
1913
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<#{name}>{n}\n" }
1914
- assert_equal ":1: error: unknown #{name}: n", e.message
2443
+ @log_io.string = ''
2444
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
2445
+ assert_match(/unknown #{name}: n/, @log_io.string)
1915
2446
  end
1916
2447
  %w[chap chapref title].each do |name|
1917
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<#{name}>{n}\n" }
1918
- assert_equal ':1: error: key not found: "n"', e.message
2448
+ @log_io.string = ''
2449
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
2450
+ assert_match(/key not found: "n"/, @log_io.string)
1919
2451
  end
1920
2452
  end
1921
2453
 
@@ -2042,5 +2574,344 @@ e=mc^2
2042
2574
  EOS
2043
2575
  actual = compile_block(src)
2044
2576
  assert_equal expected, actual
2577
+
2578
+ @config['caption_position']['equation'] = 'bottom'
2579
+ expected = <<-EOS
2580
+
2581
+ \\reviewequationref{1.1}
2582
+
2583
+ \\begin{reviewequationblock}
2584
+ \\begin{equation*}
2585
+ e=mc^2
2586
+ \\end{equation*}
2587
+ \\reviewequationcaption{式1.1: The Equivalence of Mass \\reviewit{and} Energy}
2588
+ \\end{reviewequationblock}
2589
+ EOS
2590
+ actual = compile_block(src)
2591
+ assert_equal expected, actual
2592
+ end
2593
+
2594
+ def test_nest_error_close1
2595
+ src = <<-EOS
2596
+ //beginchild
2597
+ EOS
2598
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
2599
+ assert_equal "//beginchild is shown, but previous element isn't ul, ol, or dl", e.message
2600
+ end
2601
+
2602
+ def test_nest_error_close2
2603
+ src = <<-EOS
2604
+ * foo
2605
+
2606
+ //beginchild
2607
+
2608
+ 1. foo
2609
+
2610
+ //beginchild
2611
+
2612
+ : foo
2613
+
2614
+ //beginchild
2615
+ EOS
2616
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
2617
+ assert_equal '//beginchild of dl,ol,ul misses //endchild', e.message
2618
+ end
2619
+
2620
+ def test_nest_error_close3
2621
+ src = <<-EOS
2622
+ * foo
2623
+
2624
+ //beginchild
2625
+
2626
+ 1. foo
2627
+
2628
+ //beginchild
2629
+
2630
+ : foo
2631
+
2632
+ //beginchild
2633
+
2634
+ //endchild
2635
+ EOS
2636
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
2637
+ assert_equal '//beginchild of ol,ul misses //endchild', e.message
2638
+ end
2639
+
2640
+ def test_nest_ul
2641
+ src = <<-EOS
2642
+ * UL1
2643
+
2644
+ //beginchild
2645
+
2646
+ 1. UL1-OL1
2647
+ 2. UL1-OL2
2648
+
2649
+ * UL1-UL1
2650
+ * UL1-UL2
2651
+
2652
+ : UL1-DL1
2653
+ UL1-DD1
2654
+ : UL1-DL2
2655
+ UL1-DD2
2656
+
2657
+ //endchild
2658
+
2659
+ * UL2
2660
+
2661
+ //beginchild
2662
+
2663
+ UL2-PARA
2664
+
2665
+ //endchild
2666
+ EOS
2667
+
2668
+ expected = <<-EOS
2669
+
2670
+ \\begin{itemize}
2671
+ \\item UL1
2672
+
2673
+
2674
+ \\begin{enumerate}
2675
+ \\item UL1{-}OL1
2676
+ \\item UL1{-}OL2
2677
+ \\end{enumerate}
2678
+
2679
+ \\begin{itemize}
2680
+ \\item UL1{-}UL1
2681
+ \\item UL1{-}UL2
2682
+ \\end{itemize}
2683
+
2684
+ \\begin{description}
2685
+ \\item[UL1{-}DL1] \\mbox{} \\\\
2686
+ UL1{-}DD1
2687
+ \\item[UL1{-}DL2] \\mbox{} \\\\
2688
+ UL1{-}DD2
2689
+ \\end{description}
2690
+
2691
+
2692
+ \\item UL2
2693
+
2694
+
2695
+ UL2{-}PARA
2696
+
2697
+ \\end{itemize}
2698
+ EOS
2699
+
2700
+ actual = compile_block(src)
2701
+ assert_equal expected, actual
2702
+ end
2703
+
2704
+ def test_nest_ol
2705
+ src = <<-EOS
2706
+ 1. OL1
2707
+
2708
+ //beginchild
2709
+
2710
+ 1. OL1-OL1
2711
+ 2. OL1-OL2
2712
+
2713
+ * OL1-UL1
2714
+ * OL1-UL2
2715
+
2716
+ : OL1-DL1
2717
+ OL1-DD1
2718
+ : OL1-DL2
2719
+ OL1-DD2
2720
+
2721
+ //endchild
2722
+
2723
+ 2. OL2
2724
+
2725
+ //beginchild
2726
+
2727
+ OL2-PARA
2728
+
2729
+ //endchild
2730
+ EOS
2731
+
2732
+ expected = <<-EOS
2733
+
2734
+ \\begin{enumerate}
2735
+ \\item OL1
2736
+
2737
+
2738
+ \\begin{enumerate}
2739
+ \\item OL1{-}OL1
2740
+ \\item OL1{-}OL2
2741
+ \\end{enumerate}
2742
+
2743
+ \\begin{itemize}
2744
+ \\item OL1{-}UL1
2745
+ \\item OL1{-}UL2
2746
+ \\end{itemize}
2747
+
2748
+ \\begin{description}
2749
+ \\item[OL1{-}DL1] \\mbox{} \\\\
2750
+ OL1{-}DD1
2751
+ \\item[OL1{-}DL2] \\mbox{} \\\\
2752
+ OL1{-}DD2
2753
+ \\end{description}
2754
+
2755
+
2756
+ \\item OL2
2757
+
2758
+
2759
+ OL2{-}PARA
2760
+
2761
+ \\end{enumerate}
2762
+ EOS
2763
+
2764
+ actual = compile_block(src)
2765
+ assert_equal expected, actual
2766
+ end
2767
+
2768
+ def test_nest_dl
2769
+ src = <<-EOS
2770
+ : DL1
2771
+
2772
+ //beginchild
2773
+
2774
+ 1. DL1-OL1
2775
+ 2. DL1-OL2
2776
+
2777
+ * DL1-UL1
2778
+ * DL1-UL2
2779
+
2780
+ : DL1-DL1
2781
+ DL1-DD1
2782
+ : DL1-DL2
2783
+ DL1-DD2
2784
+
2785
+ //endchild
2786
+
2787
+ : DL2
2788
+ DD2
2789
+
2790
+ //beginchild
2791
+
2792
+ * DD2-UL1
2793
+ * DD2-UL2
2794
+
2795
+ DD2-PARA
2796
+
2797
+ //endchild
2798
+ EOS
2799
+
2800
+ expected = <<-EOS
2801
+
2802
+ \\begin{description}
2803
+ \\item[DL1] \\mbox{} \\\\
2804
+
2805
+
2806
+
2807
+ \\begin{enumerate}
2808
+ \\item DL1{-}OL1
2809
+ \\item DL1{-}OL2
2810
+ \\end{enumerate}
2811
+
2812
+ \\begin{itemize}
2813
+ \\item DL1{-}UL1
2814
+ \\item DL1{-}UL2
2815
+ \\end{itemize}
2816
+
2817
+ \\begin{description}
2818
+ \\item[DL1{-}DL1] \\mbox{} \\\\
2819
+ DL1{-}DD1
2820
+ \\item[DL1{-}DL2] \\mbox{} \\\\
2821
+ DL1{-}DD2
2822
+ \\end{description}
2823
+
2824
+
2825
+ \\item[DL2] \\mbox{} \\\\
2826
+ DD2
2827
+
2828
+
2829
+ \\begin{itemize}
2830
+ \\item DD2{-}UL1
2831
+ \\item DD2{-}UL2
2832
+ \\end{itemize}
2833
+
2834
+ DD2{-}PARA
2835
+
2836
+ \\end{description}
2837
+ EOS
2838
+
2839
+ actual = compile_block(src)
2840
+ assert_equal expected, actual
2841
+ end
2842
+
2843
+ def test_nest_multi
2844
+ src = <<-EOS
2845
+ 1. OL1
2846
+
2847
+ //beginchild
2848
+
2849
+ 1. OL1-OL1
2850
+
2851
+ //beginchild
2852
+
2853
+ * OL1-OL1-UL1
2854
+
2855
+ OL1-OL1-PARA
2856
+
2857
+ //endchild
2858
+
2859
+ 2. OL1-OL2
2860
+
2861
+ * OL1-UL1
2862
+
2863
+ //beginchild
2864
+
2865
+ : OL1-UL1-DL1
2866
+ OL1-UL1-DD1
2867
+
2868
+ OL1-UL1-PARA
2869
+
2870
+ //endchild
2871
+
2872
+ * OL1-UL2
2873
+
2874
+ //endchild
2875
+ EOS
2876
+ expected = <<-EOS
2877
+
2878
+ \\begin{enumerate}
2879
+ \\item OL1
2880
+
2881
+
2882
+ \\begin{enumerate}
2883
+ \\item OL1{-}OL1
2884
+
2885
+
2886
+ \\begin{itemize}
2887
+ \\item OL1{-}OL1{-}UL1
2888
+ \\end{itemize}
2889
+
2890
+ OL1{-}OL1{-}PARA
2891
+
2892
+
2893
+ \\item OL1{-}OL2
2894
+ \\end{enumerate}
2895
+
2896
+ \\begin{itemize}
2897
+ \\item OL1{-}UL1
2898
+
2899
+
2900
+ \\begin{description}
2901
+ \\item[OL1{-}UL1{-}DL1] \\mbox{} \\\\
2902
+ OL1{-}UL1{-}DD1
2903
+ \\end{description}
2904
+
2905
+ OL1{-}UL1{-}PARA
2906
+
2907
+
2908
+ \\item OL1{-}UL2
2909
+ \\end{itemize}
2910
+
2911
+ \\end{enumerate}
2912
+ EOS
2913
+
2914
+ actual = compile_block(src)
2915
+ assert_equal expected, actual
2045
2916
  end
2046
2917
  end