Module: Jekyll::Converters::Markdown::RedcarpetParser::WithPygments

Includes:
CommonMethods
Defined in:
lib/jekyll/converters/markdown/redcarpet_parser.rb

Instance Method Summary collapse

Methods included from CommonMethods

#add_code_tags

Instance Method Details

#block_code(code, lang) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jekyll/converters/markdown/redcarpet_parser.rb', line 18

def block_code(code, lang)
  unless defined?(Pygments)
    Jekyll::External.require_with_graceful_fail("pygments")
  end
  lang = lang && lang.split.first || "text"
  add_code_tags(
    Pygments.highlight(
      code,
      {
        :lexer   => lang,
        :options => { :encoding => "utf-8" },
      }
    ),
    lang
  )
end