Update libhtml.py to handle html5 and make html5 the default -- extra stuff

svn: r18642
This commit is contained in:
Gerald Britton 2011-12-20 16:38:05 +00:00
parent 78e3584aec
commit 11a7aa2e8e

View File

@ -60,6 +60,8 @@ __all__ = ['Html']
#
# XHTML DOCTYPE constants to be used in <!DOCTYPE ... > statements
#
# Reference: http://www.w3.org/QA/2002/04/valid-dtd-list.html
#
#------------------------------------------------------------------------
_XHTML10_STRICT = '"-//W3C//DTD XHTML 1.0 Strict//EN"\n' \
@ -427,8 +429,8 @@ class Html(list):
)
self[0:0] = [xmldecl]
#
def addDOCTYPE(self, name='html', public='PUBLIC',
external_id=_XHTML10_STRICT, *args):
def addDOCTYPE(self, name='HTML', public='',
external_id=_HTML5, *args):
"""
Add a DOCTYPE statement to the start of the list
@ -441,12 +443,14 @@ class Html(list):
:param args: 0 or more positional parameters to be added to this
DOCTYPE.
"""
doctype = '<!DOCTYPE %s %s %s%s>' % (
doctype = (
'<!DOCTYPE %s %s %s%s' % (
name,
public,
external_id,
' %s'*len(args) % args
)
).rstrip() + '>'
# Note: DOCTYPE declaration must follow XML declaration
if len(self) and self[0][:6] == '<?xml ':