Permalink
Browse files

Merge pull request #81 from millermedeiros/master

improve support for HTML5 attributes
  • Loading branch information...
2 parents 8989818 + 8afc49d commit a97b9eaba8b8678a498694f4a50d3a4dea5aea17 @scrooloose scrooloose committed Dec 9, 2011
Showing with 38 additions and 7 deletions.
  1. +38 −7 syntax_checkers/html.vim
View
@@ -37,19 +37,50 @@ function! s:TidyEncOptByFenc()
return get(tidy_opts, &fileencoding, '-utf8')
endfunction
+let s:ignore_html_errors = [
+ \ "<table> lacks \"summary\" attribute",
+ \ "not approved by W3C",
+ \ "attribute \"placeholder\"",
+ \ "<meta> proprietary attribute \"charset\"",
+ \ "<meta> lacks \"content\" attribute",
+ \ "inserting \"type\" attribute",
+ \ "proprietary attribute \"data-"
+ \]
+
+function! s:ValidateError(text)
+ let valid = 0
+ for i in s:ignore_html_errors
+ if stridx(a:text, i) != -1
+ let valid = 1
+ break
+ endif
+ endfor
+ return valid
+endfunction
+
+
function! SyntaxCheckers_html_GetLocList()
- "grep out the '<table> lacks "summary" attribute' since it is almost
- "always present and almost always useless
let encopt = s:TidyEncOptByFenc()
- let makeprg="tidy ".encopt." --new-blocklevel-tags 'section, article, aside, hgroup, header, footer, nav, figure, figcaption' --new-inline-tags 'video, audio, embed, mark, progress, meter, time, ruby, rt, rp, canvas, command, details, datalist' --new-empty-tags 'wbr, keygen' -e ".shellescape(expand('%'))." 2>&1 \\| grep -v '\<table\> lacks \"summary\" attribute' \\| grep -v 'not approved by W3C' \\| grep -v 'attribute \"placeholder\"'"
+ let makeprg="tidy ".encopt." --new-blocklevel-tags 'section, article, aside, hgroup, header, footer, nav, figure, figcaption' --new-inline-tags 'video, audio, embed, mark, progress, meter, time, ruby, rt, rp, canvas, command, details, datalist' --new-empty-tags 'wbr, keygen' -e ".shellescape(expand('%'))." 2>&1"
let errorformat='%Wline %l column %c - Warning: %m,%Eline %l column %c - Error: %m,%-G%.%#,%-G%.%#'
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
- "the file name isnt in the output so stick in the buf num manually
- for i in loclist
- let i['bufnr'] = bufnr("")
- endfor
+ " process loclist since we need to add some info and filter out valid HTML5
+ " from the errors
+ let n = len(loclist) - 1
+ let bufnum = bufnr("")
+ while n >= 0
+ let i = loclist[n]
+ " filter out valid HTML5
+ if s:ValidateError(i['text']) == 1
+ unlet loclist[n]
+ else
+ "the file name isnt in the output so stick in the buf num manually
+ let i['bufnr'] = bufnum
+ endif
+ let n -= 1
+ endwhile
return loclist
endfunction

0 comments on commit a97b9ea

Please sign in to comment.