Gruntjs 是否有Grunt.js插件帮助检测打开的HTML元素?
我喜欢grunt,有时在大量代码中工作时,留下一个标记比较容易。是否有一个grunt脚本可以在构建时解析HTML,然后将消息发送到控制台,其中有一个断开的元素或一个非闭合的元素?是的,有。这是HTML的一个过梁,它将检查未关闭的元素、大写标记、唯一ID等(请参阅) 注意,您必须在grunt插件中指定选项,因为它没有默认值。以下是我以前使用过的配置示例:Gruntjs 是否有Grunt.js插件帮助检测打开的HTML元素?,gruntjs,Gruntjs,我喜欢grunt,有时在大量代码中工作时,留下一个标记比较容易。是否有一个grunt脚本可以在构建时解析HTML,然后将消息发送到控制台,其中有一个断开的元素或一个非闭合的元素?是的,有。这是HTML的一个过梁,它将检查未关闭的元素、大写标记、唯一ID等(请参阅) 注意,您必须在grunt插件中指定选项,因为它没有默认值。以下是我以前使用过的配置示例: htmlhint: { build: { options: { 'tag-pair': true
htmlhint: {
build: {
options: {
'tag-pair': true, // Force tags to have a closing pair
'tagname-lowercase': true, // Force tags to be lowercase
'attr-lowercase': true, // Force attribute names to be lowercase e.g. <div ID="header"> is invalid
'attr-value-double-quotes': true, // Force attributes to have double quotes rather than single
'doctype-first': true, // Force the DOCTYPE declaration to come first in the document
'spec-char-escape': true, // Force special characters to be escaped
'id-unique': true, // Prevent using the same ID multiple times in a document
'head-script-disabled': true, // Prevent script tags being loaded in the <head> for performance reasons
'style-disabled': true // Prevent style tags. CSS should be loaded through <link>
},
src: ['static/**/*.html']
}
}
htmlhint:{
建造:{
选项:{
“标记对”:true,//强制标记具有结束对
“标记名小写”:true,//强制标记为小写
“attr lowercase”:true,//强制属性名称为小写,例如无效
“attr value双引号”:true,//强制属性使用双引号而不是单引号
“doctype first”:true,//强制文档中的doctype声明位于第一位
“spec char转义”:true,//强制转义特殊字符
“id唯一”:true,//防止在文档中多次使用同一id
“头脚本已禁用”:true,//出于性能原因,阻止在中加载脚本标记
“style disabled”:true//防止样式标记。CSS应通过
},
src:['static/***/.html']
}
}
希望这有帮助。:-) 太棒了-我还发现html验证grunt也可以做到这一点-谢谢果然它抓住了我的空位。