review 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +43 -1
  3. data/.rubocop_todo.yml +605 -0
  4. data/.travis.yml +9 -0
  5. data/ChangeLog +4 -0
  6. data/Dockerfile +22 -0
  7. data/README.rdoc +1 -1
  8. data/Rakefile +1 -1
  9. data/bin/review-check +8 -21
  10. data/bin/review-compile +9 -15
  11. data/bin/review-epubmaker-legacy +6 -6
  12. data/bin/review-index +2 -13
  13. data/bin/review-preproc +1 -14
  14. data/bin/review-validate +1 -1
  15. data/bin/review-vol +1 -13
  16. data/doc/NEWS.ja.md +22 -0
  17. data/doc/NEWS.md +22 -0
  18. data/doc/quickstart.ja.md +1 -1
  19. data/doc/quickstart.md +1 -1
  20. data/lib/epubmaker/content.rb +3 -3
  21. data/lib/epubmaker/epubcommon.rb +91 -108
  22. data/lib/epubmaker/epubv2.rb +14 -67
  23. data/lib/epubmaker/epubv3.rb +25 -59
  24. data/lib/epubmaker/producer.rb +12 -0
  25. data/lib/review/book/base.rb +12 -4
  26. data/lib/review/book/compilable.rb +1 -3
  27. data/lib/review/book/index.rb +4 -4
  28. data/lib/review/builder.rb +6 -11
  29. data/lib/review/compiler.rb +7 -7
  30. data/lib/review/configure.rb +20 -8
  31. data/lib/review/epubbuilder.rb +1 -1
  32. data/lib/review/epubmaker.rb +52 -122
  33. data/lib/review/ewbbuilder.rb +4 -4
  34. data/lib/review/exception.rb +1 -1
  35. data/lib/review/htmlbuilder.rb +49 -54
  36. data/lib/review/htmltoc.rb +45 -0
  37. data/lib/review/htmlutils.rb +3 -3
  38. data/lib/review/i18n.rb +6 -2
  39. data/lib/review/i18n.yml +1 -1
  40. data/lib/review/idgxmlbuilder.rb +4 -5
  41. data/lib/review/inaobuilder.rb +1 -1
  42. data/lib/review/latexbuilder.rb +2 -2
  43. data/lib/review/latexutils.rb +6 -6
  44. data/lib/review/markdownbuilder.rb +4 -3
  45. data/lib/review/pdfmaker.rb +92 -92
  46. data/lib/review/preprocessor.rb +14 -51
  47. data/lib/review/template.rb +21 -0
  48. data/lib/review/textbuilder.rb +1 -1
  49. data/lib/review/textutils.rb +0 -28
  50. data/lib/review/tocparser.rb +3 -3
  51. data/lib/review/tocprinter.rb +8 -31
  52. data/lib/review/topbuilder.rb +2 -3
  53. data/lib/review/unfold.rb +2 -2
  54. data/lib/review/version.rb +1 -1
  55. data/review.gemspec +2 -1
  56. data/templates/html/layout-html5.html.erb +17 -0
  57. data/templates/html/layout-xhtml1.html.erb +20 -0
  58. data/templates/ncx/epubv2.ncx.erb +11 -0
  59. data/templates/opf/epubv2.opf.erb +21 -0
  60. data/templates/opf/epubv3.opf.erb +18 -0
  61. data/templates/xml/container.xml.erb +6 -0
  62. data/test/assets/test.xml.erb +3 -0
  63. data/test/test.re +1 -1
  64. data/test/test_book.rb +4 -4
  65. data/test/test_book_chapter.rb +0 -76
  66. data/test/test_book_part.rb +1 -1
  67. data/test/test_builder.rb +0 -49
  68. data/test/test_configure.rb +50 -0
  69. data/test/test_htmlbuilder.rb +54 -4
  70. data/test/test_htmltoc.rb +32 -0
  71. data/test/test_i18n.rb +3 -5
  72. data/test/test_idgxmlbuilder.rb +0 -2
  73. data/test/test_inaobuilder.rb +2 -4
  74. data/test/test_latexbuilder.rb +2 -4
  75. data/test/test_lineinput.rb +0 -18
  76. data/test/test_markdownbuilder.rb +5 -4
  77. data/test/test_pdfmaker.rb +11 -10
  78. data/test/test_template.rb +26 -0
  79. data/test/test_topbuilder.rb +0 -2
  80. metadata +35 -4
  81. data/rubocop-todo.yml +0 -456
