class Middleman::Renderers::MiddlemanKramdownHTML

Custom Kramdown renderer that uses our helpers for images and links

Public Instance Methods

convert_a(el, indent) click to toggle source
# File lib/middleman-core/renderers/kramdown.rb, line 35
def convert_a(el, indent)
  content = inner(el, indent)

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

  attr = el.attr.dup
  link = attr.delete('href')

  # options to link_to are expected to be symbols, but in Markdown
  # everything is a string.
  attr.transform_keys!(&:to_sym)

  scope.link_to(content, link, attr)
end
convert_img(el, _) click to toggle source
# File lib/middleman-core/renderers/kramdown.rb, line 28
def convert_img(el, _)
  attrs = el.attr.dup

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