review 5.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-tex.yml +31 -0
  3. data/.github/workflows/ruby-win.yml +3 -3
  4. data/.github/workflows/ruby.yml +1 -1
  5. data/.rubocop.yml +15 -7
  6. data/NEWS.ja.md +108 -0
  7. data/NEWS.md +108 -0
  8. data/README.md +7 -6
  9. data/Rakefile +7 -2
  10. data/bin/review +2 -4
  11. data/bin/review-catalog-converter +3 -3
  12. data/bin/review-check +6 -8
  13. data/bin/review-checkdep +1 -4
  14. data/bin/review-compile +2 -5
  15. data/bin/review-epub2html +1 -4
  16. data/bin/review-epubmaker +3 -4
  17. data/bin/review-idgxmlmaker +1 -3
  18. data/bin/review-index +11 -5
  19. data/bin/review-init +1 -4
  20. data/bin/review-pdfmaker +1 -3
  21. data/bin/review-preproc +2 -4
  22. data/bin/review-textmaker +1 -3
  23. data/bin/review-update +1 -4
  24. data/bin/review-validate +3 -3
  25. data/bin/review-vol +1 -4
  26. data/bin/review-webmaker +1 -3
  27. data/doc/config.yml.sample +21 -5
  28. data/doc/config.yml.sample-simple +1 -1
  29. data/doc/format.ja.md +21 -10
  30. data/doc/format.md +21 -10
  31. data/doc/quickstart.ja.md +11 -1
  32. data/doc/quickstart.md +11 -2
  33. data/lib/review.rb +1 -1
  34. data/lib/review/book/base.rb +4 -0
  35. data/lib/review/book/book_unit.rb +3 -0
  36. data/lib/review/book/chapter.rb +3 -0
  37. data/lib/review/book/index.rb +1 -0
  38. data/lib/review/book/volume.rb +1 -0
  39. data/lib/review/builder.rb +8 -1
  40. data/lib/review/call_hook.rb +20 -0
  41. data/lib/review/catalog.rb +1 -0
  42. data/lib/review/compiler.rb +27 -10
  43. data/lib/review/configure.rb +64 -7
  44. data/lib/review/epubmaker.rb +93 -96
  45. data/lib/review/epubmaker/content.rb +113 -0
  46. data/lib/review/epubmaker/epubcommon.rb +372 -0
  47. data/lib/review/epubmaker/epubv2.rb +178 -0
  48. data/lib/review/epubmaker/epubv3.rb +231 -0
  49. data/lib/review/epubmaker/producer.rb +168 -0
  50. data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
  51. data/lib/review/epubmaker/zip_exporter.rb +84 -0
  52. data/lib/review/exception.rb +6 -0
  53. data/lib/review/htmlbuilder.rb +36 -49
  54. data/lib/review/htmlutils.rb +1 -1
  55. data/lib/review/i18n.rb +1 -0
  56. data/lib/review/idgxmlbuilder.rb +33 -30
  57. data/lib/review/idgxmlmaker.rb +3 -1
  58. data/lib/review/img_math.rb +245 -0
  59. data/lib/review/index_builder.rb +1 -0
  60. data/lib/review/init.rb +4 -4
  61. data/lib/review/latexbox.rb +58 -0
  62. data/lib/review/latexbuilder.rb +30 -19
  63. data/lib/review/latexutils.rb +9 -1
  64. data/lib/review/lineinput.rb +112 -2
  65. data/lib/review/logger.rb +41 -2
  66. data/lib/review/makerhelper.rb +2 -205
  67. data/lib/review/markdownbuilder.rb +32 -1
  68. data/lib/review/pdfmaker.rb +31 -29
  69. data/lib/review/plaintextbuilder.rb +9 -1
  70. data/lib/review/preprocessor.rb +12 -6
  71. data/lib/review/rstbuilder.rb +1 -1
  72. data/lib/review/sec_counter.rb +1 -0
  73. data/lib/review/template.rb +6 -0
  74. data/lib/review/textmaker.rb +11 -7
  75. data/lib/review/textutils.rb +2 -10
  76. data/lib/review/tocprinter.rb +85 -68
  77. data/lib/review/topbuilder.rb +18 -11
  78. data/lib/review/update.rb +5 -6
  79. data/lib/review/version.rb +1 -1
  80. data/lib/review/volumeprinter.rb +4 -5
  81. data/lib/review/webmaker.rb +18 -13
  82. data/lib/review/webtocprinter.rb +10 -9
  83. data/lib/review/yamlloader.rb +2 -1
  84. data/review.gemspec +5 -3
  85. data/samples/sample-book/src/config-epub2.yml +1 -1
  86. data/samples/sample-book/src/config.yml +1 -1
  87. data/samples/sample-book/src/lib/tasks/review.rake +17 -1
  88. data/samples/syntax-book/ch01.re +1 -1
  89. data/samples/syntax-book/ch02.re +21 -6
  90. data/samples/syntax-book/ch03.re +1 -1
  91. data/samples/syntax-book/images/img3-2.png +0 -0
  92. data/templates/html/_colophon.html.erb +23 -0
  93. data/templates/html/_colophon_history.html.erb +9 -0
  94. data/templates/html/_cover.html.erb +10 -0
  95. data/templates/html/_part_body.html.erb +6 -0
  96. data/templates/html/_titlepage.html.erb +20 -0
  97. data/templates/html/layout-html5.html.erb +6 -0
  98. data/templates/html/layout-xhtml1.html.erb +6 -0
  99. data/templates/latex/config.erb +8 -0
  100. data/templates/latex/review-jlreq/review-base.sty +4 -5
  101. data/templates/latex/review-jlreq/review-jlreq.cls +10 -2
  102. data/templates/latex/review-jlreq/review-style.sty +6 -1
  103. data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
  104. data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
  105. data/templates/latex/review-jsbook/review-base.sty +5 -7
  106. data/templates/latex/review-jsbook/review-jsbook.cls +10 -2
  107. data/templates/latex/review-jsbook/review-style.sty +6 -1
  108. data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
  109. data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
  110. data/templates/opf/epubv2.opf.erb +7 -7
  111. data/templates/opf/epubv3.opf.erb +7 -7
  112. data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
  113. data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
  114. data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
  115. data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
  116. data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
  117. data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
  118. data/templates/web/html/layout-html5.html.erb +6 -5
  119. data/templates/web/html/layout-xhtml1.html.erb +6 -0
  120. data/test/assets/header_listener.html +35 -0
  121. data/test/assets/img_math/img1.png +0 -0
  122. data/test/assets/img_math/img2.png +0 -0
  123. data/test/assets/img_math/img3.png +0 -0
  124. data/test/assets/syntax_book_index_detail.txt +58 -0
  125. data/test/assets/test_template.tex +4 -1
  126. data/test/assets/test_template_backmatter.tex +4 -1
  127. data/test/run_test.rb +1 -1
  128. data/test/test_book_chapter.rb +2 -2
  129. data/test/test_catalog_converter_cmd.rb +1 -1
  130. data/test/test_epub3maker.rb +168 -124
  131. data/test/test_epubmaker.rb +243 -131
  132. data/test/test_epubmaker_cmd.rb +2 -2
  133. data/test/test_helper.rb +5 -4
  134. data/test/test_htmlbuilder.rb +64 -6
  135. data/test/test_idgxmlbuilder.rb +13 -0
  136. data/test/test_idgxmlmaker_cmd.rb +7 -3
  137. data/test/test_img_math.rb +111 -0
  138. data/test/test_indexbuilder.rb +5 -5
  139. data/test/test_latexbuilder.rb +107 -4
  140. data/test/test_lineinput.rb +20 -93
  141. data/test/test_markdownbuilder.rb +29 -0
  142. data/test/test_pdfmaker.rb +71 -0
  143. data/test/test_pdfmaker_cmd.rb +2 -2
  144. data/test/test_plaintextbuilder.rb +10 -18
  145. data/test/test_reviewheaderlistener.rb +49 -0
  146. data/test/test_template.rb +12 -2
  147. data/test/test_textmaker_cmd.rb +5 -1
  148. data/test/test_tocprinter.rb +46 -0
  149. data/test/test_topbuilder.rb +6 -1
  150. data/test/test_update.rb +34 -34
  151. data/test/test_zip_exporter.rb +5 -6
  152. metadata +91 -17
  153. data/lib/epubmaker.rb +0 -23
  154. data/lib/epubmaker/content.rb +0 -111
  155. data/lib/epubmaker/epubcommon.rb +0 -449
  156. data/lib/epubmaker/epubv2.rb +0 -142
  157. data/lib/epubmaker/epubv3.rb +0 -235
  158. data/lib/epubmaker/producer.rb +0 -375
  159. data/lib/epubmaker/zip_exporter.rb +0 -81
  160. data/lib/lineinput.rb +0 -155