@@ -54,6 +54,18 @@ module EPUBMaker
54
54
  end
55
55
  end
56
56
 
57
+ def coverimage
58
+ if !params["coverimage"]
59
+ return nil
60
+ end
61
+ @contents.each do |item|
62
+ if item.media =~ /\Aimage/ && item.file =~ /#{params["coverimage"]}\Z/ # /
63
+ return item.file
64
+ end
65
+ end
66
+ return nil
67
+ end
68
+
57
69
  # Update parameters by merging from new parameter hash +params+.
58
70
  def merge_params(params)
59
71
  @params = @params.merge(params)
@@ -84,6 +84,14 @@ module ReVIEW
84
84
  end
85
85
  end
86
86
 
87
+ def htmlversion
88
+ if config["htmlversion"].blank?
89
+ nil
90
+ else
91
+ config["htmlversion"].to_i
92
+ end
93
+ end
94
+
87
95
  def parts
88
96
  @parts ||= read_parts()
89
97
  end
@@ -111,7 +119,7 @@ module ReVIEW
111
119
  end
112
120
 
113
121
  def each_chapter_r(&block)
114
- chapters.reverse.each(&block)
122
+ chapters.reverse_each(&block)
115
123
  end
116
124
 
117
125
  def chapter_index
@@ -217,12 +225,12 @@ module ReVIEW
217
225
  end
218
226
 
219
227
  def read_PART
220
- return @read_PART if @read_PART
228
+ return @read_part if @read_part
221
229
 
222
230
  if catalog
223
- @read_PART = catalog.parts
231
+ @read_part = catalog.parts
224
232
  else
225
- @read_PART = File.read("#{@basedir}/#{config["part_file"]}")
233
+ @read_part = File.read("#{@basedir}/#{config["part_file"]}")
226
234
  end
227
235
  end
228
236
 
@@ -44,7 +44,6 @@ module ReVIEW
44
44
  @title = ''
