npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-tidy-html5

v1.0.1

Published

Grunt task for checking and fixing HTML files using tidy-html5

Downloads

3

Readme

grunt-tidy-html5

NPM version Build Status Coverage Status Dependency Status devDependency Status devDependency Status Code Climate Codacy Badge Built with Grunt semantic-release

NPM Downloads

This module provides a grunt multi-task for checking and fixing HTML files using tidy-html5, wrapped for Node.js by node-libtidy. See the official HTML Tidy pages for more information.

Installation

You need node >= 4, npm and grunt >= 1 installed and your project build managed by a Gruntfile with the necessary modules listed in package.json. If you haven't used Grunt before, be sure to check out the [Getting Started] guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins.

Install the Grunt task:

$ npm install grunt-tidy-html5 --save-dev

Configuration

Add the tidy-html5 entry with the HTML Tidy task configuration to the options of the grunt.initConfig method:

grunt.initConfig({
  'tidy-html5': {
    test: {
      src: ['*.html']
    }
  }
});

Then, load the plugin:

grunt.loadNpmTasks('grunt-tidy-html5');

Build

Call the HTML Tidy task:

$ grunt tidy-html5

or integrate it to your build sequence in Gruntfile.js:

grunt.registerTask('default', ['tidy-html5', ...]);

Warnings about invalid parts of the HTML markup will be logged on the console, if the quiet mode is not enabled. If there are any, unless the task execution is forced, the task will make Grunt fail.

Customizing

Default behaviour of the task can be tweaked by the task options; these are the defaults:

grunt.initConfig({
  tidy-html5: {
    task: {
      options: {
        force: false,
        quiet: false,
        report: '',
        ignoreMissing: false,
        tidyOptions: {}
      },
      src: ...
    }
  }
});

Options

force

Type: Boolean Default: false

Suppresses reporting the failure to Grunt and thus stopping execution of further tasks, if set to true.

quiet

Type: Boolean Default: false

Suppresses printing of errors and warnings about problems found in input files on the console. if set to true.

report

Type: String Default: ''

Path to the file, where the report will be written. If specified, the file will contain an array of objects describing every problem found, for example:

[
  {
    "type": "warning",
    "firstColumn": 1,
    "lastColumn": 1,
    "lastLine": 1,
    "message": "missing <!DOCTYPE> declaration",
    "extract": "<html></html>",
    "hiliteStart": 0,
    "hiliteLength": 0,
    "file":"test/work/incomplete.html"
  }
]

The file will have the JSON format compatible with the JSON report produced by grunt-html, which is backed up by gthe Nu Html Checker (v.Nu). Marking the invalid code excerps is not supported.

The JSON report file can be converted to a HTML report file using grunt-html-html-report-converter.

ignoreMissing

Type: Boolean Default: false

If the src property does not point to any files, or if it is missing, the task will make the Grunt run fail. If you set the ignoreMissing option to true, Grunt will continue executing other tasks.

tidyOptions

Type: Object Default: {}

Object passed to the TidyDoc.options property to set libtidy options. Any of all HTML Tidy options can be used as a property key and its value as a property value in the object.

More Usage Examples

'tidy-html5': {
  accessibility: {
    options: {
      report: 'output/report.json',
      tidyOptions: {
        'accessibility-check': 2
      }
    },
    src: ['input/*.html']
  }
}

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • 2018-04-27 v1.0.0 Dropped support of Node.js 4
  • 2018-03-06 v0.1.0 Write report to a file as JSON
  • 2018-02-26 v0.0.1 Initial release

License

Copyright (c) 2018-2019 Ferdinand Prantl

Licensed under the MIT license.