Module: Redmine::SyntaxHighlighting::CodeRay

Defined in:
lib/redmine/syntax_highlighting.rb

Class Method Summary collapse

Class Method Details

.highlight_by_filename(text, filename) ⇒ Object

Highlights text as the content of filename Should not return line numbers nor outer pre tag


51
52
53
54
# File 'lib/redmine/syntax_highlighting.rb', line 51

def highlight_by_filename(text, filename)
  language = ::CodeRay::FileType[filename]
  language ? ::CodeRay.scan(text, language).html(:break_lines => true) : ERB::Util.h(text)
end

.highlight_by_language(text, language) ⇒ Object

Highlights text using language syntax Should not return outer pre tag


58
59
60
# File 'lib/redmine/syntax_highlighting.rb', line 58

def highlight_by_language(text, language)
  ::CodeRay.scan(text, language).html(:wrap => :span)
end