Sha256: f987ea972f26864b6d5ac330f2fb4332b9150e39d646c78ba7069ba2e9f8e0e6

Contents?: true

Size: 700 Bytes

Versions: 7

Compression:

Stored size: 700 Bytes

Contents

# this file is not require'd from the root.  To use this plugin, run:
#
#    require 'rouge/plugins/redcarpet'

module Rouge
  module Plugins
    module Redcarpet
      def block_code(code, language)
        lexer = Lexer.find_fancy(language, code) || Lexers::PlainText

        # XXX HACK: Redcarpet strips hard tabs out of code blocks,
        # so we assume you're not using leading spaces that aren't tabs,
        # and just replace them here.
        if lexer.tag == 'make'
          code.gsub! /^    /, "\t"
        end

        formatter = Formatters::HTML.new(
          :css_class => "highlight #{lexer.tag}"
        )

        formatter.format(lexer.lex(code))
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rouge-1.2.0 lib/rouge/plugins/redcarpet.rb
rouge-1.1.0 lib/rouge/plugins/redcarpet.rb
rouge-0.5.4 lib/rouge/plugins/redcarpet.rb
rouge-0.5.3 lib/rouge/plugins/redcarpet.rb
rouge-0.5.2 lib/rouge/plugins/redcarpet.rb
rouge-0.5.1 lib/rouge/plugins/redcarpet.rb
rouge-0.5.0 lib/rouge/plugins/redcarpet.rb