Git Product home page Git Product logo

html-validator-cli's Introduction

Build Status Coverage Status js-standard-style

html-validator-cli

CLI for validating html using validator.w3.org/nu

Requires Node >= 8.15.3 for older versions use v5.0.0

Sends Page is validto STDOUT and exits with code 0 if page is valid.

Sends Page is not valid to STDOUT and exits with code 1 if page is not valid.

Sends Page not found to STDOUT and exits with code 1 if page is not found.

Installation

$ npm i html-validator-cli -g

Usage

$ html-validator <url>

With file

$ html-validator --file=<path-to-file>

With data

$ html-validator --data=data

Optional pass in format for returned data.

Valid options: json, html, xhtml, xml, gnu and text (default).

$ html-validator <url> --format=gnu

Optional pass in another validator.

It needs to expose the same REST interface.

$ html-validator <url> --validator='http://html5.validator.nu'

Optional pass in strings to ignore

$ html-validator <url> --ignore='Error: Stray end tag “div”.' --ignore='Error: Stray end tag “body”.'

Optional pass in headers

$ html-validator <url> --headers='{"foo":"doo"}'

To get full result from validator use --verbose

$ html-validator <url> --verbose

Optional, only get errors use --quiet

$ html-validator <url> --quiet

Validate a local document without setting up a tunnel

$ html-validator <local-url> --islocal

returns array of error messages

[
  {
    "type": "error",
    "lastLine": 8,
    "lastColumn": 32,
    "firstColumn": 27,
    "message": "Stray end tag “div”.",
    "extract": "aaaad code</div></p>\n<",
    "hiliteStart": 10,
    "hiliteLength": 6
  }
]

Related

License

MIT

html-validator-cli's People

Contributors

9renpoto avatar afeld avatar greenkeeper[bot] avatar greenkeeperio-bot avatar jasperv avatar renovate-bot avatar sambodo7 avatar xhmikosr avatar zrrrzzt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

html-validator-cli's Issues

Does this CLI support offline validation?

Looking at the README for the underlying library html-validator, that mentions offline validation (called WHATWG?), but does this CLI support that?

I tried

$ html-validator --validator WHATWG --file path/to/x.html

but it doesn't like that:

Error: Invalid URI "WHATWG"

Crawl all pages in the same domain

Hello,

First of all I'd like to say that this is a great tool! It just works.
However, it seems that this tool only evaluates 1 page at a time.
I was wondering if there are any plans to include a crawl option so it evaluates the entire site within the same domain? (i.e., give it the homepage, and it'll recurisvely crawl the links with relative hrefs or pages with the same domain)
There was a tool developed for this purpose on npm called w3c-validator-cli, but it's deprecated.

Path globs support

Hello,
I'd like to ask you to implement support for specifying input files by globs. That would allow us to run html-validator-cli from build (e.g. npm) scripts in a portable (cross-platform) way. There is actually a lot of linters that accept globs already. They use minimatch AFAIK. I mean some module based on it like globby, glob-all, globule or simple-glob.

include url in quiet mode

if you run it with quiet mode you only get the error messages
perhaps it would make sense to still include the url in the returned json object?

Push the git tags

Please don't forget to create and push git tags for each release.

There is no way to see the changes since there's no changelog and comparing the tags can help a lot.

Ignore errors

Hi, there.

We've been using your html-validator module in BootstrapCDN. Now, we need to switch to html-validator-cli.

So, I'm wondering, is there any way to ignore specific errors like the html-validator module allows?

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Preset name not found within published preset config (monorepo:angularmaterial). Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Invalid URL shows site validated

Hello, I found that entering certain invalid urls will still pass as valid as shown below
image

However, running the following code

(async () => {
  const validator = require('html-validator')
  let data = await validator({url: 'http://asdf'})
  console.log(data)
})()

outputs

{"url":"http://asdf","messages":[{"type":"non-document-error","subType":"io","message":"asdf: No address associated with hostname"}]}

which means html-validator is functioning correctly.

I think there just needs to be a check that includes checking for non-document-error.
If needed, I can submit a PR, and link here.

Return error code on failure.

I'm trying to incorporate this tool into a build process but when run through npm test it doesn't return an error status code (1) so npm test thinks everything is fine.

If possible it would be great to provide the correct exit code so the tool can fail builds.

Multiple files support

Hello,
I'd like to ask you to implement (and document) support for specifying multiple input files (without a need to prefix every file name with a command line option). That would allow us to run html-validator-cli from build (e.g. npm) scripts. There is actually a lot of linters that accept multiple files already.

Resolve files through local machine

I am looking for a solution to validating files in my local development environment. When I point to a local dev url, I get the message

IO Error: local.dev: Name or service not known

Is there a way I could solve this problem using this tool?

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.