🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@ganlanyuan/w3cjs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ganlanyuan/w3cjs

A node.js module for using the w3c validator.

latest
Source
npmnpm
Version
0.4.3
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Dependencies

w3cjs

A node.js library for testing files or url's against the w3c html validator.

Installation

npm install w3cjs

Usage

var w3cjs = require('w3cjs');

var results = w3cjs.validate({
	file: 'demo.html', // file can either be a local file or a remote file
	//file: 'http://html5boilerplate.com/',
	//input: '<html>...</html>',
	//input: myBuffer,
	output: 'json', // Defaults to 'json', other option includes html
	//proxy: 'http://proxy:8080', // Default to null
	callback: function (err, res) {
		console.log(res);
		// depending on the output type, res will either be a json object or a html string
	}
});

Example async testing with Mocha

var w3cjs = require('w3cjs');
describe('html validation', function(){
	it('index page should have no html errors', function(done){
		w3cjs.validate({
			file: 'index.html',
			callback: function (error, res) {
				console.log(error || res);
				if (res && res.messages.length > 0 ) {
					throw {error: 'html errors have been found', results: res};
				};
				done();
			}
		})
	})
})

Older versions < 0.2.0

w3c has changed their validator API to not include some old options. It will eventually be fully deprecated and everyone is advised to update to 0.3.0 of this module.

doctype: 'HTML5', // Defaults false for autodetect
charset: 'utf-8', // Defaults false for autodetect

Keywords

w3c

FAQs

Package last updated on 20 Jan 2018

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