首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Grunt w3c验证插件用法

Grunt w3c验证插件用法
EN

Stack Overflow用户
提问于 2015-06-19 12:23:07
回答 1查看 828关注 0票数 0

我正在尝试使用Grunt中的w3c validator插件来验证一个简单的HTML文件。它在line 33上给我一个unexpected identifier错误。我不知道我错在哪里。

我知道如何使用grunt-html-validation插件,但是不能让grunt-w3c-validation插件工作。

我正在尝试验证的HTML

代码语言:javascript
复制
<!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

代码语言:javascript
复制
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"]);
};
EN

回答 1

Stack Overflow用户

发布于 2016-04-07 18:33:28

grunt.initConfig中,带连字符(-)的部分应用引号引起来。如下所示:

代码语言:javascript
复制
'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']
            }
        }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30929851

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档