2013-12-13 51 views

回答

3

是的,有HTMLHint which has this grunt wrapper。這是一個HTML的短信,它將檢查未關閉的元素,大寫標籤,唯一ID等(請參閱wiki page)。

請注意,您必須在grunt插件中指定選項,因爲它沒有默認值。以下是我以前使用過的配置示例:

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'] 
    } 
} 

希望這有助於您。 :-)

+0

奇妙 - 我也發現html-validation-grunt也會這樣做 - 謝謝! https://npmjs.org/package/grunt-html-validation - 果然它引起了我打開的div。 – imaginethepoet