review 3.0.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-win.yml +39 -0
  3. data/.github/workflows/ruby.yml +27 -0
  4. data/.rubocop.yml +50 -12
  5. data/.travis.yml +17 -8
  6. data/Dockerfile +21 -5
  7. data/NEWS.ja.md +358 -0
  8. data/NEWS.md +358 -1
  9. data/README.md +11 -8
  10. data/appveyor.yml +1 -3
  11. data/bin/review-catalog-converter +4 -4
  12. data/bin/review-check +8 -8
  13. data/bin/review-checkdep +1 -1
  14. data/bin/review-compile +12 -12
  15. data/bin/review-epubmaker +3 -35
  16. data/bin/review-idgxmlmaker +16 -0
  17. data/bin/review-index +2 -89
  18. data/bin/review-preproc +14 -19
  19. data/bin/review-validate +3 -3
  20. data/bin/review-vol +4 -78
  21. data/doc/LICENSE +1 -1
  22. data/doc/config.yml.sample +46 -12
  23. data/doc/config.yml.sample-simple +4 -2
  24. data/doc/format.ja.md +37 -13
  25. data/doc/format.md +35 -20
  26. data/doc/pdfmaker.ja.md +43 -1
  27. data/doc/pdfmaker.md +42 -1
  28. data/doc/quickstart.ja.md +46 -26
  29. data/doc/quickstart.md +38 -17
  30. data/lib/epubmaker/epubcommon.rb +10 -5
  31. data/lib/epubmaker/epubv2.rb +1 -1
  32. data/lib/epubmaker/epubv3.rb +1 -0
  33. data/lib/epubmaker/producer.rb +4 -2
  34. data/lib/review/book.rb +1 -1
  35. data/lib/review/book/base.rb +38 -79
  36. data/lib/review/book/chapter.rb +18 -3
  37. data/lib/review/book/compilable.rb +6 -5
  38. data/lib/review/book/index.rb +69 -101
  39. data/lib/review/book/index/item.rb +40 -0
  40. data/lib/review/book/page_metric.rb +7 -7
  41. data/lib/review/book/part.rb +28 -5
  42. data/lib/review/book/volume.rb +3 -4
  43. data/lib/review/builder.rb +105 -44
  44. data/lib/review/catalog.rb +13 -16
  45. data/lib/review/compiler.rb +84 -72
  46. data/lib/review/configure.rb +19 -8
  47. data/lib/review/epub2html.rb +37 -4
  48. data/lib/review/epubmaker.rb +62 -7
  49. data/lib/review/extentions/string.rb +0 -4
  50. data/lib/review/htmlbuilder.rb +102 -115
  51. data/lib/review/htmlutils.rb +2 -3
  52. data/lib/review/i18n.rb +2 -2
  53. data/lib/review/i18n.yml +9 -0
  54. data/lib/review/idgxmlbuilder.rb +153 -74
  55. data/lib/review/idgxmlmaker.rb +191 -0
  56. data/lib/review/init-web/finish.html +10 -0
  57. data/lib/review/init-web/index.html +190 -0
  58. data/lib/review/init-web/review-layout-design.js +691 -0
  59. data/lib/review/init.rb +125 -34
  60. data/lib/review/latexbuilder.rb +199 -88
  61. data/lib/review/lineinput.rb +1 -1
  62. data/lib/review/location.rb +32 -0
  63. data/lib/review/logger.rb +4 -8
  64. data/lib/review/makerhelper.rb +24 -5
  65. data/lib/review/markdownbuilder.rb +31 -37
  66. data/lib/review/md2inaobuilder.rb +3 -5
  67. data/lib/review/pdfmaker.rb +44 -22
  68. data/lib/review/plaintextbuilder.rb +106 -85
  69. data/lib/review/preprocessor.rb +32 -41
  70. data/lib/review/rstbuilder.rb +33 -33
  71. data/lib/review/textmaker.rb +19 -3
  72. data/lib/review/textutils.rb +76 -2
  73. data/lib/review/tocprinter.rb +231 -102
  74. data/lib/review/topbuilder.rb +114 -61
  75. data/lib/review/update.rb +19 -19
  76. data/lib/review/version.rb +1 -1
  77. data/lib/review/volumeprinter.rb +99 -0
  78. data/lib/review/webmaker.rb +11 -4
  79. data/lib/review/webtocprinter.rb +38 -35
  80. data/lib/review/yamlloader.rb +26 -16
  81. data/review.gemspec +6 -4
  82. data/samples/sample-book/README.md +7 -2
  83. data/samples/sample-book/src/.gitignore +154 -0
  84. data/samples/sample-book/src/config-ebook.yml +4 -0
  85. data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
  86. data/samples/sample-book/src/config-jlreq.yml +6 -0
  87. data/samples/sample-book/src/config.yml +2 -2
  88. data/samples/sample-book/src/lib/tasks/review.rake +29 -14
  89. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
  90. data/samples/syntax-book/ch01.re +4 -2
  91. data/samples/syntax-book/ch02.re +8 -16
  92. data/samples/syntax-book/ch03.re +3 -6
  93. data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
  94. data/samples/syntax-book/config-jlreq.yml +5 -0
  95. data/samples/syntax-book/config-print.yml +3 -0
  96. data/samples/syntax-book/config.yml +1 -1
  97. data/samples/syntax-book/lib/tasks/review.rake +30 -15
  98. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
  99. data/templates/latex/config.erb +16 -0
  100. data/templates/latex/layout.tex.erb +4 -0
  101. data/templates/latex/review-jlreq/review-base.sty +150 -61
  102. data/templates/latex/review-jlreq/review-jlreq.cls +74 -8
  103. data/templates/latex/review-jlreq/review-style.sty +4 -1
  104. data/templates/latex/review-jsbook/README.md +39 -0
  105. data/templates/latex/review-jsbook/review-base.sty +101 -23
  106. data/templates/latex/review-jsbook/review-jsbook.cls +28 -5
  107. data/templates/latex/review-jsbook/review-style.sty +5 -2
  108. data/templates/opf/epubv3.opf.erb +1 -0
  109. data/templates/web/html/layout-html5.html.erb +2 -2
  110. data/test/assets/test_template.tex +24 -3
  111. data/test/assets/test_template_backmatter.tex +24 -3
  112. data/test/test_book.rb +75 -21
  113. data/test/test_book_chapter.rb +4 -2
  114. data/test/test_book_part.rb +3 -3
  115. data/test/test_builder.rb +16 -0
  116. data/test/test_catalog.rb +24 -42
  117. data/test/test_catalog_converter_cmd.rb +1 -1
  118. data/test/test_epubmaker_cmd.rb +14 -7
  119. data/test/test_helper.rb +15 -7
  120. data/test/test_htmlbuilder.rb +909 -159
  121. data/test/test_i18n.rb +25 -25
  122. data/test/test_idgxmlbuilder.rb +395 -38
  123. data/test/test_idgxmlmaker_cmd.rb +46 -0
  124. data/test/test_image_finder.rb +52 -70
  125. data/test/test_index.rb +50 -10
  126. data/test/test_latexbuilder.rb +1194 -106
  127. data/test/test_latexbuilder_v2.rb +628 -97
  128. data/test/test_logger.rb +14 -1
  129. data/test/test_makerhelper.rb +3 -3
  130. data/test/test_markdownbuilder.rb +134 -16
  131. data/test/test_md2inaobuilder.rb +32 -9
  132. data/test/test_pdfmaker.rb +18 -1
  133. data/test/test_pdfmaker_cmd.rb +100 -6
  134. data/test/test_plaintextbuilder.rb +371 -25
  135. data/test/test_preprocessor.rb +2 -16
  136. data/test/test_rstbuilder.rb +249 -26
  137. data/test/test_textmaker_cmd.rb +54 -0
  138. data/test/test_textutils.rb +109 -2
  139. data/test/test_topbuilder.rb +546 -31
  140. data/test/test_update.rb +17 -8
  141. data/test/test_webtocprinter.rb +66 -34
  142. data/test/test_yamlloader.rb +13 -0
  143. data/vendor/jsclasses/LICENSE +1 -1
  144. data/vendor/jsclasses/jis/jsarticle.cls +53 -14
  145. data/vendor/jsclasses/jis/jsbook.cls +53 -14
  146. data/vendor/jsclasses/jis/jsclasses.dtx +84 -25
  147. data/vendor/jsclasses/jis/jslogo.dtx +4 -4
  148. data/vendor/jsclasses/jis/jslogo.sty +3 -3
  149. data/vendor/jsclasses/jis/jspf.cls +52 -13
  150. data/vendor/jsclasses/jis/jsreport.cls +53 -14
  151. data/vendor/jsclasses/jis/kiyou.cls +53 -14
  152. data/vendor/jsclasses/jis/okumacro.dtx +4 -5
  153. data/vendor/jsclasses/jis/okumacro.sty +3 -4
  154. data/vendor/jsclasses/jsarticle.cls +53 -14
  155. data/vendor/jsclasses/jsbook.cls +53 -14
  156. data/vendor/jsclasses/jsclasses.dtx +84 -25
  157. data/vendor/jsclasses/jsclasses.pdf +0 -0
  158. data/vendor/jsclasses/jslogo.dtx +4 -4
  159. data/vendor/jsclasses/jslogo.pdf +0 -0
  160. data/vendor/jsclasses/jslogo.sty +3 -3
  161. data/vendor/jsclasses/jspf.cls +52 -13
  162. data/vendor/jsclasses/jsreport.cls +53 -14
  163. data/vendor/jsclasses/kiyou.cls +53 -14
  164. data/vendor/jsclasses/okumacro.dtx +4 -5
  165. data/vendor/jsclasses/okumacro.pdf +0 -0
  166. data/vendor/jsclasses/okumacro.sty +3 -4
  167. metadata +55 -10
  168. data/lib/review/tocparser.rb +0 -271
  169. data/samples/syntax-book/review-ext.rb +0 -14
  170. data/test/test_tocparser.rb +0 -25
@@ -0,0 +1,46 @@
1
+ require 'test_helper'
2
+ require 'tmpdir'
3
+ require 'fileutils'
4
+ require 'yaml'
5
+ require 'rbconfig'
6
+ require 'open3'
7
+
8
+ REVIEW_IDGXMLMAKER = File.expand_path('../bin/review-idgxmlmaker', File.dirname(__FILE__))
9
+
10
+ class IDGXMLMakerCmdTest < Test::Unit::TestCase
11
+ def setup
12
+ @tmpdir1 = Dir.mktmpdir
13
+
14
+ @old_rubylib = ENV['RUBYLIB']
15
+ ENV['RUBYLIB'] = File.expand_path('../lib', File.dirname(__FILE__))
16
+ end
17
+
18
+ def teardown
19
+ FileUtils.rm_rf(@tmpdir1)
20
+ ENV['RUBYLIB'] = @old_rubylib
21
+ end
22
+
23
+ def common_buildidgxml(bookdir, configfile, targetfile, option)
24
+ if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
25
+ config = prepare_samplebook(@tmpdir1, bookdir, nil, configfile)
26
+ builddir = File.join(@tmpdir1, config['bookname'] + '-idgxml')
27
+ assert !File.exist?(builddir)
28
+
29
+ ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
30
+ Dir.chdir(@tmpdir1) do
31
+ _o, e, s = Open3.capture3("#{ruby_cmd} -S #{REVIEW_IDGXMLMAKER} #{option} #{configfile}")
32
+ STDERR.puts e unless e.empty?
33
+ assert s.success?
34
+ end
35
+ assert File.exist?(File.join(@tmpdir1, targetfile))
36
+ end
37
+ end
38
+
39
+ def test_idgxmlmaker_cmd_samplebook
40
+ common_buildidgxml('sample-book/src', 'config.yml', 'book-idgxml/ch01.xml', nil)
41
+ end
42
+
43
+ def test_idgxmlmaker_cmd_syntaxbook
44
+ common_buildidgxml('syntax-book', 'config.yml', 'syntax-book-idgxml/ch01.xml', nil)
45
+ end
46
+ end
@@ -7,93 +7,75 @@ class ImageFinderTest < Test::Unit::TestCase
7
7
  include ReVIEW
