Class: Pygments
- Inherits:
-
Object
- Object
- Pygments
- Defined in:
- lib/pygments.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
Class Method Details
.bin ⇒ Object
6 7 8 |
# File 'lib/pygments.rb', line 6 def self.bin "/usr/bin/env python #{File.("../vendor/pygmentize.py", File.dirname(__FILE__))}" end |
.pygmentize(source, lexer) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pygments.rb', line 10 def self.pygmentize(source, lexer) args = [ "-l", lexer.to_s, "-f", "html", "-O", "encoding=#{source.encoding}" ] IO.popen("#{bin} #{Shellwords.shelljoin args}", "r+") do |io| io.write(source) io.close_write io.read end end |