instiki/vendor/plugins/maruku/bin/marudown
Jacques Distler 37aff87d71 Sync with latest Maruku
Contains Ari Stern's additions for Blahtex support.
2008-08-05 13:18:23 -05:00

30 lines
651 B
Ruby

#!/usr/bin/env ruby
require 'maruku'
# 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
# create Maruku
doc = Maruku.new(input, {:on_error=>:warning})
# convert to a complete html document
output = doc.to_md
# write to file
dir = File.dirname(f)
filename = File.basename(f, File.extname(f)) + ".txt"
output = File.join(dir, filename)
File.open(output,'w') do |f| f.puts html end
end
else
# else, act as a filter
data = $stdin.read
puts Maruku.new(data, {:on_error=>:warning}).to_md
end