Module: Scarlet::Highlighter

Defined in:
lib/scarlet/highlighter.rb

Class Method Summary collapse

Class Method Details

.run(text, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/scarlet/highlighter.rb', line 6

def self.run(text, options={})
  options[:format] ||= "html"
  options[:lexer] ||= "text"
  options[:arguments] ||= ""
  pid, stdin, stdout, stderr = Open4.popen4("pygmentize -f #{options[:format]} -l #{options[:lexer]} #{options[:arguments]}")
  stdin.puts(text)
  stdin.close
  stdout.read.strip
end