Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

implementing proper html5 syntax checking (,5 mapping)

  • Loading branch information...
commit 39cb9514628bed0e6f806c020f759c55c8c818fc 1 parent 35732df
authored November 27, 2011
99  .gitmodules
... ...
@@ -0,0 +1,99 @@
  1
+[submodule "bundle/vim-pathogen"]
  2
+	path = bundle/vim-pathogen
  3
+	url = https://github.com/tpope/vim-pathogen.git
  4
+[submodule "bundle/tartify"]
  5
+	path = bundle/tartify
  6
+	url = git://github.com/peterhost/tartify.git
  7
+[submodule "bundle/vim-fugitive"]
  8
+	path = bundle/vim-fugitive
  9
+	url = git://github.com/tpope/vim-fugitive.git
  10
+[submodule "bundle/vim-git-branch-info"]
  11
+	path = bundle/vim-git-branch-info
  12
+	url = git://github.com/taq/vim-git-branch-info.git
  13
+[submodule "bundle/jshint.vim"]
  14
+	path = bundle/jshint.vim
  15
+	url = git://github.com/wookiehangover/jshint.vim.git
  16
+[submodule "bundle/csapprox"]
  17
+	path = bundle/csapprox
  18
+	url = git://github.com/godlygeek/csapprox.git
  19
+[submodule "bundle/vim-bufexplorer"]
  20
+	path = bundle/vim-bufexplorer
  21
+	url = git://github.com/slack/vim-bufexplorer.git
  22
+[submodule "bundle/LustyJuggler"]
  23
+	path = bundle/LustyJuggler
  24
+	url = git://github.com/vim-scripts/LustyJuggler.git
  25
+[submodule "bundle/syntastic"]
  26
+	path = bundle/syntastic
  27
+	url = git://github.com/scrooloose/syntastic.git
  28
+[submodule "bundle/vim-matchit"]
  29
+	path = bundle/vim-matchit
  30
+	url = git://github.com/mhz/vim-matchit.git
  31
+[submodule "bundle/nerdcommenter"]
  32
+	path = bundle/nerdcommenter
  33
+	url = git://github.com/scrooloose/nerdcommenter.git
  34
+[submodule "bundle/vim-markdown"]
  35
+	path = bundle/vim-markdown
  36
+	url = git://github.com/plasticboy/vim-markdown.git
  37
+[submodule "bundle/vim-surround"]
  38
+	path = bundle/vim-surround
  39
+	url = git://github.com/tpope/vim-surround.git
  40
+[submodule "bundle/repeat.vim"]
  41
+	path = bundle/repeat.vim
  42
+	url = git://github.com/vim-scripts/repeat.vim.git
  43
+[submodule "bundle/vim-css-color"]
  44
+	path = bundle/vim-css-color
  45
+	url = git://github.com/skammer/vim-css-color.git
  46
+[submodule "bundle/vim-javascript"]
  47
+	path = bundle/vim-javascript
  48
+	url = git://github.com/pangloss/vim-javascript.git
  49
+[submodule "bundle/YankRing.vim"]
  50
+	path = bundle/YankRing.vim
  51
+	url = git://github.com/vim-scripts/YankRing.vim.git
  52
+[submodule "bundle/session.vim--Odding"]
  53
+	path = bundle/session.vim--Odding
  54
+	url = git://github.com/vim-scripts/session.vim--Odding.git
  55
+[submodule "bundle/vim-colors-solarized"]
  56
+	path = bundle/vim-colors-solarized
  57
+	url = git://github.com/altercation/vim-colors-solarized.git
  58
+[submodule "bundle/vim-bclose"]
  59
+	path = bundle/vim-bclose
  60
+	url = git://github.com/cespare/vim-bclose.git
  61
+[submodule "bundle/Decho"]
  62
+	path = bundle/Decho
  63
+	url = git://github.com/vim-scripts/Decho.git
  64
+[submodule "bundle/vim-unimpaired"]
  65
+	path = bundle/vim-unimpaired
  66
+	url = git://github.com/tpope/vim-unimpaired.git
  67
