Class: Rembrandt::Engines::Pygmentize

Inherits:
Object
  • Object
show all
Defined in:
lib/rembrandt/engines/pygmentize.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/rembrandt/engines/pygmentize.rb', line 13

def self.available?
  present_on_system?
end

.present_on_system?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rembrandt/engines/pygmentize.rb', line 17

def self.present_on_system?
  !`which pygmentize`.empty?
end

Instance Method Details

#highlight(input, language) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/rembrandt/engines/pygmentize.rb', line 4

def highlight(input, language)
  tmp_file = File.open(".colorize_temp", "w")
  tmp_file.write(input)
  tmp_file.close
  output = `pygmentize -f html -l #{language} -O encoding=utf8 .colorize_temp`
  `rm .colorize_temp`
  output
end