8
8
 
9
9
  def setup
10
+ if ENV['GITHUB_WORKSPACE']
11
+ ENV['TMPDIR'] = File.join(ENV['GITHUB_WORKSPACE'], 'tmp_review')
12
+ FileUtils.mkdir_p(ENV['TMPDIR'])
13
+ end
14
+ @dir = Dir.mktmpdir
10
15
  end
11
16
 
12
- def test_find_path_pattern1
13
- dir = Dir.mktmpdir
14
- begin
15
- path = File.join(dir, 'builder/ch01/foo.jpg')
16
- FileUtils.mkdir_p(File.dirname(path))
17
- FileUtils.touch(path)
18
-
19
- finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
20
- assert_equal(path, finder.find_path('foo'))
21
- ensure
22
- FileUtils.remove_entry_secure dir
17
+ def teardown
18
+ if @dir
19
+ FileUtils.remove_entry_secure(@dir)
23
20
  end
24
21
  end
25
22
 
23
+ def test_find_path_pattern1
24
+ path = File.join(@dir, 'builder/ch01/foo.jpg')
25
+ FileUtils.mkdir_p(File.dirname(path))
26
+ FileUtils.touch(path)
27
+
28
+ finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
29
+
30
+ assert_equal(path, finder.find_path('foo'))
31
+ end
32
+
26
33
  def test_find_path_pattern2
27
- dir = Dir.mktmpdir
28
- begin
29
- path = File.join(dir, 'builder/ch01-foo.jpg')
30
- FileUtils.mkdir_p(File.dirname(path))
31
- FileUtils.touch(path)
32
-
33
- finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
34
- assert_equal(path, finder.find_path('foo'))
35
- ensure
36
- FileUtils.remove_entry_secure dir
37
- end
34
+ path = File.join(@dir, 'builder/ch01-foo.jpg')
35
+ FileUtils.mkdir_p(File.dirname(path))
36
+ FileUtils.touch(path)
37
+
38
+ finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
39
+ assert_equal(path, finder.find_path('foo'))
38
40
  end
39
41
 
40
42
  def test_find_path_pattern3
41
- dir = Dir.mktmpdir
42
- begin
43
- path = File.join(dir, 'builder/foo.jpg')
44
- FileUtils.mkdir_p(File.dirname(path))
45
- FileUtils.touch(path)
46
-
47
- finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
48
- assert_equal(path, finder.find_path('foo'))
49
- ensure
50
- FileUtils.remove_entry_secure dir
51
- end
43
+ path = File.join(@dir, 'builder/foo.jpg')
44
+ FileUtils.mkdir_p(File.dirname(path))
45
+ FileUtils.touch(path)
46
+
47
+ finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
48
+ assert_equal(path, finder.find_path('foo'))
52
49
  end
53
50
 
54
51
  def test_find_path_pattern4
55
- dir = Dir.mktmpdir
56
- begin
57
- path = File.join(dir, 'ch01/foo.jpg')
58
- FileUtils.mkdir_p(File.dirname(path))
59
- FileUtils.touch(path)
60
-
61
- finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
62
- assert_equal(path, finder.find_path('foo'))
63
- ensure
64
- FileUtils.remove_entry_secure dir
65
- end
52
+ path = File.join(@dir, 'ch01/foo.jpg')
53
+ FileUtils.mkdir_p(File.dirname(path))
54
+ FileUtils.touch(path)
55
+
56
+ finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
57
+ assert_equal(path, finder.find_path('foo'))
66
58
  end
67
59
 
68
60
  def test_find_path_pattern5
69
- dir = Dir.mktmpdir
70
- begin
71
- path = File.join(dir, 'ch01-foo.jpg')
72
- FileUtils.mkdir_p(File.dirname(path))
73
- FileUtils.touch(path)
74
-
75
- finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
76
- assert_equal(path, finder.find_path('foo'))
77
- ensure
78
- FileUtils.remove_entry_secure dir
79
- end
61
+ path = File.join(@dir, 'ch01-foo.jpg')
62
+ FileUtils.mkdir_p(File.dirname(path))
63
+ FileUtils.touch(path)
64
+
65
+ finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
66
+ assert_equal(path, finder.find_path('foo'))
80
67
  end
81
68
 
82
69
  def test_find_path_dir_symlink
83
- dir = Dir.mktmpdir
84
- begin
85
- path_src = File.join(dir, 'src')
86
- path_dst = File.join(dir, 'ch01')
87
- FileUtils.mkdir_p(path_src)
88
- FileUtils.symlink(path_src, path_dst)
89
- path_srcimg = File.join(path_src, 'foo.jpg')
90
- path_dstimg = File.join(path_dst, 'foo.jpg')
91
- FileUtils.touch(path_srcimg)
92
-
93
- finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
94
- assert_equal(path_dstimg, finder.find_path('foo'))
95
- ensure
96
- FileUtils.remove_entry_secure dir
97
- end
70
+ path_src = File.join(@dir, 'src')
71
+ path_dst = File.join(@dir, 'ch01')
72
+ FileUtils.mkdir_p(path_src)
73
+ FileUtils.symlink(path_src, path_dst)
74
+ path_srcimg = File.join(path_src, 'foo.jpg')
75
+ path_dstimg = File.join(path_dst, 'foo.jpg')
76
+ FileUtils.touch(path_srcimg)
77
+
78
+ finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
79
+ assert_equal(path_dstimg, finder.find_path('foo'))
98
80
  end
99
81
  end
@@ -54,7 +54,7 @@ class IndexTest < Test::Unit::TestCase
54
54
  EOB
55
55
  book = Book::Base.load
56
56
  chap = Book::Chapter.new(book, 1, '-', nil) # dummy
57
- index = Book::HeadlineIndex.parse(src, chap)
57
+ index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
58
58
  assert_equal [2, 2], index['sec1-2|sec1-2-2'].number
59
59
  assert_equal '1.2.2', index.number('sec1-2|sec1-2-2')
60
60
  end
@@ -71,7 +71,7 @@ class IndexTest < Test::Unit::TestCase
71
71
  EOB
72
72
  book = Book::Base.load
73
73
  chap = Book::Chapter.new(book, 1, '-', nil) # dummy
74
- index = Book::HeadlineIndex.parse(src, chap)
74
+ index = Book::HeadlineIndex.parse(src.lines, chap)
75
75
  assert_equal [3, 1], index['sec1-3|sec1-3-1'].number
76
76
  assert_equal '1.3.1', index.number('sec1-3|sec1-3-1')
77
77
  end
@@ -89,7 +89,7 @@ class IndexTest < Test::Unit::TestCase
89
89
  EOB
90
90
  book = Book::Base.load
91
91
  chap = Book::Chapter.new(book, 1, '-', nil) # dummy
92
- index = Book::HeadlineIndex.parse(src, chap)
92
+ index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
93
93
  assert_equal [2, 2], index['sec1-2|sec1-2-2'].number
94
94
  assert_equal '1.2.2', index.number('sec1-2|sec1-2-2')
95
95
 
@@ -108,7 +108,7 @@ class IndexTest < Test::Unit::TestCase
108
108
  EOB
109
109
  book = Book::Base.load
110
110
  chap = Book::Chapter.new(book, 1, '-', nil) # dummy
111
- index = Book::HeadlineIndex.parse(src, chap)
111
+ index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
112
112
  assert_equal [2, 2], index['sec1-2|sec1-2-2'].number
113
113
  assert_equal '1.2.2', index.number('sec1-2|sec1-2-2')
114
114
  end
@@ -124,7 +124,7 @@ class IndexTest < Test::Unit::TestCase
124
124
  EOB
125
125
  book = Book::Base.load
126
126
  chap = Book::Chapter.new(book, 1, '-', nil) # dummy
127
- index = Book::HeadlineIndex.parse(src, chap)
127
+ index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
128
128
  assert_equal [2, 2], index['sec1-2-2'].number
129
129
  assert_equal '1.2.2', index.number('sec1-2-2')
130
130
  end
@@ -139,7 +139,7 @@ class IndexTest < Test::Unit::TestCase
139
139
  EOB
140
140
  book = Book::Base.load
141
141
  chap = Book::Chapter.new(book, 1, '-', nil) # dummy
142
- index = Book::HeadlineIndex.parse(src, chap)
142
+ index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
143
143
  assert_equal [1, 1], index['target'].number
144
144
  assert_equal '1.1.1', index.number('target')
145
145
  end
@@ -157,7 +157,7 @@ class IndexTest < Test::Unit::TestCase
157
157
  EOB
158
158
  book = Book::Base.load
159
159
  chap = Book::Chapter.new(book, 1, '-', nil) # dummy
160
- index = Book::HeadlineIndex.parse(src, chap)
160
+ index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
161
161
 
162
162
  assert_raise ReVIEW::KeyError do
163
163
  assert_equal [1, 1], index['target'].number
@@ -174,7 +174,7 @@ class IndexTest < Test::Unit::TestCase
174
174
  EOB
175
175
  book = Book::Base.load
176
176
  chap = Book::Chapter.new(book, 1, '-', nil)
177
- index = Book::HeadlineIndex.parse(src, chap)
177
+ index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
178
178
  assert_equal '1.1.1', index.number('sec1-1')
179
179
  end
180
180
 
@@ -190,7 +190,7 @@ class IndexTest < Test::Unit::TestCase
190
190
  EOB
191
191
  book = Book::Base.load
192
192
  chap = Book::Chapter.new(book, 1, '-', nil)
193
- index = Book::HeadlineIndex.parse(src, chap)
193
+ index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
194
194
  assert_equal [1, 1, 1], index['sec1-1-1'].number
195
195
  end
196
196
 
@@ -205,7 +205,47 @@ class IndexTest < Test::Unit::TestCase
205
205
  EOB
206
206
  book = Book::Base.load
207
207
  chap = Book::Chapter.new(book, 1, '-', nil)
208
- index = Book::HeadlineIndex.parse(src, chap)
208
+ index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
209
209
  assert_equal [1, 1, 1], index['sec1-1-1'].number
210
210
  end
211
+
212
+ def test_headeline_index11
213
+ src = <<-EOB
214
+ = chap1
215
+ ==[nodisp] sec01
216
+ ==[notoc] sec02
217
+ == sec1
218
+ ===[nodisp] sec1-0
219
+ === sec1-1
220
+ ==[nonum] sec03
221
+ == sec04
222
+ EOB
223
+ book = Book::Base.load
224
+ chap = Book::Chapter.new(book, 1, '-', nil)
225
+ index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
226
+ assert_equal nil, index['sec01'].number
227
+ assert_equal nil, index['sec02'].number
228
+ assert_equal [1], index['sec1'].number
229
+ assert_equal nil, index['sec1-0'].number
230
+ assert_equal [1, 1], index['sec1-1'].number
231
+ assert_equal nil, index['sec03'].number
232
+ assert_equal [2], index['sec04'].number
233
+ end
234
+
235
+ def test_headeline_index12
236
+ src = <<-EOB
237
+ = chap1
238
+ == A
239
+ === A2
240
+ ==[nonum] B
241
+ === B2
242
+ EOB
243
+ book = Book::Base.load
244
+ chap = Book::Chapter.new(book, 1, '-', nil)
245
+ index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
246
+ assert_equal [1], index['A'].number
247
+ assert_equal [1, 1], index['A2'].number
248
+ assert_equal nil, index['B'].number
249
+ assert_equal [1, 2], index['B2'].number
250
+ end
211
251
  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)