@@ -7,15 +7,15 @@
7
7
  <%= @opf_manifest %>
8
8
  <%= @opf_toc %>
9
9
  <guide>
10
- <reference type="cover" title="<%= @producer.res.v('covertitle') %>" href="<%= @producer.config['cover'] %>"/>
11
- <% if @producer.config['titlepage'].present? %>
12
- <reference type="title-page" title="<%= @producer.res.v('titlepagetitle') %>" href="titlepage.<%= @producer.config['htmlext'] %>"/>
10
+ <reference type="cover" title="<%= ReVIEW::I18n.t('covertitle') %>" href="<%= @config['cover'] %>"/>
11
+ <% if @config['titlepage'].present? %>
12
+ <reference type="title-page" title="<%= ReVIEW::I18n.t('titlepagetitle') %>" href="titlepage.<%= @config['htmlext'] %>"/>
13
13
  <% end %>
14
- <% if @producer.config['mytoc'].present? %>
15
- <reference type="toc" title="<%= @producer.res.v('toctitle') %>" href="<%= @producer.config['bookname'] %>-toc.<%= @producer.config['htmlext'] %>"/>
14
+ <% if @config['mytoc'].present? %>
15
+ <reference type="toc" title="<%= ReVIEW::I18n.t('toctitle') %>" href="<%= @config['bookname'] %>-toc.<%= @config['htmlext'] %>"/>
16
16
  <% end %>
