Module: Redmine::SyntaxHighlighting::CodeRay Deprecated

Defined in:
lib/redmine/syntax_highlighting.rb

Overview

Deprecated.

Removed at 4.0.0

Constant Summary collapse

SUPPORTED_LANGUAGES =
retrieve_supported_languages

Class Method Summary collapse

Class Method Details

.highlight_by_filename(text, filename) ⇒ Object

Highlights text as the content of filename Should not return line numbers nor outer pre tag

Since:

  • 1.0.0



72
73
74
75
# File 'lib/redmine/syntax_highlighting.rb', line 72

def highlight_by_filename(text, filename)
  language = ::CodeRay::FileType[filename]
  language ? ::CodeRay.scan(text, language).html(:break_lines => true) : ERB::Util.h(text)
end

.highlight_by_language(text, language) ⇒ Object

Highlights text using language syntax Should not return outer pre tag

Since:

  • 1.0.0



79
80
81
# File 'lib/redmine/syntax_highlighting.rb', line 79

def highlight_by_language(text, language)
  ::CodeRay.scan(text, language).html(:wrap => :span)
end

.language_supported?(language) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 3.2.6



83
84
85
86
87
# File 'lib/redmine/syntax_highlighting.rb', line 83

def language_supported?(language)
  SUPPORTED_LANGUAGES.include?(language.to_s.downcase.to_sym)
rescue
  false
end