review-peg 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +36 -0
  3. data/.rubocop.yml +47 -0
  4. data/.rubocop_todo.yml +605 -0
  5. data/.travis.yml +18 -0
  6. data/COPYING +515 -0
  7. data/ChangeLog +2449 -0
  8. data/Dockerfile +22 -0
  9. data/Gemfile +6 -0
  10. data/README.rdoc +81 -0
  11. data/Rakefile +51 -0
  12. data/bin/review-catalog-converter-peg +129 -0
  13. data/bin/review-check-peg +169 -0
  14. data/bin/review-checkdep-peg +63 -0
  15. data/bin/review-compile-peg +202 -0
  16. data/bin/review-epubmaker-legacy-peg +1024 -0
  17. data/bin/review-epubmaker-peg +44 -0
  18. data/bin/review-index-peg +110 -0
  19. data/bin/review-init-peg +151 -0
  20. data/bin/review-pdfmaker-peg +18 -0
  21. data/bin/review-preproc-peg +131 -0
  22. data/bin/review-validate-peg +51 -0
  23. data/bin/review-vol-peg +100 -0
  24. data/debian/README.Debian +12 -0
  25. data/debian/README.source +5 -0
  26. data/debian/changelog +5 -0
  27. data/debian/compat +1 -0
  28. data/debian/control +22 -0
  29. data/debian/copyright +62 -0
  30. data/debian/docs +6 -0
  31. data/debian/manpage.1.ex +59 -0
  32. data/debian/patches/path.diff +91 -0
  33. data/debian/patches/series +1 -0
  34. data/debian/review.install +13 -0
  35. data/debian/review.links +4 -0
  36. data/debian/rules +13 -0
  37. data/debian/source/format +1 -0
  38. data/doc/NEWS.ja.md +350 -0
  39. data/doc/NEWS.md +354 -0
  40. data/doc/catalog.ja.md +53 -0
  41. data/doc/catalog.md +52 -0
  42. data/doc/format.ja.md +734 -0
  43. data/doc/format.md +746 -0
  44. data/doc/format_idg.ja.md +203 -0
  45. data/doc/quickstart.ja.md +222 -0
  46. data/doc/quickstart.md +252 -0
  47. data/doc/ruby-uuid/README +11 -0
  48. data/doc/ruby-uuid/README.ja +34 -0
  49. data/doc/sample.css +108 -0
  50. data/doc/sample.yml +238 -0
  51. data/lib/epubmaker.rb +24 -0
  52. data/lib/epubmaker/content.rb +93 -0
  53. data/lib/epubmaker/epubcommon.rb +424 -0
  54. data/lib/epubmaker/epubv2.rb +139 -0
  55. data/lib/epubmaker/epubv3.rb +222 -0
  56. data/lib/epubmaker/producer.rb +330 -0
  57. data/lib/lineinput.rb +107 -0
  58. data/lib/review.rb +3 -0
  59. data/lib/review/book.rb +43 -0
  60. data/lib/review/book/base.rb +401 -0
  61. data/lib/review/book/chapter.rb +100 -0
  62. data/lib/review/book/compilable.rb +184 -0
  63. data/lib/review/book/image_finder.rb +71 -0
  64. data/lib/review/book/index.rb +413 -0
  65. data/lib/review/book/page_metric.rb +47 -0
  66. data/lib/review/book/part.rb +54 -0
  67. data/lib/review/book/volume.rb +67 -0
  68. data/lib/review/builder.rb +452 -0
  69. data/lib/review/catalog.rb +52 -0
  70. data/lib/review/compiler.rb +5183 -0
  71. data/lib/review/compiler/literals_1_9.kpeg +22 -0
  72. data/lib/review/compiler/literals_1_9.rb +435 -0
  73. data/lib/review/configure.rb +64 -0
  74. data/lib/review/epubbuilder.rb +18 -0
  75. data/lib/review/epubmaker.rb +480 -0
  76. data/lib/review/ewbbuilder.rb +381 -0
  77. data/lib/review/exception.rb +21 -0
  78. data/lib/review/extentions.rb +4 -0
  79. data/lib/review/extentions/array.rb +25 -0
  80. data/lib/review/extentions/object.rb +9 -0
  81. data/lib/review/extentions/string.rb +33 -0
  82. data/lib/review/htmlbuilder.rb +1166 -0
  83. data/lib/review/htmllayout.rb +41 -0
  84. data/lib/review/htmltoc.rb +45 -0
  85. data/lib/review/htmlutils.rb +90 -0
  86. data/lib/review/i18n.rb +96 -0
  87. data/lib/review/i18n.yml +169 -0
  88. data/lib/review/idgxmlbuilder.rb +1233 -0
  89. data/lib/review/inaobuilder.rb +357 -0
  90. data/lib/review/latexbuilder.rb +941 -0
  91. data/lib/review/latexindex.rb +35 -0
  92. data/lib/review/latexutils.rb +95 -0
  93. data/lib/review/layout.tex.erb +340 -0
  94. data/lib/review/lineinput.rb +17 -0
  95. data/lib/review/location.rb +24 -0
  96. data/lib/review/makerhelper.rb +67 -0
  97. data/lib/review/markdownbuilder.rb +339 -0
  98. data/lib/review/node.rb +288 -0
  99. data/lib/review/pdfmaker.rb +332 -0
  100. data/lib/review/preprocessor.rb +530 -0
  101. data/lib/review/review.kpeg +745 -0
  102. data/lib/review/sec_counter.rb +69 -0
  103. data/lib/review/template.rb +21 -0
  104. data/lib/review/textbuilder.rb +17 -0
  105. data/lib/review/textutils.rb +16 -0
  106. data/lib/review/tocparser.rb +348 -0
  107. data/lib/review/tocprinter.rb +205 -0
  108. data/lib/review/topbuilder.rb +796 -0
  109. data/lib/review/unfold.rb +138 -0
  110. data/lib/review/version.rb +3 -0
  111. data/lib/uuid.rb +312 -0
  112. data/review.gemspec +32 -0
  113. data/templates/html/layout-html5.html.erb +17 -0
  114. data/templates/html/layout-xhtml1.html.erb +20 -0
  115. data/templates/ncx/epubv2.ncx.erb +11 -0
  116. data/templates/opf/epubv2.opf.erb +21 -0
  117. data/templates/opf/epubv3.opf.erb +18 -0
  118. data/templates/xml/container.xml.erb +6 -0
  119. data/test/CHAPS +2 -0
  120. data/test/assets/test.xml.erb +3 -0
  121. data/test/assets/test_template.tex +255 -0
  122. data/test/assets/test_template_backmatter.tex +32 -0
  123. data/test/bib.re +13 -0
  124. data/test/book_test_helper.rb +35 -0
  125. data/test/sample-book/README.md +7 -0
  126. data/test/sample-book/src/Rakefile +58 -0
  127. data/test/sample-book/src/_cover.html +3 -0
  128. data/test/sample-book/src/catalog.yml +10 -0
  129. data/test/sample-book/src/ch01.re +71 -0
  130. data/test/sample-book/src/ch02.re +3 -0
  131. data/test/sample-book/src/config.yml +186 -0
  132. data/test/sample-book/src/images/ch01-imgsample.jpg +0 -0
  133. data/test/sample-book/src/images/cover.jpg +0 -0
  134. data/test/sample-book/src/preface.re +15 -0
  135. data/test/sample-book/src/sty/jumoline.sty +310 -0
  136. data/test/sample-book/src/sty/reviewmacro.sty +39 -0
  137. data/test/sample-book/src/style.css +251 -0
  138. data/test/sample-book/src/vendor/jumoline/README +29 -0
  139. data/test/sample-book/src/vendor/jumoline/jumoline.dtx +2988 -0
  140. data/test/sample-book/src/vendor/jumoline/jumoline.ins +6 -0
  141. data/test/test.re +43 -0
  142. data/test/test_book.rb +556 -0
  143. data/test/test_book_chapter.rb +280 -0
  144. data/test/test_book_part.rb +54 -0
  145. data/test/test_builder.rb +80 -0
  146. data/test/test_catalog.rb +119 -0
  147. data/test/test_catalog_converter_cmd.rb +73 -0
  148. data/test/test_compiler.rb +92 -0
  149. data/test/test_configure.rb +50 -0
  150. data/test/test_epub3maker.rb +529 -0
  151. data/test/test_epubmaker.rb +569 -0
  152. data/test/test_epubmaker_cmd.rb +40 -0
  153. data/test/test_helper.rb +92 -0
  154. data/test/test_htmlbuilder.rb +1114 -0
  155. data/test/test_htmltoc.rb +32 -0
  156. data/test/test_htmlutils.rb +50 -0
  157. data/test/test_i18n.rb +180 -0
  158. data/test/test_idgxmlbuilder.rb +608 -0
  159. data/test/test_image_finder.rb +82 -0
  160. data/test/test_inaobuilder.rb +245 -0
  161. data/test/test_index.rb +174 -0
  162. data/test/test_latexbuilder.rb +732 -0
  163. data/test/test_lineinput.rb +182 -0
  164. data/test/test_makerhelper.rb +66 -0
  165. data/test/test_markdownbuilder.rb +125 -0
  166. data/test/test_pdfmaker.rb +171 -0
  167. data/test/test_pdfmaker_cmd.rb +40 -0
  168. data/test/test_preprocessor.rb +23 -0
  169. data/test/test_review_ext.rb +31 -0
  170. data/test/test_template.rb +26 -0
  171. data/test/test_textutils.rb +32 -0
  172. data/test/test_topbuilder.rb +291 -0
  173. data/test/test_uuid.rb +157 -0
  174. metadata +357 -0
