Class: MarkdownConverter::HTMLwithSyntaxHighlight

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Defined in:
lib/gitdocs/markdown_converter.rb

Instance Method Summary collapse

Instance Method Details

#block_code(code, language) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/gitdocs/markdown_converter.rb', line 11

def block_code(code, language)
 language = 'text' if language.blank?
 begin
   Pygments.highlight(code, :lexer => language, :formatter => 'html', :options => {:encoding => 'utf-8'})
 rescue
   Pygments.highlight(code, :lexer => 'text', :formatter => 'html', :options => {:encoding => 'utf-8'})
 end
end