From bd8e4cd19d43c3c29dc7250a054b9a08eff405fd Mon Sep 17 00:00:00 2001 From: Mischa The Evil Date: Sun, 28 May 2017 06:50:15 +0200 Subject: [PATCH 2/4] Pull-up retrieve_supported_languages private class method. --- lib/redmine/syntax_highlighting.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/redmine/syntax_highlighting.rb b/lib/redmine/syntax_highlighting.rb index 6d0eab3..580ed68 100644 --- a/lib/redmine/syntax_highlighting.rb +++ b/lib/redmine/syntax_highlighting.rb @@ -55,6 +55,15 @@ module Redmine module CodeRay require 'coderay' + def self.retrieve_supported_languages + ::CodeRay::Scanners.list + + # Add CodeRay scanner aliases + ::CodeRay::Scanners.plugin_hash.keys.map(&:to_sym) - + # Remove internal CodeRay scanners + %w(debug default raydebug scanner).map(&:to_sym) + end + private_class_method :retrieve_supported_languages + class << self # Highlights +text+ as the content of +filename+ # Should not return line numbers nor outer pre tag @@ -70,10 +79,7 @@ module Redmine end def language_supported?(language) - supported_languages = - ::CodeRay::Scanners.list + - ::CodeRay::Scanners.plugin_hash.keys.map(&:to_sym) - - %w(debug default raydebug scanner).map(&:to_sym) + supported_languages = retrieve_supported_languages supported_languages.include?(language.to_s.downcase.to_sym) rescue false -- 1.9.1