summaryrefslogtreecommitdiffstats
path: root/lib/redmine/syntax_highlighting.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-05-04 10:26:31 +0000
committerGo MAEDA <maeda@farend.jp>2019-05-04 10:26:31 +0000
commit5b5298bac05ac272d6aafee73990d6b098c35bce (patch)
treee2ed1143af2282e087657843cc601ff2a1e1cc0e /lib/redmine/syntax_highlighting.rb
parentb4562c3989804da8214211fa34221fd8e8067b8e (diff)
downloadredmine-5b5298bac05ac272d6aafee73990d6b098c35bce.tar.gz
redmine-5b5298bac05ac272d6aafee73990d6b098c35bce.zip
Merged r18122 from trunk to 4.0-stable (#29259).
git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@18123 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/syntax_highlighting.rb')
-rw-r--r--lib/redmine/syntax_highlighting.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/redmine/syntax_highlighting.rb b/lib/redmine/syntax_highlighting.rb
index 400f805ec..6232228ce 100644
--- a/lib/redmine/syntax_highlighting.rb
+++ b/lib/redmine/syntax_highlighting.rb
@@ -50,6 +50,14 @@ module Redmine
rescue
false
end
+
+ def filename_supported?(filename)
+ if highlighter.respond_to? :filename_supported?
+ highlighter.filename_supported? filename
+ else
+ false
+ end
+ end
end
module Rouge
@@ -99,7 +107,11 @@ module Redmine
def language_supported?(language)
find_lexer(language.to_s.downcase) ? true : false
end
-
+
+ def filename_supported?(filename)
+ !::Rouge::Lexer.guesses(:filename => filename).empty?
+ end
+
private
# Alias names used by CodeRay and not supported by Rouge
LANG_ALIASES = {