Mercurial > hg > soundsoftware-site
comparison lib/redmine/syntax_highlighting.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | cbb26bc654de |
children | 622f24f53b42 |
comparison
equal
deleted
inserted
replaced
929:5f33065ddc4b | 1115:433d4f72a19b |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2011 Jean-Philippe Lang | 2 # Copyright (C) 2006-2012 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
38 class << self | 38 class << self |
39 # Highlights +text+ as the content of +filename+ | 39 # Highlights +text+ as the content of +filename+ |
40 # Should not return line numbers nor outer pre tag | 40 # Should not return line numbers nor outer pre tag |
41 def highlight_by_filename(text, filename) | 41 def highlight_by_filename(text, filename) |
42 language = ::CodeRay::FileType[filename] | 42 language = ::CodeRay::FileType[filename] |
43 language ? ::CodeRay.scan(text, language).html : ERB::Util.h(text) | 43 language ? ::CodeRay.scan(text, language).html(:break_lines => true) : ERB::Util.h(text) |
44 end | 44 end |
45 | 45 |
46 # Highlights +text+ using +language+ syntax | 46 # Highlights +text+ using +language+ syntax |
47 # Should not return outer pre tag | 47 # Should not return outer pre tag |
48 def highlight_by_language(text, language) | 48 def highlight_by_language(text, language) |
49 ::CodeRay.scan(text, language).html(:line_numbers => :inline, :line_number_anchors => false, :wrap => :span) | 49 ::CodeRay.scan(text, language).html(:wrap => :span) |
50 end | 50 end |
51 end | 51 end |
52 end | 52 end |
53 end | 53 end |
54 | 54 |