review 5.0.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-tex.yml +35 -0
  3. data/.github/workflows/ruby-win.yml +8 -4
  4. data/.github/workflows/ruby.yml +6 -2
  5. data/.rubocop.yml +24 -9
  6. data/NEWS.ja.md +215 -0
  7. data/NEWS.md +215 -1
  8. data/README.md +7 -6
  9. data/Rakefile +7 -2
  10. data/bin/review +2 -4
  11. data/bin/review-catalog-converter +3 -3
  12. data/bin/review-check +6 -8
  13. data/bin/review-checkdep +1 -4
  14. data/bin/review-compile +10 -20
  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 +11 -5
  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 +3 -3
  25. data/bin/review-vol +1 -4
  26. data/bin/review-webmaker +1 -3
  27. data/doc/config.yml.sample +23 -5
  28. data/doc/config.yml.sample-simple +1 -1
  29. data/doc/format.ja.md +49 -12
  30. data/doc/format.md +52 -12
  31. data/doc/quickstart.ja.md +11 -1
  32. data/doc/quickstart.md +11 -2
  33. data/doc/writing_vertical.ja.md +6 -0
  34. data/lib/review/book/base.rb +4 -0
  35. data/lib/review/book/book_unit.rb +15 -2
  36. data/lib/review/book/chapter.rb +3 -0
  37. data/lib/review/book/index.rb +5 -1
  38. data/lib/review/book/volume.rb +1 -0
  39. data/lib/review/builder.rb +90 -54
  40. data/lib/review/call_hook.rb +20 -0
  41. data/lib/review/catalog.rb +2 -0
  42. data/lib/review/compiler.rb +88 -52
  43. data/lib/review/configure.rb +64 -7
  44. data/lib/review/epubmaker/content.rb +113 -0
  45. data/lib/review/epubmaker/epubcommon.rb +372 -0
  46. data/lib/review/epubmaker/epubv2.rb +178 -0
  47. data/lib/review/epubmaker/epubv3.rb +231 -0
  48. data/lib/review/epubmaker/producer.rb +167 -0
  49. data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
  50. data/lib/review/epubmaker/zip_exporter.rb +84 -0
  51. data/lib/review/epubmaker.rb +114 -129
  52. data/lib/review/exception.rb +13 -0
  53. data/lib/review/htmlbuilder.rb +109 -67
  54. data/lib/review/htmlutils.rb +1 -1
  55. data/lib/review/i18n.rb +1 -0
  56. data/lib/review/i18n.yml +6 -0
  57. data/lib/review/idgxmlbuilder.rb +72 -48
  58. data/lib/review/idgxmlmaker.rb +15 -14
  59. data/lib/review/img_math.rb +239 -0
  60. data/lib/review/index_builder.rb +90 -32
  61. data/lib/review/init.rb +4 -4
  62. data/lib/review/latexbox.rb +58 -0
  63. data/lib/review/latexbuilder.rb +79 -58
  64. data/lib/review/latexutils.rb +9 -1
  65. data/lib/review/lineinput.rb +112 -2
  66. data/lib/review/loggable.rb +27 -0
  67. data/lib/review/logger.rb +89 -2
  68. data/lib/review/makerhelper.rb +7 -206
  69. data/lib/review/markdownbuilder.rb +44 -4
  70. data/lib/review/pdfmaker.rb +70 -51
  71. data/lib/review/plaintextbuilder.rb +20 -11
  72. data/lib/review/preprocessor/directive.rb +35 -0
  73. data/lib/review/preprocessor/line.rb +34 -0
  74. data/lib/review/preprocessor/repository.rb +177 -0
  75. data/lib/review/preprocessor.rb +105 -301
  76. data/lib/review/rstbuilder.rb +13 -4
  77. data/lib/review/sec_counter.rb +1 -0
  78. data/lib/review/template.rb +11 -1
  79. data/lib/review/textmaker.rb +23 -20
  80. data/lib/review/textutils.rb +10 -17
  81. data/lib/review/tocprinter.rb +93 -71
  82. data/lib/review/topbuilder.rb +44 -19
  83. data/lib/review/update.rb +5 -6
  84. data/lib/review/version.rb +1 -1
  85. data/lib/review/volumeprinter.rb +11 -12
  86. data/lib/review/webmaker.rb +31 -27
  87. data/lib/review/webtocprinter.rb +10 -9
  88. data/lib/review/yamlloader.rb +2 -1
  89. data/lib/review.rb +1 -1
  90. data/review.gemspec +5 -3
  91. data/samples/sample-book/src/config-epub2.yml +1 -1
  92. data/samples/sample-book/src/config.yml +1 -1
  93. data/samples/sample-book/src/lib/tasks/review.rake +19 -1
  94. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +2 -1
  95. data/samples/syntax-book/ch01.re +1 -1
  96. data/samples/syntax-book/ch02.re +30 -6
  97. data/samples/syntax-book/ch03.re +1 -1
  98. data/samples/syntax-book/images/img3-2.png +0 -0
  99. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +2 -1
  100. data/templates/html/_colophon.html.erb +23 -0
  101. data/templates/html/_colophon_history.html.erb +9 -0
  102. data/templates/html/_cover.html.erb +10 -0
  103. data/templates/html/_part_body.html.erb +6 -0
  104. data/templates/html/_titlepage.html.erb +20 -0
  105. data/templates/html/layout-html5.html.erb +6 -0
  106. data/templates/html/layout-xhtml1.html.erb +6 -0
  107. data/templates/latex/config.erb +11 -0
  108. data/templates/latex/review-jlreq/review-base.sty +7 -9
  109. data/templates/latex/review-jlreq/review-jlreq.cls +48 -6
  110. data/templates/latex/review-jlreq/review-style.sty +6 -1
  111. data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
  112. data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
  113. data/templates/latex/review-jsbook/review-base.sty +13 -9
  114. data/templates/latex/review-jsbook/review-jsbook.cls +41 -6
  115. data/templates/latex/review-jsbook/review-style.sty +6 -1
  116. data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
  117. data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
  118. data/templates/opf/epubv2.opf.erb +7 -7
  119. data/templates/opf/epubv3.opf.erb +7 -7
  120. data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
  121. data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
  122. data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
  123. data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
  124. data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
  125. data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
  126. data/templates/web/html/layout-html5.html.erb +6 -5
  127. data/templates/web/html/layout-xhtml1.html.erb +6 -0
  128. data/test/assets/header_listener.html +35 -0
  129. data/test/assets/img_math/img1.png +0 -0
  130. data/test/assets/img_math/img2.png +0 -0
  131. data/test/assets/img_math/img3.png +0 -0
  132. data/test/assets/syntax_book_index_detail.txt +60 -0
  133. data/test/assets/test_template.tex +7 -1
  134. data/test/assets/test_template_backmatter.tex +7 -1
  135. data/test/run_test.rb +1 -1
  136. data/test/test_book_chapter.rb +27 -4
  137. data/test/test_builder.rb +10 -8
  138. data/test/test_catalog_converter_cmd.rb +1 -1
  139. data/test/test_epub3maker.rb +168 -124
  140. data/test/test_epubmaker.rb +248 -131
  141. data/test/test_epubmaker_cmd.rb +15 -4
  142. data/test/test_helper.rb +5 -4
  143. data/test/test_htmlbuilder.rb +170 -31
  144. data/test/test_idgxmlbuilder.rb +44 -23
  145. data/test/test_idgxmlmaker_cmd.rb +7 -3
  146. data/test/test_img_math.rb +111 -0
  147. data/test/test_index.rb +30 -4
  148. data/test/test_indexbuilder.rb +5 -5
  149. data/test/test_latexbuilder.rb +151 -26
  150. data/test/test_latexbuilder_v2.rb +18 -10
  151. data/test/test_lineinput.rb +20 -93
  152. data/test/test_markdownbuilder.rb +42 -0
  153. data/test/test_pdfmaker.rb +90 -0
  154. data/test/test_pdfmaker_cmd.rb +2 -2
  155. data/test/test_plaintextbuilder.rb +56 -40
  156. data/test/test_preprocessor.rb +188 -1
  157. data/test/test_reviewheaderlistener.rb +49 -0
  158. data/test/test_rstbuilder.rb +13 -0
  159. data/test/test_template.rb +12 -2
  160. data/test/test_textmaker_cmd.rb +5 -1
  161. data/test/test_tocprinter.rb +46 -0
  162. data/test/test_topbuilder.rb +50 -19
  163. data/test/test_update.rb +34 -34
  164. data/test/test_zip_exporter.rb +5 -6
  165. metadata +95 -17
  166. data/lib/epubmaker/content.rb +0 -111
  167. data/lib/epubmaker/epubcommon.rb +0 -449
  168. data/lib/epubmaker/epubv2.rb +0 -142
  169. data/lib/epubmaker/epubv3.rb +0 -235
  170. data/lib/epubmaker/producer.rb +0 -375
  171. data/lib/epubmaker/zip_exporter.rb +0 -81
  172. data/lib/epubmaker.rb +0 -23
  173. data/lib/lineinput.rb +0 -155
