Module: Rouge::Plugins::Redcarpet

Defined in:
lib/rouge/plugins/redcarpet.rb

Instance Method Summary collapse

Instance Method Details

#block_code(code, language) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rouge/plugins/redcarpet.rb', line 10

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 = rouge_formatter(lexer)
  formatter.format(lexer.lex(code))
end

#rouge_formatter(lexer) ⇒ Object

override this method for custom formatting behavior



25
26
27
# File 'lib/rouge/plugins/redcarpet.rb', line 25

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