review 3.2.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-tex.yml +31 -0
  3. data/.github/workflows/ruby-win.yml +45 -0
  4. data/.github/workflows/ruby.yml +27 -0
  5. data/.rubocop.yml +167 -42
  6. data/.travis.yml +1 -1
  7. data/Dockerfile +21 -5
  8. data/NEWS.ja.md +428 -1
  9. data/NEWS.md +429 -2
  10. data/README.md +11 -7
  11. data/Rakefile +7 -2
  12. data/appveyor.yml +0 -20
  13. data/bin/review +2 -4
  14. data/bin/review-catalog-converter +5 -5
  15. data/bin/review-check +13 -17
  16. data/bin/review-checkdep +3 -6
  17. data/bin/review-compile +13 -22
  18. data/bin/review-epub2html +1 -4
  19. data/bin/review-epubmaker +3 -4
  20. data/bin/review-idgxmlmaker +14 -0
  21. data/bin/review-index +5 -86
  22. data/bin/review-init +1 -4
  23. data/bin/review-pdfmaker +1 -3
  24. data/bin/review-preproc +11 -13
  25. data/bin/review-textmaker +1 -3
  26. data/bin/review-update +1 -4
  27. data/bin/review-validate +7 -7
  28. data/bin/review-vol +5 -82
  29. data/bin/review-webmaker +1 -3
  30. data/doc/config.yml.sample +67 -16
  31. data/doc/config.yml.sample-simple +4 -3
  32. data/doc/format.ja.md +133 -21
  33. data/doc/format.md +135 -34
  34. data/doc/makeindex.ja.md +2 -2
  35. data/doc/pdfmaker.ja.md +43 -1
  36. data/doc/pdfmaker.md +42 -1
  37. data/doc/quickstart.ja.md +55 -25
  38. data/doc/quickstart.md +47 -17
  39. data/lib/review.rb +1 -1
  40. data/lib/review/book.rb +2 -2
  41. data/lib/review/book/base.rb +89 -90
  42. data/lib/review/book/bib.rb +21 -0
  43. data/lib/review/book/book_unit.rb +158 -0
  44. data/lib/review/book/chapter.rb +51 -29
  45. data/lib/review/book/index.rb +42 -248
  46. data/lib/review/book/index/item.rb +46 -0
  47. data/lib/review/book/page_metric.rb +7 -7
  48. data/lib/review/book/part.rb +45 -10
  49. data/lib/review/book/volume.rb +5 -5
  50. data/lib/review/builder.rb +171 -54
  51. data/lib/review/call_hook.rb +20 -0
  52. data/lib/review/catalog.rb +15 -17
  53. data/lib/review/compiler.rb +240 -102
  54. data/lib/review/configure.rb +101 -12
  55. data/lib/review/converter.rb +1 -1
  56. data/lib/review/epub2html.rb +6 -1
  57. data/lib/review/epubmaker.rb +120 -118
  58. data/lib/review/epubmaker/content.rb +113 -0
  59. data/lib/review/epubmaker/epubcommon.rb +372 -0
  60. data/lib/review/epubmaker/epubv2.rb +178 -0
  61. data/lib/review/epubmaker/epubv3.rb +231 -0
  62. data/lib/review/epubmaker/producer.rb +168 -0
  63. data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
  64. data/lib/review/epubmaker/zip_exporter.rb +84 -0
  65. data/lib/review/exception.rb +6 -0
  66. data/lib/review/extentions/string.rb +0 -4
  67. data/lib/review/htmlbuilder.rb +147 -149
  68. data/lib/review/htmlutils.rb +10 -14
  69. data/lib/review/i18n.rb +4 -3
  70. data/lib/review/idgxmlbuilder.rb +229 -103
  71. data/lib/review/idgxmlmaker.rb +188 -0
  72. data/lib/review/img_math.rb +245 -0
  73. data/lib/review/index_builder.rb +654 -0
  74. data/lib/review/init-web/finish.html +10 -0
  75. data/lib/review/init-web/index.html +190 -0
  76. data/lib/review/init-web/review-layout-design.js +691 -0
  77. data/lib/review/init.rb +124 -41
  78. data/lib/review/latexbox.rb +58 -0
  79. data/lib/review/latexbuilder.rb +249 -97
  80. data/lib/review/latexutils.rb +9 -1
  81. data/lib/review/lineinput.rb +113 -3
  82. data/lib/review/logger.rb +43 -8
  83. data/lib/review/makerhelper.rb +13 -186
  84. data/lib/review/markdownbuilder.rb +75 -39
  85. data/lib/review/md2inaobuilder.rb +3 -5
  86. data/lib/review/pdfmaker.rb +88 -83
  87. data/lib/review/plaintextbuilder.rb +158 -83
  88. data/lib/review/preprocessor.rb +30 -24
  89. data/lib/review/rstbuilder.rb +58 -39
  90. data/lib/review/sec_counter.rb +14 -0
  91. data/lib/review/template.rb +6 -0
  92. data/lib/review/textmaker.rb +29 -17
  93. data/lib/review/textutils.rb +68 -2
  94. data/lib/review/tocprinter.rb +242 -97
  95. data/lib/review/topbuilder.rb +147 -61
  96. data/lib/review/update.rb +27 -28
  97. data/lib/review/version.rb +1 -1
  98. data/lib/review/volumeprinter.rb +97 -0
  99. data/lib/review/webmaker.rb +36 -35
  100. data/lib/review/webtocprinter.rb +39 -35
  101. data/lib/review/yamlloader.rb +4 -0
  102. data/review.gemspec +8 -5
  103. data/samples/sample-book/README.md +7 -2
  104. data/samples/sample-book/src/.gitignore +154 -0
  105. data/samples/sample-book/src/config-ebook.yml +4 -0
  106. data/samples/sample-book/src/config-epub2.yml +1 -1
  107. data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
  108. data/samples/sample-book/src/config-jlreq.yml +6 -0
  109. data/samples/sample-book/src/config.yml +3 -3
  110. data/samples/sample-book/src/lib/tasks/review.rake +45 -14
  111. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
  112. data/samples/syntax-book/Gemfile +1 -1
  113. data/samples/syntax-book/ch01.re +3 -1
  114. data/samples/syntax-book/ch02.re +28 -21
  115. data/samples/syntax-book/ch03.re +4 -7
  116. data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
  117. data/samples/syntax-book/config-jlreq.yml +5 -0
  118. data/samples/syntax-book/config-print.yml +3 -0
  119. data/samples/syntax-book/config.yml +1 -1
  120. data/samples/syntax-book/images/img3-2.png +0 -0
  121. data/samples/syntax-book/lib/tasks/review.rake +30 -15
  122. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
  123. data/templates/html/_colophon.html.erb +23 -0
  124. data/templates/html/_colophon_history.html.erb +9 -0
  125. data/templates/html/_cover.html.erb +10 -0
  126. data/templates/html/_part_body.html.erb +6 -0
  127. data/templates/html/_titlepage.html.erb +20 -0
  128. data/templates/html/layout-html5.html.erb +6 -0
  129. data/templates/html/layout-xhtml1.html.erb +6 -0
  130. data/templates/latex/config.erb +45 -27
  131. data/templates/latex/layout.tex.erb +1 -0
  132. data/templates/latex/review-jlreq/README.md +3 -1
  133. data/templates/latex/review-jlreq/review-base.sty +124 -37
  134. data/templates/latex/review-jlreq/review-jlreq.cls +29 -22
  135. data/templates/latex/review-jlreq/review-style.sty +9 -1
  136. data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
  137. data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
  138. data/templates/latex/review-jsbook/README.md +46 -5
  139. data/templates/latex/review-jsbook/review-base.sty +111 -30
  140. data/templates/latex/review-jsbook/review-jsbook.cls +16 -2
  141. data/templates/latex/review-jsbook/review-style.sty +10 -2
  142. data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
  143. data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
  144. data/templates/opf/epubv2.opf.erb +7 -7
  145. data/templates/opf/epubv3.opf.erb +7 -7
  146. data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
  147. data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
  148. data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
  149. data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
  150. data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
  151. data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
  152. data/templates/web/html/layout-html5.html.erb +9 -8
  153. data/templates/web/html/layout-xhtml1.html.erb +6 -0
  154. data/test/assets/header_listener.html +35 -0
  155. data/test/assets/img_math/img1.png +0 -0
  156. data/test/assets/img_math/img2.png +0 -0
  157. data/test/assets/img_math/img3.png +0 -0
  158. data/test/assets/syntax_book_index_detail.txt +58 -0
  159. data/test/assets/test_template.tex +20 -9
  160. data/test/assets/test_template_backmatter.tex +20 -9
  161. data/test/book_test_helper.rb +11 -5
  162. data/test/run_test.rb +1 -1
  163. data/test/test_book.rb +123 -78
  164. data/test/test_book_chapter.rb +99 -56
  165. data/test/test_book_part.rb +3 -3
  166. data/test/test_builder.rb +24 -15
  167. data/test/test_catalog.rb +19 -42
  168. data/test/test_catalog_converter_cmd.rb +1 -1
  169. data/test/test_converter.rb +1 -0
  170. data/test/test_epub3maker.rb +170 -126
  171. data/test/test_epubmaker.rb +249 -129
  172. data/test/test_epubmaker_cmd.rb +16 -9
  173. data/test/test_helper.rb +23 -11
  174. data/test/test_htmlbuilder.rb +1083 -114
  175. data/test/test_htmlutils.rb +0 -12
  176. data/test/test_i18n.rb +37 -37
  177. data/test/test_idgxmlbuilder.rb +627 -27
  178. data/test/test_idgxmlmaker_cmd.rb +50 -0
  179. data/test/test_image_finder.rb +52 -70
  180. data/test/test_img_math.rb +111 -0
  181. data/test/test_index.rb +62 -52
  182. data/test/test_indexbuilder.rb +52 -0
  183. data/test/test_latexbuilder.rb +1189 -59
  184. data/test/test_latexbuilder_v2.rb +74 -34
  185. data/test/test_lineinput.rb +20 -93
  186. data/test/test_logger.rb +17 -4
  187. data/test/test_makerhelper.rb +2 -14
  188. data/test/test_markdownbuilder.rb +77 -4
  189. data/test/test_md2inaobuilder.rb +12 -2
  190. data/test/test_pdfmaker.rb +101 -12
  191. data/test/test_pdfmaker_cmd.rb +102 -8
  192. data/test/test_plaintextbuilder.rb +562 -31
  193. data/test/test_review_ext.rb +2 -1
  194. data/test/test_reviewheaderlistener.rb +49 -0
  195. data/test/test_rstbuilder.rb +58 -5
  196. data/test/test_sec_counter.rb +156 -0
  197. data/test/test_template.rb +12 -2
  198. data/test/test_textmaker_cmd.rb +58 -0
  199. data/test/test_textutils.rb +109 -2
  200. data/test/test_tocprinter.rb +46 -0
  201. data/test/test_topbuilder.rb +400 -17
  202. data/test/test_update.rb +53 -44
  203. data/test/test_webtocprinter.rb +75 -43
  204. data/test/test_yamlloader.rb +13 -0
  205. data/test/test_zip_exporter.rb +5 -6
  206. data/vendor/gentombow/LICENSE +1 -1
  207. data/vendor/gentombow/Makefile +0 -1
  208. data/vendor/gentombow/bounddvi-en.pdf +0 -0
  209. data/vendor/gentombow/bounddvi-en.tex +1 -0
  210. data/vendor/gentombow/bounddvi.pdf +0 -0
  211. data/vendor/gentombow/bounddvi.sty +30 -7
  212. data/vendor/gentombow/bounddvi.tex +1 -0
  213. data/vendor/gentombow/create_archive.sh +1 -0
  214. data/vendor/gentombow/gentombow-ja.pdf +0 -0
  215. data/vendor/gentombow/gentombow-ja.tex +9 -0
  216. data/vendor/gentombow/gentombow.pdf +0 -0
  217. data/vendor/gentombow/gentombow.sty +32 -10
  218. data/vendor/gentombow/gentombow.tex +8 -0
  219. data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
  220. data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
  221. data/vendor/jsclasses/LICENSE +1 -1
  222. data/vendor/jsclasses/Makefile +3 -2
  223. data/vendor/jsclasses/create_archive.sh +5 -5
  224. data/vendor/jsclasses/jis/Makefile +3 -2
  225. data/vendor/jsclasses/jis/jsarticle.cls +74 -31
  226. data/vendor/jsclasses/jis/jsbook.cls +74 -31
  227. data/vendor/jsclasses/jis/jsclasses.dtx +176 -36
  228. data/vendor/jsclasses/jis/jsclasses.ins +15 -5
  229. data/vendor/jsclasses/jis/jslogo.dtx +4 -4
  230. data/vendor/jsclasses/jis/jslogo.ins +9 -0
  231. data/vendor/jsclasses/jis/jslogo.sty +4 -16
  232. data/vendor/jsclasses/jis/jspf.cls +73 -30
  233. data/vendor/jsclasses/jis/jsreport.cls +74 -31
  234. data/vendor/jsclasses/jis/jsverb.ins +9 -0
  235. data/vendor/jsclasses/jis/jsverb.sty +1 -13
  236. data/vendor/jsclasses/jis/kiyou.cls +74 -31
  237. data/vendor/jsclasses/jis/minijs.sty +65 -22
  238. data/vendor/jsclasses/jis/okumacro.dtx +4 -5
  239. data/vendor/jsclasses/jis/okumacro.ins +9 -0
  240. data/vendor/jsclasses/jis/okumacro.sty +4 -17
  241. data/vendor/jsclasses/jis/okuverb.ins +9 -0
  242. data/vendor/jsclasses/jis/okuverb.sty +1 -13
  243. data/vendor/jsclasses/jis/winjis.sty +23 -19
  244. data/vendor/jsclasses/jsarticle.cls +74 -31
  245. data/vendor/jsclasses/jsbook.cls +74 -31
  246. data/vendor/jsclasses/jsclasses.dtx +176 -36
  247. data/vendor/jsclasses/jsclasses.ins +15 -5
  248. data/vendor/jsclasses/jsclasses.pdf +0 -0
  249. data/vendor/jsclasses/jslogo.dtx +4 -4
  250. data/vendor/jsclasses/jslogo.ins +9 -0
  251. data/vendor/jsclasses/jslogo.pdf +0 -0
  252. data/vendor/jsclasses/jslogo.sty +4 -16
  253. data/vendor/jsclasses/jspf.cls +73 -30
  254. data/vendor/jsclasses/jsreport.cls +74 -31
  255. data/vendor/jsclasses/jsverb.ins +9 -0
  256. data/vendor/jsclasses/jsverb.pdf +0 -0
  257. data/vendor/jsclasses/jsverb.sty +1 -13
  258. data/vendor/jsclasses/kiyou.cls +74 -31
  259. data/vendor/jsclasses/minijs.sty +68 -22
  260. data/vendor/jsclasses/okumacro.dtx +4 -5
  261. data/vendor/jsclasses/okumacro.ins +9 -0
  262. data/vendor/jsclasses/okumacro.pdf +0 -0
  263. data/vendor/jsclasses/okumacro.sty +4 -17
  264. data/vendor/jsclasses/okuverb.ins +9 -0
  265. data/vendor/jsclasses/okuverb.pdf +0 -0
  266. data/vendor/jsclasses/okuverb.sty +1 -13
  267. data/vendor/jsclasses/tests/relfont.tex +10 -0
  268. data/vendor/jsclasses/winjis.sty +23 -19
  269. metadata +136 -23
  270. data/.rubocop_todo.yml +0 -7
  271. data/lib/epubmaker.rb +0 -23
  272. data/lib/epubmaker/content.rb +0 -110
  273. data/lib/epubmaker/epubcommon.rb +0 -441
  274. data/lib/epubmaker/epubv2.rb +0 -143
  275. data/lib/epubmaker/epubv3.rb +0 -233
  276. data/lib/epubmaker/producer.rb +0 -375
  277. data/lib/epubmaker/zip_exporter.rb +0 -81
  278. data/lib/lineinput.rb +0 -155
  279. data/lib/review/book/compilable.rb +0 -173
  280. data/lib/review/tocparser.rb +0 -271
  281. data/samples/syntax-book/review-ext.rb +0 -14
  282. data/test/test_tocparser.rb +0 -25
