lib/review/makerhelper.rb in review-3.2.0 vs lib/review/makerhelper.rb in review-4.0.0

- old
+ new

@@ -53,23 +53,23 @@ end exts = options[:exts] || %w[png gif jpg jpeg svg pdf eps ai tif psd] exts_str = exts.join('|') if !is_converted && fname =~ /\.(#{exts_str})$/i - FileUtils.cp "#{from_dir}/#{fname}", to_dir + FileUtils.cp("#{from_dir}/#{fname}", to_dir) image_files << "#{from_dir}/#{fname}" end end end end image_files end module_function :copy_images_to_dir - def cleanup_mathimg - math_dir = "./#{@config['imagedir']}/_review_math" + def cleanup_mathimg(path = '_review_math') + math_dir = "./#{@config['imagedir']}/#{path}" if @config['imgmath'] && Dir.exist?(math_dir) FileUtils.rm_rf(math_dir) end end @@ -139,10 +139,11 @@ FileUtils.rm_f([File.join(math_dir, '__IMGMATH_BODY__.tex'), File.join(math_dir, '__IMGMATH_BODY__.map')]) end def make_math_images_pdfcrop(dir, tex_path, math_dir) + # rubocop:disable Metrics/BlockLength Dir.chdir(dir) do dvi_path = '__IMGMATH__.dvi' pdf_path = '__IMGMATH__.pdf' out, status = Open3.capture2e(*[@config['texcommand'], @config['texoptions'].shellsplit, tex_path].flatten.compact) if !status.success? || (!File.exist?(dvi_path) && !File.exist?(pdf_path)) @@ -153,11 +154,10 @@ if !status.success? || !File.exist?(pdf_path) warn "error in #{@config['dvicommand']}. Error log:\n#{out}" raise CompileError end end - args = @config['imgmath_options']['pdfcrop_cmd'].shellsplit args.map! do |m| m.sub('%i', pdf_path). sub('%o', '__IMGMATH__pdfcrop.pdf') end @@ -199,10 +199,11 @@ end args = @config['imgmath_options']['pdfcrop_pixelize_cmd'].shellsplit args.map! do |m| m.sub('%i', pdf_path2). + sub('%t', @config['imgmath_options']['format']). sub('%o', File.join(math_dir, "_gen_#{key}.#{@config['imgmath_options']['format']}")). sub('%O', File.join(math_dir, "_gen_#{key}")). sub('%p', page.to_s) end out, status = Open3.capture2e(*args) @@ -211,9 +212,10 @@ raise CompileError end end end end + # rubocop:enable Metrics/BlockLength end def make_math_images_dvipng(dir, tex_path, math_dir) Dir.chdir(dir) do dvi_path = '__IMGMATH__.dvi'