+[submodule "bundle/vim-git"]
  68
+	path = bundle/vim-git
  69
+	url = git://github.com/tpope/vim-git.git
  70
+[submodule "bundle/scss-syntax.vim"]
  71
+	path = bundle/scss-syntax.vim
  72
+	url = git://github.com/cakebaker/scss-syntax.vim.git
  73
+[submodule "bundle/html5-syntax.vim"]
  74
+	path = bundle/html5-syntax.vim
  75
+	url = git://github.com/othree/html5-syntax.vim.git
  76
+[submodule "bundle/L9"]
  77
+	path = bundle/L9
  78
+	url = git://github.com/vim-scripts/L9.git
  79
+[submodule "bundle/FuzzyFinder"]
  80
+	path = bundle/FuzzyFinder
  81
+	url = git://github.com/vim-scripts/FuzzyFinder.git
  82
+[submodule "bundle/PreciseJump"]
  83
+	path = bundle/PreciseJump
  84
+	url = git@github.com:peterhost/PreciseJump.git
  85
+[submodule "bundle/neocomplcache"]
  86
+	path = bundle/neocomplcache
  87
+	url = git://github.com/Shougo/neocomplcache.git
  88
+[submodule "bundle/SearchComplete"]
  89
+	path = bundle/SearchComplete
  90
+	url = git://github.com/vim-scripts/SearchComplete.git
  91
+[submodule "bundle/vim-markdown-preview"]
  92
+	path = bundle/vim-markdown-preview
  93
+	url = git://github.com/peterhost/vim-markdown-preview.git
  94
+[submodule "bundle/vim-taglist-plus"]
  95
+	path = bundle/vim-taglist-plus
  96
+	url = git://github.com/int3/vim-taglist-plus.git
  97
+[submodule "bundle/snipMate"]
  98
+	path = bundle/snipMate
  99
+	url = git://github.com/vim-scripts/snipMate.git
15  bin/bootstrap
@@ -30,5 +30,18 @@ if  ! which node >/dev/null 2>&1  ||  ! which jsctags >/dev/null 2>&1 ;then
30 30
 	echo "
31 31
 	WARN : either node.js or jsctags (jsdoctor) seems to be missing on your
32 32
 	       system. vim-taglist-plus will use CTAGS instead of JSCTAGS for js
