Package: html5validator
html5validatoris a command line tool that tests files for
HTML5 validity. This was written with static site generators likeJekyllandPelicanin mind. Dynamic html content
(for example from JS template engines) can be crawled
(e.g. withlocalcrawl)
and then validated.InstallThis module requires Python 3.6, 3.7, 3.8 or 3.9 and Java 8 (openjdk8ororaclejdk8).
Install withpip install html5validatorand run withhtml5validator--root_build/to validate all html files in the_builddirectory.
Runhtml5validator--helpto see the list of command line options:usage: html5validator [-h] [--root ROOT] [--match MATCH [MATCH ...]]
                      [--blacklist [BLACKLIST ...]] [--show-warnings]
                      [--no-langdetect] [--no-vnu-stdout] [--no-asciiquotes]
                      [--format {gnu,xml,json,text}]
                      [--ignore [IGNORE ...]] [--ignore-re [IGNORE_RE ...]]
                      [--config CONFIG] [-l] [-ll] [-lll] [--log LOG]
                      [--log-file LOG_FILE] [--version]
                      [files ...]

[v0.4.0] Command line tool for HTML5 validation. Return code is 0 for valid
HTML5. Arguments that are unknown to html5validator
are passed as arguments to `vnu.jar`.

positional arguments:
  files                 specify files to check

optional arguments:
  -h, --help            show this help message and exit
  --root ROOT           start directory to search for files to validate
  --match MATCH [MATCH ...]
                        match file pattern in search (default: "*.html" or
                        "*.html *.css" if --also-check-css is used)
  --blacklist [BLACKLIST ...]
                        directory names to skip in search
  --show-warnings       show warnings and count them as errors
  --no-langdetect       disable language detection
  --no-vnu-stdout       do not use --stdout with vnu.jar
  --no-asciiquotes      do not use --asciiquotes with vnu.jar
  --format {gnu,xml,json,text}
                        output format
  --ignore [IGNORE ...]
                        ignore messages containing the given strings
  --ignore-re [IGNORE_RE ...]
                        regular expression of messages to ignore
  --config CONFIG       Path to a config file for options
  -l                    run on larger files: sets Java stack size to 2048k
  -ll                   run on larger files: sets Java stack size to 8192k
  -lll                  run on larger files: sets Java stack size to 32768k
  --log LOG             log level: DEBUG, INFO or WARNING (default: WARNING)
  --log-file LOG_FILE   Name for log file. If no name supplied then no log
                        file will be created
  --version             show program's version number and exitThis module uses thevalidator.nu backendwhich is written in Java. Therefore, a Java Runtime Environment must be
available on your system. Since version 0.2, Java 8 is required.Checking CSS/SVGhtml5validator--root_build/--also-check-css# checking only CSShtml5validator--root_build/--skip-non-cssReplacecsswithsvgfor similar behavior with SVG files.Integration with CircleCI 1.0Create acircle.ymlfile:machine:java:version:openjdk8dependencies:pre:-sudo pip install html5validatortest:override:-html5validator --root _build/in your repository with static html files and get HTML5 validation on everygit push.Integration with CircleCI 2.0Simplified examplecircle.ymlfile frompelican-jsmath:version:2jobs:test-3.6:docker:-image:python:3.6-stretchsteps:-run:name:install Javacommand:apt-get update && apt-get install -y openjdk-8-jre-checkout-run:name:installcommand:pip install '.[test]'-run:name:generate htmlworking_directory:test/example_sitecommand:pelican content -s pelicanconf.py-run:name:validate htmlcommand:html5validator --root test/example_site/outputworkflows:version:2build_and_test:jobs:-test-3.6Integration with TravisCICreate a.travis.ymlfile. This is an example for a Python project:language:pythonpython:-"2.7"addons:apt:packages:-openjdk-8-jre# install Java8 as required by vnu.jarbranches:only:-gh-pagesinstall:-pip install html5validatorscript:html5validator --root _build/This is an example for Java project:language:javajdk:-oraclejdk8# vnu.jar requires Java 8branches:only:-gh-pagesinstall:-pip install --user html5validatorscript:html5validator --root _build/Fix thehtml5validatorversion by usingpip install--userhtml5validator==<versionnumber>.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-pagesfrom.travis.yml. I am using this onmy own user page.Integration with CodeShipAdd this lines to theSetup Commands:jdk_switcher use oraclejdk8pip install html5validatorThis is an example for Ruby project:rvm use 2.2.0 --installbundle installbundle updateexport RAILS_ENV=testjdk_switcher use oraclejdk8pip install html5validatorIntegration with GitLab CIThere is a docker image available to be used with GitLab CI or stand alone.Docker image,Docker image repo.Example for html test(Full):html_test:stage:html_testimage:cyb3rjak3/html5validator:latestscript:-html5validator --root public/ --also-check-css --format textIntegration with GitHub ActionsThere is a Github Action that can be used to check repositories.Marketplace Link.Example action:-name:HTML5 Validatoruses:Cyb3r-Jak3/html5validator-action@masterwith:root:html/Technical NotesIf you are using grunt already, maybe consider using thegrunt-htmlplugin for grunt instead.Use--ignore-re'Attribute"ng-[a-z-]+"not allowed'with angular.js apps.Example with multiple ignores:html5validator--roottests/multiple_ignores/--ignore-re'Attribute"ng-[a-z-]+"not allowed' 'Start tag seen without seeing a doctype first'ChangelogInstall a particular version, for example0.1.14, withpip installhtml5validator==0.1.14.main0.4.2(2022-05-29)test with Python 3.10vnu.jar updated to 20.6.30compatibility restored with certain versions of Python (os.errnoissue)0.4.0(2021-05-03)update vnu jar to 21.4.9use–stdoutand–asciiquotesby default for vnu.jarmake–format=jsonparsablebetter log file and config file testsmove tests to GitHub Actions and setup auto-deploy to PyPI from GitHub releases0.3.3(2019-12-07)PR#590.3.2(2019-11-22)update vnu jar to 18.11.5better output checkPR#57by@Cyb3r-Jak30.3.1(2018-06-01)update vnu jar to 18.3.0pass remaining command line options tovnu.jarallow to match multiple file patterns, e.g.--match*.html *.css0.3.0(2018-01-21)update vnu jar to 17.11.1support explicit list of files:html5validator file1.html file2.htmlnew command line options:--no-langdetect,--formatnew tests for--show-warningsflagrefactored internal APIbugfix: check existence of Javabugfix: split Java and vnu.jar command line options0.2.8(2017-09-08)update vnu jar to 17.9.0suppress a warning from the JDK about picked up environment variables0.2.7(2017-04-09)update vnu jar to 17.3.0lint Python code0.2.5(2016-07-30)clamp CLI return value at 255:PR260.2.4(2016-07-14)a fix for Cygwin thanks to thisPR200.2.3(2016-07-05)vnu.jarupdated to 16.6.29 thanks to thisPR0.2.2(2016-04-30)vnu.jarupdated to 16.3.30.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--ignorewith--ignore-re)curly quotes and straight quotes can now be used interchangeablychange Java stack size handling (introduced the new command line options-l,-lland-lll)update vnu.jar to 16.1.1 (which now requires Java 8)0.1.14(2015-10-09)change text encoding handlingadding command line arguments--logand--version0.1.12(2015-05-07)document how to specify multiple regular expressions to be ignoredadd--ignoreas command line argument. Takes a regular expression
for warnings and errors that should be ignored.0.1.9(2015-03-02)