简体   繁体   English

Grunt W3C验证插件用法

[英]Grunt w3c validation plugin usage

I am trying to validate a simple HTML file using the w3c validator plugin in Grunt. 我正在尝试使用Grunt中的w3c validator插件来验证简单的HTML文件。 It is giving me an unexpected identifier error on line 33 . line 33上给了我一个unexpected identifier错误。 I do not understand where I am wrong. 我不明白我哪里错了。
The figured out how to use the grunt-html-validation plugin, but can not get grunt-w3c-validation plugin to work. 想通了如何使用grunt-html-validation插件,但无法使grunt-w3c-validation插件正常工作。

HTML that I am trying to validate: 我正在尝试验证的HTML

<!doctype html>
<html>
  <head>
      <title> I will see </title>
  </head>

  <body>
    <p>Ok</p>
    <div>Whatever</div>
    <span>why</span>
    <p>why </p>
  </body>
</html>

Gruntfile.js Gruntfile.js

module.exports = function (grunt) {
    grunt.initConfig({
        jade: {
            compile: {
                files: {
                    "html/calculator.html" : "jade/calculator.jade"
                }
            }
        },

        sass: {
            compile: {
                files: {
                     "css/calculator.css": "sass/calculator.sass"
                }
            }
        },

        jasmine: {
            compile: {
                src: 'javascript/calculator.js',
                 options: {
                       vendor: 'node-modules/jasmine-jquery/jquery.js',
                    specs: 'specs/calculatorSpec.js'
                 }
            }
        },

        jshint: {
             all: ['Gruntfile.js', 'javascript/calculator.js']
        },

        html-validation: {
            options: {
                reset: grunt.option('reset') || false,
                stoponerror: false,
                remotePath: "http://decodize.com/",
                remoteFiles: ["html/moving-from-wordpress-to-octopress/",
                                "css/site-preloading-methods/"], //or 
                remoteFiles: "validation-files.json", // JSON file contains array of page paths. 
                relaxerror: ["Bad value X-UA-Compatible for attribute http-equiv on element meta."] //ignores these errors 
            },
            files: {
                src: ['html/example.html']
            }
        }

});

    grunt.loadNpmTasks('grunt-contrib-jade');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-jasmine');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-w3c-validation');

    grunt.registerTask('default', ['jade','sass','jasmine','jshint']);
    grunt.registerTask("default", ["html-validation"]);
    grunt.registerTask("default", ["css-validation"]);
};

In grunt.initConfig sections with hyphens (-) should be in quotes. grunt.initConfig带连字符(-)的部分应加引号。 Like this: 像这样:

'html-validation': {
            options: {
                reset: grunt.option('reset') || false,
                stoponerror: false,
                remotePath: "http://decodize.com/",
                remoteFiles: ["html/moving-from-wordpress-to-octopress/",
                                "css/site-preloading-methods/"], //or 
                remoteFiles: "validation-files.json", // JSON file contains array of page paths. 
                relaxerror: ["Bad value X-UA-Compatible for attribute http-equiv on element meta."] //ignores these errors 
            },
            files: {
                src: ['html/example.html']
            }
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM