Skip to content

Commit

Permalink
Merge pull request #1081 from kmuto/rename_mastertexfilename
Browse files Browse the repository at this point in the history
when generating a base file from layout.tex.erb, use `__REVIEW_BOOK__` instead of `book.tex` to use names like `book.re` as chapters
  • Loading branch information
takahashim authored Jul 19, 2018
2 parents e46092d + 35abb9c commit c904fbf
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/review/pdfmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def initialize
@basehookdir = nil
@logger = ReVIEW.logger
@input_files = Hash.new { |h, key| h[key] = '' }
@mastertex = '__REVIEW_BOOK__'
end

def system_with_info(*args)
Expand Down Expand Up @@ -178,7 +179,7 @@ def make_input_files(book, yamlfile)
def build_pdf
template = template_content
Dir.chdir(@path) do
File.open('./book.tex', 'wb') { |f| f.write(template) }
File.open("./#{@mastertex}.tex", 'wb') { |f| f.write(template) }

call_hook('hook_beforetexcompile')

Expand Down Expand Up @@ -214,20 +215,20 @@ def build_pdf
end

2.times do
system_or_raise("#{texcommand} #{texoptions} book.tex")
system_or_raise("#{texcommand} #{texoptions} #{@mastertex}.tex")
end

call_hook('hook_beforemakeindex')
if @config['pdfmaker']['makeindex'] && File.exist?('book.idx')
system_or_raise("#{makeindex_command} #{makeindex_options} book")
if @config['pdfmaker']['makeindex'] && File.exist?("#{@mastertex}.idx")
system_or_raise("#{makeindex_command} #{makeindex_options} #{@mastertex}")
end
call_hook('hook_aftermakeindex')

system_or_raise("#{texcommand} #{texoptions} book.tex")
system_or_raise("#{texcommand} #{texoptions} #{@mastertex}")
call_hook('hook_aftertexcompile')

if File.exist?('book.dvi')
system_or_raise("#{dvicommand} #{dvioptions} book.dvi")
if File.exist?("#{@mastertex}.dvi")
system_or_raise("#{dvicommand} #{dvioptions} #{@mastertex}.dvi")
call_hook('hook_afterdvipdf')
end
end
Expand Down Expand Up @@ -262,7 +263,7 @@ def generate_pdf(yamlfile)

build_pdf

FileUtils.cp(File.join(@path, 'book.pdf'), pdf_filepath)
FileUtils.cp(File.join(@path, "#{@mastertex}.pdf"), pdf_filepath)
ensure
remove_entry_secure @path unless @config['debug']
end
Expand Down

0 comments on commit c904fbf

Please sign in to comment.