@@ -0,0 +1,52 @@
1
+ require 'test_helper'
2
+ require 'review/builder'
3
+
4
+ require 'review/book'
5
+
6
+ class MockCompiler
7
+ def text(s)
8
+ [:text, s]
9
+ end
10
+ end
11
+
12
+ class IndexBuidlerTest < Test::Unit::TestCase
13
+ include ReVIEW
14
+
15
+ def setup
16
+ @b = IndexBuilder.new
17
+ chap = ReVIEW::Book::Chapter.new(nil, nil, '-', nil)
18
+ @b.bind(MockCompiler.new, chap, nil)
19
+ end
20
+
21
+ def test_initialize
22
+ assert IndexBuilder.new
23
+ end
24
+
25
+ def test_check_id
26
+ io = StringIO.new
27
+ @b.instance_eval { @logger = ReVIEW::Logger.new(io) }
28
+ @b.check_id('ABC')
29
+ assert_match('', io.string)
30
+
31
+ %w(# % \\ { } [ ] ~ / $ ' " | * ? & < > `).each do |c|
32
+ io = StringIO.new
33
+ @b.instance_eval { @logger = ReVIEW::Logger.new(io) }
34
+ @b.check_id("id#{c}")
35
+ assert_match(/deprecated ID: `#{Regexp.escape(c)}` in `id#{Regexp.escape(c)}`/, io.string)
36
+ end
37
+ io = StringIO.new
38
+ @b.instance_eval { @logger = ReVIEW::Logger.new(io) }
39
+ @b.check_id('A B C#')
40
+ assert_match(/deprecated ID: ` ` in `A B C#`/, io.string)
41
+
42
+ io = StringIO.new
43
+ @b.instance_eval { @logger = ReVIEW::Logger.new(io) }
44
+ @b.check_id("A\tB")
45
+ assert_match(/deprecated ID: `\t` in `A\tB`/, io.string)
46
+
47
+ io = StringIO.new
48
+ @b.instance_eval { @logger = ReVIEW::Logger.new(io) }
49
+ @b.check_id('.ABC')
50
+ assert_match(/deprecated ID: `.ABC` begins from `.`/, io.string)
51
+ end
52
+ end
@@ -14,10 +14,10 @@ class LATEXBuidlerTest < Test::Unit::TestCase
14
14
  'secnolevel' => 2, # for IDGXMLBuilder, EPUBBuilder
15
15
  'toclevel' => 2,
16
16
  'stylesheet' => nil, # for EPUBBuilder
17
- 'image_scale2width' => false,
18
17
  'texcommand' => 'uplatex',
19
- 'review_version' => '3'
18
+ 'review_version' => '4'
20
19
  )
20
+ @config['pdfmaker']['image_scale2width'] = nil
21
21
  @book = Book::Base.new
22
22
  @book.config = @config
23
23
  @compiler = ReVIEW::Compiler.new(@builder)
@@ -197,6 +197,16 @@ EOS
197
197
  assert_equal 'abc\\reviewunderline{def}ghi', actual
198
198
  end
199
199
 
200
+ def test_inline_ins
201
+ actual = compile_inline('abc@<ins>{def}ghi')
202
+ assert_equal 'abc\\reviewinsert{def}ghi', actual
203
+ end
204
+
205
+ def test_inline_del
206
+ actual = compile_inline('abc@<del>{def}ghi')
207
+ assert_equal 'abc\\reviewstrike{def}ghi', actual
208
+ end
209
+
200
210
  def test_inline_bou
201
211
  actual = compile_inline('傍点の@<bou>{テスト}です。')
202
212
  assert_equal '傍点の\\reviewbou{テスト}です。', actual
@@ -247,12 +257,18 @@ EOS
247
257
 
248
258
  def test_inline_hd_chap
249
259
  def @chapter.headline_index
250
- items = [Book::HeadlineIndex::Item.new('chap1|test', [1, 1], 'te_st')]
251
- Book::HeadlineIndex.new(items, self)
260
+ item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
261
+ idx = Book::HeadlineIndex.new(self)
262
+ idx.add_item(item)
263
+ idx
252
264
  end
