lib/softcover/builders/pdf.rb in softcover-0.6.10 vs lib/softcover/builders/pdf.rb in softcover-0.7.0

- old
+ new

@@ -1,39 +1,44 @@ module Softcover module Builders class Pdf < Builder include Softcover::Output + include Softcover::Utils def build!(options={}) if manifest.markdown? # Build the HTML to produce PolyTeX as a side-effect, # then update the manifest to reduce PDF generation # to a previously solved problem. Softcover::Builders::Html.new.build! self.manifest = Softcover::BookManifest.new(source: :polytex, origin: :markdown) end + + write_master_latex_file(manifest) + # Build the PolyTeX filename so it accepts both 'foo' and 'foo.tex'. basename = File.basename(manifest.filename, '.tex') book_filename = basename + '.tex' # In debug mode, execute `xelatex` and exit. if options[:debug] execute "#{xelatex} #{book_filename}" return # only gets called in test env elsif options[:'find-overfull'] tmp_name = book_filename.sub('.tex', '.tmp.tex') - # The we do things, code listings show up as "Overfull", but they're - # actually fine, so filter them out. + # The way we do things, code listings show up as "Overfull", but + # they're actually fine, so filter them out. filter_out_listings = "grep -v 3.22281pt" - # It's hard to correlate Overfull line numbers with source files, + # Because each chapter typically lives in a separate file, it's + # hard to correlate Overfull line numbers with lines in the source, # so we use grep's -A flag to provide some context instead. Authors - # can then use their text editors to find the corresponding place - # in the text. + # can then use their text editors' search function to find the + # corresponding place in the text. show_context = 'grep -A 3 "Overfull \hbox"' cmd = "xelatex #{tmp_name} | #{filter_out_listings} | #{show_context}" - execute cmd + silence_stream(STDERR) { execute cmd } return end polytex_filenames = manifest.pdf_chapter_filenames << book_filename polytex_filenames.each do |filename| @@ -64,10 +69,12 @@ pdf_cmd = options[:once] ? build_pdf : "#{build_pdf} ; #{build_pdf}" cmd = "#{pdf_cmd} ; #{rename_pdf(basename)}" # Here we use `system` when making a preview because the preview command # needs to run after the main PDF build. if options[:quiet] || options[:silent] - silence { options[:preview] ? system(cmd) : execute(cmd) } + silence_stream(STDERR) do + silence { options[:preview] ? system(cmd) : execute(cmd) } + end else options[:preview] ? system(cmd) : execute(cmd) end end \ No newline at end of file