Giter Club home page Giter Club logo

html5validator's Introduction

HTML5 Validator

This was written with static site generators like Jekyll and Pelican in mind that push to a static server. html5validator is a command line executable that integrates well with CircleCI and TravisCI and tests all static html files for HTML5 validity.
https://travis-ci.org/svenkreiss/html5validator.svg?branch=master

Install

Install with pip install html5validator and run with

html5validator --root _build/ --ignore "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.

This package uses the validator.nu backend which is written in Java. Therefore, a Java Runtime Environment must be available on your system.

Integration with CircleCI

Create a circle.yml file:

dependencies:
  pre:
    - sudo pip install html5validator
test:
  override:
    - html5validator

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

Integration with TravisCI

Create a .travis.yml file:

language: python
branches:
  only:
    - gh-pages
python:
 - "2.7"
install:
 - "pip install html5validator"
script: "html5validator"

Enable the repository on TravisCI.

You probably don't want TravisCI to run on the master branch but only on the gh-pages branch. TravisCI has an option (off by default) to run tests only on branches that have a .travis.yml.

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.

Technical Notes

  • If you are using grunt already, maybe consider using the grunt-html plugin for grunt instead.
  • Use --ignore "Attribute “ng-[a-z-]+” not allowed" with angular.js apps.
  • Example with multiple ignores: html5validator --root tests/multiple_ignores/ --ignore "Attribute “ng-[a-z-]+” not allowed" "Start tag seen without seeing a doctype first"
  • Be careful with the non-standard quotes in the error messages when constructing the expressions to ignore.

Changelog

  • master
  • 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)

html5validator's People

Contributors

mprins avatar svenkreiss avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.