Sha256: 124019029772a0ac718f4b4d9da835388a7e8d70edce3eb536cc93da9a107069

Contents?: true

Size: 695 Bytes

Versions: 18

Compression:

Stored size: 695 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::Text

        # 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

18 entries across 18 versions & 1 rubygems

Version Path
rouge-0.4.0 lib/rouge/plugins/redcarpet.rb
rouge-0.3.10 lib/rouge/plugins/redcarpet.rb
rouge-0.3.9 lib/rouge/plugins/redcarpet.rb
rouge-0.3.8 lib/rouge/plugins/redcarpet.rb
rouge-0.3.7 lib/rouge/plugins/redcarpet.rb
rouge-0.3.6 lib/rouge/plugins/redcarpet.rb
rouge-0.3.5 lib/rouge/plugins/redcarpet.rb
rouge-0.3.4 lib/rouge/plugins/redcarpet.rb
rouge-0.3.3 lib/rouge/plugins/redcarpet.rb
rouge-0.3.2 lib/rouge/plugins/redcarpet.rb
rouge-0.3.1 lib/rouge/plugins/redcarpet.rb
rouge-0.3.0 lib/rouge/plugins/redcarpet.rb
rouge-0.2.15 lib/rouge/plugins/redcarpet.rb
rouge-0.2.14 lib/rouge/plugins/redcarpet.rb
rouge-0.2.13 lib/rouge/plugins/redcarpet.rb
rouge-0.2.12 lib/rouge/plugins/redcarpet.rb
rouge-0.2.11 lib/rouge/plugins/redcarpet.rb
rouge-0.2.10 lib/rouge/plugins/redcarpet.rb