class Blogdoor::Converter::BlockCodeWithFilename

Constants

INDENT

Public Instance Methods

block_code(code, metadata) click to toggle source
# File lib/blogdoor/converter.rb, line 18
def block_code(code, metadata)
  language, filename = metadata.split(":") if metadata
  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