Class: Blogdoor::Converter::BlockCodeWithFilename

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Defined in:
lib/blogdoor/converter.rb

Constant Summary collapse

INDENT =
" " * 2

Instance Method Summary collapse

Instance Method Details

#block_code(code, metadata) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/blogdoor/converter.rb', line 18

def block_code(code, )
  language, filename = .split(":") if 
  rows = []
  rows << %(<div class="code-block">)
  if filename
    rows << %(#{INDENT}<div class="code-header">)
    rows << %(#{INDENT * 2}<span>#{filename}</span>)
    rows << %(#{INDENT}</div>)
  end
  rows << %(#{INDENT}<div class="code-body">)
  rows << %(#{INDENT * 2}#{Pygments.highlight(code, lexer: language)})
  rows << %(#{INDENT}</div>)
  rows << %(</div>)
  rows.join("\n")
end