Skip to content

Commit

Permalink
Merge pull request #1404 from kmuto/refactor-pdfmaker2
Browse files Browse the repository at this point in the history
generate_pdfのyaml依存を除く
  • Loading branch information
takahashim authored Oct 26, 2019
2 parents 7b69db0 + 90e5dc4 commit 6aa2bbc
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/review/pdfmaker.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2010-2018 Kenshi Muto and Masayoshi Takahashi
# Copyright (c) 2010-2019 Kenshi Muto and Masayoshi Takahashi
#
# This program is free software.
# You can distribute or modify this program under the terms of
Expand Down Expand Up @@ -153,20 +153,20 @@ def execute(*args)
end

begin
generate_pdf(yamlfile)
generate_pdf
rescue ApplicationError => e
raise if @config['debug']
error(e.message)
end
end

def make_input_files(book, yamlfile)
def make_input_files(book)
input_files = Hash.new { |h, key| h[key] = '' }
book.parts.each do |part|
if part.name.present?
@config['use_part'] = true
if part.file?
output_chaps(part.name, yamlfile)
output_chaps(part.name)
input_files['CHAPS'] << %Q(\\input{#{part.name}.tex}\n)
else
input_files['CHAPS'] << %Q(\\part{#{part.name}}\n)
Expand All @@ -175,7 +175,7 @@ def make_input_files(book, yamlfile)

part.chapters.each do |chap|
filename = File.basename(chap.path, '.*')
output_chaps(filename, yamlfile)
output_chaps(filename)
input_files['PREDEF'] << "\\input{#{filename}.tex}\n" if chap.on_predef?
input_files['CHAPS'] << "\\input{#{filename}.tex}\n" if chap.on_chaps?
input_files['APPENDIX'] << "\\input{#{filename}.tex}\n" if chap.on_appendix?
Expand Down Expand Up @@ -250,18 +250,18 @@ def build_pdf
end
end

def generate_pdf(yamlfile)
def generate_pdf
remove_old_file
erb_config
@path = build_path
begin
@compile_errors = nil

book = ReVIEW::Book.load(File.dirname(yamlfile))
book = ReVIEW::Book.load(@basedir)
book.config = @config
@converter = ReVIEW::Converter.new(book, ReVIEW::LATEXBuilder.new)

@input_files = make_input_files(book, yamlfile)
@input_files = make_input_files(book)

check_compile_status(@config['ignore-errors'])

Expand All @@ -285,7 +285,7 @@ def generate_pdf(yamlfile)
end
end

def output_chaps(filename, _yamlfile)
def output_chaps(filename)
@logger.info "compiling #{filename}.tex"
begin
@converter.convert(filename + '.re', File.join(@path, filename + '.tex'))
Expand Down

0 comments on commit 6aa2bbc

Please sign in to comment.