Class: Codemerger::HTMLwithAlbino
- Inherits:
-
Redcarpet::Render::HTML
- Object
- Redcarpet::Render::HTML
- Codemerger::HTMLwithAlbino
- Includes:
- Redcarpet::Render::SmartyPants
- Defined in:
- lib/codemerger/merger.rb
Instance Method Summary collapse
Instance Method Details
#block_code(code, language) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/codemerger/merger.rb', line 26 def block_code(code, language) if language Albino.new(code, language).colorize({O:"linenos=table,encoding=utf-8"}) else %Q{<pre><code>#{code}</code></pre>} end end |
#block_html(raw_html) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/codemerger/merger.rb', line 15 def block_html(raw_html) @markdown ||= Redcarpet::Markdown.new(HTMLwithAlbino.new, :autolink => true, :space_after_headers => true, :superscript => true, :fenced_code_blocks => true, :tables => true, :no_intra_emphasis => true) m,tag,attrs,content = *(raw_html.match(/<([a-z]+)(.*?)>(.*)<\/\1>/m)) result = @markdown.render(content) %Q{<#{tag}#{attrs}> #{result} </#{tag}> } end |
#code(code, language) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/codemerger/merger.rb', line 8 def code(code, language) if language Albino.new(code, language).colorize({O:"linenos=table,encoding=utf-8"}) else %Q{<pre><code>#{code}</code></pre>} end end |