Module: Redmine::SyntaxHighlighting

Defined in:
lib/redmine/syntax_highlighting.rb

Overview

Since:

  • 1.0.0

Defined Under Namespace

Modules: Rouge

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.highlighterObject

Returns the value of attribute highlighter



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

def highlighter
  @highlighter
end

Class Method Details

.highlight_by_filename(text, filename) ⇒ Object

Since:

  • 2.5.0



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

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

.highlight_by_language(text, language) ⇒ Object

Since:

  • 2.5.0



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

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

.language_supported?(language) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 3.2.6



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

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