class Jekyll::Converters::Markdown::RedcarpetParser

Public Class Methods

new(config) click to toggle source
# File lib/jekyll/converters/markdown/redcarpet_parser.rb, line 62
def initialize(config)
  Jekyll::External.require_with_graceful_fail("redcarpet")
  @config = config
  @redcarpet_extensions = {}
  @config["redcarpet"]["extensions"].each do |e|
    @redcarpet_extensions[e.to_sym] = true
  end

  @renderer ||= class_with_proper_highlighter(@config["highlighter"])
end

Public Instance Methods

class_with_proper_highlighter(highlighter) click to toggle source
# File lib/jekyll/converters/markdown/redcarpet_parser.rb, line 73
def class_with_proper_highlighter(highlighter)
  Class.new(Redcarpet::Render::HTML) do
    case highlighter
    when "pygments"
      include WithPygments
    when "rouge"
      Jekyll::External.require_with_graceful_fail(%w(
        rouge rouge/plugins/redcarpet
      ))

      unless Gem::Version.new(Rouge.version) > Gem::Version.new("1.3.0")
        abort "Please install Rouge 1.3.0 or greater and try running Jekyll again."
      end

      include Rouge::Plugins::Redcarpet
      include CommonMethods
      include WithRouge
    else
      include WithoutHighlighting
    end
  end
end
convert(content) click to toggle source
# File lib/jekyll/converters/markdown/redcarpet_parser.rb, line 96
def convert(content)
  @redcarpet_extensions[:fenced_code_blocks] =        !@redcarpet_extensions[:no_fenced_code_blocks]
  if @redcarpet_extensions[:smart]
    @renderer.send :include, Redcarpet::Render::SmartyPants
  end
  markdown = Redcarpet::Markdown.new(
    @renderer.new(@redcarpet_extensions),
    @redcarpet_extensions
  )
  markdown.render(content)
end