diff --git a/bin/rocco b/bin/rocco index 100e608..aaa526f 100755 --- a/bin/rocco +++ b/bin/rocco @@ -7,10 +7,6 @@ #/ -c, --comment-chars= #/ The string to recognize as a comment marker #/ -o, --output= Directory where generated HTML files are written -#/ -w Highlight code using http://pygments.appspot.com -#/ instead of pygmentize(1) -#/ -#/ #/ --help Show this help message require 'optparse' @@ -40,7 +36,6 @@ ARGV.options { |o| o.on("-o", "--output=DIR") { |dir| output_dir = dir } o.on("-l", "--language=LANG") { |lang| options[:language] = lang } o.on("-c", "--comment-chars=CHARS") { |chars| options[:comment_chars] = Regexp.escape(chars) } - o.on("-w") { |v| options[:webservice] = v } o.on_tail("-h", "--help") { usage($stdout, 0) } o.parse! } or abort_with_note diff --git a/lib/rocco.rb b/lib/rocco.rb index 4a544ba..28a5d4d 100644 --- a/lib/rocco.rb +++ b/lib/rocco.rb @@ -75,7 +75,6 @@ class Rocco defaults = { :language => 'ruby', :comment_chars => '#', - :webservice => false } @options = defaults.merge(options) @sources = sources @@ -162,9 +161,10 @@ class Rocco code_stream = code_blocks.join("\n\n# DIVIDER\n\n") code_html = - if @options[:webservice] + if `which pygmentize` == "" + puts "Warning: pygmentize not installed. Using pygmentize.appspot.com" highlight_webservice(code_stream) - else + elsif highlight_pygmentize(code_stream) end @@ -199,7 +199,9 @@ class Rocco code_html end - + + # Pygments is not one of those things that's trivial for a ruby user to install, + # so we'll fall back on a webservice to highlight the code if it isn't available. def highlight_webservice(code) Net::HTTP.post_form( URI.parse('http://pygments.appspot.com/'),