##// END OF EJS Templates
remove trailing white-spaces from lib/redmine/syntax_highlighting.rb...
Toshi MARUYAMA -
r7289:125ffb33d31b
parent child
Show More
@@ -1,27 +1,27
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2010 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 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.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module Redmine
18 module Redmine
19 module SyntaxHighlighting
19 module SyntaxHighlighting
20
20
21 class << self
21 class << self
22 attr_reader :highlighter
22 attr_reader :highlighter
23 delegate :highlight_by_filename, :highlight_by_language, :to => :highlighter
23 delegate :highlight_by_filename, :highlight_by_language, :to => :highlighter
24
24
25 def highlighter=(name)
25 def highlighter=(name)
26 if name.is_a?(Module)
26 if name.is_a?(Module)
27 @highlighter = name
27 @highlighter = name
@@ -30,11 +30,11 module Redmine
30 end
30 end
31 end
31 end
32 end
32 end
33
33
34 module CodeRay
34 module CodeRay
35 require 'coderay'
35 require 'coderay'
36 require 'coderay/helpers/file_type'
36 require 'coderay/helpers/file_type'
37
37
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
@@ -42,7 +42,7 module Redmine
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 : 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)
@@ -51,6 +51,6 module Redmine
51 end
51 end
52 end
52 end
53 end
53 end
54
54
55 SyntaxHighlighting.highlighter = 'CodeRay'
55 SyntaxHighlighting.highlighter = 'CodeRay'
56 end
56 end
General Comments 0
You need to be logged in to leave comments. Login now