Class: Middleman::Renderers::RedcarpetTemplate

Inherits:
Tilt::RedcarpetTemplate::Redcarpet2
  • Object
show all
Defined in:
lib/middleman-core/renderers/redcarpet.rb

Constant Summary collapse

ALIASES =

because tilt has decided to convert these in the wrong direction

{
  :escape_html => :filter_html
}

Instance Method Summary collapse

Instance Method Details

#generate_rendererObject

Overwrite built-in Tilt version. Don’t overload :renderer option with smartypants Support renderer-level options



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/middleman-core/renderers/redcarpet.rb', line 17

def generate_renderer
  return options.delete(:renderer) if options.has_key?(:renderer)

  covert_options_to_aliases!

  # Pick a renderer
  renderer = MiddlemanRedcarpetHTML

  # Support SmartyPants
  if options.delete(:smartypants)
    renderer = Class.new(renderer) do
      include ::Redcarpet::Render::SmartyPants
    end
  end

  # Renderer Options
  possible_render_opts = [:filter_html, :no_images, :no_links, :no_styles, :safe_links_only, :with_toc_data, :hard_wrap, :xhtml, :prettify, :link_attributes]

  render_options = possible_render_opts.inject({}) do |sum, opt|
    sum[opt] = options.delete(opt) if options.has_key?(opt)
    sum
  end

  renderer.new(render_options)
end