33  
-		   (https://github.com/pcwalton/doctorjs.git)"
  33
+		   (https://github.com/pcwalton/doctorjs.git)
  34
+"
  35
+fi
  36
+
  37
+
  38
+if  ! which html5check >/dev/null 2>&1 ;then
  39
+	echo "
  40
+	WARN : html5check is not in your path, do: 
  41
+
  42
+	         ln -s ~/.vim/lib/html5check /usr/local/bin/html5check
  43
+
  44
+	       so that you can use the ",5" mapping to properly validate
  45
+         HTML5 files (syntastic's based on tidy and is broken)
  46
+"
34 47
 fi
1  bundle/Decho
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 3a55aca47b8ab629b64302f6f50966e3afb167e1
1  bundle/FuzzyFinder
... ...
@@ -0,0 +1 @@
  1
+Subproject commit b9f165970346df55862853dd83c8a4f2b2b70262
1  bundle/L9
... ...
@@ -0,0 +1 @@
  1
+Subproject commit c822b05ee0886f9a9703227dc85a6d47612c4bf1
1  bundle/LustyJuggler
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 6722d371eeb2c14dd4449de2bed77ffda435c72b
1  bundle/PreciseJump
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 72bc53a7e69c2d10753f7236a505bcdd7a5be220
1  bundle/SearchComplete
... ...
@@ -0,0 +1 @@
  1
+Subproject commit d85ccf8c6c1fa88feff0c56b8fe271b7d91bd292
1  bundle/YankRing.vim
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 280ca1b471bd3a0d2347735e8fcbd03a53f2c6ad
1  bundle/csapprox
... ...
@@ -0,0 +1 @@
  1
+Subproject commit f98bf4acef9d9aa5e7f5b42eba09e259908f639b
1  bundle/html5-syntax.vim
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 2f82fce6b97407e09a9635938e21506444c4d13a
1  bundle/jshint.vim
... ...
@@ -0,0 +1 @@
  1
+Subproject commit dd2e24a5ee604759862bf2ab408bde6783eca047
1  bundle/neocomplcache
... ...
@@ -0,0 +1 @@
  1
+Subproject commit d847ce395ac1a0000205b5a9060bb7372c5dd690
1  bundle/nerdcommenter
... ...
@@ -0,0 +1 @@
  1
+Subproject commit b28e7be63235982501ab7dd30c03ea7feef7b095
1  bundle/repeat.vim
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 6336f383e25874aee82b8418940592fba618ad3e
1  bundle/scss-syntax.vim
... ...
@@ -0,0 +1 @@
  1
+Subproject commit d4016f8b31f786d830bb59bb78979c6b5d5a200d
1  bundle/session.vim--Odding
... ...
@@ -0,0 +1 @@
  1
+Subproject commit d9952100f8b186fb2d14713dd42b9377c4b25734
1  bundle/snipMate
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 018e0dd72178f0936ba4399d7393b2d2cf78e368
1  bundle/syntastic
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 3c26740b28073c262e6b2b723c5c608815ce4290
1  bundle/tartify
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 08170d13400d944597e16e8c49f8af7c83b3db1a
1  bundle/vim-bclose
... ...
@@ -0,0 +1 @@
  1
+Subproject commit b93bc48c10dee3517100c67b4b33057b23bf8d91
1  bundle/vim-bufexplorer
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 3af55351b61f540cb4898ffa5f362a6b54dd5603
1  bundle/vim-colors-solarized
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 528a59f26d12278698bb946f8fb82a63711eec21
1  bundle/vim-css-color
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 417eaf8a20a6208e34ff167f5636b20f8f812ed8
1  bundle/vim-fugitive
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 1b7e4070f5f7b7522422f5b00a75b323cc314daf
1  bundle/vim-git
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 0a0d799e72ed63a08eb60070eadb343dea3b8c26
1  bundle/vim-git-branch-info
... ...
@@ -0,0 +1 @@
  1
+Subproject commit fc43139eaf11680b383c941382af4d1816330e8c
1  bundle/vim-javascript
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 9990a767695c78a44611ce33fb2dbc25c83d8827
1  bundle/vim-markdown
... ...
@@ -0,0 +1 @@
  1
+Subproject commit f3f96fd7c1bec0527de62415fd344e73994f1c47
1  bundle/vim-markdown-preview
... ...
@@ -0,0 +1 @@
  1
+Subproject commit b0842f896bf151324573e1d11a02be3c028876eb
1  bundle/vim-matchit
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 67cc55c340ddd1c62ea84d1f9774cbf6e297b970
1  bundle/vim-pathogen
... ...
@@ -0,0 +1 @@
  1
+Subproject commit ab64b4ddd0c184a528780b498a0b0a5b40248f7c
1  bundle/vim-surround
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 4eb2cdfccc016889acfa3b5d63e8f390a87863cf
1  bundle/vim-taglist-plus
... ...
@@ -0,0 +1 @@
  1
+Subproject commit fc9f1c843733a0fd2dec29d49d5d83912c978914
1  bundle/vim-unimpaired
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 440629adb4051e5f9920704570d1ff0e88356dc2
186  lib/html5check
... ...
@@ -0,0 +1,186 @@
  1
+#!/usr/bin/python
  2
+
  3
+# Copyright (c) 2007-2008 Mozilla Foundation
  4
+#
  5
+# Permission is hereby granted, free of charge, to any person obtaining a 
  6
+# copy of this software and associated documentation files (the "Software"), 
  7
+# to deal in the Software without restriction, including without limitation 
  8
+# the rights to use, copy, modify, merge, publish, distribute, sublicense, 
  9
+# and/or sell copies of the Software, and to permit persons to whom the 
  10
+# Software is furnished to do so, subject to the following conditions:
  11
+#
  12
+# The above copyright notice and this permission notice shall be included in 
  13
+# all copies or substantial portions of the Software.
  14
+#
  15
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
  16
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
  17
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
  18
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
  19
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
  20
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
  21
+# DEALINGS IN THE SOFTWARE.
  22
+
  23
+import httplib
  24
+import os
  25
+import sys
  26
+import re
  27
+import urlparse
  28
+import string
  29
+import gzip
  30
+import StringIO
  31
+
  32
+extPat = re.compile(r'^.*\.([A-Za-z]+)$')
  33
+extDict = {
  34
+  "html" : "text/html",
  35
+  "htm" : "text/html",
  36
+  "xhtml" : "application/xhtml+xml",
  37
+  "xht" : "application/xhtml+xml",
  38
+  "xml" : "application/xml",
  39
+}
  40
+
  41
+argv = sys.argv[1:]
  42
+
  43
+forceXml = 0
  44
+forceHtml = 0
  45
+gnu = 0
  46
+errorsOnly = 0
  47
+encoding = None
  48
+fileName = None
  49
+contentType = None
  50
+inputHandle = None
  51
+service = 'http://html5.validator.nu/'
  52
+
  53
+for arg in argv:
  54
+  if '--help' == arg:
  55
+    print '-h : force text/html'
  56
+    print '-x : force application/xhtml+xml'
  57
+    print '-g : GNU output'
  58
+    print '-e : errors only (no info or warnings)'
  59
+    print '--encoding=foo : declare encoding foo'
  60
+    print '--service=url  : the address of the HTML5 validator'
  61
+    print 'One file argument allowed. Leave out to read from stdin.' 
  62
+    sys.exit(0)
  63
+  elif arg.startswith("--encoding="):
  64
+    encoding = arg[11:]
  65
+  elif arg.startswith("--service="):
  66
+    service = arg[10:]
  67
+  elif arg.startswith("--"):
  68
+      sys.stderr.write('Unknown argument %s.\n' % arg)
  69
+      sys.exit(2)
  70
+  elif arg.startswith("-"):
  71
+    for c in arg[1:]:
  72
+      if 'x' == c:
  73
+        forceXml = 1
  74
+      elif 'h' == c:
  75
+        forceHtml = 1
  76
+      elif 'g' == c:
  77
+        gnu = 1  		
  78
+      elif 'e' == c:
  79
+        errorsOnly = 1
  80
+      else:
  81
+        sys.stderr.write('Unknown argument %s.\n' % arg)
  82
+        sys.exit(3)        		
  83
+  else:
  84
+    if fileName:
  85
+      sys.stderr.write('Cannot have more than one input file.\n')
  86
+      sys.exit(1)
  87
+    fileName = arg
  88
+    
  89
+if forceXml and forceHtml:
  90
+  sys.stderr.write('Cannot force HTML and XHTML at the same time.\n')
  91
+  sys.exit(2)
  92
+  
  93
+if forceXml:
  94
+  contentType = 'application/xhtml+xml'
  95
+elif forceHtml:
  96
+  contentType = 'text/html'
  97
+elif fileName:
  98
+  m = extPat.match(fileName)
  99
+  if m:
  100
+    ext = m.group(1)
  101
+    ext = ext.translate(string.maketrans(string.ascii_uppercase, string.ascii_lowercase))    
  102
+    if extDict.has_key(ext):
  103
+      contentType = extDict[ext]
  104
+    else:
  105
+      sys.stderr.write('Unable to guess Content-Type from file name. Please force the type.\n')
  106
+      sys.exit(3)
  107
+  else:
  108
+    sys.stderr.write('Could not extract a filename extension. Please force the type.\n')
  109
+    sys.exit(6)    
  110
+else:
  111
+  sys.stderr.write('Need to force HTML or XHTML when reading from stdin.\n')
  112
+  sys.exit(4)
  113
+
  114
+if encoding:
  115
+  contentType = '%s; charset=%s' % (contentType, encoding)
  116
+
  117
+if fileName:
  118
+  inputHandle = open(fileName, "rb")
  119
+else:
  120
+  inputHandle = sys.stdin
  121
+
  122
+data = inputHandle.read()
  123
+
  124
+buf = StringIO.StringIO()
  125
+gzipper = gzip.GzipFile(fileobj=buf, mode='wb')
  126
+gzipper.write(data)
  127
+gzipper.close()
  128
+gzippeddata = buf.getvalue()
  129
+buf.close()
  130
+
  131
+connection = None
  132
+response = None
  133
+status = 302
  134
+redirectCount = 0
  135
+
  136
+url = service
  137
+if gnu:
  138
+  url = url + '?out=gnu'
  139
+else:
  140
+  url = url + '?out=text'
  141
+  
  142
+if errorsOnly:
  143
+  url = url + '&level=error'
  144
+
  145
+while (status == 302 or status == 301 or status == 307) and redirectCount < 10:
  146
+  if redirectCount > 0:
  147
+    url = response.getheader('Location')
  148
+  parsed = urlparse.urlsplit(url)
  149
+  if parsed[0] != 'http':
  150
+    sys.stderr.write('URI scheme %s not supported.\n' % parsed[0])
  151
+    sys.exit(7)    
  152
+  if redirectCount > 0:
  153
+    connection.close() # previous connection
  154
+    print 'Redirecting to %s' % url
  155
+    print 'Please press enter to continue or type "stop" followed by enter to stop.'
  156
+    if raw_input() != "":
  157
+      sys.exit(0)
  158
+  connection = httplib.HTTPConnection(parsed[1])
  159
+  connection.connect()
  160
+  connection.putrequest("POST", "%s?%s" % (parsed[2], parsed[3]), skip_accept_encoding=1)
  161
+  connection.putheader("Accept-Encoding", 'gzip')
  162
+  connection.putheader("Content-Type", contentType)
  163
+  connection.putheader("Content-Encoding", 'gzip')
  164
+  connection.putheader("Content-Length", len(gzippeddata))
  165
+  connection.endheaders()
  166
+  connection.send(gzippeddata)
  167
+  response = connection.getresponse()
  168
+  status = response.status
  169
+  redirectCount += 1
  170
+
  171
+if status != 200:
  172
+  sys.stderr.write('%s %s\n' % (status, response.reason))
  173
+  sys.exit(5)
  174
+
  175
+if response.getheader('Content-Encoding', 'identity').lower() == 'gzip':
  176
+  response = gzip.GzipFile(fileobj=StringIO.StringIO(response.read()))
  177
+  
  178
+if fileName and gnu:
  179
+  quotedName = '"%s"' % fileName.replace('"', '\\042')
  180
+  for line in response:
  181
+    sys.stdout.write(quotedName)
  182
+    sys.stdout.write(line)
  183
+else:
  184
+  sys.stdout.write(response.read())
  185
+
  186
+connection.close()
7  vimrc
@@ -781,6 +781,8 @@ let g:CommandTMaxHeight=20
781 781
     let g:syntastic_auto_loc_list=2
782 782
 
783 783
 " Disable for HTML as it doesn't play nicely
  784
+" (cf. http://stackoverflow.com/questions/5237275/how-can-i-validate-html5-directly-in-vim)
  785
+" SEE HTML5 validation further on
784 786
     let g:syntastic_disabled_filetypes = ['html']
785 787
 
786 788
 "1}}}
@@ -1399,6 +1401,11 @@ map <S-Enter> O<ESC> " awesome, inserts new line without going into insert mode
1399 1401
 
1400 1402
 
1401 1403
 "1}}}
  1404
+"--------HTML5 validation--------------{{{1
  1405
+"check html
  1406
+map ,5 :!html5check %<CR>
  1407
+
  1408
+"1}}}
1402 1409
 
1403 1410
 "------------------------------------------------------------------------------
1404 1411
 "                           PLUGINS

0 notes on commit 39cb951

Please sign in to comment.
Something went wrong with that request. Please try again.