diff --git a/bin/rocco b/bin/rocco index 437c84c..92bc820 100755 --- a/bin/rocco +++ b/bin/rocco @@ -22,13 +22,9 @@ rescue LoadError raise end -rocco = - Rocco.new(ARGV[0]) do - if $stdin.tty? - File.read(ARGV[0]) - else - $stdin.read - end - end - -$stdout.write(rocco.to_html) +ARGV.each do |filename| + rocco = Rocco.new(filename) + dest = File.basename(filename, '.rb') + '.html' + warn "rocco: #{filename} -> #{dest}" + File.open(dest, 'wb') { |fd| fd.write(rocco.to_html) } +end diff --git a/lib/rocco.rb b/lib/rocco.rb index 929320a..78bb3b9 100644 --- a/lib/rocco.rb +++ b/lib/rocco.rb @@ -30,9 +30,20 @@ #### Prerequisites -# The RDiscount library is required for Markdown processing. +# The [rdiscount](http://github.com/rtomayko/rdiscount) library is +# required for Markdown processing. require 'rdiscount' +# We use [{{ mustache }}](http://defunkt.github.com/mustache/) for +# templating. +require 'mustache' + +# Code is run through [Pygments](http://pygments.org/) for syntax +# highlighting. Fail fast if we can't find the `pygmentize` program. +if ! ENV['PATH'].split(':').any? { |dir| File.exist?("#{dir}/pygmentize") } + fail "Pygments is required for syntax highlighting" +end + #### Public Interface # `Rocco.new` takes a source `filename` and an optional `block`. @@ -48,7 +59,7 @@ class Rocco else File.read(filename) end - # Jump right into parsing and highlighting. + # Parsing and highlighting @sections = highlight(parse(@data)) end