https://github.com/deezer/html-linter
HTML5 Linter based on Google Style Guide
https://github.com/deezer/html-linter
Last synced: 5 months ago
JSON representation
HTML5 Linter based on Google Style Guide
- Host: GitHub
- URL: https://github.com/deezer/html-linter
- Owner: deezer
- License: apache-2.0
- Created: 2014-05-07T10:19:26.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2021-11-05T17:01:42.000Z (about 4 years ago)
- Last Synced: 2024-04-16T11:27:17.259Z (over 1 year ago)
- Language: Python
- Size: 203 KB
- Stars: 51
- Watchers: 41
- Forks: 13
- Open Issues: 7
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
HTML Linter
===========
.. image:: https://badge.fury.io/py/html-linter.png
:target: http://badge.fury.io/py/html-linter
.. image:: https://travis-ci.org/deezer/html-linter.png?branch=master
:target: https://travis-ci.org/deezer/html-linter
.. image:: https://coveralls.io/repos/deezer/html-linter/badge.png?branch=master
:target: https://coveralls.io/r/deezer/html-linter?branch=master
HTML Linter is an HTML5 linter that follows the style guide defined by Google.
Motivation
----------
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 `_
and we enhance it with some extra rules deinfed by the project
`html-minifier `_. You can read his
detailed `article `_.
The list of extra rules we added are:
* Boolean attributes should not have an explicit value.
* Do not use the name attribute in a tags.
* Do not use the language attribute in script tags.
* Do not use the charset attribute in script tags when there is no source.
* Javascript:void(0) links are evil.
* onclick='javascript: ...' is not required. This will raise also a Concerns Separation error.
* meta http-equiv: use only standard properties + X-UA-compatible
* No extra whitespaces between attributes or before the opening or closing tag.
What is missing?
----------------
Check if the file has BOM.
The abbility to validate the HTML using the tool
`HTML5 tidy `_ 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:
* Tidy can be easily integrated using the tool `git-lint `_
* Any other validator can also be integrated with `git-lint `_
* Adding any extra validator would pull many more dependencies and change the scope.
Limitations
-----------
html_linter used the project
`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::
" ?>
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.
Example use
-----------
Below are example of how template_remover.py is used::
$ html_lint.py filename.html
Installation
------------
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 Versions
---------------
Python 2.7 is officially supported, 3.2, 3.3 and 3.4 should also work.
Development
-----------
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 `_ before any commit, so
errors and style problems are caught early.
TODOS and Possible Features
---------------------------
* Make the output less verbose.
* Integrate with HTML5 tidy.
* Integrate with a schema.org/micrdata validator.
Changelog
=========
v0.1 (2014-05-07)
-------------------
* Initial commit.