GithubHelp home page GithubHelp logo

validator / gulp-html Goto Github PK

View Code? Open in Web Editor NEW
74.0 8.0 16.0 43.18 MB

Gulp plugin for HTML validation, using the official Nu Html Checker (v.Nu)

Home Page: https://validator.github.io/gulp-html/

License: MIT License

JavaScript 93.58% HTML 6.42%
vnu html html-validation gulp-plugins jar gulp-plugin gulpplugin validator official w3c-validator

gulp-html's Introduction

gulp-html

npm version Build Status

gulp plugin for HTML validation, using the Nu Html Checker (v.Nu)

Install

Run npm install gulp-html -D.

Usage

const gulp = require('gulp');
const validator = require('gulp-html');

const html = () => {
  return gulp.src('src/index.html')
    .pipe(validator())
    .pipe(gulp.dest('dist/'));
};

Options

The options object supports the same options as Nu Html Checker.

See also https://validator.github.io/validator/#options.

errors-only

  • Type: Boolean
  • Default: false

format

  • Type: String
  • Default: "gnu"

html

  • Type: Boolean
  • Default: false

no-stream

  • Type: Boolean
  • Default: false

verbose

  • Type: Boolean
  • Default: false

License

Copyright 2015 Daijiro Wachi

This software is released under the MIT License. See LICENSE.

gulp-html's People

Contributors

dependabot[bot] avatar dilatorily avatar kuzvac avatar mischah avatar silvenon avatar sitaggart avatar vernando05 avatar watilde avatar xhmikosr 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gulp-html's Issues

Can't make it work

Hi,

I'm trying to validate all the .html files under the /dist folder, but apparently I can't make this task work:

gulp.task('html', function() {
  return gulp.src("dist/**/*.html")
  .pipe(validator())
  .pipe(gulp.dest('dist/'));
});

I constantly get:

[My directory]\node_modules\gulp-util\lib\PluginError.js:73
  if (!this.message) throw new Error('Missing error message');
                     ^

Error: Missing error message
    at new PluginError ( [My directory]\node_modules\gulp-util\lib\PluginError.js:73:28)
    at [My directory]\node_modules\gulp-html\index.js:33:17
    at ChildProcess.exithandler (child_process.js:209:5)
    at emitTwo (events.js:100:13)
    at ChildProcess.emit (events.js:185:7)
    at maybeClose (internal/child_process.js:850:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)

What am I missing?
Help is appreciated, thanks!

P.S.
Node version is 5.8.0

Multiple files checking speed issue

When checking multiple files, I notice that gulp-html spawns a new Java process for each file. This is far from optimal and it's super slow with a big number of HTML files.

You should gather the source files and pass all of them in one Java process. Here's how grunt-html does this.

Thanks!

"Unable to access jarfile" error

Hey,

This plugin was throwing this error. I found the cause was that my file directory had a space in it e.g. "Documents/Web Dev/Project". Changed it to "/Websites" and it fixed.

I've been told it's bad practice to have spaces in your folder names but thought you might want to know.
I'm not too sure if you want to fix this or not but there might be others who don't know any better like me

Thanks!

PluginError: Unable to locate a Java Runtime

Hi, I installed gulp-html 3.2.0 on macOS 11.0.1, added it to a gulp pipeline, and when I run it, I get the following error:

[07:47:49] Starting 'validate'...
[07:47:49] 'validate' errored after 32 ms
[07:47:49] Error in plugin "gulp-html"
Message:
    The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

Details:
    domainEmitter: [object Object]
    domainThrown: false

I would expect that when I run npm run validate or gulp validate, ./index.html would be validated instead of receiving the Java runtime error.

I'd rather not manually install a Java runtime. Do I have an implementation error, or is this a bug?

Here's my code:

// ./package.json

{
  "scripts": {
    "validate": "gulp validate"
  },
  "devDependencies": {
    "gulp": "^4.0.2",
    "gulp-cli": "^2.3.0",
    "gulp-html": "^3.2.0"
  }
}
// ./gulpfile.js

const { src, dest } = require('gulp')
const validator = require('gulp-html')

/**
 * Validate HTML.
 * Usage: `gulp validate`
 *
 * @since unreleased
 *
 * @return {Object} Gulp stream
 */
exports.validate = function validate () {
  return src('./index.html')
    .pipe(validator())
    .pipe(dest('./'))
}
<!-- ./index.html -->

<!DOCTYPE html>
<html>
	<head>
		<title>Test</title>
	</head>
	<body>
	<header>This is wrong</footer>
<p></div>This should throw validation errors.</i>
</body>
</html>

Thank you!

False errors in files, compiled with partials

I'm using gulp-file-include to move repetitive parts of my html pages (like page header and footer) to outside files. However, gulp-html does not seem to use the compiled version for its validation, because it gives me errors about missing title element within head (which is inside one of the partials).

Here's a shortened version of my gulpfile.js:

var gulp            = require('gulp');
var gulpFileInclude = require('gulp-file-include');
var gulpHtml        = require('gulp-html');

gulp.task('html', function () {
    return gulp.src('src/*.html')

        // Include partials
        .pipe(gulpFileInclude({
            prefix:   '<!-- partial:',
            suffix:   ' -->',
            basepath: 'src/partials/',
            context:  {
                'compileJs': false
            }
        }))

        // Validate
        .pipe(gulpHtml())
        .pipe(gulp.dest('dist/'));
});

Am I missing something or is it a bug?

Multiple files validation

When multiple files are passed to the plugin, the the exec command is not formatted properly.
See the example below:

gulpfile.js

var gulp = require('gulp');
var validator = require('gulp-html');

gulp.task('default', function () {
    gulp.src('*.html').pipe(validator());
});

Here is the output if I put a console.log(vnu); on line 31 of index.js.

[05:22:09] Using gulpfile ~/Sources/temp/gulpfile.js
[05:22:09] Starting 'default'...
[05:22:09] Finished 'default' after 6.32 ms
java -jar /home/ehuylen/Sources/temp/node_modules/gulp-html/vnu/vnu.jar /home/ehuylen/Sources/temp/index.html
java -jar /home/ehuylen/Sources/temp/node_modules/gulp-html/vnu/vnu.jar /home/ehuylen/Sources/temp/index.html/home/ehuylen/Sources/temp/test.html

uses java

its a gulp plugin use javascript not java

Unable to access jarfile vnu.jar

$ npm i --save-dev gulp-html
$ brew install vnu
var validator = require('gulp-html');

gulp.task('validate', function () {
  return gulp.src('app/**/*.html')
    .pipe(validator())
    .pipe(gulp.dest('dist'));
});
$ gulp validate
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Error: Unable to access jarfile vnu.jar

'format' option doesn't work

2 issues -

  • vnu += '--format ' needs a space before appending the option string, otherwise it gets appended to the filename and causes an error
  • options need to be appended before the filename in order to work

Cheers.

Output customizing

Hi, I want to format the error output by handling the "error" event, but when using the "json" format, the event does not fire because a hard-coded formatter is used.

For example, validatorLog will only be called for { format: "gnu" }

const gulp = require('gulp')
const validator = require('gulp-html')

function validatorLog(e) {
    console.log('=== validatorLog ===')
    console.log(typeof e)
    console.log('=== validatorLog ===')
}

function validatorGnu() {
    return gulp.src('./index.html')
        .pipe(validator({ format: "gnu" }).on('error', validatorLog))
}

function validatorJson() {
    return gulp.src('./index.html')
        .pipe(validator({ format: "json" }).on('error', validatorLog))
}

exports.default = gulp.series(validatorGnu, validatorJson)

Also, this hard-coded formatter just prints json to the console. This is not a bug?
image

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.