review 4.1.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-tex.yml +35 -0
  3. data/.github/workflows/ruby-win.yml +19 -9
  4. data/.github/workflows/ruby.yml +7 -3
  5. data/.rubocop.yml +138 -34
  6. data/NEWS.ja.md +285 -0
  7. data/NEWS.md +285 -1
  8. data/README.md +7 -6
  9. data/Rakefile +7 -2
  10. data/bin/review +2 -4
  11. data/bin/review-catalog-converter +4 -4
  12. data/bin/review-check +8 -12
  13. data/bin/review-checkdep +2 -5
  14. data/bin/review-compile +18 -34
  15. data/bin/review-epub2html +1 -4
  16. data/bin/review-epubmaker +3 -4
  17. data/bin/review-idgxmlmaker +1 -3
  18. data/bin/review-index +5 -86
  19. data/bin/review-init +1 -4
  20. data/bin/review-pdfmaker +1 -3
  21. data/bin/review-preproc +30 -38
  22. data/bin/review-textmaker +1 -3
  23. data/bin/review-update +1 -4
  24. data/bin/review-validate +4 -4
  25. data/bin/review-vol +5 -82
  26. data/bin/review-webmaker +1 -3
  27. data/doc/config.yml.sample +45 -11
  28. data/doc/config.yml.sample-simple +3 -3
  29. data/doc/format.ja.md +103 -13
  30. data/doc/format.md +104 -16
  31. data/doc/makeindex.ja.md +2 -2
  32. data/doc/pdfmaker.ja.md +42 -0
  33. data/doc/pdfmaker.md +41 -0
  34. data/doc/quickstart.ja.md +19 -6
  35. data/doc/quickstart.md +18 -6
  36. data/doc/writing_vertical.ja.md +6 -0
  37. data/lib/review.rb +1 -1
  38. data/lib/review/book.rb +2 -2
  39. data/lib/review/book/base.rb +67 -29
  40. data/lib/review/book/bib.rb +21 -0
  41. data/lib/review/book/book_unit.rb +158 -0
  42. data/lib/review/book/chapter.rb +33 -26
  43. data/lib/review/book/index.rb +24 -185
  44. data/lib/review/book/index/item.rb +7 -1
  45. data/lib/review/book/page_metric.rb +7 -7
  46. data/lib/review/book/part.rb +26 -11
  47. data/lib/review/book/volume.rb +5 -5
  48. data/lib/review/builder.rb +121 -52
  49. data/lib/review/call_hook.rb +20 -0
  50. data/lib/review/catalog.rb +3 -2
  51. data/lib/review/compiler.rb +230 -111
  52. data/lib/review/configure.rb +91 -7
  53. data/lib/review/converter.rb +1 -1
  54. data/lib/review/epub2html.rb +6 -1
  55. data/lib/review/epubmaker.rb +124 -152
  56. data/lib/review/epubmaker/content.rb +113 -0
  57. data/lib/review/epubmaker/epubcommon.rb +372 -0
  58. data/lib/review/epubmaker/epubv2.rb +178 -0
  59. data/lib/review/epubmaker/epubv3.rb +231 -0
  60. data/lib/review/epubmaker/producer.rb +167 -0
  61. data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
  62. data/lib/review/epubmaker/zip_exporter.rb +84 -0
  63. data/lib/review/exception.rb +13 -0
  64. data/lib/review/htmlbuilder.rb +176 -89
  65. data/lib/review/htmlutils.rb +8 -11
  66. data/lib/review/i18n.rb +2 -1
  67. data/lib/review/idgxmlbuilder.rb +165 -75
  68. data/lib/review/idgxmlmaker.rb +24 -28
  69. data/lib/review/img_math.rb +238 -0
  70. data/lib/review/index_builder.rb +645 -0
  71. data/lib/review/init.rb +9 -17
  72. data/lib/review/latexbox.rb +58 -0
  73. data/lib/review/latexbuilder.rb +193 -75
  74. data/lib/review/latexutils.rb +9 -1
  75. data/lib/review/lineinput.rb +112 -2
  76. data/lib/review/loggable.rb +27 -0
  77. data/lib/review/logger.rb +90 -3
  78. data/lib/review/makerhelper.rb +17 -188
  79. data/lib/review/markdownbuilder.rb +54 -4
  80. data/lib/review/pdfmaker.rb +76 -84
  81. data/lib/review/plaintextbuilder.rb +106 -22
  82. data/lib/review/preprocessor.rb +107 -303
  83. data/lib/review/preprocessor/directive.rb +35 -0
  84. data/lib/review/preprocessor/line.rb +34 -0
  85. data/lib/review/preprocessor/repository.rb +177 -0
  86. data/lib/review/rstbuilder.rb +27 -8
  87. data/lib/review/sec_counter.rb +14 -0
  88. data/lib/review/template.rb +11 -1
  89. data/lib/review/textmaker.rb +27 -32
  90. data/lib/review/textutils.rb +3 -12
  91. data/lib/review/tocprinter.rb +242 -97
  92. data/lib/review/topbuilder.rb +98 -31
  93. data/lib/review/update.rb +12 -13
  94. data/lib/review/version.rb +1 -1
  95. data/lib/review/volumeprinter.rb +97 -0
  96. data/lib/review/webmaker.rb +40 -47
  97. data/lib/review/webtocprinter.rb +39 -35
  98. data/lib/review/yamlloader.rb +2 -1
  99. data/review.gemspec +5 -3
  100. data/samples/sample-book/src/config-epub2.yml +1 -1
  101. data/samples/sample-book/src/config.yml +3 -3
  102. data/samples/sample-book/src/lib/tasks/review.rake +19 -1
  103. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +2 -1
  104. data/samples/syntax-book/Gemfile +1 -1
  105. data/samples/syntax-book/ch01.re +1 -1
  106. data/samples/syntax-book/ch02.re +21 -6
  107. data/samples/syntax-book/ch03.re +1 -1
  108. data/samples/syntax-book/config.yml +1 -1
  109. data/samples/syntax-book/images/img3-2.png +0 -0
  110. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +2 -1
  111. data/templates/html/_colophon.html.erb +23 -0
  112. data/templates/html/_colophon_history.html.erb +9 -0
  113. data/templates/html/_cover.html.erb +10 -0
  114. data/templates/html/_part_body.html.erb +6 -0
  115. data/templates/html/_titlepage.html.erb +20 -0
  116. data/templates/html/layout-html5.html.erb +6 -0
  117. data/templates/html/layout-xhtml1.html.erb +6 -0
  118. data/templates/latex/config.erb +35 -23
  119. data/templates/latex/review-jlreq/README.md +3 -1
  120. data/templates/latex/review-jlreq/review-base.sty +36 -23
  121. data/templates/latex/review-jlreq/review-jlreq.cls +18 -25
  122. data/templates/latex/review-jlreq/review-style.sty +6 -1
  123. data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
  124. data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
  125. data/templates/latex/review-jsbook/README.md +7 -5
  126. data/templates/latex/review-jsbook/review-base.sty +40 -24
  127. data/templates/latex/review-jsbook/review-jsbook.cls +13 -3
  128. data/templates/latex/review-jsbook/review-style.sty +6 -1
  129. data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
  130. data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
  131. data/templates/opf/epubv2.opf.erb +7 -7
  132. data/templates/opf/epubv3.opf.erb +7 -7
  133. data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
  134. data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
  135. data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
  136. data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
  137. data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
  138. data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
  139. data/templates/web/html/layout-html5.html.erb +9 -8
  140. data/templates/web/html/layout-xhtml1.html.erb +6 -0
  141. data/test/assets/header_listener.html +35 -0
  142. data/test/assets/img_math/img1.png +0 -0
  143. data/test/assets/img_math/img2.png +0 -0
  144. data/test/assets/img_math/img3.png +0 -0
  145. data/test/assets/syntax_book_index_detail.txt +58 -0
  146. data/test/assets/test_template.tex +6 -3
  147. data/test/assets/test_template_backmatter.tex +6 -3
  148. data/test/book_test_helper.rb +11 -5
  149. data/test/run_test.rb +1 -1
  150. data/test/test_book.rb +54 -63
  151. data/test/test_book_chapter.rb +95 -54
  152. data/test/test_book_part.rb +3 -3
  153. data/test/test_builder.rb +29 -20
  154. data/test/test_catalog_converter_cmd.rb +1 -1
  155. data/test/test_converter.rb +1 -0
  156. data/test/test_epub3maker.rb +170 -126
  157. data/test/test_epubmaker.rb +254 -129
  158. data/test/test_epubmaker_cmd.rb +15 -4
  159. data/test/test_helper.rb +12 -5
  160. data/test/test_htmlbuilder.rb +926 -76
  161. data/test/test_htmlutils.rb +0 -12
  162. data/test/test_i18n.rb +33 -33
  163. data/test/test_idgxmlbuilder.rb +531 -20
  164. data/test/test_idgxmlmaker_cmd.rb +7 -3
  165. data/test/test_img_math.rb +111 -0
  166. data/test/test_index.rb +62 -52
  167. data/test/test_indexbuilder.rb +52 -0
  168. data/test/test_latexbuilder.rb +891 -20
  169. data/test/test_latexbuilder_v2.rb +56 -10
  170. data/test/test_lineinput.rb +20 -93
  171. data/test/test_logger.rb +7 -7
  172. data/test/test_makerhelper.rb +0 -12
  173. data/test/test_markdownbuilder.rb +32 -0
  174. data/test/test_pdfmaker.rb +100 -11
  175. data/test/test_pdfmaker_cmd.rb +3 -3
  176. data/test/test_plaintextbuilder.rb +546 -32
  177. data/test/test_preprocessor.rb +188 -1
  178. data/test/test_review_ext.rb +2 -1
  179. data/test/test_reviewheaderlistener.rb +49 -0
  180. data/test/test_rstbuilder.rb +25 -1
  181. data/test/test_sec_counter.rb +156 -0
  182. data/test/test_template.rb +12 -2
  183. data/test/test_textmaker_cmd.rb +5 -1
  184. data/test/test_tocprinter.rb +46 -0
  185. data/test/test_topbuilder.rb +324 -20
  186. data/test/test_update.rb +44 -44
  187. data/test/test_webtocprinter.rb +75 -43
  188. data/test/test_zip_exporter.rb +5 -6
  189. data/vendor/gentombow/LICENSE +1 -1
  190. data/vendor/gentombow/Makefile +0 -1
  191. data/vendor/gentombow/bounddvi-en.pdf +0 -0
  192. data/vendor/gentombow/bounddvi-en.tex +1 -0
  193. data/vendor/gentombow/bounddvi.pdf +0 -0
  194. data/vendor/gentombow/bounddvi.sty +30 -7
  195. data/vendor/gentombow/bounddvi.tex +1 -0
  196. data/vendor/gentombow/create_archive.sh +1 -0
  197. data/vendor/gentombow/gentombow-ja.pdf +0 -0
  198. data/vendor/gentombow/gentombow-ja.tex +9 -0
  199. data/vendor/gentombow/gentombow.pdf +0 -0
  200. data/vendor/gentombow/gentombow.sty +32 -10
  201. data/vendor/gentombow/gentombow.tex +8 -0
  202. data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
  203. data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
  204. data/vendor/jsclasses/Makefile +3 -2
  205. data/vendor/jsclasses/create_archive.sh +5 -5
  206. data/vendor/jsclasses/jis/Makefile +3 -2
  207. data/vendor/jsclasses/jis/jsarticle.cls +22 -18
  208. data/vendor/jsclasses/jis/jsbook.cls +22 -18
  209. data/vendor/jsclasses/jis/jsclasses.dtx +94 -13
  210. data/vendor/jsclasses/jis/jsclasses.ins +15 -5
  211. data/vendor/jsclasses/jis/jslogo.ins +9 -0
  212. data/vendor/jsclasses/jis/jslogo.sty +1 -13
  213. data/vendor/jsclasses/jis/jspf.cls +22 -18
  214. data/vendor/jsclasses/jis/jsreport.cls +22 -18
  215. data/vendor/jsclasses/jis/jsverb.ins +9 -0
  216. data/vendor/jsclasses/jis/jsverb.sty +1 -13
  217. data/vendor/jsclasses/jis/kiyou.cls +22 -18
  218. data/vendor/jsclasses/jis/minijs.sty +65 -22
  219. data/vendor/jsclasses/jis/okumacro.ins +9 -0
  220. data/vendor/jsclasses/jis/okumacro.sty +1 -13
  221. data/vendor/jsclasses/jis/okuverb.ins +9 -0
  222. data/vendor/jsclasses/jis/okuverb.sty +1 -13
  223. data/vendor/jsclasses/jis/winjis.sty +23 -19
  224. data/vendor/jsclasses/jsarticle.cls +22 -18
  225. data/vendor/jsclasses/jsbook.cls +22 -18
  226. data/vendor/jsclasses/jsclasses.dtx +94 -13
  227. data/vendor/jsclasses/jsclasses.ins +15 -5
  228. data/vendor/jsclasses/jsclasses.pdf +0 -0
  229. data/vendor/jsclasses/jslogo.ins +9 -0
  230. data/vendor/jsclasses/jslogo.pdf +0 -0
  231. data/vendor/jsclasses/jslogo.sty +1 -13
  232. data/vendor/jsclasses/jspf.cls +22 -18
  233. data/vendor/jsclasses/jsreport.cls +22 -18
  234. data/vendor/jsclasses/jsverb.ins +9 -0
  235. data/vendor/jsclasses/jsverb.pdf +0 -0
  236. data/vendor/jsclasses/jsverb.sty +1 -13
  237. data/vendor/jsclasses/kiyou.cls +22 -18
  238. data/vendor/jsclasses/minijs.sty +68 -22
  239. data/vendor/jsclasses/okumacro.ins +9 -0
  240. data/vendor/jsclasses/okumacro.pdf +0 -0
  241. data/vendor/jsclasses/okumacro.sty +1 -13
  242. data/vendor/jsclasses/okuverb.ins +9 -0
  243. data/vendor/jsclasses/okuverb.pdf +0 -0
  244. data/vendor/jsclasses/okuverb.sty +1 -13
  245. data/vendor/jsclasses/tests/relfont.tex +10 -0
  246. data/vendor/jsclasses/winjis.sty +23 -19
  247. metadata +106 -22
  248. data/.rubocop_todo.yml +0 -7
  249. data/lib/epubmaker.rb +0 -23
  250. data/lib/epubmaker/content.rb +0 -110
  251. data/lib/epubmaker/epubcommon.rb +0 -441
  252. data/lib/epubmaker/epubv2.rb +0 -143
  253. data/lib/epubmaker/epubv3.rb +0 -233
  254. data/lib/epubmaker/producer.rb +0 -375
  255. data/lib/epubmaker/zip_exporter.rb +0 -81
  256. data/lib/lineinput.rb +0 -155
  257. data/lib/review/book/compilable.rb +0 -178
  258. data/lib/review/tocparser.rb +0 -275
  259. data/test/test_tocparser.rb +0 -25