253
265
 
254
266
  @config['secnolevel'] = 3
255
267
  actual = compile_inline('test @<hd>{chap1|test} test2')
268
+ assert_equal 'test \reviewsecref{「1.1.1 te\\textunderscore{}st」}{sec:1-1-1} test2', actual
269
+
270
+ @config['chapterlink'] = nil
271
+ actual = compile_inline('test @<hd>{chap1|test} test2')
256
272
  assert_equal 'test 「1.1.1 te\\textunderscore{}st」 test2', actual
257
273
  end
258
274
 
@@ -282,21 +298,73 @@ EOS
282
298
  end
283
299
 
284
300
  def test_inline_idx_yomi
301
+ require 'nkf'
285
302
  begin
286
303
  require 'MeCab'
287
- require 'nkf'
288
304
  rescue LoadError
289
305
  $stderr.puts 'skip test_inline_idx_yomi (cannot find MeCab)'
290
306
  return true
291
307
  end
292
308
  tmpdir = Dir.mktmpdir
293
- File.write(File.join(tmpdir, 'sample.dic'), "強運\tはーどらっく\n")
309
+ File.write(File.join(tmpdir, 'sample.dic'), "強運\tはーどらっく\nmain(ブロック)\tmain{|}\n")
294
310
  @book.config['pdfmaker']['makeindex'] = true
295
311
  @book.config['pdfmaker']['makeindex_dic'] = "#{tmpdir}/sample.dic"
296
312
  @builder.setup_index
297
313
  actual = compile_inline('@<hidx>{漢字}@<hidx>{強運}@<hidx>{項目@1<<>>項目@2}')
298
- FileUtils.remove_entry_secure(tmpdir)
299
314
  assert_equal %Q(\\index{かんじ@漢字}\\index{はーどらっく@強運}\\index{こうもく"@1@項目"@1!こうもく"@2@項目"@2}), actual
