.. image:: https://badge.fury.io/py/html-linter.svg :target: http://badge.fury.io/py/html-linter
.. image:: https://api.travis-ci.org/sk-/html-linter.svg?branch=master :target: https://travis-ci.org/sk-/html-linter
.. image:: https://coveralls.io/repos/sk-/html-linter/badge.svg?branch=master :target: https://coveralls.io/r/sk-/html-linter?branch=master
HTML Linter is an HTML5 linter that follows the style guide defined by Google.
Handling HTML5 files generated by lots of different of people is a difficult task, because the standard is evolving quite fast and also because browsers are quite open to accept any malformed/invalid/incomplete input.
That's why we decided to have an automated tool to check our coding standard.
We start with the
Google standard <https://google.github.io/styleguide/htmlcssguide.html>
and we enhance it with some extra rules defined by the project
html-minifier <https://github.com/kangax/html-minifier>
. You can read his
detailed article <http://perfectionkills.com/experimenting-with-html-minifier/#remove_redundant_attributes>
_.
The list of extra rules we added are:
Check if the file has BOM.
The ability to validate the HTML using the tool
HTML5 tidy <https://w3c.github.io/tidy-html5/>
_ and to integrate some
schema.org or microdata validator.
However, we do not have any short terms plans to handle the latter, due to a couple of reasons:
git-lint <https://github.com/sk-/git-lint>
_git-lint <https://github.com/sk-/git-lint>
_htmllinter used the project
template-remover <https://github.com/deezer/template-remover>
to remove the
PHP and Jinja markup from the files and this project works has some limitations.
One example that won't work is the following::
<?php echo "?>" ?>
The reason it does not work is because when the method sees the first '?>' (the one inside the string), it thinks it's a closing tag.
Below are example of how template_remover.py is used::
$ html_lint.py filename.html
You can install, upgrade or uninstall html-linter with these commands::
$ pip install html-linter $ pip install --upgrade html-linter $ pip uninstall html-linter
Python 2.7, 3.3, 3.4, 3.5 and 3.6 are supported.
Help for this project is more than welcomed, so feel free to create an issue or to send a pull request via http://github.com/deezer/html-linter.
Tests are run using nose, either with::
$ python -R setup.py nosetests $ nosetests
Use the tool git-lint <https://github.com/sk-/git-lint>
_ before any commit, so
errors and style problems are caught early.
Dustin Ingram <https://github.com/di>
_--printfilename
option (#8 <https://github.com/sk-/html-linter/pull/8>
_)#12 <https://github.com/sk-/html-linter/pull/12>
_)@di <https://github.com/di>
_)