Sha256: e58a81cac797578313727a60862b226e6c31d26d4e6443bf9f8eca9f0b6e7c52
Contents?: true
Size: 1.62 KB
Versions: 3
Compression:
Stored size: 1.62 KB
Contents
require 'kramdown' module Bookmaker module Parser class PDF < Base def content raw = [] entries.keys.each do |chapter| title = (chapter.empty?) ? "Untitled" : chapter.split('_')[1] raw << "\\Chapter{#{title.gsub('-',' ')}}\n\n" entries[chapter].each do |section| s = read_content(section)[0] raw << "#{s}\n\n* * *" end end raw end def parse puts "-- Exporting PDF" locals = config.merge({ :contents => parse_layout(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 " - Pass 1" spawn_command ["xelatex", tex_file.to_s,] puts " - Pass 2" spawn_command ["xelatex", tex_file.to_s,] if config['is_final'].to_i == 0 puts " - Pass 3 - Indexing" spawn_command ["makeindex #{name}.idx"] # spawn_command ["makeglossaries #{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 #{name}.pdf output/#{name}.pdf"] true rescue Exception p $!, $@ false end def parse_layout(text) text = text.join("\n\n") text.gsub!('* * *', "\n\n\\pbreak{}\n\n") end def tex_file root_dir.join("output/#{name}.tex") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bookmaker-0.6.0 | lib/bookmaker/parser/pdf.rb |
bookmaker-0.5.5 | lib/bookmaker/parser/pdf.rb |
bookmaker-0.5.2 | lib/bookmaker/parser/pdf.rb |