@@ -1,13 +1,11 @@
1
1
  require 'test_helper'
2
- require 'epubmaker'
2
+ require 'review/configure'
3
3
  require 'review/epubmaker'
4
4
 
5
5
  class EPUB3MakerTest < Test::Unit::TestCase
6
- include EPUBMaker
7
-
8
6
  def setup
9
- @producer = Producer.new
10
- @producer.merge_config(
7
+ config = ReVIEW::Configure.values
8
+ config.merge!(
11
9
  'bookname' => 'sample',
12
10
  'title' => 'Sample Book',
13
11
  'epubversion' => 3,
@@ -17,30 +15,32 @@ class EPUB3MakerTest < Test::Unit::TestCase
17
15
  'modified' => '2014-12-13T14:15:16Z',
18
16
  'titlepage' => nil
19
17
  )
20
- @output = StringIO.new
18
+ @producer = ReVIEW::EPUBMaker::Producer.new(config)
21
19
  end
22
20
 
23
21
  def test_initialize
24
- assert Producer.new
22
+ assert ReVIEW::EPUBMaker::Producer.new(ReVIEW::Configure.values)
25
23
  end
26
24
 
27
25
  def test_resource_en
28
- @producer.merge_config('language' => 'en')
29
- assert_equal 'Table of Contents', @producer.res.v('toctitle')
26
+ @producer.config['language'] = 'en'
27
+ @producer.modify_config
28
+ assert_equal 'Table of Contents', ReVIEW::I18n.t('toctitle')
30
29
  end
31
30
 
32
31
  def test_resource_ja
33
- @producer.merge_config('language' => 'ja')
34
- assert_equal '目次', @producer.res.v('toctitle')
32
+ @producer.config['language'] = 'ja'
33
+ @producer.modify_config
34
+ assert_equal '目次', ReVIEW::I18n.t('toctitle')
35
35
  end
36
36
 
37
37
  def test_mimetype
38
- @producer.mimetype(@output)
39
- assert_equal 'application/epub+zip', @output.string
38
+ output = @producer.instance_eval { @epub.mimetype }
39
+ assert_equal 'application/epub+zip', output
40
40
  end
41
41
 
42
42
  def test_container
43
- @producer.container(@output)
43
+ output = @producer.instance_eval { @epub.container }
44
44
  expect = <<EOT
45
45
  <?xml version="1.0" encoding="UTF-8"?>
46
46
  <container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
@@ -49,11 +49,11 @@ class EPUB3MakerTest < Test::Unit::TestCase
49
49
  </rootfiles>
50
50
  </container>
51
51
  EOT
52
- assert_equal expect, @output.string
52
+ assert_equal expect, output
53
53
  end
54
54
 
55
55
  def test_stage1_opf
56
- @producer.opf(@output)
56
+ output = @producer.instance_eval { @epub.opf }
57
57
  expect = <<EOT
58
58
  <?xml version="1.0" encoding="UTF-8"?>
59
59
  <package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="en">
@@ -77,15 +77,16 @@ EOT
77
77
  </guide>
78
78
  </package>
79
79
  EOT
80
- assert_equal expect, @output.string
80
+ assert_equal expect, output
81
81
  end
82
82
 
83
83
  def test_stage1_opf_ebpaj
84
- @producer.merge_config(
84
+ @producer.config.merge!(
85
85
  'opf_prefix' => { 'ebpaj' => 'http://www.ebpaj.jp/' },
86
86
  'opf_meta' => { 'ebpaj:guide-version' => '1.1.2' }
87
87
  )
88
- @producer.opf(@output)
88
+ @producer.modify_config
89
+ output = @producer.instance_eval { @epub.opf }
89
90
  expect = <<EOT
90
91
  <?xml version="1.0" encoding="UTF-8"?>
91
92
  <package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="en" prefix="ebpaj: http://www.ebpaj.jp/">
@@ -110,14 +111,15 @@ EOT
110
111
  </guide>
111
112
  </package>
112
113
  EOT
113
- assert_equal expect, @output.string
114
+ assert_equal expect, output
114
115
  end
115
116
 
116
117
  def test_stage1_opf_fileas
117
- @producer.config['title'] = { 'name' => 'これは書籍です', 'file-as' => 'コレハショセキデス' }
118
- @producer.config['aut'] = [{ 'name' => '著者A', 'file-as' => 'チョシャA' }, { 'name' => '著者B', 'file-as' => 'チョシャB' }]
119
- @producer.config['pbl'] = [{ 'name' => '出版社', 'file-as' => 'シュッパンシャ' }]
120
- @producer.opf(@output)
118
+ @producer.config.merge!('title' => { 'name' => 'これは書籍です', 'file-as' => 'コレハショセキデス' },
119
+ 'aut' => [{ 'name' => '著者A', 'file-as' => 'チョシャA' }, { 'name' => '著者B', 'file-as' => 'チョシャB' }],
120
+ 'pbl' => [{ 'name' => '出版社', 'file-as' => 'シュッパンシャ' }])
121
+ @producer.modify_config
122
+ output = @producer.instance_eval { @epub.opf }
121
123
  expect = <<EOT
122
124
  <?xml version="1.0" encoding="UTF-8"?>
123
125
  <package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="en">
@@ -154,11 +156,11 @@ EOT
154
156
  </guide>
155
157
  </package>
156
158
  EOT
157
- assert_equal expect, @output.string
159
+ assert_equal expect, output
158
160
  end
159
161
 
160
162
  def test_stage1_ncx
161
- @producer.ncx(@output)
163
+ output = @producer.instance_eval { @epub.ncx([]) }
162
164
  expect = <<EOT
163
165
  <?xml version="1.0" encoding="UTF-8"?>
164
166
  <!DOCTYPE html>
@@ -176,27 +178,27 @@ EOT
176
178
  </body>
177
179
  </html>
178
180
  EOT
179
- assert_equal expect, @output.string
181
+ assert_equal expect, output
180
182
  end
181
183
 
182
184
  def stage2
183
185
  # add one item
184
- @producer.contents << Content.new({ 'file' => 'ch01.html', 'title' => 'CH01', 'level' => 1 })
186
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch01.html', title: 'CH01', level: 1)
185
187
  end
186
188
 
187
189
  def test_stage2_add_l1item
188
190
  stage2
189
- expect = EPUBMaker::Content.new('ch01.html',
190
- 'ch01-html',
191
- 'application/xhtml+xml',
192
- 'CH01',
193
- 1)
191
+ expect = ReVIEW::EPUBMaker::Content.new(file: 'ch01.html',
192
+ id: 'ch01-html',
193
+ media: 'application/xhtml+xml',
194
+ title: 'CH01',
195
+ level: 1)
194
196
  assert_equal expect, @producer.contents[0]
195
197
  end
196
198
 
197
199
  def test_stage2_opf
198
200
  stage2
199
- @producer.opf(@output)
201
+ output = @producer.instance_eval { @epub.opf }
200
202
  expect = <<EOT
201
203
  <?xml version="1.0" encoding="UTF-8"?>
202
204
  <package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="en">
@@ -222,12 +224,12 @@ EOT
222
224
  </guide>
223
225
  </package>
224
226
  EOT
225
- assert_equal expect, @output.string
227
+ assert_equal expect, output
226
228
  end
227
229
 
228
230
  def test_stage2_ncx
229
231
  stage2
230
- @producer.ncx(@output)
232
+ output = @producer.instance_eval { @epub.ncx([]) }
231
233
  expect = <<EOT
232
234
  <?xml version="1.0" encoding="UTF-8"?>
233
235
  <!DOCTYPE html>
@@ -246,54 +248,54 @@ EOT
246
248
  </body>
247
249
  </html>
248
250
  EOT
249
- assert_equal expect, @output.string
251
+ assert_equal expect, output
250
252
  end
251
253
 
252
254
  def stage3
253
255
  # add more items
254
- @producer.contents << Content.new({ 'file' => 'ch01.html', 'title' => %Q(CH01<>&"), 'level' => 1 })
255
- @producer.contents << Content.new({ 'file' => 'ch02.html', 'title' => 'CH02', 'level' => 1 })
256
- @producer.contents << Content.new({ 'file' => 'ch02.html#S1', 'title' => 'CH02.1', 'level' => 2 })
257
- @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1', 'title' => 'CH02.1.1', 'level' => 3 })
258
- @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1.1', 'title' => 'CH02.1.1.1', 'level' => 4 })
259
- @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1.1.1', 'title' => 'CH02.1.1.1.1', 'level' => 5 })
260
- @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1.2', 'title' => 'CH02.1.1.2', 'level' => 4 })
261
- @producer.contents << Content.new({ 'file' => 'ch02.html#S2', 'title' => 'CH02.2', 'level' => 2 })
262
- @producer.contents << Content.new({ 'file' => 'ch02.html#S2.1', 'title' => 'CH02.2.1', 'level' => 3 })
263
- @producer.contents << Content.new({ 'file' => 'ch03.html', 'title' => 'CH03', 'level' => 1, 'properties' => ['mathml'] })
264
- @producer.contents << Content.new({ 'file' => 'ch03.html#S1', 'title' => 'CH03.1', 'level' => 2 })
265
- @producer.contents << Content.new({ 'file' => 'ch03.html#S1.1', 'title' => 'CH03.1.1', 'level' => 3 })
266
- @producer.contents << Content.new({ 'file' => 'ch04.html', 'title' => 'CH04', 'level' => 1 })
267
- @producer.contents << Content.new({ 'file' => 'sample.png' })
268
- @producer.contents << Content.new({ 'file' => 'sample.jpg' })
269
- @producer.contents << Content.new({ 'file' => 'sample.JPEG' })
270
- @producer.contents << Content.new({ 'file' => 'sample.SvG' })
271
- @producer.contents << Content.new({ 'file' => 'sample.GIF' })
272
- @producer.contents << Content.new({ 'file' => 'sample.css' })
256
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch01.html', title: %Q(CH01<>&"), level: 1)
257
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html', title: 'CH02', level: 1)
258
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1', title: 'CH02.1', level: 2)
259
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1', title: 'CH02.1.1', level: 3)
260
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1.1', title: 'CH02.1.1.1', level: 4)
261
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1.1.1', title: 'CH02.1.1.1.1', level: 5)
262
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1.2', title: 'CH02.1.1.2', level: 4)
263
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S2', title: 'CH02.2', level: 2)
264
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S2.1', title: 'CH02.2.1', level: 3)
265
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch03.html', title: 'CH03', level: 1, properties: ['mathml'])
266
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch03.html#S1', title: 'CH03.1', level: 2)
267
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch03.html#S1.1', title: 'CH03.1.1', level: 3)
268
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch04.html', title: 'CH04', level: 1)
269
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'sample.png')
270
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'sample.jpg')
271
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'sample.JPEG')
272
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'sample.SvG')
273
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'sample.GIF')
274
+ @producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'sample.css')
273
275
  end
