Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implementing proper html5 syntax checking (,5 mapping)
- Loading branch information
Peter Host
committed
Nov 27, 2011
1 parent
35732df
commit 39cb951
Showing
37 changed files
with
339 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule Decho
added at
3a55ac
Submodule FuzzyFinder
added at
b9f165
Submodule LustyJuggler
added at
6722d3
Submodule PreciseJump
added at
72bc53
Submodule SearchComplete
added at
d85ccf
Submodule YankRing.vim
added at
280ca1
Submodule csapprox
added at
f98bf4
Submodule html5-syntax.vim
added at
2f82fc
Submodule jshint.vim
added at
dd2e24
Submodule neocomplcache
added at
d847ce
Submodule nerdcommenter
added at
b28e7b
Submodule repeat.vim
added at
6336f3
Submodule scss-syntax.vim
added at
d4016f
Submodule session.vim--Odding
added at
d99521
Submodule snipMate
added at
018e0d
Submodule syntastic
added at
3c2674
Submodule tartify
added at
08170d
Submodule vim-bclose
added at
b93bc4
Submodule vim-bufexplorer
added at
3af553
Submodule vim-colors-solarized
added at
528a59
Submodule vim-css-color
added at
417eaf
Submodule vim-fugitive
added at
1b7e40
Submodule vim-git
added at
0a0d79
Submodule vim-git-branch-info
added at
fc4313
Submodule vim-javascript
added at
9990a7
Submodule vim-markdown
added at
f3f96f
Submodule vim-markdown-preview
added at
b0842f
Submodule vim-matchit
added at
67cc55
Submodule vim-pathogen
added at
ab64b4
Submodule vim-surround
added at
4eb2cd
Submodule vim-taglist-plus
added at
fc9f1c
Submodule vim-unimpaired
added at
440629
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters