Module: Rouge::Plugins::Redcarpet
- Defined in:
- lib/rouge/plugins/redcarpet.rb
Instance Method Summary collapse
Instance Method Details
#block_code(code, language) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rouge/plugins/redcarpet.rb', line 8 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 |