Module: Rouge::Plugins::Redcarpet

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

Instance Method Summary collapse

Instance Method Details

#block_code(code, language) ⇒ Object


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

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! %r/^    /, "\t"
  end

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

#rouge_formatter(lexer) ⇒ Object

override this method for custom formatting behavior


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

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