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

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

Constant Summary collapse

CODERAY_DEFAULTS =
{
  "css"               => "style",
  "bold_every"        => 10,
  "line_numbers"      => "inline",
  "line_number_start" => 1,
  "tab_width"         => 4,
  "wrap"              => "div"
}

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ KramdownParser

Returns a new instance of KramdownParser.



17
18
19
20
21
22
# File 'lib/jekyll/converters/markdown/kramdown_parser.rb', line 17

def initialize(config)
  Jekyll::External.require_with_graceful_fail "kramdown"
  @main_fallback_highlighter = config["highlighter"] || "rogue"
  @config = config["kramdown"] || {}
  setup
end

Instance Method Details

#convert(content) ⇒ Object



37
38
39
# File 'lib/jekyll/converters/markdown/kramdown_parser.rb', line 37

def convert(content)
  Kramdown::Document.new(content, @config).to_html
end

#setupObject

Setup and normalize the configuration:

* Create Kramdown if it doesn't exist.
* Set syntax_highlighter, detecting enable_coderay and merging highlighter if none.
* Merge kramdown[coderay] into syntax_highlighter_opts stripping coderay_.
* Make sure `syntax_highlighter_opts` exists.


30
31
32
33
34
35
# File 'lib/jekyll/converters/markdown/kramdown_parser.rb', line 30

def setup
  @config["syntax_highlighter"] ||= highlighter
  @config["syntax_highlighter_opts"] ||= {}
  @config["coderay"] ||= {} # XXX: Legacy.
  modernize_coderay_config
end