diff --git a/lib/rocco.rb b/lib/rocco.rb index f3d96d0..2e7fb34 100644 --- a/lib/rocco.rb +++ b/lib/rocco.rb @@ -52,7 +52,8 @@ require 'net/http' # Code is run through [Pygments](http://pygments.org/) for syntax # highlighting. If it's not installed, locally, use a webservice. -if `which pygmentize`.blank? +include FileTest +if !ENV['PATH'].split(':').any? { |dir| executable?("#{dir}/pygmentize") } warn "WARNING: Pygments not found. Using webservice." end @@ -166,10 +167,10 @@ class Rocco # `pygmentize(1)` or code_stream = code_blocks.join("\n\n#{@options[:comment_chars]} DIVIDER\n\n") - if `which pygmentize`.blank? - code_html = highlight_webservice(code_stream) - else + if ENV['PATH'].split(':').any? { |dir| executable?("#{dir}/pygmentize") } code_html = highlight_pygmentize(code_stream) + else + code_html = highlight_webservice(code_stream) end # Do some post-processing on the pygments output to split things back