Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Validate HTML5 files.

Project Description
html5validator is a command line tool that tests files for HTML5 validity. This was written with static site generators like Jekyll and Pelican in mind. Dynamic html content (for example from JS template engines) can be crawled (e.g. with localcrawl) and then validated.

Install

This module requires Python 2.7, 3.4, 3.5 or 3.6 and Java 8. Install with pip install html5validator and run with

html5validator --root _build/ --ignore-re 'Attribute "ng-[a-z-]+" not allowed'

to validate all html files in the _build directory and to ignore all messages that match the regular expression Attribute "ng-[a-z-]+" not allowed. Run html5validator --help to see the list of command line options.

This module uses the validator.nu backend which is written in Java. Therefore, a Java Runtime Environment must be available on your system. Since version 0.2, Java 8 is required.

Integration with CircleCI

Create a circle.yml file:

machine:
  java:
    version: oraclejdk8
dependencies:
  pre:
    - sudo pip install html5validator
test:
  override:
    - html5validator --root _build/

in your repository with static html files and get HTML5 validation on every git push.

Integration with TravisCI

Create a .travis.yml file. This is an example for a Python project:

language: python
python:
 - "2.7"
addons:
  apt:
    packages:
      - oracle-java8-set-default  # install Java8 as required by vnu.jar

branches:
  only:
    - gh-pages

install:
 - pip install html5validator

script: html5validator --root _build/

This is an example for Java project:

language: java
jdk:
 - oraclejdk8  # vnu.jar requires Java 8

branches:
  only:
    - gh-pages

install:
 - pip install --user html5validator

script: html5validator --root _build/

Fix the html5validator version by using pip install --user html5validator==<version number>.

You can also use this for user pages (repositories of the form <username>.github.io) where the html files are in the master branch. You only have to remove:

branches:
  only:
    - gh-pages

from .travis.yml. I am using this on my own user page.

Integration with CodeShip

Add this lines to the Setup Commands:

jdk_switcher use oraclejdk8
pip install html5validator

This is an example for Ruby project:

rvm use 2.2.0 --install
bundle install
bundle update
export RAILS_ENV=test
jdk_switcher use oraclejdk8
pip install html5validator

Technical Notes

  • If you are using grunt already, maybe consider using the grunt-html plugin for grunt instead.
  • Use --ignore-re 'Attribute "ng-[a-z-]+" not allowed' with angular.js apps.
  • Example with multiple ignores: html5validator --root tests/multiple_ignores/ --ignore-re 'Attribute "ng-[a-z-]+" not allowed' 'Start tag seen without seeing a doctype first'

Changelog

Install a particular version, for example 0.1.14, with pip install html5validator==0.1.14.

  • master
  • 0.2.8 (2017-09-08)
    • update vnu jar to 17.9.0
    • suppress a warning from the JDK about picked up environment variables
  • 0.2.7 (2017-04-09)
    • update vnu jar to 17.3.0
    • lint Python code
  • 0.2.5 (2016-07-30)
    • clamp CLI return value at 255: PR26
  • 0.2.4 (2016-07-14)
    • a fix for Cygwin thanks to this PR20
  • 0.2.3 (2016-07-05)
    • vnu.jar updated to 16.6.29 thanks to this PR
  • 0.2.2 (2016-04-30)
    • vnu.jar updated to 16.3.3
  • 0.2.1 (2016-01-25)
    • --ignore, --ignore-re: ignore messages containing an exact pattern or matching a regular expression (migration from version 0.1.14: replace --ignore with --ignore-re)
    • curly quotes and straight quotes can now be used interchangeably
    • change Java stack size handling (introduced the new command line options -l, -ll and -lll)
    • update vnu.jar to 16.1.1 (which now requires Java 8)
  • 0.1.14 (2015-10-09)
    • change text encoding handling
    • adding command line arguments --log and --version
  • 0.1.12 (2015-05-07)
    • document how to specify multiple regular expressions to be ignored
    • add --ignore as command line argument. Takes a regular expression for warnings and errors that should be ignored.
  • 0.1.9 (2015-03-02)
Release History

Release History

This version
History Node

0.2.8

History Node

0.2.7

History Node

0.2.6

History Node

0.2.5

History Node

0.2.4

History Node

0.2.3

History Node

0.2.2

History Node

0.2.1

History Node

0.2.0

History Node

0.1.14

History Node

0.1.13

History Node

0.1.12

History Node

0.1.11

History Node

0.1.10

History Node

0.1.9

History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
html5validator-0.2.8.tar.gz (23.9 MB) Copy SHA256 Checksum SHA256 Source Sep 8, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting