rocco command acts like documented
This commit is contained in:
parent
50fb900e5e
commit
4a0dfe7421
16
bin/rocco
16
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
|
||||
|
15
lib/rocco.rb
15
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user