Class: Middleman::Renderers::MiddlemanRedcarpetHTML

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Defined in:
lib/middleman-core/renderers/redcarpet.rb

Overview

Custom Redcarpet renderer that uses our helpers for images and links

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ MiddlemanRedcarpetHTML

Returns a new instance of MiddlemanRedcarpetHTML.



56
57
58
59
60
# File 'lib/middleman-core/renderers/redcarpet.rb', line 56

def initialize(options={})
  @local_options = options.dup

  super
end

Instance Method Details

#image(link, title, alt_text) ⇒ Object



62
63
64
65
66
67
68
69
70
# File 'lib/middleman-core/renderers/redcarpet.rb', line 62

def image(link, title, alt_text)
  if !@local_options[:no_images]
    middleman_app.image_tag(link, :title => title, :alt => alt_text)
  else
    link_string = link.dup
    link_string << %Q{"#{title}"} if title && title.length > 0 && title != alt_text
    %Q{![#{alt_text}](#{link_string})}
  end
end


72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/middleman-core/renderers/redcarpet.rb', line 72

def link(link, title, content)
  if !@local_options[:no_links]
    attributes = { :title => title }
    attributes.merge!( @local_options[:link_attributes] ) if @local_options[:link_attributes]

    middleman_app.link_to(content, link, attributes )
  else
    link_string = link.dup
    link_string << %Q{"#{title}"} if title && title.length > 0 && title != alt_text
    %Q{[#{content}](#{link_string})}
  end
end