Commit 8b834379 authored by jplang's avatar jplang

Helper methods to find out if a given language is supported (#25503).

Patch by Jan Schulz-Hofen.

git-svn-id: https://svn.redmine.org/redmine/trunk@16501 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent fced8b8e
......@@ -40,6 +40,16 @@ module Redmine
rescue
ERB::Util.h(text)
end
def language_supported?(language)
if highlighter.respond_to? :language_supported?
highlighter.language_supported? language
else
true
end
rescue
false
end
end
module CodeRay
......@@ -58,6 +68,12 @@ module Redmine
def highlight_by_language(text, language)
::CodeRay.scan(text, language).html(:wrap => :span)
end
def language_supported?(language)
::CodeRay::Scanners.list.include?(language.to_s.downcase.to_sym)
rescue
false
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment