2005-01-15 21:26:54 +01:00
|
|
|
#!/usr/bin/env ruby
|
2005-02-11 00:11:47 +01:00
|
|
|
require 'lib/redcloth'
|
2005-01-15 21:26:54 +01:00
|
|
|
require 'yaml'
|
|
|
|
|
|
|
|
Dir["tests/*.yml"].each do |testfile|
|
|
|
|
YAML::load_documents( File.open( testfile ) ) do |doc|
|
|
|
|
if doc['in'] and doc['out']
|
2005-09-16 06:27:07 +02:00
|
|
|
opts = []
|
|
|
|
opts << :hard_breaks if testfile =~ /hard_breaks/
|
|
|
|
red = RedCloth.new( doc['in'], opts )
|
2005-02-11 00:11:47 +01:00
|
|
|
html = if testfile =~ /markdown/
|
|
|
|
red.to_html( :markdown )
|
|
|
|
else
|
|
|
|
red.to_html
|
|
|
|
end
|
2005-01-15 21:26:54 +01:00
|
|
|
puts "---"
|
2005-02-11 00:11:47 +01:00
|
|
|
|
|
|
|
html.gsub!( /\n+/, "\n" )
|
|
|
|
doc['out'].gsub!( /\n+/, "\n" )
|
2005-01-15 21:26:54 +01:00
|
|
|
if html == doc['out']
|
|
|
|
puts "success: true"
|
|
|
|
else
|
|
|
|
puts "out: "; p html
|
|
|
|
puts "expected: "; p doc['out']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|