review 5.0.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-tex.yml +35 -0
- data/.github/workflows/ruby-win.yml +8 -4
- data/.github/workflows/ruby.yml +6 -2
- data/.rubocop.yml +24 -9
- data/NEWS.ja.md +215 -0
- data/NEWS.md +215 -1
- data/README.md +7 -6
- data/Rakefile +7 -2
- data/bin/review +2 -4
- data/bin/review-catalog-converter +3 -3
- data/bin/review-check +6 -8
- data/bin/review-checkdep +1 -4
- data/bin/review-compile +10 -20
- data/bin/review-epub2html +1 -4
- data/bin/review-epubmaker +3 -4
- data/bin/review-idgxmlmaker +1 -3
- data/bin/review-index +11 -5
- data/bin/review-init +1 -4
- data/bin/review-pdfmaker +1 -3
- data/bin/review-preproc +30 -38
- data/bin/review-textmaker +1 -3
- data/bin/review-update +1 -4
- data/bin/review-validate +3 -3
- data/bin/review-vol +1 -4
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +23 -5
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +49 -12
- data/doc/format.md +52 -12
- data/doc/quickstart.ja.md +11 -1
- data/doc/quickstart.md +11 -2
- data/doc/writing_vertical.ja.md +6 -0
- data/lib/review/book/base.rb +4 -0
- data/lib/review/book/book_unit.rb +15 -2
- data/lib/review/book/chapter.rb +3 -0
- data/lib/review/book/index.rb +5 -1
- data/lib/review/book/volume.rb +1 -0
- data/lib/review/builder.rb +90 -54
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +2 -0
- data/lib/review/compiler.rb +88 -52
- data/lib/review/configure.rb +64 -7
- data/lib/review/epubmaker/content.rb +113 -0
- data/lib/review/epubmaker/epubcommon.rb +372 -0
- data/lib/review/epubmaker/epubv2.rb +178 -0
- data/lib/review/epubmaker/epubv3.rb +231 -0
- data/lib/review/epubmaker/producer.rb +167 -0
- data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
- data/lib/review/epubmaker/zip_exporter.rb +84 -0
- data/lib/review/epubmaker.rb +114 -129
- data/lib/review/exception.rb +13 -0
- data/lib/review/htmlbuilder.rb +109 -67
- data/lib/review/htmlutils.rb +1 -1
- data/lib/review/i18n.rb +1 -0
- data/lib/review/i18n.yml +6 -0
- data/lib/review/idgxmlbuilder.rb +72 -48
- data/lib/review/idgxmlmaker.rb +15 -14
- data/lib/review/img_math.rb +239 -0
- data/lib/review/index_builder.rb +90 -32
- data/lib/review/init.rb +4 -4
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +79 -58
- data/lib/review/latexutils.rb +9 -1
- data/lib/review/lineinput.rb +112 -2
- data/lib/review/loggable.rb +27 -0
- data/lib/review/logger.rb +89 -2
- data/lib/review/makerhelper.rb +7 -206
- data/lib/review/markdownbuilder.rb +44 -4
- data/lib/review/pdfmaker.rb +70 -51
- data/lib/review/plaintextbuilder.rb +20 -11
- data/lib/review/preprocessor/directive.rb +35 -0
- data/lib/review/preprocessor/line.rb +34 -0
- data/lib/review/preprocessor/repository.rb +177 -0
- data/lib/review/preprocessor.rb +105 -301
- data/lib/review/rstbuilder.rb +13 -4
- data/lib/review/sec_counter.rb +1 -0
- data/lib/review/template.rb +11 -1
- data/lib/review/textmaker.rb +23 -20
- data/lib/review/textutils.rb +10 -17
- data/lib/review/tocprinter.rb +93 -71
- data/lib/review/topbuilder.rb +44 -19
- data/lib/review/update.rb +5 -6
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +11 -12
- data/lib/review/webmaker.rb +31 -27
- data/lib/review/webtocprinter.rb +10 -9
- data/lib/review/yamlloader.rb +2 -1
- data/lib/review.rb +1 -1
- data/review.gemspec +5 -3
- data/samples/sample-book/src/config-epub2.yml +1 -1
- data/samples/sample-book/src/config.yml +1 -1
- data/samples/sample-book/src/lib/tasks/review.rake +19 -1
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +2 -1
- data/samples/syntax-book/ch01.re +1 -1
- data/samples/syntax-book/ch02.re +30 -6
- data/samples/syntax-book/ch03.re +1 -1
- data/samples/syntax-book/images/img3-2.png +0 -0
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +2 -1
- data/templates/html/_colophon.html.erb +23 -0
- data/templates/html/_colophon_history.html.erb +9 -0
- data/templates/html/_cover.html.erb +10 -0
- data/templates/html/_part_body.html.erb +6 -0
- data/templates/html/_titlepage.html.erb +20 -0
- data/templates/html/layout-html5.html.erb +6 -0
- data/templates/html/layout-xhtml1.html.erb +6 -0
- data/templates/latex/config.erb +11 -0
- data/templates/latex/review-jlreq/review-base.sty +7 -9
- data/templates/latex/review-jlreq/review-jlreq.cls +48 -6
- data/templates/latex/review-jlreq/review-style.sty +6 -1
- data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
- data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
- data/templates/latex/review-jsbook/review-base.sty +13 -9
- data/templates/latex/review-jsbook/review-jsbook.cls +41 -6
- data/templates/latex/review-jsbook/review-style.sty +6 -1
- data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
- data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
- data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
- data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
- data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
- data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
- data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
- data/templates/web/html/layout-html5.html.erb +6 -5
- data/templates/web/html/layout-xhtml1.html.erb +6 -0
- data/test/assets/header_listener.html +35 -0
- data/test/assets/img_math/img1.png +0 -0
- data/test/assets/img_math/img2.png +0 -0
- data/test/assets/img_math/img3.png +0 -0
- data/test/assets/syntax_book_index_detail.txt +60 -0
- data/test/assets/test_template.tex +7 -1
- data/test/assets/test_template_backmatter.tex +7 -1
- data/test/run_test.rb +1 -1
- data/test/test_book_chapter.rb +27 -4
- data/test/test_builder.rb +10 -8
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_epub3maker.rb +168 -124
- data/test/test_epubmaker.rb +248 -131
- data/test/test_epubmaker_cmd.rb +15 -4
- data/test/test_helper.rb +5 -4
- data/test/test_htmlbuilder.rb +170 -31
- data/test/test_idgxmlbuilder.rb +44 -23
- data/test/test_idgxmlmaker_cmd.rb +7 -3
- data/test/test_img_math.rb +111 -0
- data/test/test_index.rb +30 -4
- data/test/test_indexbuilder.rb +5 -5
- data/test/test_latexbuilder.rb +151 -26
- data/test/test_latexbuilder_v2.rb +18 -10
- data/test/test_lineinput.rb +20 -93
- data/test/test_markdownbuilder.rb +42 -0
- data/test/test_pdfmaker.rb +90 -0
- data/test/test_pdfmaker_cmd.rb +2 -2
- data/test/test_plaintextbuilder.rb +56 -40
- data/test/test_preprocessor.rb +188 -1
- data/test/test_reviewheaderlistener.rb +49 -0
- data/test/test_rstbuilder.rb +13 -0
- data/test/test_template.rb +12 -2
- data/test/test_textmaker_cmd.rb +5 -1
- data/test/test_tocprinter.rb +46 -0
- data/test/test_topbuilder.rb +50 -19
- data/test/test_update.rb +34 -34
- data/test/test_zip_exporter.rb +5 -6
- metadata +95 -17
- data/lib/epubmaker/content.rb +0 -111
- data/lib/epubmaker/epubcommon.rb +0 -449
- data/lib/epubmaker/epubv2.rb +0 -142
- data/lib/epubmaker/epubv3.rb +0 -235
- data/lib/epubmaker/producer.rb +0 -375
- data/lib/epubmaker/zip_exporter.rb +0 -81
- data/lib/epubmaker.rb +0 -23
- data/lib/lineinput.rb +0 -155
data/test/test_epub3maker.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require '
|
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
|
-
|
10
|
-
|
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
|
-
@
|
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.
|
29
|
-
|
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.
|
34
|
-
|
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
|
39
|
-
assert_equal 'application/epub+zip',
|
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
|
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,
|
52
|
+
assert_equal expect, output
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_stage1_opf
|
56
|
-
@producer.opf
|
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,
|
80
|
+
assert_equal expect, output
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_stage1_opf_ebpaj
|
84
|
-
@producer.
|
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.
|
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,
|
114
|
+
assert_equal expect, output
|
114
115
|
end
|
115
116
|
|
116
117
|
def test_stage1_opf_fileas
|
117
|
-
@producer.config
|
118
|
-
|
119
|
-
|
120
|
-
@producer.
|
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,
|
159
|
+
assert_equal expect, output
|
158
160
|
end
|
159
161
|
|
160
162
|
def test_stage1_ncx
|
161
|
-
@producer.ncx(
|
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,
|
181
|
+
assert_equal expect, output
|
180
182
|
end
|
181
183
|
|
182
184
|
def stage2
|
183
185
|
# add one item
|
184
|
-
@producer.contents << Content.new(
|
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
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
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
|
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,
|
227
|
+
assert_equal expect, output
|
226
228
|
end
|
227
229
|
|
228
230
|
def test_stage2_ncx
|
229
231
|
stage2
|
230
|
-
@producer.ncx(
|
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,
|
251
|
+
assert_equal expect, output
|
250
252
|
end
|
251
253
|
|
252
254
|
def stage3
|
253
255
|
# add more items
|
254
|
-
@producer.contents << Content.new(
|
255
|
-
@producer.contents << Content.new(
|
256
|
-
@producer.contents << Content.new(
|
257
|
-
@producer.contents << Content.new(
|
258
|
-
@producer.contents << Content.new(
|
259
|
-
@producer.contents << Content.new(
|
260
|
-
@producer.contents << Content.new(
|
261
|
-
@producer.contents << Content.new(
|
262
|
-
@producer.contents << Content.new(
|
263
|
-
@producer.contents << Content.new(
|
264
|
-
@producer.contents << Content.new(
|
265
|
-
@producer.contents << Content.new(
|
266
|
-
@producer.contents << Content.new(
|
267
|
-
@producer.contents << Content.new(
|
268
|
-
@producer.contents << Content.new(
|
269
|
-
@producer.contents << Content.new(
|
270
|
-
@producer.contents << Content.new(
|
271
|
-
@producer.contents << Content.new(
|
272
|
-
@producer.contents << Content.new(
|
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,
|
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
|
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,
|
344
|
+
assert_equal expect, output
|
343
345
|
end
|
344
346
|
|
345
347
|
def test_stage3_ncx
|
346
348
|
stage3
|
347
|
-
@producer.
|
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,
|
377
|
+
assert_equal expect, output
|
375
378
|
end
|
376
379
|
|
377
380
|
def test_stage3_mytoc
|
378
381
|
stage3
|
379
|
-
@producer.
|
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,
|
408
|
+
assert_equal expect, output
|
405
409
|
end
|
406
410
|
|
407
411
|
def test_stage3_flat
|
408
|
-
@producer.
|
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
|
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,
|
442
|
+
assert_equal expect, output
|
435
443
|
end
|
436
444
|
|
437
445
|
def test_stage3_cover
|
438
446
|
stage3
|
439
|
-
@producer.cover
|
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,
|
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.
|
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,
|
486
|
+
assert_equal expect, output
|
478
487
|
end
|
479
488
|
|
480
489
|
def test_colophon_default
|
481
|
-
@producer.config
|
482
|
-
|
483
|
-
@producer.
|
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,
|
517
|
+
assert_equal expect, output
|
508
518
|
end
|
509
519
|
|
510
520
|
def test_colophon_pht
|
511
|
-
@producer.config
|
512
|
-
|
513
|
-
|
514
|
-
@producer.
|
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,
|
550
|
+
assert_equal expect, output
|
540
551
|
end
|
541
552
|
|
542
553
|
def test_colophon_history
|
543
|
-
@producer.config
|
544
|
-
|
545
|
-
|
546
|
-
|
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
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
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
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
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
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
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
|