@@ -10,9 +10,10 @@ class PDFMakerTest < Test::Unit::TestCase
10
10
  @config.merge!(
11
11
  'bookname' => 'sample',
12
12
  'title' => 'Sample Book',
13
- 'review_version' => 3,
13
+ 'aut' => 'anonymous',
14
+ 'review_version' => 4,
14
15
  'urnid' => 'http://example.jp/',
15
- 'date' => '2011-01-01',
16
+ 'date' => '2020-07-11',
16
17
  'language' => 'ja',
17
18
  'texcommand' => 'uplatex'
18
19
  )
@@ -75,7 +76,7 @@ class PDFMakerTest < Test::Unit::TestCase
75
76
  Dir.mktmpdir do |dir|
76
77
  coverfile = 'cover.html'
77
78
  content = '<html><body>test</body></html>'
78
- File.open(File.join(dir, 'cover.tex'), 'w') { |f| f.write(content) }
79
+ File.write(File.join(dir, 'cover.tex'), content)
79
80
  page = @maker.make_custom_page(File.join(dir, coverfile))
80
81
  assert_equal(content, page)
81
82
  end
@@ -144,11 +145,28 @@ class PDFMakerTest < Test::Unit::TestCase
144
145
  @maker.erb_config
145
146
  tmpl = @maker.template_content
