Class: Middleman::Renderers::MiddlemanKramdownHTML

Inherits:
Kramdown::Converter::Html
  • Object
show all
Defined in:
lib/middleman-core/renderers/kramdown.rb

Overview

Custom Kramdown renderer that uses our helpers for images and links

Instance Method Summary collapse

Instance Method Details

#convert_a(el, indent) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/middleman-core/renderers/kramdown.rb', line 28

def convert_a(el, indent)
  content = inner(el, indent)

  if el.attr['href'] =~ /\Amailto:/
    mail_addr = el.attr['href'].sub(/\Amailto:/, '')
    href = obfuscate('mailto') << ":" << obfuscate(mail_addr)
    content = obfuscate(content) if content == mail_addr
    return %Q{<a href="#{href}">#{content}</a>}
  end

  attr = el.attr.dup
  link = attr.delete('href')
  middleman_app.link_to(content, link, attr)
end

#convert_img(el, indent) ⇒ Object



21
22
23
24
25
26
# File 'lib/middleman-core/renderers/kramdown.rb', line 21

def convert_img(el, indent)
  attrs = el.attr.dup

  link = attrs.delete('src')
  middleman_app.image_tag(link, attrs)
end