module JekyllPandocMultipleFormats::ConverterMethods
When included in the correspondant markdown class this module redefines the three needed Converter instance methods
Public Class Methods
included(base)
click to toggle source
# File lib/jekyll-pandoc-multiple-formats-jekyll34/converter.rb, line 44 def self.included(base) base.class_eval do # Just return html5 def convert(content) flags = "#{@config['pandoc']['flags']} #{@config['pandoc']['site_flags']}" output = '' Dir::chdir(@config['source']) do Open3::popen3("pandoc -t html5 #{flags}") do |stdin, stdout, stderr, thread| stdin.puts content stdin.close output = stdout.read.strip STDERR.print stderr.read # Wait for the process to finish thread.value end end output end def matches(ext) rgx = '(' + @config['markdown_ext'].gsub(',','|') +')' ext =~ Regexp.new(rgx, Regexp::IGNORECASE) end def output_ext(ext) '.html' end end end
Public Instance Methods
convert(content)
click to toggle source
Just return html5
# File lib/jekyll-pandoc-multiple-formats-jekyll34/converter.rb, line 47 def convert(content) flags = "#{@config['pandoc']['flags']} #{@config['pandoc']['site_flags']}" output = '' Dir::chdir(@config['source']) do Open3::popen3("pandoc -t html5 #{flags}") do |stdin, stdout, stderr, thread| stdin.puts content stdin.close output = stdout.read.strip STDERR.print stderr.read # Wait for the process to finish thread.value end end output end
matches(ext)
click to toggle source
# File lib/jekyll-pandoc-multiple-formats-jekyll34/converter.rb, line 67 def matches(ext) rgx = '(' + @config['markdown_ext'].gsub(',','|') +')' ext =~ Regexp.new(rgx, Regexp::IGNORECASE) end
output_ext(ext)
click to toggle source
# File lib/jekyll-pandoc-multiple-formats-jekyll34/converter.rb, line 72 def output_ext(ext) '.html' end