class PBSimply::Processor::Pandoc
Pandoc
processor
Public Class Methods
new(config)
click to toggle source
Calls superclass method
PBSimply::new
# File lib/pbsimply.rb, line 869 def initialize(config) @pandoc_default_file = {} # -d @pandoc_default_file = { "to" => "html5", "standalone" => true } super end
Public Instance Methods
print_fileproc_msg(filename)
click to toggle source
Invoke pandoc, parse and format and write out.
# File lib/pbsimply.rb, line 905 def print_fileproc_msg(filename) STDERR.puts "#{filename} is going Pandoc." end
process_document(dir, filename, frontmatter, orig_filepath, ext, procdoc)
click to toggle source
# File lib/pbsimply.rb, line 909 def process_document(dir, filename, frontmatter, orig_filepath, ext, procdoc) doc = nil File.open(".pbsimply-defaultfiles.yaml", "w") {|f| YAML.dump(@pandoc_default_file, f)} File.open(".pbsimply-frontmatter.yaml", "w") {|f| YAML.dump(frontmatter, f)} # Go Pandoc pandoc_cmdline = ["pandoc"] pandoc_cmdline += ["-d", ".pbsimply-defaultfiles.yaml", "--metadata-file", ".pbsimply-frontmatter.yaml", "-M", "title:#{frontmatter["title"]}"] pandoc_cmdline += ["-f", frontmatter["input_format"]] if frontmatter["input_format"] pandoc_cmdline += [ procdoc ] IO.popen((pandoc_cmdline)) do |io| doc = io.read end # Abort if pandoc returns non-zero status if $?.exitstatus != 0 abort "Pandoc returns exit code #{$?.exitstatus}" end doc end
setup_config(dir)
click to toggle source
Calls superclass method
PBSimply#setup_config
# File lib/pbsimply.rb, line 880 def setup_config(dir) super @pandoc_default_file["template"] = @config["template"] if @config["css"] if @config["css"].kind_of?(String) @pandoc_default_file["css"] = [@config["css"]] elsif @config["css"].kind_of?(Array) @pandoc_default_file["css"] = @config["css"] else abort "css in Config should be a String or an Array." end end if @config["toc"] @pandoc_default_file["toc"] = true end if Hash === @config["pandoc_additional_options"] @pandoc_default_file.merge! @config["pandoc_additional_options"] end end
target_file_extensions()
click to toggle source
# File lib/pbsimply.rb, line 932 def target_file_extensions [".md", ".rst"] end