Permalink
Browse files

implementing proper html5 syntax checking (,5 mapping)

  • Loading branch information...
1 parent 35732df commit 39cb9514628bed0e6f806c020f759c55c8c818fc Peter Host committed Nov 27, 2011
View
99 .gitmodules
@@ -0,0 +1,99 @@
+[submodule "bundle/vim-pathogen"]
+ path = bundle/vim-pathogen
+ url = https://github.com/tpope/vim-pathogen.git
+[submodule "bundle/tartify"]
+ path = bundle/tartify
+ url = git://github.com/peterhost/tartify.git
+[submodule "bundle/vim-fugitive"]
+ path = bundle/vim-fugitive
+ url = git://github.com/tpope/vim-fugitive.git
+[submodule "bundle/vim-git-branch-info"]
+ path = bundle/vim-git-branch-info
+ url = git://github.com/taq/vim-git-branch-info.git
+[submodule "bundle/jshint.vim"]
+ path = bundle/jshint.vim
+ url = git://github.com/wookiehangover/jshint.vim.git
+[submodule "bundle/csapprox"]
+ path = bundle/csapprox
+ url = git://github.com/godlygeek/csapprox.git
+[submodule "bundle/vim-bufexplorer"]
+ path = bundle/vim-bufexplorer
+ url = git://github.com/slack/vim-bufexplorer.git
+[submodule "bundle/LustyJuggler"]
+ path = bundle/LustyJuggler
+ url = git://github.com/vim-scripts/LustyJuggler.git
+[submodule "bundle/syntastic"]
+ path = bundle/syntastic
+ url = git://github.com/scrooloose/syntastic.git
+[submodule "bundle/vim-matchit"]
+ path = bundle/vim-matchit
+ url = git://github.com/mhz/vim-matchit.git
+[submodule "bundle/nerdcommenter"]
+ path = bundle/nerdcommenter
+ url = git://github.com/scrooloose/nerdcommenter.git
+[submodule "bundle/vim-markdown"]
+ path = bundle/vim-markdown
+ url = git://github.com/plasticboy/vim-markdown.git
+[submodule "bundle/vim-surround"]
+ path = bundle/vim-surround
+ url = git://github.com/tpope/vim-surround.git
+[submodule "bundle/repeat.vim"]
+ path = bundle/repeat.vim
+ url = git://github.com/vim-scripts/repeat.vim.git
+[submodule "bundle/vim-css-color"]
+ path = bundle/vim-css-color
+ url = git://github.com/skammer/vim-css-color.git
+[submodule "bundle/vim-javascript"]
+ path = bundle/vim-javascript
+ url = git://github.com/pangloss/vim-javascript.git
+[submodule "bundle/YankRing.vim"]
+ path = bundle/YankRing.vim
+ url = git://github.com/vim-scripts/YankRing.vim.git
+[submodule "bundle/session.vim--Odding"]
+ path = bundle/session.vim--Odding
+ url = git://github.com/vim-scripts/session.vim--Odding.git
+[submodule "bundle/vim-colors-solarized"]
+ path = bundle/vim-colors-solarized
+ url = git://github.com/altercation/vim-colors-solarized.git
+[submodule "bundle/vim-bclose"]
+ path = bundle/vim-bclose
+ url = git://github.com/cespare/vim-bclose.git
+[submodule "bundle/Decho"]
+ path = bundle/Decho
+ url = git://github.com/vim-scripts/Decho.git
+[submodule "bundle/vim-unimpaired"]
+ path = bundle/vim-unimpaired
+ url = git://github.com/tpope/vim-unimpaired.git
+[submodule "bundle/vim-git"]
+ path = bundle/vim-git
+ url = git://github.com/tpope/vim-git.git
+[submodule "bundle/scss-syntax.vim"]
+ path = bundle/scss-syntax.vim
+ url = git://github.com/cakebaker/scss-syntax.vim.git
+[submodule "bundle/html5-syntax.vim"]
+ path = bundle/html5-syntax.vim
+ url = git://github.com/othree/html5-syntax.vim.git
+[submodule "bundle/L9"]
+ path = bundle/L9
+ url = git://github.com/vim-scripts/L9.git
+[submodule "bundle/FuzzyFinder"]
+ path = bundle/FuzzyFinder
+ url = git://github.com/vim-scripts/FuzzyFinder.git
+[submodule "bundle/PreciseJump"]
+ path = bundle/PreciseJump
+ url = git@github.com:peterhost/PreciseJump.git
+[submodule "bundle/neocomplcache"]
+ path = bundle/neocomplcache
+ url = git://github.com/Shougo/neocomplcache.git
+[submodule "bundle/SearchComplete"]
+ path = bundle/SearchComplete
+ url = git://github.com/vim-scripts/SearchComplete.git
+[submodule "bundle/vim-markdown-preview"]
+ path = bundle/vim-markdown-preview
+ url = git://github.com/peterhost/vim-markdown-preview.git
+[submodule "bundle/vim-taglist-plus"]
+ path = bundle/vim-taglist-plus
+ url = git://github.com/int3/vim-taglist-plus.git
+[submodule "bundle/snipMate"]
+ path = bundle/snipMate
+ url = git://github.com/vim-scripts/snipMate.git
View
15 bin/bootstrap
@@ -30,5 +30,18 @@ if ! which node >/dev/null 2>&1 || ! which jsctags >/dev/null 2>&1 ;then
echo "
WARN : either node.js or jsctags (jsdoctor) seems to be missing on your
system. vim-taglist-plus will use CTAGS instead of JSCTAGS for js
- (https://github.com/pcwalton/doctorjs.git)"
+ (https://github.com/pcwalton/doctorjs.git)
+"
+fi
+
+
+if ! which html5check >/dev/null 2>&1 ;then
+ echo "
+ WARN : html5check is not in your path, do:
+
+ ln -s ~/.vim/lib/html5check /usr/local/bin/html5check
+
+ so that you can use the ",5" mapping to properly validate
+ HTML5 files (syntastic's based on tidy and is broken)
+"
fi
1 bundle/Decho
@@ -0,0 +1 @@
+Subproject commit 3a55aca47b8ab629b64302f6f50966e3afb167e1
1 bundle/FuzzyFinder
@@ -0,0 +1 @@
+Subproject commit b9f165970346df55862853dd83c8a4f2b2b70262
1 bundle/L9
@@ -0,0 +1 @@
+Subproject commit c822b05ee0886f9a9703227dc85a6d47612c4bf1
1 bundle/LustyJuggler
@@ -0,0 +1 @@
+Subproject commit 6722d371eeb2c14dd4449de2bed77ffda435c72b
1 bundle/PreciseJump
@@ -0,0 +1 @@
+Subproject commit 72bc53a7e69c2d10753f7236a505bcdd7a5be220
1 bundle/SearchComplete
@@ -0,0 +1 @@
+Subproject commit d85ccf8c6c1fa88feff0c56b8fe271b7d91bd292
1 bundle/YankRing.vim
@@ -0,0 +1 @@
+Subproject commit 280ca1b471bd3a0d2347735e8fcbd03a53f2c6ad
1 bundle/csapprox
@@ -0,0 +1 @@
+Subproject commit f98bf4acef9d9aa5e7f5b42eba09e259908f639b
1 bundle/html5-syntax.vim
@@ -0,0 +1 @@
+Subproject commit 2f82fce6b97407e09a9635938e21506444c4d13a
1 bundle/jshint.vim
@@ -0,0 +1 @@
+Subproject commit dd2e24a5ee604759862bf2ab408bde6783eca047
1 bundle/neocomplcache
@@ -0,0 +1 @@
+Subproject commit d847ce395ac1a0000205b5a9060bb7372c5dd690
1 bundle/nerdcommenter
@@ -0,0 +1 @@
+Subproject commit b28e7be63235982501ab7dd30c03ea7feef7b095
1 bundle/repeat.vim
@@ -0,0 +1 @@
+Subproject commit 6336f383e25874aee82b8418940592fba618ad3e
1 bundle/scss-syntax.vim
@@ -0,0 +1 @@
+Subproject commit d4016f8b31f786d830bb59bb78979c6b5d5a200d
1 bundle/session.vim--Odding
@@ -0,0 +1 @@
+Subproject commit d9952100f8b186fb2d14713dd42b9377c4b25734
1 bundle/snipMate
@@ -0,0 +1 @@
+Subproject commit 018e0dd72178f0936ba4399d7393b2d2cf78e368
1 bundle/syntastic
@@ -0,0 +1 @@
+Subproject commit 3c26740b28073c262e6b2b723c5c608815ce4290
1 bundle/tartify
@@ -0,0 +1 @@
+Subproject commit 08170d13400d944597e16e8c49f8af7c83b3db1a
1 bundle/vim-bclose
@@ -0,0 +1 @@
+Subproject commit b93bc48c10dee3517100c67b4b33057b23bf8d91
1 bundle/vim-bufexplorer
@@ -0,0 +1 @@
+Subproject commit 3af55351b61f540cb4898ffa5f362a6b54dd5603
1 bundle/vim-colors-solarized
@@ -0,0 +1 @@
+Subproject commit 528a59f26d12278698bb946f8fb82a63711eec21
1 bundle/vim-css-color
@@ -0,0 +1 @@
+Subproject commit 417eaf8a20a6208e34ff167f5636b20f8f812ed8
1 bundle/vim-fugitive
@@ -0,0 +1 @@
+Subproject commit 1b7e4070f5f7b7522422f5b00a75b323cc314daf
1 bundle/vim-git
@@ -0,0 +1 @@
+Subproject commit 0a0d799e72ed63a08eb60070eadb343dea3b8c26
1 bundle/vim-git-branch-info
@@ -0,0 +1 @@
+Subproject commit fc43139eaf11680b383c941382af4d1816330e8c
1 bundle/vim-javascript
@@ -0,0 +1 @@
+Subproject commit 9990a767695c78a44611ce33fb2dbc25c83d8827
1 bundle/vim-markdown
@@ -0,0 +1 @@
+Subproject commit f3f96fd7c1bec0527de62415fd344e73994f1c47
1 bundle/vim-markdown-preview
@@ -0,0 +1 @@
+Subproject commit b0842f896bf151324573e1d11a02be3c028876eb
1 bundle/vim-matchit
@@ -0,0 +1 @@
+Subproject commit 67cc55c340ddd1c62ea84d1f9774cbf6e297b970
1 bundle/vim-pathogen
@@ -0,0 +1 @@
+Subproject commit ab64b4ddd0c184a528780b498a0b0a5b40248f7c
1 bundle/vim-surround
@@ -0,0 +1 @@
+Subproject commit 4eb2cdfccc016889acfa3b5d63e8f390a87863cf
1 bundle/vim-taglist-plus
@@ -0,0 +1 @@
+Subproject commit fc9f1c843733a0fd2dec29d49d5d83912c978914
1 bundle/vim-unimpaired
@@ -0,0 +1 @@
+Subproject commit 440629adb4051e5f9920704570d1ff0e88356dc2
View
186 lib/html5check
@@ -0,0 +1,186 @@
+#!/usr/bin/python
+
+# Copyright (c) 2007-2008 Mozilla Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+import httplib
+import os
+import sys
+import re
+import urlparse
+import string
+import gzip
+import StringIO
+
+extPat = re.compile(r'^.*\.([A-Za-z]+)$')
+extDict = {
+ "html" : "text/html",
+ "htm" : "text/html",
+ "xhtml" : "application/xhtml+xml",
+ "xht" : "application/xhtml+xml",
+ "xml" : "application/xml",
+}
+
+argv = sys.argv[1:]
+
+forceXml = 0
+forceHtml = 0
+gnu = 0
+errorsOnly = 0
+encoding = None
+fileName = None
+contentType = None
+inputHandle = None
+service = 'http://html5.validator.nu/'
+
+for arg in argv:
+ if '--help' == arg:
+ print '-h : force text/html'
+ print '-x : force application/xhtml+xml'
+ print '-g : GNU output'
+ print '-e : errors only (no info or warnings)'
+ print '--encoding=foo : declare encoding foo'
+ print '--service=url : the address of the HTML5 validator'
+ print 'One file argument allowed. Leave out to read from stdin.'
+ sys.exit(0)
+ elif arg.startswith("--encoding="):
+ encoding = arg[11:]
+ elif arg.startswith("--service="):
+ service = arg[10:]
+ elif arg.startswith("--"):
+ sys.stderr.write('Unknown argument %s.\n' % arg)
+ sys.exit(2)
+ elif arg.startswith("-"):
+ for c in arg[1:]:
+ if 'x' == c:
+ forceXml = 1
+ elif 'h' == c:
+ forceHtml = 1
+ elif 'g' == c:
+ gnu = 1
+ elif 'e' == c:
+ errorsOnly = 1
+ else:
+ sys.stderr.write('Unknown argument %s.\n' % arg)
+ sys.exit(3)
+ else:
+ if fileName:
+ sys.stderr.write('Cannot have more than one input file.\n')
+ sys.exit(1)
+ fileName = arg
+
+if forceXml and forceHtml:
+ sys.stderr.write('Cannot force HTML and XHTML at the same time.\n')
+ sys.exit(2)
+
+if forceXml:
+ contentType = 'application/xhtml+xml'
+elif forceHtml:
+ contentType = 'text/html'
+elif fileName:
+ m = extPat.match(fileName)
+ if m:
+ ext = m.group(1)
+ ext = ext.translate(string.maketrans(string.ascii_uppercase, string.ascii_lowercase))
+ if extDict.has_key(ext):
+ contentType = extDict[ext]
+ else:
+ sys.stderr.write('Unable to guess Content-Type from file name. Please force the type.\n')
+ sys.exit(3)
+ else:
+ sys.stderr.write('Could not extract a filename extension. Please force the type.\n')
+ sys.exit(6)
+else:
+ sys.stderr.write('Need to force HTML or XHTML when reading from stdin.\n')
+ sys.exit(4)
+
+if encoding:
+ contentType = '%s; charset=%s' % (contentType, encoding)
+
+if fileName:
+ inputHandle = open(fileName, "rb")
+else:
+ inputHandle = sys.stdin
+
+data = inputHandle.read()
+
+buf = StringIO.StringIO()
+gzipper = gzip.GzipFile(fileobj=buf, mode='wb')
+gzipper.write(data)
+gzipper.close()
+gzippeddata = buf.getvalue()
+buf.close()
+
+connection = None
+response = None
+status = 302
+redirectCount = 0
+
+url = service
+if gnu:
+ url = url + '?out=gnu'
+else:
+ url = url + '?out=text'
+
+if errorsOnly:
+ url = url + '&level=error'
+
+while (status == 302 or status == 301 or status == 307) and redirectCount < 10:
+ if redirectCount > 0:
+ url = response.getheader('Location')
+ parsed = urlparse.urlsplit(url)
+ if parsed[0] != 'http':
+ sys.stderr.write('URI scheme %s not supported.\n' % parsed[0])
+ sys.exit(7)
+ if redirectCount > 0:
+ connection.close() # previous connection
+ print 'Redirecting to %s' % url
+ print 'Please press enter to continue or type "stop" followed by enter to stop.'
+ if raw_input() != "":
+ sys.exit(0)
+ connection = httplib.HTTPConnection(parsed[1])
+ connection.connect()
+ connection.putrequest("POST", "%s?%s" % (parsed[2], parsed[3]), skip_accept_encoding=1)
+ connection.putheader("Accept-Encoding", 'gzip')
+ connection.putheader("Content-Type", contentType)
+ connection.putheader("Content-Encoding", 'gzip')
+ connection.putheader("Content-Length", len(gzippeddata))
+ connection.endheaders()
+ connection.send(gzippeddata)
+ response = connection.getresponse()
+ status = response.status
+ redirectCount += 1
+
+if status != 200:
+ sys.stderr.write('%s %s\n' % (status, response.reason))
+ sys.exit(5)
+
+if response.getheader('Content-Encoding', 'identity').lower() == 'gzip':
+ response = gzip.GzipFile(fileobj=StringIO.StringIO(response.read()))
+
+if fileName and gnu:
+ quotedName = '"%s"' % fileName.replace('"', '\\042')
+ for line in response:
+ sys.stdout.write(quotedName)
+ sys.stdout.write(line)
+else:
+ sys.stdout.write(response.read())
+
+connection.close()
View
7 vimrc
@@ -781,6 +781,8 @@ let g:CommandTMaxHeight=20
let g:syntastic_auto_loc_list=2
" Disable for HTML as it doesn't play nicely
+" (cf. http://stackoverflow.com/questions/5237275/how-can-i-validate-html5-directly-in-vim)
+" SEE HTML5 validation further on
let g:syntastic_disabled_filetypes = ['html']
"1}}}
@@ -1399,6 +1401,11 @@ map <S-Enter> O<ESC> " awesome, inserts new line without going into insert mode
"1}}}
+"--------HTML5 validation--------------{{{1
+"check html
+map ,5 :!html5check %<CR>
+
+"1}}}
"------------------------------------------------------------------------------
" PLUGINS

0 comments on commit 39cb951

Please sign in to comment.