17
- <% if @producer.config['colophon'].present? %>
18
- <reference type="colophon" title="<%= @producer.res.v('colophontitle') %>" href="colophon.<%= @producer.config['htmlext'] %>"/>
17
+ <% if @config['colophon'].present? %>
18
+ <reference type="colophon" title="<%= ReVIEW::I18n.t('colophontitle') %>" href="colophon.<%= @config['htmlext'] %>"/>
19
19
  <% end %>
20
20
  </guide>
21
21
  </package>
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="<%= @producer.config['language'] %>"<%= @package_attrs %>>
2
+ <package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="<%= @config['language'] %>"<%= @package_attrs %>>
3
3
  <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
4
4
  <%= @opf_metainfo %>
5
5
  <%= @opf_coverimage %>
@@ -7,13 +7,13 @@
7
7
  <%= @opf_manifest %>
8
8
  <%= @opf_toc %>
9
9
  <guide>
10
- <reference type="cover" title="<%= @producer.res.v('covertitle') %>" href="<%= @producer.config['cover'] %>"/>
11
- <% if @producer.config["titlepage"].present? %>
12
- <reference type="title-page" title="<%= @producer.res.v('titlepagetitle') %>" href="titlepage.<%= @producer.config['htmlext'] %>"/>
10
+ <reference type="cover" title="<%= ReVIEW::I18n.t('covertitle') %>" href="<%= @config['cover'] %>"/>
11
+ <% if @config["titlepage"].present? %>
12
+ <reference type="title-page" title="<%= ReVIEW::I18n.t('titlepagetitle') %>" href="titlepage.<%= @config['htmlext'] %>"/>
13
13
  <% end %>
14
- <reference type="toc" title="<%= @producer.res.v('toctitle') %>" href="<%= @producer.config['bookname'] %>-toc.<%= @producer.config['htmlext'] %>"/>
15
- <% if @producer.config['colophon'].present? %>
16
- <reference type="colophon" title="<%= @producer.res.v('colophontitle') %>" href="colophon.<%= @producer.config['htmlext'] %>"/>
14
+ <reference type="toc" title="<%= ReVIEW::I18n.t('toctitle') %>" href="<%= @config['bookname'] %>-toc.<%= @config['htmlext'] %>"/>
15
+ <% if @config['colophon'].present? %>
16
+ <reference type="colophon" title="<%= ReVIEW::I18n.t('colophontitle') %>" href="colophon.<%= @config['htmlext'] %>"/>
17
17
  <% end %>
18
18
  </guide>
19
19
  </package>