274
276
 
275
277
  def test_stage3_add_various_items
276
278
  stage3
277
279
  expect = [
278
- Content.new('ch01.html', 'ch01-html', 'application/xhtml+xml', %Q(CH01<>&"), 1),
279
- Content.new('ch02.html', 'ch02-html', 'application/xhtml+xml', 'CH02', 1),
280
- Content.new('ch02.html#S1', 'ch02-html#S1', 'html#s1', 'CH02.1', 2),
281
- Content.new('ch02.html#S1.1', 'ch02-html#S1-1', '1', 'CH02.1.1', 3),
282
- Content.new('ch02.html#S1.1.1', 'ch02-html#S1-1-1', '1', 'CH02.1.1.1', 4),
283
- Content.new('ch02.html#S1.1.1.1', 'ch02-html#S1-1-1-1', '1', 'CH02.1.1.1.1', 5),
284
- Content.new('ch02.html#S1.1.2', 'ch02-html#S1-1-2', '2', 'CH02.1.1.2', 4),
285
- Content.new('ch02.html#S2', 'ch02-html#S2', 'html#s2', 'CH02.2', 2),
286
- Content.new('ch02.html#S2.1', 'ch02-html#S2-1', '1', 'CH02.2.1', 3),
287
- Content.new('ch03.html', 'ch03-html', 'application/xhtml+xml', 'CH03', 1, nil, ['mathml']),
288
- Content.new('ch03.html#S1', 'ch03-html#S1', 'html#s1', 'CH03.1', 2),
289
- Content.new('ch03.html#S1.1', 'ch03-html#S1-1', '1', 'CH03.1.1', 3),
290
- Content.new('ch04.html', 'ch04-html', 'application/xhtml+xml', 'CH04', 1),
291
- Content.new('sample.png', 'sample-png', 'image/png'),
292
- Content.new('sample.jpg', 'sample-jpg', 'image/jpeg'),
293
- Content.new('sample.JPEG', 'sample-JPEG', 'image/jpeg'),
294
- Content.new('sample.SvG', 'sample-SvG', 'image/svg+xml'),
295
- Content.new('sample.GIF', 'sample-GIF', 'image/gif'),
296
- Content.new('sample.css', 'sample-css', 'text/css')
280
+ ReVIEW::EPUBMaker::Content.new(file: 'ch01.html', id: 'ch01-html', media: 'application/xhtml+xml', title: %Q(CH01<>&"), level: 1),
281
+ ReVIEW::EPUBMaker::Content.new(file: 'ch02.html', id: 'ch02-html', media: 'application/xhtml+xml', title: 'CH02', level: 1),
282
+ ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1', id: 'ch02-html#S1', media: 'html#s1', title: 'CH02.1', level: 2),
283
+ ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1', id: 'ch02-html#S1-1', media: '1', title: 'CH02.1.1', level: 3),
284
+ ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1.1', id: 'ch02-html#S1-1-1', media: '1', title: 'CH02.1.1.1', level: 4),
285
+ ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1.1.1', id: 'ch02-html#S1-1-1-1', media: '1', title: 'CH02.1.1.1.1', level: 5),
286
+ ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1.2', id: 'ch02-html#S1-1-2', media: '2', title: 'CH02.1.1.2', level: 4),
287
+ ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S2', id: 'ch02-html#S2', media: 'html#s2', title: 'CH02.2', level: 2),
288
+ ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S2.1', id: 'ch02-html#S2-1', media: '1', title: 'CH02.2.1', level: 3),
289
+ ReVIEW::EPUBMaker::Content.new(file: 'ch03.html', id: 'ch03-html', media: 'application/xhtml+xml', title: 'CH03', level: 1, properties: ['mathml']),
290
+ ReVIEW::EPUBMaker::Content.new(file: 'ch03.html#S1', id: 'ch03-html#S1', media: 'html#s1', title: 'CH03.1', level: 2),
291
+ ReVIEW::EPUBMaker::Content.new(file: 'ch03.html#S1.1', id: 'ch03-html#S1-1', media: '1', title: 'CH03.1.1', level: 3),
292
+ ReVIEW::EPUBMaker::Content.new(file: 'ch04.html', id: 'ch04-html', media: 'application/xhtml+xml', title: 'CH04', level: 1),
293
+ ReVIEW::EPUBMaker::Content.new(file: 'sample.png', id: 'sample-png', media: 'image/png'),
294
+ ReVIEW::EPUBMaker::Content.new(file: 'sample.jpg', id: 'sample-jpg', media: 'image/jpeg'),
295
+ ReVIEW::EPUBMaker::Content.new(file: 'sample.JPEG', id: 'sample-JPEG', media: 'image/jpeg'),
296
+ ReVIEW::EPUBMaker::Content.new(file: 'sample.SvG', id: 'sample-SvG', media: 'image/svg+xml'),
297
+ ReVIEW::EPUBMaker::Content.new(file: 'sample.GIF', id: 'sample-GIF', media: 'image/gif'),
298
+ ReVIEW::EPUBMaker::Content.new(file: 'sample.css', id: 'sample-css', media: 'text/css')
297
299
  ]
298
300
 
299
301
  assert_equal expect, @producer.contents
@@ -301,7 +303,7 @@ EOT
301
303
 
302
304
  def test_stage3_opf
303
305
  stage3
304
- @producer.opf(@output)
306
+ output = @producer.instance_eval { @epub.opf }
305
307
  expect = <<EOT
306
308
  <?xml version="1.0" encoding="UTF-8"?>
307
309
  <package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="en">
@@ -339,12 +341,13 @@ EOT
339
341
  </guide>
340
342
  </package>
341
343
  EOT
342
- assert_equal expect, @output.string
344
+ assert_equal expect, output
343
345
  end
344
346
 
345
347
  def test_stage3_ncx
346
348
  stage3
347
- @producer.ncx(@output)
349
+ @producer.config['toclevel'] = 2
350
+ output = @producer.instance_eval { @epub.ncx([]) }
348
351
  expect = <<EOT
349
352
  <?xml version="1.0" encoding="UTF-8"?>
350
353
  <!DOCTYPE html>
@@ -371,12 +374,13 @@ EOT
371
374
  </body>
372
375
  </html>
373
376
  EOT
374
- assert_equal expect, @output.string
377
+ assert_equal expect, output
375
378
  end
376
379
 
377
380
  def test_stage3_mytoc
378
381
  stage3
379
- @producer.mytoc(@output)
382
+ @producer.config['toclevel'] = 2
383
+ output = @producer.instance_eval { @epub.mytoc }
380
384
  expect = <<EOT
381
385
  <?xml version="1.0" encoding="UTF-8"?>
382
386
  <!DOCTYPE html>
@@ -401,13 +405,17 @@ EOT
401
405
  </ul></body>
402
406
  </html>
403
407
  EOT
404
- assert_equal expect, @output.string
408
+ assert_equal expect, output
405
409
  end
406
410
 
407
411
  def test_stage3_flat
408
- @producer.merge_config('epubmaker' => { 'flattoc' => true, 'flattocindent' => false })
412
+ @producer.config.deep_merge!(
413
+ 'toclevel' => 2,
414
+ 'epubmaker' => { 'flattoc' => true, 'flattocindent' => false }
415
+ )
416
+ @producer.modify_config
409
417
  stage3
410
- @producer.mytoc(@output)
418
+ output = @producer.instance_eval { @epub.mytoc }
411
419
  expect = <<EOT
412
420
  <?xml version="1.0" encoding="UTF-8"?>
413
421
  <!DOCTYPE html>
@@ -431,12 +439,12 @@ EOT
431
439
  </body>
432
440
  </html>
433
441
  EOT
434
- assert_equal expect, @output.string
442
+ assert_equal expect, output
435
443
  end
436
444
 
437
445
  def test_stage3_cover
438
446
  stage3
439
- @producer.cover(@output)
447
+ output = @producer.instance_eval { @epub.cover }
440
448
  expect = <<EOT
441
449
  <?xml version="1.0" encoding="UTF-8"?>
442
450
  <!DOCTYPE html>
@@ -451,13 +459,14 @@ EOT
451
459
  </body>
452
460
  </html>
453
461
  EOT
454
- assert_equal expect, @output.string
462
+ assert_equal expect, output
455
463
  end
456
464
 
457
465
  def test_stage3_cover_with_image
458
466
  stage3
459
467
  @producer.config['coverimage'] = 'sample.png'
460
- @producer.cover(@output)
468
+ @producer.modify_config
469
+ output = @producer.instance_eval { @epub.cover }
461
470
  expect = <<EOT
462
471
  <?xml version="1.0" encoding="UTF-8"?>
463
472
  <!DOCTYPE html>
@@ -474,13 +483,14 @@ EOT
474
483
  </body>
475
484
  </html>
476
485
  EOT
477
- assert_equal expect, @output.string
486
+ assert_equal expect, output
478
487
  end
479
488
 
480
489
  def test_colophon_default
481
- @producer.config['aut'] = ['Mr.Smith']
482
- @producer.config['pbl'] = ['BLUEPRINT']
483
- @producer.colophon(@output)
490
+ @producer.config.merge!('aut' => ['Mr.Smith'],
491
+ 'pbl' => ['BLUEPRINT'])
492
+ @producer.modify_config
493
+ output = @producer.instance_eval { @epub.colophon }
484
494
  expect = <<EOT
485
495
  <?xml version="1.0" encoding="UTF-8"?>
486
496
  <!DOCTYPE html>
@@ -504,14 +514,15 @@ EOT
504
514
  </body>
505
515
  </html>
506
516
  EOT
507
- assert_equal expect, @output.string
517
+ assert_equal expect, output
508
518
  end
509
519
 
510
520
  def test_colophon_pht
511
- @producer.config['aut'] = ['Mr.Smith']
512
- @producer.config['pbl'] = ['BLUEPRINT']
513
- @producer.config['pht'] = ['Mrs.Smith']
514
- @producer.colophon(@output)
521
+ @producer.config.merge!('aut' => ['Mr.Smith'],
522
+ 'pbl' => ['BLUEPRINT'],
523
+ 'pht' => ['Mrs.Smith'])
524
+ @producer.modify_config
525
+ output = @producer.instance_eval { @epub.colophon }
515
526
  expect = <<EOT
516
527
  <?xml version="1.0" encoding="UTF-8"?>
517
528
  <!DOCTYPE html>
@@ -536,14 +547,15 @@ EOT
536
547
  </body>
537
548
  </html>
538
549
  EOT
539
- assert_equal expect, @output.string
550
+ assert_equal expect, output
540
551
  end
541
552
 
542
553
  def test_colophon_history
543
- @producer.config['aut'] = ['Mr.Smith']
544
- @producer.config['pbl'] = ['BLUEPRINT']
545
- @producer.config['pht'] = ['Mrs.Smith']
546
- @producer.merge_config('language' => 'ja')
554
+ @producer.config.merge!('aut' => 'Mr.Smith',
555
+ 'pbl' => 'BLUEPRINT',
556
+ 'pht' => 'Mrs.Smith',
557
+ 'language' => 'ja')
558
+ @producer.modify_config
547
559
  history = @producer.instance_eval { @epub.colophon_history }
548
560
  expect = <<EOT
549
561
  <div class="pubhistory">
@@ -554,13 +566,12 @@ EOT
554
566
  end
555
567
 
556
568
  def test_colophon_history_2
557
- @producer.config['aut'] = ['Mr.Smith']
558
- @producer.config['pbl'] = ['BLUEPRINT']
559
- @producer.config['pht'] = ['Mrs.Smith']
560
- @producer.merge_config(
561
- 'language' => 'ja',
562
- 'history' => [['2011-08-03 v1.0.0版発行', '2012-02-15 v1.1.0版発行']]
563
- )
569
+ @producer.config.merge!('aut' => ['Mr.Smith'],
570
+ 'pbl' => ['BLUEPRINT'],
571
+ 'pht' => ['Mrs.Smith'],
572
+ 'language' => 'ja',
573
+ 'history' => [['2011-08-03 v1.0.0版発行', '2012-02-15 v1.1.0版発行']])
574
+ @producer.modify_config
564
575
  history = @producer.instance_eval { @epub.colophon_history }
565
576
  expect = <<EOT
566
577
  <div class="pubhistory">
@@ -572,13 +583,12 @@ EOT
572
583
  end
573
584
 
574
585
  def test_colophon_history_date
575
- @producer.config['aut'] = ['Mr.Smith']
576
- @producer.config['pbl'] = ['BLUEPRINT']
577
- @producer.config['pht'] = ['Mrs.Smith']
578
- @producer.merge_config(
579
- 'language' => 'ja',
580
- 'history' => [['2011-08-03', '2012-02-15']]
581
- )
586
+ @producer.config.merge!('aut' => ['Mr.Smith'],
587
+ 'pbl' => ['BLUEPRINT'],
588
+ 'pht' => ['Mrs.Smith'],
589
+ 'language' => 'ja',
590
+ 'history' => [['2011-08-03', '2012-02-15']])
591
+ @producer.modify_config
582
592
  history = @producer.instance_eval { @epub.colophon_history }
583
593
  expect = <<EOT
584
594
  <div class="pubhistory">
@@ -590,15 +600,14 @@ EOT
590
600
  end
591
601
 
592
602
  def test_colophon_history_date2
593
- @producer.config['aut'] = ['Mr.Smith']
594
- @producer.config['pbl'] = ['BLUEPRINT']
595
- @producer.config['pht'] = ['Mrs.Smith']
596
- @producer.merge_config(
597
- 'language' => 'ja',
598
- 'history' => [['2011-08-03', '2012-02-15'],
599
- ['2012-10-01'],
600
- ['2013-03-01']]
601
- )
603
+ @producer.config.merge!('aut' => ['Mr.Smith'],
604
+ 'pbl' => ['BLUEPRINT'],
605
+ 'pht' => ['Mrs.Smith'],
606
+ 'language' => 'ja',
607
+ 'history' => [['2011-08-03', '2012-02-15'],
608
+ ['2012-10-01'],
609
+ ['2013-03-01']])
610
+ @producer.modify_config
602
611
  history = @producer.instance_eval { @epub.colophon_history }
603
612
  expect = <<EOT
604
613
  <div class="pubhistory">
@@ -686,4 +695,39 @@ large.svg: 250x150 exceeds a limit. suggeted value is 95x57
686
695
  EOS
687
696
  assert_equal expected, err
688
697
  end
698
+
699
+ def test_build_part
700
+ Dir.mktmpdir do |tmpdir|
701
+ book = ReVIEW::Book::Base.new
702
+ book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re])
703
+ io1 = StringIO.new("//list[sampletest][a]{\nfoo\n//}\n")
704
+ chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
705
+ part1 = ReVIEW::Book::Part.new(book, 1, [chap1])
706
+ book.parts = [part1]
707
+ epubmaker = ReVIEW::EPUBMaker.new
708
+ epubmaker.instance_eval do
709
+ @config = book.config
710
+ @producer = ReVIEW::EPUBMaker::Producer.new(@config)
711
+ end
712
+ epubmaker.build_part(part1, tmpdir, 'part1.html')
713
+
714
+ expected = <<-EOB
715
+ <?xml version="1.0" encoding="UTF-8"?>
716
+ <!DOCTYPE html>
717
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="ja">
718
+ <head>
719
+ <meta charset="UTF-8" />
720
+ <meta name="generator" content="Re:VIEW" />
721
+ <title></title>
722
+ </head>
723
+ <body>
724
+ <div class="part">
725
+ <h1 class="part-number">第I部</h1>
726
+ </div>
727
+ </body>
728
+ </html>
729
+ EOB
730
+ assert_equal expected, File.read(File.join(tmpdir, 'part1.html'))
731
+ end
732
+ end
689
733
  end