lib/review/epubmaker.rb in review-3.0.0.preview2 vs lib/review/epubmaker.rb in review-3.0.0.preview3

- old
+ new

@@ -21,15 +21,17 @@ require 'review/yamlloader' require 'rexml/document' require 'rexml/streamlistener' require 'epubmaker' require 'review/epubmaker/reviewheaderlistener' +require 'review/makerhelper' module ReVIEW class EPUBMaker include ::EPUBMaker include REXML + include MakerHelper def initialize @producer = nil @htmltoc = nil @buildlogtxt = 'build-log.txt' @@ -101,15 +103,13 @@ FileUtils.rm_f("#{bookname}.epub") if @config['debug'] FileUtils.rm_rf(booktmpname) end - math_dir = "./#{@config['imagedir']}/_review_math" - if @config['imgmath'] && Dir.exist?(math_dir) - FileUtils.rm_rf(math_dir) - end + cleanup_mathimg + basetmpdir = build_path begin log("Created first temporary directory as #{basetmpdir}.") call_hook('hook_beforeprocess', basetmpdir) @@ -123,10 +123,15 @@ build_body(basetmpdir, yamlfile) call_hook('hook_afterbody', basetmpdir) copy_backmatter(basetmpdir) + + math_dir = "./#{@config['imagedir']}/_review_math" + if @config['imgmath'] && File.exist?("#{math_dir}/__IMGMATH_BODY__.tex") + make_math_images(math_dir) + end call_hook('hook_afterbackmatter', basetmpdir) ## push contents in basetmpdir into @producer push_contents(basetmpdir) @@ -265,9 +270,10 @@ base_path = Pathname.new(basedir) book = ReVIEW::Book.load(basedir) book.config = @config @converter = ReVIEW::Converter.new(book, ReVIEW::HTMLBuilder.new) @compile_errors = nil + book.parts.each do |part| if part.name.present? if part.file? build_chap(part, base_path, basetmpdir, true) else