class Object

Public Instance Methods

convert_codeblock(element, indent) click to toggle source

Transform markdown code blocks into HTML with syntax highlighting based on Pygments

@param element [Kramdown::Element]

element containing the code block

@param indent [Fixnum]

number of indent spaces (not used here)

@return [String]

HTML for highlighted code block
# File lib/slowdown_html.rb, line 15
def convert_codeblock(element, indent)
  attribute = element.attr.dup
  code = element.value
  language = extract_code_language!(attribute)

  options = {:stripall => true}
  options[:startinline] = true if language == 'php'

  Pygments.highlight(code, :lexer => language, :options => options)
end