@@ -39,34 +39,62 @@ class LATEXBuidlerTest < Test::Unit::TestCase
39
39
 
40
40
  def test_headline_level1
41
41
  actual = compile_block("={test} this is test.\n")
42
- assert_equal %Q(\\chapter{this is test.}\n\\label{chap:chap1}\n), actual
42
+ expected = <<-EOS
43
+ \\chapter{this is test.}
44
+ \\label{chap:chap1}
45
+ EOS
46
+ assert_equal expected, actual
43
47
  end
44
48
 
45
49
  def test_headline_level1_without_secno
46
50
  @config['secnolevel'] = 0
47
51
  actual = compile_block("={test} this is test.\n")
48
- assert_equal %Q(\\chapter*{this is test.}\n\\addcontentsline{toc}{chapter}{this is test.}\n\\label{chap:chap1}\n), actual
52
+ expected = <<-EOS
53
+ \\chapter*{this is test.}
54
+ \\addcontentsline{toc}{chapter}{this is test.}
55
+ \\label{chap:chap1}
56
+ EOS
57
+ assert_equal expected, actual
49
58
  end
50
59
 
51
60
  def test_headline_level1_with_inlinetag
52
61
  actual = compile_block(%Q(={test} this @<b>{is} test.<&"_>\n))
53
- assert_equal %Q(\\chapter{this \\reviewbold{is} test.\\textless{}\\&"\\textunderscore{}\\textgreater{}}\n\\label{chap:chap1}\n), actual
62
+ expected = <<-EOS
63
+ \\chapter{this \\reviewbold{is} test.\\textless{}\\&"\\textunderscore{}\\textgreater{}}
64
+ \\label{chap:chap1}
65
+ EOS
66
+ assert_equal expected, actual
54
67
  end
55
68
 
56
69
  def test_headline_level2
57
70
  actual = compile_block("=={test} this is test.\n")
58
- assert_equal %Q(\\section{this is test.}\n\\label{sec:1-1}\n\\label{test}\n), actual
71
+ expected = <<-EOS
72
+ \\section{this is test.}
73
+ \\label{sec:1-1}
74
+ \\label{test}
75
+ EOS
76
+ assert_equal expected, actual
59
77
  end
60
78
 
61
79
  def test_headline_level3
62
80
  actual = compile_block("==={test} this is test.\n")
63
- assert_equal %Q(\\subsection*{this is test.}\n\\label{sec:1-0-1}\n\\label{test}\n), actual
81
+ expected = <<-EOS
82
+ \\subsection*{this is test.}
83
+ \\label{sec:1-0-1}
84
+ \\label{test}
85
+ EOS
86
+ assert_equal expected, actual
64
87
  end
65
88
 
66
89
  def test_headline_level3_with_secno
67
90
  @config['secnolevel'] = 3
68
91
  actual = compile_block("==={test} this is test.\n")
69
- assert_equal %Q(\\subsection{this is test.}\n\\label{sec:1-0-1}\n\\label{test}\n), actual
92
+ expected = <<-EOS
93
+ \\subsection{this is test.}
94
+ \\label{sec:1-0-1}
95
+ \\label{test}
96
+ EOS
97
+ assert_equal expected, actual
70
98
  end
71
99
 
72
100
  def test_label
@@ -169,6 +197,11 @@ class LATEXBuidlerTest < Test::Unit::TestCase
169
197
  assert_equal 'abc\\reviewunderline{def}ghi', actual
170
198
  end
171
199
 
200
+ def test_inline_bou
201
+ actual = compile_inline('傍点の@<bou>{テスト}です。')
202
+ assert_equal '傍点の\\reviewbou{テスト}です。', actual
203
+ end
204
+
172
205
  def test_inline_m
173
206
  @config['review_version'] = '3.0'
174
207
  actual = compile_inline('abc@<m>{\\alpha^n = \\inf < 2}ghi')
@@ -214,8 +247,10 @@ class LATEXBuidlerTest < Test::Unit::TestCase
214
247
 
215
248
  def test_inline_hd_chap
216
249
  def @chapter.headline_index
217
- items = [Book::HeadlineIndex::Item.new('chap1|test', [1, 1], 'te_st')]
218
- Book::HeadlineIndex.new(items, self)
250
+ item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
251
+ idx = Book::HeadlineIndex.new(self)
252
+ idx.add_item(item)
253
+ idx
219
254
  end
220
255
 
221
256
  @config['secnolevel'] = 3
@@ -249,9 +284,9 @@ class LATEXBuidlerTest < Test::Unit::TestCase
249
284
  end
250
285
 
251
286
  def test_inline_idx_yomi
287
+ require 'nkf'
252
288
  begin
253
289
  require 'MeCab'
254
- require 'nkf'
255
290
  rescue LoadError
256
291
  $stderr.puts 'skip test_inline_idx_yomi (cannot find MeCab)'
257
292
  return true
@@ -274,47 +309,191 @@ class LATEXBuidlerTest < Test::Unit::TestCase
274
309
  end
275
310
 
276
311
  def test_dlist
277
- actual = compile_block(": foo\n foo.\n bar.\n")
278
- assert_equal %Q(\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.bar.\n\\end{description}\n), actual
312
+ actual = compile_block(" : foo\n foo.\n bar.\n")
313
+ expected = <<-EOS
314
+
315
+ \\begin{description}
316
+ \\item[foo] \\mbox{} \\\\
317
+ foo.
318
+ bar.
319
+ \\end{description}
320
+ EOS
321
+ assert_equal expected, actual
322
+
323
+ @book.config['join_lines_by_lang'] = true
324
+ actual = compile_block(" : foo\n foo.\n bar.\n")
325
+ expected = <<-EOS
326
+
327
+ \\begin{description}
328
+ \\item[foo] \\mbox{} \\\\
329
+ foo. bar.
330
+ \\end{description}
331
+ EOS
332
+ assert_equal expected, actual
279
333
  end
280
334
 
281
335
  def test_dlist_with_bracket
282
- actual = compile_block(": foo[bar]\n foo.\n bar.\n")
283
- assert_equal %Q(\n\\begin{description}\n\\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\\nfoo.bar.\n\\end{description}\n), actual
336
+ actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
337
+ expected = <<-EOS
338
+
339
+ \\begin{description}
340
+ \\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\
341
+ foo.
342
+ bar.
343
+ \\end{description}
344
+ EOS
345
+ assert_equal expected, actual
346
+
347
+ @book.config['join_lines_by_lang'] = true
348
+ actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
349
+ expected = <<-EOS
350
+
351
+ \\begin{description}
352
+ \\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\
353
+ foo. bar.
354
+ \\end{description}
355
+ EOS
356
+ assert_equal expected, actual
284
357
  end
285
358
 
286
359
  def test_dlist_beforeulol
287
360
  actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
288
- assert_equal %Q(\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\n\\end{description}\n\npara\n\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\n\\end{description}\n\n\\begin{enumerate}\n\\item bar\n\\end{enumerate}\n\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\n\\end{description}\n\n\\begin{itemize}\n\\item bar\n\\end{itemize}\n), actual
361
+ expected = <<-EOS
362
+
363
+ \\begin{description}
364
+ \\item[foo] \\mbox{} \\\\
365
+ foo.
366
+ \\end{description}
367
+
368
+ para
369
+
370
+ \\begin{description}
371
+ \\item[foo] \\mbox{} \\\\
372
+ foo.
373
+ \\end{description}
374
+
375
+ \\begin{enumerate}
376
+ \\item bar
377
+ \\end{enumerate}
378
+
379
+ \\begin{description}
380
+ \\item[foo] \\mbox{} \\\\
381
+ foo.
382
+ \\end{description}
383
+
384
+ \\begin{itemize}
385
+ \\item bar
386
+ \\end{itemize}
387
+ EOS
388
+ assert_equal expected, actual
389
+ end
390
+
391
+ 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")
395
+
396
+ expected = <<-EOS
397
+
398
+ \\begin{description}
399
+ \\item[foo\\protect\\footnotemark{}\\lbrack{}\\rbrack{}\\textless{}\\textgreater{}\\&$\\alpha\\lbrack{}\\rbrack{}$] \\mbox{} \\\\
400
+
401
+ \\end{description}
402
+ EOS
403
+ assert_equal expected, actual
289
404
  end
290
405
 
291
406
  def test_cmd
292
407
  actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
293
- assert_equal %Q(\n\\begin{reviewlistblock}\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n\\end{reviewlistblock}\n), actual
408
+ expected = <<-EOS
409
+
410
+ \\begin{reviewlistblock}
411
+ \\begin{reviewcmd}
412
+ foo
413
+ bar
414
+
415
+ buz
416
+ \\end{reviewcmd}
417
+ \\end{reviewlistblock}
418
+ EOS
419
+ assert_equal expected, actual
294
420
  end
295
421
 
296
422
  def test_cmd_caption
297
423
  actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
298
- assert_equal %Q(\n\\begin{reviewlistblock}\n\\reviewcmdcaption{cap1}\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n\\end{reviewlistblock}\n), actual
424
+ expected = <<-EOS
425
+
426
+ \\begin{reviewlistblock}
427
+ \\reviewcmdcaption{cap1}
428
+ \\begin{reviewcmd}
429
+ foo
430
+ bar
431
+
432
+ buz
433
+ \\end{reviewcmd}
434
+ \\end{reviewlistblock}
435
+ EOS
436
+ assert_equal expected, actual
437
+
438
+ @config['caption_position']['list'] = 'bottom'
439
+ actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
440
+ expected = <<-EOS
441
+
442
+ \\begin{reviewlistblock}
443
+ \\begin{reviewcmd}
444
+ foo
445
+ bar
446
+
447
+ buz
448
+ \\end{reviewcmd}
449
+ \\reviewcmdcaption{cap1}
450
+ \\end{reviewlistblock}
451
+ EOS
452
+ assert_equal expected, actual
299
453
  end
300
454
 
301
455
  def test_cmd_lst
302
456
  @book.config['highlight'] = {}
303
457
  @book.config['highlight']['latex'] = 'listings'
304
458
  actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
305
- assert_equal %Q(\\begin{reviewcmdlst}[language={}]\nfoo\nbar\n\nbuz\n\\end{reviewcmdlst}\n), actual
459
+ expected = <<-EOS
460
+ \\begin{reviewcmdlst}[language={}]
461
+ foo
462
+ bar
463
+
464
+ buz
465
+ \\end{reviewcmdlst}
466
+ EOS
467
+ assert_equal expected, actual
306
468
  end
307
469
 
308
470
  def test_emlist
309
471
  actual = compile_block("//emlist{\nfoo\nbar\n\nbuz\n//}\n")
310
- assert_equal %Q(\n\\begin{reviewlistblock}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n\\end{reviewlistblock}\n), actual
472
+ expected = <<-EOS
473
+
474
+ \\begin{reviewlistblock}
475
+ \\begin{reviewemlist}
476
+ foo
477
+ bar
478
+
479
+ buz
480
+ \\end{reviewemlist}
481
+ \\end{reviewlistblock}
482
+ EOS
483
+ assert_equal expected, actual
311
484
  end
312
485
 
313
486
  def test_emlist_lst
314
487
  @book.config['highlight'] = {}
315
488
  @book.config['highlight']['latex'] = 'listings'
316
489
  actual = compile_block("//emlist[][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
317
- assert_equal %Q(\n\\begin{reviewemlistlst}[language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewemlistlst}\n), actual
490
+ expected = <<-EOS
491
+
492
+ \\begin{reviewemlistlst}[language={sql}]
493
+ SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
494
+ \\end{reviewemlistlst}
495
+ EOS
496
+ assert_equal expected, actual
318
497
  end
319
498
 
320
499
  def test_emlist_lst_without_lang
@@ -322,45 +501,181 @@ class LATEXBuidlerTest < Test::Unit::TestCase
322
501
  @book.config['highlight']['latex'] = 'listings'
323
502
  @book.config['highlight']['lang'] = 'sql'
324
503
  actual = compile_block("//emlist[]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
325
- assert_equal %Q(\n\\begin{reviewemlistlst}[language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewemlistlst}\n), actual
504
+ expected = <<-EOS
505
+
506
+ \\begin{reviewemlistlst}[language={sql}]
507
+ SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
508
+ \\end{reviewemlistlst}
509
+ EOS
510
+ assert_equal expected, actual
326
511
  end
327
512
 
328
513
  def test_emlist_caption
329
514
  actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
330
- assert_equal %Q(\n\\begin{reviewlistblock}\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n\\end{reviewlistblock}\n), actual
515
+ expected = <<-EOS
516
+
517
+ \\begin{reviewlistblock}
518
+ \\reviewemlistcaption{cap1}
519
+ \\begin{reviewemlist}
520
+ foo
521
+ bar
522
+
523
+ buz
524
+ \\end{reviewemlist}
525
+ \\end{reviewlistblock}
526
+ EOS
527
+ assert_equal expected, actual
528
+
529
+ @config['caption_position']['list'] = 'bottom'
530
+ actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
531
+ expected = <<-EOS
532
+
533
+ \\begin{reviewlistblock}
534
+ \\begin{reviewemlist}
535
+ foo
536
+ bar
537
+
538
+ buz
539
+ \\end{reviewemlist}
540
+ \\reviewemlistcaption{cap1}
541
+ \\end{reviewlistblock}
542
+ EOS
543
+ assert_equal expected, actual
331
544
  end
332
545
 
333
546
  def test_emlist_empty_caption
334
547
  actual = compile_block("//emlist[]{\nfoo\nbar\n\nbuz\n//}\n")
335
- assert_equal %Q(\n\\begin{reviewlistblock}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n\\end{reviewlistblock}\n), actual
548
+ expected = <<-EOS
549
+
550
+ \\begin{reviewlistblock}
551
+ \\begin{reviewemlist}
552
+ foo
553
+ bar
554
+
555
+ buz
556
+ \\end{reviewemlist}
557
+ \\end{reviewlistblock}
558
+ EOS
559
+ assert_equal expected, actual
336
560
  end
337
561
 
338
562
  def test_emlist_with_tab
339
563
  actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
340
- assert_equal %Q(\n\\begin{reviewlistblock}\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n\\end{reviewlistblock}\n), actual
564
+ expected = <<-EOS
565
+
566
+ \\begin{reviewlistblock}
567
+ \\begin{reviewemlist}
568
+ foo
569
+ bar
570
+
571
+ buz
572
+ \\end{reviewemlist}
573
+ \\end{reviewlistblock}
574
+ EOS
575
+ assert_equal expected, actual
341
576
  end
342
577
 
343
578
  def test_emlist_with_tab4
344
579
  @config['tabwidth'] = 4
345
580
  actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
346
- assert_equal %Q(\n\\begin{reviewlistblock}\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n\\end{reviewlistblock}\n), actual
581
+ expected = <<-EOS
582
+
583
+ \\begin{reviewlistblock}
584
+ \\begin{reviewemlist}
585
+ foo
586
+ bar
587
+
588
+ buz
589
+ \\end{reviewemlist}
590
+ \\end{reviewlistblock}
591
+ EOS
592
+ assert_equal expected, actual
347
593
  end
348
594
 
349
595
  def test_emlistnum_caption
350
596
  actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
351
- assert_equal %Q(\n\\begin{reviewlistblock}\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\n 1: foo\n 2: bar\n 3: \n 4: buz\n\\end{reviewemlist}\n\\end{reviewlistblock}\n), actual
597
+ expected = <<-EOS
598
+
599
+ \\begin{reviewlistblock}
600
+ \\reviewemlistcaption{cap1}
601
+ \\begin{reviewemlist}
602
+ 1: foo
603
+ 2: bar
604
+ 3:
605
+ 4: buz
606
+ \\end{reviewemlist}
607
+ \\end{reviewlistblock}
608
+ EOS
609
+ assert_equal expected, actual
610
+
611
+ @config['caption_position']['list'] = 'bottom'
612
+ actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
613
+ expected = <<-EOS
614
+
615
+ \\begin{reviewlistblock}
616
+ \\begin{reviewemlist}
617
+ 1: foo
618
+ 2: bar
619
+ 3:
620
+ 4: buz
621
+ \\end{reviewemlist}
622
+ \\reviewemlistcaption{cap1}
623
+ \\end{reviewlistblock}
624
+ EOS
625
+ assert_equal expected, actual
352
626
  end
353
627
 
354
628
  def test_list
355
629
  actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
356
- assert_equal %Q(\\begin{reviewlistblock}\n\\reviewlistcaption{リスト1.1: cap1}\n\\begin{reviewlist}\nfoo\nbar\n\nbuz\n\\end{reviewlist}\n\\end{reviewlistblock}\n), actual
630
+ expected = <<-EOS
631
+ \\begin{reviewlistblock}
632
+ \\reviewlistcaption{リスト1.1: cap1}
633
+ \\begin{reviewlist}
634
+ foo
635
+ bar
636
+
637
+ buz
638
+ \\end{reviewlist}
639
+ \\end{reviewlistblock}
640
+ EOS
641
+ assert_equal expected, actual
642
+
643
+ @config['caption_position']['list'] = 'bottom'
644
+ actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
645
+ expected = <<-EOS
646
+ \\begin{reviewlistblock}
647
+ \\begin{reviewlist}
648
+ foo
649
+ bar
650
+
651
+ buz
652
+ \\end{reviewlist}
653
+ \\reviewlistcaption{リスト1.1: cap1}
654
+ \\end{reviewlistblock}
655
+ EOS
656
+ assert_equal expected, actual
357
657
  end
358
658
 
359
659
  def test_list_lst
360
660
  @book.config['highlight'] = {}
361
661
  @book.config['highlight']['latex'] = 'listings'
362
662
  actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
363
- assert_equal %Q(\\begin{reviewlistlst}[caption={cap1},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewlistlst}\n), actual
663
+ expected = <<-EOS
664
+ \\begin{reviewlistlst}[caption={cap1},language={sql}]
665
+ SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
666
+ \\end{reviewlistlst}
667
+ EOS
668
+ assert_equal expected, actual
669
+
670
+ @config['caption_position']['list'] = 'bottom'
671
+ # XXX: caption_position won't work with highlight
672
+ actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
673
+ expected = <<-EOS
674
+ \\begin{reviewlistlst}[caption={cap1},language={sql}]
675
+ SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
676
+ \\end{reviewlistlst}
677
+ EOS
678
+ assert_equal expected, actual
364
679
  end
365
680
 
366
681
  def test_list_lst_with_lang
@@ -368,227 +683,687 @@ class LATEXBuidlerTest < Test::Unit::TestCase
368
683
  @book.config['highlight']['latex'] = 'listings'
369
684
  @book.config['highlight']['lang'] = 'sql'
370
685
  actual = compile_block("//list[id1][cap1]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
371
- assert_equal %Q(\\begin{reviewlistlst}[caption={cap1},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewlistlst}\n), actual
686
+ expected = <<-EOS
687
+ \\begin{reviewlistlst}[caption={cap1},language={sql}]
688
+ SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
689
+ \\end{reviewlistlst}
690
+ EOS
691
+ assert_equal expected, actual
372
692
  end
373
693
 
374
694
  def test_listnum
375
695
  actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
376
- assert_equal %Q(\\begin{reviewlistblock}\n\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n 1: class Foo\n 2: def foo\n 3: bar\n 4: \n 5: buz\n 6: end\n 7: end\n\\end{reviewlist}\n\\end{reviewlistblock}\n), actual
696
+ expected = <<-EOS
697
+ \\begin{reviewlistblock}
698
+ \\reviewlistcaption{リスト1.1: ruby}
699
+ \\begin{reviewlist}
700
+ 1: class Foo
701
+ 2: def foo
702
+ 3: bar
703
+ 4:
704
+ 5: buz
705
+ 6: end
706
+ 7: end
707
+ \\end{reviewlist}
708
+ \\end{reviewlistblock}
709
+ EOS
710
+ assert_equal expected, actual
711
+
712
+ @config['caption_position']['list'] = 'bottom'
713
+ actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
714
+ expected = <<-EOS
715
+ \\begin{reviewlistblock}
716
+ \\begin{reviewlist}
717
+ 1: class Foo
718
+ 2: def foo
719
+ 3: bar
720
+ 4:
721
+ 5: buz
722
+ 6: end
723
+ 7: end
724
+ \\end{reviewlist}
725
+ \\reviewlistcaption{リスト1.1: ruby}
726
+ \\end{reviewlistblock}
727
+ EOS
728
+ assert_equal expected, actual
377
729
  end
378
730
 
379
731
  def test_listnum_linenum
380
732
  actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
381
- assert_equal %Q(\\begin{reviewlistblock}\n\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n100: class Foo\n101: def foo\n102: bar\n103: \n104: buz\n105: end\n106: end\n\\end{reviewlist}\n\\end{reviewlistblock}\n), actual
733
+ expected = <<-EOS
734
+ \\begin{reviewlistblock}
735
+ \\reviewlistcaption{リスト1.1: ruby}
736
+ \\begin{reviewlist}
737
+ 100: class Foo
738
+ 101: def foo
739
+ 102: bar
740
+ 103:
741
+ 104: buz
742
+ 105: end
743
+ 106: end
744
+ \\end{reviewlist}
745
+ \\end{reviewlistblock}
746
+ EOS
747
+ assert_equal expected, actual
382
748
  end
383
749
 
384
750
  def test_listnum_lst
385
751
  @book.config['highlight'] = {}
386
752
  @book.config['highlight']['latex'] = 'listings'
387
753
  actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
388
- assert_equal %Q(\\begin{reviewlistnumlst}[caption={ruby},language={}]\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n\\end{reviewlistnumlst}\n), actual
754
+ expected = <<-EOS
755
+ \\begin{reviewlistnumlst}[caption={ruby},language={}]
756
+ class Foo
757
+ def foo
758
+ bar
759
+
760
+ buz
761
+ end
762
+ end
763
+ \\end{reviewlistnumlst}
764
+ EOS
765
+ assert_equal expected, actual
766
+
767
+ @config['caption_position']['list'] = 'bottom'
768
+ # XXX: caption_position won't work with highlight
769
+ actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
770
+ expected = <<-EOS
771
+ \\begin{reviewlistnumlst}[caption={ruby},language={}]
772
+ class Foo
773
+ def foo
774
+ bar
775
+
776
+ buz
777
+ end
778
+ end
779
+ \\end{reviewlistnumlst}
780
+ EOS
781
+ assert_equal expected, actual
389
782
  end
390
783
 
391
784
  def test_listnum_lst_linenum
392
785
  @book.config['highlight'] = {}
393
786
  @book.config['highlight']['latex'] = 'listings'
394
787
  actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
395
- assert_equal %Q(\\begin{reviewlistnumlst}[caption={ruby},language={},firstnumber=100]\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n\\end{reviewlistnumlst}\n), actual
788
+ expected = <<-EOS
789
+ \\begin{reviewlistnumlst}[caption={ruby},language={},firstnumber=100]
790
+ class Foo
791
+ def foo
792
+ bar
793
+
794
+ buz
795
+ end
796
+ end
797
+ \\end{reviewlistnumlst}
798
+ EOS
799
+ assert_equal expected, actual
396
800
  end
397
801
 
398
802
  def test_source
399
803
  actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
400
- assert_equal %Q(\\begin{reviewlistblock}\n\\reviewsourcecaption{foo/bar/test.rb}\n\\begin{reviewsource}\nfoo\nbar\n\nbuz\n\\end{reviewsource}\n\\end{reviewlistblock}\n), actual
804
+ expected = <<-EOS
805
+ \\begin{reviewlistblock}
806
+ \\reviewsourcecaption{foo/bar/test.rb}
807
+ \\begin{reviewsource}
808
+ foo
809
+ bar
810
+
811
+ buz
812
+ \\end{reviewsource}
813
+ \\end{reviewlistblock}
814
+ EOS
815
+ assert_equal expected, actual
816
+
817
+ @config['caption_position']['list'] = 'bottom'
818
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
819
+ expected = <<-EOS
820
+ \\begin{reviewlistblock}
821
+ \\begin{reviewsource}
822
+ foo
823
+ bar
824
+
825
+ buz
826
+ \\end{reviewsource}
827
+ \\reviewsourcecaption{foo/bar/test.rb}
828
+ \\end{reviewlistblock}
829
+ EOS
830
+ assert_equal expected, actual
401
831
  end
402
832
 
403
833
  def test_source_empty_caption
404
834
  actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
405
- assert_equal %Q(\\begin{reviewlistblock}\n\\begin{reviewsource}\nfoo\nbar\n\nbuz\n\\end{reviewsource}\n\\end{reviewlistblock}\n), actual
835
+ expected = <<-EOS
836
+ \\begin{reviewlistblock}
837
+ \\begin{reviewsource}
838
+ foo
839
+ bar
840
+
841
+ buz
842
+ \\end{reviewsource}
843
+ \\end{reviewlistblock}
844
+ EOS
845
+ assert_equal expected, actual
406
846
  end
407
847
 
408
848
  def test_source_lst
409
849
  @book.config['highlight'] = {}
410
850
  @book.config['highlight']['latex'] = 'listings'
411
851
  actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
412
- assert_equal %Q(\\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]\nfoo\nbar\n\nbuz\n\\end{reviewsourcelst}\n), actual
852
+ expected = <<-EOS
853
+ \\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]
854
+ foo
855
+ bar
856
+
857
+ buz
858
+ \\end{reviewsourcelst}
859
+ EOS
860
+ assert_equal expected, actual
861
+
862
+ @config['caption_position']['list'] = 'bottom'
863
+ # XXX: caption_position won't work with highlight
864
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
865
+ expected = <<-EOS
866
+ \\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]
867
+ foo
868
+ bar
869
+
870
+ buz
871
+ \\end{reviewsourcelst}
872
+ EOS
873
+ assert_equal expected, actual
413
874
  end
414
875
 
415
876
  def test_quote
416
877
  actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
417
- assert_equal %Q(\n\\begin{quote}\nfoobar\n\nbuz\n\\end{quote}\n), actual
878
+ expected = <<-EOS
879
+
880
+ \\begin{quote}
881
+ foobar
882
+
883
+ buz
884
+ \\end{quote}
885
+ EOS
886
+ assert_equal expected, actual
887
+
888
+ @book.config['join_lines_by_lang'] = true
889
+ actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
890
+ expected = <<-EOS
891
+
892
+ \\begin{quote}
893
+ foo bar
894
+
895
+ buz
896
+ \\end{quote}
897
+ EOS
898
+ assert_equal expected, actual
418
899
  end
419
900
 
420
901
  def test_memo
421
902
  actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
422
- assert_equal %Q(\\begin{reviewmemo}[this is \\reviewbold{test}\\textless{}\\&\\textgreater{}\\textunderscore{}]\ntest1\n\ntest\\reviewit{2}\n\\end{reviewmemo}\n), actual
903
+ expected = <<-EOS
904
+ \\begin{reviewmemo}[this is \\reviewbold{test}\\textless{}\\&\\textgreater{}\\textunderscore{}]
905
+ test1
906
+
907
+ test\\reviewit{2}
908
+ \\end{reviewmemo}
909
+ EOS
910
+ assert_equal expected, actual
423
911
  end
424
912
 
425
913
  def test_flushright
426
914
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
427
- assert_equal %Q(\n\\begin{flushright}\nfoobar\n\nbuz\n\\end{flushright}\n), actual
915
+ expected = <<-EOS
916
+
917
+ \\begin{flushright}
918
+ foobar
919
+
920
+ buz
921
+ \\end{flushright}
922
+ EOS
923
+ assert_equal expected, actual
924
+
925
+ @book.config['join_lines_by_lang'] = true
926
+ actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
927
+ expected = <<-EOS
928
+
929
+ \\begin{flushright}
930
+ foo bar
931
+
932
+ buz
933
+ \\end{flushright}
934
+ EOS
935
+ assert_equal expected, actual
428
936
  end
429
937
 
430
938
  def test_centering
431
939
  actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
432
- assert_equal %Q(\n\\begin{center}\nfoobar\n\nbuz\n\\end{center}\n), actual
940
+ expected = <<-EOS
941
+
942
+ \\begin{center}
943
+ foobar
944
+
945
+ buz
946
+ \\end{center}
947
+ EOS
948
+ assert_equal expected, actual
949
+
950
+ @book.config['join_lines_by_lang'] = true
951
+ actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
952
+ expected = <<-EOS
953
+
954
+ \\begin{center}
955
+ foo bar
956
+
957
+ buz
958
+ \\end{center}
959
+ EOS
960
+ assert_equal expected, actual
433
961
  end
434
962
 
435
963
  def test_blankline
436
964
  actual = compile_block("//blankline\nfoo\n")
437
- assert_equal %Q(\\vspace*{\\baselineskip}\n\nfoo\n), actual
965
+ expected = <<-EOS
966
+ \\vspace*{\\baselineskip}
967
+
968
+ foo
969
+ EOS
970
+ assert_equal expected, actual
438
971
  end
439
972
 
440
973
  def test_noindent
441
974
  actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
442
- assert_equal %Q(\\noindent\nfoo\nbar\n\nfoo2\nbar2\n), actual
975
+ expected = <<-EOS
976
+ \\noindent
977
+ foo
978
+ bar
979
+
980
+ foo2
981
+ bar2
982
+ EOS
983
+ assert_equal expected, actual
984
+
985
+ @book.config['join_lines_by_lang'] = true
986
+ actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
987
+ expected = <<-EOS
988
+ \\noindent
989
+ foo bar
990
+
991
+ foo2 bar2
992
+ EOS
993
+ assert_equal expected, actual
443
994
  end
444
995
 
445
996
  def test_image
446
997
  def @chapter.image(_id)
447
- item = Book::ImageIndex::Item.new('sampleimg', 1)
998
+ item = Book::Index::Item.new('sampleimg', 1)
448
999
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
449
1000
  item
450
1001
  end
451
1002
 
452
1003
  actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
453
- assert_equal %Q(\\begin{reviewimage}%%sampleimg\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
1004
+ expected = <<-EOS
1005
+ \\begin{reviewimage}%%sampleimg
1006
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1007
+ \\reviewimagecaption{sample photo}
1008
+ \\label{image:chap1:sampleimg}
1009
+ \\end{reviewimage}
1010
+ EOS
1011
+ assert_equal expected, actual
1012
+
1013
+ @book.config['pdfmaker']['use_original_image_size'] = true
1014
+ actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
1015
+ expected = <<-EOS
1016
+ \\begin{reviewimage}%%sampleimg
1017
+ \\reviewincludegraphics[ ]{./images/chap1-sampleimg.png}
1018
+ \\reviewimagecaption{sample photo}
1019
+ \\label{image:chap1:sampleimg}
1020
+ \\end{reviewimage}
1021
+ EOS
1022
+ assert_equal expected, actual
1023
+
1024
+ actual = compile_block("//image[sampleimg][sample photo][]{\n//}\n")
1025
+ assert_equal expected, actual
1026
+
1027
+ @book.config['pdfmaker']['use_original_image_size'] = nil
1028
+ @config['caption_position']['image'] = 'top'
1029
+ actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
1030
+ expected = <<-EOS
1031
+ \\begin{reviewimage}%%sampleimg
1032
+ \\reviewimagecaption{sample photo}
1033
+ \\label{image:chap1:sampleimg}
1034
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1035
+ \\end{reviewimage}
1036
+ EOS
1037
+ assert_equal expected, actual
454
1038
  end
455
1039
 
456
1040
  def test_image_with_metric
457
1041
  def @chapter.image(_id)
458
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1042
+ item = Book::Index::Item.new('sampleimg', 1)
459
1043
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
460
1044
  item
461
1045
  end
462
1046
 
463
1047
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
464
- assert_equal %Q(\\begin{reviewimage}%%sampleimg\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
1048
+ expected = <<-EOS
1049
+ \\begin{reviewimage}%%sampleimg
1050
+ \\reviewincludegraphics[scale=1.2]{./images/chap1-sampleimg.png}
1051
+ \\reviewimagecaption{sample photo}
1052
+ \\label{image:chap1:sampleimg}
1053
+ \\end{reviewimage}
1054
+ EOS
1055
+ assert_equal expected, actual
1056
+
1057
+ @book.config['pdfmaker']['use_original_image_size'] = true
1058
+ actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
1059
+ assert_equal expected, actual
465
1060
  end
466
1061
 
467
1062
  def test_image_with_metric_width
468
1063
  def @chapter.image(_id)
469
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1064
+ item = Book::Index::Item.new('sampleimg', 1)
470
1065
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
471
1066
  item
472
1067
  end
473
1068
 
474
- @config['image_scale2width'] = true
1069
+ @config['pdfmaker']['image_scale2width'] = true
1070
+ actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
1071
+ expected = <<-EOS
1072
+ \\begin{reviewimage}%%sampleimg
1073
+ \\reviewincludegraphics[width=1.2\\maxwidth]{./images/chap1-sampleimg.png}
1074
+ \\reviewimagecaption{sample photo}
1075
+ \\label{image:chap1:sampleimg}
1076
+ \\end{reviewimage}
1077
+ EOS
1078
+ assert_equal expected, actual
1079
+
1080
+ @book.config['pdfmaker']['use_original_image_size'] = true
475
1081
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
476
- assert_equal %Q(\\begin{reviewimage}%%sampleimg\n\\includegraphics[width=1.2\\maxwidth]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
1082
+ assert_equal expected, actual
477
1083
  end
478
1084
 
479
1085
  def test_image_with_metric2
480
1086
  def @chapter.image(_id)
481
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1087
+ item = Book::Index::Item.new('sampleimg', 1)
482
1088
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
483
1089
  item
484
1090
  end
485
1091
 
486
1092
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
487
- assert_equal %Q(\\begin{reviewimage}%%sampleimg\n\\includegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
1093
+ expected = <<-EOS
1094
+ \\begin{reviewimage}%%sampleimg
1095
+ \\reviewincludegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}
1096
+ \\reviewimagecaption{sample photo}
1097
+ \\label{image:chap1:sampleimg}
1098
+ \\end{reviewimage}
1099
+ EOS
1100
+ assert_equal expected, actual
1101
+
1102
+ @book.config['pdfmaker']['use_original_image_size'] = true
1103
+ actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
1104
+ assert_equal expected, actual
488
1105
  end
489
1106
 
490
1107
  def test_image_with_metric2_width
491
1108
  def @chapter.image(_id)
492
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1109
+ item = Book::Index::Item.new('sampleimg', 1)
493
1110
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
494
1111
  item
495
1112
  end
496
1113
 
497
- @config['image_scale2width'] = true
1114
+ @config['pdfmaker']['image_scale2width'] = true
498
1115
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
499
- assert_equal %Q(\\begin{reviewimage}%%sampleimg\n\\includegraphics[width=1.2\\maxwidth,ignore=params]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
1116
+ expected = <<-EOS
1117
+ \\begin{reviewimage}%%sampleimg
1118
+ \\reviewincludegraphics[width=1.2\\maxwidth,ignore=params]{./images/chap1-sampleimg.png}
1119
+ \\reviewimagecaption{sample photo}
1120
+ \\label{image:chap1:sampleimg}
1121
+ \\end{reviewimage}
1122
+ EOS
1123
+ assert_equal expected, actual
1124
+
1125
+ @book.config['pdfmaker']['use_original_image_size'] = true
1126
+ actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
1127
+ assert_equal expected, actual
500
1128
  end
501
1129
 
502
1130
  def test_indepimage
503
1131
  def @chapter.image(_id)
504
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1132
+ item = Book::Index::Item.new('sampleimg', 1)
505
1133
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
506
1134
  item
507
1135
  end
508
1136
 
509
1137
  actual = compile_block("//indepimage[sampleimg][sample photo]\n")
510
- assert_equal %Q(\\begin{reviewimage}%%sampleimg\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n), actual
1138
+ expected = <<-EOS
1139
+ \\begin{reviewimage}%%sampleimg
1140
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1141
+ \\reviewindepimagecaption{図: sample photo}
1142
+ \\end{reviewimage}
1143
+ EOS
1144
+ assert_equal expected, actual
1145
+
1146
+ @book.config['pdfmaker']['use_original_image_size'] = true
1147
+ actual = compile_block("//indepimage[sampleimg][sample photo]\n")
1148
+ expected = <<-EOS
1149
+ \\begin{reviewimage}%%sampleimg
1150
+ \\reviewincludegraphics[ ]{./images/chap1-sampleimg.png}
1151
+ \\reviewindepimagecaption{図: sample photo}
1152
+ \\end{reviewimage}
1153
+ EOS
1154
+ assert_equal expected, actual
1155
+
1156
+ actual = compile_block("//indepimage[sampleimg][sample photo][]\n")
1157
+ assert_equal expected, actual
1158
+
1159
+ @book.config['pdfmaker']['use_original_image_size'] = nil
1160
+ @config['caption_position']['image'] = 'top'
1161
+ actual = compile_block("//indepimage[sampleimg][sample photo]\n")
1162
+ expected = <<-EOS
1163
+ \\begin{reviewimage}%%sampleimg
1164
+ \\reviewindepimagecaption{図: sample photo}
1165
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1166
+ \\end{reviewimage}
1167
+ EOS
1168
+ assert_equal expected, actual
511
1169
  end
512
1170
 
513
1171
  def test_indepimage_without_caption
514
1172
  def @chapter.image(_id)
515
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1173
+ item = Book::Index::Item.new('sampleimg', 1)
516
1174
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
517
1175
  item
518
1176
  end
519
1177
 
520
1178
  # FIXME: indepimage's caption should not be with a counter.
521
1179
  actual = compile_block("//indepimage[sampleimg]\n")
522
- assert_equal %Q(\\begin{reviewimage}%%sampleimg\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n), actual
1180
+ expected = <<-EOS
1181
+ \\begin{reviewimage}%%sampleimg
1182
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1183
+ \\end{reviewimage}
1184
+ EOS
1185
+ assert_equal expected, actual
523
1186
  end
524
1187
 
525
1188
  def test_indepimage_with_metric
526
1189
  def @chapter.image(_id)
527
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1190
+ item = Book::Index::Item.new('sampleimg', 1)
528
1191
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
529
1192
  item
530
1193
  end
531
1194
 
532
1195
  actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
533
- assert_equal %Q(\\begin{reviewimage}%%sampleimg\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n), actual
1196
+ expected = <<-EOS
1197
+ \\begin{reviewimage}%%sampleimg
1198
+ \\reviewincludegraphics[scale=1.2]{./images/chap1-sampleimg.png}
1199
+ \\reviewindepimagecaption{図: sample photo}
1200
+ \\end{reviewimage}
1201
+ EOS
1202
+ assert_equal expected, actual
1203
+
1204
+ @book.config['pdfmaker']['use_original_image_size'] = true
1205
+ actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
1206
+ assert_equal expected, actual
534
1207
  end
535
1208
 
536
1209
  def test_indepimage_with_metric_width
537
1210
  def @chapter.image(_id)
538
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1211
+ item = Book::Index::Item.new('sampleimg', 1)
539
1212
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
540
1213
  item
541
1214
  end
542
1215
 
543
- @config['image_scale2width'] = true
1216
+ @config['pdfmaker']['image_scale2width'] = true
1217
+ actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
1218
+ expected = <<-EOS
1219
+ \\begin{reviewimage}%%sampleimg
1220
+ \\reviewincludegraphics[width=1.2\\maxwidth]{./images/chap1-sampleimg.png}
1221
+ \\reviewindepimagecaption{図: sample photo}
1222
+ \\end{reviewimage}
1223
+ EOS
1224
+ assert_equal expected, actual
1225
+
1226
+ @book.config['pdfmaker']['use_original_image_size'] = true
544
1227
  actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
545
- assert_equal %Q(\\begin{reviewimage}%%sampleimg\n\\includegraphics[width=1.2\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n), actual
1228
+ assert_equal expected, actual
546
1229
  end
547
1230
 
548
1231
  def test_indepimage_with_metric2
549
1232
  def @chapter.image(_id)
550
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1233
+ item = Book::Index::Item.new('sampleimg', 1)
551
1234
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
552
1235
  item
553
1236
  end
554
1237
 
555
1238
  actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
556
- assert_equal %Q(\\begin{reviewimage}%%sampleimg\n\\includegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n), actual
1239
+ expected = <<-EOS
1240
+ \\begin{reviewimage}%%sampleimg
1241
+ \\reviewincludegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}
1242
+ \\reviewindepimagecaption{図: sample photo}
1243
+ \\end{reviewimage}
1244
+ EOS
1245
+ assert_equal expected, actual
1246
+
1247
+ @book.config['pdfmaker']['use_original_image_size'] = true
1248
+ actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
1249
+ assert_equal expected, actual
557
1250
  end
558
1251
 
559
1252
  def test_indepimage_without_caption_but_with_metric
560
1253
  def @chapter.image(_id)
561
- item = Book::ImageIndex::Item.new('sampleimg', 1)
1254
+ item = Book::Index::Item.new('sampleimg', 1)
562
1255
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
563
1256
  item
564
1257
  end
565
1258
 
566
1259
  # FIXME: indepimage's caption should not be with a counter.
567
1260
  actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
568
- assert_equal %Q(\\begin{reviewimage}%%sampleimg\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n), actual
1261
+ expected = <<-EOS
1262
+ \\begin{reviewimage}%%sampleimg
1263
+ \\reviewincludegraphics[scale=1.2]{./images/chap1-sampleimg.png}
1264
+ \\end{reviewimage}
1265
+ EOS
1266
+ assert_equal expected, actual
1267
+
1268
+ @book.config['pdfmaker']['use_original_image_size'] = true
1269
+ actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
1270
+ assert_equal expected, actual
569
1271
  end
570
1272
 
571
1273
  def test_table
572
1274
  actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
573
- assert_equal "\\begin{reviewtable}{|l|l|}\n\\hline\n\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline\nccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline\n\\end{reviewtable}\n",
574
- actual
1275
+ expected = <<-EOS
1276
+ \\begin{reviewtable}{|l|l|}
1277
+ \\hline
1278
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1279
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1280
+ \\end{reviewtable}
1281
+ EOS
1282
+ assert_equal expected, actual
1283
+
1284
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1285
+ expected = <<-EOS
1286
+ \\begin{table}%%foo
1287
+ \\reviewtablecaption{FOO}
1288
+ \\label{table:chap1:foo}
1289
+ \\begin{reviewtable}{|l|l|}
1290
+ \\hline
1291
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1292
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1293
+ \\end{reviewtable}
1294
+ \\end{table}
1295
+ EOS
1296
+ assert_equal expected, actual
1297
+
1298
+ @config['caption_position']['table'] = 'bottom'
1299
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1300
+ expected = <<-EOS
1301
+ \\begin{table}%%foo
1302
+ \\begin{reviewtable}{|l|l|}
1303
+ \\hline
1304
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1305
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1306
+ \\end{reviewtable}
1307
+ \\reviewtablecaption{FOO}
1308
+ \\label{table:chap1:foo}
1309
+ \\end{table}
1310
+ EOS
1311
+ assert_equal expected, actual
1312
+ end
1313
+
1314
+ def test_empty_table
1315
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
1316
+ assert_equal ':2: error: no rows in the table', e.message
1317
+
1318
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
1319
+ assert_equal ':3: error: no rows in the table', e.message
575
1320
  end
576
1321
 
577
1322
  def test_customize_cellwidth
578
1323
  actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
579
- assert_equal %Q(\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}\n\\hline\n\\reviewth{A} & B & C \\\\ \\hline\n\\end{reviewtable}\n), actual
1324
+ expected = <<-EOS
1325
+ \\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}
1326
+ \\hline
1327
+ \\reviewth{A} & B & C \\\\ \\hline
1328
+ \\end{reviewtable}
1329
+ EOS
1330
+ assert_equal expected, actual
580
1331
 
581
1332
  actual = compile_block("//tsize[|latex,html|2,3,5]\n//table{\nA\tB\tC\n//}\n")
582
- assert_equal %Q(\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}\n\\hline\n\\reviewth{A} & B & C \\\\ \\hline\n\\end{reviewtable}\n), actual
1333
+ expected = <<-EOS
1334
+ \\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}
1335
+ \\hline
1336
+ \\reviewth{A} & B & C \\\\ \\hline
1337
+ \\end{reviewtable}
1338
+ EOS
1339
+ assert_equal expected, actual
583
1340
 
584
1341
  actual = compile_block("//tsize[|html|2,3,5]\n//table{\nA\tB\tC\n//}\n")
585
- assert_equal %Q(\\begin{reviewtable}{|l|l|l|}\n\\hline\n\\reviewth{A} & B & C \\\\ \\hline\n\\end{reviewtable}\n), actual
1342
+ expected = <<-EOS
1343
+ \\begin{reviewtable}{|l|l|l|}
1344
+ \\hline
1345
+ \\reviewth{A} & B & C \\\\ \\hline
1346
+ \\end{reviewtable}
1347
+ EOS
1348
+ assert_equal expected, actual
586
1349
 
587
1350
  actual = compile_block("//tsize[|latex|2,3,5]\n//table{\nA\tB\tC\n//}\n")
588
- assert_equal %Q(\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}\n\\hline\n\\reviewth{A} & B & C \\\\ \\hline\n\\end{reviewtable}\n), actual
1351
+ expected = <<-EOS
1352
+ \\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}
1353
+ \\hline
1354
+ \\reviewth{A} & B & C \\\\ \\hline
1355
+ \\end{reviewtable}
1356
+ EOS
1357
+ assert_equal expected, actual
589
1358
 
590
1359
  actual = compile_block("//tsize[|latex||p{5mm}|cr|]\n//table{\nA\tB\tC\n//}\n")
591
- assert_equal %Q(\\begin{reviewtable}{|p{5mm}|cr|}\n\\hline\n\\reviewth{A} & B & C \\\\ \\hline\n\\end{reviewtable}\n), actual
1360
+ expected = <<-EOS
1361
+ \\begin{reviewtable}{|p{5mm}|cr|}
1362
+ \\hline
1363
+ \\reviewth{A} & B & C \\\\ \\hline
1364
+ \\end{reviewtable}
1365
+ EOS
1366
+ assert_equal expected, actual
592
1367
  end
593
1368
 
594
1369
  def test_separate_tsize
@@ -604,21 +1379,72 @@ class LATEXBuidlerTest < Test::Unit::TestCase
604
1379
 
605
1380
  def test_break_tablecell
606
1381
  actual = compile_block("//tsize[|latex||p{10mm}|cp{10mm}|]\n//table{\nA@<br>{}A\tB@<br>{}B\tC@<br>{}C\n//}\n")
607
- assert_equal %Q(\\begin{reviewtable}{|p{10mm}|cp{10mm}|}\n\\hline\n\\reviewth{A\\newline{}A} & \\shortstack[l]{B\\\\\nB} & C\\newline{}C \\\\ \\hline\n\\end{reviewtable}\n), actual
1382
+ expected = <<-EOS
1383
+ \\begin{reviewtable}{|p{10mm}|cp{10mm}|}
1384
+ \\hline
1385
+ \\reviewth{A\\newline{}A} & \\shortstack[l]{B\\\\
1386
+ B} & C\\newline{}C \\\\ \\hline
1387
+ \\end{reviewtable}
1388
+ EOS
1389
+ assert_equal expected, actual
608
1390
 
609
1391
  actual = compile_block("//tsize[|latex||p{10mm}|cp{10mm}|]\n//table{\n1@<br>{}1\t2@<br>{}2\t3\n------------\nA@<br>{}A\tB@<br>{}B\tC@<br>{}C\n//}\n")
610
- assert_equal %Q(\\begin{reviewtable}{|p{10mm}|cp{10mm}|}\n\\hline\n\\reviewth{1\\newline{}1} & \\reviewth{\\shortstack[l]{2\\\\\n2}} & \\reviewth{3} \\\\ \\hline\nA\\newline{}A & \\shortstack[l]{B\\\\\nB} & C\\newline{}C \\\\ \\hline\n\\end{reviewtable}\n), actual
1392
+ expected = <<-EOS
1393
+ \\begin{reviewtable}{|p{10mm}|cp{10mm}|}
1394
+ \\hline
1395
+ \\reviewth{1\\newline{}1} & \\reviewth{\\shortstack[l]{2\\\\
1396
+ 2}} & \\reviewth{3} \\\\ \\hline
1397
+ A\\newline{}A & \\shortstack[l]{B\\\\
1398
+ B} & C\\newline{}C \\\\ \\hline
1399
+ \\end{reviewtable}
1400
+ EOS
1401
+ assert_equal expected, actual
611
1402
  end
612
1403
 
613
1404
  def test_emtable
614
1405
  actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
615
- assert_equal "\\begin{table}%%\n\\reviewtablecaption*{foo}\n\\begin{reviewtable}{|l|l|}\n\\hline\n\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline\nccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline\n\\end{reviewtable}\n\\end{table}\n\n\\begin{reviewtable}{|l|l|}\n\\hline\n\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline\nccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline\n\\end{reviewtable}\n",
616
- actual
1406
+ expected = <<-EOS
1407
+ \\begin{table}%%
1408
+ \\reviewtablecaption*{foo}
1409
+ \\begin{reviewtable}{|l|l|}
1410
+ \\hline
1411
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1412
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1413
+ \\end{reviewtable}
1414
+ \\end{table}
1415
+
1416
+ \\begin{reviewtable}{|l|l|}
1417
+ \\hline
1418
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1419
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1420
+ \\end{reviewtable}
1421
+ EOS
1422
+ assert_equal expected, actual
1423
+
1424
+ @config['caption_position']['table'] = 'bottom'
1425
+ actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1426
+ expected = <<-EOS
1427
+ \\begin{table}%%
1428
+ \\begin{reviewtable}{|l|l|}
1429
+ \\hline
1430
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1431
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1432
+ \\end{reviewtable}
1433
+ \\reviewtablecaption*{foo}
1434
+ \\end{table}
1435
+
1436
+ \\begin{reviewtable}{|l|l|}
1437
+ \\hline
1438
+ \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1439
+ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1440
+ \\end{reviewtable}
1441
+ EOS
1442
+ assert_equal expected, actual
617
1443
  end
618
1444
 
619
1445
  def test_imgtable
620
1446
  def @chapter.image(_id)
621
- item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample img')
1447
+ item = Book::Index::Item.new('sampleimg', 1, 'sample img')
622
1448
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
623
1449
  item
624
1450
  end
@@ -630,16 +1456,118 @@ class LATEXBuidlerTest < Test::Unit::TestCase
630
1456
  \\reviewimgtablecaption{test for imgtable}
631
1457
  \\label{table:chap1:sampleimg}
632
1458
  \\begin{reviewimage}%%sampleimg
633
- \\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1459
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1460
+ \\end{reviewimage}
1461
+ \\end{table}
1462
+ EOS
1463
+ assert_equal expected, actual
1464
+
1465
+ @book.config['pdfmaker']['use_original_image_size'] = true
1466
+ actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
1467
+
1468
+ expected = <<-EOS
1469
+ \\begin{table}[h]%%sampleimg
1470
+ \\reviewimgtablecaption{test for imgtable}
1471
+ \\label{table:chap1:sampleimg}
1472
+ \\begin{reviewimage}%%sampleimg
1473
+ \\reviewincludegraphics[ ]{./images/chap1-sampleimg.png}
1474
+ \\end{reviewimage}
1475
+ \\end{table}
1476
+ EOS
1477
+ assert_equal expected, actual
1478
+
1479
+ actual = compile_block("//imgtable[sampleimg][test for imgtable][]{\n//}\n")
1480
+ assert_equal expected, actual
1481
+
1482
+ @book.config['pdfmaker']['use_original_image_size'] = nil
1483
+ @config['caption_position']['table'] = 'bottom'
1484
+ actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
1485
+
1486
+ expected = <<-EOS
1487
+ \\begin{table}[h]%%sampleimg
1488
+ \\label{table:chap1:sampleimg}
1489
+ \\begin{reviewimage}%%sampleimg
1490
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1491
+ \\end{reviewimage}
1492
+ \\reviewimgtablecaption{test for imgtable}
1493
+ \\end{table}
1494
+ EOS
1495
+ assert_equal expected, actual
1496
+ end
1497
+
1498
+ def test_imgtable_with_metrics
1499
+ def @chapter.image(_id)
1500
+ item = Book::Index::Item.new('sampleimg', 1, 'sample img')
1501
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
1502
+ item
1503
+ end
1504
+
1505
+ actual = compile_block("//imgtable[sampleimg][test for imgtable][scale=1.2]{\n//}\n")
1506
+ expected = <<-EOS
1507
+ \\begin{table}[h]%%sampleimg
1508
+ \\reviewimgtablecaption{test for imgtable}
1509
+ \\label{table:chap1:sampleimg}
1510
+ \\begin{reviewimage}%%sampleimg
1511
+ \\reviewincludegraphics[scale=1.2]{./images/chap1-sampleimg.png}
634
1512
  \\end{reviewimage}
635
1513
  \\end{table}
1514
+ EOS
1515
+ assert_equal expected, actual
1516
+
1517
+ @book.config['pdfmaker']['use_original_image_size'] = true
1518
+ actual = compile_block("//imgtable[sampleimg][test for imgtable][scale=1.2]{\n//}\n")
1519
+ assert_equal expected, actual
1520
+ end
1521
+
1522
+ def test_table_row_separator
1523
+ src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
1524
+ expected = <<-EOS
1525
+ \\begin{reviewtable}{|l|l|l|}
1526
+ \\hline
1527
+ \\reviewth{1} & \\reviewth{2} & \\reviewth{3 4\\textbar{} 5} \\\\ \\hline
1528
+ a b & c d \\textbar{}e & \\\\ \\hline
1529
+ \\end{reviewtable}
1530
+ EOS
1531
+ actual = compile_block(src)
1532
+ assert_equal expected, actual
1533
+
1534
+ @config['table_row_separator'] = 'singletab'
1535
+ actual = compile_block(src)
1536
+ expected = <<-EOS
1537
+ \\begin{reviewtable}{|l|l|l|l|}
1538
+ \\hline
1539
+ \\reviewth{1} & \\reviewth{2} & \\reviewth{} & \\reviewth{3 4\\textbar{} 5} \\\\ \\hline
1540
+ a b & c d \\textbar{}e & & \\\\ \\hline
1541
+ \\end{reviewtable}
1542
+ EOS
1543
+ assert_equal expected, actual
1544
+
1545
+ @config['table_row_separator'] = 'spaces'
1546
+ actual = compile_block(src)
1547
+ expected = <<-EOS
1548
+ \\begin{reviewtable}{|l|l|l|l|l|}
1549
+ \\hline
1550
+ \\reviewth{1} & \\reviewth{2} & \\reviewth{3} & \\reviewth{4\\textbar{}} & \\reviewth{5} \\\\ \\hline
1551
+ a & b & c & d & \\textbar{}e \\\\ \\hline
1552
+ \\end{reviewtable}
1553
+ EOS
1554
+ assert_equal expected, actual
1555
+
1556
+ @config['table_row_separator'] = 'verticalbar'
1557
+ actual = compile_block(src)
1558
+ expected = <<-EOS
1559
+ \\begin{reviewtable}{|l|l|}
1560
+ \\hline
1561
+ \\reviewth{1 2 3 4} & \\reviewth{5} \\\\ \\hline
1562
+ a b c d & e \\\\ \\hline
1563
+ \\end{reviewtable}
636
1564
  EOS
637
1565
  assert_equal expected, actual
638
1566
  end
639
1567
 
640
1568
  def test_bib
641
1569
  def @chapter.bibpaper(_id)
642
- Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
1570
+ Book::Index::Item.new('samplebib', 1, 'sample bib')
643
1571
  end
644
1572
 
645
1573
  assert_equal '\\reviewbibref{[1]}{bib:samplebib}', compile_inline('@<bib>{samplebib}')
@@ -647,20 +1575,43 @@ EOS
647
1575
 
648
1576
  def test_bibpaper
649
1577
  def @chapter.bibpaper(_id)
650
- Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
1578
+ Book::Index::Item.new('samplebib', 1, 'sample bib')
651
1579
  end
652
1580
 
653
1581
  actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
654
- assert_equal %Q([1] sample bib \\reviewbold{bold}\n\\label{bib:samplebib}\n\nab\n\n), actual
1582
+ expected = <<-EOS
1583
+ [1] sample bib \\reviewbold{bold}
1584
+ \\label{bib:samplebib}
1585
+
1586
+ ab
1587
+
1588
+ EOS
1589
+ assert_equal expected, actual
1590
+
1591
+ @book.config['join_lines_by_lang'] = true
1592
+ actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
1593
+ expected = <<-EOS
1594
+ [1] sample bib \\reviewbold{bold}
1595
+ \\label{bib:samplebib}
1596
+
1597
+ a b
1598
+
1599
+ EOS
1600
+ assert_equal expected, actual
655
1601
  end
656
1602
 
657
1603
  def test_bibpaper_without_body
658
1604
  def @chapter.bibpaper(_id)
659
- Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
1605
+ Book::Index::Item.new('samplebib', 1, 'sample bib')
660
1606
  end
661
1607
 
662
1608
  actual = compile_block("//bibpaper[samplebib][sample bib]\n")
663
- assert_equal %Q([1] sample bib\n\\label{bib:samplebib}\n\n), actual
1609
+ expected = <<-EOS
1610
+ [1] sample bib
1611
+ \\label{bib:samplebib}
1612
+
1613
+ EOS
1614
+ assert_equal expected, actual
664
1615
  end
665
1616
 
666
1617
  def column_helper(review)
@@ -778,8 +1729,56 @@ EOS
778
1729
  expected = <<-EOS
779
1730
 
780
1731
  \\begin{itemize}
781
- \\item AAA{-}AA
782
- \\item BBB{-}BB
1732
+ \\item AAA
1733
+ {-}AA
1734
+ \\item BBB
1735
+ {-}BB
1736
+ \\end{itemize}
1737
+ EOS
1738
+ actual = compile_block(src)
1739
+ assert_equal expected, actual
1740
+
1741
+ @book.config['join_lines_by_lang'] = true
1742
+ expected = <<-EOS
1743
+
1744
+ \\begin{itemize}
1745
+ \\item AAA {-}AA
1746
+ \\item BBB {-}BB
1747
+ \\end{itemize}
1748
+ EOS
1749
+ actual = compile_block(src)
1750
+ assert_equal expected, actual
1751
+ end
1752
+
1753
+ def test_cont_with_br
1754
+ src = <<-EOS
1755
+ * AAA@<br>{}
1756
+ -AA
1757
+ * BBB@<br>{}1@<br>{}
1758
+ -BB
1759
+ EOS
1760
+ expected = <<-EOS
1761
+
1762
+ \\begin{itemize}
1763
+ \\item AAA\\\\
1764
+ {-}AA
1765
+ \\item BBB\\\\
1766
+ 1\\\\
1767
+ {-}BB
1768
+ \\end{itemize}
1769
+ EOS
1770
+ actual = compile_block(src)
1771
+ assert_equal expected, actual
1772
+
1773
+ @book.config['join_lines_by_lang'] = true
1774
+ expected = <<-EOS
1775
+
1776
+ \\begin{itemize}
1777
+ \\item AAA\\\\
1778
+ {-}AA
1779
+ \\item BBB\\\\
1780
+ 1\\\\
1781
+ {-}BB
783
1782
  \\end{itemize}
784
1783
  EOS
785
1784
  actual = compile_block(src)
@@ -871,35 +1870,107 @@ EOS
871
1870
 
872
1871
  def test_major_blocks
873
1872
  actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
874
- expected = %Q(\\begin{reviewnote}\nA\n\nB\n\\end{reviewnote}\n\\begin{reviewnote}[caption]\nA\n\\end{reviewnote}\n)
1873
+ expected = <<-EOS
1874
+ \\begin{reviewnote}
1875
+ A
1876
+
1877
+ B
1878
+ \\end{reviewnote}
1879
+ \\begin{reviewnote}[caption]
1880
+ A
1881
+ \\end{reviewnote}
1882
+ EOS
875
1883
  assert_equal expected, actual
876
1884
 
877
1885
  actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
878
- expected = %Q(\\begin{reviewmemo}\nA\n\nB\n\\end{reviewmemo}\n\\begin{reviewmemo}[caption]\nA\n\\end{reviewmemo}\n)
1886
+ expected = <<-EOS
1887
+ \\begin{reviewmemo}
1888
+ A
1889
+
1890
+ B
1891
+ \\end{reviewmemo}
1892
+ \\begin{reviewmemo}[caption]
1893
+ A
1894
+ \\end{reviewmemo}
1895
+ EOS
879
1896
  assert_equal expected, actual
880
1897
 
881
1898
  actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
882
- expected = %Q(\\begin{reviewinfo}\nA\n\nB\n\\end{reviewinfo}\n\\begin{reviewinfo}[caption]\nA\n\\end{reviewinfo}\n)
1899
+ expected = <<-EOS
1900
+ \\begin{reviewinfo}
1901
+ A
1902
+
1903
+ B
1904
+ \\end{reviewinfo}
1905
+ \\begin{reviewinfo}[caption]
1906
+ A
1907
+ \\end{reviewinfo}
1908
+ EOS
883
1909
  assert_equal expected, actual
884
1910
 
885
1911
  actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
886
- expected = %Q(\\begin{reviewimportant}\nA\n\nB\n\\end{reviewimportant}\n\\begin{reviewimportant}[caption]\nA\n\\end{reviewimportant}\n)
1912
+ expected = <<-EOS
1913
+ \\begin{reviewimportant}
1914
+ A
1915
+
1916
+ B
1917
+ \\end{reviewimportant}
1918
+ \\begin{reviewimportant}[caption]
1919
+ A
1920
+ \\end{reviewimportant}
1921
+ EOS
887
1922
  assert_equal expected, actual
888
1923
 
889
1924
  actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
890
- expected = %Q(\\begin{reviewcaution}\nA\n\nB\n\\end{reviewcaution}\n\\begin{reviewcaution}[caption]\nA\n\\end{reviewcaution}\n)
1925
+ expected = <<-EOS
1926
+ \\begin{reviewcaution}
1927
+ A
1928
+
1929
+ B
1930
+ \\end{reviewcaution}
1931
+ \\begin{reviewcaution}[caption]
1932
+ A
1933
+ \\end{reviewcaution}
1934
+ EOS
891
1935
  assert_equal expected, actual
892
1936
 
893
1937
  actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
894
- expected = %Q(\\begin{reviewnotice}\nA\n\nB\n\\end{reviewnotice}\n\\begin{reviewnotice}[caption]\nA\n\\end{reviewnotice}\n)
1938
+ expected = <<-EOS
1939
+ \\begin{reviewnotice}
1940
+ A
1941
+
1942
+ B
1943
+ \\end{reviewnotice}
1944
+ \\begin{reviewnotice}[caption]
1945
+ A
1946
+ \\end{reviewnotice}
1947
+ EOS
895
1948
  assert_equal expected, actual
896
1949
 
897
1950
  actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
898
- expected = %Q(\\begin{reviewwarning}\nA\n\nB\n\\end{reviewwarning}\n\\begin{reviewwarning}[caption]\nA\n\\end{reviewwarning}\n)
1951
+ expected = <<-EOS
1952
+ \\begin{reviewwarning}
1953
+ A
1954
+
1955
+ B
1956
+ \\end{reviewwarning}
1957
+ \\begin{reviewwarning}[caption]
1958
+ A
1959
+ \\end{reviewwarning}
1960
+ EOS
899
1961
  assert_equal expected, actual
900
1962
 
901
1963
  actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
902
- expected = %Q(\\begin{reviewtip}\nA\n\nB\n\\end{reviewtip}\n\\begin{reviewtip}[caption]\nA\n\\end{reviewtip}\n)
1964
+ expected = <<-EOS
1965
+ \\begin{reviewtip}
1966
+ A
1967
+
1968
+ B
1969
+ \\end{reviewtip}
1970
+ \\begin{reviewtip}[caption]
1971
+ A
1972
+ \\end{reviewtip}
1973
+ EOS
903
1974
  assert_equal expected, actual
904
1975
  end
905
1976
 
@@ -934,24 +2005,24 @@ EOS
934
2005
 
935
2006
  def test_inline_imgref
936
2007
  def @chapter.image(_id)
937
- item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample photo')
2008
+ item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
938
2009
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
939
2010
  item
940
2011
  end
941
2012
 
942
- actual = compile_block "@<imgref>{sampleimg}\n"
2013
+ actual = compile_block("@<imgref>{sampleimg}\n")
943
2014
  expected = "\n\\reviewimageref{1.1}{image:chap1:sampleimg}「sample photo」\n"
944
2015
  assert_equal expected, actual
945
2016
  end
946
2017
 
947
2018
  def test_inline_imgref2
948
2019
  def @chapter.image(_id)
949
- item = Book::NumberlessImageIndex::Item.new('sampleimg', 1)
2020
+ item = Book::Index::Item.new('sampleimg', 1)
950
2021
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
951
2022
  item
952
2023
  end
953
2024
 
954
- actual = compile_block "@<imgref>{sampleimg}\n"
2025
+ actual = compile_block("@<imgref>{sampleimg}\n")
955
2026
  expected = "\n\\reviewimageref{1.1}{image:chap1:sampleimg}\n"
956
2027
  assert_equal expected, actual
957
2028
  end
@@ -993,8 +2064,10 @@ EOS
993
2064
 
994
2065
  def test_comment_for_draft
995
2066
  @config['draft'] = true
996
- actual = compile_block('//comment[コメント]')
997
- assert_equal %Q(\\pdfcomment{コメント}\n), actual
2067
+ actual = compile_block('//comment[コメント<]')
2068
+ assert_equal %Q(\\pdfcomment{コメント\\textless{}}\n), actual
2069
+ actual = compile_block("//comment{\nA<>\nB&\n//}")
2070
+ assert_equal %Q(\\pdfcomment{A\\textless{}\\textgreater{}\\par B\\&}\n), actual
998
2071
  end
999
2072
 
1000
2073
  def test_inline_comment
@@ -1033,7 +2106,7 @@ EOB
1033
2106
  foo bar"\\reviewbackslash{}\\textless{}\\textgreater{}\\textunderscore{}@\\textless{}b\\textgreater{}\\{BAZ\\} \\reviewbold{bar"\\reviewbackslash{}\\textless{}\\textgreater{}\\textunderscore{}@\\textless{}b\\textgreater{}\\{BAZ\\}} [missing word: N]
1034
2107
  EOS
1035
2108
  assert_equal expected, actual
1036
- assert_match(/WARN -- : :1: word not bound: N/, io.string)
2109
+ assert_match(/WARN --: :1: word not bound: N/, io.string)
1037
2110
  end
1038
2111
  end
1039
2112
 
@@ -1116,7 +2189,7 @@ EOS
1116
2189
  end
1117
2190
 
1118
2191
  def @chapter.image(_id)
1119
- item = Book::NumberlessImageIndex::Item.new('sampleimg', 1)
2192
+ item = Book::Index::Item.new('sampleimg', 1)
1120
2193
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
1121
2194
  item
1122
2195
  end
@@ -1131,8 +2204,8 @@ EOS
1131
2204
  \\reviewimageref{A.1}{image:chap1:sampleimg}
1132
2205
 
1133
2206
  \\begin{reviewimage}%%sampleimg
1134
- \\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1135
- \\caption{FOO}
2207
+ \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
2208
+ \\reviewimagecaption{FOO}
1136
2209
  \\label{image:chap1:sampleimg}
1137
2210
  \\end{reviewimage}
1138
2211
  EOS
@@ -1174,6 +2247,21 @@ EOS
1174
2247
  e=mc^2
1175
2248
  \\end{equation*}
1176
2249
  \\end{reviewequationblock}
2250
+ EOS
2251
+ actual = compile_block(src)
2252
+ assert_equal expected, actual
2253
+
2254
+ @config['caption_position']['equation'] = 'bottom'
2255
+ expected = <<-EOS
2256
+
2257
+ \\reviewequationref{1.1}
2258
+
2259
+ \\begin{reviewequationblock}
2260
+ \\begin{equation*}
2261
+ e=mc^2
2262
+ \\end{equation*}
2263
+ \\reviewequationcaption{式1.1: The Equivalence of Mass \\reviewit{and} Energy}
2264
+ \\end{reviewequationblock}
1177
2265
  EOS
1178
2266
  actual = compile_block(src)
1179
2267
  assert_equal expected, actual