Class: Markdown::Pandoc
- Inherits:
-
Object
- Object
- Markdown::Pandoc
- Defined in:
- lib/jekyll-pandoc.rb
Constant Summary collapse
- DEFAULT_EXTENSIONS =
[]
- DEFAULT_FORMAT =
'html5'
Instance Method Summary collapse
- #config_option(key, default = nil) ⇒ Object
- #convert(content) ⇒ Object
-
#initialize(config) ⇒ Pandoc
constructor
A new instance of Pandoc.
Constructor Details
#initialize(config) ⇒ Pandoc
Returns a new instance of Pandoc.
7 8 9 10 11 |
# File 'lib/jekyll-pandoc.rb', line 7 def initialize(config) Jekyll::External.require_with_graceful_fail "pandoc-ruby" @config = config end |
Instance Method Details
#config_option(key, default = nil) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/jekyll-pandoc.rb', line 22 def config_option(key, default=nil) if @config['pandoc'] @config.fetch('pandoc', {}).fetch(key, default) else default end end |
#convert(content) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/jekyll-pandoc.rb', line 13 def convert(content) extensions = config_option('extensions', DEFAULT_EXTENSIONS) format = config_option('format', DEFAULT_FORMAT) content = PandocRuby.new(content, *extensions).send("to_#{format}") raise Erros::FatalException, "Conversion returned empty string" unless content.length > 0 content end |