Please Validate

github.com/DylanFM/please_validate/tree

DESCRIPTION:

A little markup validator.

FEATURES/PROBLEMS:

  • Validate (X)HTML files.

SYNOPSIS:

Valid file

$ pleasevalidate examples/valid.html
Valid: examples/valid.html

Invalid file

$ pleasevalidate examples/invalid.html
Invalid: examples/invalid.html
11 errors:
Line 8, Column 19: end tag for element "itle" which is not open
Line 10, Column 6: end tag for "title" omitted, but OMITTAG NO was specified
Line 8, Column 1: start tag was here
Line 16, Column 5: document type does not allow element "ul" here; missing one of "object", "ins", "del", "map", "button" start-tag
Line 20, Column 0: unclosed end-tag requires SHORTTAG YES
Line 20, Column 0: end tag for "li" omitted, but OMITTAG NO was specified
Line 17, Column 4: start tag was here
Line 20, Column 0: end tag for "ul" omitted, but OMITTAG NO was specified
Line 16, Column 2: start tag was here
Line 20, Column 0: end tag for "p" omitted, but OMITTAG NO was specified
Line 15, Column 2: start tag was here
Line 8, Column 20: XML Parsing Error:  Opening and ending tag mismatch: title line 8 and itle
Line 20, Column 7: XML Parsing Error:  expected '>'
Line 20, Column 7: XML Parsing Error:  Premature end of data in tag p line 15
Line 20, Column 7: XML Parsing Error:  Premature end of data in tag body line 12
Line 20, Column 7: XML Parsing Error:  Premature end of data in tag html line 4

A few files: valid, invalid and a non-HTML file

$pleasevalidate examples/valid.html RakeFile examples/invalid.html

Valid: examples/valid.html

Validation failed: RakeFile must have a content type of text/html

Invalid: examples/invalid.html 11 errors: Line 8, Column 19: end tag for element “itle” which is not open Line 10, Column 6: end tag for “title” omitted, but OMITTAG NO was specified Line 8, Column 1: start tag was here Line 16, Column 5: document type does not allow element “ul” here; missing one of “object”, “ins”, “del”, “map”, “button” start-tag Line 20, Column 0: unclosed end-tag requires SHORTTAG YES Line 20, Column 0: end tag for “li” omitted, but OMITTAG NO was specified Line 17, Column 4: start tag was here Line 20, Column 0: end tag for “ul” omitted, but OMITTAG NO was specified Line 16, Column 2: start tag was here Line 20, Column 0: end tag for “p” omitted, but OMITTAG NO was specified Line 15, Column 2: start tag was here Line 8, Column 20: XML Parsing Error: Opening and ending tag mismatch: title line 8 and itle Line 20, Column 7: XML Parsing Error: expected ‘>’ Line 20, Column 7: XML Parsing Error: Premature end of data in tag p line 15 Line 20, Column 7: XML Parsing Error: Premature end of data in tag body line 12 Line 20, Column 7: XML Parsing Error: Premature end of data in tag html line 4

REQUIREMENTS:

  • nokogiri

  • colored

  • mime/types

INSTALL:

Run the following if you haven’t already:

gem sources -a http://gems.github.com

Install the gem:

sudo gem install DylanFM-pleasevalidate

LICENSE:

(The MIT License)

Copyright © 2009 Dylan Fogarty-MacDonald

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.