我正在尝试使用Grunt中的HTML
插件验证一个简单的w3c validator
文件。它在unexpected identifier
上给了我一个line 33
错误。我不明白我错在哪里。
想出了如何使用grunt-html-validation插件,但无法使用grunt-w3c-validation插件。
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
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"]);
};
答案 0 :(得分:0)
In grunt.initConfig
sections with hyphens (-) should be in quotes. 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']
}
}