315
+ actual = compile_inline('@<hidx>{main(ブロック)}@<hidx>{あいうえお{\}}')
316
+ FileUtils.remove_entry_secure(tmpdir)
317
+ assert_equal %Q(\\index{main{|}@main(ブロック)}\\index{あいうえお{}@あいうえお\\reviewleftcurlybrace{}\\reviewrightcurlybrace{}}), actual
318
+ end
319
+
320
+ def test_inline_idx_escape
321
+ # as is
322
+ %w[a あ ' ( ) = ` + ; * : , . ? /].each do |c|
323
+ actual = @builder.index(c)
324
+ assert_equal %Q(\\index{#{c}}), actual
325
+ end
326
+ actual = @builder.index('[')
327
+ assert_equal %Q(\\index{[}), actual
328
+ actual = @builder.index(']')
329
+ assert_equal %Q(\\index{]}), actual
330
+
331
+ # escape display string by "
332
+ %w[! " @].each do |c|
333
+ actual = @builder.index(c)
334
+ assert_equal %Q(\\index{"#{c}@"#{c}}), actual
335
+ end
336
+
337
+ # escape display string by \
338
+ %w[# % &].each do |c|
339
+ actual = @builder.index(c)
340
+ assert_equal %Q(\\index{#{c}@\\#{c}}), actual
341
+ end
342
+
343
+ # escape display string by macro
344
+ actual = @builder.index('$')
345
+ assert_equal %Q(\\index{$@\\textdollar{}}), actual
346
+ actual = @builder.index('-')
347
+ assert_equal %Q(\\index{-@{-}}), actual
348
+ actual = @builder.index('~')
349
+ assert_equal %Q(\\index{~@\\textasciitilde{}}), actual
350
+ actual = @builder.index('^')
351
+ assert_equal %Q(\\index{^@\\textasciicircum{}}), actual
352
+ actual = @builder.index('\\')
353
+ assert_equal %Q(\\index{\\@\\reviewbackslash{}}), actual
354
+ actual = @builder.index('<')
355
+ assert_equal %Q(\\index{<@\\textless{}}), actual
356
+ actual = @builder.index('>')
357
+ assert_equal %Q(\\index{>@\\textgreater{}}), actual
358
+ actual = @builder.index('_')
359
+ assert_equal %Q(\\index{_@\\textunderscore{}}), actual
360
+
361
+ # escape both sort key and display string
362
+ actual = @builder.index('{')
363
+ assert_equal %Q(\\index{{@\\reviewleftcurlybrace{}}), actual
364
+ actual = @builder.index('|')
365
+ assert_equal %Q(\\index{|@\\textbar{}}), actual
366
+ actual = @builder.index('}')
367
+ assert_equal %Q(\\index{}@\\reviewrightcurlybrace{}}), actual
300
368
  end
301
369
 
302
370
  def test_jis_x_0201_kana
@@ -307,7 +375,7 @@ EOS
307
375
  end
308
376
 
309
377
  def test_dlist
310
- actual = compile_block(": foo\n foo.\n bar.\n")
378
+ actual = compile_block(" : foo\n foo.\n bar.\n")
311
379
  expected = <<-EOS
312
380
 
313
381
  \\begin{description}
@@ -315,12 +383,23 @@ EOS
315
383
  foo.
316
384
  bar.
317
385
  \\end{description}
386
+ EOS
387
+ assert_equal expected, actual
388
+
389
+ @book.config['join_lines_by_lang'] = true
390
+ actual = compile_block(" : foo\n foo.\n bar.\n")
391
+ expected = <<-EOS
392
+
393
+ \\begin{description}
394
+ \\item[foo] \\mbox{} \\\\
395
+ foo. bar.
396
+ \\end{description}
318
397
  EOS
319
398
  assert_equal expected, actual
320
399
  end
321
400
 
322
401
  def test_dlist_with_bracket
323
- actual = compile_block(": foo[bar]\n foo.\n bar.\n")
402
+ actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
324
403
  expected = <<-EOS
325
404
 
326
405
  \\begin{description}
@@ -328,6 +407,17 @@ EOS
328
407
  foo.
329
408
  bar.
330
409
  \\end{description}
410
+ EOS
411
+ assert_equal expected, actual
412
+
413
+ @book.config['join_lines_by_lang'] = true
414
+ actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
415
+ expected = <<-EOS
416
+
417
+ \\begin{description}
418
+ \\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\
419
+ foo. bar.
420
+ \\end{description}
331
421
  EOS
332
422
  assert_equal expected, actual
333
423
  end
@@ -364,6 +454,19 @@ EOS
364
454
  assert_equal expected, actual
365
455
  end
366
456
 
457
+ def test_dt_inline
458
+ actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
459
+
460
+ expected = <<-EOS
461
+
462
+ \\begin{description}
463
+ \\item[foo\\protect\\footnotemark{}\\lbrack{}\\rbrack{}\\textless{}\\textgreater{}\\&$\\alpha\\lbrack{}\\rbrack{}$] \\mbox{} \\\\
464
+
465
+ \\end{description}
466
+ EOS
467
+ assert_equal expected, actual
468
+ end
469
+
367
470
  def test_cmd
368
471
  actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
369
472
  expected = <<-EOS
@@ -393,6 +496,22 @@ bar
393
496
  buz
394
497
  \\end{reviewcmd}
395
498
  \\end{reviewlistblock}
499
+ EOS
500
+ assert_equal expected, actual
501
+
502
+ @config['caption_position']['list'] = 'bottom'
503
+ actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
504
+ expected = <<-EOS
505
+
506
+ \\begin{reviewlistblock}
507
+ \\begin{reviewcmd}
508
+ foo
509
+ bar
510
+
511
+ buz
512
+ \\end{reviewcmd}
513
+ \\reviewcmdcaption{cap1}
514
+ \\end{reviewlistblock}
396
515
  EOS
397
516
  assert_equal expected, actual
398
517
  end
@@ -468,6 +587,22 @@ bar
468
587
  buz
469
588
  \\end{reviewemlist}
470
589
  \\end{reviewlistblock}
590
+ EOS
591
+ assert_equal expected, actual
592
+
593
+ @config['caption_position']['list'] = 'bottom'
594
+ actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
595
+ expected = <<-EOS
596
+
597
+ \\begin{reviewlistblock}
598
+ \\begin{reviewemlist}
599
+ foo
600
+ bar
601
+
602
+ buz
603
+ \\end{reviewemlist}
604
+ \\reviewemlistcaption{cap1}
605
+ \\end{reviewlistblock}
471
606
  EOS
472
607
  assert_equal expected, actual
473
608
  end
@@ -534,6 +669,22 @@ EOS
534
669
  4: buz
535
670
  \\end{reviewemlist}
536
671
  \\end{reviewlistblock}
672
+ EOS
673
+ assert_equal expected, actual
674
+
675
+ @config['caption_position']['list'] = 'bottom'
676
+ actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
677
+ expected = <<-EOS
678
+
679
+ \\begin{reviewlistblock}
680
+ \\begin{reviewemlist}
681
+ 1: foo
682
+ 2: bar
683
+ 3:
684
+ 4: buz
685
+ \\end{reviewemlist}
686
+ \\reviewemlistcaption{cap1}
687
+ \\end{reviewlistblock}
537
688
  EOS
538
689
  assert_equal expected, actual
539
690
  end
@@ -550,6 +701,21 @@ bar
550
701
  buz
551
702
  \\end{reviewlist}
552
703
  \\end{reviewlistblock}
704
+ EOS
705
+ assert_equal expected, actual
706
+
707
+ @config['caption_position']['list'] = 'bottom'
708
+ actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
709
+ expected = <<-EOS
710
+ \\begin{reviewlistblock}
711
+ \\begin{reviewlist}
712
+ foo
713
+ bar
714
+
715
+ buz
716
+ \\end{reviewlist}
717
+ \\reviewlistcaption{リスト1.1: cap1}
718
+ \\end{reviewlistblock}
553
719
  EOS
554
720
  assert_equal expected, actual
555
721
  end
@@ -562,6 +728,16 @@ EOS
562
728
  \\begin{reviewlistlst}[caption={cap1},language={sql}]
563
729
  SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
564
730
  \\end{reviewlistlst}
731
+ EOS
732
+ assert_equal expected, actual
733
+
734
+ @config['caption_position']['list'] = 'bottom'
735
+ # XXX: caption_position won't work with highlight
736
+ actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
737
+ expected = <<-EOS
738
+ \\begin{reviewlistlst}[caption={cap1},language={sql}]
739
+ SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
740
+ \\end{reviewlistlst}
565
741
  EOS
566
742
  assert_equal expected, actual
567
743
  end
@@ -594,6 +770,24 @@ EOS
594
770
  7: end
595
771
  \\end{reviewlist}
596
772
  \\end{reviewlistblock}
773
+ EOS
774
+ assert_equal expected, actual
775
+
776
+ @config['caption_position']['list'] = 'bottom'
777
+ actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
778
+ expected = <<-EOS
779
+ \\begin{reviewlistblock}
780
+ \\begin{reviewlist}
781
+ 1: class Foo
782
+ 2: def foo
783
+ 3: bar
784
+ 4:
785
+ 5: buz
786
+ 6: end
787
+ 7: end
788
+ \\end{reviewlist}
789
+ \\reviewlistcaption{リスト1.1: ruby}
790
+ \\end{reviewlistblock}
597
791
  EOS
598
792
  assert_equal expected, actual
599
793
  end
@@ -631,6 +825,22 @@ class Foo
631
825
  end
632
826
  end
633
827
  \\end{reviewlistnumlst}
828
+ EOS
829
+ assert_equal expected, actual
830
+
831
+ @config['caption_position']['list'] = 'bottom'
832
+ # XXX: caption_position won't work with highlight
833
+ actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
834
+ expected = <<-EOS
835
+ \\begin{reviewlistnumlst}[caption={ruby},language={}]
836
+ class Foo
837
+ def foo
838
+ bar
839
+
840
+ buz
841
+ end
842
+ end
843
+ \\end{reviewlistnumlst}
634
844
  EOS
635
845
  assert_equal expected, actual
636
846
  end
@@ -665,6 +875,21 @@ bar
665
875
  buz
666
876
  \\end{reviewsource}
667
877
  \\end{reviewlistblock}
878
+ EOS
879
+ assert_equal expected, actual
880
+
881
+ @config['caption_position']['list'] = 'bottom'
882
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
883
+ expected = <<-EOS
884
+ \\begin{reviewlistblock}
885
+ \\begin{reviewsource}
886
+ foo
887
+ bar
888
+
889
+ buz
890
+ \\end{reviewsource}
891
+ \\reviewsourcecaption{foo/bar/test.rb}
892
+ \\end{reviewlistblock}
668
893
  EOS
669
894
  assert_equal expected, actual
670
895
  end
@@ -693,6 +918,19 @@ EOS
693
918
  foo
694
919
  bar
695
920
 
921
+ buz
922
+ \\end{reviewsourcelst}
923
+ EOS
924
+ assert_equal expected, actual
925
+
926
+ @config['caption_position']['list'] = 'bottom'
927
+ # XXX: caption_position won't work with highlight
928
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
929
+ expected = <<-EOS
930
+ \\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]
931
+ foo
932
+ bar
933
+
696
934
  buz
697
935
  \\end{reviewsourcelst}
698
936
  EOS
@@ -706,6 +944,18 @@ EOS
706
944
  \\begin{quote}
707
945
  foobar
708
946
 
947
+ buz
948
+ \\end{quote}
949
+ EOS
950
+ assert_equal expected, actual
951
+
952
+ @book.config['join_lines_by_lang'] = true
953
+ actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
954
+ expected = <<-EOS
955
+
956
+ \\begin{quote}
957
+ foo bar
958
+
709
959
  buz
710
960
  \\end{quote}
711
961
  EOS
@@ -716,9 +966,11 @@ EOS
716
966
  actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
717
967
  expected = <<-EOS
718
968
  \\begin{reviewmemo}[this is \\reviewbold{test}\\textless{}\\&\\textgreater{}\\textunderscore{}]
969
+
719
970
  test1
720
971
 
721
972
  test\\reviewit{2}
973
+
722
974
  \\end{reviewmemo}
723
975
  EOS
724
976
  assert_equal expected, actual
@@ -731,6 +983,18 @@ EOS
731
983
  \\begin{flushright}
732
984
  foobar
733
985
 
986
+ buz
987
+ \\end{flushright}
988
+ EOS
989
+ assert_equal expected, actual
990
+
991
+ @book.config['join_lines_by_lang'] = true
992
+ actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
993
+ expected = <<-EOS
994
+
995
+ \\begin{flushright}
996
+ foo bar
997
+
734
998
  buz
735
999
  \\end{flushright}
736
1000
  EOS
@@ -744,6 +1008,18 @@ EOS
744
1008
  \\begin{center}
745
1009
  foobar
746
1010
 
1011
+ buz
1012
+ \\end{center}
1013
+ EOS
1014
+ assert_equal expected, actual
1015
+
1016
+ @book.config['join_lines_by_lang'] = true
1017
+ actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
1018
+ expected = <<-EOS
1019
+
1020
+ \\begin{center}
1021
+ foo bar
1022
+
747
1023
  buz
748
1024
  \\end{center}
749
1025
  EOS
@@ -769,13 +1045,23 @@ bar
769
1045
 
770
1046
  foo2
771
1047
  bar2
1048
+ EOS
1049
+ assert_equal expected, actual
1050
+
1051
+ @book.config['join_lines_by_lang'] = true
1052
+ actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
1053
+ expected = <<-EOS
1054
+ \\noindent
1055
+ foo bar
1056
+
1057
+ foo2 bar2
772
1058
  EOS
773
1059
  assert_equal expected, actual
774
1060
  end
775
1061
 
776
1062
  def test_image
777
1063
  def @chapter.image(_id)
778
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1064
+ item = Book::Index::Item.new('sampleimg', 1)
779
1065
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
780
1066
  item
781
1067
  end
@@ -789,11 +1075,50 @@ EOS
789
1075
  \\end{reviewimage}
790
1076
  EOS
791
1077
  assert_equal expected, actual
1078
+
1079
+ @book.config['pdfmaker']['use_original_image_size'] = true
1080
+ actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
1081
+ expected = <<-EOS
1082
+ \\begin{reviewimage}%%sampleimg
1083
+ \\reviewincludegraphics[ ]{./images/chap1-sampleimg.png}
1084
+ \\reviewimagecaption{sample photo}
1085
+ \\label{image:chap1:sampleimg}
1086
+ \\end{reviewimage}
1087
+ EOS
1088
+ assert_equal expected, actual
1089
+
1090
+ actual = compile_block("//image[sampleimg][sample photo][]{\n//}\n")
1091
+ assert_equal expected, actual
1092
+
1093
+ @book.config['pdfmaker']['use_original_image_size'] = nil
1094
+ @config['caption_position']['image'] = 'top'
1095
+ actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
1096
+ expected = <<-EOS
1097
+ \\begin{reviewimage}%%sampleimg
1098
+ \\reviewimagecaption{sample photo}
1099
+ \\label{image:chap1:sampleimg}
1100
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1101
+ \\end{reviewimage}
1102
+ EOS
1103
+ assert_equal expected, actual
1104
+
1105
+ actual = compile_block("//image[sampleimg][]{\n//}\n")
1106
+ expected = <<-EOS
1107
+ \\begin{reviewimage}%%sampleimg
1108
+ \\reviewimagecaption{}
1109
+ \\label{image:chap1:sampleimg}
1110
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1111
+ \\end{reviewimage}
1112
+ EOS
1113
+ assert_equal expected, actual
1114
+
1115
+ actual = compile_block("//image[sampleimg][][]{\n//}\n")
1116
+ assert_equal expected, actual
792
1117
  end
793
1118
 
794
1119
  def test_image_with_metric
795
1120
  def @chapter.image(_id)
796
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1121
+ item = Book::Index::Item.new('sampleimg', 1)
797
1122
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
798
1123
  item
799
1124
  end
@@ -807,16 +1132,20 @@ EOS
807
1132
  \\end{reviewimage}
808
1133
  EOS
809
1134
  assert_equal expected, actual
1135
+
1136
+ @book.config['pdfmaker']['use_original_image_size'] = true
1137
+ actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
1138
+ assert_equal expected, actual
810
1139
  end
811
1140
 
812
1141
  def test_image_with_metric_width
813
1142
  def @chapter.image(_id)
814
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1143
+ item = Book::Index::Item.new('sampleimg', 1)
815
1144
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
816
1145
  item
817
1146
  end
818
1147
 
819
- @config['image_scale2width'] = true
1148
+ @config['pdfmaker']['image_scale2width'] = true
820
1149
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
821
1150
  expected = <<-EOS
822
1151
  \\begin{reviewimage}%%sampleimg
@@ -826,11 +1155,15 @@ EOS
826
1155
  \\end{reviewimage}
827
1156
  EOS
828
1157
  assert_equal expected, actual
1158
+
1159
+ @book.config['pdfmaker']['use_original_image_size'] = true
1160
+ actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
1161
+ assert_equal expected, actual
829
1162
  end
830
1163
 
831
1164
  def test_image_with_metric2
832
1165
  def @chapter.image(_id)
833
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1166
+ item = Book::Index::Item.new('sampleimg', 1)
834
1167
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
835
1168
  item
836
1169
  end
@@ -844,16 +1177,20 @@ EOS
844
1177
  \\end{reviewimage}
845
1178
  EOS
846
1179
  assert_equal expected, actual
1180
+
1181
+ @book.config['pdfmaker']['use_original_image_size'] = true
1182
+ actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
1183
+ assert_equal expected, actual
847
1184
  end
848
1185
 
849
1186
  def test_image_with_metric2_width
850
1187
  def @chapter.image(_id)
851
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1188
+ item = Book::Index::Item.new('sampleimg', 1)
852
1189
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
853
1190
  item
854
1191
  end
855
1192
 
856
- @config['image_scale2width'] = true
1193
+ @config['pdfmaker']['image_scale2width'] = true
857
1194
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
858
1195
  expected = <<-EOS
859
1196
  \\begin{reviewimage}%%sampleimg
@@ -863,11 +1200,15 @@ EOS
863
1200
  \\end{reviewimage}
864
1201
  EOS
865
1202
  assert_equal expected, actual
1203
+
1204
+ @book.config['pdfmaker']['use_original_image_size'] = true
1205
+ actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
1206
+ assert_equal expected, actual
866
1207
  end
867
1208
 
868
1209
  def test_indepimage
869
1210
  def @chapter.image(_id)
870
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1211
+ item = Book::Index::Item.new('sampleimg', 1)
871
1212
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
872
1213
  item
873
1214
  end
@@ -880,28 +1221,58 @@ EOS
880
1221
  \\end{reviewimage}
881
1222
  EOS
882
1223
  assert_equal expected, actual
883
- end
884
-
885
- def test_indepimage_without_caption
886
- def @chapter.image(_id)
887
- item = Book::ImageIndex::Item.new('sampleimg', 1)
888
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
889
- item
890
- end
891
1224
 
892
- # FIXME: indepimage's caption should not be with a counter.
893
- actual = compile_block("//indepimage[sampleimg]\n")
1225
+ @book.config['pdfmaker']['use_original_image_size'] = true
1226
+ actual = compile_block("//indepimage[sampleimg][sample photo]\n")
1227
+ expected = <<-EOS
1228
+ \\begin{reviewimage}%%sampleimg
1229
+ \\reviewincludegraphics[ ]{./images/chap1-sampleimg.png}
1230
+ \\reviewindepimagecaption{図: sample photo}
1231
+ \\end{reviewimage}
1232
+ EOS
1233
+ assert_equal expected, actual
1234
+
1235
+ actual = compile_block("//indepimage[sampleimg][sample photo][]\n")
1236
+ assert_equal expected, actual
1237
+
1238
+ @book.config['pdfmaker']['use_original_image_size'] = nil
1239
+ @config['caption_position']['image'] = 'top'
1240
+ actual = compile_block("//indepimage[sampleimg][sample photo]\n")
1241
+ expected = <<-EOS
1242
+ \\begin{reviewimage}%%sampleimg
1243
+ \\reviewindepimagecaption{図: sample photo}
1244
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1245
+ \\end{reviewimage}
1246
+ EOS
1247
+ assert_equal expected, actual
1248
+ end
1249
+
1250
+ def test_indepimage_without_caption
1251
+ def @chapter.image(_id)
1252
+ item = Book::Index::Item.new('sampleimg', 1)
1253
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
1254
+ item
1255
+ end
1256
+
1257
+ # FIXME: indepimage's caption should not be with a counter.
1258
+ actual = compile_block("//indepimage[sampleimg]\n")
894
1259
  expected = <<-EOS
895
1260
  \\begin{reviewimage}%%sampleimg
896
1261
  \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
897
1262
  \\end{reviewimage}
898
1263
  EOS
899
1264
  assert_equal expected, actual
1265
+
1266
+ actual = compile_block("//indepimage[sampleimg][]\n")
1267
+ assert_equal expected, actual
1268
+
1269
+ actual = compile_block("//indepimage[sampleimg][][]\n")
1270
+ assert_equal expected, actual
900
1271
  end
901
1272
 
902
1273
  def test_indepimage_with_metric
903
1274
  def @chapter.image(_id)
904
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1275
+ item = Book::Index::Item.new('sampleimg', 1)
905
1276
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
906
1277
  item
907
1278
  end
@@ -914,16 +1285,20 @@ EOS
914
1285
  \\end{reviewimage}
915
1286
  EOS
916
1287
  assert_equal expected, actual
1288
+
1289
+ @book.config['pdfmaker']['use_original_image_size'] = true
1290
+ actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
1291
+ assert_equal expected, actual
917
1292
  end
918
1293
 
919
1294
  def test_indepimage_with_metric_width
920
1295
  def @chapter.image(_id)
921
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1296
+ item = Book::Index::Item.new('sampleimg', 1)
922
1297
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
923
1298
  item
924
1299
  end
925
1300
 
926
- @config['image_scale2width'] = true
1301
+ @config['pdfmaker']['image_scale2width'] = true
927
1302
  actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
928
1303
  expected = <<-EOS
929
1304
  \\begin{reviewimage}%%sampleimg
@@ -932,11 +1307,15 @@ EOS
932
1307
  \\end{reviewimage}
933
1308
  EOS
934
1309
  assert_equal expected, actual
1310
+
1311
+ @book.config['pdfmaker']['use_original_image_size'] = true
1312
+ actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
1313
+ assert_equal expected, actual
935
1314
  end
936
1315
 
937
1316
  def test_indepimage_with_metric2
938
1317
  def @chapter.image(_id)
939
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1318
+ item = Book::Index::Item.new('sampleimg', 1)
940
1319
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
941
1320
  item
942
1321
  end
@@ -949,11 +1328,15 @@ EOS
949
1328
  \\end{reviewimage}
950
1329
  EOS
951
1330
  assert_equal expected, actual
1331
+
1332
+ @book.config['pdfmaker']['use_original_image_size'] = true
1333
+ actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
1334
+ assert_equal expected, actual
952
1335
  end
953
1336
 
954
1337
  def test_indepimage_without_caption_but_with_metric
955
1338
  def @chapter.image(_id)
956
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1339
+ item = Book::Index::Item.new('sampleimg', 1)
957
1340
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
958
1341
  item
959
1342
  end
@@ -966,6 +1349,35 @@ EOS
966
1349
  \\end{reviewimage}
967
1350
  EOS
968
1351
  assert_equal expected, actual
1352
+
1353
+ @book.config['pdfmaker']['use_original_image_size'] = true
1354
+ actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
1355
+ assert_equal expected, actual
1356
+ end
1357
+
1358
+ def test_indepimage_nofile
1359
+ def @chapter.image(_id)
1360
+ item = Book::Index::Item.new('sample_img_nofile_', 1)
1361
+ item.instance_eval do
1362
+ def path
1363
+ nil
1364
+ end
1365
+ end
1366
+ item
1367
+ end
1368
+
1369
+ io = StringIO.new
1370
+ @builder.instance_eval { @logger = ReVIEW::Logger.new(io) }
1371
+
1372
+ actual = compile_block("//indepimage[sample_img_nofile_][sample photo]\n")
1373
+ expected = <<-EOS
1374
+ \\begin{reviewdummyimage}
1375
+ --[[path = sample\\textunderscore{}img\\textunderscore{}nofile\\textunderscore{} (not exist)]]--
1376
+ \\reviewindepimagecaption{図: sample photo}
1377
+ \\end{reviewdummyimage}
1378
+ EOS
1379
+ assert_equal expected, actual
1380
+ assert_match(/WARN --: :1: image not bound: sample_img_nofile_/, io.string)
969
1381
  end
970
1382
 
971
1383
  def test_table
@@ -990,15 +1402,40 @@ EOS
990
1402
  ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
991
1403
  \\end{reviewtable}
992
1404
  \\end{table}
1405
+ EOS
1406
+ assert_equal expected, actual
1407
+
1408
+ actual = compile_block("//table[foo][]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1409
+ expected = <<-EOS
1410
+ \\begin{reviewtable}{|l|l|}
1411
+ \\hline
1412
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1413
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1414
+ \\end{reviewtable}
1415
+ EOS
1416
+ assert_equal expected, actual
1417
+
1418
+ @config['caption_position']['table'] = 'bottom'
1419
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1420
+ expected = <<-EOS
1421
+ \\begin{table}%%foo
1422
+ \\begin{reviewtable}{|l|l|}
1423
+ \\hline
1424
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1425
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1426
+ \\end{reviewtable}
1427
+ \\reviewtablecaption{FOO}
1428
+ \\label{table:chap1:foo}
1429
+ \\end{table}
993
1430
  EOS
994
1431
  assert_equal expected, actual
995
1432
  end
996
1433
 
997
1434
  def test_empty_table
998
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
1435
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
999
1436
  assert_equal ':2: error: no rows in the table', e.message
1000
1437
 
1001
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
1438
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
1002
1439
  assert_equal ':3: error: no rows in the table', e.message
1003
1440
  end
1004
1441
 
@@ -1096,6 +1533,26 @@ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1096
1533
  \\end{reviewtable}
1097
1534
  \\end{table}
1098
1535
 
1536
+ \\begin{reviewtable}{|l|l|}
1537
+ \\hline
1538
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1539
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1540
+ \\end{reviewtable}
1541
+ EOS
1542
+ assert_equal expected, actual
1543
+
1544
+ @config['caption_position']['table'] = 'bottom'
1545
+ actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1546
+ expected = <<-EOS
1547
+ \\begin{table}%%
1548
+ \\begin{reviewtable}{|l|l|}
1549
+ \\hline
1550
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1551
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1552
+ \\end{reviewtable}
1553
+ \\reviewtablecaption*{foo}
1554
+ \\end{table}
1555
+
1099
1556
  \\begin{reviewtable}{|l|l|}
1100
1557
  \\hline
1101
1558
  \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
@@ -1107,7 +1564,7 @@ EOS
1107
1564
 
1108
1565
  def test_imgtable
1109
1566
  def @chapter.image(_id)
1110
- item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample img')
1567
+ item = Book::Index::Item.new('sampleimg', 1, 'sample img')
1111
1568
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
1112
1569
  item
1113
1570
  end
@@ -1122,13 +1579,127 @@ EOS
1122
1579
  \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1123
1580
  \\end{reviewimage}
1124
1581
  \\end{table}
1582
+ EOS
1583
+ assert_equal expected, actual
1584
+
1585
+ actual = compile_block("//imgtable[sampleimg][]{\n//}\n")
1586
+ expected = <<-EOS
1587
+ \\label{table:chap1:sampleimg}
1588
+ \\begin{reviewimage}%%sampleimg
1589
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1590
+ \\end{reviewimage}
1591
+ EOS
1592
+ assert_equal expected, actual
1593
+
1594
+ actual = compile_block("//imgtable[sampleimg][][]{\n//}\n")
1595
+ assert_equal expected, actual
1596
+
1597
+ @book.config['pdfmaker']['use_original_image_size'] = true
1598
+ actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
1599
+
1600
+ expected = <<-EOS
1601
+ \\begin{table}[h]%%sampleimg
1602
+ \\reviewimgtablecaption{test for imgtable}
1603
+ \\label{table:chap1:sampleimg}
1604
+ \\begin{reviewimage}%%sampleimg
1605
+ \\reviewincludegraphics[ ]{./images/chap1-sampleimg.png}
1606
+ \\end{reviewimage}
1607
+ \\end{table}
1608
+ EOS
1609
+ assert_equal expected, actual
1610
+
1611
+ actual = compile_block("//imgtable[sampleimg][test for imgtable][]{\n//}\n")
1612
+ assert_equal expected, actual
1613
+
1614
+ @book.config['pdfmaker']['use_original_image_size'] = nil
1615
+ @config['caption_position']['table'] = 'bottom'
1616
+ actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
1617
+
1618
+ expected = <<-EOS
1619
+ \\begin{table}[h]%%sampleimg
1620
+ \\label{table:chap1:sampleimg}
1621
+ \\begin{reviewimage}%%sampleimg
1622
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1623
+ \\end{reviewimage}
1624
+ \\reviewimgtablecaption{test for imgtable}
1625
+ \\end{table}
1626
+ EOS
1627
+ assert_equal expected, actual
1628
+ end
1629
+
1630
+ def test_imgtable_with_metrics
1631
+ def @chapter.image(_id)
1632
+ item = Book::Index::Item.new('sampleimg', 1, 'sample img')
1633
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
1634
+ item
1635
+ end
1636
+
1637
+ actual = compile_block("//imgtable[sampleimg][test for imgtable][scale=1.2]{\n//}\n")
1638
+ expected = <<-EOS
1639
+ \\begin{table}[h]%%sampleimg
1640
+ \\reviewimgtablecaption{test for imgtable}
1641
+ \\label{table:chap1:sampleimg}
1642
+ \\begin{reviewimage}%%sampleimg
1643
+ \\reviewincludegraphics[scale=1.2]{./images/chap1-sampleimg.png}
1644
+ \\end{reviewimage}
1645
+ \\end{table}
1646
+ EOS
1647
+ assert_equal expected, actual
1648
+
1649
+ @book.config['pdfmaker']['use_original_image_size'] = true
1650
+ actual = compile_block("//imgtable[sampleimg][test for imgtable][scale=1.2]{\n//}\n")
1651
+ assert_equal expected, actual
1652
+ end
1653
+
1654
+ def test_table_row_separator
1655
+ src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
1656
+ expected = <<-EOS
1657
+ \\begin{reviewtable}{|l|l|l|}
1658
+ \\hline
1659
+ \\reviewth{1} & \\reviewth{2} & \\reviewth{3 4\\textbar{} 5} \\\\ \\hline
1660
+ a b & c d \\textbar{}e & \\\\ \\hline
1661
+ \\end{reviewtable}
1662
+ EOS
1663
+ actual = compile_block(src)
1664
+ assert_equal expected, actual
1665
+
1666
+ @config['table_row_separator'] = 'singletab'
1667
+ actual = compile_block(src)
1668
+ expected = <<-EOS
1669
+ \\begin{reviewtable}{|l|l|l|l|}
1670
+ \\hline
1671
+ \\reviewth{1} & \\reviewth{2} & \\reviewth{} & \\reviewth{3 4\\textbar{} 5} \\\\ \\hline
1672
+ a b & c d \\textbar{}e & & \\\\ \\hline
1673
+ \\end{reviewtable}
1674
+ EOS
1675
+ assert_equal expected, actual
1676
+
1677
+ @config['table_row_separator'] = 'spaces'
1678
+ actual = compile_block(src)
1679
+ expected = <<-EOS
1680
+ \\begin{reviewtable}{|l|l|l|l|l|}
1681
+ \\hline
1682
+ \\reviewth{1} & \\reviewth{2} & \\reviewth{3} & \\reviewth{4\\textbar{}} & \\reviewth{5} \\\\ \\hline
1683
+ a & b & c & d & \\textbar{}e \\\\ \\hline
1684
+ \\end{reviewtable}
1685
+ EOS
1686
+ assert_equal expected, actual
1687
+
1688
+ @config['table_row_separator'] = 'verticalbar'
1689
+ actual = compile_block(src)
1690
+ expected = <<-EOS
1691
+ \\begin{reviewtable}{|l|l|}
1692
+ \\hline
1693
+ \\reviewth{1 2 3 4} & \\reviewth{5} \\\\ \\hline
1694
+ a b c d & e \\\\ \\hline
1695
+ \\end{reviewtable}
1125
1696
  EOS
1126
1697
  assert_equal expected, actual
1127
1698
  end
1128
1699
 
1129
1700
  def test_bib
1130
1701
  def @chapter.bibpaper(_id)
1131
- Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
1702
+ Book::Index::Item.new('samplebib', 1, 'sample bib')
1132
1703
  end
1133
1704
 
1134
1705
  assert_equal '\\reviewbibref{[1]}{bib:samplebib}', compile_inline('@<bib>{samplebib}')
@@ -1136,7 +1707,7 @@ EOS
1136
1707
 
1137
1708
  def test_bibpaper
1138
1709
  def @chapter.bibpaper(_id)
1139
- Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
1710
+ Book::Index::Item.new('samplebib', 1, 'sample bib')
1140
1711
  end
1141
1712
 
1142
1713
  actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
@@ -1146,13 +1717,24 @@ EOS
1146
1717
 
1147
1718
  ab
1148
1719
 
1720
+ EOS
1721
+ assert_equal expected, actual
1722
+
1723
+ @book.config['join_lines_by_lang'] = true
1724
+ actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
1725
+ expected = <<-EOS
1726
+ [1] sample bib \\reviewbold{bold}
1727
+ \\label{bib:samplebib}
1728
+
1729
+ a b
1730
+
1149
1731
  EOS
1150
1732
  assert_equal expected, actual
1151
1733
  end
1152
1734
 
1153
1735
  def test_bibpaper_without_body
1154
1736
  def @chapter.bibpaper(_id)
1155
- Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
1737
+ Book::Index::Item.new('samplebib', 1, 'sample bib')
1156
1738
  end
1157
1739
 
1158
1740
  actual = compile_block("//bibpaper[samplebib][sample bib]\n")
@@ -1284,6 +1866,17 @@ EOS
1284
1866
  \\item BBB
1285
1867
  {-}BB
1286
1868
  \\end{itemize}
1869
+ EOS
1870
+ actual = compile_block(src)
1871
+ assert_equal expected, actual
1872
+
1873
+ @book.config['join_lines_by_lang'] = true
1874
+ expected = <<-EOS
1875
+
1876
+ \\begin{itemize}
1877
+ \\item AAA {-}AA
1878
+ \\item BBB {-}BB
1879
+ \\end{itemize}
1287
1880
  EOS
1288
1881
  actual = compile_block(src)
1289
1882
  assert_equal expected, actual
@@ -1305,6 +1898,20 @@ EOS
1305
1898
  1\\\\
1306
1899
  {-}BB
1307
1900
  \\end{itemize}
1901
+ EOS
1902
+ actual = compile_block(src)
1903
+ assert_equal expected, actual
1904
+
1905
+ @book.config['join_lines_by_lang'] = true
1906
+ expected = <<-EOS
1907
+
1908
+ \\begin{itemize}
1909
+ \\item AAA\\\\
1910
+ {-}AA
1911
+ \\item BBB\\\\
1912
+ 1\\\\
1913
+ {-}BB
1914
+ \\end{itemize}
1308
1915
  EOS
1309
1916
  actual = compile_block(src)
1310
1917
  assert_equal expected, actual
@@ -1397,12 +2004,16 @@ EOS
1397
2004
  actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
1398
2005
  expected = <<-EOS
1399
2006
  \\begin{reviewnote}
2007
+
1400
2008
  A
1401
2009
 
1402
2010
  B
2011
+
1403
2012
  \\end{reviewnote}
1404
2013
  \\begin{reviewnote}[caption]
2014
+
1405
2015
  A
2016
+
1406
2017
  \\end{reviewnote}
1407
2018
  EOS
1408
2019
  assert_equal expected, actual
@@ -1410,12 +2021,16 @@ EOS
1410
2021
  actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
1411
2022
  expected = <<-EOS
1412
2023
  \\begin{reviewmemo}
2024
+
1413
2025
  A
1414
2026
 
1415
2027
  B
2028
+
1416
2029
  \\end{reviewmemo}
1417
2030
  \\begin{reviewmemo}[caption]
2031
+
1418
2032
  A
2033
+
1419
2034
  \\end{reviewmemo}
1420
2035
  EOS
1421
2036
  assert_equal expected, actual
@@ -1423,12 +2038,16 @@ EOS
1423
2038
  actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
1424
2039
  expected = <<-EOS
1425
2040
  \\begin{reviewinfo}
2041
+
1426
2042
  A
1427
2043
 
1428
2044
  B
2045
+
1429
2046
  \\end{reviewinfo}
1430
2047
  \\begin{reviewinfo}[caption]
2048
+
1431
2049
  A
2050
+
1432
2051
  \\end{reviewinfo}
1433
2052
  EOS
1434
2053
  assert_equal expected, actual
@@ -1436,12 +2055,16 @@ EOS
1436
2055
  actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
1437
2056
  expected = <<-EOS
1438
2057
  \\begin{reviewimportant}
2058
+
1439
2059
  A
1440
2060
 
1441
2061
  B
2062
+
1442
2063
  \\end{reviewimportant}
1443
2064
  \\begin{reviewimportant}[caption]
2065
+
1444
2066
  A
2067
+
1445
2068
  \\end{reviewimportant}
1446
2069
  EOS
1447
2070
  assert_equal expected, actual
@@ -1449,12 +2072,16 @@ EOS
1449
2072
  actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
1450
2073
  expected = <<-EOS
1451
2074
  \\begin{reviewcaution}
2075
+
1452
2076
  A
1453
2077
 
1454
2078
  B
2079
+
1455
2080
  \\end{reviewcaution}
1456
2081
  \\begin{reviewcaution}[caption]
2082
+
1457
2083
  A
2084
+
1458
2085
  \\end{reviewcaution}
1459
2086
  EOS
1460
2087
  assert_equal expected, actual
@@ -1462,12 +2089,16 @@ EOS
1462
2089
  actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
1463
2090
  expected = <<-EOS
1464
2091
  \\begin{reviewnotice}
2092
+
1465
2093
  A
1466
2094
 
1467
2095
  B
2096
+
1468
2097
  \\end{reviewnotice}
1469
2098
  \\begin{reviewnotice}[caption]
2099
+
1470
2100
  A
2101
+
1471
2102
  \\end{reviewnotice}
1472
2103
  EOS
1473
2104
  assert_equal expected, actual
@@ -1475,12 +2106,16 @@ EOS
1475
2106
  actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
1476
2107
  expected = <<-EOS
1477
2108
  \\begin{reviewwarning}
2109
+
1478
2110
  A
1479
2111
 
1480
2112
  B
2113
+
1481
2114
  \\end{reviewwarning}
1482
2115
  \\begin{reviewwarning}[caption]
2116
+
1483
2117
  A
2118
+
1484
2119
  \\end{reviewwarning}
1485
2120
  EOS
1486
2121
  assert_equal expected, actual
@@ -1488,28 +2123,184 @@ EOS
1488
2123
  actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
1489
2124
  expected = <<-EOS
1490
2125
  \\begin{reviewtip}
2126
+
1491
2127
  A
1492
2128
 
1493
2129
  B
2130
+
1494
2131
  \\end{reviewtip}
1495
2132
  \\begin{reviewtip}[caption]
2133
+
1496
2134
  A
2135
+
1497
2136
  \\end{reviewtip}
1498
2137
  EOS
1499
2138
  assert_equal expected, actual
1500
2139
  end
1501
2140
 
1502
- def test_inline_raw0
1503
- assert_equal 'normal', compile_inline('@<raw>{normal}')
1504
- end
2141
+ def test_minicolumn_blocks
2142
+ %w[note memo tip info warning important caution notice].each do |type|
2143
+ src = <<-EOS
2144
+ //#{type}[#{type}1]{
1505
2145
 
1506
- def test_inline_raw1
1507
- assert_equal 'body', compile_inline('@<raw>{|latex|body}')
1508
- end
2146
+ //}
1509
2147
 
1510
- def test_inline_raw2
1511
- assert_equal 'body', compile_inline('@<raw>{|html, latex|body}')
1512
- end
2148
+ //#{type}[#{type}2]{
2149
+ //}
2150
+ EOS
2151
+
2152
+ expected = <<-EOS
2153
+ \\begin{review#{type}}[#{type}1]
2154
+ \\end{review#{type}}
2155
+ \\begin{review#{type}}[#{type}2]
2156
+ \\end{review#{type}}
2157
+ EOS
2158
+ assert_equal expected, compile_block(src)
2159
+
2160
+ src = <<-EOS
2161
+ //#{type}[#{type}2]{
2162
+
2163
+ //}
2164
+
2165
+ //#{type}[#{type}3]{
2166
+
2167
+ //}
2168
+
2169
+ //#{type}[#{type}4]{
2170
+
2171
+ //}
2172
+
2173
+ //#{type}[#{type}5]{
2174
+
2175
+ //}
2176
+
2177
+ //#{type}[#{type}6]{
2178
+
2179
+ //}
2180
+ EOS
2181
+
2182
+ expected = <<-EOS
2183
+ \\begin{review#{type}}[#{type}2]
2184
+ \\end{review#{type}}
2185
+ \\begin{review#{type}}[#{type}3]
2186
+ \\end{review#{type}}
2187
+ \\begin{review#{type}}[#{type}4]
2188
+ \\end{review#{type}}
2189
+ \\begin{review#{type}}[#{type}5]
2190
+ \\end{review#{type}}
2191
+ \\begin{review#{type}}[#{type}6]
2192
+ \\end{review#{type}}
2193
+ EOS
2194
+ assert_equal expected, compile_block(src)
2195
+
2196
+ src = <<-EOS
2197
+ //#{type}{
2198
+
2199
+ * A
2200
+
2201
+ 1. B
2202
+
2203
+ //}
2204
+
2205
+ //#{type}[OMITEND1]{
2206
+
2207
+ //emlist{
2208
+ LIST
2209
+ //}
2210
+
2211
+ //}
2212
+ //#{type}[OMITEND2]{
2213
+ //}
2214
+ EOS
2215
+
2216
+ expected = <<-EOS
2217
+ \\begin{review#{type}}
2218
+
2219
+ \\begin{itemize}
2220
+ \\item A
2221
+ \\end{itemize}
2222
+
2223
+ \\begin{enumerate}
2224
+ \\item B
2225
+ \\end{enumerate}
2226
+
2227
+ \\end{review#{type}}
2228
+ \\begin{review#{type}}[OMITEND1]
2229
+
2230
+ \\begin{reviewlistblock}
2231
+ \\begin{reviewemlist}
2232
+ LIST
2233
+ \\end{reviewemlist}
2234
+ \\end{reviewlistblock}
2235
+
2236
+ \\end{review#{type}}
2237
+ \\begin{review#{type}}[OMITEND2]
2238
+ \\end{review#{type}}
2239
+ EOS
2240
+ assert_equal expected, compile_block(src)
2241
+ end
2242
+ end
2243
+
2244
+ def test_minicolumn_blocks_nest_error1
2245
+ %w[note memo tip info warning important caution notice].each do |type|
2246
+ @builder.doc_status.clear
2247
+ src = <<-EOS
2248
+ //#{type}{
2249
+
2250
+ //#{type}{
2251
+ //}
2252
+
2253
+ //}
2254
+ EOS
2255
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
2256
+ assert_match(/minicolumn cannot be nested:/, e.message)
2257
+ end
2258
+ end
2259
+
2260
+ def test_minicolumn_blocks_nest_error2
2261
+ %w[note memo tip info warning important caution notice].each do |type|
2262
+ @builder.doc_status.clear
2263
+ src = <<-EOS
2264
+ //#{type}{
2265
+
2266
+ //#{type}{
2267
+
2268
+ //}
2269
+
2270
+ //}
2271
+ EOS
2272
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
2273
+ assert_match(/minicolumn cannot be nested:/, e.message)
2274
+ end
2275
+ end
2276
+
2277
+ def test_minicolumn_blocks_nest_error3
2278
+ %w[memo tip info warning important caution notice].each do |type|
2279
+ @builder.doc_status.clear
2280
+ src = <<-EOS
2281
+ //#{type}{
2282
+
2283
+ //note{
2284
+ //}
2285
+
2286
+ //}
2287
+ EOS
2288
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
2289
+ assert_match(/minicolumn cannot be nested:/, e.message)
2290
+ end
2291
+ end
2292
+
2293
+ def test_inline_raw0
2294
+ assert_equal 'normal', compile_inline('@<raw>{normal}')
2295
+ end
2296
+
2297
+ def test_inline_raw1
2298
+ assert_equal 'body', compile_inline('@<raw>{|latex|body}')
2299
+ end
2300
+
2301
+ def test_inline_raw2
2302
+ assert_equal 'body', compile_inline('@<raw>{|html, latex|body}')
2303
+ end
1513
2304
 
1514
2305
  def test_inline_raw3
1515
2306
  assert_equal '', compile_inline('@<raw>{|idgxml, html|body}')
@@ -1530,24 +2321,24 @@ EOS
1530
2321
 
1531
2322
  def test_inline_imgref
1532
2323
  def @chapter.image(_id)
1533
- item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample photo')
2324
+ item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
1534
2325
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
1535
2326
  item
1536
2327
  end
1537
2328
 
1538
- actual = compile_block "@<imgref>{sampleimg}\n"
2329
+ actual = compile_block("@<imgref>{sampleimg}\n")
1539
2330
  expected = "\n\\reviewimageref{1.1}{image:chap1:sampleimg}「sample photo」\n"
1540
2331
  assert_equal expected, actual
1541
2332
  end
1542
2333
 
1543
2334
  def test_inline_imgref2
1544
2335
  def @chapter.image(_id)
1545
- item = Book::NumberlessImageIndex::Item.new('sampleimg', 1)
2336
+ item = Book::Index::Item.new('sampleimg', 1)
1546
2337
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
1547
2338
  item
1548
2339
  end
1549
2340
 
1550
- actual = compile_block "@<imgref>{sampleimg}\n"
2341
+ actual = compile_block("@<imgref>{sampleimg}\n")
1551
2342
  expected = "\n\\reviewimageref{1.1}{image:chap1:sampleimg}\n"
1552
2343
  assert_equal expected, actual
1553
2344
  end
@@ -1624,30 +2415,30 @@ EOB
1624
2415
  @book.config['words_file'] = File.join(dir, 'words.csv')
1625
2416
 
1626
2417
  io = StringIO.new
1627
- @builder.instance_eval{ @logger = ReVIEW::Logger.new(io) }
2418
+ @builder.instance_eval { @logger = ReVIEW::Logger.new(io) }
1628
2419
  actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
1629
2420
  expected = <<-EOS
1630
2421
 
1631
2422
  foo bar"\\reviewbackslash{}\\textless{}\\textgreater{}\\textunderscore{}@\\textless{}b\\textgreater{}\\{BAZ\\} \\reviewbold{bar"\\reviewbackslash{}\\textless{}\\textgreater{}\\textunderscore{}@\\textless{}b\\textgreater{}\\{BAZ\\}} [missing word: N]
1632
2423
  EOS
1633
2424
  assert_equal expected, actual
1634
- assert_match(/WARN -- : :1: word not bound: N/, io.string)
2425
+ assert_match(/WARN --: :1: word not bound: N/, io.string)
1635
2426
  end
1636
2427
  end
1637
2428
 
1638
2429
  def test_inline_unknown
1639
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<img>{n}\n" }
2430
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
1640
2431
  assert_equal ':1: error: unknown image: n', e.message
1641
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<fn>{n}\n" }
2432
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
1642
2433
  assert_equal ':1: error: unknown footnote: n', e.message
1643
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<hd>{n}\n" }
2434
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
1644
2435
  assert_equal ':1: error: unknown headline: n', e.message
1645
2436
  %w[list table column].each do |name|
1646
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<#{name}>{n}\n" }
2437
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
1647
2438
  assert_equal ":1: error: unknown #{name}: n", e.message
1648
2439
  end
1649
2440
  %w[chap chapref title].each do |name|
1650
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<#{name}>{n}\n" }
2441
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
1651
2442
  assert_equal ':1: error: key not found: "n"', e.message
1652
2443
  end
1653
2444
  end
@@ -1714,7 +2505,7 @@ EOS
1714
2505
  end
1715
2506
 
1716
2507
  def @chapter.image(_id)
1717
- item = Book::NumberlessImageIndex::Item.new('sampleimg', 1)
2508
+ item = Book::Index::Item.new('sampleimg', 1)
1718
2509
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
1719
2510
  item
1720
2511
  end
@@ -1775,5 +2566,344 @@ e=mc^2
1775
2566
  EOS
1776
2567
  actual = compile_block(src)
1777
2568
  assert_equal expected, actual
2569
+
2570
+ @config['caption_position']['equation'] = 'bottom'
2571
+ expected = <<-EOS
2572
+
2573
+ \\reviewequationref{1.1}
2574
+
2575
+ \\begin{reviewequationblock}
2576
+ \\begin{equation*}
2577
+ e=mc^2
2578
+ \\end{equation*}
2579
+ \\reviewequationcaption{式1.1: The Equivalence of Mass \\reviewit{and} Energy}
2580
+ \\end{reviewequationblock}
2581
+ EOS
2582
+ actual = compile_block(src)
2583
+ assert_equal expected, actual
2584
+ end
2585
+
2586
+ def test_nest_error_close1
2587
+ src = <<-EOS
2588
+ //beginchild
2589
+ EOS
2590
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
2591
+ assert_equal ":1: error: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
2592
+ end
2593
+
2594
+ def test_nest_error_close2
2595
+ src = <<-EOS
2596
+ * foo
2597
+
2598
+ //beginchild
2599
+
2600
+ 1. foo
2601
+
2602
+ //beginchild
2603
+
2604
+ : foo
2605
+
2606
+ //beginchild
2607
+ EOS
2608
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
2609
+ assert_equal ':12: error: //beginchild of dl,ol,ul misses //endchild', e.message
2610
+ end
2611
+
2612
+ def test_nest_error_close3
2613
+ src = <<-EOS
2614
+ * foo
2615
+
2616
+ //beginchild
2617
+
2618
+ 1. foo
2619
+
2620
+ //beginchild
2621
+
2622
+ : foo
2623
+
2624
+ //beginchild
2625
+
2626
+ //endchild
2627
+ EOS
2628
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
2629
+ assert_equal ':14: error: //beginchild of ol,ul misses //endchild', e.message
2630
+ end
2631
+
2632
+ def test_nest_ul
2633
+ src = <<-EOS
2634
+ * UL1
2635
+
2636
+ //beginchild
2637
+
2638
+ 1. UL1-OL1
2639
+ 2. UL1-OL2
2640
+
2641
+ * UL1-UL1
2642
+ * UL1-UL2
2643
+
2644
+ : UL1-DL1
2645
+ UL1-DD1
2646
+ : UL1-DL2
2647
+ UL1-DD2
2648
+
2649
+ //endchild
2650
+
2651
+ * UL2
2652
+
2653
+ //beginchild
2654
+
2655
+ UL2-PARA
2656
+
2657
+ //endchild
2658
+ EOS
2659
+
2660
+ expected = <<-EOS
2661
+
2662
+ \\begin{itemize}
2663
+ \\item UL1
2664
+
2665
+
2666
+ \\begin{enumerate}
2667
+ \\item UL1{-}OL1
2668
+ \\item UL1{-}OL2
2669
+ \\end{enumerate}
2670
+
2671
+ \\begin{itemize}
2672
+ \\item UL1{-}UL1
2673
+ \\item UL1{-}UL2
2674
+ \\end{itemize}
2675
+
2676
+ \\begin{description}
2677
+ \\item[UL1{-}DL1] \\mbox{} \\\\
2678
+ UL1{-}DD1
2679
+ \\item[UL1{-}DL2] \\mbox{} \\\\
2680
+ UL1{-}DD2
2681
+ \\end{description}
2682
+
2683
+
2684
+ \\item UL2
2685
+
2686
+
2687
+ UL2{-}PARA
2688
+
2689
+ \\end{itemize}
2690
+ EOS
2691
+
2692
+ actual = compile_block(src)
2693
+ assert_equal expected, actual
2694
+ end
2695
+
2696
+ def test_nest_ol
2697
+ src = <<-EOS
2698
+ 1. OL1
2699
+
2700
+ //beginchild
2701
+
2702
+ 1. OL1-OL1
2703
+ 2. OL1-OL2
2704
+
2705
+ * OL1-UL1
2706
+ * OL1-UL2
2707
+
2708
+ : OL1-DL1
2709
+ OL1-DD1
2710
+ : OL1-DL2
2711
+ OL1-DD2
2712
+
2713
+ //endchild
2714
+
2715
+ 2. OL2
2716
+
2717
+ //beginchild
2718
+
2719
+ OL2-PARA
2720
+
2721
+ //endchild
2722
+ EOS
2723
+
2724
+ expected = <<-EOS
2725
+
2726
+ \\begin{enumerate}
2727
+ \\item OL1
2728
+
2729
+
2730
+ \\begin{enumerate}
2731
+ \\item OL1{-}OL1
2732
+ \\item OL1{-}OL2
2733
+ \\end{enumerate}
2734
+
2735
+ \\begin{itemize}
2736
+ \\item OL1{-}UL1
2737
+ \\item OL1{-}UL2
2738
+ \\end{itemize}
2739
+
2740
+ \\begin{description}
2741
+ \\item[OL1{-}DL1] \\mbox{} \\\\
2742
+ OL1{-}DD1
2743
+ \\item[OL1{-}DL2] \\mbox{} \\\\
2744
+ OL1{-}DD2
2745
+ \\end{description}
2746
+
2747
+
2748
+ \\item OL2
2749
+
2750
+
2751
+ OL2{-}PARA
2752
+
2753
+ \\end{enumerate}
2754
+ EOS
2755
+
2756
+ actual = compile_block(src)
2757
+ assert_equal expected, actual
2758
+ end
2759
+
2760
+ def test_nest_dl
2761
+ src = <<-EOS
2762
+ : DL1
2763
+
2764
+ //beginchild
2765
+
2766
+ 1. DL1-OL1
2767
+ 2. DL1-OL2
2768
+
2769
+ * DL1-UL1
2770
+ * DL1-UL2
2771
+
2772
+ : DL1-DL1
2773
+ DL1-DD1
2774
+ : DL1-DL2
2775
+ DL1-DD2
2776
+
2777
+ //endchild
2778
+
2779
+ : DL2
2780
+ DD2
2781
+
2782
+ //beginchild
2783
+
2784
+ * DD2-UL1
2785
+ * DD2-UL2
2786
+
2787
+ DD2-PARA
2788
+
2789
+ //endchild
2790
+ EOS
2791
+
2792
+ expected = <<-EOS
2793
+
2794
+ \\begin{description}
2795
+ \\item[DL1] \\mbox{} \\\\
2796
+
2797
+
2798
+
2799
+ \\begin{enumerate}
2800
+ \\item DL1{-}OL1
2801
+ \\item DL1{-}OL2
2802
+ \\end{enumerate}
2803
+
2804
+ \\begin{itemize}
2805
+ \\item DL1{-}UL1
2806
+ \\item DL1{-}UL2
2807
+ \\end{itemize}
2808
+
2809
+ \\begin{description}
2810
+ \\item[DL1{-}DL1] \\mbox{} \\\\
2811
+ DL1{-}DD1
2812
+ \\item[DL1{-}DL2] \\mbox{} \\\\
2813
+ DL1{-}DD2
2814
+ \\end{description}
2815
+
2816
+
2817
+ \\item[DL2] \\mbox{} \\\\
2818
+ DD2
2819
+
2820
+
2821
+ \\begin{itemize}
2822
+ \\item DD2{-}UL1
2823
+ \\item DD2{-}UL2
2824
+ \\end{itemize}
2825
+
2826
+ DD2{-}PARA
2827
+
2828
+ \\end{description}
2829
+ EOS
2830
+
2831
+ actual = compile_block(src)
2832
+ assert_equal expected, actual
2833
+ end
2834
+
2835
+ def test_nest_multi
2836
+ src = <<-EOS
2837
+ 1. OL1
2838
+
2839
+ //beginchild
2840
+
2841
+ 1. OL1-OL1
2842
+
2843
+ //beginchild
2844
+
2845
+ * OL1-OL1-UL1
2846
+
2847
+ OL1-OL1-PARA
2848
+
2849
+ //endchild
2850
+
2851
+ 2. OL1-OL2
2852
+
2853
+ * OL1-UL1
2854
+
2855
+ //beginchild
2856
+
2857
+ : OL1-UL1-DL1
2858
+ OL1-UL1-DD1
2859
+
2860
+ OL1-UL1-PARA
2861
+
2862
+ //endchild
2863
+
2864
+ * OL1-UL2
2865
+
2866
+ //endchild
2867
+ EOS
2868
+ expected = <<-EOS
2869
+
2870
+ \\begin{enumerate}
2871
+ \\item OL1
2872
+
2873
+
2874
+ \\begin{enumerate}
2875
+ \\item OL1{-}OL1
2876
+
2877
+
2878
+ \\begin{itemize}
2879
+ \\item OL1{-}OL1{-}UL1
2880
+ \\end{itemize}
2881
+
2882
+ OL1{-}OL1{-}PARA
2883
+
2884
+
2885
+ \\item OL1{-}OL2
2886
+ \\end{enumerate}
2887
+
2888
+ \\begin{itemize}
2889
+ \\item OL1{-}UL1
2890
+
2891
+
2892
+ \\begin{description}
2893
+ \\item[OL1{-}UL1{-}DL1] \\mbox{} \\\\
2894
+ OL1{-}UL1{-}DD1
2895
+ \\end{description}
2896
+
2897
+ OL1{-}UL1{-}PARA
2898
+
2899
+
2900
+ \\item OL1{-}UL2
2901
+ \\end{itemize}
2902
+
2903
+ \\end{enumerate}
2904
+ EOS
2905
+
2906
+ actual = compile_block(src)
2907
+ assert_equal expected, actual
1778
2908
  end
1779
2909
  end