Created
March 31, 2010 14:50
-
-
Save javiervidal/350420 to your computer and use it in GitHub Desktop.
Validate local HTML file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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