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.
16 17 18 19 20 21 22 |
# File 'lib/jekyll/converters/markdown/kramdown_parser.rb', line 16 def initialize(config) @main_fallback_highlighter = config["highlighter"] || "rouge" @config = config["kramdown"] || {} @highlighter = nil setup load_dependencies end |
Instance Method Details
#convert(content) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/jekyll/converters/markdown/kramdown_parser.rb', line 39 def convert(content) document = Kramdown::Document.new(content, @config) html_output = document.to_html if @config["show_warnings"] document.warnings.each do |warning| Jekyll.logger.warn "Kramdown warning:", warning end end html_output 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.
31 32 33 34 35 36 37 |
# File 'lib/jekyll/converters/markdown/kramdown_parser.rb', line 31 def setup @config["syntax_highlighter"] ||= highlighter @config["syntax_highlighter_opts"] ||= {} @config["syntax_highlighter_opts"]["guess_lang"] = @config["guess_lang"] @config["coderay"] ||= {} # XXX: Legacy. modernize_coderay_config end |