review 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +1 -0
- data/ChangeLog +87 -0
- data/bin/review-check +2 -2
- data/bin/review-compile +15 -30
- data/bin/review-index +1 -1
- data/bin/review-init +12 -7
- data/bin/review-vol +9 -1
- data/doc/catalog.ja.md +53 -0
- data/doc/catalog.md +52 -0
- data/doc/format.ja.md +734 -0
- data/doc/format.md +746 -0
- data/doc/format_idg.ja.md +203 -0
- data/doc/{quickstart.rdoc → quickstart.ja.md} +138 -104
- data/doc/quickstart.md +252 -0
- data/doc/sample.yml +216 -48
- data/lib/epubmaker.rb +0 -1
- data/lib/epubmaker/content.rb +2 -2
- data/lib/epubmaker/epubcommon.rb +440 -0
- data/lib/epubmaker/epubv2.rb +8 -418
- data/lib/epubmaker/epubv3.rb +67 -61
- data/lib/epubmaker/producer.rb +60 -19
- data/lib/review/book.rb +1 -3
- data/lib/review/book/base.rb +18 -11
- data/lib/review/book/chapter.rb +5 -24
- data/lib/review/book/compilable.rb +5 -1
- data/lib/review/book/index.rb +48 -17
- data/lib/review/book/page_metric.rb +17 -8
- data/lib/review/book/part.rb +12 -2
- data/lib/review/book/volume.rb +3 -2
- data/lib/review/builder.rb +30 -10
- data/lib/review/compiler.rb +6 -4
- data/lib/review/configure.rb +3 -3
- data/lib/review/epubmaker.rb +56 -26
- data/lib/review/htmlbuilder.rb +33 -42
- data/lib/review/htmlutils.rb +12 -7
- data/lib/review/i18n.rb +77 -17
- data/lib/review/i18n.yml +80 -4
- data/lib/review/idgxmlbuilder.rb +27 -57
- data/lib/review/inaobuilder.rb +3 -3
- data/lib/review/latexbuilder.rb +90 -67
- data/lib/review/layout.tex.erb +54 -7
- data/lib/review/markdownbuilder.rb +21 -3
- data/lib/review/pdfmaker.rb +67 -38
- data/lib/review/sec_counter.rb +1 -1
- data/lib/review/tocparser.rb +9 -5
- data/lib/review/topbuilder.rb +6 -6
- data/lib/review/version.rb +1 -1
- data/review.gemspec +3 -1
- data/test/book_test_helper.rb +1 -1
- data/test/sample-book/README.md +2 -0
- data/test/sample-book/src/Rakefile +31 -0
- data/test/sample-book/src/_cover.html +0 -0
- data/test/sample-book/src/catalog.yml +10 -0
- data/test/sample-book/src/ch01.re +0 -0
- data/test/sample-book/src/ch02.re +0 -0
- data/test/sample-book/src/config.yml +160 -32
- data/test/sample-book/src/images/ch01-imgsample.jpg +0 -0
- data/test/sample-book/src/images/cover.jpg +0 -0
- data/test/sample-book/src/preface.re +0 -0
- data/test/sample-book/src/sty/jumoline.sty +0 -0
- data/test/sample-book/src/sty/reviewmacro.sty +18 -0
- data/test/sample-book/src/style.css +0 -0
- data/test/test_book.rb +25 -27
- data/test/test_book_chapter.rb +4 -73
- data/test/test_book_part.rb +5 -4
- data/test/test_builder.rb +3 -3
- data/test/test_epub3maker.rb +527 -0
- data/test/test_epubmaker.rb +6 -6
- data/test/test_htmlbuilder.rb +143 -6
- data/test/test_i18n.rb +95 -10
- data/test/test_idgxmlbuilder.rb +28 -2
- data/test/test_index.rb +109 -1
- data/test/test_latexbuilder.rb +51 -0
- data/test/test_markdownbuilder.rb +54 -1
- data/test/test_pdfmaker.rb +7 -6
- data/test/test_review_ext.rb +31 -0
- data/test/test_topbuilder.rb +3 -1
- metadata +46 -13
- data/doc/catalog.rdoc +0 -49
- data/doc/format.rdoc +0 -618
- data/doc/format_idg.rdoc +0 -180
- data/doc/libepubmaker/config.yml +0 -207
- data/lib/epubmaker/resource.rb +0 -82
- data/test/sample-book/src/CHAPS +0 -2
- data/test/sample-book/src/PREDEF +0 -1
data/test/test_book_part.rb
CHANGED
@@ -25,7 +25,8 @@ class PartTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_volume
|
28
|
-
|
28
|
+
book = Book::Base.new(nil)
|
29
|
+
part = Book::Part.new(book, nil, [])
|
29
30
|
assert part.volume
|
30
31
|
assert_equal 0, part.volume.bytes
|
31
32
|
assert_equal 0, part.volume.chars
|
@@ -35,16 +36,16 @@ class PartTest < Test::Unit::TestCase
|
|
35
36
|
tfs = [] ## prevent from removing Tempfile
|
36
37
|
Tempfile.open('part_test') do |o|
|
37
38
|
o.print "12345"
|
38
|
-
chs << Book::Chapter.new(
|
39
|
+
chs << Book::Chapter.new(book, nil, nil, o.path)
|
39
40
|
tfs << o
|
40
41
|
end
|
41
42
|
Tempfile.open('part_test') do |o|
|
42
43
|
o.print "67890"
|
43
|
-
chs << Book::Chapter.new(
|
44
|
+
chs << Book::Chapter.new(book, nil, nil, o.path)
|
44
45
|
tfs << o
|
45
46
|
end
|
46
47
|
|
47
|
-
part = Book::Part.new(
|
48
|
+
part = Book::Part.new(book, nil, chs)
|
48
49
|
assert part.volume
|
49
50
|
assert part.volume.bytes > 0
|
50
51
|
assert part.volume.chars > 0
|
data/test/test_builder.rb
CHANGED
@@ -26,7 +26,7 @@ class BuidlerTest < Test::Unit::TestCase
|
|
26
26
|
|
27
27
|
def test_bind
|
28
28
|
b = Builder.new
|
29
|
-
chap = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.
|
29
|
+
chap = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load, nil, '-', nil)
|
30
30
|
assert_nothing_raised do
|
31
31
|
b.bind(nil, chap, nil)
|
32
32
|
end
|
@@ -39,7 +39,7 @@ class BuidlerTest < Test::Unit::TestCase
|
|
39
39
|
end
|
40
40
|
|
41
41
|
b = Builder.new
|
42
|
-
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.
|
42
|
+
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load, nil, '-', nil)
|
43
43
|
b.bind(nil, chapter, nil)
|
44
44
|
assert_equal '', b.result
|
45
45
|
end
|
@@ -82,7 +82,7 @@ class BuidlerTest < Test::Unit::TestCase
|
|
82
82
|
[:puts, "#{utf8_str}\n", "#{expect}\n"],
|
83
83
|
].each do |m, instr, expstr|
|
84
84
|
b = Builder.new
|
85
|
-
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.
|
85
|
+
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load, nil, '-', nil)
|
86
86
|
b.bind(nil, chapter, nil)
|
87
87
|
chapter.book.config = params
|
88
88
|
b.__send__(m, instr)
|
@@ -0,0 +1,527 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'epubmaker'
|
5
|
+
require 'review/epubmaker'
|
6
|
+
|
7
|
+
class EPUB3MakerTest < Test::Unit::TestCase
|
8
|
+
include EPUBMaker
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@producer = Producer.new
|
12
|
+
@producer.merge_params({
|
13
|
+
"bookname" => "sample",
|
14
|
+
"title" => "Sample Book",
|
15
|
+
"epubversion" => 3,
|
16
|
+
"urnid" => "http://example.jp/",
|
17
|
+
"date" => "2011-01-01",
|
18
|
+
"language" => "en",
|
19
|
+
"modified" => "2014-12-13T14:15:16Z"
|
20
|
+
})
|
21
|
+
@output = StringIO.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_initialize
|
25
|
+
assert Producer.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_resource_en
|
29
|
+
@producer.merge_params({"language" => "en"})
|
30
|
+
assert_equal "Table of Contents", @producer.res.v("toctitle")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_resource_ja
|
34
|
+
@producer.merge_params({"language" => "ja"})
|
35
|
+
assert_equal "目次", @producer.res.v("toctitle")
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_mimetype
|
39
|
+
@producer.mimetype(@output)
|
40
|
+
assert_equal %Q[application/epub+zip], @output.string
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_container
|
44
|
+
@producer.container(@output)
|
45
|
+
expect = <<EOT
|
46
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
47
|
+
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
|
48
|
+
<rootfiles>
|
49
|
+
<rootfile full-path="OEBPS/sample.opf" media-type="application/oebps-package+xml" />
|
50
|
+
</rootfiles>
|
51
|
+
</container>
|
52
|
+
EOT
|
53
|
+
assert_equal expect, @output.string
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_stage1_opf
|
57
|
+
@producer.opf(@output)
|
58
|
+
expect = <<EOT
|
59
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
60
|
+
<package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="en">
|
61
|
+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
62
|
+
<dc:title id="title">Sample Book</dc:title>
|
63
|
+
<dc:language id="language">en</dc:language>
|
64
|
+
<dc:date id="date">2011-01-01</dc:date>
|
65
|
+
<meta property="dcterms:modified">2014-12-13T14:15:16Z</meta>
|
66
|
+
<dc:identifier id="BookId">http://example.jp/</dc:identifier>
|
67
|
+
</metadata>
|
68
|
+
<manifest>
|
69
|
+
<item properties="nav" id="sample-toc.html" href="sample-toc.html" media-type="application/xhtml+xml"/>
|
70
|
+
<item id="sample" href="sample.html" media-type="application/xhtml+xml"/>
|
71
|
+
</manifest>
|
72
|
+
<spine>
|
73
|
+
<itemref idref="sample" linear="no"/>
|
74
|
+
</spine>
|
75
|
+
<guide>
|
76
|
+
<reference type="cover" title="Cover" href="sample.html"/>
|
77
|
+
<reference type="toc" title="Table of Contents" href="sample-toc.html"/>
|
78
|
+
</guide>
|
79
|
+
</package>
|
80
|
+
EOT
|
81
|
+
assert_equal expect, @output.string
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_stage1_ncx
|
85
|
+
@producer.ncx(@output)
|
86
|
+
expect = <<EOT
|
87
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
88
|
+
<!DOCTYPE html>
|
89
|
+
<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="en">
|
90
|
+
<head>
|
91
|
+
<meta charset="UTF-8" />
|
92
|
+
<meta name="generator" content="Re:VIEW" />
|
93
|
+
<title>Table of Contents</title>
|
94
|
+
</head>
|
95
|
+
<body>
|
96
|
+
<nav xmlns:epub="http://www.idpf.org/2007/ops" epub:type="toc" id="toc">
|
97
|
+
<h1 class="toc-title">Table of Contents</h1>
|
98
|
+
|
99
|
+
<ol class="toc-h1"></ol> </nav>
|
100
|
+
</body>
|
101
|
+
</html>
|
102
|
+
EOT
|
103
|
+
assert_equal expect, @output.string
|
104
|
+
end
|
105
|
+
|
106
|
+
def stage2
|
107
|
+
# add one item
|
108
|
+
@producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01", "level" => 1})
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_stage2_add_l1item
|
112
|
+
stage2
|
113
|
+
expect = EPUBMaker::Content.new("ch01.html",
|
114
|
+
"ch01-html",
|
115
|
+
"application/xhtml+xml",
|
116
|
+
"CH01",
|
117
|
+
1)
|
118
|
+
assert_equal expect, @producer.contents[0]
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_stage2_opf
|
122
|
+
stage2
|
123
|
+
@producer.opf(@output)
|
124
|
+
expect = <<EOT
|
125
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
126
|
+
<package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="en">
|
127
|
+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
128
|
+
<dc:title id="title">Sample Book</dc:title>
|
129
|
+
<dc:language id="language">en</dc:language>
|
130
|
+
<dc:date id="date">2011-01-01</dc:date>
|
131
|
+
<meta property="dcterms:modified">2014-12-13T14:15:16Z</meta>
|
132
|
+
<dc:identifier id="BookId">http://example.jp/</dc:identifier>
|
133
|
+
</metadata>
|
134
|
+
<manifest>
|
135
|
+
<item properties="nav" id="sample-toc.html" href="sample-toc.html" media-type="application/xhtml+xml"/>
|
136
|
+
<item id="sample" href="sample.html" media-type="application/xhtml+xml"/>
|
137
|
+
<item id="ch01-html" href="ch01.html" media-type="application/xhtml+xml"/>
|
138
|
+
</manifest>
|
139
|
+
<spine>
|
140
|
+
<itemref idref="sample" linear="no"/>
|
141
|
+
<itemref idref="ch01-html"/>
|
142
|
+
</spine>
|
143
|
+
<guide>
|
144
|
+
<reference type="cover" title="Cover" href="sample.html"/>
|
145
|
+
<reference type="toc" title="Table of Contents" href="sample-toc.html"/>
|
146
|
+
</guide>
|
147
|
+
</package>
|
148
|
+
EOT
|
149
|
+
assert_equal expect, @output.string
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_stage2_ncx
|
153
|
+
stage2
|
154
|
+
@producer.ncx(@output)
|
155
|
+
expect = <<EOT
|
156
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
157
|
+
<!DOCTYPE html>
|
158
|
+
<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="en">
|
159
|
+
<head>
|
160
|
+
<meta charset="UTF-8" />
|
161
|
+
<meta name="generator" content="Re:VIEW" />
|
162
|
+
<title>Table of Contents</title>
|
163
|
+
</head>
|
164
|
+
<body>
|
165
|
+
<nav xmlns:epub="http://www.idpf.org/2007/ops" epub:type="toc" id="toc">
|
166
|
+
<h1 class="toc-title">Table of Contents</h1>
|
167
|
+
|
168
|
+
<ol class="toc-h1"><li><a href="ch01.html">CH01</a></li>
|
169
|
+
</ol> </nav>
|
170
|
+
</body>
|
171
|
+
</html>
|
172
|
+
EOT
|
173
|
+
assert_equal expect, @output.string
|
174
|
+
end
|
175
|
+
|
176
|
+
def stage3
|
177
|
+
# add more items
|
178
|
+
@producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01<>&\"", "level" => 1})
|
179
|
+
@producer.contents << Content.new({"file" => "ch02.html", "title" => "CH02", "level" => 1})
|
180
|
+
@producer.contents << Content.new({"file" => "ch02.html#S1", "title" => "CH02.1", "level" => 2})
|
181
|
+
@producer.contents << Content.new({"file" => "ch02.html#S1.1", "title" => "CH02.1.1", "level" => 3})
|
182
|
+
@producer.contents << Content.new({"file" => "ch02.html#S1.1.1", "title" => "CH02.1.1.1", "level" => 4})
|
183
|
+
@producer.contents << Content.new({"file" => "ch02.html#S1.1.1.1", "title" => "CH02.1.1.1.1", "level" => 5})
|
184
|
+
@producer.contents << Content.new({"file" => "ch02.html#S1.1.2", "title" => "CH02.1.1.2", "level" => 4})
|
185
|
+
@producer.contents << Content.new({"file" => "ch02.html#S2", "title" => "CH02.2", "level" => 2})
|
186
|
+
@producer.contents << Content.new({"file" => "ch02.html#S2.1", "title" => "CH02.2.1", "level" => 3})
|
187
|
+
@producer.contents << Content.new({"file" => "ch03.html", "title" => "CH03", "level" => 1, "properties" => ["mathml"]})
|
188
|
+
@producer.contents << Content.new({"file" => "ch03.html#S1", "title" => "CH03.1", "level" => 2})
|
189
|
+
@producer.contents << Content.new({"file" => "ch03.html#S1.1", "title" => "CH03.1.1", "level" => 3})
|
190
|
+
@producer.contents << Content.new({"file" => "ch04.html", "title" => "CH04", "level" => 1})
|
191
|
+
@producer.contents << Content.new({"file" => "sample.png"})
|
192
|
+
@producer.contents << Content.new({"file" => "sample.jpg"})
|
193
|
+
@producer.contents << Content.new({"file" => "sample.JPEG"})
|
194
|
+
@producer.contents << Content.new({"file" => "sample.SvG"})
|
195
|
+
@producer.contents << Content.new({"file" => "sample.GIF"})
|
196
|
+
@producer.contents << Content.new({"file" => "sample.css"})
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_stage3_add_various_items
|
200
|
+
stage3
|
201
|
+
expect = [
|
202
|
+
Content.new("ch01.html", "ch01-html", "application/xhtml+xml", "CH01<>&\"", 1),
|
203
|
+
Content.new("ch02.html", "ch02-html", "application/xhtml+xml", "CH02", 1),
|
204
|
+
Content.new("ch02.html#S1", "ch02-html#S1","html#s1","CH02.1", 2),
|
205
|
+
Content.new("ch02.html#S1.1", "ch02-html#S1-1", "1", "CH02.1.1", 3),
|
206
|
+
Content.new("ch02.html#S1.1.1", "ch02-html#S1-1-1","1", "CH02.1.1.1", 4),
|
207
|
+
Content.new("ch02.html#S1.1.1.1", "ch02-html#S1-1-1-1", "1","CH02.1.1.1.1", 5),
|
208
|
+
Content.new("ch02.html#S1.1.2", "ch02-html#S1-1-2", "2", "CH02.1.1.2", 4),
|
209
|
+
Content.new("ch02.html#S2", "ch02-html#S2", "html#s2", "CH02.2", 2),
|
210
|
+
Content.new("ch02.html#S2.1", "ch02-html#S2-1", "1", "CH02.2.1", 3),
|
211
|
+
Content.new("ch03.html", "ch03-html", "application/xhtml+xml", "CH03", 1, nil, ["mathml"]),
|
212
|
+
Content.new("ch03.html#S1", "ch03-html#S1", "html#s1", "CH03.1", 2),
|
213
|
+
Content.new("ch03.html#S1.1", "ch03-html#S1-1", "1", "CH03.1.1", 3),
|
214
|
+
Content.new("ch04.html", "ch04-html", "application/xhtml+xml", "CH04", 1),
|
215
|
+
Content.new("sample.png", "sample-png", "image/png"),
|
216
|
+
Content.new("sample.jpg", "sample-jpg", "image/jpeg"),
|
217
|
+
Content.new("sample.JPEG", "sample-JPEG", "image/jpeg"),
|
218
|
+
Content.new("sample.SvG", "sample-SvG", "image/svg+xml"),
|
219
|
+
Content.new("sample.GIF", "sample-GIF", "image/gif"),
|
220
|
+
Content.new("sample.css", "sample-css", "text/css")
|
221
|
+
]
|
222
|
+
|
223
|
+
assert_equal expect, @producer.contents
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_stage3_opf
|
227
|
+
stage3
|
228
|
+
@producer.opf(@output)
|
229
|
+
expect = <<EOT
|
230
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
231
|
+
<package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="en">
|
232
|
+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
233
|
+
<dc:title id="title">Sample Book</dc:title>
|
234
|
+
<dc:language id="language">en</dc:language>
|
235
|
+
<dc:date id="date">2011-01-01</dc:date>
|
236
|
+
<meta property="dcterms:modified">2014-12-13T14:15:16Z</meta>
|
237
|
+
<dc:identifier id="BookId">http://example.jp/</dc:identifier>
|
238
|
+
</metadata>
|
239
|
+
<manifest>
|
240
|
+
<item properties="nav" id="sample-toc.html" href="sample-toc.html" media-type="application/xhtml+xml"/>
|
241
|
+
<item id="sample" href="sample.html" media-type="application/xhtml+xml"/>
|
242
|
+
<item id="ch01-html" href="ch01.html" media-type="application/xhtml+xml"/>
|
243
|
+
<item id="ch02-html" href="ch02.html" media-type="application/xhtml+xml"/>
|
244
|
+
<item id="ch03-html" href="ch03.html" media-type="application/xhtml+xml" properties="mathml"/>
|
245
|
+
<item id="ch04-html" href="ch04.html" media-type="application/xhtml+xml"/>
|
246
|
+
<item id="sample-png" href="sample.png" media-type="image/png"/>
|
247
|
+
<item id="sample-jpg" href="sample.jpg" media-type="image/jpeg"/>
|
248
|
+
<item id="sample-JPEG" href="sample.JPEG" media-type="image/jpeg"/>
|
249
|
+
<item id="sample-SvG" href="sample.SvG" media-type="image/svg+xml"/>
|
250
|
+
<item id="sample-GIF" href="sample.GIF" media-type="image/gif"/>
|
251
|
+
<item id="sample-css" href="sample.css" media-type="text/css"/>
|
252
|
+
</manifest>
|
253
|
+
<spine>
|
254
|
+
<itemref idref="sample" linear="no"/>
|
255
|
+
<itemref idref="ch01-html"/>
|
256
|
+
<itemref idref="ch02-html"/>
|
257
|
+
<itemref idref="ch03-html"/>
|
258
|
+
<itemref idref="ch04-html"/>
|
259
|
+
</spine>
|
260
|
+
<guide>
|
261
|
+
<reference type="cover" title="Cover" href="sample.html"/>
|
262
|
+
<reference type="toc" title="Table of Contents" href="sample-toc.html"/>
|
263
|
+
</guide>
|
264
|
+
</package>
|
265
|
+
EOT
|
266
|
+
assert_equal expect, @output.string
|
267
|
+
end
|
268
|
+
|
269
|
+
def test_stage3_ncx
|
270
|
+
stage3
|
271
|
+
@producer.ncx(@output)
|
272
|
+
expect = <<EOT
|
273
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
274
|
+
<!DOCTYPE html>
|
275
|
+
<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="en">
|
276
|
+
<head>
|
277
|
+
<meta charset="UTF-8" />
|
278
|
+
<meta name="generator" content="Re:VIEW" />
|
279
|
+
<title>Table of Contents</title>
|
280
|
+
</head>
|
281
|
+
<body>
|
282
|
+
<nav xmlns:epub="http://www.idpf.org/2007/ops" epub:type="toc" id="toc">
|
283
|
+
<h1 class="toc-title">Table of Contents</h1>
|
284
|
+
|
285
|
+
<ol class="toc-h1"><li><a href="ch01.html">CH01<>&"</a></li>
|
286
|
+
<li><a href="ch02.html">CH02</a>
|
287
|
+
<ol class="toc-h2"><li><a href="ch02.html#S1">CH02.1</a></li>
|
288
|
+
<li><a href="ch02.html#S2">CH02.2</a></li>
|
289
|
+
</ol></li>
|
290
|
+
<li><a href="ch03.html">CH03</a>
|
291
|
+
<ol class="toc-h2"><li><a href="ch03.html#S1">CH03.1</a></li>
|
292
|
+
</ol></li>
|
293
|
+
<li><a href="ch04.html">CH04</a></li>
|
294
|
+
</ol> </nav>
|
295
|
+
</body>
|
296
|
+
</html>
|
297
|
+
EOT
|
298
|
+
assert_equal expect, @output.string
|
299
|
+
end
|
300
|
+
|
301
|
+
def test_stage3_mytoc
|
302
|
+
stage3
|
303
|
+
@producer.mytoc(@output)
|
304
|
+
expect = <<EOT
|
305
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
306
|
+
<!DOCTYPE html>
|
307
|
+
<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="en">
|
308
|
+
<head>
|
309
|
+
<meta charset="UTF-8" />
|
310
|
+
<meta name="generator" content="Re:VIEW" />
|
311
|
+
<title>Table of Contents</title>
|
312
|
+
</head>
|
313
|
+
<body>
|
314
|
+
<h1 class="toc-title">Table of Contents</h1>
|
315
|
+
|
316
|
+
<ul class="toc-h1"><li><a href="ch01.html">CH01<>&"</a></li>
|
317
|
+
<li><a href="ch02.html">CH02</a>
|
318
|
+
<ul class="toc-h2"><li><a href="ch02.html#S1">CH02.1</a></li>
|
319
|
+
<li><a href="ch02.html#S2">CH02.2</a></li>
|
320
|
+
</ul></li>
|
321
|
+
<li><a href="ch03.html">CH03</a>
|
322
|
+
<ul class="toc-h2"><li><a href="ch03.html#S1">CH03.1</a></li>
|
323
|
+
</ul></li>
|
324
|
+
<li><a href="ch04.html">CH04</a></li>
|
325
|
+
</ul></body>
|
326
|
+
</html>
|
327
|
+
EOT
|
328
|
+
assert_equal expect, @output.string
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_stage3_flat
|
332
|
+
@producer.merge_params({"flattoc" => true, "flattocindent" => false})
|
333
|
+
stage3
|
334
|
+
@producer.mytoc(@output)
|
335
|
+
expect = <<EOT
|
336
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
337
|
+
<!DOCTYPE html>
|
338
|
+
<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="en">
|
339
|
+
<head>
|
340
|
+
<meta charset="UTF-8" />
|
341
|
+
<meta name="generator" content="Re:VIEW" />
|
342
|
+
<title>Table of Contents</title>
|
343
|
+
</head>
|
344
|
+
<body>
|
345
|
+
<h1 class="toc-title">Table of Contents</h1>
|
346
|
+
<ul class="toc-h1">
|
347
|
+
<li><a href="ch01.html">CH01<>&"</a></li>
|
348
|
+
<li><a href="ch02.html">CH02</a></li>
|
349
|
+
<li><a href="ch02.html#S1">CH02.1</a></li>
|
350
|
+
<li><a href="ch02.html#S2">CH02.2</a></li>
|
351
|
+
<li><a href="ch03.html">CH03</a></li>
|
352
|
+
<li><a href="ch03.html#S1">CH03.1</a></li>
|
353
|
+
<li><a href="ch04.html">CH04</a></li>
|
354
|
+
</ul>
|
355
|
+
</body>
|
356
|
+
</html>
|
357
|
+
EOT
|
358
|
+
assert_equal expect, @output.string
|
359
|
+
end
|
360
|
+
|
361
|
+
def test_stage3_cover
|
362
|
+
stage3
|
363
|
+
@producer.cover(@output)
|
364
|
+
expect = <<EOT
|
365
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
366
|
+
<!DOCTYPE html>
|
367
|
+
<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="en">
|
368
|
+
<head>
|
369
|
+
<meta charset="UTF-8" />
|
370
|
+
<meta name="generator" content="Re:VIEW" />
|
371
|
+
<title>Sample Book</title>
|
372
|
+
</head>
|
373
|
+
<body epub:type="cover">
|
374
|
+
<h1 class="cover-title">Sample Book</h1>
|
375
|
+
</body>
|
376
|
+
</html>
|
377
|
+
EOT
|
378
|
+
assert_equal expect, @output.string
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_stage3_cover_with_image
|
382
|
+
stage3
|
383
|
+
@producer.params["coverimage"] = "sample.png"
|
384
|
+
@producer.cover(@output)
|
385
|
+
expect = <<EOT
|
386
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
387
|
+
<!DOCTYPE html>
|
388
|
+
<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="en">
|
389
|
+
<head>
|
390
|
+
<meta charset="UTF-8" />
|
391
|
+
<meta name="generator" content="Re:VIEW" />
|
392
|
+
<title>Sample Book</title>
|
393
|
+
</head>
|
394
|
+
<body epub:type="cover">
|
395
|
+
<div id="cover-image" class="cover-image">
|
396
|
+
<img src="sample.png" alt="Sample Book" class="max"/>
|
397
|
+
</div>
|
398
|
+
</body>
|
399
|
+
</html>
|
400
|
+
EOT
|
401
|
+
assert_equal expect, @output.string
|
402
|
+
end
|
403
|
+
|
404
|
+
def test_colophon_default
|
405
|
+
@producer.params["aut"] = ["Mr.Smith"]
|
406
|
+
@producer.params["pbl"] = ["BLUEPRINT"]
|
407
|
+
@producer.colophon(@output)
|
408
|
+
expect = <<EOT
|
409
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
410
|
+
<!DOCTYPE html>
|
411
|
+
<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="en">
|
412
|
+
<head>
|
413
|
+
<meta charset="UTF-8" />
|
414
|
+
<meta name="generator" content="Re:VIEW" />
|
415
|
+
<title>Colophon</title>
|
416
|
+
</head>
|
417
|
+
<body>
|
418
|
+
<div class="colophon">
|
419
|
+
<p class="title">Sample Book</p>
|
420
|
+
<div class="pubhistory">
|
421
|
+
<p>published by Jan. 1, 2011</p>
|
422
|
+
</div>
|
423
|
+
<table class="colophon">
|
424
|
+
<tr><th>Author</th><td>Mr.Smith</td></tr>
|
425
|
+
<tr><th>Publisher</th><td>BLUEPRINT</td></tr>
|
426
|
+
</table>
|
427
|
+
</div>
|
428
|
+
</body>
|
429
|
+
</html>
|
430
|
+
EOT
|
431
|
+
assert_equal expect, @output.string
|
432
|
+
end
|
433
|
+
|
434
|
+
def test_colophon_pht
|
435
|
+
@producer.params["aut"] = ["Mr.Smith"]
|
436
|
+
@producer.params["pbl"] = ["BLUEPRINT"]
|
437
|
+
@producer.params["pht"] = ["Mrs.Smith"]
|
438
|
+
@producer.colophon(@output)
|
439
|
+
expect = <<EOT
|
440
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
441
|
+
<!DOCTYPE html>
|
442
|
+
<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="en">
|
443
|
+
<head>
|
444
|
+
<meta charset="UTF-8" />
|
445
|
+
<meta name="generator" content="Re:VIEW" />
|
446
|
+
<title>Colophon</title>
|
447
|
+
</head>
|
448
|
+
<body>
|
449
|
+
<div class="colophon">
|
450
|
+
<p class="title">Sample Book</p>
|
451
|
+
<div class="pubhistory">
|
452
|
+
<p>published by Jan. 1, 2011</p>
|
453
|
+
</div>
|
454
|
+
<table class="colophon">
|
455
|
+
<tr><th>Author</th><td>Mr.Smith</td></tr>
|
456
|
+
<tr><th>Publisher</th><td>BLUEPRINT</td></tr>
|
457
|
+
<tr><th>Director of Photography</th><td>Mrs.Smith</td></tr>
|
458
|
+
</table>
|
459
|
+
</div>
|
460
|
+
</body>
|
461
|
+
</html>
|
462
|
+
EOT
|
463
|
+
assert_equal expect, @output.string
|
464
|
+
end
|
465
|
+
|
466
|
+
# def test_duplicate_id
|
467
|
+
# stage3
|
468
|
+
# assert_raise(Error) do
|
469
|
+
# @producer.contents << Content.new({"file" => "ch02.html#S1", "title" => "CH02.1", "level" => 2})
|
470
|
+
# end
|
471
|
+
# end
|
472
|
+
|
473
|
+
def test_detect_mathml
|
474
|
+
Dir.mktmpdir do |dir|
|
475
|
+
epubmaker = ReVIEW::EPUBMaker.new
|
476
|
+
path = File.join(dir,"test.html")
|
477
|
+
html = <<EOT
|
478
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
479
|
+
<!DOCTYPE html>
|
480
|
+
<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="en">
|
481
|
+
<head>
|
482
|
+
<meta charset="UTF-8" />
|
483
|
+
<meta name="generator" content="Re:VIEW" />
|
484
|
+
<title>Colophon</title>
|
485
|
+
</head>
|
486
|
+
<body>
|
487
|
+
<div>
|
488
|
+
<p><span class=\"equation\"><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mfrac><mrow><mo stretchy='false'>-</mo><mi>b</mi><mo stretchy='false'>±</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo stretchy='false'>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></math></span></p>
|
489
|
+
</div>
|
490
|
+
</body>
|
491
|
+
</html>
|
492
|
+
EOT
|
493
|
+
File.open(path, "w") do |f|
|
494
|
+
f.write(html)
|
495
|
+
end
|
496
|
+
assert_equal ["mathml"], epubmaker.detect_properties(path)
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
|
501
|
+
def test_detect_mathml_ns
|
502
|
+
Dir.mktmpdir do |dir|
|
503
|
+
epubmaker = ReVIEW::EPUBMaker.new
|
504
|
+
path = File.join(dir,"test.html")
|
505
|
+
html = <<EOT
|
506
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
507
|
+
<!DOCTYPE html>
|
508
|
+
<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="en">
|
509
|
+
<head>
|
510
|
+
<meta charset="UTF-8" />
|
511
|
+
<meta name="generator" content="Re:VIEW" />
|
512
|
+
<title>Colophon</title>
|
513
|
+
</head>
|
514
|
+
<body>
|
515
|
+
<div>
|
516
|
+
<p><span class=\"equation\"><m:math xmlns:m='http://www.w3.org/1998/Math/MathML' display='inline'><m:mfrac><m:mrow><m:mo stretchy='false'>-</m:mo><m:mi>b</m:mi><m:mo stretchy='false'>±</m:mo><m:msqrt><m:mrow><m:msup><m:mi>b</m:mi><m:mn>2</m:mn></m:msup><m:mo stretchy='false'>-</m:mo><m:mn>4</m:mn><m:mi>a</m:mi><m:mi>c</m:mi></m:mrow></m:msqrt></m:mrow><m:mrow><m:mn>2</m:mn><m:mi>a</m:mi></m:mrow></m:mfrac></m:math></span></p>
|
517
|
+
</div>
|
518
|
+
</body>
|
519
|
+
</html>
|
520
|
+
EOT
|
521
|
+
File.open(path, "w") do |f|
|
522
|
+
f.write(html)
|
523
|
+
end
|
524
|
+
assert_equal ["mathml"], epubmaker.detect_properties(path)
|
525
|
+
end
|
526
|
+
end
|
527
|
+
end
|