diff --git a/lib/review/epub2html.rb b/lib/review/epub2html.rb index 74e0896c9..bd0cae43c 100644 --- a/lib/review/epub2html.rb +++ b/lib/review/epub2html.rb @@ -47,35 +47,35 @@ def execute(*args) exit 1 end - parse_epub(args[0]) - puts join_html(args[1]) + htmls = parse_epub(args[0]) + puts join_html(args[1], htmls) end def initialize @opfxml = nil - @htmls = {} - @head = nil - @tail = nil @inline_footnote = nil end def parse_epub(epubname) + htmls = {} Zip::File.open(epubname) do |zio| zio.each do |entry| if /.+\.opf\Z/.match?(entry.name) opf = entry.get_input_stream.read @opfxml = REXML::Document.new(opf) elsif /.+\.x?html\Z/.match?(entry.name) - @htmls[entry.name.sub('OEBPS/', '')] = entry.get_input_stream.read.force_encoding('utf-8') + htmls[entry.name.sub('OEBPS/', '')] = entry.get_input_stream.read.force_encoding('utf-8') end end end - nil + htmls end def take_headtail(html) - @head = html.sub(/(