New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

html-validator

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-validator

Validate html using validator.w3.org/nu

  • 0.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19K
increased by2.71%
Maintainers
1
Weekly downloads
 
Created
Source

#html-validator Build Status

A Node.js module/CLI app for validating html using validator.w3.org/nu

##Module Supports the following modes from Validator.nu Web Service Interface

  • Document URL as a GET parameter; the service retrieves the document by URL over HTTP or HTTPS.
  • Document POSTed as the HTTP entity body; parameters in query string as with GET.

###Installation

$ npm install html-validator

###Test

$ npm test

###Usage

Create an options object.

format This is the formatting of the returned data and it is required. It supports json, html, xhtml, xml, gnu and text.

validator You can override the default validator as long as it exposes the same REST interface.

url The url to the page you want to validate.

var validator = require('html-validator')
  , opts = {
      url : 'http://url-to-validate.com',
      format : 'json'
  };

validator(opts, function(err, data){
  if(err) throw err;

  console.log(data);
});

data The html you want to validate

var validator = require('html-validator')
  , fs = require('fs')
  , opts = {
    format : 'json'
  };


fs.readFile( 'file-to-validate.html', 'utf8', function( err, html ) {
  if (err) throw err;

  opts.data = html;

  validator(opts, function(err, data){
    if(err) throw err;

    console.log(data);
  });

});

validator You can override the default validator as long as it exposes the same REST interface.

var validator = require('html-validator')
  , opts = {
      url : 'http://url-to-validate.com',
      validator: 'http://html5.validator.nu',
      format : 'json'
  };

validator(opts, function(err, data){
  if(err) throw err;

  console.log(data);
});

##CLI

Pass in or --file and optional --format or --validator.

###Installation

Install globally

$ npm install html-validator -g

###Usage

With url

$ html-validator <url>

With file

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

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'

FAQs

Package last updated on 22 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc