Class: Jekyll::PandocGenerator
- Inherits:
-
Generator
- Object
- Generator
- Jekyll::PandocGenerator
- Defined in:
- lib/jekyll-pandoc-multiple-formats/generator.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
29 30 31 |
# File 'lib/jekyll-pandoc-multiple-formats/generator.rb', line 29 def config @config end |
#site ⇒ Object
Returns the value of attribute site.
29 30 31 |
# File 'lib/jekyll-pandoc-multiple-formats/generator.rb', line 29 def site @site end |
Instance Method Details
#generate(site) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/jekyll-pandoc-multiple-formats/generator.rb', line 31 def generate(site) @site ||= site @config ||= JekyllPandocMultipleFormats::Config.new(@site.config['pandoc']) return if @config.skip? # we create a single array of files @pandoc_files = [] @config.outputs.each_pair do |output, extra_flags| @site.posts.docs.each do |post| pandoc_file = PandocFile.new(@site, output, post) next unless pandoc_file.write @site.keep_files << pandoc_file.relative_path @pandoc_files << pandoc_file end @site.post_attr_hash('categories').each_pair do |title, posts| posts.sort! pandoc_file = PandocFile.new(@site, output, posts, title) if @site.keep_files.include? pandoc_file.relative_path puts "#{pandoc_file.relative_path} is a category file AND a post file" puts 'change the category name to fix this' next end next unless pandoc_file.write @site.keep_files << pandoc_file.relative_path @pandoc_files << pandoc_file end end @pandoc_files.each do |pandoc_file| # If output is PDF, we also create the imposed PDF if pandoc_file.pdf? if @config.imposition? imposed_file = JekyllPandocMultipleFormats::Imposition .new(pandoc_file.path, pandoc_file.papersize, pandoc_file.sheetsize, pandoc_file.signature) imposed_file.write @site.keep_files << imposed_file.relative_path(@site.dest) end # If output is PDF, we also create the imposed PDF if @config.binder? binder_file = JekyllPandocMultipleFormats::Binder .new(pandoc_file.path, pandoc_file.papersize, pandoc_file.sheetsize) binder_file.write @site.keep_files << binder_file.relative_path(@site.dest) end # Add covers to PDFs after building ready for print files if pandoc_file.has_cover? # Generate the cover next unless pandoc_file.pdf_cover! united_output = pandoc_file.path.gsub(/\.pdf\Z/, '-cover.pdf') united_file = JekyllPandocMultipleFormats::Unite .new(united_output, [pandoc_file.pdf_cover,pandoc_file.path]) if united_file.write # Replace the original file with the one with cover FileUtils.rm_f(pandoc_file.path) FileUtils.mv(united_output, pandoc_file.path) end end end end end |