Class: Hylite::Rouge
Instance Attribute Summary
Attributes inherited from Hyliter
#code, #lang
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Hyliter
#initialize, new?
Class Method Details
.available? ⇒ Boolean
26
27
28
29
30
31
|
# File 'lib/hylite/hyliters.rb', line 26
def self.available?
require 'rouge'
true
rescue LoadError
false
end
|
Instance Method Details
#call ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/hylite/hyliters.rb', line 37
def call
theme = ::Rouge::Theme.find 'monokai'
formatter = ::Rouge::Formatters::Terminal256.new theme
lexer = ::Rouge::Lexer.find @lang
tokens = lexer.lex @code
formatter.format(tokens)
end
|
#type ⇒ Object
33
34
35
|
# File 'lib/hylite/hyliters.rb', line 33
def type
:rouge
end
|