45
45
  open {|f|
46
46
  f.each_line {|l|
47
- l = convert_inencoding(l, book.config["inencoding"])
48
47
  if l =~ /\A=+/
49
48
  @title = l.sub(/\A=+(\[.+?\])?(\{.+?\})?/, '').strip
50
49
  break
@@ -74,8 +73,7 @@ module ReVIEW
74
73
  attr_writer :content
75
74
 
76
75
  def content
77
- @content = convert_inencoding(File.read(path()),
78
- book.config["inencoding"])
76
+ @content = File.read(path())
79
77
  rescue
80
78
  @content
81
79
  end
@@ -58,7 +58,7 @@ module ReVIEW
58
58
  @index.fetch(id)
59
59
  rescue
60
60
  if @index.keys.map{|i| i.split(/\|/).last }.flatten. # unfold all ids
61
- reduce(Hash.new(0)){|h, i| h[i] += 1; h}. # number of occurrences
61
+ reduce(Hash.new(0)){|h, i| h[i] += 1; h}. # number of occurrences
62
62
  select{|k, v| k == id && v > 1 }.present? # detect duplicated
63
63
  raise KeyError, "key '#{id}' is ambiguous for #{self.class}"
64
64
  end
@@ -172,7 +172,7 @@ module ReVIEW
172
172
  attr_reader :id
173
173
  attr_reader :number
174
174
  attr_reader :caption
175
- attr_writer :index # internal use only
175
+ attr_writer :index # internal use only
176
176
 
177
177
  def bound?
178
178
  path
@@ -245,12 +245,12 @@ module ReVIEW
245
245
  end
246
246
 
247
247
  def title(id)
248
- sprintf(@locale["#{@index.item_type}_caption_format".intern],
248
+ sprintf(@locale["#{@index.item_type}_caption_format".to_sym],
249
249
  @index.title(id))
250
250
  end
251
251
 
252
252
  def number(id)
253
- sprintf(@locale["#{@index.item_type}_number_format".intern],
253
+ sprintf(@locale["#{@index.item_type}_number_format".to_sym],
254
254
  @index.number(id))
255
255
  end
256
256
 
@@ -63,15 +63,11 @@ module ReVIEW
63
63
  alias_method :raw_result, :result
64
64
 
65
65
  def print(*s)
66
- @output.print(*s.map{|i|
67
- convert_outencoding(i, @book.config["outencoding"])
68
- })
66
+ @output.print(*s)
69
67
  end
70
68
 
71
69
  def puts(*s)
72
- @output.puts *s.map{|i|
73
- convert_outencoding(i, @book.config["outencoding"])
74
- }
70
+ @output.puts(*s)
75
71
  end
76
72
 
77
73
  def target_name
@@ -380,7 +376,7 @@ module ReVIEW
380
376
  line = self.unescape(lines.join("\n"))
381
377
  cmds = {
382
378
  :graphviz => "echo '#{line}' | dot -T#{image_ext} -o#{file_path}",
383
- :gnuplot => "echo 'set terminal " +
379
+ :gnuplot => "echo 'set terminal " +
384
380
  "#{(image_ext == "eps") ? "postscript eps" : image_ext}\n" +
385
381
  " set output \"#{file_path}\"\n#{line}' | gnuplot",
386
382
  :blockdiag => "echo '#{line}' "+
@@ -400,13 +396,12 @@ module ReVIEW
400
396
  end
401
397
 
402
398
  def inline_include(file_name)
403
- compile_inline convert_inencoding(File.open(file_name).read,
404
- @book.config["inencoding"])
399
+ compile_inline File.open(file_name).read
405
400
  end
406
401
 
407
402
  def include(file_name)
408
403
  File.foreach(file_name) do |line|
409
- paragraph([convert_inencoding(line, @book.config["inencoding"])])
404
+ paragraph([line])
410
405
  end
411
406
  end
412
407
 
@@ -443,4 +438,4 @@ module ReVIEW
443
438
  end
444
439
  end
445
440
 
446
- end # module ReVIEW
441
+ end # module ReVIEW
@@ -362,7 +362,7 @@ module ReVIEW
362
362
  elsif level < current_level # down
363
363
  level_diff = current_level - level
364
364
  level = current_level
365
- (1..(level_diff - 1)).to_a.reverse.each do |i|
365
+ (1..(level_diff - 1)).to_a.reverse_each do |i|
366
366
  @strategy.ul_begin {i}
367
367
  @strategy.ul_item_begin []
368
368
  end
@@ -371,7 +371,7 @@ module ReVIEW
371
371
  elsif level > current_level # up
372
372
  level_diff = level - current_level
373
373
  level = current_level
374
- (1..level_diff).to_a.reverse.each do |i|
374
+ (1..level_diff).to_a.reverse_each do |i|
375
375
  @strategy.ul_item_end
376
376
  @strategy.ul_end {level + i}
377
377
  end
@@ -381,7 +381,7 @@ module ReVIEW
381
381
  end
382
382
  end
383
383
 
384
- (1..level).to_a.reverse.each do |i|
384
+ (1..level).to_a.reverse_each do |i|
385
385
  @strategy.ul_item_end
386
386
  @strategy.ul_end {i}
387
387
  end
@@ -424,7 +424,7 @@ module ReVIEW
424
424
 
425
425
  def read_command(f)
426
426
  line = f.gets
427
- name = line.slice(/[a-z]+/).intern
427
+ name = line.slice(/[a-z]+/).to_sym
428
428
  args = parse_args(line.sub(%r<\A//[a-z]+>, '').rstrip.chomp('{'), name)
429
429
  lines = block_open?(line) ? read_block(f) : nil
430
430
  return name, args, lines
@@ -446,7 +446,7 @@ module ReVIEW
446
446
  error "unexpected EOF (block begins at: #{head})"
447
447
  return buf
448
448
  end
449
- f.gets # discard terminator
449
+ f.gets # discard terminator
450
450
  buf
451
451
  end
452
452
 
@@ -524,7 +524,7 @@ module ReVIEW
524
524
  rescue => err
525
525
  error err.message
526
526
  end
527
- public :text # called from strategy
527
+ public :text # called from strategy
528
528
 
529
529
  def compile_inline(str)
530
530
  op, arg = /\A@<(\w+)>\{(.*?)\}\z/.match(str).captures
@@ -550,4 +550,4 @@ module ReVIEW
550
550
 
551
551
  end
552
552
 
553
- end # module ReVIEW
553
+ end # module ReVIEW
@@ -1,6 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module ReVIEW
3
3
  class Configure < Hash
4
+
5
+ attr_accessor :maker
6
+
4
7
  def self.values
5
8
  Configure[
6
9
  # These parameters can be overridden by YAML file.
@@ -36,17 +39,26 @@ module ReVIEW
36
39
  "language" => 'ja', # XXX default language should be JA??
37
40
 
38
41
  "chapter_file" => 'CHAPS',
39
- "part_file" => 'PART',
40
- "reject_file" => 'REJECT',
41
- "predef_file" => 'PREDEF',
42
+ "part_file" => 'PART',
43
+ "reject_file" => 'REJECT',
44
+ "predef_file" => 'PREDEF',
42
45
  "postdef_file" => 'POSTDEF',
43
- "page_metric" => ReVIEW::Book::PageMetric.a5,
44
- "ext" => '.re',
45
- "image_dir" => 'images',
46
- "image_types" => %w( .ai .psd .eps .pdf .tif .tiff .png .bmp .jpg .jpeg .gif .svg ),
47
- "bib_file" => "bib.re",
46
+ "page_metric" => ReVIEW::Book::PageMetric.a5,
47
+ "ext" => '.re',
48
+ "image_dir" => 'images',
49
+ "image_types" => %w( .ai .psd .eps .pdf .tif .tiff .png .bmp .jpg .jpeg .gif .svg ),
50
+ "bib_file" => "bib.re",
48
51
  "colophon_order" => %w(aut csl trl dsr ill cov edt pbl contact prt),
49
52
  ]
50
53
  end
54
+
55
+ def [](key)
56
+ if self.key?(key)
57
+ return self.fetch(key)
58
+ end
59
+ if @maker && self.key?(@maker)
60
+ return self.fetch(@maker).fetch(key, nil)
61
+ end
62
+ end
51
63
  end
52
64
  end
@@ -15,4 +15,4 @@ module ReVIEW
15
15
  class EPUBBuilder < HTMLBuilder
16
16
  end
17
17
 
18
- end # module ReVIEW
18
+ end # module ReVIEW
@@ -11,6 +11,7 @@ require 'review'
11
11
  require 'rexml/document'
12
12
  require 'rexml/streamlistener'
13
13
  require 'epubmaker'
14
+ require 'review/htmltoc'
14
15
 
15
16
  module ReVIEW
16
17
  class EPUBMaker
@@ -19,7 +20,7 @@ module ReVIEW
19
20
 
20
21
  def initialize
21
22
  @producer = nil
22
- @tochtmltxt = "toc-html.txt"
23
+ @htmltoc = nil
23
24
  @buildlogtxt = "build-log.txt"
24
25
  end
25
26
 
@@ -51,6 +52,7 @@ module ReVIEW
51
52
 
52
53
  call_hook("hook_beforeprocess", basetmpdir)
53
54
 
55
+ @htmltoc = ReVIEW::HTMLToc.new(basetmpdir)
54
56
  ## copy all files into basetmpdir
55
57
  copy_stylesheet(basetmpdir)
56
58
 
@@ -200,7 +202,7 @@ module ReVIEW
200
202
  build_part(part, basetmpdir, htmlfile)
201
203
  title = ReVIEW::I18n.t("part", part.number)
202
204
  title += ReVIEW::I18n.t("chapter_postfix") + part.name.strip if part.name.strip.present?
203
- write_tochtmltxt(basetmpdir, "0\t#{htmlfile}\t#{title}\tchaptype=part")
205
+ @htmltoc.add_item(0, htmlfile, title, {:chaptype => "part"})
204
206
  write_buildlogtxt(basetmpdir, htmlfile, "")
205
207
  end
206
208
  end
@@ -215,21 +217,23 @@ module ReVIEW
215
217
  def build_part(part, basetmpdir, htmlfile)
216
218
  log("Create #{htmlfile} from a template.")
217
219
  File.open("#{basetmpdir}/#{htmlfile}", "w") do |f|
218
- f.puts header(CGI.escapeHTML(@params["booktitle"]))
219
- f.puts <<EOT
220
- <div class="part">
221
- <h1 class="part-number">#{ReVIEW::I18n.t("part", part.number)}</h1>
222
- EOT
220
+ @body = ""
221
+ @body << "<div class=\"part\">\n"
222
+ @body << "<h1 class=\"part-number\">#{ReVIEW::I18n.t("part", part.number)}</h1>\n"
223
223
  if part.name.strip.present?
224
- f.puts <<EOT
225
- <h2 class="part-title">#{part.name.strip}</h2>
226
- EOT
224
+ @body << "<h2 class=\"part-title\">#{part.name.strip}</h2>\n"
227
225
  end
226
+ @body << "</div>\n"
228
227
 
229
- f.puts <<EOT
230
- </div>
231
- EOT
232
- f.puts footer
228
+ @language = @producer.params['language']
229
+ @stylesheets = @producer.params["stylesheet"]
230
+ if @producer.params["htmlversion"].to_i == 5
231
+ tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR)
232
+ else
233
+ tmplfile = File.expand_path('./html/layout-xhtml1.html.erb', ReVIEW::Template::TEMPLATE_DIR)
234
+ end
235
+ tmpl = ReVIEW::Template.load(tmplfile)
236
+ f.write tmpl.result(binding)
233
237
  end
234
238
  end
235
239
 
@@ -320,51 +324,27 @@ EOT
320
324
  headlines.each do |headline|
321
325
  headline["level"] = 0 if ispart.present? && headline["level"] == 1
322
326
  if first.nil?
323
- write_tochtmltxt(basetmpdir, "#{headline["level"]}\t#{filename}##{headline["id"]}\t#{headline["title"]}\tchaptype=#{chaptype}")
327
+ @htmltoc.add_item(headline["level"], filename+"#"+headline["id"], headline["title"], {:chaptype => chaptype})
324
328
  else
325
- write_tochtmltxt(basetmpdir, "#{headline["level"]}\t#{filename}\t#{headline["title"]}\tforce_include=true,chaptype=#{chaptype}#{prop_str}")
329
+ @htmltoc.add_item(headline["level"], filename, headline["title"], {:force_include => true, :chaptype => chaptype+prop_str})
326
330
  first = nil
327
331
  end
328
332
  end
329
333
  end
330
334
 
331
335
  def push_contents(basetmpdir)
332
- File.open("#{basetmpdir}/#{@tochtmltxt}") do |f|
333
- f.each_line do |l|
334
- force_include = nil
335
- customid = nil
336
- chaptype = nil
337
- properties = nil
338
- level, file, title, custom = l.chomp.split("\t")
339
- if custom.present?
340
- # custom setting
341
- vars = custom.split(/,\s*/)
342
- vars.each do |var|
343
- k, v = var.split("=")
344
- case k
345
- when "id"
346
- customid = v
347
- when "force_include"
348
- force_include = true
349
- when "chaptype"
350
- chaptype = v
351
- when "properties"
352
- properties = v
353
- end
354
- end
355
- end
356
- next if level.to_i > @params["toclevel"] && force_include.nil?
357
- log("Push #{file} to ePUB contents.")
336
+ @htmltoc.each_item do |level, file, title, args|
337
+ next if level.to_i > @params["toclevel"] && args[:force_include].nil?
338
+ log("Push #{file} to ePUB contents.")
358
339
 
359
- hash = {"file" => file, "level" => level.to_i, "title" => title, "chaptype" => chaptype}
360
- if customid.present?
361
- hash["id"] = customid
362
- end
363
- if properties.present?
364
- hash["properties"] = properties.split(" ")
365
- end
366
- @producer.contents.push(Content.new(hash))
340
+ hash = {"file" => file, "level" => level.to_i, "title" => title, "chaptype" => args[:chaptype]}
341
+ if args[:id].present?
342
+ hash["id"] = args[:id]
343
+ end
344
+ if args[:properties].present?
345
+ hash["properties"] = args[:properties].split(" ")
367
346
  end
347
+ @producer.contents.push(Content.new(hash))
368
348
  end
369
349
  end
370
350
 
@@ -386,55 +366,54 @@ EOT
386
366
  else
387
367
  FileUtils.cp(@params["titlefile"], "#{basetmpdir}/titlepage.#{@params["htmlext"]}")
388
368
  end
389
- write_tochtmltxt(basetmpdir, "1\ttitlepage.#{@params["htmlext"]}\t#{@producer.res.v("titlepagetitle")}\tchaptype=pre")
369
+ @htmltoc.add_item(1, "titlepage.#{@params['htmlext']}", @producer.res.v("titlepagetitle"), {:chaptype => "pre"})
390
370
  end
391
371
 
392
372
  if @params["originaltitlefile"].present? && File.exist?(@params["originaltitlefile"])
393
373
  FileUtils.cp(@params["originaltitlefile"], "#{basetmpdir}/#{File.basename(@params["originaltitlefile"])}")
394
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["originaltitlefile"])}\t#{@producer.res.v("originaltitle")}\tchaptype=pre")
374
+ @htmltoc.add_item(1, File.basename(@params["originaltitlefile"]), @producer.res.v("originaltitle"), {:chaptype => "pre"})
395
375
  end
396
376
 
397
377
  if @params["creditfile"].present? && File.exist?(@params["creditfile"])
398
378
  FileUtils.cp(@params["creditfile"], "#{basetmpdir}/#{File.basename(@params["creditfile"])}")
399
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["creditfile"])}\t#{@producer.res.v("credittitle")}\tchaptype=pre")
379
+ @htmltoc.add_item(1, File.basename(@params["creditfile"]), @producer.res.v("credittitle"), {:chaptype => "pre"})
400
380
  end
401
381
  end
402
382
 
403
383
  def build_titlepage(basetmpdir, htmlfile)
404
384
  File.open("#{basetmpdir}/#{htmlfile}", "w") do |f|
405
- f.puts header(CGI.escapeHTML(@params["booktitle"]))
406
- f.puts <<EOT
407
- <div class="titlepage">
408
- <h1 class="tp-title">#{CGI.escapeHTML(@params["booktitle"])}</h1>
409
- EOT
410
-
385
+ @body = ""
386
+ @body << "<div class=\"titlepage\">"
387
+ @body << "<h1 class=\"tp-title\">#{CGI.escapeHTML(@params["booktitle"])}</h1>"
411
388
  if @params["aut"]
412
- f.puts <<EOT
413
- <h2 class="tp-author">#{@params["aut"].join(", ")}</h2>
414
- EOT
389
+ @body << "<h2 class=\"tp-author\">#{@params["aut"].join(", ")}</h2>"
415
390
  end
416
391
  if @params["prt"]
417
- f.puts <<EOT
418
- <h3 class="tp-publisher">#{@params["prt"].join(", ")}</h3>
419
- EOT
392
+ @body << "<h3 class=\"tp-publisher\">#{@params["prt"].join(", ")}</h3>"
420
393
  end
394
+ @body << "</div>"
421
395
 
422
- f.puts <<EOT
423
- </div>
424
- EOT
425
- f.puts footer
396
+ @language = @producer.params['language']
397
+ @stylesheets = @producer.params["stylesheet"]
398
+ if @producer.params["htmlversion"].to_i == 5
399
+ tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR)
400
+ else
401
+ tmplfile = File.expand_path('./html/layout-xhtml1.html.erb', ReVIEW::Template::TEMPLATE_DIR)
402
+ end
403
+ tmpl = ReVIEW::Template.load(tmplfile)
404
+ f.write tmpl.result(binding)
426
405
  end
427
406
  end
428
407
 
429
408
  def copy_backmatter(basetmpdir)
430
409
  if @params["profile"]
431
410
  FileUtils.cp(@params["profile"], "#{basetmpdir}/#{File.basename(@params["profile"])}")
432
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["profile"])}\t#{@producer.res.v("profiletitle")}\tchaptype=post")
411
+ @htmltoc.add_item(1, File.basename(@params["profile"]), @producer.res.v("profiletitle"), {:chaptype => "post"})
433
412
  end
