Module: Rouge::Plugins::CommonMark

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

Instance Method Summary collapse

Instance Method Details

#code_block(code, language) ⇒ Object


9
10
11
12
13
14
# File 'lib/rouge/plugins/common_mark.rb', line 9

def code_block(code, language)
  lexer = Lexer.find_fancy(language, code) || Lexers::PlainText

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

#rouge_formatter(lexer) ⇒ Object

override this method for custom formatting behavior


17
18
19
# File 'lib/rouge/plugins/common_mark.rb', line 17

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