lib/review/makerhelper.rb in review-4.1.0 vs lib/review/makerhelper.rb in review-4.2.0
- old
+ new
@@ -1,6 +1,6 @@
-# Copyright (c) 2012-2018 Yuto HAYAMIZU, Kenshi Muto
+# Copyright (c) 2012-2020 Yuto HAYAMIZU, 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".
@@ -110,10 +110,26 @@
\\fontsize{#{fontsize}}{#{lineheight}}\\selectfont
\\input{__IMGMATH_BODY__}
\\end{document}
EOB
+ hashes = File.readlines(File.join(math_dir, '__IMGMATH_BODY__.map')).sort.uniq
+ File.write(File.join(math_dir, '__IMGMATH_BODY__.map'), hashes.join)
+
+ File.open(File.join(math_dir, '__IMGMATH_BODY__.tex'), 'w') do |f|
+ File.open(File.join(math_dir, '__IMGMATH_BODY__.map')) do |map|
+ map.each_line do |l|
+ l.chomp!
+ f.puts "% #{l}"
+ f.puts File.read(File.join(math_dir, "__IMGMATH_BODY__#{l}.tex"))
+ File.unlink(File.join(math_dir, "__IMGMATH_BODY__#{l}.tex"))
+ f.puts '\\clearpage'
+ f.puts
+ end
+ end
+ end
+
math_dir = File.realpath(math_dir)
Dir.mktmpdir do |tmpdir|
FileUtils.cp([File.join(math_dir, '__IMGMATH_BODY__.tex'),
File.join(math_dir, '__IMGMATH_BODY__.map')],
tmpdir)
@@ -137,9 +153,10 @@
end
end
FileUtils.rm_f([File.join(math_dir, '__IMGMATH_BODY__.tex'),
File.join(math_dir, '__IMGMATH_BODY__.map')])
end
+ module_function :make_math_images
def make_math_images_pdfcrop(dir, tex_path, math_dir)
# rubocop:disable Metrics/BlockLength
Dir.chdir(dir) do
dvi_path = '__IMGMATH__.dvi'