Sha256: e6c3690d34ba29dcbae3181ef4594e0d892de90b93afe378c38026c93be40e3b
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
require 'kramdown' module Verku module Parser class PDF < Base def content raw = [] entries.keys.each do |chapter| title = (chapter.empty?) ? "Untitled" : chapter.split('_')[1] title = 'Untitled' if title.nil? raw << "\\Chapter{#{title.gsub('-',' ')}}\n\n" entries[chapter].each do |section| s = read_content(section)[0].to_latex.gsub(/\$(\\index\{[^\$]*?\})\$/) {"#{$1}"} 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 builds/#{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("builds/#{name}.tex") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
verku-0.8.1.0 | lib/verku/parser/pdf.rb |
verku-0.8.0.p | lib/verku/parser/pdf.rb |