434
413
 
435
414
  if @params["advfile"]
436
415
  FileUtils.cp(@params["advfile"], "#{basetmpdir}/#{File.basename(@params["advfile"])}")
437
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["advfile"])}\t#{@producer.res.v("advtitle")}\tchaptype=post")
416
+ @htmltoc.add_item(1, File.basename(@params["advfile"]), @producer.res.v("advtitle"), {:chaptype => "post"})
438
417
  end
439
418
 
440
419
  if @params["colophon"]
@@ -443,18 +422,12 @@ EOT
443
422
  else
444
423
  File.open("#{basetmpdir}/colophon.#{@params["htmlext"]}", "w") {|f| @producer.colophon(f) }
445
424
  end
446
- write_tochtmltxt(basetmpdir, "1\tcolophon.#{@params["htmlext"]}\t#{@producer.res.v("colophontitle")}\tchaptype=post")
425
+ @htmltoc.add_item(1, "colophon.#{@params["htmlext"]}", @producer.res.v("colophontitle"), {:chaptype => "post"})
447
426
  end
448
427
 
449
428
  if @params["backcover"]
450
429
  FileUtils.cp(@params["backcover"], "#{basetmpdir}/#{File.basename(@params["backcover"])}")
451
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["backcover"])}\t#{@producer.res.v("backcovertitle")}\tchaptype=post")
452
- end
453
- end
454
-
455
- def write_tochtmltxt(basetmpdir, s)
456
- File.open("#{basetmpdir}/#{@tochtmltxt}", "a") do |f|
457
- f.puts s
430
+ @htmltoc.add_item(1, File.basename(@params["backcover"]), @producer.res.v("backcovertitle"), {:chaptype => "post"})
458
431
  end
