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_epubmaker.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'epubmaker'
|
3
2
|
require 'review/epubmaker'
|
4
3
|
|
5
4
|
class EPUBMakerTest < Test::Unit::TestCase
|
6
|
-
include EPUBMaker
|
7
|
-
|
8
5
|
def setup
|
9
|
-
|
10
|
-
|
6
|
+
config = ReVIEW::Configure.values
|
7
|
+
config.merge!(
|
11
8
|
'bookname' => 'sample',
|
12
9
|
'title' => 'Sample Book',
|
13
10
|
'epubversion' => 2,
|
@@ -16,30 +13,34 @@ class EPUBMakerTest < Test::Unit::TestCase
|
|
16
13
|
'language' => 'en',
|
17
14
|
'titlepage' => nil
|
18
15
|
)
|
19
|
-
@
|
16
|
+
@log_io = StringIO.new
|
17
|
+
ReVIEW.logger = ReVIEW::Logger.new(@log_io)
|
18
|
+
@producer = ReVIEW::EPUBMaker::Producer.new(config)
|
20
19
|
end
|
21
20
|
|
22
21
|
def test_initialize
|
23
|
-
assert Producer.new
|
22
|
+
assert ReVIEW::EPUBMaker::Producer.new(ReVIEW::Configure.values)
|
24
23
|
end
|
25
24
|
|
26
25
|
def test_resource_en
|
27
|
-
@producer.
|
28
|
-
|
26
|
+
@producer.config['language'] = 'en'
|
27
|
+
@producer.modify_config
|
28
|
+
assert_equal 'Table of Contents', ReVIEW::I18n.t('toctitle')
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_resource_ja
|
32
|
-
@producer.
|
33
|
-
|
32
|
+
@producer.config['language'] = 'ja'
|
33
|
+
@producer.modify_config
|
34
|
+
assert_equal '目次', ReVIEW::I18n.t('toctitle')
|
34
35
|
end
|
35
36
|
|
36
37
|
def test_mimetype
|
37
|
-
@producer.mimetype
|
38
|
-
assert_equal 'application/epub+zip',
|
38
|
+
output = @producer.instance_eval { @epub.mimetype }
|
39
|
+
assert_equal 'application/epub+zip', output
|
39
40
|
end
|
40
41
|
|
41
42
|
def test_container
|
42
|
-
@producer.container
|
43
|
+
output = @producer.instance_eval { @epub.container }
|
43
44
|
expect = <<EOT
|
44
45
|
<?xml version="1.0" encoding="UTF-8"?>
|
45
46
|
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
|
@@ -48,11 +49,11 @@ class EPUBMakerTest < Test::Unit::TestCase
|
|
48
49
|
</rootfiles>
|
49
50
|
</container>
|
50
51
|
EOT
|
51
|
-
assert_equal expect,
|
52
|
+
assert_equal expect, output
|
52
53
|
end
|
53
54
|
|
54
55
|
def test_stage1_opf
|
55
|
-
@producer.opf
|
56
|
+
output = @producer.instance_eval { @epub.opf }
|
56
57
|
expect = <<EOT
|
57
58
|
<?xml version="1.0" encoding="UTF-8"?>
|
58
59
|
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
@@ -74,12 +75,13 @@ EOT
|
|
74
75
|
</guide>
|
75
76
|
</package>
|
76
77
|
EOT
|
77
|
-
assert_equal expect,
|
78
|
+
assert_equal expect, output
|
78
79
|
end
|
79
80
|
|
80
81
|
def test_stage1_opf_escape
|
81
82
|
@producer.config['title'] = 'Sample<>Book'
|
82
|
-
@producer.
|
83
|
+
@producer.modify_config
|
84
|
+
output = @producer.instance_eval { @epub.opf }
|
83
85
|
expect = <<EOT
|
84
86
|
<?xml version="1.0" encoding="UTF-8"?>
|
85
87
|
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
@@ -101,11 +103,11 @@ EOT
|
|
101
103
|
</guide>
|
102
104
|
</package>
|
103
105
|
EOT
|
104
|
-
assert_equal expect,
|
106
|
+
assert_equal expect, output
|
105
107
|
end
|
106
108
|
|
107
109
|
def test_stage1_ncx
|
108
|
-
@producer.ncx(
|
110
|
+
output = @producer.instance_eval { @epub.ncx([]) }
|
109
111
|
expect = <<EOT
|
110
112
|
<?xml version="1.0" encoding="UTF-8"?>
|
111
113
|
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
@@ -131,12 +133,13 @@ EOT
|
|
131
133
|
</navMap>
|
132
134
|
</ncx>
|
133
135
|
EOT
|
134
|
-
assert_equal expect,
|
136
|
+
assert_equal expect, output
|
135
137
|
end
|
136
138
|
|
137
139
|
def test_stage1_ncx_escape
|
138
140
|
@producer.config['title'] = 'Sample<>Book'
|
139
|
-
@producer.
|
141
|
+
@producer.modify_config
|
142
|
+
output = @producer.instance_eval { @epub.ncx([]) }
|
140
143
|
expect = <<EOT
|
141
144
|
<?xml version="1.0" encoding="UTF-8"?>
|
142
145
|
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
@@ -162,27 +165,27 @@ EOT
|
|
162
165
|
</navMap>
|
163
166
|
</ncx>
|
164
167
|
EOT
|
165
|
-
assert_equal expect,
|
168
|
+
assert_equal expect, output
|
166
169
|
end
|
167
170
|
|
168
171
|
def stage2
|
169
172
|
# add one item
|
170
|
-
@producer.contents << Content.new(
|
173
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch01.html', title: 'CH01', level: 1)
|
171
174
|
end
|
172
175
|
|
173
176
|
def test_stage2_add_l1item
|
174
177
|
stage2
|
175
|
-
expect = EPUBMaker::Content.new('ch01.html',
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
178
|
+
expect = ReVIEW::EPUBMaker::Content.new(file: 'ch01.html',
|
179
|
+
id: 'ch01-html',
|
180
|
+
media: 'application/xhtml+xml',
|
181
|
+
title: 'CH01',
|
182
|
+
level: 1)
|
180
183
|
assert_equal expect, @producer.contents[0]
|
181
184
|
end
|
182
185
|
|
183
186
|
def test_stage2_opf
|
184
187
|
stage2
|
185
|
-
@producer.opf
|
188
|
+
output = @producer.instance_eval { @epub.opf }
|
186
189
|
expect = <<EOT
|
187
190
|
<?xml version="1.0" encoding="UTF-8"?>
|
188
191
|
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
@@ -206,12 +209,12 @@ EOT
|
|
206
209
|
</guide>
|
207
210
|
</package>
|
208
211
|
EOT
|
209
|
-
assert_equal expect,
|
212
|
+
assert_equal expect, output
|
210
213
|
end
|
211
214
|
|
212
215
|
def test_stage2_ncx
|
213
216
|
stage2
|
214
|
-
@producer.ncx(
|
217
|
+
output = @producer.instance_eval { @epub.ncx([]) }
|
215
218
|
expect = <<EOT
|
216
219
|
<?xml version="1.0" encoding="UTF-8"?>
|
217
220
|
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
@@ -243,54 +246,54 @@ EOT
|
|
243
246
|
</navMap>
|
244
247
|
</ncx>
|
245
248
|
EOT
|
246
|
-
assert_equal expect,
|
249
|
+
assert_equal expect, output
|
247
250
|
end
|
248
251
|
|
249
252
|
def stage3
|
250
253
|
# add more items
|
251
|
-
@producer.contents << Content.new(
|
252
|
-
@producer.contents << Content.new(
|
253
|
-
@producer.contents << Content.new(
|
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(
|
254
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch01.html', title: %Q(CH01<>&"), level: 1)
|
255
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html', title: 'CH02', level: 1)
|
256
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1', title: 'CH02.1', level: 2)
|
257
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1', title: 'CH02.1.1', level: 3)
|
258
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1.1', title: 'CH02.1.1.1', level: 4)
|
259
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1.1.1', title: 'CH02.1.1.1.1', level: 5)
|
260
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1.2', title: 'CH02.1.1.2', level: 4)
|
261
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S2', title: 'CH02.2', level: 2)
|
262
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S2.1', title: 'CH02.2.1', level: 3)
|
263
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch03.html', title: 'CH03', level: 1)
|
264
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch03.html#S1', title: 'CH03.1', level: 2)
|
265
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch03.html#S1.1', title: 'CH03.1.1', level: 3)
|
266
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch04.html', title: 'CH04', level: 1)
|
267
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'sample.png')
|
268
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'sample.jpg')
|
269
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'sample.JPEG')
|
270
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'sample.SvG')
|
271
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'sample.GIF')
|
272
|
+
@producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'sample.css')
|
270
273
|
end
|
271
274
|
|
272
275
|
def test_stage3_add_various_items
|
273
276
|
stage3
|
274
277
|
expect = [
|
275
|
-
Content.new('ch01.html', 'ch01-html', 'application/xhtml+xml', %Q(CH01<>&"), 1),
|
276
|
-
Content.new('ch02.html', 'ch02-html', 'application/xhtml+xml', 'CH02', 1),
|
277
|
-
Content.new('ch02.html#S1', 'ch02-html#S1', 'html#s1', 'CH02.1', 2),
|
278
|
-
Content.new('ch02.html#S1.1', 'ch02-html#S1-1', '1', 'CH02.1.1', 3),
|
279
|
-
Content.new('ch02.html#S1.1.1', 'ch02-html#S1-1-1', '1', 'CH02.1.1.1', 4),
|
280
|
-
Content.new('ch02.html#S1.1.1.1', 'ch02-html#S1-1-1-1', '1', 'CH02.1.1.1.1', 5),
|
281
|
-
Content.new('ch02.html#S1.1.2', 'ch02-html#S1-1-2', '2', 'CH02.1.1.2', 4),
|
282
|
-
Content.new('ch02.html#S2', 'ch02-html#S2', 'html#s2', 'CH02.2', 2),
|
283
|
-
Content.new('ch02.html#S2.1', 'ch02-html#S2-1', '1', 'CH02.2.1', 3),
|
284
|
-
Content.new('ch03.html', 'ch03-html', 'application/xhtml+xml', 'CH03', 1),
|
285
|
-
Content.new('ch03.html#S1', 'ch03-html#S1', 'html#s1', 'CH03.1', 2),
|
286
|
-
Content.new('ch03.html#S1.1', 'ch03-html#S1-1', '1', 'CH03.1.1', 3),
|
287
|
-
Content.new('ch04.html', 'ch04-html', 'application/xhtml+xml', 'CH04', 1),
|
288
|
-
Content.new('sample.png', 'sample-png', 'image/png'),
|
289
|
-
Content.new('sample.jpg', 'sample-jpg', 'image/jpeg'),
|
290
|
-
Content.new('sample.JPEG', 'sample-JPEG', 'image/jpeg'),
|
291
|
-
Content.new('sample.SvG', 'sample-SvG', 'image/svg+xml'),
|
292
|
-
Content.new('sample.GIF', 'sample-GIF', 'image/gif'),
|
293
|
-
Content.new('sample.css', 'sample-css', 'text/css')
|
278
|
+
ReVIEW::EPUBMaker::Content.new(file: 'ch01.html', id: 'ch01-html', media: 'application/xhtml+xml', title: %Q(CH01<>&"), level: 1),
|
279
|
+
ReVIEW::EPUBMaker::Content.new(file: 'ch02.html', id: 'ch02-html', media: 'application/xhtml+xml', title: 'CH02', level: 1),
|
280
|
+
ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1', id: 'ch02-html#S1', media: 'html#s1', title: 'CH02.1', level: 2),
|
281
|
+
ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S1.1', id: 'ch02-html#S1-1', media: '1', title: 'CH02.1.1', level: 3),
|
282
|
+
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),
|
283
|
+
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),
|
284
|
+
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),
|
285
|
+
ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S2', id: 'ch02-html#S2', media: 'html#s2', title: 'CH02.2', level: 2),
|
286
|
+
ReVIEW::EPUBMaker::Content.new(file: 'ch02.html#S2.1', id: 'ch02-html#S2-1', media: '1', title: 'CH02.2.1', level: 3),
|
287
|
+
ReVIEW::EPUBMaker::Content.new(file: 'ch03.html', id: 'ch03-html', media: 'application/xhtml+xml', title: 'CH03', level: 1),
|
288
|
+
ReVIEW::EPUBMaker::Content.new(file: 'ch03.html#S1', id: 'ch03-html#S1', media: 'html#s1', title: 'CH03.1', level: 2),
|
289
|
+
ReVIEW::EPUBMaker::Content.new(file: 'ch03.html#S1.1', id: 'ch03-html#S1-1', media: '1', title: 'CH03.1.1', level: 3),
|
290
|
+
ReVIEW::EPUBMaker::Content.new(file: 'ch04.html', id: 'ch04-html', media: 'application/xhtml+xml', title: 'CH04', level: 1),
|
291
|
+
ReVIEW::EPUBMaker::Content.new(file: 'sample.png', id: 'sample-png', media: 'image/png'),
|
292
|
+
ReVIEW::EPUBMaker::Content.new(file: 'sample.jpg', id: 'sample-jpg', media: 'image/jpeg'),
|
293
|
+
ReVIEW::EPUBMaker::Content.new(file: 'sample.JPEG', id: 'sample-JPEG', media: 'image/jpeg'),
|
294
|
+
ReVIEW::EPUBMaker::Content.new(file: 'sample.SvG', id: 'sample-SvG', media: 'image/svg+xml'),
|
295
|
+
ReVIEW::EPUBMaker::Content.new(file: 'sample.GIF', id: 'sample-GIF', media: 'image/gif'),
|
296
|
+
ReVIEW::EPUBMaker::Content.new(file: 'sample.css', id: 'sample-css', media: 'text/css')
|
294
297
|
]
|
295
298
|
|
296
299
|
assert_equal expect, @producer.contents
|
@@ -298,7 +301,7 @@ EOT
|
|
298
301
|
|
299
302
|
def test_stage3_opf
|
300
303
|
stage3
|
301
|
-
@producer.opf
|
304
|
+
output = @producer.instance_eval { @epub.opf }
|
302
305
|
expect = <<EOT
|
303
306
|
<?xml version="1.0" encoding="UTF-8"?>
|
304
307
|
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
@@ -334,12 +337,12 @@ EOT
|
|
334
337
|
</guide>
|
335
338
|
</package>
|
336
339
|
EOT
|
337
|
-
assert_equal expect,
|
340
|
+
assert_equal expect, output
|
338
341
|
end
|
339
342
|
|
340
343
|
def test_stage3_ncx
|
341
344
|
stage3
|
342
|
-
@producer.ncx(
|
345
|
+
output = @producer.instance_eval { @epub.ncx([]) }
|
343
346
|
expect = <<EOT
|
344
347
|
<?xml version="1.0" encoding="UTF-8"?>
|
345
348
|
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
@@ -443,12 +446,14 @@ EOT
|
|
443
446
|
</navMap>
|
444
447
|
</ncx>
|
445
448
|
EOT
|
446
|
-
assert_equal expect,
|
449
|
+
assert_equal expect, output
|
447
450
|
end
|
448
451
|
|
449
452
|
def test_stage3_mytoc
|
450
453
|
stage3
|
451
|
-
@producer.
|
454
|
+
@producer.config['toclevel'] = 2
|
455
|
+
@producer.modify_config
|
456
|
+
output = @producer.instance_eval { @epub.mytoc }
|
452
457
|
expect = <<EOT
|
453
458
|
<?xml version="1.0" encoding="UTF-8"?>
|
454
459
|
<!DOCTYPE html>
|
@@ -473,13 +478,17 @@ EOT
|
|
473
478
|
</ul></body>
|
474
479
|
</html>
|
475
480
|
EOT
|
476
|
-
assert_equal expect,
|
481
|
+
assert_equal expect, output
|
477
482
|
end
|
478
483
|
|
479
484
|
def test_stage3_flat
|
480
|
-
@producer.
|
485
|
+
@producer.config.deep_merge!(
|
486
|
+
'epubmaker' => { 'flattoc' => true, 'flattocindent' => false },
|
487
|
+
'toclevel' => 2
|
488
|
+
)
|
489
|
+
@producer.modify_config
|
481
490
|
stage3
|
482
|
-
@producer.mytoc
|
491
|
+
output = @producer.instance_eval { @epub.mytoc }
|
483
492
|
expect = <<EOT
|
484
493
|
<?xml version="1.0" encoding="UTF-8"?>
|
485
494
|
<!DOCTYPE html>
|
@@ -503,12 +512,12 @@ EOT
|
|
503
512
|
</body>
|
504
513
|
</html>
|
505
514
|
EOT
|
506
|
-
assert_equal expect,
|
515
|
+
assert_equal expect, output
|
507
516
|
end
|
508
517
|
|
509
518
|
def test_stage3_cover
|
510
519
|
stage3
|
511
|
-
@producer.cover
|
520
|
+
output = @producer.instance_eval { @epub.cover }
|
512
521
|
expect = <<EOT
|
513
522
|
<?xml version="1.0" encoding="UTF-8"?>
|
514
523
|
<!DOCTYPE html>
|
@@ -523,13 +532,14 @@ EOT
|
|
523
532
|
</body>
|
524
533
|
</html>
|
525
534
|
EOT
|
526
|
-
assert_equal expect,
|
535
|
+
assert_equal expect, output
|
527
536
|
end
|
528
537
|
|
529
538
|
def test_stage3_cover_escape
|
530
539
|
stage3
|
531
540
|
@producer.config['title'] = 'Sample<>Book'
|
532
|
-
@producer.
|
541
|
+
@producer.modify_config
|
542
|
+
output = @producer.instance_eval { @epub.cover }
|
533
543
|
expect = <<EOT
|
534
544
|
<?xml version="1.0" encoding="UTF-8"?>
|
535
545
|
<!DOCTYPE html>
|
@@ -544,13 +554,14 @@ EOT
|
|
544
554
|
</body>
|
545
555
|
</html>
|
546
556
|
EOT
|
547
|
-
assert_equal expect,
|
557
|
+
assert_equal expect, output
|
548
558
|
end
|
549
559
|
|
550
560
|
def test_stage3_cover_with_image
|
551
561
|
stage3
|
552
562
|
@producer.config['coverimage'] = 'sample.png'
|
553
|
-
@producer.
|
563
|
+
@producer.modify_config
|
564
|
+
output = @producer.instance_eval { @epub.cover }
|
554
565
|
expect = <<EOT
|
555
566
|
<?xml version="1.0" encoding="UTF-8"?>
|
556
567
|
<!DOCTYPE html>
|
@@ -567,14 +578,17 @@ EOT
|
|
567
578
|
</body>
|
568
579
|
</html>
|
569
580
|
EOT
|
570
|
-
assert_equal expect,
|
581
|
+
assert_equal expect, output
|
571
582
|
end
|
572
583
|
|
573
584
|
def test_stage3_cover_with_image_escape
|
574
585
|
stage3
|
575
|
-
@producer.config
|
576
|
-
|
577
|
-
|
586
|
+
@producer.config.merge!(
|
587
|
+
'title' => 'Sample<>Book',
|
588
|
+
'coverimage' => 'sample.png'
|
589
|
+
)
|
590
|
+
@producer.modify_config
|
591
|
+
output = @producer.instance_eval { @epub.cover }
|
578
592
|
expect = <<EOT
|
579
593
|
<?xml version="1.0" encoding="UTF-8"?>
|
580
594
|
<!DOCTYPE html>
|
@@ -591,14 +605,17 @@ EOT
|
|
591
605
|
</body>
|
592
606
|
</html>
|
593
607
|
EOT
|
594
|
-
assert_equal expect,
|
608
|
+
assert_equal expect, output
|
595
609
|
end
|
596
610
|
|
597
611
|
def test_colophon_default
|
598
|
-
@producer.config
|
599
|
-
|
600
|
-
|
601
|
-
|
612
|
+
@producer.config.merge!(
|
613
|
+
'aut' => ['Mr.Smith'],
|
614
|
+
'pbl' => ['BLUEPRINT'],
|
615
|
+
'isbn' => '9784797372274'
|
616
|
+
)
|
617
|
+
@producer.modify_config
|
618
|
+
output = @producer.instance_eval { @epub.colophon }
|
602
619
|
expect = <<EOT
|
603
620
|
<?xml version="1.0" encoding="UTF-8"?>
|
604
621
|
<!DOCTYPE html>
|
@@ -623,17 +640,20 @@ EOT
|
|
623
640
|
</body>
|
624
641
|
</html>
|
625
642
|
EOT
|
626
|
-
assert_equal expect,
|
643
|
+
assert_equal expect, output
|
627
644
|
end
|
628
645
|
|
629
646
|
def test_colophon_default_escape_and_multiple
|
630
|
-
@producer.config
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
647
|
+
@producer.config.merge!(
|
648
|
+
'title' => '<&Sample Book>',
|
649
|
+
'subtitle' => 'Sample<>Subtitle',
|
650
|
+
'aut' => ['Mr.Smith', 'Mr.&Anderson'],
|
651
|
+
'pbl' => ['BLUEPRINT', 'COPY<>EDIT'],
|
652
|
+
'isbn' => '9784797372274',
|
653
|
+
'rights' => ['COPYRIGHT 2016 <>', '& REVIEW']
|
654
|
+
)
|
655
|
+
@producer.modify_config
|
656
|
+
output = @producer.instance_eval { @epub.colophon }
|
637
657
|
expect = <<EOT
|
638
658
|
<?xml version="1.0" encoding="UTF-8"?>
|
639
659
|
<!DOCTYPE html>
|
@@ -659,19 +679,22 @@ EOT
|
|
659
679
|
</body>
|
660
680
|
</html>
|
661
681
|
EOT
|
662
|
-
assert_equal expect,
|
682
|
+
assert_equal expect, output
|
663
683
|
end
|
664
684
|
|
665
685
|
def test_colophon_history
|
666
|
-
@producer.config
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
686
|
+
@producer.config.merge!(
|
687
|
+
'aut' => ['Mr.Smith'],
|
688
|
+
'pbl' => ['BLUEPRINT'],
|
689
|
+
'pht' => ['Mrs.Smith'],
|
690
|
+
'language' => 'ja',
|
691
|
+
'history' =>
|
671
692
|
[['2011-08-03',
|
672
693
|
'2012-02-15'],
|
673
694
|
['2012-10-01'],
|
674
695
|
['2013-03-01']]
|
696
|
+
)
|
697
|
+
@producer.modify_config
|
675
698
|
epub = @producer.instance_eval { @epub }
|
676
699
|
result = epub.colophon_history
|
677
700
|
expect = <<-EOT
|
@@ -686,14 +709,17 @@ EOT
|
|
686
709
|
end
|
687
710
|
|
688
711
|
def test_colophon_history_freeformat
|
689
|
-
@producer.config
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
712
|
+
@producer.config.merge!(
|
713
|
+
'aut' => ['Mr.Smith'],
|
714
|
+
'pbl' => ['BLUEPRINT'],
|
715
|
+
'pht' => ['Mrs.Smith'],
|
716
|
+
'language' => 'ja',
|
717
|
+
'history' =>
|
694
718
|
[['2011年8月3日 ver 1.1.0発行'],
|
695
719
|
['2011年10月12日 ver 1.2.0発行'],
|
696
720
|
['2012年1月31日 ver 1.2.1発行']]
|
721
|
+
)
|
722
|
+
@producer.modify_config
|
697
723
|
|
698
724
|
epub = @producer.instance_eval { @epub }
|
699
725
|
result = epub.colophon_history
|
@@ -708,10 +734,13 @@ EOT
|
|
708
734
|
end
|
709
735
|
|
710
736
|
def test_colophon_pht
|
711
|
-
@producer.config
|
712
|
-
|
713
|
-
|
714
|
-
|
737
|
+
@producer.config.merge!(
|
738
|
+
'aut' => ['Mr.Smith'],
|
739
|
+
'pbl' => ['BLUEPRINT'],
|
740
|
+
'pht' => ['Mrs.Smith']
|
741
|
+
)
|
742
|
+
@producer.modify_config
|
743
|
+
output = @producer.instance_eval { @epub.colophon }
|
715
744
|
expect = <<EOT
|
716
745
|
<?xml version="1.0" encoding="UTF-8"?>
|
717
746
|
<!DOCTYPE html>
|
@@ -736,28 +765,37 @@ EOT
|
|
736
765
|
</body>
|
737
766
|
</html>
|
738
767
|
EOT
|
739
|
-
assert_equal expect,
|
768
|
+
assert_equal expect, output
|
740
769
|
end
|
741
770
|
|
742
771
|
def test_isbn13
|
743
772
|
@producer.config['isbn'] = '9784797372274'
|
744
|
-
|
773
|
+
@producer.modify_config
|
774
|
+
isbn = @producer.instance_eval { @epub.isbn_hyphen }
|
775
|
+
assert_equal '978-4-79737-227-4', isbn
|
745
776
|
end
|
746
777
|
|
747
778
|
def test_isbn10
|
748
779
|
@producer.config['isbn'] = '4797372273'
|
749
|
-
|
780
|
+
@producer.modify_config
|
781
|
+
isbn = @producer.instance_eval { @epub.isbn_hyphen }
|
782
|
+
assert_equal '4-79737-227-3', isbn
|
750
783
|
end
|
751
784
|
|
752
785
|
def test_isbn_nil
|
753
786
|
@producer.config['isbn'] = nil
|
754
|
-
|
787
|
+
@producer.modify_config
|
788
|
+
isbn = @producer.instance_eval { @epub.isbn_hyphen }
|
789
|
+
assert_equal nil, isbn
|
755
790
|
end
|
756
791
|
|
757
792
|
def test_title
|
758
|
-
@producer.config
|
759
|
-
|
760
|
-
|
793
|
+
@producer.config.merge!(
|
794
|
+
'aut' => ['Mr.Smith'],
|
795
|
+
'pbl' => ['BLUEPRINT']
|
796
|
+
)
|
797
|
+
@producer.modify_config
|
798
|
+
output = @producer.instance_eval { @epub.titlepage }
|
761
799
|
expect = <<EOT
|
762
800
|
<?xml version="1.0" encoding="UTF-8"?>
|
763
801
|
<!DOCTYPE html>
|
@@ -784,13 +822,16 @@ EOT
|
|
784
822
|
</body>
|
785
823
|
</html>
|
786
824
|
EOT
|
787
|
-
assert_equal expect,
|
825
|
+
assert_equal expect, output
|
788
826
|
end
|
789
827
|
|
790
828
|
def test_title_single_value_param
|
791
|
-
@producer.config
|
792
|
-
|
793
|
-
|
829
|
+
@producer.config.merge!(
|
830
|
+
'aut' => 'Mr.Smith',
|
831
|
+
'pbl' => 'BLUEPRINT'
|
832
|
+
)
|
833
|
+
@producer.modify_config
|
834
|
+
output = @producer.instance_eval { @epub.titlepage }
|
794
835
|
expect = <<EOT
|
795
836
|
<?xml version="1.0" encoding="UTF-8"?>
|
796
837
|
<!DOCTYPE html>
|
@@ -817,13 +858,89 @@ EOT
|
|
817
858
|
</body>
|
818
859
|
</html>
|
819
860
|
EOT
|
820
|
-
assert_equal expect,
|
861
|
+
assert_equal expect, output
|
821
862
|
end
|
822
863
|
|
823
864
|
def test_epub_unsafe_id
|
824
|
-
content = Content.new(
|
865
|
+
content = ReVIEW::EPUBMaker::Content.new(file: 'sample.png')
|
825
866
|
assert_equal 'sample-png', content.id
|
826
|
-
content = Content.new(
|
867
|
+
content = ReVIEW::EPUBMaker::Content.new(file: 'sample-&()-=+@:,漢字.png')
|
827
868
|
assert_equal 'sample-_25_26_25_28_25_29-_25_3D_25_2B_25_40_25_3A_25_2C_25_E6_25_BC_25_A2_25_E5_25_AD_25_97-png', content.id
|
828
869
|
end
|
870
|
+
|
871
|
+
def epubmaker_instance
|
872
|
+
Dir.mktmpdir do |tmpdir|
|
873
|
+
epubmaker = ReVIEW::EPUBMaker.new
|
874
|
+
epubmaker.instance_eval do
|
875
|
+
@config = ReVIEW::Configure.create(maker: 'epubmaker')
|
876
|
+
@config['titlepage'] = nil
|
877
|
+
@producer = ReVIEW::EPUBMaker::Producer.new(@config)
|
878
|
+
|
879
|
+
@htmltoc = ReVIEW::HTMLToc.new(tmpdir)
|
880
|
+
|
881
|
+
def config
|
882
|
+
@config
|
883
|
+
end
|
884
|
+
|
885
|
+
def error(s)
|
886
|
+
raise ApplicationError, s
|
887
|
+
end
|
888
|
+
end
|
889
|
+
|
890
|
+
File.write(File.join(tmpdir, 'exist.css'), 'body {}')
|
891
|
+
File.write(File.join(tmpdir, 'exist.html'), '<html></html>')
|
892
|
+
|
893
|
+
Dir.chdir(tmpdir) do
|
894
|
+
Dir.mkdir('test')
|
895
|
+
yield(epubmaker, File.join(tmpdir, 'test'))
|
896
|
+
end
|
897
|
+
end
|
898
|
+
end
|
899
|
+
|
900
|
+
def test_copy_static_file
|
901
|
+
epubmaker_instance do |epubmaker, tmpdir|
|
902
|
+
epubmaker.config['stylesheet'] = ['exist.css']
|
903
|
+
assert_nothing_raised { epubmaker.copy_stylesheet(tmpdir) }
|
904
|
+
|
905
|
+
epubmaker.config['stylesheet'] = ['nothing.css']
|
906
|
+
assert_raise(SystemExit) { epubmaker.copy_stylesheet(tmpdir) }
|
907
|
+
assert_equal "ERROR --: stylesheet: nothing.css is not found.\n", @log_io.string
|
908
|
+
end
|
909
|
+
|
910
|
+
epubmaker_instance do |epubmaker, tmpdir|
|
911
|
+
epubmaker.config['titlepage'] = true
|
912
|
+
epubmaker.config['titlefile'] = 'exist.html'
|
913
|
+
assert_nothing_raised { epubmaker.copy_frontmatter(tmpdir) }
|
914
|
+
|
915
|
+
epubmaker.config['titlefile'] = 'nothing.html'
|
916
|
+
@log_io.string = ''
|
917
|
+
assert_raise(SystemExit) { epubmaker.copy_frontmatter(tmpdir) }
|
918
|
+
assert_equal "ERROR --: titlefile: nothing.html is not found.\n", @log_io.string
|
919
|
+
end
|
920
|
+
|
921
|
+
# XXX: only `cover' is allowed to have invalid file name.
|
922
|
+
%w[originaltitlefile creditfile].each do |name|
|
923
|
+
epubmaker_instance do |epubmaker, tmpdir|
|
924
|
+
epubmaker.config[name] = 'exist.html'
|
925
|
+
assert_nothing_raised { epubmaker.copy_frontmatter(tmpdir) }
|
926
|
+
|
927
|
+
epubmaker.config[name] = 'nothing.html'
|
928
|
+
@log_io.string = ''
|
929
|
+
assert_raise(SystemExit) { epubmaker.copy_frontmatter(tmpdir) }
|
930
|
+
assert_equal "ERROR --: #{name}: nothing.html is not found.\n", @log_io.string
|
931
|
+
end
|
932
|
+
end
|
933
|
+
|
934
|
+
%w[profile advfile colophon backcover].each do |name|
|
935
|
+
epubmaker_instance do |epubmaker, tmpdir|
|
936
|
+
epubmaker.config[name] = 'exist.html'
|
937
|
+
assert_nothing_raised { epubmaker.copy_backmatter(tmpdir) }
|
938
|
+
|
939
|
+
epubmaker.config[name] = 'nothing.html'
|
940
|
+
@log_io.string = ''
|
941
|
+
assert_raise(SystemExit) { epubmaker.copy_backmatter(tmpdir) }
|
942
|
+
assert_equal "ERROR --: #{name}: nothing.html is not found.\n", @log_io.string
|
943
|
+
end
|
944
|
+
end
|
945
|
+
end
|
829
946
|
end
|