lib/review/epubmaker/epubv3.rb in review-5.3.0 vs lib/review/epubmaker/epubv3.rb in review-5.4.0

- old
+ new

@@ -1,8 +1,8 @@ # = epubv3.rb -- EPUB version 3 producer. # -# Copyright (c) 2010-2017 Kenshi Muto +# Copyright (c) 2010-2022 Kenshi Muto # # This program is free software. # You can distribute or modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. # For details of the GNU LGPL, see the file "COPYING". @@ -184,11 +184,11 @@ 'no' end @tocx_contents = [] toc = nil contents.each do |item| - next if item.media !~ /xhtml\+xml/ # skip non XHTML + next unless /xhtml\+xml/.match?(item.media) # skip non XHTML @tocx_contents << item end ReVIEW::Template.generate(path: './opf/opf_tocx_epubv3.opf.erb', binding: binding) @@ -208,22 +208,23 @@ EOT @title = h(ReVIEW::I18n.t('toctitle')) @language = config['language'] @stylesheets = config['stylesheet'] - ReVIEW::Template.generate(path: './html/layout-html5.html.erb', binding: binding) + ReVIEW::Template.generate(path: template_name, binding: binding) end # Produce EPUB file +epubfile+. # +work_dir+ points the directory has contents. # +tmpdir+ defines temporary directory. def produce(epubfile, work_dir, tmpdir, base_dir:) + @workdir = base_dir produce_write_common(work_dir, tmpdir) toc_file = "#{tmpdir}/OEBPS/#{config['bookname']}-toc.#{config['htmlext']}" File.write(toc_file, ncx(config['epubmaker']['ncxindent'])) - call_hook('hook_prepack', tmpdir, base_dir: base_dir) + call_hook('hook_prepack', tmpdir, base_dir: @workdir) expoter = ReVIEW::EPUBMaker::ZipExporter.new(tmpdir, config) expoter.export_zip(epubfile) end end end