@@ -0,0 +1,569 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test_helper'
4
+ require 'epubmaker'
5
+
6
+ class EPUBMakerTest < Test::Unit::TestCase
7
+ include EPUBMaker
8
+
9
+ def setup
10
+ @producer = Producer.new
11
+ @producer.merge_params({
12
+ "bookname" => "sample",
13
+ "title" => "Sample Book",
14
+ "epubversion" => 2,
15
+ "urnid" => "http://example.jp/",
16
+ "date" => "2011-01-01",
17
+ "language" => "en",
18
+ })
19
+ @output = StringIO.new
20
+ end
21
+
22
+ def test_initialize
23
+ assert Producer.new
24
+ end
25
+
26
+ def test_resource_en
27
+ @producer.merge_params({"language" => "en"})
28
+ assert_equal "Table of Contents", @producer.res.v("toctitle")
29
+ end
30
+
31
+ def test_resource_ja
32
+ @producer.merge_params({"language" => "ja"})
33
+ assert_equal "目次", @producer.res.v("toctitle")
34
+ end
35
+
36
+ def test_mimetype
37
+ @producer.mimetype(@output)
38
+ assert_equal %Q[application/epub+zip], @output.string
39
+ end
40
+
41
+ def test_container
42
+ @producer.container(@output)
43
+ expect = <<EOT
44
+ <?xml version="1.0" encoding="UTF-8"?>
45
+ <container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
46
+ <rootfiles>
47
+ <rootfile full-path="OEBPS/sample.opf" media-type="application/oebps-package+xml" />
48
+ </rootfiles>
49
+ </container>
50
+ EOT
51
+ assert_equal expect, @output.string
52
+ end
53
+
54
+ def test_stage1_opf
55
+ @producer.opf(@output)
56
+ expect = <<EOT
57
+ <?xml version="1.0" encoding="UTF-8"?>
58
+ <package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
59
+ <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
60
+ <dc:title>Sample Book</dc:title>
61
+ <dc:language>en</dc:language>
62
+ <dc:date>2011-01-01</dc:date>
63
+ <dc:identifier id="BookId">http://example.jp/</dc:identifier>
64
+ </metadata>
65
+ <manifest>
66
+ <item id="ncx" href="sample.ncx" media-type="application/x-dtbncx+xml"/>
67
+ <item id="sample" href="sample.html" media-type="application/xhtml+xml"/>
68
+ </manifest>
69
+ <spine toc="ncx">
70
+ <itemref idref="sample" linear="no"/>
71
+ </spine>
72
+ <guide>
73
+ <reference type="cover" title="Cover" href="sample.html"/>
74
+ </guide>
75
+ </package>
76
+ EOT
77
+ assert_equal expect, @output.string
78
+ end
79
+
80
+ def test_stage1_ncx
81
+ @producer.ncx(@output)
82
+ expect = <<EOT
83
+ <?xml version="1.0" encoding="UTF-8"?>
84
+ <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
85
+ <head>
86
+ <meta name="dtb:depth" content="1"/>
87
+ <meta name="dtb:totalPageCount" content="0"/>
88
+ <meta name="dtb:maxPageNumber" content="0"/>
89
+ <meta name="dtb:uid" content="http://example.jp/"/>
90
+ </head>
91
+ <docTitle>
92
+ <text>Sample Book</text>
93
+ </docTitle>
94
+ <docAuthor>
95
+ <text></text>
96
+ </docAuthor>
97
+ <navMap>
98
+ <navPoint id="top" playOrder="1">
99
+ <navLabel>
100
+ <text>Sample Book</text>
101
+ </navLabel>
102
+ <content src="sample.html"/>
103
+ </navPoint>
104
+ </navMap>
105
+ </ncx>
106
+ EOT
107
+ assert_equal expect, @output.string
108
+ end
109
+
110
+ def stage2
111
+ # add one item
112
+ @producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01", "level" => 1})
113
+ end
114
+
115
+ def test_stage2_add_l1item
116
+ stage2
117
+ expect = EPUBMaker::Content.new("ch01.html",
118
+ "ch01-html",
119
+ "application/xhtml+xml",
120
+ "CH01",
121
+ 1)
122
+ assert_equal expect, @producer.contents[0]
123
+ end
124
+
125
+ def test_stage2_opf
126
+ stage2
127
+ @producer.opf(@output)
128
+ expect = <<EOT
129
+ <?xml version="1.0" encoding="UTF-8"?>
130
+ <package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
131
+ <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
132
+ <dc:title>Sample Book</dc:title>
133
+ <dc:language>en</dc:language>
134
+ <dc:date>2011-01-01</dc:date>
135
+ <dc:identifier id="BookId">http://example.jp/</dc:identifier>
136
+ </metadata>
137
+ <manifest>
138
+ <item id="ncx" href="sample.ncx" media-type="application/x-dtbncx+xml"/>
139
+ <item id="sample" href="sample.html" media-type="application/xhtml+xml"/>
140
+ <item id="ch01-html" href="ch01.html" media-type="application/xhtml+xml"/>
141
+ </manifest>
142
+ <spine toc="ncx">
143
+ <itemref idref="sample" linear="no"/>
144
+ <itemref idref="ch01-html"/>
145
+ </spine>
146
+ <guide>
147
+ <reference type="cover" title="Cover" href="sample.html"/>
148
+ </guide>
149
+ </package>
150
+ EOT
151
+ assert_equal expect, @output.string
152
+ end
153
+
154
+ def test_stage2_ncx
155
+ stage2
156
+ @producer.ncx(@output)
157
+ expect = <<EOT
158
+ <?xml version="1.0" encoding="UTF-8"?>
159
+ <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
160
+ <head>
161
+ <meta name="dtb:depth" content="1"/>
162
+ <meta name="dtb:totalPageCount" content="0"/>
163
+ <meta name="dtb:maxPageNumber" content="0"/>
164
+ <meta name="dtb:uid" content="http://example.jp/"/>
165
+ </head>
166
+ <docTitle>
167
+ <text>Sample Book</text>
168
+ </docTitle>
169
+ <docAuthor>
170
+ <text></text>
171
+ </docAuthor>
172
+ <navMap>
173
+ <navPoint id="top" playOrder="1">
174
+ <navLabel>
175
+ <text>Sample Book</text>
176
+ </navLabel>
177
+ <content src="sample.html"/>
178
+ </navPoint>
179
+ <navPoint id="nav-2" playOrder="2">
180
+ <navLabel>
181
+ <text>CH01</text>
182
+ </navLabel>
183
+ <content src="ch01.html"/>
184
+ </navPoint>
185
+ </navMap>
186
+ </ncx>
187
+ EOT
188
+ assert_equal expect, @output.string
189
+ end
190
+
191
+ def stage3
192
+ # add more items
193
+ @producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01<>&\"", "level" => 1})
194
+ @producer.contents << Content.new({"file" => "ch02.html", "title" => "CH02", "level" => 1})
195
+ @producer.contents << Content.new({"file" => "ch02.html#S1", "title" => "CH02.1", "level" => 2})
196
+ @producer.contents << Content.new({"file" => "ch02.html#S1.1", "title" => "CH02.1.1", "level" => 3})
197
+ @producer.contents << Content.new({"file" => "ch02.html#S1.1.1", "title" => "CH02.1.1.1", "level" => 4})
198
+ @producer.contents << Content.new({"file" => "ch02.html#S1.1.1.1", "title" => "CH02.1.1.1.1", "level" => 5})
199
+ @producer.contents << Content.new({"file" => "ch02.html#S1.1.2", "title" => "CH02.1.1.2", "level" => 4})
200
+ @producer.contents << Content.new({"file" => "ch02.html#S2", "title" => "CH02.2", "level" => 2})
201
+ @producer.contents << Content.new({"file" => "ch02.html#S2.1", "title" => "CH02.2.1", "level" => 3})
202
+ @producer.contents << Content.new({"file" => "ch03.html", "title" => "CH03", "level" => 1})
203
+ @producer.contents << Content.new({"file" => "ch03.html#S1", "title" => "CH03.1", "level" => 2})
204
+ @producer.contents << Content.new({"file" => "ch03.html#S1.1", "title" => "CH03.1.1", "level" => 3})
205
+ @producer.contents << Content.new({"file" => "ch04.html", "title" => "CH04", "level" => 1})
206
+ @producer.contents << Content.new({"file" => "sample.png"})
207
+ @producer.contents << Content.new({"file" => "sample.jpg"})
208
+ @producer.contents << Content.new({"file" => "sample.JPEG"})
209
+ @producer.contents << Content.new({"file" => "sample.SvG"})
210
+ @producer.contents << Content.new({"file" => "sample.GIF"})
211
+ @producer.contents << Content.new({"file" => "sample.css"})
212
+ end
213
+
214
+ def test_stage3_add_various_items
215
+ stage3
216
+ expect = [
217
+ Content.new("ch01.html", "ch01-html", "application/xhtml+xml", "CH01<>&\"", 1),
218
+ Content.new("ch02.html", "ch02-html", "application/xhtml+xml", "CH02", 1),
219
+ Content.new("ch02.html#S1", "ch02-html#S1","html#s1","CH02.1", 2),
220
+ Content.new("ch02.html#S1.1", "ch02-html#S1-1", "1", "CH02.1.1", 3),
221
+ Content.new("ch02.html#S1.1.1", "ch02-html#S1-1-1","1", "CH02.1.1.1", 4),
222
+ Content.new("ch02.html#S1.1.1.1", "ch02-html#S1-1-1-1", "1","CH02.1.1.1.1", 5),
223
+ Content.new("ch02.html#S1.1.2", "ch02-html#S1-1-2", "2", "CH02.1.1.2", 4),
224
+ Content.new("ch02.html#S2", "ch02-html#S2", "html#s2", "CH02.2", 2),
225
+ Content.new("ch02.html#S2.1", "ch02-html#S2-1", "1", "CH02.2.1", 3),
226
+ Content.new("ch03.html", "ch03-html", "application/xhtml+xml", "CH03", 1),
227
+ Content.new("ch03.html#S1", "ch03-html#S1", "html#s1", "CH03.1", 2),
228
+ Content.new("ch03.html#S1.1", "ch03-html#S1-1", "1", "CH03.1.1", 3),
229
+ Content.new("ch04.html", "ch04-html", "application/xhtml+xml", "CH04", 1),
230
+ Content.new("sample.png", "sample-png", "image/png"),
231
+ Content.new("sample.jpg", "sample-jpg", "image/jpeg"),
232
+ Content.new("sample.JPEG", "sample-JPEG", "image/jpeg"),
233
+ Content.new("sample.SvG", "sample-SvG", "image/svg+xml"),
234
+ Content.new("sample.GIF", "sample-GIF", "image/gif"),
235
+ Content.new("sample.css", "sample-css", "text/css")
236
+ ]
237
+
238
+ assert_equal expect, @producer.contents
239
+ end
240
+
241
+ def test_stage3_opf
242
+ stage3
243
+ @producer.opf(@output)
244
+ expect = <<EOT
245
+ <?xml version="1.0" encoding="UTF-8"?>
246
+ <package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
247
+ <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
248
+ <dc:title>Sample Book</dc:title>
249
+ <dc:language>en</dc:language>
250
+ <dc:date>2011-01-01</dc:date>
251
+ <dc:identifier id="BookId">http://example.jp/</dc:identifier>
252
+ </metadata>
253
+ <manifest>
254
+ <item id="ncx" href="sample.ncx" media-type="application/x-dtbncx+xml"/>
255
+ <item id="sample" href="sample.html" media-type="application/xhtml+xml"/>
256
+ <item id="ch01-html" href="ch01.html" media-type="application/xhtml+xml"/>
257
+ <item id="ch02-html" href="ch02.html" media-type="application/xhtml+xml"/>
258
+ <item id="ch03-html" href="ch03.html" media-type="application/xhtml+xml"/>
259
+ <item id="ch04-html" href="ch04.html" media-type="application/xhtml+xml"/>
260
+ <item id="sample-png" href="sample.png" media-type="image/png"/>
261
+ <item id="sample-jpg" href="sample.jpg" media-type="image/jpeg"/>
262
+ <item id="sample-JPEG" href="sample.JPEG" media-type="image/jpeg"/>
263
+ <item id="sample-SvG" href="sample.SvG" media-type="image/svg+xml"/>
264
+ <item id="sample-GIF" href="sample.GIF" media-type="image/gif"/>
265
+ <item id="sample-css" href="sample.css" media-type="text/css"/>
266
+ </manifest>
267
+ <spine toc="ncx">
268
+ <itemref idref="sample" linear="no"/>
269
+ <itemref idref="ch01-html"/>
270
+ <itemref idref="ch02-html"/>
271
+ <itemref idref="ch03-html"/>
272
+ <itemref idref="ch04-html"/>
273
+ </spine>
274
+ <guide>
275
+ <reference type="cover" title="Cover" href="sample.html"/>
276
+ </guide>
277
+ </package>
278
+ EOT
279
+ assert_equal expect, @output.string
280
+ end
281
+
282
+ def test_stage3_ncx
283
+ stage3
284
+ @producer.ncx(@output)
285
+ expect = <<EOT
286
+ <?xml version="1.0" encoding="UTF-8"?>
287
+ <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
288
+ <head>
289
+ <meta name="dtb:depth" content="1"/>
290
+ <meta name="dtb:totalPageCount" content="0"/>
291
+ <meta name="dtb:maxPageNumber" content="0"/>
292
+ <meta name="dtb:uid" content="http://example.jp/"/>
293
+ </head>
294
+ <docTitle>
295
+ <text>Sample Book</text>
296
+ </docTitle>
297
+ <docAuthor>
298
+ <text></text>
299
+ </docAuthor>
300
+ <navMap>
301
+ <navPoint id="top" playOrder="1">
302
+ <navLabel>
303
+ <text>Sample Book</text>
304
+ </navLabel>
305
+ <content src="sample.html"/>
306
+ </navPoint>
307
+ <navPoint id="nav-2" playOrder="2">
308
+ <navLabel>
309
+ <text>CH01&lt;&gt;&amp;&quot;</text>
310
+ </navLabel>
311
+ <content src="ch01.html"/>
312
+ </navPoint>
313
+ <navPoint id="nav-3" playOrder="3">
314
+ <navLabel>
315
+ <text>CH02</text>
316
+ </navLabel>
317
+ <content src="ch02.html"/>
318
+ </navPoint>
319
+ <navPoint id="nav-4" playOrder="4">
320
+ <navLabel>
321
+ <text>CH02.1</text>
322
+ </navLabel>
323
+ <content src="ch02.html#S1"/>
324
+ </navPoint>
325
+ <navPoint id="nav-5" playOrder="5">
326
+ <navLabel>
327
+ <text>CH02.1.1</text>
328
+ </navLabel>
329
+ <content src="ch02.html#S1.1"/>
330
+ </navPoint>
331
+ <navPoint id="nav-6" playOrder="6">
332
+ <navLabel>
333
+ <text>CH02.1.1.1</text>
334
+ </navLabel>
335
+ <content src="ch02.html#S1.1.1"/>
336
+ </navPoint>
337
+ <navPoint id="nav-7" playOrder="7">
338
+ <navLabel>
339
+ <text>CH02.1.1.1.1</text>
340
+ </navLabel>
341
+ <content src="ch02.html#S1.1.1.1"/>
342
+ </navPoint>
343
+ <navPoint id="nav-8" playOrder="8">
344
+ <navLabel>
345
+ <text>CH02.1.1.2</text>
346
+ </navLabel>
347
+ <content src="ch02.html#S1.1.2"/>
348
+ </navPoint>
349
+ <navPoint id="nav-9" playOrder="9">
350
+ <navLabel>
351
+ <text>CH02.2</text>
352
+ </navLabel>
353
+ <content src="ch02.html#S2"/>
354
+ </navPoint>
355
+ <navPoint id="nav-10" playOrder="10">
356
+ <navLabel>
357
+ <text>CH02.2.1</text>
358
+ </navLabel>
359
+ <content src="ch02.html#S2.1"/>
360
+ </navPoint>
361
+ <navPoint id="nav-11" playOrder="11">
362
+ <navLabel>
363
+ <text>CH03</text>
364
+ </navLabel>
365
+ <content src="ch03.html"/>
366
+ </navPoint>
367
+ <navPoint id="nav-12" playOrder="12">
368
+ <navLabel>
369
+ <text>CH03.1</text>
370
+ </navLabel>
371
+ <content src="ch03.html#S1"/>
372
+ </navPoint>
373
+ <navPoint id="nav-13" playOrder="13">
374
+ <navLabel>
375
+ <text>CH03.1.1</text>
376
+ </navLabel>
377
+ <content src="ch03.html#S1.1"/>
378
+ </navPoint>
379
+ <navPoint id="nav-14" playOrder="14">
380
+ <navLabel>
381
+ <text>CH04</text>
382
+ </navLabel>
383
+ <content src="ch04.html"/>
384
+ </navPoint>
385
+ </navMap>
386
+ </ncx>
387
+ EOT
388
+ assert_equal expect, @output.string
389
+ end
390
+
391
+ def test_stage3_mytoc
392
+ stage3
393
+ @producer.mytoc(@output)
394
+ expect = <<EOT
395
+ <?xml version="1.0" encoding="UTF-8"?>
396
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
397
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
398
+ <head>
399
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
400
+ <meta http-equiv="Content-Style-Type" content="text/css"/>
401
+ <meta name="generator" content="Re:VIEW"/>
402
+ <title>Table of Contents</title>
403
+ </head>
404
+ <body>
405
+ <h1 class="toc-title">Table of Contents</h1>
406
+
407
+ <ul class="toc-h1"><li><a href="ch01.html">CH01&lt;&gt;&amp;&quot;</a></li>
408
+ <li><a href="ch02.html">CH02</a>
409
+ <ul class="toc-h2"><li><a href="ch02.html#S1">CH02.1</a></li>
410
+ <li><a href="ch02.html#S2">CH02.2</a></li>
411
+ </ul></li>
412
+ <li><a href="ch03.html">CH03</a>
413
+ <ul class="toc-h2"><li><a href="ch03.html#S1">CH03.1</a></li>
414
+ </ul></li>
415
+ <li><a href="ch04.html">CH04</a></li>
416
+ </ul></body>
417
+ </html>
418
+ EOT
419
+ assert_equal expect, @output.string
420
+ end
421
+
422
+ def test_stage3_flat
423
+ @producer.merge_params({"epubmaker" => {"flattoc" => true, "flattocindent" => false}})
424
+ stage3
425
+ @producer.mytoc(@output)
426
+ expect = <<EOT
427
+ <?xml version="1.0" encoding="UTF-8"?>
428
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
429
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
430
+ <head>
431
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
432
+ <meta http-equiv="Content-Style-Type" content="text/css"/>
433
+ <meta name="generator" content="Re:VIEW"/>
434
+ <title>Table of Contents</title>
435
+ </head>
436
+ <body>
437
+ <h1 class="toc-title">Table of Contents</h1>
438
+ <ul class="toc-h1">
439
+ <li><a href="ch01.html">CH01&lt;&gt;&amp;&quot;</a></li>
440
+ <li><a href="ch02.html">CH02</a></li>
441
+ <li><a href="ch02.html#S1">CH02.1</a></li>
442
+ <li><a href="ch02.html#S2">CH02.2</a></li>
443
+ <li><a href="ch03.html">CH03</a></li>
444
+ <li><a href="ch03.html#S1">CH03.1</a></li>
445
+ <li><a href="ch04.html">CH04</a></li>
446
+ </ul>
447
+ </body>
448
+ </html>
449
+ EOT
450
+ assert_equal expect, @output.string
451
+ end
452
+
453
+ def test_stage3_cover
454
+ stage3
455
+ @producer.cover(@output)
456
+ expect = <<EOT
457
+ <?xml version="1.0" encoding="UTF-8"?>
458
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
459
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
460
+ <head>
461
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
462
+ <meta http-equiv="Content-Style-Type" content="text/css"/>
463
+ <meta name="generator" content="Re:VIEW"/>
464
+ <title>Sample Book</title>
465
+ </head>
466
+ <body>
467
+ <h1 class="cover-title">Sample Book</h1>
468
+ </body>
469
+ </html>
470
+ EOT
471
+ assert_equal expect, @output.string
472
+ end
473
+
474
+ def test_stage3_cover_with_image
475
+ stage3
476
+ @producer.params["coverimage"] = "sample.png"
477
+ @producer.cover(@output)
478
+ expect = <<EOT
479
+ <?xml version="1.0" encoding="UTF-8"?>
480
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
481
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
482
+ <head>
483
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
484
+ <meta http-equiv="Content-Style-Type" content="text/css"/>
485
+ <meta name="generator" content="Re:VIEW"/>
486
+ <title>Sample Book</title>
487
+ </head>
488
+ <body>
489
+ <div id="cover-image" class="cover-image">
490
+ <img src="sample.png" alt="Sample Book" class="max"/>
491
+ </div>
492
+ </body>
493
+ </html>
494
+ EOT
495
+ assert_equal expect, @output.string
496
+ end
497
+
498
+ def test_colophon_default
499
+ @producer.params["aut"] = ["Mr.Smith"]
500
+ @producer.params["pbl"] = ["BLUEPRINT"]
501
+ @producer.colophon(@output)
502
+ expect = <<EOT
503
+ <?xml version="1.0" encoding="UTF-8"?>
504
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
505
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
506
+ <head>
507
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
508
+ <meta http-equiv="Content-Style-Type" content="text/css"/>
509
+ <meta name="generator" content="Re:VIEW"/>
510
+ <title>Colophon</title>
511
+ </head>
512
+ <body>
513
+ <div class="colophon">
514
+ <p class="title">Sample Book</p>
515
+ <div class="pubhistory">
516
+ <p>published by Jan. 1, 2011</p>
517
+ </div>
518
+ <table class="colophon">
519
+ <tr><th>Author</th><td>Mr.Smith</td></tr>
520
+ <tr><th>Publisher</th><td>BLUEPRINT</td></tr>
521
+ </table>
522
+ </div>
523
+ </body>
524
+ </html>
525
+ EOT
526
+ assert_equal expect, @output.string
527
+ end
528
+
529
+ def test_colophon_pht
530
+ @producer.params["aut"] = ["Mr.Smith"]
531
+ @producer.params["pbl"] = ["BLUEPRINT"]
532
+ @producer.params["pht"] = ["Mrs.Smith"]
533
+ @producer.colophon(@output)
534
+ expect = <<EOT
535
+ <?xml version="1.0" encoding="UTF-8"?>
536
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
537
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en">
538
+ <head>
539
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
540
+ <meta http-equiv="Content-Style-Type" content="text/css"/>
541
+ <meta name="generator" content="Re:VIEW"/>
542
+ <title>Colophon</title>
543
+ </head>
544
+ <body>
545
+ <div class="colophon">
546
+ <p class="title">Sample Book</p>
547
+ <div class="pubhistory">
548
+ <p>published by Jan. 1, 2011</p>
549
+ </div>
550
+ <table class="colophon">
551
+ <tr><th>Author</th><td>Mr.Smith</td></tr>
552
+ <tr><th>Publisher</th><td>BLUEPRINT</td></tr>
553
+ <tr><th>Director of Photography</th><td>Mrs.Smith</td></tr>
554
+ </table>
555
+ </div>
556
+ </body>
557
+ </html>
558
+ EOT
559
+ assert_equal expect, @output.string
560
+ end
561
+
562
+ # def test_duplicate_id
563
+ # stage3
564
+ # assert_raise(Error) do
565
+ # @producer.contents << Content.new({"file" => "ch02.html#S1", "title" => "CH02.1", "level" => 2})
566
+ # end
567
+ # end
568
+
569
+ end