hlint uses Mozilla's HTML5 Validator instance to lint HTML documents. This project is heavily influenced by mozilla's own linter.
pip install hlint
from hlint import lint
result = lint.check("index.html")
print(result)
assert(result.flag == True)
from hlint import lint
results = lint.check_files(["index.html", "bad.html"])
print(results)
assert(results.total_error_count == 1)
Error: Bad value for attribute “href” on element “link”: Illegal character in scheme data: space is not allowed. From line 3, column 6387; to line 3, column 7788 Error: Bad value for attribute “href” on element “link”: Illegal character in scheme data: space is not allowed. From line 7, column 1; to line 7, column 842 Error: Bad value “1” for attribute “async” on element “script”. From line 12, column 1; to line 12, column 303 Error: Bad value “toggle” for attribute “rel” on element “a”: The string “toggle” is not a registered keyword. From line 29, column 121809; to line 29, column 121991 Error: Bad value “1” for attribute “required” on element “input”. From line 29, column 123986; to line 29, column 124160 Error: Element “input” is missing required attribute “aria-expanded”. From line 29, column 123986; to line 29, column 124160 Error: Attribute “ajaxify” not allowed on element “a” at this point. From line 29, column 125356; to line 29, column 125575 Warning: The “name” attribute is obsolete. Consider putting an “id” attribute on the nearest container instead. From line 29, column 126674; to line 29, column 126859 Error: Attribute “ajaxify” not allowed on element “a” at this point. Error: The “scrolling” attribute on the “iframe” element is obsolete. Use CSS instead. From line 29, column 134870; to line 29, column 134973 Error: The “marginheight” attribute on the “iframe” element is obsolete. Use CSS instead. From line 29, column 134870; to line 29, column 134973 From line 29, column 135584; to line 29, column 135688 Error: The “aria-labelledby” attribute must point to an element in the same document. From line 29, column 126125; to line 29, column 126258 There were errors. (Tried in the text/html mode.)
MIT License
Copyright (c) 2018 Andrew Porter
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.