From fb4b5404ae72214b5ee92d235bb8ef45eaa6d259 Mon Sep 17 00:00:00 2001 From: Burke Libbey Date: Tue, 30 Mar 2010 13:46:24 -0500 Subject: [PATCH] just use the pygments.appspot.com if there's no pygmentize on the path, rather than as a command line flag --- bin/rocco | 5 ----- lib/rocco.rb | 10 ++++++---- 2 files changed, 6 insertions(+), 9 deletions(-) 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/'),