459
432
  end
460
433
 
@@ -464,49 +437,6 @@ EOT
464
437
  end
465
438
  end
466
439
 
467
- def header(title)
468
- # titleはすでにエスケープ済みと想定
469
- s = <<EOT
470
- <?xml version="1.0" encoding="UTF-8"?>
471
- EOT
472
- if @params["htmlversion"] == 5
473
- s << <<EOT
474
- <!DOCTYPE html>
475
- <html xml:lang='ja' xmlns:ops='http://www.idpf.org/2007/ops' xmlns='http://www.w3.org/1999/xhtml'>
476
- <head>
477
- <meta charset="UTF-8" />
478
- EOT
479
- else
480
- s << <<EOT
481
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
482
- <html xml:lang='ja' xmlns:ops='http://www.idpf.org/2007/ops' xmlns='http://www.w3.org/1999/xhtml'>
483
- <head>
484
- <meta http-equiv='Content-Type' content='text/html;charset=UTF-8' />
485
- <meta http-equiv='Content-Style-Type' content='text/css' />
486
- EOT
487
- end
488
- if @params["stylesheet"].size > 0
489
- @params["stylesheet"].each do |sfile|
490
- s << <<EOT
491
- <link rel='stylesheet' type='text/css' href='#{sfile}' />
492
- EOT
493
- end
494
- end
495
- s << <<EOT
496
- <meta content='Re:VIEW' name='generator'/>
497
- <title>#{title}</title>
498
- </head>
499
- <body>
500
- EOT
501
- end
502
-
503
- def footer
504
- <<EOT
505
- </body>
506
- </html>
507
- EOT
508
- end
509
-
510
440
  class ReVIEWHeaderListener
511
441
  include REXML::StreamListener
512
442
  def initialize(headlines)