@@ -0,0 +1,10 @@
1
+ <manifest>
2
+ <item id="ncx" href="<%= @config['bookname'] %>.ncx" media-type="application/x-dtbncx+xml"/>
3
+ <item id="<%= @config['bookname'] %>" href="<%= @config['cover'] %>" media-type="application/xhtml+xml"/>
4
+ <% if @config['toc'] && @config['mytoc'] %>
5
+ <item id="toc" href="<%= @config['bookname'] %>-toc.<%= @config['htmlext'] %>" media-type="application/xhtml+xml"/>
6
+ <% end %>
7
+ <% @items.each do |item| %>
8
+ <item id="<%= item.id %>" href="<%= item.file %>" media-type="<%= item.media %>"/>
9
+ <% end %>
10
+ </manifest>
@@ -0,0 +1,10 @@
1
+ <manifest>
2
+ <item properties="nav" id="<%= @config['bookname'] %>-toc.<%= @config['htmlext'] %>" href="<%= @config['bookname'] %>-toc.<%= @config['htmlext'] %>" media-type="application/xhtml+xml"/>
3
+ <item id="<%= @config['bookname'] %>" href="<%= @config['cover'] %>" media-type="application/xhtml+xml"/>
4
+ <% if @coverimage %>
5
+ <item properties="cover-image" id="cover-<%= @coverimage.id %>" href="<%= @coverimage.file %>" media-type="<%= @coverimage.media %>"/>
6
+ <% end %>
7
+ <% @items.each do |item| %>
8
+ <item id="<%= item.id %>" href="<%= item.file %>" media-type="<%= item.media %>"<%= item.properties_attribute %>/>
9
+ <% end %>
10
+ </manifest>
@@ -0,0 +1,17 @@
1
+ <% @dc_items.each do |item| %>
2
+ <<%= item[:tag] %>><%= h(item[:val]) %></<%= item[:tag] %>>
3
+ <% end %>
4
+ <% if @config['isbn'] %>
5
+ <dc:identifier id="BookId" opf:scheme="ISBN"><%= @config['isbn'] %></dc:identifier>
6
+ <% else %>
7
+ <dc:identifier id="BookId"><%= @config['urnid'] %></dc:identifier>
8
+ <% end %>
9
+ <% @creators.each do |creator| %>
10
+ <dc:creator opf:role="<%= creator[:role] %>"><%= h(creator[:val]) %></dc:creator>
11
+ <% end %>
12
+ <% @contributers.each do |contributer| %>
13
+ <dc:contributor opf:role="<%= contributer[:role] %>"><%= h(contributer[:val]) %></dc:contributor>
14
+ <% if contributer[:role] == 'prt' %>
15
+ <dc:publisher><%= h(contributer[:val]) %></dc:publisher>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,49 @@
1
+ <%# --- DC items --- %>
2
+ <% @dc_items.each do |item| %>
3
+ <<%= item[:tag] %> id="<%= item[:id] %>"><%= item[:val] %></<%= item[:tag] %>>
4
+ <% item[:refines].each do | refine | %>
5
+ <meta refines="#<%= item[:id] %>" property="<%= refine[:name] %>"><%= h(refine[:val]) %></meta>
6
+ <% end %>
7
+ <% end %>
8
+ <meta property="dcterms:modified"><%= @config['modified'] %></meta>
9
+ <% if @config['isbn'] %>
10
+ <dc:identifier id="BookId"><%= @config['isbn'] %></dc:identifier>
11
+ <% else %>
12
+ <dc:identifier id="BookId"><%= @config['urnid'] %></dc:identifier>
13
+ <% end %>
14
+ <%# --- creator --- %>
15
+ <% @creators.each do |creator| %>
16
+ <dc:creator id="<%= creator[:id] %>"><%= creator[:val] %></dc:creator>
17
+ <% creator[:refines].each do |refine| %>
18
+ <% if refine[:scheme] %>
19
+ <meta refines="#<%= refine[:id] %>" property="<%= refine[:property]%>" scheme="<%= refine[:scheme] %>"><%= refine[:val] %></meta>
20
+ <% else %>
21
+ <meta refines="#<%= refine[:id] %>" property="<%= refine[:property]%>"><%= refine[:val] %></meta>
22
+ <% end %>
23
+ <% end %>
24
+ <% end %>
25
+ <%# --- contributer --- %>
26
+ <% @contributers.each do |contributer| %>
27
+ <dc:contributor id="<%= contributer[:id] %>"><%= h(contributer[:val]) %></dc:contributor>
28
+ <% contributer[:refines].each do |refine| %>
29
+ <% if refine[:scheme] %>
30
+ <meta refines="#<%= refine[:id] %>" property="<%= refine[:property]%>" scheme="<%= refine[:scheme] %>"><%= refine[:val] %></meta>
31
+ <% else %>
32
+ <meta refines="#<%= refine[:id] %>" property="<%= refine[:property]%>"><%= refine[:val] %></meta>
33
+ <% end %>
34
+ <% end %>
35
+ <% if contributer[:pub_id] %>
36
+ <dc:publisher id="<%= contributer[:pub_id] %>"><%= h(contributer[:pub_val]) %></dc:publisher>
37
+ <% contributer[:pub_refines].each do |refine| %>
38
+ <% if refine[:scheme] %>
39
+ <meta refines="#<%= refine[:id] %>" property="<%= refine[:property]%>" scheme="<%= refine[:scheme] %>"><%= refine[:val] %></meta>
40
+ <% else %>
41
+ <meta refines="#<%= refine[:id] %>" property="<%= refine[:property]%>"><%= refine[:val] %></meta>
42
+ <% end %>
43
+ <% end %>
44
+ <% end %>
45
+ <% end %>
46
+ <%# --- other --- %>
47
+ <% (@config['opf_meta'] || [] ).each do |k, v| %>
48
+ <meta property="<%= h(k) %>"><%= h(v) %></meta>
49
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <spine toc="ncx">
2
+ <itemref idref="<%= @config['bookname'] %>" linear="<%= @cover_linear %>"/>
3
+ <% if @config['mytoc'] %>
4
+ <itemref idref="toc" />
5
+ <% end %>
6
+ <% @ncx_contents.each do |item| %>
7
+ <itemref idref="<%= item.id %>"/>
8
+ <% end %>
9
+ </spine>
@@ -0,0 +1,17 @@
1
+ <% if @config['direction'] %>
2
+ <spine page-progression-direction="<%= @config['direction'] %>">
3
+ <% else %>
4
+ <spine>
5
+ <% end %>
6
+ <itemref idref="<%= @config['bookname'] %>" linear="<%= @cover_linear %>"/>
7
+ <% toc = nil %>
8
+ <% @tocx_contents.each do |item| %>
9
+ <% if toc.nil? && item.chaptype != 'pre' %>
10
+ <% if @config['toc'] %>
11
+ <itemref idref="<%= @config['bookname'] %>-toc.<%= @config['htmlext'] %>" />
12
+ <% end %>
13
+ <% toc = true %>
14
+ <% end %>
15
+ <itemref idref="<%= item.id %>"/>
16
+ <% end %>
17
+ </spine>
@@ -3,6 +3,12 @@
3
3
  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="<%=h @language %>">
