bin/maruku in maruku-0.2.13 vs bin/maruku in maruku-0.3.0
- old
+ new
@@ -1,25 +1,33 @@
#!/usr/bin/env ruby
require 'maruku'
if File.basename($0) =~ /^maruku/
- # Convert each file
- ARGV.each do |f|
- puts "Opening #{f}"
+ # If we are given filenames, convert each file
+ if not ARGV.empty?
+ ARGV.each do |f|
+ puts "Opening #{f}"
- # read file content
- input = File.open(f,'r').read
+ # read file content
+ input = File.open(f,'r').read
- # create Maruku
- doc = Maruku.new(input)
- # convert to a complete html document
- html = doc.to_html_document
+ # create Maruku
+ doc = Maruku.new(input, {:on_error=>:warning})
+ # convert to a complete html document
+ html = doc.to_html_document( {:indent => -1})
- # write to file
- dir = File.dirname(f)
- filename = File.basename(f, File.extname(f)) + ".html"
+ # write to file
+ dir = File.dirname(f)
+ filename = File.basename(f, File.extname(f)) + ".html"
- out_xml = File.join(dir, filename)
- File.open(out_xml,'w') do |f| f.puts html end
+ out_xml = File.join(dir, filename)
+ File.open(out_xml,'w') do |f| f.puts html end
+ end
+ else
+ # else, act as a filter
+ data = $stdin.read
+ puts Maruku.new(data).to_html
end
-end
\ No newline at end of file
+end
+
+