Module: Redmine::SyntaxHighlighting

Defined in:
lib/redmine/syntax_highlighting.rb

Defined Under Namespace

Modules: Rouge

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.highlighterObject

Returns the value of attribute highlighter


23
24
25
# File 'lib/redmine/syntax_highlighting.rb', line 23

def highlighter
  @highlighter
end

Class Method Details

.filename_supported?(filename) ⇒ Boolean

Returns:

  • (Boolean)

55
56
57
58
59
60
61
# File 'lib/redmine/syntax_highlighting.rb', line 55

def filename_supported?(filename)
  if highlighter.respond_to? :filename_supported?
    highlighter.filename_supported? filename
  else
    false
  end
end

.highlight_by_filename(text, filename) ⇒ Object


33
34
35
36
37
# File 'lib/redmine/syntax_highlighting.rb', line 33

def highlight_by_filename(text, filename)
  highlighter.highlight_by_filename(text, filename)
rescue
  ERB::Util.h(text)
end

.highlight_by_language(text, language) ⇒ Object


39
40
41
42
43
# File 'lib/redmine/syntax_highlighting.rb', line 39

def highlight_by_language(text, language)
  highlighter.highlight_by_language(text, language)
rescue
  ERB::Util.h(text)
end

.language_supported?(language) ⇒ Boolean

Returns:

  • (Boolean)

45
46
47
48
49
50
51
52
53
# File 'lib/redmine/syntax_highlighting.rb', line 45

def language_supported?(language)
  if highlighter.respond_to? :language_supported?
    highlighter.language_supported? language
  else
    true
  end
rescue
  false
end