Class: Schnitzelpress::MarkdownRenderer
- Inherits:
-
Redcarpet::Render::HTML
- Object
- Redcarpet::Render::HTML
- Schnitzelpress::MarkdownRenderer
- Includes:
- Redcarpet::Render::SmartyPants
- Defined in:
- lib/schnitzelpress/markdown_renderer.rb
Instance Method Summary collapse
- #block_code(code, language) ⇒ Object
- #escape_html(html) ⇒ Object
- #image(link, title, alt_text) ⇒ Object
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::Providers.get(link) %q(<div class="embedded %s %s">%s</div>) % [.type, .provider_name.parameterize, .html] rescue OEmbed::NotFound %q(<img src="%s" title="%s" alt="%s"/>) % [link, escape_html(title), escape_html(alt_text)] end |