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, WithRouge, WithoutHighlighting
Instance Method Summary collapse
- #class_with_proper_highlighter(highlighter) ⇒ Object
- #convert(content) ⇒ Object
-
#initialize(config) ⇒ RedcarpetParser
constructor
A new instance of RedcarpetParser.
Constructor Details
#initialize(config) ⇒ RedcarpetParser
Returns a new instance of RedcarpetParser.
56 57 58 59 60 61 62 63 |
# File 'lib/jekyll/converters/markdown/redcarpet_parser.rb', line 56 def initialize(config) External.require_with_graceful_fail("redcarpet") @config = config @redcarpet_extensions = {} @config['redcarpet']['extensions'].each { |e| @redcarpet_extensions[e.to_sym] = true } @renderer ||= class_with_proper_highlighter(@config['highlighter']) end |
Instance Method Details
#class_with_proper_highlighter(highlighter) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/jekyll/converters/markdown/redcarpet_parser.rb', line 65 def class_with_proper_highlighter(highlighter) case highlighter when "pygments" Class.new(Redcarpet::Render::HTML) do include WithPygments end when "rouge" Class.new(Redcarpet::Render::HTML) do 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 end else Class.new(Redcarpet::Render::HTML) do include WithoutHighlighting end end end |
#convert(content) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/jekyll/converters/markdown/redcarpet_parser.rb', line 93 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 |