Class: Middleman::Renderers::MiddlemanKramdownHTML
- Inherits:
-
Kramdown::Converter::Html
- Object
- Kramdown::Converter::Html
- Middleman::Renderers::MiddlemanKramdownHTML
- 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
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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, _) ⇒ Object
28 29 30 31 32 33 |
# 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 |