Class: Schnitzelpress::MarkdownRenderer

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Includes:
Redcarpet::Render::SmartyPants
Defined in:
lib/schnitzelpress/markdown_renderer.rb

Instance Method Summary collapse

Instance Method Details

#block_code(code, language) ⇒ Object



5
6
7
# File 'lib/schnitzelpress/markdown_renderer.rb', line 5

def block_code(code, language)
  CodeRay.highlight(code, language)
end

#escape_html(html) ⇒ Object



16
17
18
# File 'lib/schnitzelpress/markdown_renderer.rb', line 16

def escape_html(html)
  Rack::Utils.escape_html(html)
end

#image(link, title, alt_text) ⇒ Object



9
10
11
12
13
14
# File 'lib/schnitzelpress/markdown_renderer.rb', line 9

def image(link, title, alt_text)
  oembed = OEmbed::Providers.get(link)
  %q(<div class="embedded %s %s">%s</div>) % [oembed.type, oembed.provider_name.parameterize, oembed.html]
rescue OEmbed::NotFound
  %q(<img src="%s" title="%s" alt="%s"/>) % [link, escape_html(title), escape_html(alt_text)]
end