146
147
  expect = File.read(File.join(assets_dir, 'test_template.tex'))
147
- expect.gsub!(/\\def\\review@reviewversion{[^\}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
148
+ expect.gsub!(/\\def\\review@reviewversion{[^}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
148
149
  assert_equal(expect, tmpl)
149
150
  end
150
151
  end
151
152
 
153
+ def test_template_content_with_localconfig
154
+ @config['mycustom'] = { 'value' => '#_TEST_' }
155
+ Dir.mktmpdir do |dir|
156
+ Dir.chdir(dir) do
157
+ Dir.mkdir('layouts')
158
+ File.write(File.join('layouts', 'config-local.tex.erb'), %q(\def\customvalue{<%= escape(@config['mycustom']['value']) %>}) + "\n")
159
+ @maker.basedir = Dir.pwd
160
+ @maker.erb_config
161
+ tmpl = @maker.template_content
162
+ expect = File.read(File.join(assets_dir, 'test_template.tex'))
163
+ expect.gsub!(/\\def\\review@reviewversion{[^}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
164
+ expect.sub!("\\makeatother\n", '\&' + "%% BEGIN: config-local.tex.erb\n\\def\\customvalue{\\#\\textunderscore{}TEST\\textunderscore{}}\n%% END: config-local.tex.erb\n")
165
+ assert_equal(expect, tmpl)
166
+ end
167
+ end
168
+ end
169
+
152
170
  def test_gettemplate_with_backmatter
153
171
  @config.merge!(
154
172
  'backcover' => 'backcover.tex',
@@ -158,13 +176,13 @@ class PDFMakerTest < Test::Unit::TestCase
158
176
  Dir.mktmpdir do |dir|
159
177
  Dir.chdir(dir) do
160
178
  profile = "\\thispagestyle{empty}\\chapter*{Profile}\nsome profile\n"
161
- File.open(File.join(dir, 'profile.tex'), 'w') { |f| f.write(profile) }
179
+ File.write(File.join(dir, 'profile.tex'), profile)
162
180
  advfile = "\\thispagestyle{empty}\\chapter*{Ad}\nsome ad content\n"
163
- File.open(File.join(dir, 'advfile.tex'), 'w') { |f| f.write(advfile) }
181
+ File.write(File.join(dir, 'advfile.tex'), advfile)
164
182
  backcover = "\\clearpage\n\\thispagestyle{empty}\\AddToShipoutPictureBG{%\n\\AtPageLowerLeft{\\includegraphics[width=\\paperwidth,height=\\paperheight]{images/backcover.png}}\n}\n\\null"
165
- File.open(File.join(dir, 'backcover.tex'), 'w') { |f| f.write(backcover) }
183
+ File.write(File.join(dir, 'backcover.tex'), backcover)
166
184
  expect = File.read(File.join(assets_dir, 'test_template_backmatter.tex'))
167
- expect.gsub!(/\\def\\review@reviewversion{[^\}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
185
+ expect.gsub!(/\\def\\review@reviewversion{[^}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
168
186
  @maker.basedir = Dir.pwd
169
187
  @maker.erb_config
170
188
  tmpl = @maker.template_content
@@ -179,7 +197,7 @@ class PDFMakerTest < Test::Unit::TestCase
179
197
  @config['pht'] = ['Mrs.Smith']
180
198
  @config['language'] = 'ja'
181
199
  history = @maker.make_history_list
182
- expect = ['201111日 発行']
200
+ expect = ['2020711日 発行']
183
201
  assert_equal expect, history
184
202
  end
185
203
 
@@ -190,9 +208,9 @@ class PDFMakerTest < Test::Unit::TestCase
190
208
  @config['language'] = 'ja'
191
209
  @config['history'] =
192
210
  [['2011-08-03 v1.0.0版発行',
193
- '2012-02-15 v1.1.0版発行']]
211
+ '2020-07-11 v1.2.0版発行']]
194
212
  history = @maker.make_history_list
195
- expect = ['2011年8月3日 v1.0.0版発行', '2012215日 v1.1.0版発行']
213
+ expect = ['2011年8月3日 v1.0.0版発行', '2020711日 v1.2.0版発行']
196
214
  assert_equal expect, history
197
215
  end
198
216
 
@@ -243,4 +261,75 @@ class PDFMakerTest < Test::Unit::TestCase
243
261
  '2012年1月31日 ver 1.2.1発行']
244
262
  assert_equal expect, history
245
263
  end
264
+
265
+ def test_box_setting_is_defined
266
+ %w[column note memo tip info warning important caution notice].each do |name|
267
+ @config['pdfmaker']['boxsetting'] = {
268
+ name => { 'style' => 'simplebox' }
269
+ }
270
+ assert !ReVIEW::LaTeXBox.new.tcbox(@config).empty?
271
+ end
272
+ @config['pdfmaker']['boxsetting'] = {
273
+ 'invalid' => { 'style' => 'simplebox' }
274
+ }
275
+ assert ReVIEW::LaTeXBox.new.tcbox(@config).empty?
276
+ end
277
+
278
+ def test_box_setting_options
279
+ @config['pdfmaker']['boxsetting'] = {
280
+ 'note' => { 'style' => 'simplebox' },
281
+ 'important' => { 'style' => 'simplebox', 'options' => 'colback=blue,arc=3mm' },
282
+ 'caution' => { 'style' => 'squarecaptionbox', 'options_with_caption' => 'attach boxed title to top bottom' }
283
+ }
284
+
285
+ expected = <<-EOS
286
+ \\renewenvironment{reviewnote}[1][]{%
287
+ \\csdef{rv@tmp@withcaption}{true}
288
+ \\notblank{##1}{
289
+ \\begin{rv@simplebox@caption}{##1}[]
290
+ }{
291
+ \\csundef{rv@tmp@withcaption}
292
+ \\begin{rv@simplebox@nocaption}[]
293
+ }
294
+ }{
295
+ \\ifcsdef{rv@tmp@withcaption}{
296
+ \\end{rv@simplebox@caption}
297
+ }{
298
+ \\end{rv@simplebox@nocaption}
299
+ }
300
+ }
301
+ \\renewenvironment{reviewimportant}[1][]{%
302
+ \\csdef{rv@tmp@withcaption}{true}
303
+ \\notblank{##1}{
304
+ \\begin{rv@simplebox@caption}{##1}[colback=blue,arc=3mm]
305
+ }{
306
+ \\csundef{rv@tmp@withcaption}
307
+ \\begin{rv@simplebox@nocaption}[colback=blue,arc=3mm]
308
+ }
309
+ }{
310
+ \\ifcsdef{rv@tmp@withcaption}{
311
+ \\end{rv@simplebox@caption}
312
+ }{
313
+ \\end{rv@simplebox@nocaption}
314
+ }
315
+ }
316
+ \\renewenvironment{reviewcaution}[1][]{%
317
+ \\csdef{rv@tmp@withcaption}{true}
318
+ \\notblank{##1}{
319
+ \\begin{rv@squarecaptionbox@caption}{##1}[attach boxed title to top bottom]
320
+ }{
321
+ \\csundef{rv@tmp@withcaption}
322
+ \\begin{rv@squarecaptionbox@nocaption}[]
323
+ }
324
+ }{
325
+ \\ifcsdef{rv@tmp@withcaption}{
326
+ \\end{rv@squarecaptionbox@caption}
327
+ }{
328
+ \\end{rv@squarecaptionbox@nocaption}
329
+ }
330
+ }
331
+ EOS
332
+ actual = ReVIEW::LaTeXBox.new.tcbox(@config)
333
+ assert_equal expected, actual
334
+ end
246
335
  end
@@ -5,14 +5,14 @@ require 'yaml'
5
5
  require 'rbconfig'
6
6
  require 'open3'
7
7
 
8
- REVIEW_PDFMAKER = File.expand_path('../bin/review-pdfmaker', File.dirname(__FILE__))
8
+ REVIEW_PDFMAKER = File.expand_path('../bin/review-pdfmaker', __dir__)
9
9
 
10
10
  class PDFMakerCmdTest < Test::Unit::TestCase
11
11
  def setup
12
12
  @tmpdir1 = Dir.mktmpdir
13
13
 
14
14
  @old_rubylib = ENV['RUBYLIB']
15
- ENV['RUBYLIB'] = File.expand_path('../lib', File.dirname(__FILE__))
15
+ ENV['RUBYLIB'] = File.expand_path('../lib', __dir__)
16
16
  end
17
17
 
18
18
  def teardown
@@ -30,7 +30,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
30
30
  Dir.chdir(@tmpdir1) do
31
31
  _o, e, s = Open3.capture3("#{ruby_cmd} -S #{REVIEW_PDFMAKER} #{option} #{configfile}")
32
32
  if !e.empty? && !s.success?
33
- STDERR.puts e
33
+ $stderr.puts e
34
34
  end
35
35
  assert s.success?
36
36
  end
@@ -14,6 +14,8 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
14
14
  @config['language'] = 'ja'
15
15
  @book = Book::Base.new
16
16
  @book.config = @config
17
+ @log_io = StringIO.new
18
+ ReVIEW.logger = ReVIEW::Logger.new(@log_io)
17
19
  @compiler = ReVIEW::Compiler.new(@builder)
18
20
  @chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
19
21
  location = Location.new(nil, nil)
@@ -90,9 +92,16 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
90
92
  assert_equal "\n", actual
91
93
  end
92
94
 
93
- def test_inline_i
94
- actual = compile_inline('test @<i>{inline test} test2')
95
- assert_equal 'test inline test test2', actual
95
+ def test_inline_asis
96
+ %w[i b tti ttb bou ami u strong em code ins tcy].each do |tag|
97
+ actual = compile_inline("test @<#{tag}>{inline test} test2")
98
+ assert_equal 'test inline test test2', actual
99
+ end
100
+ end
101
+
102
+ def test_inline_del
103
+ actual = compile_inline('test @<del>{inline test} test2')
104
+ assert_equal 'test test2', actual
96
105
  end
97
106
 
98
107
  def test_inline_i_and_escape
@@ -100,11 +109,6 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
100
109
  assert_equal 'test inline<&;\\ test test2', actual
101
110
  end
102
111
 
103
- def test_inline_b
104
- actual = compile_inline('test @<b>{inline test} test2')
105
- assert_equal 'test inline test test2', actual
106
- end
107
-
108
112
  def test_inline_b_and_escape
109
113
  actual = compile_inline('test @<b>{inline<&;\\ test} test2')
110
114
  assert_equal 'test inline<&;\\ test test2', actual
@@ -115,16 +119,6 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
115
119
  assert_equal 'test inline test test2}', actual
116
120
  end
117
121
 
118
- def test_inline_tti
119
- actual = compile_inline('test @<tti>{inline test} test2')
120
- assert_equal 'test inline test test2', actual
121
- end
122
-
123
- def test_inline_ttb
124
- actual = compile_inline('test @<ttb>{inline test} test2')
125
- assert_equal 'test inline test test2', actual
126
- end
127
-
128
122
  def test_inline_uchar
129
123
  actual = compile_inline('test @<uchar>{2460} test2')
130
124
  assert_equal 'test ① test2', actual
@@ -249,6 +243,17 @@ EOS
249
243
  foo
250
244
  bar
251
245
 
246
+ EOS
247
+ assert_equal expected, actual
248
+
249
+ @config['caption_position']['list'] = 'bottom'
250
+ actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
251
+ expected = <<-EOS
252
+ foo
253
+ bar
254
+
255
+ リスト1.1 this is test<&>_
256
+
252
257
  EOS
253
258
  assert_equal expected, actual
254
259
  end
@@ -264,6 +269,17 @@ EOS
264
269
  1: foo
265
270
  2: bar
266
271
 
272
+ EOS
273
+ assert_equal expected, actual
274
+
275
+ @config['caption_position']['list'] = 'bottom'
276
+ actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
277
+ expected = <<-EOS
278
+ 1: foo
279
+ 2: bar
280
+
281
+ リスト1.1 this is test<&>_
282
+
267
283
  EOS
268
284
  assert_equal expected, actual
269
285
  end
@@ -277,6 +293,18 @@ bar
277
293
 
278
294
  buz
279
295
 
296
+ EOS
297
+ assert_equal expected, actual
298
+
299
+ @config['caption_position']['list'] = 'bottom'
300
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
301
+ expected = <<-EOS
302
+ foo
303
+ bar
304
+
305
+ buz
306
+ foo/bar/test.rb
307
+
280
308
  EOS
281
309
  assert_equal expected, actual
282
310
  end
@@ -308,6 +336,16 @@ FOO
308
336
  foo
309
337
  bar
310
338
 
339
+ EOS
340
+ assert_equal expected, actual
341
+
342
+ @config['caption_position']['list'] = 'bottom'
343
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
344
+ expected = <<-EOS
345
+ foo
346
+ bar
347
+ FOO
348
+
311
349
  EOS
312
350
  assert_equal expected, actual
313
351
  end
@@ -327,6 +365,16 @@ cap1
327
365
  lineA
328
366
  lineB
329
367
 
368
+ EOS
369
+ assert_equal expected, actual
370
+
371
+ @config['caption_position']['list'] = 'bottom'
372
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
373
+ expected = <<-EOS
374
+ lineA
375
+ lineB
376
+ cap1
377
+
330
378
  EOS
331
379
  assert_equal expected, actual
332
380
  end
@@ -348,6 +396,16 @@ cap1
348
396
  lineA
349
397
  lineB
350
398
 
399
+ EOS
400
+ assert_equal expected, actual
401
+
402
+ @config['caption_position']['list'] = 'bottom'
403
+ actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
404
+ expected = <<-EOS
405
+ lineA
406
+ lineB
407
+ cap1
408
+
351
409
  EOS
352
410
  assert_equal expected, actual
353
411
  end
@@ -359,6 +417,16 @@ this is test<&>_
359
417
  1: foo
360
418
  2: bar
361
419
 
420
+ EOS
421
+ assert_equal expected, actual
422
+
423
+ @config['caption_position']['list'] = 'bottom'
424
+ actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
425
+ expected = <<-EOS
426
+ 1: foo
427
+ 2: bar
428
+ this is test<&>_
429
+
362
430
  EOS
363
431
  assert_equal expected, actual
364
432
  end
@@ -387,16 +455,26 @@ EOS
387
455
  aaa\tbbb
388
456
  ccc\tddd<>&
389
457
 
458
+ EOS
459
+ assert_equal expected, actual
460
+
461
+ @config['caption_position']['table'] = 'bottom'
462
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
463
+ expected = <<-EOS
464
+ aaa\tbbb
465
+ ccc\tddd<>&
466
+
467
+ 表1.1 FOO
390
468
  EOS
391
469
  assert_equal expected, actual
392
470
  end
393
471
 
394
472
  def test_empty_table
395
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
396
- assert_equal ':2: error: no rows in the table', e.message
473
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
474
+ assert_equal 'no rows in the table', e.message
397
475
 
398
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
399
- assert_equal ':3: error: no rows in the table', e.message
476
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
477
+ assert_equal 'no rows in the table', e.message
400
478
  end
401
479
 
402
480
  def test_inline_table
@@ -512,6 +590,147 @@ EOS
512
590
  assert_equal expected, actual
513
591
  end
514
592
 
593
+ def test_minicolumn_blocks
594
+ %w[note memo tip info warning important caution notice].each do |type|
595
+ @builder.doc_status.clear
596
+ src = <<-EOS
597
+ //#{type}[#{type}1]{
598
+
599
+ //}
600
+
601
+ //#{type}[#{type}2]{
602
+ //}
603
+ EOS
604
+
605
+ expected = <<-EOS
606
+ #{type}1
607
+
608
+ #{type}2
609
+
610
+ EOS
611
+ assert_equal expected, compile_block(src)
612
+
613
+ src = <<-EOS
614
+ //#{type}[#{type}2]{
615
+
616
+ //}
617
+
618
+ //#{type}[#{type}3]{
619
+
620
+ //}
621
+
622
+ //#{type}[#{type}4]{
623
+
624
+ //}
625
+
626
+ //#{type}[#{type}5]{
627
+
628
+ //}
629
+
630
+ //#{type}[#{type}6]{
631
+
632
+ //}
633
+ EOS
634
+
635
+ expected = <<-EOS
636
+ #{type}2
637
+
638
+ #{type}3
639
+
640
+ #{type}4
641
+
642
+ #{type}5
643
+
644
+ #{type}6
645
+
646
+ EOS
647
+ assert_equal expected, compile_block(src)
648
+
649
+ src = <<-EOS
650
+ //#{type}{
651
+
652
+ * A
653
+
654
+ 1. B
655
+
656
+ //}
657
+
658
+ //#{type}[OMITEND1]{
659
+
660
+ //emlist{
661
+ LIST
662
+ //}
663
+
664
+ //}
665
+ //#{type}[OMITEND2]{
666
+ //}
667
+ EOS
668
+
669
+ expected = <<-EOS
670
+ A
671
+
672
+ 1 B
673
+
674
+ OMITEND1
675
+
676
+ LIST
677
+
678
+ OMITEND2
679
+
680
+ EOS
681
+ assert_equal expected, compile_block(src)
682
+ end
683
+ end
684
+
685
+ def test_minicolumn_blocks_nest_error1
686
+ %w[note memo tip info warning important caution notice].each do |type|
687
+ @builder.doc_status.clear
688
+ src = <<-EOS
689
+ //#{type}{
690
+
691
+ //#{type}{
692
+ //}
693
+
694
+ //}
695
+ EOS
696
+ assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
697
+ assert_match(/minicolumn cannot be nested:/, @log_io.string)
698
+ end
699
+ end
700
+
701
+ def test_minicolumn_blocks_nest_error2
702
+ %w[note memo tip info warning important caution notice].each do |type|
703
+ @builder.doc_status.clear
704
+ src = <<-EOS
705
+ //#{type}{
706
+
707
+ //#{type}{
708
+
709
+ //}
710
+
711
+ //}
712
+ EOS
713
+ assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
714
+ assert_match(/minicolumn cannot be nested:/, @log_io.string)
715
+ end
716
+ end
717
+
718
+ def test_minicolumn_blocks_nest_error3
719
+ %w[memo tip info warning important caution notice].each do |type|
720
+ @builder.doc_status.clear
721
+ src = <<-EOS
722
+ //#{type}{
723
+
724
+ //note{
725
+ //}
726
+
727
+ //}
728
+ EOS
729
+ assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
730
+ assert_match(/minicolumn cannot be nested:/, @log_io.string)
731
+ end
732
+ end
733
+
515
734
  def test_image
516
735
  def @chapter.image(_id)
517
736
  item = Book::Index::Item.new('sampleimg', 1)
@@ -521,6 +740,10 @@ EOS
521
740
 
522
741
  actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
523
742
  assert_equal %Q(図1.1 sample photo\n\n), actual
743
+
744
+ @config['caption_position']['image'] = 'top'
745
+ actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
746
+ assert_equal %Q(図1.1 sample photo\n\n), actual
524
747
  end
525
748
 
526
749
  def test_image_with_metric
@@ -540,19 +763,25 @@ EOS
540
763
  end
541
764
 
542
765
  def test_inline_unknown
543
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<img>{n}\n" }
544
- assert_equal ':1: error: unknown image: n', e.message
545
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<fn>{n}\n" }
546
- assert_equal ':1: error: unknown footnote: n', e.message
547
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<hd>{n}\n" }
548
- assert_equal ':1: error: unknown headline: n', e.message
766
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
767
+ assert_match(/unknown image: n/, @log_io.string)
768
+
769
+ @log_io.string = ''
770
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
771
+ assert_match(/unknown footnote: n/, @log_io.string)
772
+
773
+ @log_io.string = ''
774
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
775
+ assert_match(/unknown headline: n/, @log_io.string)
549
776
  %w[list table column].each do |name|
550
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<#{name}>{n}\n" }
551
- assert_equal ":1: error: unknown #{name}: n", e.message
777
+ @log_io.string = ''
778
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
779
+ assert_match(/unknown #{name}: n/, @log_io.string)
552
780
  end
553
781
  %w[chap chapref title].each do |name|
554
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<#{name}>{n}\n" }
555
- assert_equal ':1: error: key not found: "n"', e.message
782
+ @log_io.string = ''
783
+ assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
784
+ assert_match(/key not found: "n"/, @log_io.string)
556
785
  end
557
786
  end
558
787
 
@@ -652,5 +881,290 @@ e=mc^2
652
881
  EOS
653
882
  actual = compile_block(src)
654
883
  assert_equal expected, actual
884
+
885
+ @config['caption_position']['equation'] = 'bottom'
886
+ expected = <<-EOS
887
+ 式1.1
888
+
889
+ e=mc^2
890
+ 式1.1 The Equivalence of Mass and Energy
891
+
892
+ EOS
893
+ actual = compile_block(src)
894
+ assert_equal expected, actual
895
+ end
896
+
897
+ def test_nest_error_open
898
+ src = <<-EOS
899
+ //endchild
900
+ EOS
901
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
902
+ assert_equal "//endchild is shown, but any opened //beginchild doesn't exist", e.message
903
+ end
904
+
905
+ def test_nest_error_close1
906
+ src = <<-EOS
907
+ //beginchild
908
+ EOS
909
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
910
+ assert_equal "//beginchild is shown, but previous element isn't ul, ol, or dl", e.message
911
+ end
912
+
913
+ def test_nest_error_close2
914
+ src = <<-EOS
915
+ * foo
916
+
917
+ //beginchild
918
+
919
+ 1. foo
920
+
921
+ //beginchild
922
+
923
+ : foo
924
+
925
+ //beginchild
926
+ EOS
927
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
928
+ assert_equal '//beginchild of dl,ol,ul misses //endchild', e.message
929
+ end
930
+
931
+ def test_nest_error_close3
932
+ src = <<-EOS
933
+ * foo
934
+
935
+ //beginchild
936
+
937
+ 1. foo
938
+
939
+ //beginchild
940
+
941
+ : foo
942
+
943
+ //beginchild
944
+
945
+ //endchild
946
+ EOS
947
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
948
+ assert_equal '//beginchild of ol,ul misses //endchild', e.message
949
+ end
950
+
951
+ def test_nest_ul
952
+ src = <<-EOS
953
+ * UL1
954
+
955
+ //beginchild
956
+
957
+ 1. UL1-OL1
958
+ 2. UL1-OL2
959
+
960
+ * UL1-UL1
961
+ * UL1-UL2
962
+
963
+ : UL1-DL1
964
+ UL1-DD1
965
+ : UL1-DL2
966
+ UL1-DD2
967
+
968
+ //endchild
969
+
970
+ * UL2
971
+
972
+ //beginchild
973
+
974
+ UL2-PARA
975
+
976
+ //endchild
977
+ EOS
978
+
979
+ expected = <<-EOS
980
+ UL1
981
+
982
+ 1 UL1-OL1
983
+ 2 UL1-OL2
984
+
985
+ UL1-UL1
986
+ UL1-UL2
987
+
988
+ UL1-DL1
989
+ UL1-DD1
990
+ UL1-DL2
991
+ UL1-DD2
992
+
993
+ UL2
994
+ UL2-PARA
995
+ EOS
996
+
997
+ actual = compile_block(src)
998
+ assert_equal expected, actual
999
+ end
1000
+
1001
+ def test_nest_ol
1002
+ src = <<-EOS
1003
+ 1. OL1
1004
+
1005
+ //beginchild
1006
+
1007
+ 1. OL1-OL1
1008
+ 2. OL1-OL2
1009
+
1010
+ * OL1-UL1
1011
+ * OL1-UL2
1012
+
1013
+ : OL1-DL1
1014
+ OL1-DD1
1015
+ : OL1-DL2
1016
+ OL1-DD2
1017
+
1018
+ //endchild
1019
+
1020
+ 2. OL2
1021
+
1022
+ //beginchild
1023
+
1024
+ OL2-PARA
1025
+
1026
+ //endchild
1027
+ EOS
1028
+
1029
+ expected = <<-EOS
1030
+ 1 OL1
1031
+
1032
+ 1 OL1-OL1
1033
+ 2 OL1-OL2
1034
+
1035
+ OL1-UL1
1036
+ OL1-UL2
1037
+
1038
+ OL1-DL1
1039
+ OL1-DD1
1040
+ OL1-DL2
1041
+ OL1-DD2
1042
+
1043
+ 2 OL2
1044
+ OL2-PARA
1045
+ EOS
1046
+
1047
+ actual = compile_block(src)
1048
+ assert_equal expected, actual
1049
+ end
1050
+
1051
+ def test_nest_dl
1052
+ src = <<-EOS
1053
+ : DL1
1054
+
1055
+ //beginchild
1056
+
1057
+ 1. DL1-OL1
1058
+ 2. DL1-OL2
1059
+
1060
+ * DL1-UL1
1061
+ * DL1-UL2
1062
+
1063
+ : DL1-DL1
1064
+ DL1-DD1
1065
+ : DL1-DL2
1066
+ DL1-DD2
1067
+
1068
+ //endchild
1069
+
1070
+ : DL2
1071
+ DD2
1072
+
1073
+ //beginchild
1074
+
1075
+ * DD2-UL1
1076
+ * DD2-UL2
1077
+
1078
+ DD2-PARA
1079
+
1080
+ //endchild
1081
+ EOS
1082
+
1083
+ expected = <<-EOS
1084
+ DL1
1085
+
1086
+ 1 DL1-OL1
1087
+ 2 DL1-OL2
1088
+
1089
+ DL1-UL1
1090
+ DL1-UL2
1091
+
1092
+ DL1-DL1
1093
+ DL1-DD1
1094
+ DL1-DL2
1095
+ DL1-DD2
1096
+
1097
+ DL2
1098
+ DD2
1099
+
1100
+ DD2-UL1
1101
+ DD2-UL2
1102
+
1103
+ DD2-PARA
1104
+ EOS
1105
+
1106
+ actual = compile_block(src)
1107
+ assert_equal expected, actual
1108
+ end
1109
+
1110
+ def test_nest_multi
1111
+ src = <<-EOS
1112
+ 1. OL1
1113
+
1114
+ //beginchild
1115
+
1116
+ 1. OL1-OL1
1117
+
1118
+ //beginchild
1119
+
1120
+ * OL1-OL1-UL1
1121
+
1122
+ OL1-OL1-PARA
1123
+
1124
+ //endchild
1125
+
1126
+ 2. OL1-OL2
1127
+
1128
+ * OL1-UL1
1129
+
1130
+ //beginchild
1131
+
1132
+ : OL1-UL1-DL1
1133
+ OL1-UL1-DD1
1134
+
1135
+ OL1-UL1-PARA
1136
+
1137
+ //endchild
1138
+
1139
+ * OL1-UL2
1140
+
1141
+ //endchild
1142
+ EOS
1143
+ expected = <<-EOS
1144
+ 1 OL1
1145
+
1146
+ 1 OL1-OL1
1147
+
1148
+
1149
+ OL1-OL1-UL1
1150
+
1151
+ OL1-OL1-PARA
1152
+
1153
+ 2 OL1-OL2
1154
+
1155
+ OL1-UL1
1156
+
1157
+
1158
+ OL1-UL1-DL1
1159
+ OL1-UL1-DD1
1160
+
1161
+ OL1-UL1-PARA
1162
+
1163
+ OL1-UL2
1164
+
1165
+ EOS
1166
+
1167
+ actual = compile_block(src)
1168
+ assert_equal expected, actual
655
1169
  end
656
1170
  end