Sha256: 797418ebcbfab4c44f9d6dab935a3aa069ab1d96cc3266ff2393ba556cf27043

Contents?: true

Size: 754 Bytes

Versions: 2

Compression:

Stored size: 754 Bytes

Contents

# Replace method to use Pygments for syntax highlighting instead of Coderay

Kramdown::Converter::SlodownHtml.class_eval do

  # 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
  #
  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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slodown.py-1.0.1 lib/slowdown_html.rb
slodown.py-1.0.0 lib/slowdown_html.rb