module Bunto::Converters::Markdown::RedcarpetParser::WithPygments

Public Instance Methods

block_code(code, lang) click to toggle source
# File lib/bunto/converters/markdown/redcarpet_parser.rb, line 16
def block_code(code, lang)
  Bunto::External.require_with_graceful_fail("pygments")
  lang = lang && lang.split.first || "text"
  add_code_tags(
    Pygments.highlight(
      code,
      {
        :lexer   => lang,
        :options => { :encoding => "utf-8" },
      }
    ),
    lang
  )
end