review 4.0.0 → 5.1.1
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 +31 -0
- data/.github/workflows/ruby-win.yml +45 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +141 -38
- data/Dockerfile +21 -5
- data/NEWS.ja.md +338 -1
- data/NEWS.md +339 -2
- data/README.md +11 -7
- data/Rakefile +7 -2
- data/appveyor.yml +0 -20
- data/bin/review +2 -4
- data/bin/review-catalog-converter +4 -4
- data/bin/review-check +8 -12
- data/bin/review-checkdep +2 -5
- data/bin/review-compile +11 -20
- data/bin/review-epub2html +1 -4
- data/bin/review-epubmaker +3 -4
- data/bin/review-idgxmlmaker +1 -3
- data/bin/review-index +5 -86
- data/bin/review-init +1 -4
- data/bin/review-pdfmaker +1 -3
- data/bin/review-preproc +3 -5
- data/bin/review-textmaker +1 -3
- data/bin/review-update +1 -4
- data/bin/review-validate +5 -5
- data/bin/review-vol +5 -82
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +55 -12
- data/doc/config.yml.sample-simple +4 -3
- data/doc/format.ja.md +119 -17
- data/doc/format.md +106 -17
- data/doc/makeindex.ja.md +2 -2
- data/doc/pdfmaker.ja.md +42 -0
- data/doc/pdfmaker.md +41 -0
- data/doc/quickstart.ja.md +55 -25
- data/doc/quickstart.md +47 -17
- data/lib/review.rb +1 -1
- data/lib/review/book.rb +2 -2
- data/lib/review/book/base.rb +69 -30
- data/lib/review/book/bib.rb +21 -0
- data/lib/review/book/book_unit.rb +158 -0
- data/lib/review/book/chapter.rb +33 -26
- data/lib/review/book/index.rb +39 -206
- data/lib/review/book/index/item.rb +8 -2
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +26 -11
- data/lib/review/book/volume.rb +5 -5
- data/lib/review/builder.rb +124 -27
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +3 -2
- data/lib/review/compiler.rb +197 -91
- data/lib/review/configure.rb +95 -9
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +6 -1
- data/lib/review/epubmaker.rb +116 -117
- 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 +168 -0
- data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
- data/lib/review/epubmaker/zip_exporter.rb +84 -0
- data/lib/review/exception.rb +6 -0
- data/lib/review/extentions/string.rb +0 -4
- data/lib/review/htmlbuilder.rb +132 -87
- data/lib/review/htmlutils.rb +8 -11
- data/lib/review/i18n.rb +2 -1
- data/lib/review/idgxmlbuilder.rb +156 -76
- data/lib/review/idgxmlmaker.rb +22 -18
- data/lib/review/img_math.rb +245 -0
- data/lib/review/index_builder.rb +654 -0
- data/lib/review/init.rb +17 -18
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +173 -43
- data/lib/review/latexutils.rb +9 -1
- data/lib/review/lineinput.rb +112 -2
- data/lib/review/logger.rb +42 -3
- data/lib/review/makerhelper.rb +12 -187
- data/lib/review/markdownbuilder.rb +51 -2
- data/lib/review/pdfmaker.rb +78 -73
- data/lib/review/plaintextbuilder.rb +98 -14
- data/lib/review/preprocessor.rb +18 -12
- data/lib/review/rstbuilder.rb +28 -9
- data/lib/review/sec_counter.rb +14 -0
- data/lib/review/template.rb +6 -0
- data/lib/review/textmaker.rb +21 -19
- data/lib/review/textutils.rb +3 -12
- data/lib/review/tocprinter.rb +242 -97
- data/lib/review/topbuilder.rb +91 -24
- data/lib/review/update.rb +12 -13
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +97 -0
- data/lib/review/webmaker.rb +34 -33
- data/lib/review/webtocprinter.rb +39 -35
- data/lib/review/yamlloader.rb +2 -1
- data/review.gemspec +5 -3
- data/samples/sample-book/src/.gitignore +1 -0
- data/samples/sample-book/src/config-ebook.yml +4 -0
- data/samples/sample-book/src/config-epub2.yml +1 -1
- data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
- data/samples/sample-book/src/config.yml +3 -3
- data/samples/sample-book/src/lib/tasks/review.rake +26 -6
- data/samples/syntax-book/Gemfile +1 -1
- data/samples/syntax-book/ch01.re +3 -1
- data/samples/syntax-book/ch02.re +28 -21
- data/samples/syntax-book/ch03.re +1 -1
- data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
- data/samples/syntax-book/config-print.yml +3 -0
- data/samples/syntax-book/config.yml +1 -1
- data/samples/syntax-book/images/img3-2.png +0 -0
- data/samples/syntax-book/lib/tasks/review.rake +23 -8
- 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 +41 -29
- data/templates/latex/review-jlreq/README.md +3 -1
- data/templates/latex/review-jlreq/review-base.sty +47 -22
- data/templates/latex/review-jlreq/review-jlreq.cls +25 -24
- 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/README.md +7 -5
- data/templates/latex/review-jsbook/review-base.sty +47 -21
- data/templates/latex/review-jsbook/review-jsbook.cls +12 -2
- 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 +9 -8
- 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 +58 -0
- data/test/assets/test_template.tex +12 -9
- data/test/assets/test_template_backmatter.tex +12 -9
- data/test/book_test_helper.rb +11 -5
- data/test/run_test.rb +1 -1
- data/test/test_book.rb +62 -63
- data/test/test_book_chapter.rb +99 -56
- data/test/test_book_part.rb +3 -3
- data/test/test_builder.rb +24 -15
- data/test/test_catalog.rb +1 -0
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_converter.rb +1 -0
- data/test/test_epub3maker.rb +170 -126
- data/test/test_epubmaker.rb +249 -129
- data/test/test_epubmaker_cmd.rb +14 -7
- data/test/test_helper.rb +23 -11
- data/test/test_htmlbuilder.rb +956 -76
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +33 -33
- data/test/test_idgxmlbuilder.rb +568 -10
- data/test/test_idgxmlmaker_cmd.rb +50 -0
- data/test/test_image_finder.rb +52 -70
- data/test/test_img_math.rb +111 -0
- data/test/test_index.rb +62 -52
- data/test/test_indexbuilder.rb +52 -0
- data/test/test_latexbuilder.rb +1056 -30
- data/test/test_latexbuilder_v2.rb +52 -12
- data/test/test_lineinput.rb +20 -93
- data/test/test_logger.rb +7 -7
- data/test/test_makerhelper.rb +0 -12
- data/test/test_markdownbuilder.rb +32 -0
- data/test/test_pdfmaker.rb +100 -11
- data/test/test_pdfmaker_cmd.rb +101 -7
- data/test/test_plaintextbuilder.rb +531 -25
- data/test/test_review_ext.rb +2 -1
- data/test/test_reviewheaderlistener.rb +49 -0
- data/test/test_rstbuilder.rb +25 -1
- data/test/test_sec_counter.rb +156 -0
- data/test/test_template.rb +12 -2
- data/test/test_textmaker_cmd.rb +58 -0
- data/test/test_tocprinter.rb +46 -0
- data/test/test_topbuilder.rb +365 -10
- data/test/test_update.rb +44 -44
- data/test/test_webtocprinter.rb +75 -43
- data/test/test_zip_exporter.rb +5 -6
- data/vendor/gentombow/LICENSE +1 -1
- data/vendor/gentombow/Makefile +0 -1
- data/vendor/gentombow/bounddvi-en.pdf +0 -0
- data/vendor/gentombow/bounddvi-en.tex +1 -0
- data/vendor/gentombow/bounddvi.pdf +0 -0
- data/vendor/gentombow/bounddvi.sty +30 -7
- data/vendor/gentombow/bounddvi.tex +1 -0
- data/vendor/gentombow/create_archive.sh +1 -0
- data/vendor/gentombow/gentombow-ja.pdf +0 -0
- data/vendor/gentombow/gentombow-ja.tex +9 -0
- data/vendor/gentombow/gentombow.pdf +0 -0
- data/vendor/gentombow/gentombow.sty +32 -10
- data/vendor/gentombow/gentombow.tex +8 -0
- data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
- data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
- data/vendor/jsclasses/LICENSE +1 -1
- data/vendor/jsclasses/Makefile +3 -2
- data/vendor/jsclasses/create_archive.sh +5 -5
- data/vendor/jsclasses/jis/Makefile +3 -2
- data/vendor/jsclasses/jis/jsarticle.cls +74 -31
- data/vendor/jsclasses/jis/jsbook.cls +74 -31
- data/vendor/jsclasses/jis/jsclasses.dtx +176 -36
- data/vendor/jsclasses/jis/jsclasses.ins +15 -5
- data/vendor/jsclasses/jis/jslogo.dtx +4 -4
- data/vendor/jsclasses/jis/jslogo.ins +9 -0
- data/vendor/jsclasses/jis/jslogo.sty +4 -16
- data/vendor/jsclasses/jis/jspf.cls +73 -30
- data/vendor/jsclasses/jis/jsreport.cls +74 -31
- data/vendor/jsclasses/jis/jsverb.ins +9 -0
- data/vendor/jsclasses/jis/jsverb.sty +1 -13
- data/vendor/jsclasses/jis/kiyou.cls +74 -31
- data/vendor/jsclasses/jis/minijs.sty +65 -22
- data/vendor/jsclasses/jis/okumacro.dtx +4 -5
- data/vendor/jsclasses/jis/okumacro.ins +9 -0
- data/vendor/jsclasses/jis/okumacro.sty +4 -17
- data/vendor/jsclasses/jis/okuverb.ins +9 -0
- data/vendor/jsclasses/jis/okuverb.sty +1 -13
- data/vendor/jsclasses/jis/winjis.sty +23 -19
- data/vendor/jsclasses/jsarticle.cls +74 -31
- data/vendor/jsclasses/jsbook.cls +74 -31
- data/vendor/jsclasses/jsclasses.dtx +176 -36
- data/vendor/jsclasses/jsclasses.ins +15 -5
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.dtx +4 -4
- data/vendor/jsclasses/jslogo.ins +9 -0
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +4 -16
- data/vendor/jsclasses/jspf.cls +73 -30
- data/vendor/jsclasses/jsreport.cls +74 -31
- data/vendor/jsclasses/jsverb.ins +9 -0
- data/vendor/jsclasses/jsverb.pdf +0 -0
- data/vendor/jsclasses/jsverb.sty +1 -13
- data/vendor/jsclasses/kiyou.cls +74 -31
- data/vendor/jsclasses/minijs.sty +68 -22
- data/vendor/jsclasses/okumacro.dtx +4 -5
- data/vendor/jsclasses/okumacro.ins +9 -0
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +4 -17
- data/vendor/jsclasses/okuverb.ins +9 -0
- data/vendor/jsclasses/okuverb.pdf +0 -0
- data/vendor/jsclasses/okuverb.sty +1 -13
- data/vendor/jsclasses/tests/relfont.tex +10 -0
- data/vendor/jsclasses/winjis.sty +23 -19
- metadata +109 -20
- data/.rubocop_todo.yml +0 -7
- data/lib/epubmaker.rb +0 -23
- data/lib/epubmaker/content.rb +0 -110
- data/lib/epubmaker/epubcommon.rb +0 -441
- data/lib/epubmaker/epubv2.rb +0 -143
- data/lib/epubmaker/epubv3.rb +0 -233
- data/lib/epubmaker/producer.rb +0 -375
- data/lib/epubmaker/zip_exporter.rb +0 -81
- data/lib/lineinput.rb +0 -155
- data/lib/review/book/compilable.rb +0 -178
- data/lib/review/tocparser.rb +0 -271
- data/samples/syntax-book/review-ext.rb +0 -14
- data/test/test_tocparser.rb +0 -25
data/test/test_book_chapter.rb
CHANGED
@@ -2,6 +2,10 @@ require 'book_test_helper'
|
|
2
2
|
class ChapterTest < Test::Unit::TestCase
|
3
3
|
include BookTestHelper
|
4
4
|
|
5
|
+
def setup
|
6
|
+
I18n.setup
|
7
|
+
end
|
8
|
+
|
5
9
|
def test_initialize
|
6
10
|
ch = Book::Chapter.new(:book, :number, :name, '/foo/bar', :io)
|
7
11
|
assert_equal :book, ch.book
|
@@ -37,11 +41,13 @@ class ChapterTest < Test::Unit::TestCase
|
|
37
41
|
|
38
42
|
def test_size
|
39
43
|
ch = Book::Chapter.new(nil, nil, nil, __FILE__, :io)
|
40
|
-
|
44
|
+
filesize = IO.read(__FILE__, mode: 'rt:BOM|utf-8').size
|
45
|
+
assert_equal filesize, ch.size
|
41
46
|
|
42
47
|
File.open(__FILE__, 'r') do |i|
|
43
48
|
ch = Book::Chapter.new(nil, nil, nil, nil, i)
|
44
|
-
|
49
|
+
filesize = IO.read(__FILE__, mode: 'rt:BOM|utf-8').size
|
50
|
+
assert_equal filesize, ch.size
|
45
51
|
end
|
46
52
|
end
|
47
53
|
|
@@ -64,6 +70,7 @@ class ChapterTest < Test::Unit::TestCase
|
|
64
70
|
|
65
71
|
book = Book::Base.new
|
66
72
|
ch = Book::Chapter.new(book, nil, nil, tf.path)
|
73
|
+
ch.generate_indexes
|
67
74
|
assert_equal lines, ch.lines
|
68
75
|
|
69
76
|
lines = ["1\n", "2\n", '3']
|
@@ -76,6 +83,7 @@ class ChapterTest < Test::Unit::TestCase
|
|
76
83
|
tf2.close
|
77
84
|
|
78
85
|
ch = Book::Chapter.new(book, nil, nil, tf1.path, tf2.path)
|
86
|
+
ch.generate_indexes
|
79
87
|
assert_equal lines, ch.lines # XXX: OK?
|
80
88
|
end
|
81
89
|
|
@@ -101,20 +109,20 @@ class ChapterTest < Test::Unit::TestCase
|
|
101
109
|
end
|
102
110
|
|
103
111
|
def test_on_chaps?
|
104
|
-
mktmpbookdir
|
105
|
-
'chapter1.re' => '12345', 'preface.re' => 'abcde' do |dir, book, files|
|
112
|
+
mktmpbookdir('CHAPS' => "chapter1.re\nchapter2.re",
|
113
|
+
'chapter1.re' => '12345', 'preface.re' => 'abcde') do |dir, book, files|
|
106
114
|
ch1 = Book::Chapter.new(book, 1, 'chapter1', files['chapter1.re'])
|
107
115
|
pre = Book::Chapter.new(book, nil, 'preface', files['preface.re'])
|
108
116
|
|
109
117
|
assert ch1.on_chaps?
|
110
118
|
assert !pre.on_chaps?
|
111
119
|
|
112
|
-
ch2_path = File.join(dir, 'chapter2.
|
113
|
-
|
120
|
+
ch2_path = File.join(dir, 'chapter2.re')
|
121
|
+
FileUtils.touch(ch2_path)
|
114
122
|
ch2 = Book::Chapter.new(book, 2, 'chapter2', ch2_path)
|
115
123
|
|
116
|
-
ch3_path = File.join(dir, 'chapter3.
|
117
|
-
|
124
|
+
ch3_path = File.join(dir, 'chapter3.re')
|
125
|
+
FileUtils.touch(ch3_path)
|
118
126
|
ch3 = Book::Chapter.new(book, 3, 'chapter3', ch3_path)
|
119
127
|
|
120
128
|
assert ch2.on_chaps?
|
@@ -122,50 +130,70 @@ class ChapterTest < Test::Unit::TestCase
|
|
122
130
|
end
|
123
131
|
end
|
124
132
|
|
133
|
+
def test_invalid_encoding
|
134
|
+
mktmpbookdir('CHAPS' => 'chapter1.re',
|
135
|
+
'chapter1.re' => "= 日本語UTF-8\n") do |_dir, book, files|
|
136
|
+
assert Book::Chapter.new(book, 1, 'chapter1', files['chapter1.re'])
|
137
|
+
end
|
138
|
+
|
139
|
+
# UTF-16LE UTF-16BE UTF-32LE UTF-32BE cause error on Windows
|
140
|
+
%w[CP932 SHIFT_JIS EUC-JP].each do |enc|
|
141
|
+
mktmpbookdir('CHAPS' => 'chapter1.re',
|
142
|
+
'chapter1.re' => "= 日本語UTF-8\n".encode(enc)) do |_dir, book, files|
|
143
|
+
e = assert_raises(ReVIEW::CompileError) { Book::Chapter.new(book, 1, 'chapter1', files['chapter1.re']) }
|
144
|
+
assert_equal 'chapter1: invalid byte sequence in UTF-8', e.message
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
125
149
|
def test_list_index
|
126
150
|
do_test_index(<<E, Book::ListIndex, :list_index, :list)
|
127
|
-
//
|
128
|
-
//
|
129
|
-
//list
|
130
|
-
//
|
131
|
-
//table
|
151
|
+
//listnum[abc][abc-listnum]{
|
152
|
+
//}
|
153
|
+
//list[def][def-list]{
|
154
|
+
//}
|
155
|
+
//table[def]{
|
156
|
+
//}
|
157
|
+
//table[others]{
|
158
|
+
//}
|
132
159
|
E
|
133
160
|
end
|
134
161
|
|
135
162
|
def test_table_index
|
136
163
|
do_test_index(<<E, Book::TableIndex, :table_index, :table)
|
137
|
-
//table
|
138
|
-
//
|
139
|
-
//table
|
140
|
-
//
|
141
|
-
//list
|
164
|
+
//table[abc]{
|
165
|
+
//}
|
166
|
+
//table[def]{
|
167
|
+
//}
|
168
|
+
//list[def][def-list]{
|
169
|
+
//}
|
170
|
+
//list[others][other-list]{
|
171
|
+
//}
|
142
172
|
E
|
143
173
|
end
|
144
174
|
|
145
175
|
def test_footnote_index
|
146
176
|
content = <<E
|
147
|
-
//footnote
|
148
|
-
//footnote
|
149
|
-
//footnote
|
150
|
-
//
|
151
|
-
//
|
152
|
-
//list
|
177
|
+
//footnote[abc][textabc...]
|
178
|
+
//footnote[def][textdef...]
|
179
|
+
//footnote[xyz][textxyz...]
|
180
|
+
//list[def][def-list]{
|
181
|
+
//}
|
182
|
+
//list[others][others-list]{
|
183
|
+
//}
|
153
184
|
E
|
154
185
|
do_test_index(content, Book::FootnoteIndex, :footnote_index, :footnote) do |ch|
|
155
186
|
assert_raises ReVIEW::KeyError do
|
156
|
-
ch.footnote('
|
187
|
+
ch.footnote('xyz2')
|
157
188
|
end
|
158
189
|
end
|
159
190
|
end
|
160
191
|
|
161
192
|
def test_bibpaper
|
162
193
|
do_test_index(<<E, Book::BibpaperIndex, :bibpaper_index, :bibpaper, filename: 'bib.re')
|
163
|
-
//bibpaper
|
164
|
-
//bibpaper
|
165
|
-
//bibpaper
|
166
|
-
//bibpaper [xyz]
|
167
|
-
//list [def]
|
168
|
-
//list [others]
|
194
|
+
//bibpaper[abc][text...]
|
195
|
+
//bibpaper[def][text...]
|
196
|
+
//bibpaper[xyz][text...]
|
169
197
|
E
|
170
198
|
assert_raises FileNotFound do
|
171
199
|
do_test_index('', Book::BibpaperIndex, :bibpaper_index, :bibpaper, filename: 'bib')
|
@@ -174,11 +202,12 @@ E
|
|
174
202
|
|
175
203
|
def test_headline_index
|
176
204
|
do_test_index(<<E, Book::HeadlineIndex, :headline_index, :headline, propagate: false)
|
177
|
-
==
|
205
|
+
== x
|
178
206
|
== abc
|
179
207
|
== def
|
180
208
|
=== def
|
181
|
-
//table
|
209
|
+
//table[others]{
|
210
|
+
//}
|
182
211
|
E
|
183
212
|
end
|
184
213
|
|
@@ -202,35 +231,47 @@ E
|
|
202
231
|
|
203
232
|
def test_image
|
204
233
|
do_test_index(<<E, Book::ImageIndex, :image_index, :image)
|
205
|
-
//image
|
206
|
-
//
|
207
|
-
//image
|
208
|
-
//
|
209
|
-
//list
|
234
|
+
//image[abc][abc-image]{
|
235
|
+
//}
|
236
|
+
//image[def][abc-image]{
|
237
|
+
//}
|
238
|
+
//list[def][def-list]{
|
239
|
+
//}
|
240
|
+
//list[others][others-list]{
|
241
|
+
//}
|
210
242
|
E
|
211
243
|
|
212
244
|
do_test_index(<<E, Book::NumberlessImageIndex, :numberless_image_index, :image, propagate: false)
|
213
|
-
//numberlessimage
|
214
|
-
//
|
215
|
-
//numberlessimage
|
216
|
-
//
|
217
|
-
//list
|
245
|
+
//numberlessimage[abc]{
|
246
|
+
//}
|
247
|
+
//numberlessimage[def]{
|
248
|
+
//}
|
249
|
+
//list[def][def-list]{
|
250
|
+
//}
|
251
|
+
//list[others][others-list]{
|
252
|
+
//}
|
218
253
|
E
|
219
254
|
|
220
255
|
do_test_index(<<E, Book::ImageIndex, :image_index, :image)
|
221
|
-
//
|
222
|
-
//
|
223
|
-
//image
|
224
|
-
//
|
225
|
-
//list
|
256
|
+
//numberlessimage[abc]{
|
257
|
+
//}
|
258
|
+
//image[def][def-image]{
|
259
|
+
//}
|
260
|
+
//list[def][def-list]{
|
261
|
+
//}
|
262
|
+
//list[others][others-list]{
|
263
|
+
//}
|
226
264
|
E
|
227
265
|
|
228
266
|
do_test_index(<<E, Book::NumberlessImageIndex, :numberless_image_index, :image, propagate: false)
|
229
|
-
//
|
230
|
-
//
|
231
|
-
//image
|
232
|
-
//
|
233
|
-
//list
|
267
|
+
//numberlessimage[abc]{
|
268
|
+
//}
|
269
|
+
//image[def][def-image]{
|
270
|
+
//}
|
271
|
+
//list[def][def-list]{
|
272
|
+
//}
|
273
|
+
//list[others][others-list]{
|
274
|
+
//}
|
234
275
|
E
|
235
276
|
end
|
236
277
|
|
@@ -238,13 +279,15 @@ E
|
|
238
279
|
Dir.mktmpdir do |dir|
|
239
280
|
path = File.join(dir, opts[:filename] || 'chapter.re')
|
240
281
|
|
241
|
-
book = Book::Base.new(dir)
|
242
|
-
|
243
282
|
File.open(path, 'w') do |o|
|
244
283
|
o.print content
|
245
284
|
end
|
246
|
-
ch = Book::Chapter.new(book, 1, 'chapter', path)
|
247
285
|
|
286
|
+
book = Book::Base.new(dir)
|
287
|
+
|
288
|
+
ch = Book::Chapter.new(book, 1, 'chapter', path)
|
289
|
+
book.generate_indexes
|
290
|
+
ch.generate_indexes
|
248
291
|
assert ch.__send__(ref_method, 'abc')
|
249
292
|
assert ch.__send__(ref_method, 'def')
|
250
293
|
assert_raises ReVIEW::KeyError do
|
data/test/test_book_part.rb
CHANGED
@@ -46,8 +46,8 @@ class PartTest < Test::Unit::TestCase
|
|
46
46
|
|
47
47
|
part = Book::Part.new(book, nil, chs)
|
48
48
|
assert part.volume
|
49
|
-
assert part.volume.bytes
|
50
|
-
assert part.volume.chars
|
51
|
-
assert part.volume.lines
|
49
|
+
assert part.volume.bytes == 0
|
50
|
+
assert part.volume.chars == 0
|
51
|
+
assert part.volume.lines == 0
|
52
52
|
end
|
53
53
|
end
|
data/test/test_builder.rb
CHANGED
@@ -24,7 +24,7 @@ class BuidlerTest < Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
def test_bind
|
26
26
|
b = Builder.new
|
27
|
-
chap = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.
|
27
|
+
chap = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.new, nil, '-', nil)
|
28
28
|
assert_nothing_raised do
|
29
29
|
b.bind(nil, chap, nil)
|
30
30
|
end
|
@@ -37,7 +37,7 @@ class BuidlerTest < Test::Unit::TestCase
|
|
37
37
|
end
|
38
38
|
|
39
39
|
b = Builder.new
|
40
|
-
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.
|
40
|
+
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.new, nil, '-', nil)
|
41
41
|
b.bind(nil, chapter, nil)
|
42
42
|
assert_equal '', b.result
|
43
43
|
end
|
@@ -82,7 +82,7 @@ class BuidlerTest < Test::Unit::TestCase
|
|
82
82
|
|
83
83
|
def test_inline_missing_ref
|
84
84
|
b = Builder.new
|
85
|
-
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.
|
85
|
+
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.new, 1, 'chap1', nil, StringIO.new)
|
86
86
|
b.bind(nil, chapter, nil)
|
87
87
|
e = assert_raises(ReVIEW::ApplicationError) { b.inline_list('unknown|list1') }
|
88
88
|
assert_equal ': error: unknown list: unknown|list1', e.message
|
@@ -96,20 +96,29 @@ class BuidlerTest < Test::Unit::TestCase
|
|
96
96
|
assert_equal ': error: unknown footnote: unknown|footnote1', e.message
|
97
97
|
end
|
98
98
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
99
|
+
def test_nest_error
|
100
|
+
b = XBuilder.new
|
101
|
+
b.children = nil
|
102
|
+
assert_equal '', b.solve_nest('')
|
103
|
+
b.children = ['dl']
|
104
|
+
e = assert_raises(ReVIEW::ApplicationError) { b.solve_nest('') }
|
105
|
+
assert_equal ': error: //beginchild of dl misses //endchild', e.message
|
106
|
+
b.children = ['ul', 'dl', 'ol']
|
107
|
+
e = assert_raises(ReVIEW::ApplicationError) { b.solve_nest('') }
|
108
|
+
assert_equal ': error: //beginchild of ol,dl,ul misses //endchild', e.message
|
109
|
+
|
110
|
+
assert_equal "\u0001→/ol←\u0001", b.endchild
|
111
|
+
assert_equal "\u0001→/dl←\u0001", b.endchild
|
112
|
+
assert_equal "\u0001→/ul←\u0001", b.endchild
|
113
|
+
e = assert_raises(ReVIEW::ApplicationError) { b.endchild }
|
114
|
+
assert_equal ": error: //endchild is shown, but any opened //beginchild doesn't exist", e.message
|
115
|
+
end
|
108
116
|
|
109
|
-
|
110
|
-
|
117
|
+
class XBuilder < Builder
|
118
|
+
attr_accessor :children
|
111
119
|
|
112
|
-
def
|
120
|
+
def puts(s)
|
121
|
+
s
|
113
122
|
end
|
114
123
|
end
|
115
124
|
end
|
data/test/test_catalog.rb
CHANGED
@@ -4,7 +4,7 @@ require 'fileutils'
|
|
4
4
|
require 'yaml'
|
5
5
|
require 'rbconfig'
|
6
6
|
|
7
|
-
load(File.expand_path('../bin/review-catalog-converter',
|
7
|
+
load(File.expand_path('../bin/review-catalog-converter', __dir__))
|
8
8
|
|
9
9
|
class CatalogConverterCmdTest < Test::Unit::TestCase
|
10
10
|
def test_parse_chaps
|
data/test/test_converter.rb
CHANGED
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">
|
@@ -631,7 +640,7 @@ EOT
|
|
631
640
|
</body>
|
632
641
|
</html>
|
633
642
|
EOT
|
634
|
-
File.
|
643
|
+
File.write(path, html)
|
635
644
|
assert_equal ['mathml'], epubmaker.detect_properties(path)
|
636
645
|
end
|
637
646
|
end
|
@@ -656,7 +665,7 @@ EOT
|
|
656
665
|
</body>
|
657
666
|
</html>
|
658
667
|
EOT
|
659
|
-
File.
|
668
|
+
File.write(path, html)
|
660
669
|
assert_equal ['mathml'], epubmaker.detect_properties(path)
|
661
670
|
end
|
662
671
|
end
|
@@ -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
|