4
4
  <head>
5
5
  <meta charset="UTF-8" />
6
+ <% if @javascripts.present? %>
7
+ <% @javascripts.each do |js| %>
8
+ <%= js %>
9
+
10
+ <% end %>
11
+ <% end %>
6
12
  <% if @stylesheets.present? %>
7
13
  <% @stylesheets.each do |style| %>
8
14
  <link rel="stylesheet" type="text/css" href="<%=h style %>" />
@@ -47,10 +53,5 @@
47
53
  <p class="copyright"><%=h @config["copyright"] %></p>
48
54
  <% end %>
49
55
  </footer>
50
- <% if @javascripts.present? %>
51
- <% @javascripts.each do |script| %>
52
- <script src="<%=h script %>"></script>
53
- <% end %>
54
- <% end%>
55
56
  </body>
56
57
  </html>
@@ -3,6 +3,12 @@
3
3
  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="<%= @language %>">
4
4
  <head>
5
5
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
6
+ <% if @javascripts.present? %>
7
+ <% @javascripts.each do |js| %>
8
+ <%= js %>
9
+
10
+ <% end %>
11
+ <% end %>
6
12
  <meta http-equiv="Content-Style-Type" content="text/css"/>
7
13
  <% if @stylesheets.present? %>
8
14
  <% @stylesheets.each do |style| %>
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html>
3
+ <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">
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <link rel="stylesheet" type="text/css" href="style.css" />
7
+ <meta name="generator" content="Re:VIEW" />
8
+ <title>first chapter</title>
9
+ </head>
10
+ <body>
11
+ <h1><a id="h1"></a><span class="secno">第1章 </span>first chapter</h1>
12
+
13
+ <h2><a id="h1-1"></a><span class="secno">1.1 </span>first section</h2>
14
+
15
+ <h3><a id="h1-1-1"></a>first <img src="images/icon1.jpg" alt="subsection" /></h3>
16
+
17
+ <h2><a id="h1-2"></a><span class="secno">1.2 </span>second section</h2>
18
+
19
+ <h3 id="dummy1"><a id="h1-2-1"></a>dummy subsection</h3>
20
+
21
+ <h2><a id="h1-3"></a><span class="secno">1.3 </span>third section</h2>
22
+
23
+ <h2 id="ch01_nonum1" notoc="true">notoc section</h2>
24
+
25
+ <h2 id="dummy2" notoc="true">notoc section</h2>
26
+
27
+ <a id="ch01_nonum3" /><h2 id="ch01_nonum3" hidden="true">nodisp section</h2>
28
+
29
+ <a id="dummy3" /><h2 id="dummy3" hidden="true">nodisp section</h2>
30
+
31
+ <h2 id="ch01_nonum5">nonum section</h2>
32
+
33
+ <h2 id="dummy4">nonum section</h2>
34
+ </body>
35
+ </html>
Binary file
Binary file
Binary file
@@ -0,0 +1,58 @@
1
+ =============================
2
+ 272C 16L 1P pre01
3
+ -----------------------------
4
+ 272C 16L 0.7P 前書き
5
+ =============================
6
+ 9C 1L 1P
7
+ -----------------------------
8
+ 9C 1L 0.0P 第I部 部扉見出し
9
+ =============================
10
+ 2444C 75L 5P ch01
11
+ -----------------------------
12
+ 419C 9L 0.6P 第1章 章見出し
13
+ 270C 9L 0.5P 1.1 節見出し
14
+ 137C 3L 0.2P 1.1.1 項見出し……に脚注を入れるとTeXではエラー
15
+ 187C 5L 0.3P 1.1.1.1 段見出し
16
+ 46C 1L 0.0P 1.2 長い節見出し■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
17
+ 48C 1L 0.0P 1.2.1 長い項見出し■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
18
+ 193C 4L 0.3P 1.2.1.1 長い段見出し■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
19
+ 138C 2L 0.2P 1.2.2 採番する項見出し
20
+ 8C 1L 0.0P 1.3 箇条書き
21
+ 255C 12L 0.6P 1.3.1 ナカグロ箇条書き
22
+ 159C 7L 0.4P 1.3.2 番号箇条書き
23
+ 584C 21L 1.0P 1.3.3 用語リスト
24
+ =============================
25
+ 169C 2L 1P part2
26
+ -----------------------------
27
+ 169C 2L 0.2P 第II部 部見出し■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
28
+ =============================
29
+ 5652C 175L 10P ch02
30
+ -----------------------------
31
+ 52C 1L 0.0P 第2章 長い章見出し■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
32
+ 10C 1L 0.0P 2.1 ブロック命令
33
+ 784C 27L 1.4P 2.1.1 ソースコード
34
+ 338C 8L 0.5P 2.1.2 図
35
+ 709C 22L 1.3P 2.1.3 表
36
+ 1154C 56L 2.8P 2.1.4 囲み記事
37
+ 523C 14L 0.8P 2.2 LaTeX式
38
+ 11C 1L 0.0P 2.3 インライン命令
39
+ 967C 17L 1.3P 2.3.1 書体
40
+ 74C 1L 0.0P 2.3.2 見出し内 BOLD,ITALIC,TT,STRONG,EM,CODE,TTB,TTI,AMI,BOU,KW,UNDERLINE,INS、
41
+ 797C 22L 1.3P 2.3.3 参照
42
+ 39C 2L 0.1P 2.3.4 参考文献
43
+ 194C 3L 0.3P 2.3.5 索引
44
+ =============================
45
+ 2255C 38L 4P ch03
46
+ -----------------------------
47
+ 2255C 38L 3.1P 第3章 コラム
48
+ =============================
49
+ 134C 12L 1P appA
50
+ -----------------------------
51
+ 10C 1L 0.0P 付録A 付録の見出し
52
+ 8C 1L 0.0P A.1 付録の節
53
+ 10C 1L 0.0P A.1.1 付録の項
54
+ 106C 9L 0.4P A.1.1.1 付録の段
55
+ =============================
56
+ 219C 3L 1P bib
57
+ -----------------------------
58
+ 219C 3L 0.2P 参考文献
@@ -1,6 +1,6 @@
1
1
  \documentclass[dvipdfmx]{review-jsbook}
