Skip to content

Instantly share code, notes, and snippets.

@javiervidal
Created March 31, 2010 14:50
Show Gist options
  • Save javiervidal/350420 to your computer and use it in GitHub Desktop.
Save javiervidal/350420 to your computer and use it in GitHub Desktop.
Validate local HTML file
require 'rubygems'
require 'w3c_validators'
include W3CValidators
@validator = MarkupValidator.new
# override the DOCTYPE
#@validator.set_doctype!(:html32)
# turn on debugging messages
@validator.set_debug!(true)
#file = File.dirname(__FILE__) + '/tmp/index.html'
file = '/tmp/index.html'
results = @validator.validate_file(file)
if results.errors.length > 0
results.errors.each do |err|
puts err.to_s
end
else
puts 'Valid!'
end
puts 'Debugging messages'
results.debug_messages.each do |key, value|
puts "#{key}: #{value}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment