marucc
6/26/2013 - 3:54 AM

html5のチェック html5libを入れている環境でworkonしておくこと。

html5のチェック html5libを入れている環境でworkonしておくこと。

#!/usr/bin/env python
# coding: utf-8
import os
import sys

from html5lib import HTMLParser

argvs = sys.argv
argc = len(argvs)

if (argc != 2):
    print 'Usage: # python %s filename' % argvs[0]
    quit()

print 'html validate check %s ...' % argvs[1]
f = open(argvs[1])
html = f.read()
f.close

parser = HTMLParser()
doc = parser.parse(html)
errors = parser.errors
if len(errors):
    print 'ERROR'
    print errors
    sys.exit(1)
else:
    print 'OK'