Sha256: b13b858ebd8a71ec9b68f4e4a6dfb1f77965971bb0f02dc9778cd6a77b2f487b

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

require 'kramdown'
require "awesome_print"

module Verku
  class Exporter
    class PDF < Base
      def export!
        locals = config.merge({ :contents => content })
        locals['copyright'].gsub!("(C)", "\\copyright{}")
        output = render_template(root_dir.join("_templates/pdf/layout.erb"), locals)
        File.open(root_dir.join(tex_file), 'w').write(output)

        puts "-- Exporting PDF"
        puts "   - Pass 1"; spawn_command ["xelatex", tex_file.to_s,]
        puts "   - Pass 2"; spawn_command ["xelatex", tex_file.to_s,]

        if config['status'] == 'final'
          puts "   - Pass 3 - Indexing"
          spawn_command ["makeindex #{name}.idx"]
          spawn_command ["makeglossaries #{name}.glo"] if File.exist?("#{name}.glo")
          spawn_command ["xelatex", tex_file.to_s,]
          spawn_command ["rm *ilg *ind "]
        end

        spawn_command ["rm *.glo *.idx *.log *.out *.toc *aux *ist"]
        spawn_command ["mv #{base_name("pdf")}.pdf #{output_name("pdf")}"]
        true

      rescue Exception => error
        handle_error(error)
        false
      end

      private
        def content
          source_list.map do |file|
            Kramdown::Document.new(
              read_content(file)[0],
              :latex_headers => %w{chapter section subsection subsubsection paragraph subparagraph}
            ).to_latex.fix_scenebreaks
            # PandocRuby.markdown(read_content(file)[0], "top-level-division" => 'chapter').to_latex.fix_scenebreaks
          end.join("\n\n")
        end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
verku-0.16.8 lib/verku/exporter/pdf.rb
verku-0.16.7 lib/verku/exporter/pdf.rb
verku-0.16.6 lib/verku/exporter/pdf.rb
verku-0.16.5 lib/verku/exporter/pdf.rb