2
2
  \makeatletter
3
- \def\review@reviewversion{4.2.0}
3
+ \def\review@reviewversion{5.1.0}
4
4
  \def\review@texcompiler{uplatex}
5
5
  \def\review@documentclass{review-jsbook}
6
6
 
@@ -58,6 +58,9 @@
58
58
  \ifdefined\covermatter\else% for 4.0.0 compatibility
59
59
  \def\covermatter{}
60
60
  \fi
61
+ \ifdefined\reviewchapref\else% for 5.1.0 compatibility
62
+ \newcommand{\reviewchapref}[2]{\hyperref[##2]{##1}}
63
+ \fi
61
64
  }
62
65
 
63
66
  \makeatother
@@ -1,6 +1,6 @@
1
1
  \documentclass[dvipdfmx]{review-jsbook}
2
2
  \makeatletter
3
- \def\review@reviewversion{4.2.0}
3
+ \def\review@reviewversion{5.1.0}
4
4
  \def\review@texcompiler{uplatex}
5
5
  \def\review@documentclass{review-jsbook}
6
6
 
@@ -69,6 +69,9 @@ some ad content
69
69
  \ifdefined\covermatter\else% for 4.0.0 compatibility
70
70
  \def\covermatter{}
71
71
  \fi
72
+ \ifdefined\reviewchapref\else% for 5.1.0 compatibility
73
+ \newcommand{\reviewchapref}[2]{\hyperref[##2]{##1}}
74
+ \fi
72
75
  }
73
76
 
74
77
  \makeatother
data/test/run_test.rb CHANGED
@@ -1,4 +1,4 @@
1
- base_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
1
+ base_dir = File.expand_path('..', __dir__)
2
2
  lib_dir = File.join(base_dir, 'lib')
3
3
  test_dir = File.join(base_dir, 'test')
4
4
 
@@ -118,11 +118,11 @@ class ChapterTest < Test::Unit::TestCase
118
118
  assert !pre.on_chaps?
119
119
 
120
120
  ch2_path = File.join(dir, 'chapter2.re')
121
- File.open(ch2_path, 'w') {}
121
+ FileUtils.touch(ch2_path)
122
122
  ch2 = Book::Chapter.new(book, 2, 'chapter2', ch2_path)
123
123
 
124
124
  ch3_path = File.join(dir, 'chapter3.re')
125
- File.open(ch3_path, 'w') {}
125
+ FileUtils.touch(ch3_path)
126
126
  ch3 = Book::Chapter.new(book, 3, 'chapter3', ch3_path)
127
127
 
128
128
  assert ch2.on_chaps?
@@ -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', File.dirname(__FILE__)))
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
@@ -1,13 +1,11 @@
1
1
  require 'test_helper'
2
- require 'epubmaker'
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
- @producer = Producer.new
10
- @producer.merge_config(
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
- @output = StringIO.new
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.merge_config('language' => 'en')
29
- assert_equal 'Table of Contents', @producer.res.v('toctitle')
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.merge_config('language' => 'ja')
34
- assert_equal '目次', @producer.res.v('toctitle')
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(@output)
39
- assert_equal 'application/epub+zip', @output.string
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(@output)
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, @output.string
52
+ assert_equal expect, output
53
53
  end
54
54
 
55
55
  def test_stage1_opf
56
- @producer.opf(@output)
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, @output.string
80
+ assert_equal expect, output
81
81
  end
82
82
 
83
83
  def test_stage1_opf_ebpaj
84
- @producer.merge_config(
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.opf(@output)
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, @output.string
114
+ assert_equal expect, output
114
115
  end
115
116
 
116
117
  def test_stage1_opf_fileas
117
- @producer.config['title'] = { 'name' => 'これは書籍です', 'file-as' => 'コレハショセキデス' }
118
- @producer.config['aut'] = [{ 'name' => '著者A', 'file-as' => 'チョシャA' }, { 'name' => '著者B', 'file-as' => 'チョシャB' }]
119
- @producer.config['pbl'] = [{ 'name' => '出版社', 'file-as' => 'シュッパンシャ' }]
120
- @producer.opf(@output)
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, @output.string
159
+ assert_equal expect, output
158
160
  end
159
161
 
160
162
  def test_stage1_ncx
161
- @producer.ncx(@output)
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, @output.string
181
+ assert_equal expect, output
180
182
  end
181
183
 
182
184
  def stage2
183
185
  # add one item
184
- @producer.contents << Content.new({ 'file' => 'ch01.html', 'title' => 'CH01', 'level' => 1 })
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
- 'ch01-html',
191
- 'application/xhtml+xml',
192
- 'CH01',
193
- 1)
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(@output)
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, @output.string
227
+ assert_equal expect, output
226
228
  end
227
229
 
228
230
  def test_stage2_ncx
229
231
  stage2
230
- @producer.ncx(@output)
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, @output.string
251
+ assert_equal expect, output
250
252
  end
251
253
 
252
254
  def stage3
253
255
  # add more items
254
- @producer.contents << Content.new({ 'file' => 'ch01.html', 'title' => %Q(CH01<>&"), 'level' => 1 })
255
- @producer.contents << Content.new({ 'file' => 'ch02.html', 'title' => 'CH02', 'level' => 1 })
256
- @producer.contents << Content.new({ 'file' => 'ch02.html#S1', 'title' => 'CH02.1', 'level' => 2 })
257
- @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1', 'title' => 'CH02.1.1', 'level' => 3 })
258
- @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1.1', 'title' => 'CH02.1.1.1', 'level' => 4 })
259
- @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1.1.1', 'title' => 'CH02.1.1.1.1', 'level' => 5 })
260
- @producer.contents << Content.new({ 'file' => 'ch02.html#S1.1.2', 'title' => 'CH02.1.1.2', 'level' => 4 })
261
- @producer.contents << Content.new({ 'file' => 'ch02.html#S2', 'title' => 'CH02.2', 'level' => 2 })
262
- @producer.contents << Content.new({ 'file' => 'ch02.html#S2.1', 'title' => 'CH02.2.1', 'level' => 3 })
263
- @producer.contents << Content.new({ 'file' => 'ch03.html', 'title' => 'CH03', 'level' => 1, 'properties' => ['mathml'] })
264
- @producer.contents << Content.new({ 'file' => 'ch03.html#S1', 'title' => 'CH03.1', 'level' => 2 })
265
- @producer.contents << Content.new({ 'file' => 'ch03.html#S1.1', 'title' => 'CH03.1.1', 'level' => 3 })
266
- @producer.contents << Content.new({ 'file' => 'ch04.html', 'title' => 'CH04', 'level' => 1 })
267
- @producer.contents << Content.new({ 'file' => 'sample.png' })
268
- @producer.contents << Content.new({ 'file' => 'sample.jpg' })
269
- @producer.contents << Content.new({ 'file' => 'sample.JPEG' })
270
- @producer.contents << Content.new({ 'file' => 'sample.SvG' })
271
- @producer.contents << Content.new({ 'file' => 'sample.GIF' })
272
- @producer.contents << Content.new({ 'file' => 'sample.css' })
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, nil, ['mathml']),
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(@output)
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, @output.string
344
+ assert_equal expect, output
343
345
  end
344
346
 
345
347
  def test_stage3_ncx
346
348
  stage3
347
- @producer.ncx(@output)
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, @output.string
377
+ assert_equal expect, output
375
378
  end
376
379
 
377
380
  def test_stage3_mytoc
378
381
  stage3
379
- @producer.mytoc(@output)
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, @output.string
408
+ assert_equal expect, output
405
409
  end
406
410
 
407
411
  def test_stage3_flat
408
- @producer.merge_config('epubmaker' => { 'flattoc' => true, 'flattocindent' => false })
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(@output)
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, @output.string
442
+ assert_equal expect, output
435
443
  end
436
444
 
437
445
  def test_stage3_cover
438
446
  stage3
439
- @producer.cover(@output)
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, @output.string
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.cover(@output)
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, @output.string
486
+ assert_equal expect, output
478
487
  end
479
488
 
480
489
  def test_colophon_default
481
- @producer.config['aut'] = ['Mr.Smith']
482
- @producer.config['pbl'] = ['BLUEPRINT']
483
- @producer.colophon(@output)
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, @output.string
517
+ assert_equal expect, output
508
518
  end
509
519
 
510
520
  def test_colophon_pht
511
- @producer.config['aut'] = ['Mr.Smith']
512
- @producer.config['pbl'] = ['BLUEPRINT']
513
- @producer.config['pht'] = ['Mrs.Smith']
514
- @producer.colophon(@output)
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, @output.string
550
+ assert_equal expect, output
540
551
  end
541
552
 
542
553
  def test_colophon_history
543
- @producer.config['aut'] = ['Mr.Smith']
544
- @producer.config['pbl'] = ['BLUEPRINT']
545
- @producer.config['pht'] = ['Mrs.Smith']
546
- @producer.merge_config('language' => 'ja')
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['aut'] = ['Mr.Smith']
558
- @producer.config['pbl'] = ['BLUEPRINT']
559
- @producer.config['pht'] = ['Mrs.Smith']
560
- @producer.merge_config(
561
- 'language' => 'ja',
562
- 'history' => [['2011-08-03 v1.0.0版発行', '2012-02-15 v1.1.0版発行']]
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['aut'] = ['Mr.Smith']
576
- @producer.config['pbl'] = ['BLUEPRINT']
577
- @producer.config['pht'] = ['Mrs.Smith']
578
- @producer.merge_config(
579
- 'language' => 'ja',
580
- 'history' => [['2011-08-03', '2012-02-15']]
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['aut'] = ['Mr.Smith']
594
- @producer.config['pbl'] = ['BLUEPRINT']
595
- @producer.config['pht'] = ['Mrs.Smith']
596
- @producer.merge_config(
597
- 'language' => 'ja',
598
- 'history' => [['2011-08-03', '2012-02-15'],
599
- ['2012-10-01'],
600
- ['2013-03-01']]
601
- )
603
+ @producer.config.merge!('aut' => ['Mr.Smith'],
604
+ 'pbl' => ['BLUEPRINT'],
605
+ 'pht' => ['Mrs.Smith'],
606
+ 'language' => 'ja',
607
+ 'history' => [['2011-08-03', '2012-02-15'],
608
+ ['2012-10-01'],
609
+ ['2013-03-01']])
610
+ @producer.modify_config
602
611
  history = @producer.instance_eval { @epub.colophon_history }
603
612
  expect = <<EOT
604
613
  <div class="pubhistory">
@@ -686,4 +695,39 @@ large.svg: 250x150 exceeds a limit. suggeted value is 95x57
686
695
  EOS
687
696
  assert_equal expected, err
688
697
  end
698
+
699
+ def test_build_part
700
+ Dir.mktmpdir do |tmpdir|
701
+ book = ReVIEW::Book::Base.new
702
+ book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re])
703
+ io1 = StringIO.new("//list[sampletest][a]{\nfoo\n//}\n")
704
+ chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
705
+ part1 = ReVIEW::Book::Part.new(book, 1, [chap1])
706
+ book.parts = [part1]
707
+ epubmaker = ReVIEW::EPUBMaker.new
708
+ epubmaker.instance_eval do
709
+ @config = book.config
710
+ @producer = ReVIEW::EPUBMaker::Producer.new(@config)
711
+ end
712
+ epubmaker.build_part(part1, tmpdir, 'part1.html')
713
+
714
+ expected = <<-EOB
715
+ <?xml version="1.0" encoding="UTF-8"?>
716
+ <!DOCTYPE html>
717
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="ja">
718
+ <head>
719
+ <meta charset="UTF-8" />
720
+ <meta name="generator" content="Re:VIEW" />
721
+ <title></title>
722
+ </head>
723
+ <body>
724
+ <div class="part">
725
+ <h1 class="part-number">第I部</h1>
726
+ </div>
727
+ </body>
728
+ </html>
729
+ EOB
730
+ assert_equal expected, File.read(File.join(tmpdir, 'part1.html'))
731
+ end
732
+ end
689
733
  end