Class: Jekyll::Converters::Markdown::RDiscountParser

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ RDiscountParser

Returns a new instance of RDiscountParser.



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

def initialize(config)
  require 'rdiscount'
  @config = config
  @rdiscount_extensions = @config['rdiscount']['extensions'].map { |e| e.to_sym }
rescue LoadError
  STDERR.puts 'You are missing a library required for Markdown. Please run:'
  STDERR.puts '  $ [sudo] gem install rdiscount'
  raise FatalException.new("Missing dependency: rdiscount")
end

Instance Method Details

#convert(content) ⇒ Object



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

def convert(content)
  rd = RDiscount.new(content, *@rdiscount_extensions)
  html = rd.to_html
  if @config['rdiscount']['toc_token']
    html = replace_generated_toc(rd, html, @config['rdiscount']['toc_token'])
  end
  html
end