node package manager

vnu-jar

The Nu Html Checker (v.Nu) Chat room Download latest

The Nu Html Checker (v.Nu) is the backend of checker.html5.org, html5.validator.nu, and validator.w3.org/nu. Its source code is available, as are instructions on how to build, test, and run the code.

vnu.jar is a packaged version of the Nu Html Checker for batch-checking documents from the command line and from other scripts/apps.

You can work with vnu.jar in CommonJS modules.

Install latest release version

$ npm install --save vnu-jar

Install latest dev version

$ npm install --save vnu-jar@dev

Example

For Node.js 6+

'use strict';
 
const exec = require ( 'child_process' ).exec;
const vnu = require ( 'vnu-jar' );
 
// Print path to vnu.jar 
console.log ( vnu );
 
// Work with vnu.jar 
// for example get vnu.jar version 
exec ( `java -jar ${vnu} --version`, ( error, stdout ) => {
 
    if ( error ) {
        console.error ( `exec error: ${error}` );
        return;
    }
 
    console.log ( stdout );
 
} );
 

Usage

Use the vnu.jar HTML checker as an executable for command-line checking of documents by invoking it like this:

  java -jar ~/vnu.jar [--errors-only] [--exit-zero-always]
       [--asciiquotes] [--no-stream] [--format gnu|xml|json|text] [--html]
       [--skip-non-html] [--no-langdetect] [--help] [--verbose] [--version]
       FILES

Note: In these instructions, replace "~/vnu.jar" with the actual path to the file on your system.

To check one or more documents from the command line:

  java -jar ~/vnu.jar FILE.html FILE2.html FILE3.HTML FILE4.html...

Note: If you get a StackOverflowError error when using the vnu.jar file, try adjusting the thread stack size by providing the -Xss option to java:

  java -Xss512k -jar ~/vnu.jar FILE.html...

To check all documents in a particular directory:

  java -jar ~/vnu.jar some-directory-name/

To check all documents in a particular directory, skipping any documents whose names don’t end with the extensions .html, .htm, .xhtml, or .xht:

  java -jar ~/vnu.jar --skip-non-html some-directory-name/

To check a Web document:

  java -jar ~/vnu.jar _URL_

  example: java -jar ~/vnu.jar http://example.com/foo

To check standard input:

  java -jar ~/vnu.jar -

  example: echo '<!doctype html><title>...' | java -jar ~/vnu.jar -

Options

When used from the command line as described in this section, the vnu.jar executable provides the following options:

--asciiquotes

Specifies whether ASCII quotation marks are substituted for Unicode smart
quotation marks in messages.

default: "no"

possible values: "yes" or "no"

--errors-only

Specifies that only error-level messages and non-document-error messages are
reported (so that warnings and info messages are not reported).

default: [unset; all message reported, including warnings & info messages]

--exit-zero-always

Makes the checker exit zero even if errors are reported for any documents.

default: [unset; checker exits 1 if errors are reported for any documents]

--format format

Specifies the output format for reporting the results.

default: "gnu"

possible values: "gnu", "xml", "json", "text" [see information at URL below]

https://github.com/validator/validator/wiki/Service-%C2%BB-Common-params#out

--help

Shows detailed usage information.

--skip-non-html

Skip documents that don’t have *.html, *.htm, *.xhtml, or *.xht extensions.

default: [unset; all documents found are checked, regardless of extension]

--html

Forces any *.xhtml or *.xht documents to be parsed using the HTML parser.

default: [unset; XML parser is used for *.xhtml and *.xht documents]

--no-langdetect

Disables language detection, so that documents are not checked for missing
or mislabeled html[lang] attributes.

default: [unset; language detection & html[lang] checking are performed]

--no-stream

Forces all documents to be be parsed in buffered mode instead of streaming
mode (causes some parse errors to be treated as non-fatal document errors
instead of as fatal document errors).

default: [unset; non-streamable parse errors cause fatal document errors]

--verbose

Specifies "verbose" output. (Currently this just means that the names of
files being checked are written to stdout.)

default: [unset; output is not verbose]

--version

Shows the vnu.jar version number.