Class: Jekyll::Converters::Markdown::RedcarpetParser
- Inherits:
-
Object
- Object
- Jekyll::Converters::Markdown::RedcarpetParser
- Defined in:
- lib/jekyll/converters/markdown/redcarpet_parser.rb
Defined Under Namespace
Modules: CommonMethods, WithPygments, WithoutPygments
Instance Method Summary collapse
- #convert(content) ⇒ Object
-
#initialize(config) ⇒ RedcarpetParser
constructor
A new instance of RedcarpetParser.
Constructor Details
#initialize(config) ⇒ RedcarpetParser
Returns a new instance of RedcarpetParser.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/jekyll/converters/markdown/redcarpet_parser.rb', line 40 def initialize(config) require 'redcarpet' @config = config @redcarpet_extensions = {} @config['redcarpet']['extensions'].each { |e| @redcarpet_extensions[e.to_sym] = true } @renderer ||= if @config['pygments'] Class.new(Redcarpet::Render::HTML) do include WithPygments end else Class.new(Redcarpet::Render::HTML) do include WithoutPygments end end rescue LoadError STDERR.puts 'You are missing a library required for Markdown. Please run:' STDERR.puts ' $ [sudo] gem install redcarpet' raise FatalException.new("Missing dependency: redcarpet") end |
Instance Method Details
#convert(content) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/jekyll/converters/markdown/redcarpet_parser.rb', line 61 def convert(content) @redcarpet_extensions[:fenced_code_blocks] = !@redcarpet_extensions[:no_fenced_code_blocks] @renderer.send :include, Redcarpet::Render::SmartyPants if @redcarpet_extensions[:smart] markdown = Redcarpet::Markdown.new(@renderer.new(@redcarpet_extensions), @redcarpet_extensions) markdown.render(content) end |