Class: Jekyll::Converters::Markdown::KramdownParser
- Inherits:
-
Object
- Object
- Jekyll::Converters::Markdown::KramdownParser
- 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" }.freeze
Instance Method Summary collapse
- #convert(content) ⇒ Object
-
#initialize(config) ⇒ KramdownParser
constructor
A new instance of KramdownParser.
-
#setup ⇒ Object
Setup and normalize the configuration: * Create Kramdown if it doesn’t exist.
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"] || "rouge" @config = config["kramdown"] || {} setup end |
Instance Method Details
#convert(content) ⇒ Object
38 39 40 |
# File 'lib/jekyll/converters/markdown/kramdown_parser.rb', line 38 def convert(content) Kramdown::Document.new(content, @config).to_html end |
#setup ⇒ Object
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 36 |
# 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 make_accessible end |