Class: Jekyll::Converters::Markdown::KramdownParser

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/converters/markdown/kramdown_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ KramdownParser

Returns a new instance of KramdownParser



5
6
7
8
9
10
11
12
# File 'lib/jekyll/converters/markdown/kramdown_parser.rb', line 5

def initialize(config)
  require 'kramdown'
  @config = config
rescue LoadError
  STDERR.puts 'You are missing a library required for Markdown. Please run:'
  STDERR.puts '  $ [sudo] gem install kramdown'
  raise Errors::FatalException.new("Missing dependency: kramdown")
end

Instance Method Details

#convert(content) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jekyll/converters/markdown/kramdown_parser.rb', line 14

def convert(content)
  # Check for use of coderay
  if @config['kramdown']['use_coderay']
    %w[wrap line_numbers line_numbers_start tab_width bold_every css default_lang].each do |opt|
      key = "coderay_#{opt}"
      @config['kramdown'][key] = @config['kramdown']['coderay'][key] unless @config['kramdown'].key?(key)
    end
  end

  Kramdown::Document.new(content, Utils.symbolize_hash_keys(@config["kramdown"])).to_html
end