Class: Monograph::MarkdownRenderer
- Inherits:
-
Redcarpet::Render::HTML
- Object
- Redcarpet::Render::HTML
- Monograph::MarkdownRenderer
- Defined in:
- lib/monograph/markdown_renderer.rb
Instance Method Summary collapse
- #block_code(code, language) ⇒ Object
-
#image(src, title, alt) ⇒ Object
Images need positioning ability.
- #paragraph(text) ⇒ Object
Instance Method Details
#block_code(code, language) ⇒ Object
4 5 6 |
# File 'lib/monograph/markdown_renderer.rb', line 4 def block_code(code, language) Pygments.highlight(code, :lexer => language) end |
#image(src, title, alt) ⇒ Object
Images need positioning ability
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/monograph/markdown_renderer.rb', line 18 def image(src, title, alt) if alt.gsub!(/\*([\w\-\s]+)\z/, '') klass = "imgcontainer #{$1}" else klass = nil end String.new.tap do |s| s << "<span class='#{klass}'>" if klass == "imgcontainer captioned" s << "<span class='image'><img src='#{src}' title='#{title}' alt='#{alt}'></span>" s << "<span class='caption'>#{alt}</span>" else s << "<img src='#{src}' title='#{title}' alt='#{alt}'>" end s << "</span>" end end |
#paragraph(text) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/monograph/markdown_renderer.rb', line 8 def paragraph(text) klass = '' text.gsub!(/\A\[([A-Z]+)\]/) do klass = " class='#{$1.downcase}'" '' end "<p#{klass}>#{text}</p>" end |