<commit_before>/*
 * grunt-htmlhint-plus
 * https://github.com/poppinlp/grunt-htmlhint-plus
 *
 * Copyright (c) 2014 "PoppinLp" <NAME>
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {
    grunt.registerMultiTask('htmlhintplus', 'Validate html files with htmlhint.', function () {
        var HTMLHint = require("htmlhint").HTMLHint,
            fc = require('file-changed'),
            defaultRules = {
                "tagname-lowercase": true,
                "attr-lowercase": true,
                "attr-value-double-quotes": true,
                "attr-value-not-empty": true,
                "attr-no-duplication": true,
                "doctype-first": true,
                "tag-pair": true,
                "tag-self-close": false,
                "spec-char-escape": true,
                "id-unique": true,
                "src-not-empty": true,
                "head-script-disabled": false,
                "img-alt-require": true,
                "doctype-html5": true,
                "id-class-value": "dash",
                "style-disabled": false,
                "space-tab-mixed-disabled": true,
                "id-class-ad-disabled": true,
                "href-abs-or-rel": true,
                "attr-unsafe-chars": true
            },
            options = this.options(),
            hasError = false;

        this.files.map(function (files) {
            files.src.map(function (file) {
                if (options.newer && fc.addFile(file).check(file).length === 0) return;

                var text = grunt.file.read(file),
                    rules = defaultRules,
                    key,
                    reg,
                    result;

                if (options.ignore) {
                    for (key in options.ignore) {
                        if (options.ignore.hasOwnProperty(key)) {
                            reg = new RegExp(key + '.*?' + options.ignore[key], 'ig');
                            text = text.replace(reg, 'x');
                        }
                    }
                }

                if (options.htmlhintrc) {
                    rules = grunt.file.readJSON(options.htmlhintrc);
                } else if (options.rules) {
                    rules = options.rules;
                }

                result = HTMLHint.verify(text, rules);
                if (result.length > 0) {
                    hasError = true;
                    grunt.log.errorlns('HtmlHintPlus: ' + result.length + ' warnings in ' + file + '...');
                    result.forEach(function (msg) {
                        grunt.log.writeln( "[".red + ( "L" + msg.line ).yellow + ":".red + ( "C" + msg.col ).yellow + "]".red + ' ' + msg.message.yellow );
                    });
                } else {
                    if (options.newer) {
                        fc.addFile(file).update(file);
                    }
                    grunt.log.ok('HtmlHintPuls: ' + file + ' hint well...');
                }
            });
        });

        fc.save();

        if (options.force && hasError) {
            grunt.fail.fatal('Can\'t pass htmlhint. Set \'force\' option to continue.');
        }
    });
};
<commit_msg>fix typo "HtmlHintP.U.ls"<commit_after>/*
 * grunt-htmlhint-plus
 * https://github.com/poppinlp/grunt-htmlhint-plus
 *
 * Copyright (c) 2014 "PoppinLp" <NAME>
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {
    grunt.registerMultiTask('htmlhintplus', 'Validate html files with htmlhint.', function () {
        var HTMLHint = require("htmlhint").HTMLHint,
            fc = require('file-changed'),
            defaultRules = {
                "tagname-lowercase": true,
                "attr-lowercase": true,
                "attr-value-double-quotes": true,
                "attr-value-not-empty": true,
                "attr-no-duplication": true,
                "doctype-first": true,
                "tag-pair": true,
                "tag-self-close": false,
                "spec-char-escape": true,
                "id-unique": true,
                "src-not-empty": true,
                "head-script-disabled": false,
                "img-alt-require": true,
                "doctype-html5": true,
                "id-class-value": "dash",
                "style-disabled": false,
                "space-tab-mixed-disabled": true,
                "id-class-ad-disabled": true,
                "href-abs-or-rel": true,
                "attr-unsafe-chars": true
            },
            options = this.options(),
            hasError = false;

        this.files.map(function (files) {
            files.src.map(function (file) {
                if (options.newer && fc.addFile(file).check(file).length === 0) return;

                var text = grunt.file.read(file),
                    rules = defaultRules,
                    key,
                    reg,
                    result;

                if (options.ignore) {
                    for (key in options.ignore) {
                        if (options.ignore.hasOwnProperty(key)) {
                            reg = new RegExp(key + '.*?' + options.ignore[key], 'ig');
                            text = text.replace(reg, 'x');
                        }
                    }
                }

                if (options.htmlhintrc) {
                    rules = grunt.file.readJSON(options.htmlhintrc);
                } else if (options.rules) {
                    rules = options.rules;
                }

                result = HTMLHint.verify(text, rules);
                if (result.length > 0) {
                    hasError = true;
                    grunt.log.errorlns('HtmlHintPlus: ' + result.length + ' warnings in ' + file + '...');
                    result.forEach(function (msg) {
                        grunt.log.writeln( "[".red + ( "L" + msg.line ).yellow + ":".red + ( "C" + msg.col ).yellow + "]".red + ' ' + msg.message.yellow );
                    });
                } else {
                    if (options.newer) {
                        fc.addFile(file).update(file);
                    }
                    grunt.log.ok('HtmlHintPlus: ' + file + ' hint well...');
                }
            });
        });

        fc.save();

        if (options.force && hasError) {
            grunt.fail.fatal('Can\'t pass htmlhint. Set \'force\' option to continue.');
        }
    });
};

{'fraction_non_alphanumeric': 0.13808049535603714, 'fraction_numerical': 0.0021671826625387, 'mean_word_length': 1.1849847818735204, 'pattern_counts': {'":': 42, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4081902', 'n_tokens_mistral': 1849, 'n_tokens_neox': 1704, 'n_words': 326}