')
+ walker = treewalkers.getTreeWalker('lxml')
+ output = Lint(walker(lxmltree))
+
+ assert list(output) == expected
diff --git a/html5lib/treewalkers/lxmletree.py b/html5lib/treewalkers/lxmletree.py
index 7d99adc2..ff31a44e 100644
--- a/html5lib/treewalkers/lxmletree.py
+++ b/html5lib/treewalkers/lxmletree.py
@@ -22,13 +22,20 @@ class Root(object):
def __init__(self, et):
self.elementtree = et
self.children = []
- if et.docinfo.internalDTD:
- self.children.append(Doctype(self,
- ensure_str(et.docinfo.root_name),
- ensure_str(et.docinfo.public_id),
- ensure_str(et.docinfo.system_url)))
- root = et.getroot()
- node = root
+
+ try:
+ if et.docinfo.internalDTD:
+ self.children.append(Doctype(self,
+ ensure_str(et.docinfo.root_name),
+ ensure_str(et.docinfo.public_id),
+ ensure_str(et.docinfo.system_url)))
+ except AttributeError:
+ pass
+
+ try:
+ node = et.getroot()
+ except AttributeError:
+ node = et
while node.getprevious() is not None:
node = node.getprevious()
@@ -118,12 +125,12 @@ def __len__(self):
class TreeWalker(_base.NonRecursiveTreeWalker):
def __init__(self, tree):
# pylint:disable=redefined-variable-type
- if hasattr(tree, "getroot"):
- self.fragmentChildren = set()
- tree = Root(tree)
- elif isinstance(tree, list):
+ if isinstance(tree, list):
self.fragmentChildren = set(tree)
tree = FragmentRoot(tree)
+ else:
+ self.fragmentChildren = set()
+ tree = Root(tree)
_base.NonRecursiveTreeWalker.__init__(self, tree)
self.filter = ihatexml.InfosetFilter()
From c35d84c1c01db16bace0c69f0b1992f5123b322e Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Sun, 29 May 2016 04:38:10 +0100
Subject: [PATCH 047/223] Fix #217: Fully remove element in removeChild in
etree treebuilder (#259)
This adds a test here because we still fail the upstream one, as
our implementation of AAA is outdated.
---
html5lib/tests/test_parser2.py | 7 ++++++-
html5lib/treebuilders/etree.py | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/html5lib/tests/test_parser2.py b/html5lib/tests/test_parser2.py
index 0ec5b049..b7a92fd7 100644
--- a/html5lib/tests/test_parser2.py
+++ b/html5lib/tests/test_parser2.py
@@ -7,7 +7,7 @@
from . import support # noqa
from html5lib.constants import namespaces
-from html5lib import parse, HTMLParser
+from html5lib import parse, parseFragment, HTMLParser
# tests that aren't autogenerated from text files
@@ -88,3 +88,8 @@ def test_debug_log():
expected[i] = tuple(log)
assert parser.log == expected
+
+
+def test_no_duplicate_clone():
+ frag = parseFragment("")
+ assert len(frag) == 2
diff --git a/html5lib/treebuilders/etree.py b/html5lib/treebuilders/etree.py
index d394148d..4d12bd45 100644
--- a/html5lib/treebuilders/etree.py
+++ b/html5lib/treebuilders/etree.py
@@ -100,6 +100,7 @@ def insertBefore(self, node, refNode):
node.parent = self
def removeChild(self, node):
+ self._childNodes.remove(node)
self._element.remove(node._element)
node.parent = None
From 563dc298ea43021f9a9306fc7da3734ea5d9d8ec Mon Sep 17 00:00:00 2001
From: Adam Chainz
Date: Sun, 29 May 2016 21:21:58 +0100
Subject: [PATCH 048/223] Convert readthedocs link for their .org -> .io
migration for hosted projects (#261)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
As per [their blog post of the 27th April](https://blog.readthedocs.com/securing-subdomains/) ‘Securing subdomains’:
> Starting today, Read the Docs will start hosting projects from subdomains on the domain readthedocs.io, instead of on readthedocs.org. This change addresses some security concerns around site cookies while hosting user generated data on the same domain as our dashboard.
Test Plan: Manually visited all the links I’ve modified.
---
CHANGES.rst | 2 +-
README.rst | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 1f87d9ab..cdf21bc4 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -219,7 +219,7 @@ Released on May 17, 2013
* Test harness has been improved and now depends on ``nose``.
-* Documentation updated and moved to http://html5lib.readthedocs.org/.
+* Documentation updated and moved to https://html5lib.readthedocs.io/.
0.95
diff --git a/README.rst b/README.rst
index 47eb90d3..6859ed30 100644
--- a/README.rst
+++ b/README.rst
@@ -84,7 +84,7 @@ format:
parser = html5lib.HTMLParser(tree=html5lib.getTreeBuilder("dom"))
minidom_document = parser.parse("
Hello World!")
-More documentation is available at http://html5lib.readthedocs.org/.
+More documentation is available at https://html5lib.readthedocs.io/.
Installation
From 1ff3c802503388f39ce658decfa41f517cfd28f2 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Mon, 6 Jun 2016 21:57:48 +0100
Subject: [PATCH 049/223] Fix #239: make elementInScope consider namespaces for
target (#262)
r=nobody!
---
.pytest.expect | 45 ----------------------------------
html5lib/treebuilders/_base.py | 9 +++++--
2 files changed, 7 insertions(+), 47 deletions(-)
diff --git a/.pytest.expect b/.pytest.expect
index 8bfcf4b7..f03e18f8 100644
--- a/.pytest.expect
+++ b/.pytest.expect
@@ -208,51 +208,6 @@ u'html5lib/tests/testdata/tree-construction/isindex.dat::3::cElementTree::parser
u'html5lib/tests/testdata/tree-construction/isindex.dat::3::cElementTree::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/isindex.dat::3::lxml::parser::namespaced': FAIL
u'html5lib/tests/testdata/tree-construction/isindex.dat::3::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::DOM::treewalker': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::ElementTree::treewalker': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::cElementTree::treewalker': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::genshi::treewalker': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::0::lxml::treewalker': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::1::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::1::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::1::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::1::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::1::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::1::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::1::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::1::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::2::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::2::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::2::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::2::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::2::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::2::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::2::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::2::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::3::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::3::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::3::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::3::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::3::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::3::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::3::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::3::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::4::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::4::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::4::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::4::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::4::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::4::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::4::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/math.dat::4::lxml::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::3::DOM::parser::namespaced': FAIL
u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::3::DOM::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::3::ElementTree::parser::namespaced': FAIL
diff --git a/html5lib/treebuilders/_base.py b/html5lib/treebuilders/_base.py
index 900a724c..a4b2792a 100644
--- a/html5lib/treebuilders/_base.py
+++ b/html5lib/treebuilders/_base.py
@@ -167,12 +167,17 @@ def elementInScope(self, target, variant=None):
# If we pass a node in we match that. if we pass a string
# match any node with that name
exactNode = hasattr(target, "nameTuple")
+ if not exactNode:
+ if isinstance(target, text_type):
+ target = (namespaces["html"], target)
+ assert isinstance(target, tuple)
listElements, invert = listElementsMap[variant]
for node in reversed(self.openElements):
- if (node.name == target and not exactNode or
- node == target and exactNode):
+ if exactNode and node == target:
+ return True
+ elif not exactNode and node.nameTuple == target:
return True
elif (invert ^ (node.nameTuple in listElements)):
return False
From 5197f557afe178b9ff7ec9c37a364c73ce00194e Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Mon, 6 Jun 2016 22:40:46 +0100
Subject: [PATCH 050/223] Fix #132: add test for #115, single character
fragments (#264)
r=nobody!
---
html5lib/tests/test_treewalkers.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/html5lib/tests/test_treewalkers.py b/html5lib/tests/test_treewalkers.py
index 81ed2778..67fc89e5 100644
--- a/html5lib/tests/test_treewalkers.py
+++ b/html5lib/tests/test_treewalkers.py
@@ -1,5 +1,7 @@
from __future__ import absolute_import, division, unicode_literals
+import itertools
+
import pytest
try:
@@ -100,6 +102,24 @@ def test_treewalker_six_mix():
yield runTreewalkerEditTest, intext, expected, attrs, tree
+@pytest.mark.parametrize("tree,char", itertools.product(sorted(treeTypes.items()), ["x", "\u1234"]))
+def test_fragment_single_char(tree, char):
+ expected = [
+ {'data': char, 'type': 'Characters'}
+ ]
+
+ treeName, treeClass = tree
+ if treeClass is None:
+ pytest.skip("Treebuilder not loaded")
+
+ parser = html5parser.HTMLParser(tree=treeClass["builder"])
+ document = parser.parseFragment(char)
+ document = treeClass.get("adapter", lambda x: x)(document)
+ output = Lint(treeClass["walker"](document))
+
+ assert list(output) == expected
+
+
@pytest.mark.skipif(treeTypes["lxml"] is None, reason="lxml not importable")
def test_lxml_xml():
expected = [
From d5b0dc26ca5f3f89db0a7256894d322cd3180df7 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Mon, 6 Jun 2016 17:16:28 +0100
Subject: [PATCH 051/223] Make sure setup.py works regardless of cwd
---
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 4d5f1523..0d867279 100644
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,7 @@
long_description = readme_file.read() + '\n' + changes_file.read()
version = None
-with open(join("html5lib", "__init__.py"), "rb") as init_file:
+with open(join(here, "html5lib", "__init__.py"), "rb") as init_file:
t = ast.parse(init_file.read(), filename="__init__.py", mode="exec")
assert isinstance(t, ast.Module)
assignments = filter(lambda x: isinstance(x, ast.Assign), t.body)
From 21aabd6413c7429b1111265714b3de9c155bda24 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Mon, 6 Jun 2016 18:15:32 +0100
Subject: [PATCH 052/223] Try fixing #231 again: Return to using
platform_python_implementation
This makes us require setuptools>=18.5
---
requirements-install.sh | 2 +-
requirements.txt | 1 +
setup.py | 7 ++++---
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/requirements-install.sh b/requirements-install.sh
index 8cab142d..9b28888a 100755
--- a/requirements-install.sh
+++ b/requirements-install.sh
@@ -6,7 +6,7 @@ if [[ $USE_OPTIONAL != "true" && $USE_OPTIONAL != "false" ]]; then
fi
# Make sure we're running setuptools >= 18.5
-pip install -U pip setuptools
+pip install -U pip setuptools>=18.5
pip install -U -r requirements-test.txt
diff --git a/requirements.txt b/requirements.txt
index 745993b9..92c09036 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,4 @@
six
webencodings
ordereddict ; python_version < '2.7'
+setuptools>=18.5
diff --git a/setup.py b/setup.py
index 0d867279..7cc30534 100644
--- a/setup.py
+++ b/setup.py
@@ -52,6 +52,7 @@
install_requires=[
'six',
'webencodings',
+ 'setuptools>=18.5'
],
extras_require={
# A empty extra that only has a conditional marker will be
@@ -60,8 +61,8 @@
# A conditional extra will only install these items when the extra is
# requested and the condition matches.
- "datrie:platform.python_implementation == 'CPython'": ["datrie"],
- "lxml:platform.python_implementation == 'CPython'": ["lxml"],
+ "datrie:platform_python_implementation == 'CPython'": ["datrie"],
+ "lxml:platform_python_implementation == 'CPython'": ["lxml"],
# Standard extras, will be installed when the extra is requested.
"genshi": ["genshi"],
@@ -72,6 +73,6 @@
# extra that will be installed whenever the condition matches and the
# all extra is requested.
"all": ["genshi", "chardet>=2.2"],
- "all:platform.python_implementation == 'CPython'": ["datrie", "lxml"],
+ "all:platform_python_implementation == 'CPython'": ["datrie", "lxml"],
},
)
From c562f28b03df132c6311a7c930635dd0e12abc5b Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Mon, 6 Jun 2016 18:21:52 +0100
Subject: [PATCH 053/223] Give a more useful error message than a SyntaxError
on old setuptools
---
setup.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 7cc30534..7c419e2c 100644
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,17 @@
+from __future__ import print_function
+
import ast
import codecs
+import sys
from os.path import join, dirname
-from setuptools import setup, find_packages
+from setuptools import setup, find_packages, __version__ as setuptools_version
+from pkg_resources import parse_version
+if parse_version(setuptools_version) < parse_version("18.5"):
+ print("html5lib requires setuptools version 18.5 or above; "
+ "please upgrade before installing (you have %s)" % setuptools_version)
+ sys.exit(1)
classifiers = [
'Development Status :: 5 - Production/Stable',
From 11bdb490d410931ed366a0f6161ed8144efde315 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Mon, 27 Jun 2016 05:53:57 -0700
Subject: [PATCH 054/223] Make self closing col start tags not cause a parse
error (#244)
---
AUTHORS.rst | 1 +
html5lib/html5parser.py | 9 ++++++---
html5lib/tests/test_parser2.py | 6 ++++++
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/AUTHORS.rst b/AUTHORS.rst
index fe9ae89b..c3820ef7 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -41,3 +41,4 @@ Patches and suggestions
- Jim Baker
- Michael[tm] Smith
- Marc Abramowitz
+- Jon Dufresne
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index daee854c..3daf2995 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -171,8 +171,10 @@ def mainLoop(self):
ParseErrorToken = tokenTypes["ParseError"]
for token in self.normalizedTokens():
+ prev_token = None
new_token = token
while new_token is not None:
+ prev_token = new_token
currentNode = self.tree.openElements[-1] if self.tree.openElements else None
currentNodeNamespace = currentNode.namespace if currentNode else None
currentNodeName = currentNode.name if currentNode else None
@@ -211,10 +213,10 @@ def mainLoop(self):
elif type == DoctypeToken:
new_token = phase.processDoctype(new_token)
- if (type == StartTagToken and token["selfClosing"] and
- not token["selfClosingAcknowledged"]):
+ if (type == StartTagToken and prev_token["selfClosing"] and
+ not prev_token["selfClosingAcknowledged"]):
self.parseError("non-void-element-with-trailing-solidus",
- {"name": token["name"]})
+ {"name": prev_token["name"]})
# When the loop finishes it's EOF
reprocess = True
@@ -1933,6 +1935,7 @@ def processCharacters(self, token):
def startTagCol(self, token):
self.tree.insertElement(token)
self.tree.openElements.pop()
+ token["selfClosingAcknowledged"] = True
def startTagOther(self, token):
ignoreEndTag = self.ignoreEndTagColgroup()
diff --git a/html5lib/tests/test_parser2.py b/html5lib/tests/test_parser2.py
index b7a92fd7..21dc59d9 100644
--- a/html5lib/tests/test_parser2.py
+++ b/html5lib/tests/test_parser2.py
@@ -93,3 +93,9 @@ def test_debug_log():
def test_no_duplicate_clone():
frag = parseFragment("")
assert len(frag) == 2
+
+
+def test_self_closing_col():
+ parser = HTMLParser()
+ parser.parseFragment('
')
+ assert not parser.errors
From b45b477c1c0ef8ac12cc310af8b6516f696fc018 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Sun, 29 May 2016 05:01:50 +0100
Subject: [PATCH 055/223] Make genshi treeType get added as None to match the
others
---
html5lib/tests/support.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/tests/support.py b/html5lib/tests/support.py
index 6ae09dbe..dab65c1c 100644
--- a/html5lib/tests/support.py
+++ b/html5lib/tests/support.py
@@ -62,7 +62,7 @@
try:
import genshi # noqa
except ImportError:
- pass
+ treeTypes["genshi"] = None
else:
treeTypes["genshi"] = {
"builder": treebuilders.getTreeBuilder("dom"),
From 8852ff49e0ba463c37a8f448f9499fb4d9dfea5a Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Sun, 29 May 2016 05:15:17 +0100
Subject: [PATCH 056/223] Run tests no matter how deep in directory structure
they are
Also associated update of expectation file
---
.pytest.expect | 880 +++++++++++++++++++++++++++++++++++++
html5lib/tests/conftest.py | 13 +-
2 files changed, 888 insertions(+), 5 deletions(-)
diff --git a/.pytest.expect b/.pytest.expect
index f03e18f8..2effc347 100644
--- a/.pytest.expect
+++ b/.pytest.expect
@@ -336,6 +336,886 @@ u'html5lib/tests/testdata/tree-construction/ruby.dat::7::cElementTree::parser::n
u'html5lib/tests/testdata/tree-construction/ruby.dat::7::cElementTree::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/ruby.dat::7::lxml::parser::namespaced': FAIL
u'html5lib/tests/testdata/tree-construction/ruby.dat::7::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/adoption01.dat::0::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/adoption01.dat::0::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/adoption01.dat::0::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/adoption01.dat::0::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/adoption01.dat::0::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/adoption01.dat::0::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/adoption01.dat::0::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/adoption01.dat::0::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/ark.dat::0::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/ark.dat::0::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/ark.dat::0::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/ark.dat::0::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/ark.dat::0::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/ark.dat::0::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/ark.dat::0::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/ark.dat::0::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::0::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::0::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::0::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::0::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::0::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::0::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::0::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::0::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::1::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::1::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::1::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::1::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::1::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::1::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::1::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/scripted/webkit01.dat::1::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::0::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::0::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::0::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::0::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::0::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::0::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::0::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::0::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::100::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::100::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::100::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::100::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::100::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::100::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::100::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::100::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::101::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::101::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::101::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::101::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::101::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::101::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::101::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::101::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::102::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::102::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::102::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::102::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::102::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::102::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::102::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::102::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::103::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::103::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::103::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::103::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::103::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::103::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::103::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::103::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::104::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::104::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::104::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::104::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::104::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::104::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::104::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::104::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::105::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::105::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::105::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::105::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::105::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::105::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::105::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::105::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::106::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::106::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::106::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::106::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::106::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::106::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::106::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::106::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::107::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::107::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::107::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::107::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::107::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::107::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::107::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::107::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::10::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::10::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::10::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::10::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::10::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::10::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::10::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::10::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::11::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::11::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::11::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::11::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::11::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::11::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::11::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::11::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::12::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::12::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::12::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::12::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::12::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::12::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::12::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::12::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::13::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::13::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::13::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::13::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::13::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::13::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::13::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::13::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::14::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::14::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::14::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::14::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::14::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::14::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::14::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::14::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::15::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::15::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::15::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::15::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::15::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::15::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::15::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::15::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::16::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::16::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::16::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::16::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::16::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::16::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::16::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::16::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::17::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::17::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::17::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::17::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::17::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::17::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::17::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::17::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::18::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::18::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::18::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::18::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::18::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::18::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::18::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::18::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::19::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::19::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::19::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::19::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::19::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::19::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::19::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::19::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::1::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::1::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::1::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::1::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::1::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::1::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::1::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::1::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::20::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::20::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::20::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::20::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::20::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::20::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::20::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::20::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::21::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::21::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::21::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::21::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::21::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::21::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::21::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::21::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::22::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::22::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::22::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::22::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::22::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::22::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::22::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::22::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::23::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::23::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::23::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::23::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::23::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::23::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::23::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::23::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::24::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::24::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::24::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::24::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::24::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::24::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::24::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::24::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::25::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::25::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::25::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::25::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::25::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::25::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::25::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::25::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::26::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::26::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::26::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::26::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::26::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::26::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::26::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::26::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::27::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::27::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::27::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::27::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::27::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::27::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::27::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::27::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::28::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::28::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::28::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::28::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::28::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::28::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::28::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::28::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::29::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::29::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::29::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::29::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::29::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::29::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::29::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::29::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::2::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::2::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::2::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::2::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::2::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::2::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::2::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::2::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::30::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::30::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::30::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::30::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::30::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::30::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::30::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::30::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::31::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::31::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::31::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::31::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::31::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::31::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::31::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::31::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::32::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::32::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::32::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::32::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::32::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::32::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::32::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::32::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::33::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::33::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::33::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::33::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::33::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::33::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::33::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::33::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::34::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::34::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::34::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::34::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::34::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::34::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::34::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::34::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::35::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::35::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::35::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::35::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::35::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::35::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::35::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::35::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::36::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::36::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::36::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::36::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::36::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::36::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::36::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::36::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::37::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::37::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::37::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::37::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::37::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::37::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::37::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::37::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::38::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::38::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::38::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::38::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::38::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::38::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::38::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::38::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::3::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::3::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::3::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::3::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::3::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::3::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::3::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::3::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::40::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::40::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::40::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::40::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::40::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::40::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::40::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::40::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::41::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::41::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::41::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::41::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::41::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::41::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::41::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::41::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::42::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::42::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::42::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::42::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::42::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::42::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::42::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::42::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::43::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::43::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::43::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::43::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::43::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::43::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::43::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::43::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::44::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::44::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::44::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::44::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::44::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::44::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::44::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::44::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::45::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::45::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::45::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::45::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::45::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::45::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::45::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::45::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::46::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::46::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::46::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::46::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::46::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::46::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::46::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::46::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::47::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::47::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::47::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::47::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::47::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::47::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::47::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::47::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::48::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::48::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::48::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::48::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::48::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::48::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::48::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::48::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::49::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::49::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::49::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::49::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::49::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::49::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::49::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::49::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::4::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::4::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::4::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::4::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::4::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::4::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::4::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::4::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::50::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::50::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::50::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::50::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::50::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::50::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::50::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::50::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::51::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::51::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::51::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::51::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::51::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::51::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::51::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::51::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::52::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::52::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::52::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::52::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::52::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::52::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::52::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::52::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::53::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::53::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::53::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::53::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::53::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::53::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::53::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::53::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::54::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::54::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::54::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::54::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::54::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::54::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::54::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::54::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::55::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::55::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::55::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::55::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::55::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::55::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::55::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::55::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::56::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::56::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::56::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::56::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::56::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::56::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::56::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::56::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::57::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::57::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::57::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::57::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::57::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::57::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::57::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::57::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::58::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::58::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::58::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::58::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::58::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::58::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::58::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::58::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::59::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::59::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::59::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::59::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::59::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::59::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::59::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::59::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::5::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::5::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::5::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::5::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::5::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::5::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::5::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::5::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::60::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::60::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::60::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::60::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::60::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::60::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::60::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::60::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::61::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::61::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::61::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::61::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::61::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::61::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::61::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::61::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::62::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::62::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::62::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::62::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::62::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::62::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::62::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::62::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::63::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::63::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::63::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::63::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::63::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::63::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::63::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::63::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::64::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::64::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::64::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::64::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::64::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::64::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::64::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::64::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::65::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::65::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::65::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::65::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::65::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::65::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::65::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::65::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::66::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::66::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::66::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::66::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::66::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::66::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::66::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::66::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::67::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::67::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::67::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::67::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::67::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::67::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::67::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::67::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::68::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::68::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::68::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::68::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::68::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::68::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::68::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::68::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::69::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::69::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::69::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::69::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::69::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::69::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::69::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::69::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::6::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::6::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::6::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::6::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::6::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::6::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::6::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::6::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::70::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::70::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::70::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::70::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::70::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::70::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::70::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::70::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::71::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::71::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::71::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::71::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::71::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::71::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::71::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::71::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::72::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::72::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::72::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::72::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::72::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::72::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::72::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::72::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::73::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::73::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::73::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::73::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::73::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::73::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::73::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::73::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::74::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::74::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::74::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::74::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::74::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::74::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::74::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::74::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::75::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::75::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::75::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::75::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::75::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::75::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::75::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::75::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::76::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::76::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::76::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::76::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::76::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::76::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::76::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::76::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::77::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::77::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::77::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::77::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::77::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::77::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::77::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::77::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::78::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::78::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::78::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::78::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::78::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::78::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::78::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::78::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::79::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::79::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::79::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::79::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::79::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::79::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::79::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::79::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::80::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::80::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::80::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::80::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::80::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::80::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::80::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::80::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::81::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::81::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::81::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::81::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::81::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::81::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::81::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::81::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::82::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::82::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::82::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::82::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::82::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::82::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::82::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::82::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::83::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::83::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::83::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::83::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::83::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::83::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::83::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::83::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::84::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::84::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::84::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::84::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::84::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::84::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::84::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::84::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::85::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::85::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::85::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::85::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::85::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::85::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::85::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::85::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::86::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::86::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::86::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::86::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::86::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::86::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::86::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::86::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::87::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::87::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::87::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::87::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::87::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::87::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::87::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::87::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::88::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::88::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::88::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::88::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::88::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::88::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::88::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::88::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::89::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::89::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::89::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::89::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::89::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::89::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::89::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::89::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::8::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::8::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::8::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::8::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::8::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::8::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::8::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::8::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::90::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::90::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::90::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::90::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::90::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::90::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::90::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::90::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::91::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::91::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::91::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::91::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::91::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::91::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::91::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::91::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::92::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::92::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::92::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::92::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::92::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::92::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::92::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::92::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::93::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::93::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::93::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::93::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::93::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::93::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::93::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::93::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::94::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::94::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::94::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::94::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::94::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::94::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::94::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::94::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::95::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::95::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::95::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::95::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::95::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::95::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::95::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::95::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::96::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::96::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::96::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::96::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::96::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::96::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::96::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::96::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::97::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::97::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::97::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::97::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::97::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::97::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::97::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::97::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::98::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::98::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::98::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::98::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::98::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::98::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::98::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::98::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::99::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::99::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::99::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::99::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::99::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::99::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::99::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::99::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::9::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::9::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::9::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::9::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::9::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::9::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::9::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/template.dat::9::lxml::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/tests11.dat::2::DOM::parser::namespaced': FAIL
u'html5lib/tests/testdata/tree-construction/tests11.dat::2::DOM::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/tests11.dat::2::ElementTree::parser::namespaced': FAIL
diff --git a/html5lib/tests/conftest.py b/html5lib/tests/conftest.py
index dceb94cc..3164c289 100644
--- a/html5lib/tests/conftest.py
+++ b/html5lib/tests/conftest.py
@@ -18,14 +18,17 @@ def pytest_collectstart():
def pytest_collect_file(path, parent):
dir = os.path.abspath(path.dirname)
- if dir == _tree_construction:
- if path.basename == "template.dat":
- return
+ dir_and_parents = set()
+ while dir not in dir_and_parents:
+ dir_and_parents.add(dir)
+ dir = os.path.dirname(dir)
+
+ if _tree_construction in dir_and_parents:
if path.ext == ".dat":
return TreeConstructionFile(path, parent)
- elif dir == _tokenizer:
+ elif _tokenizer in dir_and_parents:
if path.ext == ".test":
return TokenizerFile(path, parent)
- elif dir == _sanitizer_testdata:
+ elif _sanitizer_testdata in dir_and_parents:
if path.ext == ".dat":
return SanitizerFile(path, parent)
From 2b73979ca21b55461613a0f7b67c8518628e339b Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Tue, 7 Jun 2016 17:28:59 +0100
Subject: [PATCH 057/223] Fix #122: Check the testdata submodule is present
---
html5lib/tests/conftest.py | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/html5lib/tests/conftest.py b/html5lib/tests/conftest.py
index 3164c289..aa56dd17 100644
--- a/html5lib/tests/conftest.py
+++ b/html5lib/tests/conftest.py
@@ -1,5 +1,7 @@
import os.path
+import pytest
+
from .tree_construction import TreeConstructionFile
from .tokenizer import TokenizerFile
from .sanitizer import SanitizerFile
@@ -11,9 +13,19 @@
_sanitizer_testdata = os.path.join(_dir, "sanitizer-testdata")
-def pytest_collectstart():
- """check to see if the git submodule has been init'd"""
- pass
+def pytest_configure(config):
+ msgs = []
+ if not os.path.exists(_testdata):
+ msg = "testdata not available! "
+ if os.path.exists(os.path.join(_dir, "..", "..", ".git")):
+ msg += ("Please run git submodule update --init --recursive " +
+ "and then run tests again.")
+ else:
+ msg += ("The testdata doesn't appear to be included with this package, " +
+ "so finding the right version will be hard. :(")
+ msgs.append(msg)
+ if msgs:
+ pytest.exit("\n".join(msgs))
def pytest_collect_file(path, parent):
From a6550ac253169e62fa2cbdd9d6fe3553ce3848fd Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Wed, 8 Jun 2016 02:53:36 +0100
Subject: [PATCH 058/223] Fix #237: fail if --update-xfail is used in wrong
environment
---
html5lib/tests/conftest.py | 42 +++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/html5lib/tests/conftest.py b/html5lib/tests/conftest.py
index aa56dd17..ce93eff6 100644
--- a/html5lib/tests/conftest.py
+++ b/html5lib/tests/conftest.py
@@ -1,5 +1,6 @@
import os.path
+import pkg_resources
import pytest
from .tree_construction import TreeConstructionFile
@@ -7,6 +8,7 @@
from .sanitizer import SanitizerFile
_dir = os.path.abspath(os.path.dirname(__file__))
+_root = os.path.join(_dir, "..", "..")
_testdata = os.path.join(_dir, "testdata")
_tree_construction = os.path.join(_testdata, "tree-construction")
_tokenizer = os.path.join(_testdata, "tokenizer")
@@ -15,15 +17,53 @@
def pytest_configure(config):
msgs = []
+
if not os.path.exists(_testdata):
msg = "testdata not available! "
- if os.path.exists(os.path.join(_dir, "..", "..", ".git")):
+ if os.path.exists(os.path.join(_root, ".git")):
msg += ("Please run git submodule update --init --recursive " +
"and then run tests again.")
else:
msg += ("The testdata doesn't appear to be included with this package, " +
"so finding the right version will be hard. :(")
msgs.append(msg)
+
+ if config.option.update_xfail:
+ # Check for optional requirements
+ req_file = os.path.join(_root, "requirements-optional.txt")
+ if os.path.exists(req_file):
+ with open(req_file, "r") as fp:
+ for line in fp:
+ if (line.strip() and
+ not (line.startswith("-r") or
+ line.startswith("#"))):
+ if ";" in line:
+ spec, marker = line.strip().split(";", 1)
+ else:
+ spec, marker = line.strip(), None
+ req = pkg_resources.Requirement.parse(spec)
+ if marker and not pkg_resources.evaluate_marker(marker):
+ msgs.append("%s not available in this environment" % spec)
+ else:
+ try:
+ installed = pkg_resources.working_set.find(req)
+ except pkg_resources.VersionConflict:
+ msgs.append("Outdated version of %s installed, need %s" % (req.name, spec))
+ else:
+ if not installed:
+ msgs.append("Need %s" % spec)
+
+ # Check cElementTree
+ import xml.etree.ElementTree as ElementTree
+
+ try:
+ import xml.etree.cElementTree as cElementTree
+ except ImportError:
+ msgs.append("cElementTree unable to be imported")
+ else:
+ if cElementTree.Element is ElementTree.Element:
+ msgs.append("cElementTree is just an alias for ElementTree")
+
if msgs:
pytest.exit("\n".join(msgs))
From e45339a0b8a375423743edb050f36e9a7bbb7cc1 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Sun, 29 May 2016 04:58:47 +0100
Subject: [PATCH 059/223] Fix #258: annotation-xml branch didn't check tag type
---
html5lib/html5parser.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 3daf2995..224341b7 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -193,6 +193,7 @@ def mainLoop(self):
type in (CharactersToken, SpaceCharactersToken))) or
(currentNodeNamespace == namespaces["mathml"] and
currentNodeName == "annotation-xml" and
+ type == StartTagToken and
token["name"] == "svg") or
(self.isHTMLIntegrationPoint(currentNode) and
type in (StartTagToken, CharactersToken, SpaceCharactersToken))):
From f3f00e48c4baf859dfaf4bc90d3e90debf024194 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Wed, 6 Jul 2016 19:23:28 +0100
Subject: [PATCH 060/223] Update tests to tip of html5lib-tests
---
.pytest.expect | 40 ++++++++++++++++++++++++++++++++--------
html5lib/tests/testdata | 2 +-
2 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/.pytest.expect b/.pytest.expect
index 2effc347..0fa326f0 100644
--- a/.pytest.expect
+++ b/.pytest.expect
@@ -16,6 +16,14 @@ u'html5lib/tests/testdata/tokenizer/test3.test::244::dataState': FAIL
u'html5lib/tests/testdata/tokenizer/test3.test::246::dataState': FAIL
u'html5lib/tests/testdata/tokenizer/test3.test::258::dataState': FAIL
u'html5lib/tests/testdata/tokenizer/test3.test::656::dataState': FAIL
+u'html5lib/tests/testdata/tree-construction/adoption01.dat::17::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/adoption01.dat::17::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/adoption01.dat::17::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/adoption01.dat::17::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/adoption01.dat::17::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/adoption01.dat::17::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/adoption01.dat::17::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/adoption01.dat::17::lxml::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::0::DOM::parser::namespaced': FAIL
u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::0::DOM::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::0::ElementTree::parser::namespaced': FAIL
@@ -232,14 +240,6 @@ u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::5::cElementTre
u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::5::cElementTree::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::5::lxml::parser::namespaced': FAIL
u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::5::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::9::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::9::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::9::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::9::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::9::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::9::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::9::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::9::lxml::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/namespace-sensitivity.dat::0::DOM::parser::namespaced': FAIL
u'html5lib/tests/testdata/tree-construction/namespace-sensitivity.dat::0::DOM::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/namespace-sensitivity.dat::0::ElementTree::parser::namespaced': FAIL
@@ -1224,6 +1224,30 @@ u'html5lib/tests/testdata/tree-construction/tests11.dat::2::cElementTree::parser
u'html5lib/tests/testdata/tree-construction/tests11.dat::2::cElementTree::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/tests11.dat::2::lxml::parser::namespaced': FAIL
u'html5lib/tests/testdata/tree-construction/tests11.dat::2::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::4::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::4::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::4::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::4::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::4::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::4::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::4::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::4::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::5::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::5::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::5::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::5::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::5::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::5::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::5::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::5::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::6::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::6::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::6::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::6::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::6::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::6::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::6::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests11.dat::6::lxml::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/tests19.dat::14::DOM::parser::namespaced': FAIL
u'html5lib/tests/testdata/tree-construction/tests19.dat::14::DOM::parser::void-namespace': FAIL
u'html5lib/tests/testdata/tree-construction/tests19.dat::14::ElementTree::parser::namespaced': FAIL
diff --git a/html5lib/tests/testdata b/html5lib/tests/testdata
index 8db03d03..c305da74 160000
--- a/html5lib/tests/testdata
+++ b/html5lib/tests/testdata
@@ -1 +1 @@
-Subproject commit 8db03d031c90c8b68273a90aad5168f4161c3078
+Subproject commit c305da74fae50fb018870de7a042da36c1a93b65
From e65bee98caac6c8bd028661adb2b25e91abd0f77 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Sun, 22 May 2016 21:13:46 +0100
Subject: [PATCH 061/223] Remove parseMeta
---
html5lib/html5parser.py | 9 ++++-----
html5lib/tokenizer.py | 4 ++--
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 224341b7..aeaefa70 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -86,13 +86,12 @@ def __init__(self, tree=None, tokenizer=tokenizer.HTMLTokenizer,
getPhases(debug).items()])
def _parse(self, stream, innerHTML=False, container="div", encoding=None,
- parseMeta=True, useChardet=True, scripting=False, **kwargs):
+ useChardet=True, scripting=False, **kwargs):
self.innerHTMLMode = innerHTML
self.container = container
self.scripting = scripting
self.tokenizer = self.tokenizer_class(stream, encoding=encoding,
- parseMeta=parseMeta,
useChardet=useChardet,
parser=self, **kwargs)
self.reset()
@@ -232,7 +231,7 @@ def normalizedTokens(self):
for token in self.tokenizer:
yield self.normalizeToken(token)
- def parse(self, stream, encoding=None, parseMeta=True,
+ def parse(self, stream, encoding=None,
useChardet=True, scripting=False):
"""Parse a HTML document into a well-formed tree
@@ -246,11 +245,11 @@ def parse(self, stream, encoding=None, parseMeta=True,
scripting - treat noscript elements as if javascript was turned on
"""
self._parse(stream, innerHTML=False, encoding=encoding,
- parseMeta=parseMeta, useChardet=useChardet, scripting=scripting)
+ useChardet=useChardet, scripting=scripting)
return self.tree.getDocument()
def parseFragment(self, stream, container="div", encoding=None,
- parseMeta=False, useChardet=True, scripting=False):
+ useChardet=True, scripting=False):
# pylint:disable=unused-argument
"""Parse a HTML fragment into a well-formed tree fragment
diff --git a/html5lib/tokenizer.py b/html5lib/tokenizer.py
index dd6ea75f..38a57f7f 100644
--- a/html5lib/tokenizer.py
+++ b/html5lib/tokenizer.py
@@ -31,10 +31,10 @@ class HTMLTokenizer(object):
Points to HTMLInputStream object.
"""
- def __init__(self, stream, encoding=None, parseMeta=True, useChardet=True,
+ def __init__(self, stream, encoding=None, useChardet=True,
lowercaseElementName=True, lowercaseAttrName=True, parser=None):
- self.stream = HTMLInputStream(stream, encoding, parseMeta, useChardet)
+ self.stream = HTMLInputStream(stream, encoding, True, useChardet)
self.parser = parser
# Perform case conversions?
From d8d5bb65a85600a299407c888724dc7eeedefcfe Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Sun, 22 May 2016 22:28:26 +0100
Subject: [PATCH 062/223] Remove ability to use a custom tokenizer
This should be unneeded since the sanitizer changes (#110)
---
html5lib/html5parser.py | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index aeaefa70..86e387a4 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -59,18 +59,13 @@ class HTMLParser(object):
"""HTML parser. Generates a tree structure from a stream of (possibly
malformed) HTML"""
- def __init__(self, tree=None, tokenizer=tokenizer.HTMLTokenizer,
- strict=False, namespaceHTMLElements=True, debug=False):
+ def __init__(self, tree=None, strict=False, namespaceHTMLElements=True, debug=False):
"""
strict - raise an exception when a parse error is encountered
tree - a treebuilder class controlling the type of tree that will be
returned. Built in treebuilders can be accessed through
html5lib.treebuilders.getTreeBuilder(treeType)
-
- tokenizer - a class that provides a stream of tokens to the treebuilder.
- This may be replaced for e.g. a sanitizer which converts some tags to
- text
"""
# Raise an exception on the first error encountered
@@ -79,7 +74,6 @@ def __init__(self, tree=None, tokenizer=tokenizer.HTMLTokenizer,
if tree is None:
tree = treebuilders.getTreeBuilder("etree")
self.tree = tree(namespaceHTMLElements)
- self.tokenizer_class = tokenizer
self.errors = []
self.phases = dict([(name, cls(self, self.tree)) for name, cls in
@@ -91,9 +85,9 @@ def _parse(self, stream, innerHTML=False, container="div", encoding=None,
self.innerHTMLMode = innerHTML
self.container = container
self.scripting = scripting
- self.tokenizer = self.tokenizer_class(stream, encoding=encoding,
- useChardet=useChardet,
- parser=self, **kwargs)
+ self.tokenizer = tokenizer.HTMLTokenizer(stream, encoding=encoding,
+ useChardet=useChardet,
+ parser=self, **kwargs)
self.reset()
try:
From 6464fc460a525e4d5ad4ad6c079c4d8fc7577c63 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Sun, 22 May 2016 23:19:15 +0100
Subject: [PATCH 063/223] Remove the tokenizer's unused case-converting options
---
html5lib/tokenizer.py | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/html5lib/tokenizer.py b/html5lib/tokenizer.py
index 38a57f7f..dfc03bba 100644
--- a/html5lib/tokenizer.py
+++ b/html5lib/tokenizer.py
@@ -31,16 +31,11 @@ class HTMLTokenizer(object):
Points to HTMLInputStream object.
"""
- def __init__(self, stream, encoding=None, useChardet=True,
- lowercaseElementName=True, lowercaseAttrName=True, parser=None):
+ def __init__(self, stream, encoding=None, useChardet=True, parser=None):
self.stream = HTMLInputStream(stream, encoding, True, useChardet)
self.parser = parser
- # Perform case conversions?
- self.lowercaseElementName = lowercaseElementName
- self.lowercaseAttrName = lowercaseAttrName
-
# Setup the initial tokenizer state
self.escapeFlag = False
self.lastFourChars = []
@@ -232,8 +227,7 @@ def emitCurrentToken(self):
token = self.currentToken
# Add token to the queue to be yielded
if (token["type"] in tagTokenTypes):
- if self.lowercaseElementName:
- token["name"] = token["name"].translate(asciiUpper2Lower)
+ token["name"] = token["name"].translate(asciiUpper2Lower)
if token["type"] == tokenTypes["EndTag"]:
if token["data"]:
self.tokenQueue.append({"type": tokenTypes["ParseError"],
@@ -918,9 +912,8 @@ def attributeNameState(self):
# Attributes are not dropped at this stage. That happens when the
# start tag token is emitted so values can still be safely appended
# to attributes, but we do want to report the parse error in time.
- if self.lowercaseAttrName:
- self.currentToken["data"][-1][0] = (
- self.currentToken["data"][-1][0].translate(asciiUpper2Lower))
+ self.currentToken["data"][-1][0] = (
+ self.currentToken["data"][-1][0].translate(asciiUpper2Lower))
for name, _ in self.currentToken["data"][:-1]:
if self.currentToken["data"][-1][0] == name:
self.tokenQueue.append({"type": tokenTypes["ParseError"], "data":
From fc9f63be7cf2530f28b2e0bf8b5a767e2ac2c8be Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Sun, 22 May 2016 23:47:32 +0100
Subject: [PATCH 064/223] Fix #120: introduce keyword arguments for encodings
by source
---
CHANGES.rst | 4 ++
README.rst | 4 +-
html5lib/html5parser.py | 30 ++++------
html5lib/inputstream.py | 98 +++++++++++++++++++++------------
html5lib/tests/test_encoding.py | 54 +++++++++++++++++-
html5lib/tests/test_stream.py | 4 +-
html5lib/tokenizer.py | 4 +-
7 files changed, 133 insertions(+), 65 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index cdf21bc4..fe07f1ec 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -46,6 +46,10 @@ Released on XXX
* **Drop support of charade, now that chardet is supported once more.**
+* **Replace the charset keyword argument on parse and related methods
+ with a set of keyword arguments: override_encoding, transport_encoding,
+ same_origin_parent_encoding, likely_encoding, and default_encoding.**
+
0.9999999/1.0b8
~~~~~~~~~~~~~~~
diff --git a/README.rst b/README.rst
index 6859ed30..2ad46090 100644
--- a/README.rst
+++ b/README.rst
@@ -51,7 +51,7 @@ pass into html5lib as follows:
import html5lib
with closing(urlopen("http://example.com/")) as f:
- document = html5lib.parse(f, encoding=f.info().getparam("charset"))
+ document = html5lib.parse(f, transport_encoding=f.info().getparam("charset"))
When using with ``urllib.request`` (Python 3), the charset from HTTP
should be pass into html5lib as follows:
@@ -62,7 +62,7 @@ should be pass into html5lib as follows:
import html5lib
with urlopen("http://example.com/") as f:
- document = html5lib.parse(f, encoding=f.info().get_content_charset())
+ document = html5lib.parse(f, transport_encoding=f.info().get_content_charset())
To have more control over the parser, create a parser object explicitly.
For instance, to make the parser raise exceptions on parse errors, use:
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 86e387a4..6a5c8bcb 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -28,19 +28,17 @@
)
-def parse(doc, treebuilder="etree", encoding=None,
- namespaceHTMLElements=True, scripting=False):
+def parse(doc, treebuilder="etree", namespaceHTMLElements=True, **kwargs):
"""Parse a string or file-like object into a tree"""
tb = treebuilders.getTreeBuilder(treebuilder)
p = HTMLParser(tb, namespaceHTMLElements=namespaceHTMLElements)
- return p.parse(doc, encoding=encoding, scripting=scripting)
+ return p.parse(doc, **kwargs)
-def parseFragment(doc, container="div", treebuilder="etree", encoding=None,
- namespaceHTMLElements=True, scripting=False):
+def parseFragment(doc, container="div", treebuilder="etree", namespaceHTMLElements=True, **kwargs):
tb = treebuilders.getTreeBuilder(treebuilder)
p = HTMLParser(tb, namespaceHTMLElements=namespaceHTMLElements)
- return p.parseFragment(doc, container=container, encoding=encoding, scripting=scripting)
+ return p.parseFragment(doc, container=container, **kwargs)
def method_decorator_metaclass(function):
@@ -79,15 +77,12 @@ def __init__(self, tree=None, strict=False, namespaceHTMLElements=True, debug=Fa
self.phases = dict([(name, cls(self, self.tree)) for name, cls in
getPhases(debug).items()])
- def _parse(self, stream, innerHTML=False, container="div", encoding=None,
- useChardet=True, scripting=False, **kwargs):
+ def _parse(self, stream, innerHTML=False, container="div", scripting=False, **kwargs):
self.innerHTMLMode = innerHTML
self.container = container
self.scripting = scripting
- self.tokenizer = tokenizer.HTMLTokenizer(stream, encoding=encoding,
- useChardet=useChardet,
- parser=self, **kwargs)
+ self.tokenizer = tokenizer.HTMLTokenizer(stream, parser=self, **kwargs)
self.reset()
try:
@@ -225,8 +220,7 @@ def normalizedTokens(self):
for token in self.tokenizer:
yield self.normalizeToken(token)
- def parse(self, stream, encoding=None,
- useChardet=True, scripting=False):
+ def parse(self, stream, *args, **kwargs):
"""Parse a HTML document into a well-formed tree
stream - a filelike object or string containing the HTML to be parsed
@@ -238,13 +232,10 @@ def parse(self, stream, encoding=None,
scripting - treat noscript elements as if javascript was turned on
"""
- self._parse(stream, innerHTML=False, encoding=encoding,
- useChardet=useChardet, scripting=scripting)
+ self._parse(stream, False, None, *args, **kwargs)
return self.tree.getDocument()
- def parseFragment(self, stream, container="div", encoding=None,
- useChardet=True, scripting=False):
- # pylint:disable=unused-argument
+ def parseFragment(self, stream, *args, **kwargs):
"""Parse a HTML fragment into a well-formed tree fragment
container - name of the element we're setting the innerHTML property
@@ -259,8 +250,7 @@ def parseFragment(self, stream, container="div", encoding=None,
scripting - treat noscript elements as if javascript was turned on
"""
- self._parse(stream, True, container=container,
- encoding=encoding, scripting=scripting)
+ self._parse(stream, True, *args, **kwargs)
return self.tree.getFragment()
def parseError(self, errorcode="XXX-undefined-error", datavars=None):
diff --git a/html5lib/inputstream.py b/html5lib/inputstream.py
index cfabdd86..dafe33ca 100644
--- a/html5lib/inputstream.py
+++ b/html5lib/inputstream.py
@@ -128,7 +128,7 @@ def _readFromBuffer(self, bytes):
return b"".join(rv)
-def HTMLInputStream(source, encoding=None, parseMeta=True, chardet=True):
+def HTMLInputStream(source, **kwargs):
# Work around Python bug #20007: read(0) closes the connection.
# http://bugs.python.org/issue20007
if (isinstance(source, http_client.HTTPResponse) or
@@ -142,12 +142,13 @@ def HTMLInputStream(source, encoding=None, parseMeta=True, chardet=True):
isUnicode = isinstance(source, text_type)
if isUnicode:
- if encoding is not None:
- raise TypeError("Cannot explicitly set an encoding with a unicode string")
+ encodings = [x for x in kwargs if x.endswith("_encoding")]
+ if encodings:
+ raise TypeError("Cannot set an encoding with a unicode input, set %r" % encodings)
- return HTMLUnicodeInputStream(source)
+ return HTMLUnicodeInputStream(source, **kwargs)
else:
- return HTMLBinaryInputStream(source, encoding, parseMeta, chardet)
+ return HTMLBinaryInputStream(source, **kwargs)
class HTMLUnicodeInputStream(object):
@@ -173,8 +174,6 @@ def __init__(self, source):
regardless of any BOM or later declaration (such as in a meta
element)
- parseMeta - Look for a element containing encoding information
-
"""
if not utils.supports_lone_surrogates:
@@ -390,7 +389,9 @@ class HTMLBinaryInputStream(HTMLUnicodeInputStream):
"""
- def __init__(self, source, encoding=None, parseMeta=True, chardet=True):
+ def __init__(self, source, override_encoding=None, transport_encoding=None,
+ same_origin_parent_encoding=None, likely_encoding=None,
+ default_encoding="windows-1252", useChardet=True):
"""Initialises the HTMLInputStream.
HTMLInputStream(source, [encoding]) -> Normalized stream from source
@@ -403,8 +404,6 @@ def __init__(self, source, encoding=None, parseMeta=True, chardet=True):
regardless of any BOM or later declaration (such as in a meta
element)
- parseMeta - Look for a element containing encoding information
-
"""
# Raw Stream - for unicode objects this will encode to utf-8 and set
# self.charEncoding as appropriate
@@ -412,21 +411,22 @@ def __init__(self, source, encoding=None, parseMeta=True, chardet=True):
HTMLUnicodeInputStream.__init__(self, self.rawStream)
- self.charEncoding = (lookupEncoding(encoding), "certain")
-
# Encoding Information
# Number of bytes to use when looking for a meta element with
# encoding information
self.numBytesMeta = 1024
# Number of bytes to use when using detecting encoding using chardet
self.numBytesChardet = 100
- # Encoding to use if no other information can be found
- self.defaultEncoding = "windows-1252"
+ # Things from args
+ self.override_encoding = override_encoding
+ self.transport_encoding = transport_encoding
+ self.same_origin_parent_encoding = same_origin_parent_encoding
+ self.likely_encoding = likely_encoding
+ self.default_encoding = default_encoding
- # Detect encoding iff no explicit "transport level" encoding is supplied
- if (self.charEncoding[0] is None):
- self.charEncoding = self.detectEncoding(parseMeta, chardet)
- assert self.charEncoding[0] is not None
+ # Determine encoding
+ self.charEncoding = self.determineEncoding(useChardet)
+ assert self.charEncoding[0] is not None
# Call superclass
self.reset()
@@ -454,21 +454,45 @@ def openStream(self, source):
return stream
- def detectEncoding(self, parseMeta=True, chardet=True):
- # First look for a BOM
+ def determineEncoding(self, chardet=True):
+ # BOMs take precedence over everything
# This will also read past the BOM if present
- encoding = self.detectBOM()
- confidence = "certain"
- # If there is no BOM need to look for meta elements with encoding
- # information
- if encoding is None and parseMeta:
- encoding = self.detectEncodingMeta()
- confidence = "tentative"
+ charEncoding = self.detectBOM(), "certain"
+ if charEncoding[0] is not None:
+ return charEncoding
+
+ # If we've been overriden, we've been overriden
+ charEncoding = lookupEncoding(self.override_encoding), "certain"
+ if charEncoding[0] is not None:
+ return charEncoding
+
+ # Now check the transport layer
+ charEncoding = lookupEncoding(self.transport_encoding), "certain"
+ if charEncoding[0] is not None:
+ return charEncoding
+
+ # Look for meta elements with encoding information
+ charEncoding = self.detectEncodingMeta(), "tentative"
+ if charEncoding[0] is not None:
+ return charEncoding
+
+ # Parent document encoding
+ charEncoding = lookupEncoding(self.same_origin_parent_encoding), "tentative"
+ if charEncoding[0] is not None and not charEncoding[0].name.startswith("utf-16"):
+ return charEncoding
+
+ # "likely" encoding
+ charEncoding = lookupEncoding(self.likely_encoding), "tentative"
+ if charEncoding[0] is not None:
+ return charEncoding
+
# Guess with chardet, if available
- if encoding is None and chardet:
- confidence = "tentative"
+ if chardet:
try:
from chardet.universaldetector import UniversalDetector
+ except ImportError:
+ pass
+ else:
buffers = []
detector = UniversalDetector()
while not detector.done:
@@ -481,14 +505,16 @@ def detectEncoding(self, parseMeta=True, chardet=True):
detector.close()
encoding = lookupEncoding(detector.result['encoding'])
self.rawStream.seek(0)
- except ImportError:
- pass
- # If all else fails use the default encoding
- if encoding is None:
- confidence = "tentative"
- encoding = lookupEncoding(self.defaultEncoding)
+ if encoding is not None:
+ return encoding, "tentative"
+
+ # Try the default encoding
+ charEncoding = lookupEncoding(self.default_encoding), "tentative"
+ if charEncoding[0] is not None:
+ return charEncoding
- return encoding, confidence
+ # Fallback to html5lib's default if even that hasn't worked
+ return lookupEncoding("windows-1252"), "tentative"
def changeEncoding(self, newEncoding):
assert self.charEncoding[1] != "certain"
diff --git a/html5lib/tests/test_encoding.py b/html5lib/tests/test_encoding.py
index a66a2178..b6d20f24 100644
--- a/html5lib/tests/test_encoding.py
+++ b/html5lib/tests/test_encoding.py
@@ -2,6 +2,8 @@
import os
+import pytest
+
from .support import get_data_files, test_dir, errorMessage, TestData as _TestData
from html5lib import HTMLParser, inputstream
@@ -11,7 +13,7 @@ def test_basic_prescan_length():
pad = 1024 - len(data) + 1
data = data.replace(b"-a-", b"-" + (b"a" * pad) + b"-")
assert len(data) == 1024 # Sanity
- stream = inputstream.HTMLBinaryInputStream(data, chardet=False)
+ stream = inputstream.HTMLBinaryInputStream(data, useChardet=False)
assert 'utf-8' == stream.charEncoding[0].name
@@ -20,7 +22,7 @@ def test_parser_reparse():
pad = 10240 - len(data) + 1
data = data.replace(b"-a-", b"-" + (b"a" * pad) + b"-")
assert len(data) == 10240 # Sanity
- stream = inputstream.HTMLBinaryInputStream(data, chardet=False)
+ stream = inputstream.HTMLBinaryInputStream(data, useChardet=False)
assert 'windows-1252' == stream.charEncoding[0].name
p = HTMLParser(namespaceHTMLElements=False)
doc = p.parse(data, useChardet=False)
@@ -28,6 +30,51 @@ def test_parser_reparse():
assert doc.find(".//title").text == "Caf\u00E9"
+@pytest.mark.parametrize("expected,data,kwargs", [
+ ("utf-16le", b"\xFF\xFE", {"override_encoding": "iso-8859-2"}),
+ ("utf-16be", b"\xFE\xFF", {"override_encoding": "iso-8859-2"}),
+ ("utf-8", b"\xEF\xBB\xBF", {"override_encoding": "iso-8859-2"}),
+ ("iso-8859-2", b"", {"override_encoding": "iso-8859-2", "transport_encoding": "iso-8859-3"}),
+ ("iso-8859-2", b"", {"transport_encoding": "iso-8859-2"}),
+ ("iso-8859-2", b"", {"same_origin_parent_encoding": "iso-8859-3"}),
+ ("iso-8859-2", b"", {"same_origin_parent_encoding": "iso-8859-2", "likely_encoding": "iso-8859-3"}),
+ ("iso-8859-2", b"", {"same_origin_parent_encoding": "utf-16", "likely_encoding": "iso-8859-2"}),
+ ("iso-8859-2", b"", {"same_origin_parent_encoding": "utf-16be", "likely_encoding": "iso-8859-2"}),
+ ("iso-8859-2", b"", {"same_origin_parent_encoding": "utf-16le", "likely_encoding": "iso-8859-2"}),
+ ("iso-8859-2", b"", {"likely_encoding": "iso-8859-2", "default_encoding": "iso-8859-3"}),
+ ("iso-8859-2", b"", {"default_encoding": "iso-8859-2"}),
+ ("windows-1252", b"", {"default_encoding": "totally-bogus-string"}),
+ ("windows-1252", b"", {}),
+])
+def test_parser_args(expected, data, kwargs):
+ stream = inputstream.HTMLBinaryInputStream(data, useChardet=False, **kwargs)
+ assert expected == stream.charEncoding[0].name
+ p = HTMLParser()
+ p.parse(data, useChardet=False, **kwargs)
+ assert expected == p.documentEncoding
+
+
+@pytest.mark.parametrize("kwargs", [
+ {"override_encoding": "iso-8859-2"},
+ {"override_encoding": None},
+ {"transport_encoding": "iso-8859-2"},
+ {"transport_encoding": None},
+ {"same_origin_parent_encoding": "iso-8859-2"},
+ {"same_origin_parent_encoding": None},
+ {"likely_encoding": "iso-8859-2"},
+ {"likely_encoding": None},
+ {"default_encoding": "iso-8859-2"},
+ {"default_encoding": None},
+ {"foo_encoding": "iso-8859-2"},
+ {"foo_encoding": None},
+])
+def test_parser_args_raises(kwargs):
+ with pytest.raises(TypeError) as exc_info:
+ p = HTMLParser()
+ p.parse("", useChardet=False, **kwargs)
+ assert exc_info.value.args[0].startswith("Cannot set an encoding with a unicode input")
+
+
def runParserEncodingTest(data, encoding):
p = HTMLParser()
assert p.documentEncoding is None
@@ -38,7 +85,7 @@ def runParserEncodingTest(data, encoding):
def runPreScanEncodingTest(data, encoding):
- stream = inputstream.HTMLBinaryInputStream(data, chardet=False)
+ stream = inputstream.HTMLBinaryInputStream(data, useChardet=False)
encoding = encoding.lower().decode("ascii")
# Very crude way to ignore irrelevant tests
@@ -55,6 +102,7 @@ def test_encoding():
yield (runParserEncodingTest, test[b'data'], test[b'encoding'])
yield (runPreScanEncodingTest, test[b'data'], test[b'encoding'])
+
# pylint:disable=wrong-import-position
try:
import chardet # noqa
diff --git a/html5lib/tests/test_stream.py b/html5lib/tests/test_stream.py
index 77e411d5..e8d9fd86 100644
--- a/html5lib/tests/test_stream.py
+++ b/html5lib/tests/test_stream.py
@@ -99,13 +99,13 @@ class HTMLBinaryInputStreamShortChunk(HTMLBinaryInputStream):
def test_char_ascii():
- stream = HTMLInputStream(b"'", encoding='ascii')
+ stream = HTMLInputStream(b"'", override_encoding='ascii')
assert stream.charEncoding[0].name == 'windows-1252'
assert stream.char() == "'"
def test_char_utf8():
- stream = HTMLInputStream('\u2018'.encode('utf-8'), encoding='utf-8')
+ stream = HTMLInputStream('\u2018'.encode('utf-8'), override_encoding='utf-8')
assert stream.charEncoding[0].name == 'utf-8'
assert stream.char() == '\u2018'
diff --git a/html5lib/tokenizer.py b/html5lib/tokenizer.py
index dfc03bba..3f10c01f 100644
--- a/html5lib/tokenizer.py
+++ b/html5lib/tokenizer.py
@@ -31,9 +31,9 @@ class HTMLTokenizer(object):
Points to HTMLInputStream object.
"""
- def __init__(self, stream, encoding=None, useChardet=True, parser=None):
+ def __init__(self, stream, parser=None, **kwargs):
- self.stream = HTMLInputStream(stream, encoding, True, useChardet)
+ self.stream = HTMLInputStream(stream, **kwargs)
self.parser = parser
# Setup the initial tokenizer state
From 945911bbb8d8cf01a6d8a0ea62b16a7fda658dfc Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Wed, 13 Jul 2016 23:27:55 +0100
Subject: [PATCH 065/223] Fix parse.py after #257 (#271)
---
parse.py | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/parse.py b/parse.py
index 2ed8f1c2..d5087fb8 100755
--- a/parse.py
+++ b/parse.py
@@ -9,7 +9,6 @@
from optparse import OptionParser
from html5lib import html5parser
-from html5lib.tokenizer import HTMLTokenizer
from html5lib import treebuilders, serializer, treewalkers
from html5lib import constants
from html5lib import utils
@@ -53,9 +52,7 @@ def parse():
treebuilder = treebuilders.getTreeBuilder(opts.treebuilder)
- tokenizer = HTMLTokenizer
-
- p = html5parser.HTMLParser(tree=treebuilder, tokenizer=tokenizer, debug=opts.log)
+ p = html5parser.HTMLParser(tree=treebuilder, debug=opts.log)
if opts.fragment:
parseMethod = p.parseFragment
@@ -96,7 +93,7 @@ def parse():
def run(parseMethod, f, encoding, scripting):
try:
- document = parseMethod(f, encoding=encoding, scripting=scripting)
+ document = parseMethod(f, override_encoding=encoding, scripting=scripting)
except:
document = None
traceback.print_exc()
@@ -117,16 +114,14 @@ def printOutput(parser, document, opts):
document.writexml(sys.stdout, encoding="utf-8")
elif tb == "lxml":
import lxml.etree
- sys.stdout.write(lxml.etree.tostring(document))
+ sys.stdout.write(lxml.etree.tostring(document, encoding="unicode"))
elif tb == "etree":
- sys.stdout.write(utils.default_etree.tostring(document))
+ sys.stdout.write(utils.default_etree.tostring(document, encoding="unicode"))
elif opts.tree:
if not hasattr(document, '__getitem__'):
document = [document]
for fragment in document:
print(parser.tree.testSerializer(fragment))
- elif opts.hilite:
- sys.stdout.write(document.hilite("utf-8"))
elif opts.html:
kwargs = {}
for opt in serializer.HTMLSerializer.options:
@@ -188,9 +183,6 @@ def getOptParser():
parser.add_option("", "--no-html", action="store_false", default=True,
dest="html", help="Don't output html")
- parser.add_option("", "--hilite", action="store_true", default=False,
- dest="hilite", help="Output as formatted highlighted code.")
-
parser.add_option("-c", "--encoding", action="store_true", default=False,
dest="encoding", help="Print character encoding used")
From 7bb34c7bb6e1ebddcfe70592ee072535b30cea56 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Tue, 12 Jul 2016 01:32:20 +0100
Subject: [PATCH 066/223] Rename treebuilders._base to .base to reflect public
status
---
html5lib/html5parser.py | 2 +-
html5lib/treebuilders/{_base.py => base.py} | 0
html5lib/treebuilders/dom.py | 12 ++++++------
html5lib/treebuilders/etree.py | 10 +++++-----
html5lib/treebuilders/etree_lxml.py | 8 ++++----
5 files changed, 16 insertions(+), 16 deletions(-)
rename html5lib/treebuilders/{_base.py => base.py} (100%)
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 6a5c8bcb..c51f73b1 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -12,7 +12,7 @@
from . import tokenizer
from . import treebuilders
-from .treebuilders._base import Marker
+from .treebuilders.base import Marker
from . import utils
from .constants import (
diff --git a/html5lib/treebuilders/_base.py b/html5lib/treebuilders/base.py
similarity index 100%
rename from html5lib/treebuilders/_base.py
rename to html5lib/treebuilders/base.py
diff --git a/html5lib/treebuilders/dom.py b/html5lib/treebuilders/dom.py
index 9d7f4824..461dc04f 100644
--- a/html5lib/treebuilders/dom.py
+++ b/html5lib/treebuilders/dom.py
@@ -5,7 +5,7 @@
from xml.dom import minidom, Node
import weakref
-from . import _base
+from . import base
from .. import constants
from ..constants import namespaces
from ..utils import moduleFactoryFactory
@@ -50,9 +50,9 @@ def __delitem__(self, name):
else:
del self.element.attributes[name]
- class NodeBuilder(_base.Node):
+ class NodeBuilder(base.Node):
def __init__(self, element):
- _base.Node.__init__(self, element.nodeName)
+ base.Node.__init__(self, element.nodeName)
self.element = element
namespace = property(lambda self: hasattr(self.element, "namespaceURI") and
@@ -117,7 +117,7 @@ def getNameTuple(self):
nameTuple = property(getNameTuple)
- class TreeBuilder(_base.TreeBuilder): # pylint:disable=unused-variable
+ class TreeBuilder(base.TreeBuilder): # pylint:disable=unused-variable
def documentClass(self):
self.dom = Dom.getDOMImplementation().createDocument(None, None, None)
return weakref.proxy(self)
@@ -157,12 +157,12 @@ def getDocument(self):
return self.dom
def getFragment(self):
- return _base.TreeBuilder.getFragment(self).element
+ return base.TreeBuilder.getFragment(self).element
def insertText(self, data, parent=None):
data = data
if parent != self:
- _base.TreeBuilder.insertText(self, data, parent)
+ base.TreeBuilder.insertText(self, data, parent)
else:
# HACK: allow text nodes as children of the document node
if hasattr(self.dom, '_child_node_types'):
diff --git a/html5lib/treebuilders/etree.py b/html5lib/treebuilders/etree.py
index 4d12bd45..956a717b 100644
--- a/html5lib/treebuilders/etree.py
+++ b/html5lib/treebuilders/etree.py
@@ -5,7 +5,7 @@
import re
-from . import _base
+from . import base
from .. import ihatexml
from .. import constants
from ..constants import namespaces
@@ -18,7 +18,7 @@ def getETreeBuilder(ElementTreeImplementation, fullTree=False):
ElementTree = ElementTreeImplementation
ElementTreeCommentType = ElementTree.Comment("asd").tag
- class Element(_base.Node):
+ class Element(base.Node):
def __init__(self, name, namespace=None):
self._name = name
self._namespace = namespace
@@ -142,7 +142,7 @@ def reparentChildren(self, newParent):
if self._element.text is not None:
newParent._element.text += self._element.text
self._element.text = ""
- _base.Node.reparentChildren(self, newParent)
+ base.Node.reparentChildren(self, newParent)
class Comment(Element):
def __init__(self, data):
@@ -310,7 +310,7 @@ def serializeElement(element):
return "".join(rv)
- class TreeBuilder(_base.TreeBuilder): # pylint:disable=unused-variable
+ class TreeBuilder(base.TreeBuilder): # pylint:disable=unused-variable
documentClass = Document
doctypeClass = DocumentType
elementClass = Element
@@ -332,7 +332,7 @@ def getDocument(self):
return self.document._element.find("html")
def getFragment(self):
- return _base.TreeBuilder.getFragment(self)._element
+ return base.TreeBuilder.getFragment(self)._element
return locals()
diff --git a/html5lib/treebuilders/etree_lxml.py b/html5lib/treebuilders/etree_lxml.py
index 2a69769b..15e22a57 100644
--- a/html5lib/treebuilders/etree_lxml.py
+++ b/html5lib/treebuilders/etree_lxml.py
@@ -16,7 +16,7 @@
import re
import sys
-from . import _base
+from . import base
from ..constants import DataLossWarning
from .. import constants
from . import etree as etree_builders
@@ -172,7 +172,7 @@ def serializeElement(element):
return "".join(rv)
-class TreeBuilder(_base.TreeBuilder):
+class TreeBuilder(base.TreeBuilder):
documentClass = Document
doctypeClass = DocumentType
elementClass = None
@@ -254,10 +254,10 @@ def _getData(self):
self.elementClass = Element
self.commentClass = Comment
# self.fragmentClass = builder.DocumentFragment
- _base.TreeBuilder.__init__(self, namespaceHTMLElements)
+ base.TreeBuilder.__init__(self, namespaceHTMLElements)
def reset(self):
- _base.TreeBuilder.reset(self)
+ base.TreeBuilder.reset(self)
self.insertComment = self.insertCommentInitial
self.initial_comments = []
self.doctype = None
From 19891c55261fef1ee24c1b591502f120e93a6b22 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Tue, 12 Jul 2016 01:34:35 +0100
Subject: [PATCH 067/223] Rename treewalkers._base to .base to reflect public
status
---
html5lib/tests/test_serializer.py | 2 +-
html5lib/treewalkers/{_base.py => base.py} | 0
html5lib/treewalkers/dom.py | 16 ++++++++--------
html5lib/treewalkers/etree.py | 14 +++++++-------
html5lib/treewalkers/genshistream.py | 4 ++--
html5lib/treewalkers/lxmletree.py | 20 ++++++++++----------
6 files changed, 28 insertions(+), 28 deletions(-)
rename html5lib/treewalkers/{_base.py => base.py} (100%)
diff --git a/html5lib/tests/test_serializer.py b/html5lib/tests/test_serializer.py
index b3cda7d7..9333286e 100644
--- a/html5lib/tests/test_serializer.py
+++ b/html5lib/tests/test_serializer.py
@@ -10,7 +10,7 @@
from html5lib import constants
from html5lib.filters.lint import Filter as Lint
from html5lib.serializer import HTMLSerializer, serialize
-from html5lib.treewalkers._base import TreeWalker
+from html5lib.treewalkers.base import TreeWalker
# pylint:disable=wrong-import-position
optionals_loaded = []
diff --git a/html5lib/treewalkers/_base.py b/html5lib/treewalkers/base.py
similarity index 100%
rename from html5lib/treewalkers/_base.py
rename to html5lib/treewalkers/base.py
diff --git a/html5lib/treewalkers/dom.py b/html5lib/treewalkers/dom.py
index ac4dcf31..b0c89b00 100644
--- a/html5lib/treewalkers/dom.py
+++ b/html5lib/treewalkers/dom.py
@@ -2,16 +2,16 @@
from xml.dom import Node
-from . import _base
+from . import base
-class TreeWalker(_base.NonRecursiveTreeWalker):
+class TreeWalker(base.NonRecursiveTreeWalker):
def getNodeDetails(self, node):
if node.nodeType == Node.DOCUMENT_TYPE_NODE:
- return _base.DOCTYPE, node.name, node.publicId, node.systemId
+ return base.DOCTYPE, node.name, node.publicId, node.systemId
elif node.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE):
- return _base.TEXT, node.nodeValue
+ return base.TEXT, node.nodeValue
elif node.nodeType == Node.ELEMENT_NODE:
attrs = {}
@@ -21,17 +21,17 @@ def getNodeDetails(self, node):
attrs[(attr.namespaceURI, attr.localName)] = attr.value
else:
attrs[(None, attr.name)] = attr.value
- return (_base.ELEMENT, node.namespaceURI, node.nodeName,
+ return (base.ELEMENT, node.namespaceURI, node.nodeName,
attrs, node.hasChildNodes())
elif node.nodeType == Node.COMMENT_NODE:
- return _base.COMMENT, node.nodeValue
+ return base.COMMENT, node.nodeValue
elif node.nodeType in (Node.DOCUMENT_NODE, Node.DOCUMENT_FRAGMENT_NODE):
- return (_base.DOCUMENT,)
+ return (base.DOCUMENT,)
else:
- return _base.UNKNOWN, node.nodeType
+ return base.UNKNOWN, node.nodeType
def getFirstChild(self, node):
return node.firstChild
diff --git a/html5lib/treewalkers/etree.py b/html5lib/treewalkers/etree.py
index d3b0c50e..41c652a9 100644
--- a/html5lib/treewalkers/etree.py
+++ b/html5lib/treewalkers/etree.py
@@ -12,7 +12,7 @@
from six import string_types
-from . import _base
+from . import base
from ..utils import moduleFactoryFactory
tag_regexp = re.compile("{([^}]*)}(.*)")
@@ -22,7 +22,7 @@ def getETreeBuilder(ElementTreeImplementation):
ElementTree = ElementTreeImplementation
ElementTreeCommentType = ElementTree.Comment("asd").tag
- class TreeWalker(_base.NonRecursiveTreeWalker): # pylint:disable=unused-variable
+ class TreeWalker(base.NonRecursiveTreeWalker): # pylint:disable=unused-variable
"""Given the particular ElementTree representation, this implementation,
to avoid using recursion, returns "nodes" as tuples with the following
content:
@@ -40,7 +40,7 @@ def getNodeDetails(self, node):
if isinstance(node, tuple): # It might be the root Element
elt, _, _, flag = node
if flag in ("text", "tail"):
- return _base.TEXT, getattr(elt, flag)
+ return base.TEXT, getattr(elt, flag)
else:
node = elt
@@ -48,14 +48,14 @@ def getNodeDetails(self, node):
node = node.getroot()
if node.tag in ("DOCUMENT_ROOT", "DOCUMENT_FRAGMENT"):
- return (_base.DOCUMENT,)
+ return (base.DOCUMENT,)
elif node.tag == "":
- return (_base.DOCTYPE, node.text,
+ return (base.DOCTYPE, node.text,
node.get("publicId"), node.get("systemId"))
elif node.tag == ElementTreeCommentType:
- return _base.COMMENT, node.text
+ return base.COMMENT, node.text
else:
assert isinstance(node.tag, string_types), type(node.tag)
@@ -73,7 +73,7 @@ def getNodeDetails(self, node):
attrs[(match.group(1), match.group(2))] = value
else:
attrs[(None, name)] = value
- return (_base.ELEMENT, namespace, tag,
+ return (base.ELEMENT, namespace, tag,
attrs, len(node) or node.text)
def getFirstChild(self, node):
diff --git a/html5lib/treewalkers/genshistream.py b/html5lib/treewalkers/genshistream.py
index 61cbfede..7483be27 100644
--- a/html5lib/treewalkers/genshistream.py
+++ b/html5lib/treewalkers/genshistream.py
@@ -4,12 +4,12 @@
from genshi.core import START, END, XML_NAMESPACE, DOCTYPE, TEXT
from genshi.core import START_NS, END_NS, START_CDATA, END_CDATA, PI, COMMENT
-from . import _base
+from . import base
from ..constants import voidElements, namespaces
-class TreeWalker(_base.TreeWalker):
+class TreeWalker(base.TreeWalker):
def __iter__(self):
# Buffer the events so we can pass in the following one
previous = None
diff --git a/html5lib/treewalkers/lxmletree.py b/html5lib/treewalkers/lxmletree.py
index ff31a44e..d456e3b9 100644
--- a/html5lib/treewalkers/lxmletree.py
+++ b/html5lib/treewalkers/lxmletree.py
@@ -4,7 +4,7 @@
from lxml import etree
from ..treebuilders.etree import tag_regexp
-from . import _base
+from . import base
from .. import ihatexml
@@ -122,7 +122,7 @@ def __len__(self):
return len(self.obj)
-class TreeWalker(_base.NonRecursiveTreeWalker):
+class TreeWalker(base.NonRecursiveTreeWalker):
def __init__(self, tree):
# pylint:disable=redefined-variable-type
if isinstance(tree, list):
@@ -131,29 +131,29 @@ def __init__(self, tree):
else:
self.fragmentChildren = set()
tree = Root(tree)
- _base.NonRecursiveTreeWalker.__init__(self, tree)
+ base.NonRecursiveTreeWalker.__init__(self, tree)
self.filter = ihatexml.InfosetFilter()
def getNodeDetails(self, node):
if isinstance(node, tuple): # Text node
node, key = node
assert key in ("text", "tail"), "Text nodes are text or tail, found %s" % key
- return _base.TEXT, ensure_str(getattr(node, key))
+ return base.TEXT, ensure_str(getattr(node, key))
elif isinstance(node, Root):
- return (_base.DOCUMENT,)
+ return (base.DOCUMENT,)
elif isinstance(node, Doctype):
- return _base.DOCTYPE, node.name, node.public_id, node.system_id
+ return base.DOCTYPE, node.name, node.public_id, node.system_id
elif isinstance(node, FragmentWrapper) and not hasattr(node, "tag"):
- return _base.TEXT, ensure_str(node.obj)
+ return base.TEXT, ensure_str(node.obj)
elif node.tag == etree.Comment:
- return _base.COMMENT, ensure_str(node.text)
+ return base.COMMENT, ensure_str(node.text)
elif node.tag == etree.Entity:
- return _base.ENTITY, ensure_str(node.text)[1:-1] # strip &;
+ return base.ENTITY, ensure_str(node.text)[1:-1] # strip &;
else:
# This is assumed to be an ordinary element
@@ -172,7 +172,7 @@ def getNodeDetails(self, node):
attrs[(match.group(1), match.group(2))] = value
else:
attrs[(None, name)] = value
- return (_base.ELEMENT, namespace, self.filter.fromXmlName(tag),
+ return (base.ELEMENT, namespace, self.filter.fromXmlName(tag),
attrs, len(node) > 0 or node.text)
def getFirstChild(self, node):
From 7bbde541e08ca82c07af5ac7e5f64525f1793814 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Tue, 12 Jul 2016 01:35:56 +0100
Subject: [PATCH 068/223] Rename filters._base to .base to reflect public
status
---
html5lib/filters/alphabeticalattributes.py | 6 +++---
html5lib/filters/{_base.py => base.py} | 0
html5lib/filters/inject_meta_charset.py | 8 ++++----
html5lib/filters/lint.py | 6 +++---
html5lib/filters/optionaltags.py | 4 ++--
html5lib/filters/sanitizer.py | 6 +++---
html5lib/filters/whitespace.py | 6 +++---
7 files changed, 18 insertions(+), 18 deletions(-)
rename html5lib/filters/{_base.py => base.py} (100%)
diff --git a/html5lib/filters/alphabeticalattributes.py b/html5lib/filters/alphabeticalattributes.py
index fed6996c..4795baec 100644
--- a/html5lib/filters/alphabeticalattributes.py
+++ b/html5lib/filters/alphabeticalattributes.py
@@ -1,6 +1,6 @@
from __future__ import absolute_import, division, unicode_literals
-from . import _base
+from . import base
try:
from collections import OrderedDict
@@ -8,9 +8,9 @@
from ordereddict import OrderedDict
-class Filter(_base.Filter):
+class Filter(base.Filter):
def __iter__(self):
- for token in _base.Filter.__iter__(self):
+ for token in base.Filter.__iter__(self):
if token["type"] in ("StartTag", "EmptyTag"):
attrs = OrderedDict()
for name, value in sorted(token["data"].items(),
diff --git a/html5lib/filters/_base.py b/html5lib/filters/base.py
similarity index 100%
rename from html5lib/filters/_base.py
rename to html5lib/filters/base.py
diff --git a/html5lib/filters/inject_meta_charset.py b/html5lib/filters/inject_meta_charset.py
index ca33b70b..2059ec86 100644
--- a/html5lib/filters/inject_meta_charset.py
+++ b/html5lib/filters/inject_meta_charset.py
@@ -1,11 +1,11 @@
from __future__ import absolute_import, division, unicode_literals
-from . import _base
+from . import base
-class Filter(_base.Filter):
+class Filter(base.Filter):
def __init__(self, source, encoding):
- _base.Filter.__init__(self, source)
+ base.Filter.__init__(self, source)
self.encoding = encoding
def __iter__(self):
@@ -13,7 +13,7 @@ def __iter__(self):
meta_found = (self.encoding is None)
pending = []
- for token in _base.Filter.__iter__(self):
+ for token in base.Filter.__iter__(self):
type = token["type"]
if type == "StartTag":
if token["name"].lower() == "head":
diff --git a/html5lib/filters/lint.py b/html5lib/filters/lint.py
index af231d8e..a9c0831a 100644
--- a/html5lib/filters/lint.py
+++ b/html5lib/filters/lint.py
@@ -2,21 +2,21 @@
from six import text_type
-from . import _base
+from . import base
from ..constants import namespaces, voidElements
from ..constants import spaceCharacters
spaceCharacters = "".join(spaceCharacters)
-class Filter(_base.Filter):
+class Filter(base.Filter):
def __init__(self, source, require_matching_tags=True):
super(Filter, self).__init__(source)
self.require_matching_tags = require_matching_tags
def __iter__(self):
open_elements = []
- for token in _base.Filter.__iter__(self):
+ for token in base.Filter.__iter__(self):
type = token["type"]
if type in ("StartTag", "EmptyTag"):
namespace = token["namespace"]
diff --git a/html5lib/filters/optionaltags.py b/html5lib/filters/optionaltags.py
index 8f11fff4..f6edb734 100644
--- a/html5lib/filters/optionaltags.py
+++ b/html5lib/filters/optionaltags.py
@@ -1,9 +1,9 @@
from __future__ import absolute_import, division, unicode_literals
-from . import _base
+from . import base
-class Filter(_base.Filter):
+class Filter(base.Filter):
def slider(self):
previous1 = previous2 = None
for token in self.source:
diff --git a/html5lib/filters/sanitizer.py b/html5lib/filters/sanitizer.py
index 7f81c0d1..47da50fe 100644
--- a/html5lib/filters/sanitizer.py
+++ b/html5lib/filters/sanitizer.py
@@ -5,7 +5,7 @@
from six.moves import urllib_parse as urlparse
-from . import _base
+from . import base
from ..constants import namespaces, prefixes
__all__ = ["Filter"]
@@ -712,7 +712,7 @@
re.VERBOSE)
-class Filter(_base.Filter):
+class Filter(base.Filter):
""" sanitization of XHTML+MathML+SVG and of inline style attributes."""
def __init__(self,
source,
@@ -739,7 +739,7 @@ def __init__(self,
self.svg_allow_local_href = svg_allow_local_href
def __iter__(self):
- for token in _base.Filter.__iter__(self):
+ for token in base.Filter.__iter__(self):
token = self.sanitize_token(token)
if token:
yield token
diff --git a/html5lib/filters/whitespace.py b/html5lib/filters/whitespace.py
index dfc60eeb..89210528 100644
--- a/html5lib/filters/whitespace.py
+++ b/html5lib/filters/whitespace.py
@@ -2,20 +2,20 @@
import re
-from . import _base
+from . import base
from ..constants import rcdataElements, spaceCharacters
spaceCharacters = "".join(spaceCharacters)
SPACES_REGEX = re.compile("[%s]+" % spaceCharacters)
-class Filter(_base.Filter):
+class Filter(base.Filter):
spacePreserveElements = frozenset(["pre", "textarea"] + list(rcdataElements))
def __iter__(self):
preserve = 0
- for token in _base.Filter.__iter__(self):
+ for token in base.Filter.__iter__(self):
type = token["type"]
if type == "StartTag" \
and (preserve or token["name"] in self.spacePreserveElements):
From 6c30d0bd7d5dfa4722368a8dabc637d057350185 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Tue, 12 Jul 2016 02:09:40 +0100
Subject: [PATCH 069/223] Move serializer.htmlserializer to serializer
The directory has long been pretty redundant, so let's just kill it.
---
.../htmlserializer.py => serializer.py} | 23 ++++++++++++-------
html5lib/serializer/__init__.py | 16 -------------
2 files changed, 15 insertions(+), 24 deletions(-)
rename html5lib/{serializer/htmlserializer.py => serializer.py} (95%)
delete mode 100644 html5lib/serializer/__init__.py
diff --git a/html5lib/serializer/htmlserializer.py b/html5lib/serializer.py
similarity index 95%
rename from html5lib/serializer/htmlserializer.py
rename to html5lib/serializer.py
index 8a9439df..d58a6857 100644
--- a/html5lib/serializer/htmlserializer.py
+++ b/html5lib/serializer.py
@@ -5,9 +5,9 @@
from codecs import register_error, xmlcharrefreplace_errors
-from ..constants import voidElements, booleanAttributes, spaceCharacters
-from ..constants import rcdataElements, entities, xmlEntities
-from .. import utils
+from .constants import voidElements, booleanAttributes, spaceCharacters
+from .constants import rcdataElements, entities, xmlEntities
+from . import treewalkers, utils
from xml.sax.saxutils import escape
spaceCharacters = "".join(spaceCharacters)
@@ -73,6 +73,13 @@ def htmlentityreplace_errors(exc):
register_error("htmlentityreplace", htmlentityreplace_errors)
+def serialize(input, tree="etree", encoding=None, **serializer_opts):
+ # XXX: Should we cache this?
+ walker = treewalkers.getTreeWalker(tree)
+ s = HTMLSerializer(**serializer_opts)
+ return s.render(walker(input), encoding)
+
+
class HTMLSerializer(object):
# attribute quoting options
@@ -181,24 +188,24 @@ def serialize(self, treewalker, encoding=None):
self.errors = []
if encoding and self.inject_meta_charset:
- from ..filters.inject_meta_charset import Filter
+ from .filters.inject_meta_charset import Filter
treewalker = Filter(treewalker, encoding)
# Alphabetical attributes is here under the assumption that none of
# the later filters add or change order of attributes; it needs to be
# before the sanitizer so escaped elements come out correctly
if self.alphabetical_attributes:
- from ..filters.alphabeticalattributes import Filter
+ from .filters.alphabeticalattributes import Filter
treewalker = Filter(treewalker)
# WhitespaceFilter should be used before OptionalTagFilter
# for maximum efficiently of this latter filter
if self.strip_whitespace:
- from ..filters.whitespace import Filter
+ from .filters.whitespace import Filter
treewalker = Filter(treewalker)
if self.sanitize:
- from ..filters.sanitizer import Filter
+ from .filters.sanitizer import Filter
treewalker = Filter(treewalker)
if self.omit_optional_tags:
- from ..filters.optionaltags import Filter
+ from .filters.optionaltags import Filter
treewalker = Filter(treewalker)
for token in treewalker:
diff --git a/html5lib/serializer/__init__.py b/html5lib/serializer/__init__.py
deleted file mode 100644
index 8380839a..00000000
--- a/html5lib/serializer/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from __future__ import absolute_import, division, unicode_literals
-
-from .. import treewalkers
-
-from .htmlserializer import HTMLSerializer
-
-
-def serialize(input, tree="etree", format="html", encoding=None,
- **serializer_opts):
- # XXX: Should we cache this?
- walker = treewalkers.getTreeWalker(tree)
- if format == "html":
- s = HTMLSerializer(**serializer_opts)
- else:
- raise ValueError("type must be html")
- return s.render(walker(input), encoding)
From 1a61c445fbc3a6b805352b12ff4debf1dbef2afe Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Tue, 12 Jul 2016 02:14:44 +0100
Subject: [PATCH 070/223] Rename treewalkers.genshistream to .genshi for
consistency
---
html5lib/treewalkers/__init__.py | 6 +++---
html5lib/treewalkers/{genshistream.py => genshi.py} | 0
2 files changed, 3 insertions(+), 3 deletions(-)
rename html5lib/treewalkers/{genshistream.py => genshi.py} (100%)
diff --git a/html5lib/treewalkers/__init__.py b/html5lib/treewalkers/__init__.py
index 00ae2804..c809ef64 100644
--- a/html5lib/treewalkers/__init__.py
+++ b/html5lib/treewalkers/__init__.py
@@ -13,7 +13,7 @@
from .. import constants
from ..utils import default_etree
-__all__ = ["getTreeWalker", "pprint", "dom", "etree", "genshistream", "lxmletree"]
+__all__ = ["getTreeWalker", "pprint", "dom", "etree", "genshi", "lxmletree"]
treeWalkerCache = {}
@@ -43,8 +43,8 @@ def getTreeWalker(treeType, implementation=None, **kwargs):
from . import dom
treeWalkerCache[treeType] = dom.TreeWalker
elif treeType == "genshi":
- from . import genshistream
- treeWalkerCache[treeType] = genshistream.TreeWalker
+ from . import genshi
+ treeWalkerCache[treeType] = genshi.TreeWalker
elif treeType == "lxml":
from . import lxmletree
treeWalkerCache[treeType] = lxmletree.TreeWalker
diff --git a/html5lib/treewalkers/genshistream.py b/html5lib/treewalkers/genshi.py
similarity index 100%
rename from html5lib/treewalkers/genshistream.py
rename to html5lib/treewalkers/genshi.py
From 8db5828d3624d0892f0d5903d089972dce6c48f0 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Tue, 12 Jul 2016 02:18:26 +0100
Subject: [PATCH 071/223] Rename treewalkers.lxmletree to .etree_lxml for
consistency
---
html5lib/treewalkers/__init__.py | 6 +++---
html5lib/treewalkers/{lxmletree.py => etree_lxml.py} | 0
2 files changed, 3 insertions(+), 3 deletions(-)
rename html5lib/treewalkers/{lxmletree.py => etree_lxml.py} (100%)
diff --git a/html5lib/treewalkers/__init__.py b/html5lib/treewalkers/__init__.py
index c809ef64..61172656 100644
--- a/html5lib/treewalkers/__init__.py
+++ b/html5lib/treewalkers/__init__.py
@@ -13,7 +13,7 @@
from .. import constants
from ..utils import default_etree
-__all__ = ["getTreeWalker", "pprint", "dom", "etree", "genshi", "lxmletree"]
+__all__ = ["getTreeWalker", "pprint", "dom", "etree", "genshi", "etree_lxml"]
treeWalkerCache = {}
@@ -46,8 +46,8 @@ def getTreeWalker(treeType, implementation=None, **kwargs):
from . import genshi
treeWalkerCache[treeType] = genshi.TreeWalker
elif treeType == "lxml":
- from . import lxmletree
- treeWalkerCache[treeType] = lxmletree.TreeWalker
+ from . import etree_lxml
+ treeWalkerCache[treeType] = etree_lxml.TreeWalker
elif treeType == "etree":
from . import etree
if implementation is None:
diff --git a/html5lib/treewalkers/lxmletree.py b/html5lib/treewalkers/etree_lxml.py
similarity index 100%
rename from html5lib/treewalkers/lxmletree.py
rename to html5lib/treewalkers/etree_lxml.py
From c4dd6771836841ee796af8035dbf8239074ed5ec Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Tue, 12 Jul 2016 02:52:37 +0100
Subject: [PATCH 072/223] Move a whole bunch of private modules to be
underscore prefixed
This moves: html5lib.ihatexml -> html5lib._ihatexml
html5lib.inputstream -> html5lib._inputstream
html5lib.tokenizer -> html5lib._tokenizer
html5lib.trie -> html5lib._trie
html5lib.utils -> html5lib._utils
---
html5lib/{ihatexml.py => _ihatexml.py} | 0
html5lib/{inputstream.py => _inputstream.py} | 10 +--
html5lib/{tokenizer.py => _tokenizer.py} | 4 +-
html5lib/{trie => _trie}/__init__.py | 0
html5lib/{trie => _trie}/_base.py | 0
html5lib/{trie => _trie}/datrie.py | 0
html5lib/{trie => _trie}/py.py | 0
html5lib/{utils.py => _utils.py} | 0
html5lib/html5parser.py | 90 ++++++++++----------
html5lib/serializer.py | 8 +-
html5lib/tests/test_encoding.py | 12 +--
html5lib/tests/test_stream.py | 6 +-
html5lib/tests/tokenizer.py | 6 +-
html5lib/treebuilders/__init__.py | 2 +-
html5lib/treebuilders/dom.py | 2 +-
html5lib/treebuilders/etree.py | 6 +-
html5lib/treebuilders/etree_lxml.py | 6 +-
html5lib/treewalkers/__init__.py | 2 +-
html5lib/treewalkers/etree.py | 2 +-
html5lib/treewalkers/etree_lxml.py | 4 +-
parse.py | 4 +-
21 files changed, 82 insertions(+), 82 deletions(-)
rename html5lib/{ihatexml.py => _ihatexml.py} (100%)
rename html5lib/{inputstream.py => _inputstream.py} (99%)
rename html5lib/{tokenizer.py => _tokenizer.py} (99%)
rename html5lib/{trie => _trie}/__init__.py (100%)
rename html5lib/{trie => _trie}/_base.py (100%)
rename html5lib/{trie => _trie}/datrie.py (100%)
rename html5lib/{trie => _trie}/py.py (100%)
rename html5lib/{utils.py => _utils.py} (100%)
diff --git a/html5lib/ihatexml.py b/html5lib/_ihatexml.py
similarity index 100%
rename from html5lib/ihatexml.py
rename to html5lib/_ihatexml.py
diff --git a/html5lib/inputstream.py b/html5lib/_inputstream.py
similarity index 99%
rename from html5lib/inputstream.py
rename to html5lib/_inputstream.py
index dafe33ca..79f2331e 100644
--- a/html5lib/inputstream.py
+++ b/html5lib/_inputstream.py
@@ -10,7 +10,7 @@
from .constants import EOF, spaceCharacters, asciiLetters, asciiUppercase
from .constants import ReparseException
-from . import utils
+from . import _utils
from io import StringIO
@@ -28,7 +28,7 @@
invalid_unicode_no_surrogate = "[\u0001-\u0008\u000B\u000E-\u001F\u007F-\u009F\uFDD0-\uFDEF\uFFFE\uFFFF\U0001FFFE\U0001FFFF\U0002FFFE\U0002FFFF\U0003FFFE\U0003FFFF\U0004FFFE\U0004FFFF\U0005FFFE\U0005FFFF\U0006FFFE\U0006FFFF\U0007FFFE\U0007FFFF\U0008FFFE\U0008FFFF\U0009FFFE\U0009FFFF\U000AFFFE\U000AFFFF\U000BFFFE\U000BFFFF\U000CFFFE\U000CFFFF\U000DFFFE\U000DFFFF\U000EFFFE\U000EFFFF\U000FFFFE\U000FFFFF\U0010FFFE\U0010FFFF]" # noqa
-if utils.supports_lone_surrogates:
+if _utils.supports_lone_surrogates:
# Use one extra step of indirection and create surrogates with
# eval. Not using this indirection would introduce an illegal
# unicode literal on platforms not supporting such lone
@@ -176,7 +176,7 @@ def __init__(self, source):
"""
- if not utils.supports_lone_surrogates:
+ if not _utils.supports_lone_surrogates:
# Such platforms will have already checked for such
# surrogate errors, so no need to do this checking.
self.reportCharacterErrors = None
@@ -304,9 +304,9 @@ def characterErrorsUCS2(self, data):
codepoint = ord(match.group())
pos = match.start()
# Pretty sure there should be endianness issues here
- if utils.isSurrogatePair(data[pos:pos + 2]):
+ if _utils.isSurrogatePair(data[pos:pos + 2]):
# We have a surrogate pair!
- char_val = utils.surrogatePairToCodepoint(data[pos:pos + 2])
+ char_val = _utils.surrogatePairToCodepoint(data[pos:pos + 2])
if char_val in non_bmp_invalid_codepoints:
self.errors.append("invalid-codepoint")
skip = True
diff --git a/html5lib/tokenizer.py b/html5lib/_tokenizer.py
similarity index 99%
rename from html5lib/tokenizer.py
rename to html5lib/_tokenizer.py
index 3f10c01f..6078f66a 100644
--- a/html5lib/tokenizer.py
+++ b/html5lib/_tokenizer.py
@@ -11,9 +11,9 @@
from .constants import tokenTypes, tagTokenTypes
from .constants import replacementCharacters
-from .inputstream import HTMLInputStream
+from ._inputstream import HTMLInputStream
-from .trie import Trie
+from ._trie import Trie
entitiesTrie = Trie(entities)
diff --git a/html5lib/trie/__init__.py b/html5lib/_trie/__init__.py
similarity index 100%
rename from html5lib/trie/__init__.py
rename to html5lib/_trie/__init__.py
diff --git a/html5lib/trie/_base.py b/html5lib/_trie/_base.py
similarity index 100%
rename from html5lib/trie/_base.py
rename to html5lib/_trie/_base.py
diff --git a/html5lib/trie/datrie.py b/html5lib/_trie/datrie.py
similarity index 100%
rename from html5lib/trie/datrie.py
rename to html5lib/_trie/datrie.py
diff --git a/html5lib/trie/py.py b/html5lib/_trie/py.py
similarity index 100%
rename from html5lib/trie/py.py
rename to html5lib/_trie/py.py
diff --git a/html5lib/utils.py b/html5lib/_utils.py
similarity index 100%
rename from html5lib/utils.py
rename to html5lib/_utils.py
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index c51f73b1..470c8a7d 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -8,13 +8,13 @@
except ImportError:
from ordereddict import OrderedDict
-from . import inputstream
-from . import tokenizer
+from . import _inputstream
+from . import _tokenizer
from . import treebuilders
from .treebuilders.base import Marker
-from . import utils
+from . import _utils
from .constants import (
spaceCharacters, asciiUpper2Lower,
specialElements, headingElements, cdataElements, rcdataElements,
@@ -82,7 +82,7 @@ def _parse(self, stream, innerHTML=False, container="div", scripting=False, **kw
self.innerHTMLMode = innerHTML
self.container = container
self.scripting = scripting
- self.tokenizer = tokenizer.HTMLTokenizer(stream, parser=self, **kwargs)
+ self.tokenizer = _tokenizer.HTMLTokenizer(stream, parser=self, **kwargs)
self.reset()
try:
@@ -344,7 +344,7 @@ def parseRCDataRawtext(self, token, contentType):
self.phase = self.phases["text"]
-@utils.memoize
+@_utils.memoize
def getPhases(debug):
def log(function):
"""Logger that records which phase processes each token"""
@@ -586,13 +586,13 @@ class BeforeHeadPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
("head", self.startTagHead)
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
(("head", "body", "html", "br"), self.endTagImplyHead)
])
self.endTagHandler.default = self.endTagOther
@@ -632,7 +632,7 @@ class InHeadPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
("title", self.startTagTitle),
(("noframes", "style"), self.startTagNoFramesStyle),
@@ -645,7 +645,7 @@ def __init__(self, parser, tree):
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
("head", self.endTagHead),
(("br", "html", "body"), self.endTagHtmlBodyBr)
])
@@ -687,8 +687,8 @@ def startTagMeta(self, token):
# the abstract Unicode string, and just use the
# ContentAttrParser on that, but using UTF-8 allows all chars
# to be encoded and as a ASCII-superset works.
- data = inputstream.EncodingBytes(attributes["content"].encode("utf-8"))
- parser = inputstream.ContentAttrParser(data)
+ data = _inputstream.EncodingBytes(attributes["content"].encode("utf-8"))
+ parser = _inputstream.ContentAttrParser(data)
codec = parser.parse()
self.parser.tokenizer.stream.changeEncoding(codec)
@@ -735,14 +735,14 @@ class InHeadNoscriptPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
(("basefont", "bgsound", "link", "meta", "noframes", "style"), self.startTagBaseLinkCommand),
(("head", "noscript"), self.startTagHeadNoscript),
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
("noscript", self.endTagNoscript),
("br", self.endTagBr),
])
@@ -799,7 +799,7 @@ class AfterHeadPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
("body", self.startTagBody),
("frameset", self.startTagFrameset),
@@ -809,8 +809,8 @@ def __init__(self, parser, tree):
("head", self.startTagHead)
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([(("body", "html", "br"),
- self.endTagHtmlBodyBr)])
+ self.endTagHandler = _utils.MethodDispatcher([(("body", "html", "br"),
+ self.endTagHtmlBodyBr)])
self.endTagHandler.default = self.endTagOther
def processEOF(self):
@@ -871,7 +871,7 @@ def __init__(self, parser, tree):
# Set this to the default handler
self.processSpaceCharacters = self.processSpaceCharactersNonPre
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
(("base", "basefont", "bgsound", "command", "link", "meta",
"script", "style", "title"),
@@ -918,7 +918,7 @@ def __init__(self, parser, tree):
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
("body", self.endTagBody),
("html", self.endTagHtml),
(("address", "article", "aside", "blockquote", "button", "center",
@@ -1588,9 +1588,9 @@ def endTagOther(self, token):
class TextPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([])
+ self.startTagHandler = _utils.MethodDispatcher([])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
("script", self.endTagScript)])
self.endTagHandler.default = self.endTagOther
@@ -1622,7 +1622,7 @@ class InTablePhase(Phase):
# http://www.whatwg.org/specs/web-apps/current-work/#in-table
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
("caption", self.startTagCaption),
("colgroup", self.startTagColgroup),
@@ -1636,7 +1636,7 @@ def __init__(self, parser, tree):
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
("table", self.endTagTable),
(("body", "caption", "col", "colgroup", "html", "tbody", "td",
"tfoot", "th", "thead", "tr"), self.endTagIgnore)
@@ -1813,14 +1813,14 @@ class InCaptionPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
(("caption", "col", "colgroup", "tbody", "td", "tfoot", "th",
"thead", "tr"), self.startTagTableElement)
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
("caption", self.endTagCaption),
("table", self.endTagTable),
(("body", "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
@@ -1885,13 +1885,13 @@ class InColumnGroupPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
("col", self.startTagCol)
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
("colgroup", self.endTagColgroup),
("col", self.endTagCol)
])
@@ -1949,7 +1949,7 @@ class InTableBodyPhase(Phase):
# http://www.whatwg.org/specs/web-apps/current-work/#in-table0
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
("tr", self.startTagTr),
(("td", "th"), self.startTagTableCell),
@@ -1958,7 +1958,7 @@ def __init__(self, parser, tree):
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
(("tbody", "tfoot", "thead"), self.endTagTableRowGroup),
("table", self.endTagTable),
(("body", "caption", "col", "colgroup", "html", "td", "th",
@@ -2047,7 +2047,7 @@ class InRowPhase(Phase):
# http://www.whatwg.org/specs/web-apps/current-work/#in-row
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
(("td", "th"), self.startTagTableCell),
(("caption", "col", "colgroup", "tbody", "tfoot", "thead",
@@ -2055,7 +2055,7 @@ def __init__(self, parser, tree):
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
("tr", self.endTagTr),
("table", self.endTagTable),
(("tbody", "tfoot", "thead"), self.endTagTableRowGroup),
@@ -2136,14 +2136,14 @@ class InCellPhase(Phase):
# http://www.whatwg.org/specs/web-apps/current-work/#in-cell
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
(("caption", "col", "colgroup", "tbody", "td", "tfoot", "th",
"thead", "tr"), self.startTagTableOther)
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
(("td", "th"), self.endTagTableCell),
(("body", "caption", "col", "colgroup", "html"), self.endTagIgnore),
(("table", "tbody", "tfoot", "thead", "tr"), self.endTagImply)
@@ -2212,7 +2212,7 @@ class InSelectPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
("option", self.startTagOption),
("optgroup", self.startTagOptgroup),
@@ -2222,7 +2222,7 @@ def __init__(self, parser, tree):
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
("option", self.endTagOption),
("optgroup", self.endTagOptgroup),
("select", self.endTagSelect)
@@ -2312,13 +2312,13 @@ class InSelectInTablePhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
(("caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"),
self.startTagTable)
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
(("caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"),
self.endTagTable)
])
@@ -2466,12 +2466,12 @@ class AfterBodyPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml)
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([("html", self.endTagHtml)])
+ self.endTagHandler = _utils.MethodDispatcher([("html", self.endTagHtml)])
self.endTagHandler.default = self.endTagOther
def processEOF(self):
@@ -2514,7 +2514,7 @@ class InFramesetPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
("frameset", self.startTagFrameset),
("frame", self.startTagFrame),
@@ -2522,7 +2522,7 @@ def __init__(self, parser, tree):
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
("frameset", self.endTagFrameset)
])
self.endTagHandler.default = self.endTagOther
@@ -2571,13 +2571,13 @@ class AfterFramesetPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
("noframes", self.startTagNoframes)
])
self.startTagHandler.default = self.startTagOther
- self.endTagHandler = utils.MethodDispatcher([
+ self.endTagHandler = _utils.MethodDispatcher([
("html", self.endTagHtml)
])
self.endTagHandler.default = self.endTagOther
@@ -2607,7 +2607,7 @@ class AfterAfterBodyPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml)
])
self.startTagHandler.default = self.startTagOther
@@ -2645,7 +2645,7 @@ class AfterAfterFramesetPhase(Phase):
def __init__(self, parser, tree):
Phase.__init__(self, parser, tree)
- self.startTagHandler = utils.MethodDispatcher([
+ self.startTagHandler = _utils.MethodDispatcher([
("html", self.startTagHtml),
("noframes", self.startTagNoFrames)
])
@@ -2707,7 +2707,7 @@ def processEndTag(self, token):
def adjust_attributes(token, replacements):
- if PY3 or utils.PY27:
+ if PY3 or _utils.PY27:
needs_adjustment = viewkeys(token['data']) & viewkeys(replacements)
else:
needs_adjustment = frozenset(token['data']) & frozenset(replacements)
diff --git a/html5lib/serializer.py b/html5lib/serializer.py
index d58a6857..8a780c58 100644
--- a/html5lib/serializer.py
+++ b/html5lib/serializer.py
@@ -7,7 +7,7 @@
from .constants import voidElements, booleanAttributes, spaceCharacters
from .constants import rcdataElements, entities, xmlEntities
-from . import treewalkers, utils
+from . import treewalkers, _utils
from xml.sax.saxutils import escape
spaceCharacters = "".join(spaceCharacters)
@@ -33,7 +33,7 @@
continue
if v != "&":
if len(v) == 2:
- v = utils.surrogatePairToCodepoint(v)
+ v = _utils.surrogatePairToCodepoint(v)
else:
v = ord(v)
if v not in encode_entity_map or k.islower():
@@ -51,8 +51,8 @@ def htmlentityreplace_errors(exc):
skip = False
continue
index = i + exc.start
- if utils.isSurrogatePair(exc.object[index:min([exc.end, index + 2])]):
- codepoint = utils.surrogatePairToCodepoint(exc.object[index:index + 2])
+ if _utils.isSurrogatePair(exc.object[index:min([exc.end, index + 2])]):
+ codepoint = _utils.surrogatePairToCodepoint(exc.object[index:index + 2])
skip = True
else:
codepoint = ord(c)
diff --git a/html5lib/tests/test_encoding.py b/html5lib/tests/test_encoding.py
index b6d20f24..9a411c77 100644
--- a/html5lib/tests/test_encoding.py
+++ b/html5lib/tests/test_encoding.py
@@ -5,7 +5,7 @@
import pytest
from .support import get_data_files, test_dir, errorMessage, TestData as _TestData
-from html5lib import HTMLParser, inputstream
+from html5lib import HTMLParser, _inputstream
def test_basic_prescan_length():
@@ -13,7 +13,7 @@ def test_basic_prescan_length():
pad = 1024 - len(data) + 1
data = data.replace(b"-a-", b"-" + (b"a" * pad) + b"-")
assert len(data) == 1024 # Sanity
- stream = inputstream.HTMLBinaryInputStream(data, useChardet=False)
+ stream = _inputstream.HTMLBinaryInputStream(data, useChardet=False)
assert 'utf-8' == stream.charEncoding[0].name
@@ -22,7 +22,7 @@ def test_parser_reparse():
pad = 10240 - len(data) + 1
data = data.replace(b"-a-", b"-" + (b"a" * pad) + b"-")
assert len(data) == 10240 # Sanity
- stream = inputstream.HTMLBinaryInputStream(data, useChardet=False)
+ stream = _inputstream.HTMLBinaryInputStream(data, useChardet=False)
assert 'windows-1252' == stream.charEncoding[0].name
p = HTMLParser(namespaceHTMLElements=False)
doc = p.parse(data, useChardet=False)
@@ -47,7 +47,7 @@ def test_parser_reparse():
("windows-1252", b"", {}),
])
def test_parser_args(expected, data, kwargs):
- stream = inputstream.HTMLBinaryInputStream(data, useChardet=False, **kwargs)
+ stream = _inputstream.HTMLBinaryInputStream(data, useChardet=False, **kwargs)
assert expected == stream.charEncoding[0].name
p = HTMLParser()
p.parse(data, useChardet=False, **kwargs)
@@ -85,7 +85,7 @@ def runParserEncodingTest(data, encoding):
def runPreScanEncodingTest(data, encoding):
- stream = inputstream.HTMLBinaryInputStream(data, useChardet=False)
+ stream = _inputstream.HTMLBinaryInputStream(data, useChardet=False)
encoding = encoding.lower().decode("ascii")
# Very crude way to ignore irrelevant tests
@@ -111,6 +111,6 @@ def test_encoding():
else:
def test_chardet():
with open(os.path.join(test_dir, "encoding", "chardet", "test_big5.txt"), "rb") as fp:
- encoding = inputstream.HTMLInputStream(fp.read()).charEncoding
+ encoding = _inputstream.HTMLInputStream(fp.read()).charEncoding
assert encoding[0].name == "big5"
# pylint:enable=wrong-import-position
diff --git a/html5lib/tests/test_stream.py b/html5lib/tests/test_stream.py
index e8d9fd86..27c39538 100644
--- a/html5lib/tests/test_stream.py
+++ b/html5lib/tests/test_stream.py
@@ -11,9 +11,9 @@
import six
from six.moves import http_client, urllib
-from html5lib.inputstream import (BufferedStream, HTMLInputStream,
- HTMLUnicodeInputStream, HTMLBinaryInputStream)
-from html5lib.utils import supports_lone_surrogates
+from html5lib._inputstream import (BufferedStream, HTMLInputStream,
+ HTMLUnicodeInputStream, HTMLBinaryInputStream)
+from html5lib._utils import supports_lone_surrogates
def test_basic():
diff --git a/html5lib/tests/tokenizer.py b/html5lib/tests/tokenizer.py
index 255c1859..1440a722 100644
--- a/html5lib/tests/tokenizer.py
+++ b/html5lib/tests/tokenizer.py
@@ -8,8 +8,8 @@
import pytest
from six import unichr
-from html5lib.tokenizer import HTMLTokenizer
-from html5lib import constants, utils
+from html5lib._tokenizer import HTMLTokenizer
+from html5lib import constants, _utils
class TokenizerTestParser(object):
@@ -156,7 +156,7 @@ def repl(m):
except ValueError:
# This occurs when unichr throws ValueError, which should
# only be for a lone-surrogate.
- if utils.supports_lone_surrogates:
+ if _utils.supports_lone_surrogates:
raise
return None
diff --git a/html5lib/treebuilders/__init__.py b/html5lib/treebuilders/__init__.py
index 6a6b2a4c..e2328847 100644
--- a/html5lib/treebuilders/__init__.py
+++ b/html5lib/treebuilders/__init__.py
@@ -28,7 +28,7 @@
from __future__ import absolute_import, division, unicode_literals
-from ..utils import default_etree
+from .._utils import default_etree
treeBuilderCache = {}
diff --git a/html5lib/treebuilders/dom.py b/html5lib/treebuilders/dom.py
index 461dc04f..dcfac220 100644
--- a/html5lib/treebuilders/dom.py
+++ b/html5lib/treebuilders/dom.py
@@ -8,7 +8,7 @@
from . import base
from .. import constants
from ..constants import namespaces
-from ..utils import moduleFactoryFactory
+from .._utils import moduleFactoryFactory
def getDomBuilder(DomImplementation):
diff --git a/html5lib/treebuilders/etree.py b/html5lib/treebuilders/etree.py
index 956a717b..cb1d4aef 100644
--- a/html5lib/treebuilders/etree.py
+++ b/html5lib/treebuilders/etree.py
@@ -6,10 +6,10 @@
import re
from . import base
-from .. import ihatexml
+from .. import _ihatexml
from .. import constants
from ..constants import namespaces
-from ..utils import moduleFactoryFactory
+from .._utils import moduleFactoryFactory
tag_regexp = re.compile("{([^}]*)}(.*)")
@@ -259,7 +259,7 @@ def serializeElement(element, indent=0):
def tostring(element): # pylint:disable=unused-variable
"""Serialize an element and its child nodes to a string"""
rv = []
- filter = ihatexml.InfosetFilter()
+ filter = _ihatexml.InfosetFilter()
def serializeElement(element):
if isinstance(element, ElementTree.ElementTree):
diff --git a/html5lib/treebuilders/etree_lxml.py b/html5lib/treebuilders/etree_lxml.py
index 15e22a57..908820c0 100644
--- a/html5lib/treebuilders/etree_lxml.py
+++ b/html5lib/treebuilders/etree_lxml.py
@@ -20,7 +20,7 @@
from ..constants import DataLossWarning
from .. import constants
from . import etree as etree_builders
-from .. import ihatexml
+from .. import _ihatexml
import lxml.etree as etree
@@ -54,7 +54,7 @@ def _getChildNodes(self):
def testSerializer(element):
rv = []
- infosetFilter = ihatexml.InfosetFilter(preventDoubleDashComments=True)
+ infosetFilter = _ihatexml.InfosetFilter(preventDoubleDashComments=True)
def serializeElement(element, indent=0):
if not hasattr(element, "tag"):
@@ -182,7 +182,7 @@ class TreeBuilder(base.TreeBuilder):
def __init__(self, namespaceHTMLElements, fullTree=False):
builder = etree_builders.getETreeModule(etree, fullTree=fullTree)
- infosetFilter = self.infosetFilter = ihatexml.InfosetFilter(preventDoubleDashComments=True)
+ infosetFilter = self.infosetFilter = _ihatexml.InfosetFilter(preventDoubleDashComments=True)
self.namespaceHTMLElements = namespaceHTMLElements
class Attributes(dict):
diff --git a/html5lib/treewalkers/__init__.py b/html5lib/treewalkers/__init__.py
index 61172656..9e19a559 100644
--- a/html5lib/treewalkers/__init__.py
+++ b/html5lib/treewalkers/__init__.py
@@ -11,7 +11,7 @@
from __future__ import absolute_import, division, unicode_literals
from .. import constants
-from ..utils import default_etree
+from .._utils import default_etree
__all__ = ["getTreeWalker", "pprint", "dom", "etree", "genshi", "etree_lxml"]
diff --git a/html5lib/treewalkers/etree.py b/html5lib/treewalkers/etree.py
index 41c652a9..8f30f078 100644
--- a/html5lib/treewalkers/etree.py
+++ b/html5lib/treewalkers/etree.py
@@ -13,7 +13,7 @@
from six import string_types
from . import base
-from ..utils import moduleFactoryFactory
+from .._utils import moduleFactoryFactory
tag_regexp = re.compile("{([^}]*)}(.*)")
diff --git a/html5lib/treewalkers/etree_lxml.py b/html5lib/treewalkers/etree_lxml.py
index d456e3b9..fb236311 100644
--- a/html5lib/treewalkers/etree_lxml.py
+++ b/html5lib/treewalkers/etree_lxml.py
@@ -6,7 +6,7 @@
from . import base
-from .. import ihatexml
+from .. import _ihatexml
def ensure_str(s):
@@ -132,7 +132,7 @@ def __init__(self, tree):
self.fragmentChildren = set()
tree = Root(tree)
base.NonRecursiveTreeWalker.__init__(self, tree)
- self.filter = ihatexml.InfosetFilter()
+ self.filter = _ihatexml.InfosetFilter()
def getNodeDetails(self, node):
if isinstance(node, tuple): # Text node
diff --git a/parse.py b/parse.py
index d5087fb8..3e65c330 100755
--- a/parse.py
+++ b/parse.py
@@ -11,7 +11,7 @@
from html5lib import html5parser
from html5lib import treebuilders, serializer, treewalkers
from html5lib import constants
-from html5lib import utils
+from html5lib import _utils
def parse():
@@ -116,7 +116,7 @@ def printOutput(parser, document, opts):
import lxml.etree
sys.stdout.write(lxml.etree.tostring(document, encoding="unicode"))
elif tb == "etree":
- sys.stdout.write(utils.default_etree.tostring(document, encoding="unicode"))
+ sys.stdout.write(_utils.default_etree.tostring(document, encoding="unicode"))
elif opts.tree:
if not hasattr(document, '__getitem__'):
document = [document]
From 18a7102f1b1754b430f459ec6e4996ed6464ad88 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Tue, 12 Jul 2016 22:21:08 +0100
Subject: [PATCH 073/223] Have only one set of allowed elements/attributes for
the sanitizer
---
html5lib/filters/sanitizer.py | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/html5lib/filters/sanitizer.py b/html5lib/filters/sanitizer.py
index 47da50fe..b5ddcb93 100644
--- a/html5lib/filters/sanitizer.py
+++ b/html5lib/filters/sanitizer.py
@@ -11,7 +11,7 @@
__all__ = ["Filter"]
-acceptable_elements = frozenset((
+allowed_elements = frozenset((
(namespaces['html'], 'a'),
(namespaces['html'], 'abbr'),
(namespaces['html'], 'acronym'),
@@ -175,7 +175,7 @@
(namespaces['svg'], 'use'),
))
-acceptable_attributes = frozenset((
+allowed_attributes = frozenset((
# HTML attributes
(None, 'abbr'),
(None, 'accept'),
@@ -552,7 +552,7 @@
(None, 'use')
))
-acceptable_css_properties = frozenset((
+allowed_css_properties = frozenset((
'azimuth',
'background-color',
'border-bottom-color',
@@ -601,7 +601,7 @@
'width',
))
-acceptable_css_keywords = frozenset((
+allowed_css_keywords = frozenset((
'auto',
'aqua',
'black',
@@ -643,7 +643,7 @@
'yellow',
))
-acceptable_svg_properties = frozenset((
+allowed_svg_properties = frozenset((
'fill',
'fill-opacity',
'fill-rule',
@@ -654,7 +654,7 @@
'stroke-opacity',
))
-acceptable_protocols = frozenset((
+allowed_protocols = frozenset((
'ed2k',
'ftp',
'http',
@@ -680,7 +680,7 @@
'data',
))
-acceptable_content_types = frozenset((
+allowed_content_types = frozenset((
'image/png',
'image/jpeg',
'image/gif',
@@ -689,14 +689,6 @@
'text/plain',
))
-allowed_elements = acceptable_elements
-allowed_attributes = acceptable_attributes
-allowed_css_properties = acceptable_css_properties
-allowed_css_keywords = acceptable_css_keywords
-allowed_svg_properties = acceptable_svg_properties
-allowed_protocols = acceptable_protocols
-allowed_content_types = acceptable_content_types
-
data_content_type = re.compile(r'''
^
From 00977d6ebe97ba71c4244ba2103134cde8084b97 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Thu, 14 Jul 2016 00:01:30 +0100
Subject: [PATCH 074/223] Rename a bunch of serializer module variables to be
underscore prefixed
---
html5lib/serializer.py | 44 ++++++++++++++++++++----------------------
1 file changed, 21 insertions(+), 23 deletions(-)
diff --git a/html5lib/serializer.py b/html5lib/serializer.py
index 8a780c58..103dd206 100644
--- a/html5lib/serializer.py
+++ b/html5lib/serializer.py
@@ -10,35 +10,33 @@
from . import treewalkers, _utils
from xml.sax.saxutils import escape
-spaceCharacters = "".join(spaceCharacters)
-
-quoteAttributeSpecChars = spaceCharacters + "\"'=<>`"
-quoteAttributeSpec = re.compile("[" + quoteAttributeSpecChars + "]")
-quoteAttributeLegacy = re.compile("[" + quoteAttributeSpecChars +
- "\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n"
- "\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15"
- "\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
- "\x20\x2f\x60\xa0\u1680\u180e\u180f\u2000"
- "\u2001\u2002\u2003\u2004\u2005\u2006\u2007"
- "\u2008\u2009\u200a\u2028\u2029\u202f\u205f"
- "\u3000]")
-
-
-encode_entity_map = {}
-is_ucs4 = len("\U0010FFFF") == 1
+_quoteAttributeSpecChars = "".join(spaceCharacters) + "\"'=<>`"
+_quoteAttributeSpec = re.compile("[" + _quoteAttributeSpecChars + "]")
+_quoteAttributeLegacy = re.compile("[" + _quoteAttributeSpecChars +
+ "\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n"
+ "\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15"
+ "\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x2f\x60\xa0\u1680\u180e\u180f\u2000"
+ "\u2001\u2002\u2003\u2004\u2005\u2006\u2007"
+ "\u2008\u2009\u200a\u2028\u2029\u202f\u205f"
+ "\u3000]")
+
+
+_encode_entity_map = {}
+_is_ucs4 = len("\U0010FFFF") == 1
for k, v in list(entities.items()):
# skip multi-character entities
- if ((is_ucs4 and len(v) > 1) or
- (not is_ucs4 and len(v) > 2)):
+ if ((_is_ucs4 and len(v) > 1) or
+ (not _is_ucs4 and len(v) > 2)):
continue
if v != "&":
if len(v) == 2:
v = _utils.surrogatePairToCodepoint(v)
else:
v = ord(v)
- if v not in encode_entity_map or k.islower():
+ if v not in _encode_entity_map or k.islower():
# prefer < over < and similarly for &, >, etc.
- encode_entity_map[v] = k
+ _encode_entity_map[v] = k
def htmlentityreplace_errors(exc):
@@ -58,7 +56,7 @@ def htmlentityreplace_errors(exc):
codepoint = ord(c)
codepoints.append(codepoint)
for cp in codepoints:
- e = encode_entity_map.get(cp)
+ e = _encode_entity_map.get(cp)
if e:
res.append("&")
res.append(e)
@@ -258,9 +256,9 @@ def serialize(self, treewalker, encoding=None):
if self.quote_attr_values == "always" or len(v) == 0:
quote_attr = True
elif self.quote_attr_values == "spec":
- quote_attr = quoteAttributeSpec.search(v) is not None
+ quote_attr = _quoteAttributeSpec.search(v) is not None
elif self.quote_attr_values == "legacy":
- quote_attr = quoteAttributeLegacy.search(v) is not None
+ quote_attr = _quoteAttributeLegacy.search(v) is not None
else:
raise ValueError("quote_attr_values must be one of: "
"'always', 'spec', or 'legacy'")
From 8cb144bce7b81a65cbd9401ba4b987e5055e5ba3 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Tue, 12 Jul 2016 22:30:50 +0100
Subject: [PATCH 075/223] Update the docs after all the renaming and add
CHANGES
---
CHANGES.rst | 14 +++++++++++++
doc/html5lib.filters.rst | 4 ++--
doc/html5lib.rst | 37 ++---------------------------------
doc/html5lib.serializer.rst | 19 ------------------
doc/html5lib.treebuilders.rst | 4 ++--
doc/html5lib.treewalkers.rst | 19 +++++++++---------
6 files changed, 30 insertions(+), 67 deletions(-)
delete mode 100644 doc/html5lib.serializer.rst
diff --git a/CHANGES.rst b/CHANGES.rst
index fe07f1ec..c6cbe78f 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -50,6 +50,20 @@ Released on XXX
with a set of keyword arguments: override_encoding, transport_encoding,
same_origin_parent_encoding, likely_encoding, and default_encoding.**
+* **Move filters._base, treebuilder._base, and treewalkers._base to .base
+ to clarify their status as public.**
+
+* **Get rid of the sanitizer package. Merge sanitizer.sanitize into the
+ sanitizer.htmlsanitizer module and move that to saniziter. This means
+ anyone who used sanitizer.sanitize or sanitizer.HTMLSanitizer needs no
+ code changes.**
+
+* **Rename treewalkers.lxmletree to .etree_lxml and
+ treewalkers.genshistream to .genshi to have a consistent API.**
+
+* Move a whole load of stuff (inputstream, ihatexml, trie, tokenizer,
+ utils) to be underscore prefixed to clarify their status as private.
+
0.9999999/1.0b8
~~~~~~~~~~~~~~~
diff --git a/doc/html5lib.filters.rst b/doc/html5lib.filters.rst
index 1fda38a7..38d4a956 100644
--- a/doc/html5lib.filters.rst
+++ b/doc/html5lib.filters.rst
@@ -1,10 +1,10 @@
filters Package
===============
-:mod:`_base` Module
+:mod:`base` Module
-------------------
-.. automodule:: html5lib.filters._base
+.. automodule:: html5lib.filters.base
:members:
:undoc-members:
:show-inheritance:
diff --git a/doc/html5lib.rst b/doc/html5lib.rst
index d4ed12b4..f0646aac 100644
--- a/doc/html5lib.rst
+++ b/doc/html5lib.rst
@@ -25,42 +25,10 @@ html5lib Package
:undoc-members:
:show-inheritance:
-:mod:`ihatexml` Module
+:mod:`serializer` Module
----------------------
-.. automodule:: html5lib.ihatexml
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`inputstream` Module
--------------------------
-
-.. automodule:: html5lib.inputstream
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`sanitizer` Module
------------------------
-
-.. automodule:: html5lib.sanitizer
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`tokenizer` Module
------------------------
-
-.. automodule:: html5lib.tokenizer
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`utils` Module
--------------------
-
-.. automodule:: html5lib.utils
+.. automodule:: html5lib.serializer
:members:
:undoc-members:
:show-inheritance:
@@ -71,7 +39,6 @@ Subpackages
.. toctree::
html5lib.filters
- html5lib.serializer
html5lib.treebuilders
html5lib.treewalkers
diff --git a/doc/html5lib.serializer.rst b/doc/html5lib.serializer.rst
deleted file mode 100644
index fa954742..00000000
--- a/doc/html5lib.serializer.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-serializer Package
-==================
-
-:mod:`serializer` Package
--------------------------
-
-.. automodule:: html5lib.serializer
- :members:
- :undoc-members:
- :show-inheritance:
-
-:mod:`htmlserializer` Module
-----------------------------
-
-.. automodule:: html5lib.serializer.htmlserializer
- :members:
- :undoc-members:
- :show-inheritance:
-
diff --git a/doc/html5lib.treebuilders.rst b/doc/html5lib.treebuilders.rst
index 99119839..aee82142 100644
--- a/doc/html5lib.treebuilders.rst
+++ b/doc/html5lib.treebuilders.rst
@@ -9,10 +9,10 @@ treebuilders Package
:undoc-members:
:show-inheritance:
-:mod:`_base` Module
+:mod:`base` Module
-------------------
-.. automodule:: html5lib.treebuilders._base
+.. automodule:: html5lib.treebuilders.base
:members:
:undoc-members:
:show-inheritance:
diff --git a/doc/html5lib.treewalkers.rst b/doc/html5lib.treewalkers.rst
index 694c8194..46501258 100644
--- a/doc/html5lib.treewalkers.rst
+++ b/doc/html5lib.treewalkers.rst
@@ -9,10 +9,10 @@ treewalkers Package
:undoc-members:
:show-inheritance:
-:mod:`_base` Module
+:mod:`base` Module
-------------------
-.. automodule:: html5lib.treewalkers._base
+.. automodule:: html5lib.treewalkers.base
:members:
:undoc-members:
:show-inheritance:
@@ -33,18 +33,19 @@ treewalkers Package
:undoc-members:
:show-inheritance:
-:mod:`genshistream` Module
---------------------------
+:mod:`etree_lxml` Module
+-----------------------
-.. automodule:: html5lib.treewalkers.genshistream
+.. automodule:: html5lib.treewalkers.etree_lxml
:members:
:undoc-members:
:show-inheritance:
-:mod:`lxmletree` Module
------------------------
-.. automodule:: html5lib.treewalkers.lxmletree
+:mod:`genshi` Module
+--------------------------
+
+.. automodule:: html5lib.treewalkers.genshi
:members:
:undoc-members:
- :show-inheritance:
+ :show-inheritance:
\ No newline at end of file
From ebf62250d23317ae1f51d8b8e4a1d3b62b260ff1 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Thu, 14 Jul 2016 21:22:14 +0100
Subject: [PATCH 076/223] 0.99999999 release! Let's party!
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
So almost 1.0. So almost…
---
CHANGES.rst | 2 +-
html5lib/__init__.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index c6cbe78f..3ccd0f1f 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,7 @@ Change Log
0.99999999/1.0b9
~~~~~~~~~~~~~~~~
-Released on XXX
+Released on July 14, 2016
* **Added ordereddict as a mandatory dependency on Python 2.6.**
diff --git a/html5lib/__init__.py b/html5lib/__init__.py
index 3f17d83c..b27bad71 100644
--- a/html5lib/__init__.py
+++ b/html5lib/__init__.py
@@ -22,4 +22,4 @@
"getTreeWalker", "serialize"]
# this has to be at the top level, see how setup.py parses this
-__version__ = "0.99999999-dev"
+__version__ = "0.99999999"
From a3b82521a3b7a57cedb7caa8d5f15974cdfa7c30 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Fri, 15 Jul 2016 00:06:06 +0100
Subject: [PATCH 077/223] Back to -dev
---
CHANGES.rst | 8 ++++++++
html5lib/__init__.py | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 3ccd0f1f..483bdedb 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,14 @@
Change Log
----------
+0.999999999/1.0b10
+~~~~~~~~~~~~~~~~~~
+
+Released on XXX
+
+* XXX
+
+
0.99999999/1.0b9
~~~~~~~~~~~~~~~~
diff --git a/html5lib/__init__.py b/html5lib/__init__.py
index b27bad71..473c265f 100644
--- a/html5lib/__init__.py
+++ b/html5lib/__init__.py
@@ -22,4 +22,4 @@
"getTreeWalker", "serialize"]
# this has to be at the top level, see how setup.py parses this
-__version__ = "0.99999999"
+__version__ = "0.999999999-dev"
From e0dc25f335d3df610f752df29d5c4301717eb452 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Fri, 15 Jul 2016 02:23:19 +0100
Subject: [PATCH 078/223] Fix attribute order to the treebuilder to be document
order
Somehow I managed to screw this up so it became reverse document order!
---
CHANGES.rst | 5 +++--
html5lib/html5parser.py | 6 +++++-
html5lib/tests/test_parser2.py | 33 +++++++++++++++++++++++++++++++--
3 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 483bdedb..570c9605 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,9 +4,10 @@ Change Log
0.999999999/1.0b10
~~~~~~~~~~~~~~~~~~
-Released on XXX
+Released on July 15, 2016
-* XXX
+* Fix attribute order going to the tree builder to be document order
+ instead of reverse document order(!).
0.99999999/1.0b9
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 470c8a7d..2abd63e4 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -265,7 +265,11 @@ def normalizeToken(self, token):
""" HTML5 specific normalizations to the token stream """
if token["type"] == tokenTypes["StartTag"]:
- token["data"] = OrderedDict(token['data'][::-1])
+ raw = token["data"]
+ token["data"] = OrderedDict(raw)
+ if len(raw) > len(token["data"]):
+ # we had some duplicated attribute, fix so first wins
+ token["data"].update(raw[::-1])
return token
diff --git a/html5lib/tests/test_parser2.py b/html5lib/tests/test_parser2.py
index 21dc59d9..bcc0bf48 100644
--- a/html5lib/tests/test_parser2.py
+++ b/html5lib/tests/test_parser2.py
@@ -1,12 +1,12 @@
from __future__ import absolute_import, division, unicode_literals
-from six import PY2, text_type
+from six import PY2, text_type, unichr
import io
from . import support # noqa
-from html5lib.constants import namespaces
+from html5lib.constants import namespaces, tokenTypes
from html5lib import parse, parseFragment, HTMLParser
@@ -53,6 +53,21 @@ def test_unicode_file():
assert parse(io.StringIO("a")) is not None
+def test_maintain_attribute_order():
+ # This is here because we impl it in parser and not tokenizer
+ p = HTMLParser()
+ # generate loads to maximize the chance a hash-based mutation will occur
+ attrs = [(unichr(x), i) for i, x in enumerate(range(ord('a'), ord('z')))]
+ token = {'name': 'html',
+ 'selfClosing': False,
+ 'selfClosingAcknowledged': False,
+ 'type': tokenTypes["StartTag"],
+ 'data': attrs}
+ out = p.normalizeToken(token)
+ attr_order = list(out["data"].keys())
+ assert attr_order == [x for x, i in attrs]
+
+
def test_duplicate_attribute():
# This is here because we impl it in parser and not tokenizer
doc = parse('
')
@@ -60,6 +75,20 @@ def test_duplicate_attribute():
assert el.get("class") == "a"
+def test_maintain_duplicate_attribute_order():
+ # This is here because we impl it in parser and not tokenizer
+ p = HTMLParser()
+ attrs = [(unichr(x), i) for i, x in enumerate(range(ord('a'), ord('z')))]
+ token = {'name': 'html',
+ 'selfClosing': False,
+ 'selfClosingAcknowledged': False,
+ 'type': tokenTypes["StartTag"],
+ 'data': attrs + [('a', len(attrs))]}
+ out = p.normalizeToken(token)
+ attr_order = list(out["data"].keys())
+ assert attr_order == [x for x, i in attrs]
+
+
def test_debug_log():
parser = HTMLParser(debug=True)
parser.parse("
a
bd
e")
From 6a73efa01754253605284b5a5688de3961b120fa Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Fri, 15 Jul 2016 02:24:18 +0100
Subject: [PATCH 079/223] Yes, another release, already. :(
---
html5lib/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/__init__.py b/html5lib/__init__.py
index 473c265f..8ee9b53e 100644
--- a/html5lib/__init__.py
+++ b/html5lib/__init__.py
@@ -22,4 +22,4 @@
"getTreeWalker", "serialize"]
# this has to be at the top level, see how setup.py parses this
-__version__ = "0.999999999-dev"
+__version__ = "0.999999999"
From 983a9355ea66a8c1626a42fd0682b48e246685bd Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Fri, 15 Jul 2016 02:24:33 +0100
Subject: [PATCH 080/223] And back to dev.
---
html5lib/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/__init__.py b/html5lib/__init__.py
index 8ee9b53e..f3cd9455 100644
--- a/html5lib/__init__.py
+++ b/html5lib/__init__.py
@@ -22,4 +22,4 @@
"getTreeWalker", "serialize"]
# this has to be at the top level, see how setup.py parses this
-__version__ = "0.999999999"
+__version__ = "0.9999999999-dev"
From 6cd93c82f5c0a09bc0a3ccab214d87537c5e60c2 Mon Sep 17 00:00:00 2001
From: John Vandenberg
Date: Fri, 22 Jul 2016 09:11:31 +0700
Subject: [PATCH 081/223] Monkeypatch pkg_resources to always use _markerlib
Prior to setuptools 20.10.0 there is patchy support for environment markers,
and setup.py fails while parsing them.
html5lib requires at least setuptools 18.5 for its environment markers.
However, @gsnedders developed a way to monkey patch pkg_resources
so that it always uses _markerlib, which allows all environment markers
to be used for any version of setuptools. Some patching of _markerlib
is also required so that it works on Python 3 also.
On removing the dependency for setuptools>=18.5, pip partially fails on
Python 2.6 with an error `Double requirement given: ordereddict`
and does not install the requirements.txt.
Fixed by removing ordereddict from requirements-test.txt
---
requirements-install.sh | 3 ---
requirements-test.txt | 1 -
requirements.txt | 1 -
setup.py | 53 +++++++++++++++++++++++++++++++++++++----
4 files changed, 48 insertions(+), 10 deletions(-)
diff --git a/requirements-install.sh b/requirements-install.sh
index 9b28888a..cd693444 100755
--- a/requirements-install.sh
+++ b/requirements-install.sh
@@ -5,9 +5,6 @@ if [[ $USE_OPTIONAL != "true" && $USE_OPTIONAL != "false" ]]; then
exit 1
fi
-# Make sure we're running setuptools >= 18.5
-pip install -U pip setuptools>=18.5
-
pip install -U -r requirements-test.txt
if [[ $USE_OPTIONAL == "true" ]]; then
diff --git a/requirements-test.txt b/requirements-test.txt
index e24223ef..e1ad307d 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -4,4 +4,3 @@ flake8
pytest
pytest-expect>=1.1,<2.0
mock
-ordereddict ; python_version < '2.7'
diff --git a/requirements.txt b/requirements.txt
index 92c09036..745993b9 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,3 @@
six
webencodings
ordereddict ; python_version < '2.7'
-setuptools>=18.5
diff --git a/setup.py b/setup.py
index 7c419e2c..00fee241 100644
--- a/setup.py
+++ b/setup.py
@@ -8,10 +8,54 @@
from setuptools import setup, find_packages, __version__ as setuptools_version
from pkg_resources import parse_version
-if parse_version(setuptools_version) < parse_version("18.5"):
- print("html5lib requires setuptools version 18.5 or above; "
- "please upgrade before installing (you have %s)" % setuptools_version)
- sys.exit(1)
+import pkg_resources
+
+try:
+ import _markerlib.markers
+except ImportError:
+ _markerlib = None
+
+
+# _markerlib.default_environment() obtains its data from _VARS
+# and wraps it in another dict, but _markerlib_evaluate writes
+# to the dict while it is iterating the keys, causing an error
+# on Python 3 only.
+# Replace _markerlib.default_environment to return a custom dict
+# that has all the necessary markers, and ignores any writes.
+
+class Python3MarkerDict(dict):
+
+ def __setitem__(self, key, value):
+ pass
+
+ def pop(self, i=-1):
+ return self[i]
+
+
+if _markerlib and sys.version_info[0] == 3:
+ env = _markerlib.markers._VARS
+ for key in list(env.keys()):
+ new_key = key.replace('.', '_')
+ if new_key != key:
+ env[new_key] = env[key]
+
+ _markerlib.markers._VARS = Python3MarkerDict(env)
+
+ def default_environment():
+ return _markerlib.markers._VARS
+
+ _markerlib.default_environment = default_environment
+
+# Avoid the very buggy pkg_resources.parser, which doesnt consistently
+# recognise the markers needed by this setup.py
+# Change this to setuptools 20.10.0 to support all markers.
+if pkg_resources:
+ if parse_version(setuptools_version) < parse_version('18.5'):
+ MarkerEvaluation = pkg_resources.MarkerEvaluation
+
+ del pkg_resources.parser
+ pkg_resources.evaluate_marker = MarkerEvaluation._markerlib_evaluate
+ MarkerEvaluation.evaluate_marker = MarkerEvaluation._markerlib_evaluate
classifiers = [
'Development Status :: 5 - Production/Stable',
@@ -60,7 +104,6 @@
install_requires=[
'six',
'webencodings',
- 'setuptools>=18.5'
],
extras_require={
# A empty extra that only has a conditional marker will be
From a3022dcea691780d300547bbf68b4dd921995d1c Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Tue, 26 Jul 2016 14:19:01 +0100
Subject: [PATCH 082/223] Require flake8 to be < 3.0 for Python 2.6 support
(#291)
---
requirements-test.txt | 2 +-
tox.ini | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/requirements-test.txt b/requirements-test.txt
index e1ad307d..40df78d4 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,6 +1,6 @@
-r requirements.txt
-flake8
+flake8<3.0
pytest
pytest-expect>=1.1,<2.0
mock
diff --git a/tox.ini b/tox.ini
index efaea775..da64de71 100644
--- a/tox.ini
+++ b/tox.ini
@@ -3,7 +3,7 @@ envlist = {py26,py27,py33,py34,py35,pypy}-{base,optional}
[testenv]
deps =
- flake8
+ flake8<3.0
pytest
pytest-expect>=1.1,<2.0
mock
From ea0fafdbff732b1272140b696d6948054ed1d6d2 Mon Sep 17 00:00:00 2001
From: John Vandenberg
Date: Fri, 16 Sep 2016 04:34:00 +0700
Subject: [PATCH 083/223] Remove redundant submodule update (#302)
Travis CI automatically updates submodules during initialisation.
---
.travis.yml | 3 ---
1 file changed, 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 94bb87e7..6f6be0f1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,9 +17,6 @@ env:
- USE_OPTIONAL=true
- USE_OPTIONAL=false
-before_install:
- - git submodule update --init --recursive
-
install:
- bash requirements-install.sh
From ff6111cd82191a2eb963d6d662c6da8fa2e7ddde Mon Sep 17 00:00:00 2001
From: Eric Amorde
Date: Thu, 27 Oct 2016 14:33:26 -0700
Subject: [PATCH 084/223] Declare explicit dependency on Six 1.9 (#301)
---
.travis.yml | 1 +
requirements-install.sh | 4 ++++
requirements.txt | 2 +-
setup.py | 2 +-
4 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 6f6be0f1..09ef5985 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,6 +16,7 @@ cache:
env:
- USE_OPTIONAL=true
- USE_OPTIONAL=false
+ - SIX_VERSION=1.9 USE_OPTIONAL=true
install:
- bash requirements-install.sh
diff --git a/requirements-install.sh b/requirements-install.sh
index cd693444..0be226a6 100755
--- a/requirements-install.sh
+++ b/requirements-install.sh
@@ -11,6 +11,10 @@ if [[ $USE_OPTIONAL == "true" ]]; then
pip install -U -r requirements-optional.txt
fi
+if [[ $SIX_VERSION != "false" ]]; then
+ pip install six==$SIX_VERSION
+fi
+
if [[ $CI == "true" ]]; then
pip install -U codecov
fi
diff --git a/requirements.txt b/requirements.txt
index 745993b9..3884556f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,3 @@
-six
+six>=1.9
webencodings
ordereddict ; python_version < '2.7'
diff --git a/setup.py b/setup.py
index 00fee241..6f0fc17e 100644
--- a/setup.py
+++ b/setup.py
@@ -102,7 +102,7 @@ def default_environment():
maintainer_email='james@hoppipolla.co.uk',
packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
install_requires=[
- 'six',
+ 'six>=1.9',
'webencodings',
],
extras_require={
From 1a28d721091a2c433c6e8471d14cbb75afd70d1c Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Thu, 27 Oct 2016 15:01:15 -0700
Subject: [PATCH 085/223] Fix typo in docs. (#300)
Statement was repeated twice on a single line.
---
doc/movingparts.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/movingparts.rst b/doc/movingparts.rst
index 36539785..80ee2ad1 100644
--- a/doc/movingparts.rst
+++ b/doc/movingparts.rst
@@ -136,7 +136,7 @@ To use a filter, simply wrap it around a stream:
>>> dom = html5lib.parse("
")
-
-HTMLTokenizer
-~~~~~~~~~~~~~
-
-This is the default tokenizer, the heart of html5lib. The implementation
-can be found in `html5lib/tokenizer.py
-`_.
-
-HTMLSanitizer
-~~~~~~~~~~~~~
-
-This is a tokenizer that removes unsafe markup and CSS styles from the
-input. Elements that are known to be safe are passed through and the
-rest is converted to visible text. The default configuration of the
-sanitizer follows the `WHATWG Sanitization Rules
-`_.
-
-The implementation can be found in `html5lib/sanitizer.py
-`_.
From 85540983f6285c82f2a1c4a8d756ae58d0c1e713 Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Sat, 15 Apr 2017 09:40:10 -0700
Subject: [PATCH 096/223] Fix Sphinx title underline warnings
---
doc/html5lib.rst | 2 +-
doc/html5lib.treewalkers.rst | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/doc/html5lib.rst b/doc/html5lib.rst
index 22af7728..44e34573 100644
--- a/doc/html5lib.rst
+++ b/doc/html5lib.rst
@@ -24,7 +24,7 @@ html5lib Package
:show-inheritance:
:mod:`serializer` Module
-----------------------
+------------------------
.. automodule:: html5lib.serializer
:members:
diff --git a/doc/html5lib.treewalkers.rst b/doc/html5lib.treewalkers.rst
index 46501258..085d8a98 100644
--- a/doc/html5lib.treewalkers.rst
+++ b/doc/html5lib.treewalkers.rst
@@ -10,7 +10,7 @@ treewalkers Package
:show-inheritance:
:mod:`base` Module
--------------------
+------------------
.. automodule:: html5lib.treewalkers.base
:members:
@@ -34,7 +34,7 @@ treewalkers Package
:show-inheritance:
:mod:`etree_lxml` Module
------------------------
+------------------------
.. automodule:: html5lib.treewalkers.etree_lxml
:members:
@@ -43,9 +43,9 @@ treewalkers Package
:mod:`genshi` Module
---------------------------
+--------------------
.. automodule:: html5lib.treewalkers.genshi
:members:
:undoc-members:
- :show-inheritance:
\ No newline at end of file
+ :show-inheritance:
From c8fca0ecc7c704995947601e03da0c34a85ecdf5 Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Sat, 15 Apr 2017 09:50:52 -0700
Subject: [PATCH 097/223] Open in binary mode for Python 3
---
html5lib/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/__init__.py b/html5lib/__init__.py
index 745b9342..b1970d29 100644
--- a/html5lib/__init__.py
+++ b/html5lib/__init__.py
@@ -7,7 +7,7 @@
Example usage::
import html5lib
- with open("my_document.html") as f:
+ with open("my_document.html", "rb") as f:
tree = html5lib.parse(f)
For convenience, this module re-exports the following names:
From 637826ffa72ca982dff6ae7204e4afcc35f3e29e Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Sat, 15 Apr 2017 11:51:16 -0700
Subject: [PATCH 098/223] Update and expand "moving parts" doc
---
doc/movingparts.rst | 65 +++++++++++++++++++++------------------------
1 file changed, 31 insertions(+), 34 deletions(-)
diff --git a/doc/movingparts.rst b/doc/movingparts.rst
index 3eeff4f2..1f3086cb 100644
--- a/doc/movingparts.rst
+++ b/doc/movingparts.rst
@@ -4,22 +4,25 @@ The moving parts
html5lib consists of a number of components, which are responsible for
handling its features.
+Parsing uses a *tree builder* to generate a *tree*, the in-memory representation of the document.
+Several tree representations are supported, as are translations to other formats via *tree adapters*.
+The tree may be translated to a token stream with a *tree walker*, from which :class:`~html5lib.serializer.HTMLSerializer` produces a stream of bytes.
+The token stream may also be transformed by use of *filters* to accomplish tasks like sanitization.
Tree builders
-------------
The parser reads HTML by tokenizing the content and building a tree that
-the user can later access. There are three main types of trees that
-html5lib can build:
+the user can later access. html5lib can build three types of trees:
-* ``etree`` - this is the default; builds a tree based on ``xml.etree``,
+* ``etree`` - this is the default; builds a tree based on :mod:`xml.etree`,
which can be found in the standard library. Whenever possible, the
accelerated ``ElementTree`` implementation (i.e.
``xml.etree.cElementTree`` on Python 2.x) is used.
-* ``dom`` - builds a tree based on ``xml.dom.minidom``.
+* ``dom`` - builds a tree based on :mod:`xml.dom.minidom`.
-* ``lxml.etree`` - uses lxml's implementation of the ``ElementTree``
+* ``lxml`` - uses the :mod:`lxml.etree` implementation of the ``ElementTree``
API. The performance gains are relatively small compared to using the
accelerated ``ElementTree`` module.
@@ -31,21 +34,15 @@ You can specify the builder by name when using the shorthand API:
with open("mydocument.html", "rb") as f:
lxml_etree_document = html5lib.parse(f, treebuilder="lxml")
-When instantiating a parser object, you have to pass a tree builder
-class in the ``tree`` keyword attribute:
+To get a builder class by name, use the :func:`~html5lib.treebuilders.getTreeBuilder` function.
-.. code-block:: python
-
- import html5lib
- parser = html5lib.HTMLParser(tree=SomeTreeBuilder)
- document = parser.parse("
Hello World!")
-
-To get a builder class by name, use the ``getTreeBuilder`` function:
+When instantiating a :class:`~html5lib.html5parser.HTMLParser` object, you must pass a tree builder class via the ``tree`` keyword attribute:
.. code-block:: python
import html5lib
- parser = html5lib.HTMLParser(tree=html5lib.getTreeBuilder("dom"))
+ TreeBuilder = html5lib.getTreeBuilder("dom")
+ parser = html5lib.HTMLParser(tree=TreeBuilder)
minidom_document = parser.parse("
Hello World!")
The implementation of builders can be found in `html5lib/treebuilders/
@@ -55,17 +52,16 @@ The implementation of builders can be found in `html5lib/treebuilders/
Tree walkers
------------
-Once a tree is ready, you can work on it either manually, or using
-a tree walker, which provides a streaming view of the tree. html5lib
-provides walkers for all three supported types of trees (``etree``,
-``dom`` and ``lxml``).
+In addition to manipulating a tree directly, you can use a tree walker to generate a streaming view of it.
+html5lib provides walkers for ``etree``, ``dom``, and ``lxml`` trees, as well as ``genshi`` `markup streams `_.
The implementation of walkers can be found in `html5lib/treewalkers/
`_.
-Walkers make consuming HTML easier. html5lib uses them to provide you
-with has a couple of handy tools.
+html5lib provides a few tools for consuming token streams:
+* :class:`~html5lib.serializer.HTMLSerializer`, to generate a stream of bytes; and
+* filters, to manipulate the token stream.
HTMLSerializer
~~~~~~~~~~~~~~
@@ -90,15 +86,14 @@ The serializer lets you write HTML back as a stream of bytes.
'>'
'Witam wszystkich'
-You can customize the serializer behaviour in a variety of ways, consult
-the :class:`~html5lib.serializer.htmlserializer.HTMLSerializer`
-documentation.
+You can customize the serializer behaviour in a variety of ways. Consult
+the :class:`~html5lib.serializer.HTMLSerializer` documentation.
Filters
~~~~~~~
-You can alter the stream content with filters provided by html5lib:
+html5lib provides several filters
* :class:`alphabeticalattributes.Filter
` sorts attributes on
@@ -110,11 +105,11 @@ You can alter the stream content with filters provided by html5lib:
the document
* :class:`lint.Filter ` raises
- ``LintError`` exceptions on invalid tag and attribute names, invalid
+ :exc:`AssertionError` exceptions on invalid tag and attribute names, invalid
PCDATA, etc.
* :class:`optionaltags.Filter `
- removes tags from the stream which are not necessary to produce valid
+ removes tags from the token stream which are not necessary to produce valid
HTML
* :class:`sanitizer.Filter ` removes
@@ -125,9 +120,9 @@ You can alter the stream content with filters provided by html5lib:
* :class:`whitespace.Filter `
collapses all whitespace characters to single spaces unless they're in
- ```` or ``textarea`` tags.
+ ```` or ```` tags.
-To use a filter, simply wrap it around a stream:
+To use a filter, simply wrap it around a token stream:
.. code-block:: python
@@ -142,9 +137,11 @@ To use a filter, simply wrap it around a stream:
Tree adapters
-------------
-Used to translate one type of tree to another. More documentation
-pending, sorry.
+Tree adapters can be used to translate between tree formats.
+Two adapters are provided by html5lib:
+* :func:`html5lib.treeadapters.genshi.to_genshi()` generates a `Genshi markup stream `_.
+* :func:`html5lib.treeadapters.sax.to_sax()` calls a SAX handler based on the tree.
Encoding discovery
------------------
@@ -156,14 +153,14 @@ the following way:
* The encoding may be explicitly specified by passing the name of the
encoding as the encoding parameter to the
:meth:`~html5lib.html5parser.HTMLParser.parse` method on
- ``HTMLParser`` objects.
+ :class:`~html5lib.html5parser.HTMLParser` objects.
* If no encoding is specified, the parser will attempt to detect the
encoding from a ```` element in the first 512 bytes of the
document (this is only a partial implementation of the current HTML
- 5 specification).
+ specification).
-* If no encoding can be found and the chardet library is available, an
+* If no encoding can be found and the :mod:`chardet` library is available, an
attempt will be made to sniff the encoding from the byte pattern.
* If all else fails, the default encoding will be used. This is usually
From 254fc900f70b908bcc98edb948f525cb920d0007 Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Sat, 15 Apr 2017 12:02:50 -0700
Subject: [PATCH 099/223] Add treeadapters package doc
---
doc/html5lib.rst | 1 +
doc/html5lib.treeadapters.rst | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+)
create mode 100644 doc/html5lib.treeadapters.rst
diff --git a/doc/html5lib.rst b/doc/html5lib.rst
index 44e34573..1925e3e7 100644
--- a/doc/html5lib.rst
+++ b/doc/html5lib.rst
@@ -39,4 +39,5 @@ Subpackages
html5lib.filters
html5lib.treebuilders
html5lib.treewalkers
+ html5lib.treeadapters
diff --git a/doc/html5lib.treeadapters.rst b/doc/html5lib.treeadapters.rst
new file mode 100644
index 00000000..6b2dc78d
--- /dev/null
+++ b/doc/html5lib.treeadapters.rst
@@ -0,0 +1,20 @@
+treebuilders Package
+====================
+
+:mod:`~html5lib.treeadapters` Package
+-------------------------------------
+
+.. automodule:: html5lib.treeadapters
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+.. automodule:: html5lib.treeadapters.genshi
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+.. automodule:: html5lib.treeadapters.sax
+ :members:
+ :undoc-members:
+ :show-inheritance:
From deb4206a59cf64ffb08d4baa0ae8b300bfafe726 Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Sat, 15 Apr 2017 12:03:00 -0700
Subject: [PATCH 100/223] Remove duplicate header
---
doc/html5lib.rst | 3 ---
1 file changed, 3 deletions(-)
diff --git a/doc/html5lib.rst b/doc/html5lib.rst
index 1925e3e7..2a0b150f 100644
--- a/doc/html5lib.rst
+++ b/doc/html5lib.rst
@@ -1,9 +1,6 @@
html5lib Package
================
-:mod:`html5lib` Package
------------------------
-
.. automodule:: html5lib
:members: __version__
From 29098676636bee16f19964d11d6623757635d37b Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Sat, 15 Apr 2017 12:03:14 -0700
Subject: [PATCH 101/223] Link to the spec
---
html5lib/__init__.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/html5lib/__init__.py b/html5lib/__init__.py
index b1970d29..143d308d 100644
--- a/html5lib/__init__.py
+++ b/html5lib/__init__.py
@@ -1,7 +1,7 @@
"""
-HTML parsing library based on the WHATWG "HTML5"
-specification. The parser is designed to be compatible with existing
-HTML found in the wild and implements well-defined error recovery that
+HTML parsing library based on the `WHATWG HTML specification
+`_. The parser is designed to be compatible with
+existing HTML found in the wild and implements well-defined error recovery that
is largely compatible with modern desktop web browsers.
Example usage::
@@ -12,7 +12,9 @@
For convenience, this module re-exports the following names:
-* :func:`~.html5parser.parse`, :func:`~.html5parser.parseFragment`, and :class:`~.html5parser.HTMLParser`
+* :func:`~.html5parser.parse`
+* :func:`~.html5parser.parseFragment`
+* :class:`~.html5parser.HTMLParser`
* :func:`~.treebuilders.getTreeBuilder`
* :func:`~.treewalkers.getTreeWalker`
* :func:`~.serializer.serialize`
From 739dcf003484d844812d58592c69bbb60f25f4e8 Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Sat, 15 Apr 2017 12:13:29 -0700
Subject: [PATCH 102/223] Add myself to AUTHORS
---
AUTHORS.rst | 1 +
1 file changed, 1 insertion(+)
diff --git a/AUTHORS.rst b/AUTHORS.rst
index c3820ef7..5b7637c4 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -42,3 +42,4 @@ Patches and suggestions
- Michael[tm] Smith
- Marc Abramowitz
- Jon Dufresne
+- Tom Most
From 984f934d30ba2fde0e9ce5d4581c73fb81654474 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Wed, 19 Apr 2017 05:01:00 -0700
Subject: [PATCH 103/223] Use Travis CI's keyword for pip caching (#334)
https://docs.travis-ci.com/user/caching/#pip-cache
---
.travis.yml | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index c5ffd833..65b92622 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,9 +9,7 @@ python:
sudo: false
-cache:
- directories:
- - $HOME/.cache/pip
+cache: pip
env:
- USE_OPTIONAL=true
From efe982b0efeb6805fc98a8a2a3d2e17c355d3ddf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Skytt=C3=A4?=
Date: Fri, 24 Feb 2017 10:37:57 +0200
Subject: [PATCH 104/223] More Python 3.6 invalid escape sequence deprecation
fixes
---
AUTHORS.rst | 1 +
html5lib/_ihatexml.py | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/AUTHORS.rst b/AUTHORS.rst
index c3820ef7..425dff02 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -42,3 +42,4 @@ Patches and suggestions
- Michael[tm] Smith
- Marc Abramowitz
- Jon Dufresne
+- Ville Skyttä
diff --git a/html5lib/_ihatexml.py b/html5lib/_ihatexml.py
index d6d1d6fb..4c77717b 100644
--- a/html5lib/_ihatexml.py
+++ b/html5lib/_ihatexml.py
@@ -180,7 +180,7 @@ def escapeRegexp(string):
nonXmlNameFirstBMPRegexp = re.compile('[\x00-@\\[-\\^`\\{-\xbf\xd7\xf7\u0132-\u0133\u013f-\u0140\u0149\u017f\u01c4-\u01cc\u01f1-\u01f3\u01f6-\u01f9\u0218-\u024f\u02a9-\u02ba\u02c2-\u0385\u0387\u038b\u038d\u03a2\u03cf\u03d7-\u03d9\u03db\u03dd\u03df\u03e1\u03f4-\u0400\u040d\u0450\u045d\u0482-\u048f\u04c5-\u04c6\u04c9-\u04ca\u04cd-\u04cf\u04ec-\u04ed\u04f6-\u04f7\u04fa-\u0530\u0557-\u0558\u055a-\u0560\u0587-\u05cf\u05eb-\u05ef\u05f3-\u0620\u063b-\u0640\u064b-\u0670\u06b8-\u06b9\u06bf\u06cf\u06d4\u06d6-\u06e4\u06e7-\u0904\u093a-\u093c\u093e-\u0957\u0962-\u0984\u098d-\u098e\u0991-\u0992\u09a9\u09b1\u09b3-\u09b5\u09ba-\u09db\u09de\u09e2-\u09ef\u09f2-\u0a04\u0a0b-\u0a0e\u0a11-\u0a12\u0a29\u0a31\u0a34\u0a37\u0a3a-\u0a58\u0a5d\u0a5f-\u0a71\u0a75-\u0a84\u0a8c\u0a8e\u0a92\u0aa9\u0ab1\u0ab4\u0aba-\u0abc\u0abe-\u0adf\u0ae1-\u0b04\u0b0d-\u0b0e\u0b11-\u0b12\u0b29\u0b31\u0b34-\u0b35\u0b3a-\u0b3c\u0b3e-\u0b5b\u0b5e\u0b62-\u0b84\u0b8b-\u0b8d\u0b91\u0b96-\u0b98\u0b9b\u0b9d\u0ba0-\u0ba2\u0ba5-\u0ba7\u0bab-\u0bad\u0bb6\u0bba-\u0c04\u0c0d\u0c11\u0c29\u0c34\u0c3a-\u0c5f\u0c62-\u0c84\u0c8d\u0c91\u0ca9\u0cb4\u0cba-\u0cdd\u0cdf\u0ce2-\u0d04\u0d0d\u0d11\u0d29\u0d3a-\u0d5f\u0d62-\u0e00\u0e2f\u0e31\u0e34-\u0e3f\u0e46-\u0e80\u0e83\u0e85-\u0e86\u0e89\u0e8b-\u0e8c\u0e8e-\u0e93\u0e98\u0ea0\u0ea4\u0ea6\u0ea8-\u0ea9\u0eac\u0eaf\u0eb1\u0eb4-\u0ebc\u0ebe-\u0ebf\u0ec5-\u0f3f\u0f48\u0f6a-\u109f\u10c6-\u10cf\u10f7-\u10ff\u1101\u1104\u1108\u110a\u110d\u1113-\u113b\u113d\u113f\u1141-\u114b\u114d\u114f\u1151-\u1153\u1156-\u1158\u115a-\u115e\u1162\u1164\u1166\u1168\u116a-\u116c\u116f-\u1171\u1174\u1176-\u119d\u119f-\u11a7\u11a9-\u11aa\u11ac-\u11ad\u11b0-\u11b6\u11b9\u11bb\u11c3-\u11ea\u11ec-\u11ef\u11f1-\u11f8\u11fa-\u1dff\u1e9c-\u1e9f\u1efa-\u1eff\u1f16-\u1f17\u1f1e-\u1f1f\u1f46-\u1f47\u1f4e-\u1f4f\u1f58\u1f5a\u1f5c\u1f5e\u1f7e-\u1f7f\u1fb5\u1fbd\u1fbf-\u1fc1\u1fc5\u1fcd-\u1fcf\u1fd4-\u1fd5\u1fdc-\u1fdf\u1fed-\u1ff1\u1ff5\u1ffd-\u2125\u2127-\u2129\u212c-\u212d\u212f-\u217f\u2183-\u3006\u3008-\u3020\u302a-\u3040\u3095-\u30a0\u30fb-\u3104\u312d-\u4dff\u9fa6-\uabff\ud7a4-\uffff]') # noqa
# Simpler things
-nonPubidCharRegexp = re.compile("[^\x20\x0D\x0Aa-zA-Z0-9\-\'()+,./:=?;!*#@$_%]")
+nonPubidCharRegexp = re.compile("[^\x20\x0D\x0Aa-zA-Z0-9\\-'()+,./:=?;!*#@$_%]")
class InfosetFilter(object):
From 05fcd625593f1fd499429bf2f50e9c407d88cf41 Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Thu, 31 Aug 2017 09:30:38 -0400
Subject: [PATCH 105/223] Fix alphabeticalattributes filter namepsace problem
(#324)
If a tag has an attribute with a None namespace and one with a str namespace,
then this filter would fail with a TypeError in Python 3. This fixes that.
Fixes #322
---
html5lib/filters/alphabeticalattributes.py | 13 ++-
html5lib/tests/test_alphabeticalattributes.py | 81 +++++++++++++++++++
2 files changed, 93 insertions(+), 1 deletion(-)
create mode 100644 html5lib/tests/test_alphabeticalattributes.py
diff --git a/html5lib/filters/alphabeticalattributes.py b/html5lib/filters/alphabeticalattributes.py
index 4795baec..f938ba1a 100644
--- a/html5lib/filters/alphabeticalattributes.py
+++ b/html5lib/filters/alphabeticalattributes.py
@@ -8,13 +8,24 @@
from ordereddict import OrderedDict
+def _attr_key(attr):
+ """Return an appropriate key for an attribute for sorting
+
+ Attributes have a namespace that can be either ``None`` or a string. We
+ can't compare the two because they're different types, so we convert
+ ``None`` to an empty string first.
+
+ """
+ return (attr[0][0] or ''), attr[0][1]
+
+
class Filter(base.Filter):
def __iter__(self):
for token in base.Filter.__iter__(self):
if token["type"] in ("StartTag", "EmptyTag"):
attrs = OrderedDict()
for name, value in sorted(token["data"].items(),
- key=lambda x: x[0]):
+ key=_attr_key):
attrs[name] = value
token["data"] = attrs
yield token
diff --git a/html5lib/tests/test_alphabeticalattributes.py b/html5lib/tests/test_alphabeticalattributes.py
new file mode 100644
index 00000000..9e560a1e
--- /dev/null
+++ b/html5lib/tests/test_alphabeticalattributes.py
@@ -0,0 +1,81 @@
+from __future__ import absolute_import, division, unicode_literals
+
+try:
+ from collections import OrderedDict
+except ImportError:
+ from ordereddict import OrderedDict
+
+import pytest
+
+import html5lib
+from html5lib.filters.alphabeticalattributes import Filter
+from html5lib.serializer import HTMLSerializer
+
+
+@pytest.mark.parametrize('msg, attrs, expected_attrs', [
+ (
+ 'no attrs',
+ {},
+ {}
+ ),
+ (
+ 'one attr',
+ {(None, 'alt'): 'image'},
+ OrderedDict([((None, 'alt'), 'image')])
+ ),
+ (
+ 'multiple attrs',
+ {
+ (None, 'src'): 'foo',
+ (None, 'alt'): 'image',
+ (None, 'style'): 'border: 1px solid black;'
+ },
+ OrderedDict([
+ ((None, 'alt'), 'image'),
+ ((None, 'src'), 'foo'),
+ ((None, 'style'), 'border: 1px solid black;')
+ ])
+ ),
+])
+def test_alphabetizing(msg, attrs, expected_attrs):
+ tokens = [{'type': 'StartTag', 'name': 'img', 'data': attrs}]
+ output_tokens = list(Filter(tokens))
+
+ attrs = output_tokens[0]['data']
+ assert attrs == expected_attrs
+
+
+def test_with_different_namespaces():
+ tokens = [{
+ 'type': 'StartTag',
+ 'name': 'pattern',
+ 'data': {
+ (None, 'id'): 'patt1',
+ ('http://www.w3.org/1999/xlink', 'href'): '#patt2'
+ }
+ }]
+ output_tokens = list(Filter(tokens))
+
+ attrs = output_tokens[0]['data']
+ assert attrs == OrderedDict([
+ ((None, 'id'), 'patt1'),
+ (('http://www.w3.org/1999/xlink', 'href'), '#patt2')
+ ])
+
+
+def test_with_serializer():
+ """Verify filter works in the context of everything else"""
+ parser = html5lib.HTMLParser()
+ dom = parser.parseFragment('')
+ walker = html5lib.getTreeWalker('etree')
+ ser = HTMLSerializer(
+ alphabetical_attributes=True,
+ quote_attr_values='always'
+ )
+
+ # FIXME(willkg): The "xlink" namespace gets dropped by the serializer. When
+ # that gets fixed, we can fix this expected result.
+ assert (
+ ser.render(walker(dom)) ==
+ ''
+ )
From 590d9a50d5d2837e56cfb66155129eaf18e77110 Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Fri, 1 Sep 2017 12:48:10 -0400
Subject: [PATCH 106/223] Fix tox.ini to allow specifying pytest tests (#323)
This fixes tox.ini so that you can pass arguments to py.test.
For example:
tox -e py34-base html5lib/tests/test_serializer.py
will now only run the serializer tests.
tox -e py34-base -- -vv
will run with super verbose mode and tons of data will go flying by in your
terminal.
---
tox.ini | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tox.ini b/tox.ini
index da64de71..43528d0c 100644
--- a/tox.ini
+++ b/tox.ini
@@ -13,5 +13,5 @@ deps =
optional: -r{toxinidir}/requirements-optional.txt
commands =
- {envbindir}/py.test
+ {envbindir}/py.test {posargs}
{toxinidir}/flake8-run.sh
From b47e3a1974f7492b2d54349d379343a936ba4dfc Mon Sep 17 00:00:00 2001
From: Ritwik Gupta
Date: Thu, 5 Oct 2017 14:28:41 -0400
Subject: [PATCH 107/223] Remove tuple regression, use lists
---
html5lib/constants.py | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/html5lib/constants.py b/html5lib/constants.py
index d2d0dcd8..1836a387 100644
--- a/html5lib/constants.py
+++ b/html5lib/constants.py
@@ -588,25 +588,25 @@
])
booleanAttributes = {
- "": frozenset(("irrelevant",)),
- "style": frozenset(("scoped",)),
- "img": frozenset(("ismap",)),
- "audio": frozenset(("autoplay", "controls")),
- "video": frozenset(("autoplay", "controls")),
- "script": frozenset(("defer", "async")),
- "details": frozenset(("open",)),
- "datagrid": frozenset(("multiple", "disabled")),
- "command": frozenset(("hidden", "disabled", "checked", "default")),
- "hr": frozenset(("noshade")),
- "menu": frozenset(("autosubmit",)),
- "fieldset": frozenset(("disabled", "readonly")),
- "option": frozenset(("disabled", "readonly", "selected")),
- "optgroup": frozenset(("disabled", "readonly")),
- "button": frozenset(("disabled", "autofocus")),
- "input": frozenset(("disabled", "readonly", "required", "autofocus", "checked", "ismap")),
- "select": frozenset(("disabled", "readonly", "autofocus", "multiple")),
- "output": frozenset(("disabled", "readonly")),
- "iframe": frozenset(("seamless")),
+ "": frozenset(["irrelevant"]),
+ "style": frozenset(["scoped"]),
+ "img": frozenset(["ismap"]),
+ "audio": frozenset(["autoplay", "controls"]),
+ "video": frozenset(["autoplay", "controls"]),
+ "script": frozenset(["defer", "async"]),
+ "details": frozenset(["open"]),
+ "datagrid": frozenset(["multiple", "disabled"]),
+ "command": frozenset(["hidden", "disabled", "checked", "default"]),
+ "hr": frozenset(["noshade"]),
+ "menu": frozenset(["autosubmit"]),
+ "fieldset": frozenset(["disabled", "readonly"]),
+ "option": frozenset(["disabled", "readonly", "selected"]),
+ "optgroup": frozenset(["disabled", "readonly"]),
+ "button": frozenset(["disabled", "autofocus"]),
+ "input": frozenset(["disabled", "readonly", "required", "autofocus", "checked", "ismap"]),
+ "select": frozenset(["disabled", "readonly", "autofocus", "multiple"]),
+ "output": frozenset(["disabled", "readonly"]),
+ "iframe": frozenset(["seamless"]),
}
# entitiesWindows1252 has to be _ordered_ and needs to have an index. It
From 0cae52b2073e3f2220db93a7650901f2200f2a13 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Mon, 16 Oct 2017 06:37:14 -0700
Subject: [PATCH 108/223] Include license file in the generated wheel package
(#350)
The wheel package format supports including the license file. This is
done using the [metadata] section in the setup.cfg file. For additional
information on this feature, see:
https://wheel.readthedocs.io/en/stable/index.html#including-the-license-in-the-generated-wheel-file
---
setup.cfg | 3 +++
1 file changed, 3 insertions(+)
diff --git a/setup.cfg b/setup.cfg
index 3152ac54..d309fdaa 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -9,3 +9,6 @@ exclude = .git,__pycache__,.tox,doc
[flake8]
ignore = N
max-line-length = 139
+
+[metadata]
+license_file = LICENSE
From bd6ee1198bf6a7686b6ab784b43db8763b42d478 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Wed, 25 Oct 2017 03:33:48 -0700
Subject: [PATCH 109/223] Add testing for Python 3.6 and document support
(#333)
Fixes #351
---
.travis.yml | 1 +
requirements-install.sh | 2 --
setup.py | 1 +
tox.ini | 2 +-
4 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 65b92622..a6f17c3b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,7 @@ python:
- "3.3"
- "3.4"
- "3.5"
+ - "3.6"
- "pypy"
sudo: false
diff --git a/requirements-install.sh b/requirements-install.sh
index 7ba9396f..d110bcef 100755
--- a/requirements-install.sh
+++ b/requirements-install.sh
@@ -1,7 +1,5 @@
#!/bin/bash -ex
-pip install pip==6.1.0
-
pip install -U -r requirements-test.txt
if [[ $USE_OPTIONAL == "true" ]]; then
diff --git a/setup.py b/setup.py
index 6f0fc17e..cdb63fd3 100644
--- a/setup.py
+++ b/setup.py
@@ -70,6 +70,7 @@ def default_environment():
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Text Processing :: Markup :: HTML'
]
diff --git a/tox.ini b/tox.ini
index 43528d0c..17c5db4d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = {py26,py27,py33,py34,py35,pypy}-{base,optional}
+envlist = {py26,py27,py33,py34,py35,py36,pypy}-{base,optional}
[testenv]
deps =
From 74ebfc97a17a4e45a131c0cb70845714f1a8af5e Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Sat, 28 Oct 2017 06:39:36 -0700
Subject: [PATCH 110/223] Fix Travis CI builds on Python 3.4
Avoid passing -U to pip install commands. It causes the six package to
upgrade, which fails on the Travis 3.4 image. I cannot reproduce this
locally, so I'm left to conclude that the Travis Python 3.4 image is
corrupt in some way. The installed six package is perfectly fine for
testing, so use it without upgrading. All builds now pass.
Install six package first to avoid upgrading it then downgrading it in
some test configurations.
---
requirements-install.sh | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/requirements-install.sh b/requirements-install.sh
index d110bcef..b7a8d96d 100755
--- a/requirements-install.sh
+++ b/requirements-install.sh
@@ -1,15 +1,15 @@
#!/bin/bash -ex
-pip install -U -r requirements-test.txt
-
-if [[ $USE_OPTIONAL == "true" ]]; then
- pip install -U -r requirements-optional.txt
-fi
-
if [[ $SIX_VERSION ]]; then
pip install six==$SIX_VERSION
fi
+pip install -r requirements-test.txt
+
+if [[ $USE_OPTIONAL == "true" ]]; then
+ pip install -r requirements-optional.txt
+fi
+
if [[ $CI == "true" ]]; then
- pip install -U codecov
+ pip install codecov
fi
From 8788bdafbf6dc183e96470e4c138211a92e880b8 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Tue, 31 Oct 2017 11:11:13 -0700
Subject: [PATCH 111/223] Remove utils/spider.py (#353)
Fixes #349
---
utils/spider.py | 125 ------------------------------------------------
1 file changed, 125 deletions(-)
delete mode 100644 utils/spider.py
diff --git a/utils/spider.py b/utils/spider.py
deleted file mode 100644
index 3a325888..00000000
--- a/utils/spider.py
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/usr/bin/env python
-"""Spider to try and find bugs in the parser. Requires httplib2 and elementtree
-
-usage:
-import spider
-s = spider.Spider()
-s.spider("http://www.google.com", maxURLs=100)
-"""
-
-import urllib.request
-import urllib.error
-import urllib.parse
-import urllib.robotparser
-import md5
-
-import httplib2
-
-import html5lib
-from html5lib.treebuilders import etree
-
-
-class Spider(object):
-
- def __init__(self):
- self.unvisitedURLs = set()
- self.visitedURLs = set()
- self.buggyURLs = set()
- self.robotParser = urllib.robotparser.RobotFileParser()
- self.contentDigest = {}
- self.http = httplib2.Http(".cache")
-
- def run(self, initialURL, maxURLs=1000):
- urlNumber = 0
- self.visitedURLs.add(initialURL)
- content = self.loadURL(initialURL)
- while maxURLs is None or urlNumber < maxURLs:
- if content is not None:
- self.parse(content)
- urlNumber += 1
- if not self.unvisitedURLs:
- break
- content = self.loadURL(self.unvisitedURLs.pop())
-
- def parse(self, content):
- failed = False
- p = html5lib.HTMLParser(tree=etree.TreeBuilder)
- try:
- tree = p.parse(content)
- except:
- self.buggyURLs.add(self.currentURL)
- failed = True
- print("BUGGY:", self.currentURL)
- self.visitedURLs.add(self.currentURL)
- if not failed:
- self.updateURLs(tree)
-
- def loadURL(self, url):
- resp, content = self.http.request(url, "GET")
- self.currentURL = url
- digest = md5.md5(content).hexdigest()
- if digest in self.contentDigest:
- content = None
- self.visitedURLs.add(url)
- else:
- self.contentDigest[digest] = url
-
- if resp['status'] != "200":
- content = None
-
- return content
-
- def updateURLs(self, tree):
- """Take all the links in the current document, extract the URLs and
- update the list of visited and unvisited URLs according to whether we
- have seen them before or not"""
- urls = set()
- # Remove all links we have already visited
- for link in tree.findall(".//a"):
- try:
- url = urllib.parse.urldefrag(link.attrib['href'])[0]
- if (url and url not in self.unvisitedURLs and url
- not in self.visitedURLs):
- urls.add(url)
- except KeyError:
- pass
-
- # Remove all non-http URLs and add a suitable base URL where that is
- # missing
- newUrls = set()
- for url in urls:
- splitURL = list(urllib.parse.urlsplit(url))
- if splitURL[0] != "http":
- continue
- if splitURL[1] == "":
- splitURL[1] = urllib.parse.urlsplit(self.currentURL)[1]
- newUrls.add(urllib.parse.urlunsplit(splitURL))
- urls = newUrls
-
- responseHeaders = {}
- # Now we want to find the content types of the links we haven't visited
- for url in urls:
- try:
- resp, content = self.http.request(url, "HEAD")
- responseHeaders[url] = resp
- except AttributeError:
- # Don't know why this happens
- pass
-
- # Remove links not of content-type html or pages not found
- # XXX - need to deal with other status codes?
- toVisit = set([url for url in urls if url in responseHeaders and
- "html" in responseHeaders[url]['content-type'] and
- responseHeaders[url]['status'] == "200"])
-
- # Now check we are allowed to spider the page
- for url in toVisit:
- robotURL = list(urllib.parse.urlsplit(url)[:2])
- robotURL.extend(["robots.txt", "", ""])
- robotURL = urllib.parse.urlunsplit(robotURL)
- self.robotParser.set_url(robotURL)
- if not self.robotParser.can_fetch("*", url):
- toVisit.remove(url)
-
- self.visitedURLs.update(urls)
- self.unvisitedURLs.update(toVisit)
From f32994553539b6ecde1640cef785024b076ba025 Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Tue, 31 Oct 2017 17:21:30 -0400
Subject: [PATCH 112/223] Fix annotaion-xml typo
Fixes #339
---
html5lib/constants.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/constants.py b/html5lib/constants.py
index 975aa021..70a80b23 100644
--- a/html5lib/constants.py
+++ b/html5lib/constants.py
@@ -423,7 +423,7 @@
])
htmlIntegrationPointElements = frozenset([
- (namespaces["mathml"], "annotaion-xml"),
+ (namespaces["mathml"], "annotation-xml"),
(namespaces["svg"], "foreignObject"),
(namespaces["svg"], "desc"),
(namespaces["svg"], "title")
From f25d7c0a47733ce445115081c0f09f6588426d7f Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Wed, 1 Nov 2017 20:01:54 -0700
Subject: [PATCH 113/223] Add missing colon
---
doc/movingparts.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/movingparts.rst b/doc/movingparts.rst
index 1f3086cb..b9b999a2 100644
--- a/doc/movingparts.rst
+++ b/doc/movingparts.rst
@@ -93,7 +93,7 @@ the :class:`~html5lib.serializer.HTMLSerializer` documentation.
Filters
~~~~~~~
-html5lib provides several filters
+html5lib provides several filters:
* :class:`alphabeticalattributes.Filter
` sorts attributes on
From 5eb89ccb18ac34449580d092f4934ef6283c5ab1 Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Wed, 1 Nov 2017 20:20:18 -0700
Subject: [PATCH 114/223] Rework token stream intro
---
doc/movingparts.rst | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/doc/movingparts.rst b/doc/movingparts.rst
index b9b999a2..6ba367a2 100644
--- a/doc/movingparts.rst
+++ b/doc/movingparts.rst
@@ -58,10 +58,7 @@ html5lib provides walkers for ``etree``, ``dom``, and ``lxml`` trees, as well as
The implementation of walkers can be found in `html5lib/treewalkers/
`_.
-html5lib provides a few tools for consuming token streams:
-
-* :class:`~html5lib.serializer.HTMLSerializer`, to generate a stream of bytes; and
-* filters, to manipulate the token stream.
+html5lib provides :class:`~html5lib.serializer.HTMLSerializer` for generating a stream of bytes from a token stream, and several filters which manipulate the stream.
HTMLSerializer
~~~~~~~~~~~~~~
From cb2702c11252ee6578643b0c07156d1b11700eac Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Wed, 1 Nov 2017 20:26:44 -0700
Subject: [PATCH 115/223] Remove textual backticks in changelog
reST doesn't support nesting inline markup, so this shows up in
rendered for with the backticks.
---
CHANGES.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 5a9449e6..8690d749 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -32,7 +32,7 @@ Released on July 14, 2016
* Cease supporting DATrie under PyPy.
-* **Remove ``PullDOM`` support, as this hasn't ever been properly
+* **Remove PullDOM support, as this hasn't ever been properly
tested, doesn't entirely work, and as far as I can tell is
completely unused by anyone.**
From 1084ed0db8613158216b9da7e313c1f8345ae4ab Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Wed, 1 Nov 2017 20:32:58 -0700
Subject: [PATCH 116/223] Asymptote no more
---
html5lib/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/__init__.py b/html5lib/__init__.py
index 143d308d..fc9bb09e 100644
--- a/html5lib/__init__.py
+++ b/html5lib/__init__.py
@@ -31,5 +31,5 @@
"getTreeWalker", "serialize", "__version__"]
# this has to be at the top level, see how setup.py parses this
-#: Distribution version number, which asymptotically approaches 1.
+#: Distribution version number.
__version__ = "0.9999999999-dev"
From deb98bb8fbfb08366aa08e95dd86b2ece3a6232c Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Sat, 4 Nov 2017 13:56:37 -0700
Subject: [PATCH 117/223] Remove __version__ from __all__
---
html5lib/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/__init__.py b/html5lib/__init__.py
index fc9bb09e..3edfcbf3 100644
--- a/html5lib/__init__.py
+++ b/html5lib/__init__.py
@@ -28,7 +28,7 @@
from .serializer import serialize
__all__ = ["HTMLParser", "parse", "parseFragment", "getTreeBuilder",
- "getTreeWalker", "serialize", "__version__"]
+ "getTreeWalker", "serialize"]
# this has to be at the top level, see how setup.py parses this
#: Distribution version number.
From 5f637af8edffd1c0bc3e9dcefa089edcfce9a255 Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Tue, 7 Nov 2017 13:13:50 -0500
Subject: [PATCH 118/223] Drop support for Python 2.6 (#356)
Fixes #330
---
.travis.yml | 1 -
README.rst | 5 ++---
html5lib/_trie/_base.py | 3 +--
html5lib/filters/alphabeticalattributes.py | 5 +----
html5lib/html5parser.py | 6 +-----
html5lib/tests/test_alphabeticalattributes.py | 5 +----
html5lib/treewalkers/etree.py | 9 +--------
requirements.txt | 1 -
setup.py | 5 -----
tox.ini | 3 +--
10 files changed, 8 insertions(+), 35 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index a6f17c3b..07fdff6f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,5 @@
language: python
python:
- - "2.6"
- "2.7"
- "3.3"
- "3.4"
diff --git a/README.rst b/README.rst
index 2ad46090..8c151328 100644
--- a/README.rst
+++ b/README.rst
@@ -90,7 +90,7 @@ More documentation is available at https://html5lib.readthedocs.io/.
Installation
------------
-html5lib works on CPython 2.6+, CPython 3.3+ and PyPy. To install it,
+html5lib works on CPython 2.7+, CPython 3.3+ and PyPy. To install it,
use:
.. code-block:: bash
@@ -128,8 +128,7 @@ Tests
-----
Unit tests require the ``pytest`` and ``mock`` libraries and can be
-run using the ``py.test`` command in the root directory;
-``ordereddict`` is required under Python 2.6. All should pass.
+run using the ``py.test`` command in the root directory.
Test data are contained in a separate `html5lib-tests
`_ repository and included
diff --git a/html5lib/_trie/_base.py b/html5lib/_trie/_base.py
index 25eece46..a1158bbb 100644
--- a/html5lib/_trie/_base.py
+++ b/html5lib/_trie/_base.py
@@ -13,8 +13,7 @@ def keys(self, prefix=None):
if prefix is None:
return set(keys)
- # Python 2.6: no set comprehensions
- return set([x for x in keys if x.startswith(prefix)])
+ return {x for x in keys if x.startswith(prefix)}
def has_keys_with_prefix(self, prefix):
for key in self.keys():
diff --git a/html5lib/filters/alphabeticalattributes.py b/html5lib/filters/alphabeticalattributes.py
index f938ba1a..5fea9f69 100644
--- a/html5lib/filters/alphabeticalattributes.py
+++ b/html5lib/filters/alphabeticalattributes.py
@@ -2,10 +2,7 @@
from . import base
-try:
- from collections import OrderedDict
-except ImportError:
- from ordereddict import OrderedDict
+from collections import OrderedDict
def _attr_key(attr):
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 2abd63e4..f8309e14 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -2,11 +2,7 @@
from six import with_metaclass, viewkeys, PY3
import types
-
-try:
- from collections import OrderedDict
-except ImportError:
- from ordereddict import OrderedDict
+from collections import OrderedDict
from . import _inputstream
from . import _tokenizer
diff --git a/html5lib/tests/test_alphabeticalattributes.py b/html5lib/tests/test_alphabeticalattributes.py
index 9e560a1e..7d5b8e0f 100644
--- a/html5lib/tests/test_alphabeticalattributes.py
+++ b/html5lib/tests/test_alphabeticalattributes.py
@@ -1,9 +1,6 @@
from __future__ import absolute_import, division, unicode_literals
-try:
- from collections import OrderedDict
-except ImportError:
- from ordereddict import OrderedDict
+from collections import OrderedDict
import pytest
diff --git a/html5lib/treewalkers/etree.py b/html5lib/treewalkers/etree.py
index 8f30f078..d15a7eeb 100644
--- a/html5lib/treewalkers/etree.py
+++ b/html5lib/treewalkers/etree.py
@@ -1,13 +1,6 @@
from __future__ import absolute_import, division, unicode_literals
-try:
- from collections import OrderedDict
-except ImportError:
- try:
- from ordereddict import OrderedDict
- except ImportError:
- OrderedDict = dict
-
+from collections import OrderedDict
import re
from six import string_types
diff --git a/requirements.txt b/requirements.txt
index 3884556f..ae7ec3d0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,2 @@
six>=1.9
webencodings
-ordereddict ; python_version < '2.7'
diff --git a/setup.py b/setup.py
index cdb63fd3..3e413f2a 100644
--- a/setup.py
+++ b/setup.py
@@ -64,7 +64,6 @@ def default_environment():
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
@@ -107,10 +106,6 @@ def default_environment():
'webencodings',
],
extras_require={
- # A empty extra that only has a conditional marker will be
- # unconditonally installed when the condition matches.
- ":python_version == '2.6'": ["ordereddict"],
-
# A conditional extra will only install these items when the extra is
# requested and the condition matches.
"datrie:platform_python_implementation == 'CPython'": ["datrie"],
diff --git a/tox.ini b/tox.ini
index 5b78570c..0ec9805d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = {py26,py27,py33,py34,py35,py36,pypy}-{base,optional}
+envlist = {py27,py33,py34,py35,py36,pypy}-{base,optional}
[testenv]
deps =
@@ -9,7 +9,6 @@ deps =
mock
base: six
base: webencodings
- py26-base: ordereddict
optional: -r{toxinidir}/requirements-optional.txt
doc: Sphinx
From 6bae6d910bf9a0746a3ceb39a7045d56821f7a4f Mon Sep 17 00:00:00 2001
From: John Vandenberg
Date: Wed, 8 Nov 2017 11:31:25 +0700
Subject: [PATCH 119/223] Avoid use of bash in tox
---
tox.ini | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tox.ini b/tox.ini
index 0ec9805d..42492fb7 100644
--- a/tox.ini
+++ b/tox.ini
@@ -14,7 +14,7 @@ deps =
commands =
{envbindir}/py.test {posargs}
- {toxinidir}/flake8-run.sh
+ flake8 {toxinidir}
[testenv:doc]
changedir = doc
From e8ddd0725eefac13f4dc9768418db8edb9fce310 Mon Sep 17 00:00:00 2001
From: John Vandenberg
Date: Wed, 8 Nov 2017 11:22:33 +0700
Subject: [PATCH 120/223] Add AppVeyor build control file
---
.appveyor.yml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 .appveyor.yml
diff --git a/.appveyor.yml b/.appveyor.yml
new file mode 100644
index 00000000..9284c913
--- /dev/null
+++ b/.appveyor.yml
@@ -0,0 +1,16 @@
+# To activate, change the Appveyor settings to use `.appveyor.yml`.
+init:
+ - SET PATH=C:\\Python27\\Scripts\\;%PATH%"
+
+install:
+ - git submodule update --init --recursive
+ - python -m pip install tox
+
+build: off
+
+test_script:
+ # Avoid py35-optional, as pypi does not have lxml wheels for py35
+ - python -m tox -e "py35-base,{py27,py33,py34}-{base,optional}"
+
+after_test:
+ - python debug-info.py
From 2afc3ad5f023fa7f36cadf5fe928ebd288baf9bc Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Tue, 21 Nov 2017 11:08:51 -0500
Subject: [PATCH 121/223] Fail hard with tracebacks if pytest-expect isn't
working (#360)
Fixes #329
---
html5lib/tests/conftest.py | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/html5lib/tests/conftest.py b/html5lib/tests/conftest.py
index ce93eff6..dad167c5 100644
--- a/html5lib/tests/conftest.py
+++ b/html5lib/tests/conftest.py
@@ -1,4 +1,6 @@
+from __future__ import print_function
import os.path
+import sys
import pkg_resources
import pytest
@@ -15,6 +17,26 @@
_sanitizer_testdata = os.path.join(_dir, "sanitizer-testdata")
+def fail_if_missing_pytest_expect():
+ """Throws an exception halting pytest if pytest-expect isn't working"""
+ try:
+ from pytest_expect import expect # noqa
+ except ImportError:
+ header = '*' * 78
+ print(
+ '\n' +
+ header + '\n' +
+ 'ERROR: Either pytest-expect or its dependency u-msgpack-python is not\n' +
+ 'installed. Please install them both before running pytest.\n' +
+ header + '\n',
+ file=sys.stderr
+ )
+ raise
+
+
+fail_if_missing_pytest_expect()
+
+
def pytest_configure(config):
msgs = []
From 6f8320e2a97bb2f05d0f5cca1f6073c44c96d9a4 Mon Sep 17 00:00:00 2001
From: Hugo
Date: Wed, 22 Nov 2017 16:30:52 +0200
Subject: [PATCH 122/223] Remove redundant <=2.6 code (#362)
---
html5lib/_utils.py | 5 +----
html5lib/html5parser.py | 7 ++-----
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/html5lib/_utils.py b/html5lib/_utils.py
index 03f0dab7..91252f2c 100644
--- a/html5lib/_utils.py
+++ b/html5lib/_utils.py
@@ -1,6 +1,5 @@
from __future__ import absolute_import, division, unicode_literals
-import sys
from types import ModuleType
from six import text_type
@@ -13,11 +12,9 @@
__all__ = ["default_etree", "MethodDispatcher", "isSurrogatePair",
"surrogatePairToCodepoint", "moduleFactoryFactory",
- "supports_lone_surrogates", "PY27"]
+ "supports_lone_surrogates"]
-PY27 = sys.version_info[0] == 2 and sys.version_info[1] >= 7
-
# Platforms not supporting lone surrogates (\uD800-\uDFFF) should be
# caught by the below test. In general this would be any platform
# using UTF-16 as its encoding of unicode strings, such as
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index f8309e14..dd8ba6f7 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -1,5 +1,5 @@
from __future__ import absolute_import, division, unicode_literals
-from six import with_metaclass, viewkeys, PY3
+from six import with_metaclass, viewkeys
import types
from collections import OrderedDict
@@ -2707,10 +2707,7 @@ def processEndTag(self, token):
def adjust_attributes(token, replacements):
- if PY3 or _utils.PY27:
- needs_adjustment = viewkeys(token['data']) & viewkeys(replacements)
- else:
- needs_adjustment = frozenset(token['data']) & frozenset(replacements)
+ needs_adjustment = viewkeys(token['data']) & viewkeys(replacements)
if needs_adjustment:
token['data'] = OrderedDict((replacements.get(k, k), v)
for k, v in token['data'].items())
From 7d279c518efa47ac36c62b484a64f80484efddfb Mon Sep 17 00:00:00 2001
From: John Vandenberg
Date: Thu, 23 Nov 2017 22:51:09 +0700
Subject: [PATCH 123/223] .appveyor.yml: Add Python 3.5 and 3.6 environments
(#363)
The Python 3.5 and 3.6 builds pass without problems.
---
.appveyor.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.appveyor.yml b/.appveyor.yml
index 9284c913..5eff3c1f 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -9,8 +9,7 @@ install:
build: off
test_script:
- # Avoid py35-optional, as pypi does not have lxml wheels for py35
- - python -m tox -e "py35-base,{py27,py33,py34}-{base,optional}"
+ - python -m tox -e "{py27,py33,py34,py35,py36}-{base,optional}"
after_test:
- python debug-info.py
From 208cff8d512281fbd25dac1a6a97bcbbf47eadcd Mon Sep 17 00:00:00 2001
From: John Vandenberg
Date: Fri, 24 Nov 2017 19:02:25 +0700
Subject: [PATCH 124/223] Split AppVeyor build into 10 jobs (#365)
The AppVeyor build running all tox environments in
a single job takes a long time to report any status,
and the log is difficult to load.
---
.appveyor.yml | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/.appveyor.yml b/.appveyor.yml
index 5eff3c1f..cbc93200 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -1,6 +1,18 @@
# To activate, change the Appveyor settings to use `.appveyor.yml`.
-init:
- - SET PATH=C:\\Python27\\Scripts\\;%PATH%"
+environment:
+ global:
+ PATH: "C:\\Python27\\Scripts\\;%PATH%"
+ matrix:
+ - TOXENV: py27-base
+ - TOXENV: py27-optional
+ - TOXENV: py33-base
+ - TOXENV: py33-optional
+ - TOXENV: py34-base
+ - TOXENV: py34-optional
+ - TOXENV: py35-base
+ - TOXENV: py35-optional
+ - TOXENV: py36-base
+ - TOXENV: py36-optional
install:
- git submodule update --init --recursive
@@ -9,7 +21,7 @@ install:
build: off
test_script:
- - python -m tox -e "{py27,py33,py34,py35,py36}-{base,optional}"
+ - tox
after_test:
- python debug-info.py
From 32713a572324414a8692c8342eaa67f8b6f947d0 Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Tue, 28 Nov 2017 17:30:48 -0500
Subject: [PATCH 125/223] Document exceptions in constants module (#369)
---
html5lib/constants.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/html5lib/constants.py b/html5lib/constants.py
index 4f967cb6..c0db14f1 100644
--- a/html5lib/constants.py
+++ b/html5lib/constants.py
@@ -2939,6 +2939,7 @@
class DataLossWarning(UserWarning):
+ """Raised when the current tree is unable to represent the input data"""
pass
From b5137bc30bcb708aa462b00bf49e232bc947c09f Mon Sep 17 00:00:00 2001
From: John Vandenberg
Date: Thu, 23 Nov 2017 22:22:48 +0700
Subject: [PATCH 126/223] Fix codecov data submission
The use of `coverage combine` without multiple sets
of data has been resulting in a warning `No data to combine`
and the data not being submitted.
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 07fdff6f..0e05ab04 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,4 +28,4 @@ after_script:
- python debug-info.py
after_success:
- - if [[ $TRAVIS_PYTHON_VERSION != pypy* ]]; then coverage combine && codecov; fi
+ - if [[ $TRAVIS_PYTHON_VERSION != pypy* ]]; then codecov; fi
From 943d8c37ad5217378193d8310f8bd312ed8f41ac Mon Sep 17 00:00:00 2001
From: John Vandenberg
Date: Thu, 23 Nov 2017 11:59:03 +0700
Subject: [PATCH 127/223] Collect PyPy and AppVeyor coverage using tox
Coverage of PyPy was disabled however it works
without trouble, albeit a little slow.
To allow tox to run tests under coverage,
and with arguments passed to coverage,
PYTEST_COMMAND can now be used to override
the default command used to run the tests.
Due to pips inability to deal with multiple
requirements for the same package, six==1.9 is
forcably installed after the tox environment
has been setup.
---
.appveyor.yml | 6 +++++-
.travis.yml | 17 +++++++++--------
requirements-test.txt | 4 ++++
tox.ini | 18 ++++++++++--------
4 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/.appveyor.yml b/.appveyor.yml
index cbc93200..984e2b7f 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -2,6 +2,7 @@
environment:
global:
PATH: "C:\\Python27\\Scripts\\;%PATH%"
+ PYTEST_COMMAND: "coverage run -m pytest"
matrix:
- TOXENV: py27-base
- TOXENV: py27-optional
@@ -16,7 +17,7 @@ environment:
install:
- git submodule update --init --recursive
- - python -m pip install tox
+ - python -m pip install tox codecov
build: off
@@ -25,3 +26,6 @@ test_script:
after_test:
- python debug-info.py
+
+on_success:
+ - codecov
diff --git a/.travis.yml b/.travis.yml
index 0e05ab04..c2e65375 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,20 +12,21 @@ sudo: false
cache: pip
env:
- - USE_OPTIONAL=true
- - USE_OPTIONAL=false
- - SIX_VERSION=1.9 USE_OPTIONAL=true
+ global:
+ - PYTEST_COMMAND="coverage run -m pytest"
+ matrix:
+ - TOXENV=optional
+ - TOXENV=base
+ - TOXENV=six19-optional
install:
- - ./requirements-install.sh
+ - pip install tox codecov
script:
- - if [[ $TRAVIS_PYTHON_VERSION == pypy* ]]; then py.test; fi
- - if [[ $TRAVIS_PYTHON_VERSION != pypy* ]]; then coverage run -m pytest; fi
- - bash flake8-run.sh
+ - tox
after_script:
- python debug-info.py
after_success:
- - if [[ $TRAVIS_PYTHON_VERSION != pypy* ]]; then codecov; fi
+ - codecov
diff --git a/requirements-test.txt b/requirements-test.txt
index 40df78d4..59513431 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,6 +1,10 @@
-r requirements.txt
+tox
+
flake8<3.0
+
pytest
+coverage
pytest-expect>=1.1,<2.0
mock
diff --git a/tox.ini b/tox.ini
index 42492fb7..e07ef670 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,21 +1,23 @@
[tox]
-envlist = {py27,py33,py34,py35,py36,pypy}-{base,optional}
+envlist = {py27,py33,py34,py35,py36,pypy}-{base,six19,optional}
[testenv]
deps =
- flake8<3.0
- pytest
- pytest-expect>=1.1,<2.0
- mock
- base: six
- base: webencodings
optional: -r{toxinidir}/requirements-optional.txt
+ -r{toxinidir}/requirements-test.txt
doc: Sphinx
+passenv =
+ PYTEST_COMMAND
+ COVERAGE_RUN_OPTIONS
commands =
- {envbindir}/py.test {posargs}
+ six19: pip install six==1.9
+ {env:PYTEST_COMMAND:{envbindir}/py.test} {posargs}
flake8 {toxinidir}
[testenv:doc]
changedir = doc
commands = sphinx-build -b html . _build
+
+[flake8]
+exclude = ./.tox
From e17cf26c1c36befdce7da39aed1ead96fd0ad30e Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Tue, 28 Nov 2017 19:20:46 -0500
Subject: [PATCH 128/223] Pin pytest to a version that doesn't require six
---
requirements-test.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/requirements-test.txt b/requirements-test.txt
index 59513431..4e223a3f 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -4,7 +4,7 @@ tox
flake8<3.0
-pytest
+pytest==3.2.5
coverage
pytest-expect>=1.1,<2.0
mock
From b105f6e5ca3314cca7e46dc79d3f732cdc0f81e1 Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Wed, 29 Nov 2017 07:00:26 -0500
Subject: [PATCH 129/223] Remove html5lib/tests/README file (#366)
This file wasn't informative enough beyond existing documentation. Best
to remove it.
---
html5lib/tests/README | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 html5lib/tests/README
diff --git a/html5lib/tests/README b/html5lib/tests/README
deleted file mode 100644
index c564b683..00000000
--- a/html5lib/tests/README
+++ /dev/null
@@ -1 +0,0 @@
-Each testcase file can be run through nose (using ``nosetests``).
\ No newline at end of file
From 876ff02e6a4b968c97a0efa990a13900bd1d127a Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Wed, 29 Nov 2017 09:50:54 -0500
Subject: [PATCH 130/223] Make ReparseException private
ReparseException is used internally and not intended for external use.
Fixes #371
---
html5lib/_inputstream.py | 4 ++--
html5lib/constants.py | 2 +-
html5lib/html5parser.py | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py
index 79f2331e..c60d1a47 100644
--- a/html5lib/_inputstream.py
+++ b/html5lib/_inputstream.py
@@ -9,7 +9,7 @@
import webencodings
from .constants import EOF, spaceCharacters, asciiLetters, asciiUppercase
-from .constants import ReparseException
+from .constants import _ReparseException
from . import _utils
from io import StringIO
@@ -530,7 +530,7 @@ def changeEncoding(self, newEncoding):
self.rawStream.seek(0)
self.charEncoding = (newEncoding, "certain")
self.reset()
- raise ReparseException("Encoding changed from %s to %s" % (self.charEncoding[0], newEncoding))
+ raise _ReparseException("Encoding changed from %s to %s" % (self.charEncoding[0], newEncoding))
def detectBOM(self):
"""Attempts to detect at BOM at the start of the stream. If
diff --git a/html5lib/constants.py b/html5lib/constants.py
index c0db14f1..1ff80419 100644
--- a/html5lib/constants.py
+++ b/html5lib/constants.py
@@ -2943,5 +2943,5 @@ class DataLossWarning(UserWarning):
pass
-class ReparseException(Exception):
+class _ReparseException(Exception):
pass
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index dd8ba6f7..75765924 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -20,7 +20,7 @@
adjustForeignAttributes as adjustForeignAttributesMap,
adjustMathMLAttributes, adjustSVGAttributes,
E,
- ReparseException
+ _ReparseException
)
@@ -83,7 +83,7 @@ def _parse(self, stream, innerHTML=False, container="div", scripting=False, **kw
try:
self.mainLoop()
- except ReparseException:
+ except _ReparseException:
self.reset()
self.mainLoop()
From d3de97279d906c68bf82f6a827cd29cc8248e03b Mon Sep 17 00:00:00 2001
From: Hugo
Date: Thu, 30 Nov 2017 17:53:44 +0200
Subject: [PATCH 131/223] Ignore PyCharm IDE metadata
---
.gitignore | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.gitignore b/.gitignore
index 6aed95b2..ecd62df3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -80,3 +80,6 @@ target/
# Generated by parse.py -p
stats.prof
+
+# IDE
+.idea
From 48fb9e1db4dffcb3b3a801ae80eed8a9676ba749 Mon Sep 17 00:00:00 2001
From: Hugo
Date: Thu, 30 Nov 2017 18:00:54 +0200
Subject: [PATCH 132/223] Passing test for lowercase and failing test for
uppercase
---
html5lib/tests/test_sanitizer.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/html5lib/tests/test_sanitizer.py b/html5lib/tests/test_sanitizer.py
index e19deea8..45046d57 100644
--- a/html5lib/tests/test_sanitizer.py
+++ b/html5lib/tests/test_sanitizer.py
@@ -113,3 +113,15 @@ def test_sanitizer():
yield (runSanitizerTest, "test_should_allow_uppercase_%s_uris" % protocol,
"foo" % (protocol, rest_of_uri),
"""foo""" % (protocol, rest_of_uri))
+
+
+def test_lowercase_color_codes_in_style():
+ sanitized = sanitize_html("")
+ expected = ''
+ assert expected == sanitized
+
+
+def test_uppercase_color_codes_in_style():
+ sanitized = sanitize_html("")
+ expected = ''
+ assert expected == sanitized
From a5a19007cdd951396bd769f1bac937de99b10f30 Mon Sep 17 00:00:00 2001
From: Hugo
Date: Thu, 30 Nov 2017 18:02:01 +0200
Subject: [PATCH 133/223] Allow uppercase hex chararcters in CSS colour check
---
html5lib/filters/sanitizer.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/filters/sanitizer.py b/html5lib/filters/sanitizer.py
index dc801668..6315a1c5 100644
--- a/html5lib/filters/sanitizer.py
+++ b/html5lib/filters/sanitizer.py
@@ -855,7 +855,7 @@ def sanitize_css(self, style):
'padding']:
for keyword in value.split():
if keyword not in self.allowed_css_keywords and \
- not re.match(r"^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$", keyword): # noqa
+ not re.match(r"^(#[0-9a-fA-F]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$", keyword): # noqa
break
else:
clean.append(prop + ': ' + value + ';')
From 0dcbd6868be6ad1eb48213445a568732a6a98c6a Mon Sep 17 00:00:00 2001
From: Hugo
Date: Thu, 30 Nov 2017 18:23:54 +0200
Subject: [PATCH 134/223] Run slower jobs first so as not to hold up the CI
---
.travis.yml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index c2e65375..5727e094 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,11 @@
language: python
python:
- - "2.7"
- - "3.3"
- - "3.4"
- - "3.5"
- - "3.6"
- "pypy"
+ - "3.6"
+ - "3.5"
+ - "3.4"
+ - "3.3"
+ - "2.7"
sudo: false
From 3e86e49c7d8288468f2c9e68772266960abface2 Mon Sep 17 00:00:00 2001
From: Mark Vasilkov
Date: Thu, 30 Nov 2017 20:22:58 +0300
Subject: [PATCH 135/223] Regexp change for future compatibility. Fixes #347
---
html5lib/_inputstream.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py
index c60d1a47..177f0ab9 100644
--- a/html5lib/_inputstream.py
+++ b/html5lib/_inputstream.py
@@ -48,7 +48,7 @@
0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
0x10FFFE, 0x10FFFF])
-ascii_punctuation_re = re.compile("[\u0009-\u000D\u0020-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E]")
+ascii_punctuation_re = re.compile("[\u0009-\u000D\u0020-\u002F\u003A-\u0040\u005C\u005B-\u0060\u007B-\u007E]")
# Cache for charsUntil()
charsUntilRegEx = {}
From 6b13f55b2e5095d96b81858cad5f723ac37c1574 Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Thu, 30 Nov 2017 18:00:23 -0500
Subject: [PATCH 136/223] First pass at docs for html5lib.treeadapters (#380)
---
html5lib/treeadapters/__init__.py | 18 ++++++++++++++++++
html5lib/treeadapters/genshi.py | 7 +++++++
html5lib/treeadapters/sax.py | 8 +++++++-
3 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/html5lib/treeadapters/__init__.py b/html5lib/treeadapters/__init__.py
index 4f978466..dfeb0ba5 100644
--- a/html5lib/treeadapters/__init__.py
+++ b/html5lib/treeadapters/__init__.py
@@ -1,3 +1,21 @@
+"""Tree adapters let you convert from one tree structure to another
+
+Example:
+
+.. code-block:: python
+
+ import html5lib
+ from html5lib.treeadapters import genshi
+
+ doc = 'Hi!'
+ treebuilder = html5lib.getTreeBuilder('etree')
+ parser = html5lib.HTMLParser(tree=treebuilder)
+ tree = parser.parse(doc)
+ TreeWalker = html5lib.getTreeWalker('etree')
+
+ genshi_tree = genshi.to_genshi(TreeWalker(tree))
+
+"""
from __future__ import absolute_import, division, unicode_literals
from . import sax
diff --git a/html5lib/treeadapters/genshi.py b/html5lib/treeadapters/genshi.py
index 04e316df..61d5fb6a 100644
--- a/html5lib/treeadapters/genshi.py
+++ b/html5lib/treeadapters/genshi.py
@@ -5,6 +5,13 @@
def to_genshi(walker):
+ """Convert a tree to a genshi tree
+
+ :arg walker: the treewalker to use to walk the tree to convert it
+
+ :returns: generator of genshi nodes
+
+ """
text = []
for token in walker:
type = token["type"]
diff --git a/html5lib/treeadapters/sax.py b/html5lib/treeadapters/sax.py
index ad47df95..f4ccea5a 100644
--- a/html5lib/treeadapters/sax.py
+++ b/html5lib/treeadapters/sax.py
@@ -11,7 +11,13 @@
def to_sax(walker, handler):
- """Call SAX-like content handler based on treewalker walker"""
+ """Call SAX-like content handler based on treewalker walker
+
+ :arg walker: the treewalker to use to walk the tree to convert it
+
+ :arg handler: SAX handler to use
+
+ """
handler.startDocument()
for prefix, namespace in prefix_mapping.items():
handler.startPrefixMapping(prefix, namespace)
From ed8e017200de349ce29a87546c0989efdfb05e8c Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Thu, 30 Nov 2017 18:02:28 -0500
Subject: [PATCH 137/223] First pass at treebuilder docs (#378)
---
html5lib/treebuilders/__init__.py | 90 ++++++++++++++++-------------
html5lib/treebuilders/base.py | 68 ++++++++++++++++------
html5lib/treebuilders/etree_lxml.py | 1 -
3 files changed, 102 insertions(+), 57 deletions(-)
diff --git a/html5lib/treebuilders/__init__.py b/html5lib/treebuilders/__init__.py
index e2328847..d44447ea 100644
--- a/html5lib/treebuilders/__init__.py
+++ b/html5lib/treebuilders/__init__.py
@@ -1,29 +1,32 @@
-"""A collection of modules for building different kinds of tree from
-HTML documents.
+"""A collection of modules for building different kinds of trees from HTML
+documents.
To create a treebuilder for a new type of tree, you need to do
implement several things:
-1) A set of classes for various types of elements: Document, Doctype,
-Comment, Element. These must implement the interface of
-_base.treebuilders.Node (although comment nodes have a different
-signature for their constructor, see treebuilders.etree.Comment)
-Textual content may also be implemented as another node type, or not, as
-your tree implementation requires.
-
-2) A treebuilder object (called TreeBuilder by convention) that
-inherits from treebuilders._base.TreeBuilder. This has 4 required attributes:
-documentClass - the class to use for the bottommost node of a document
-elementClass - the class to use for HTML Elements
-commentClass - the class to use for comments
-doctypeClass - the class to use for doctypes
-It also has one required method:
-getDocument - Returns the root node of the complete document tree
-
-3) If you wish to run the unit tests, you must also create a
-testSerializer method on your treebuilder which accepts a node and
-returns a string containing Node and its children serialized according
-to the format used in the unittests
+1. A set of classes for various types of elements: Document, Doctype, Comment,
+ Element. These must implement the interface of ``base.treebuilders.Node``
+ (although comment nodes have a different signature for their constructor,
+ see ``treebuilders.etree.Comment``) Textual content may also be implemented
+ as another node type, or not, as your tree implementation requires.
+
+2. A treebuilder object (called ``TreeBuilder`` by convention) that inherits
+ from ``treebuilders.base.TreeBuilder``. This has 4 required attributes:
+
+ * ``documentClass`` - the class to use for the bottommost node of a document
+ * ``elementClass`` - the class to use for HTML Elements
+ * ``commentClass`` - the class to use for comments
+ * ``doctypeClass`` - the class to use for doctypes
+
+ It also has one required method:
+
+ * ``getDocument`` - Returns the root node of the complete document tree
+
+3. If you wish to run the unit tests, you must also create a ``testSerializer``
+ method on your treebuilder which accepts a node and returns a string
+ containing Node and its children serialized according to the format used in
+ the unittests
+
"""
from __future__ import absolute_import, division, unicode_literals
@@ -34,23 +37,32 @@
def getTreeBuilder(treeType, implementation=None, **kwargs):
- """Get a TreeBuilder class for various types of tree with built-in support
-
- treeType - the name of the tree type required (case-insensitive). Supported
- values are:
-
- "dom" - A generic builder for DOM implementations, defaulting to
- a xml.dom.minidom based implementation.
- "etree" - A generic builder for tree implementations exposing an
- ElementTree-like interface, defaulting to
- xml.etree.cElementTree if available and
- xml.etree.ElementTree if not.
- "lxml" - A etree-based builder for lxml.etree, handling
- limitations of lxml's implementation.
-
- implementation - (Currently applies to the "etree" and "dom" tree types). A
- module implementing the tree type e.g.
- xml.etree.ElementTree or xml.etree.cElementTree."""
+ """Get a TreeBuilder class for various types of trees with built-in support
+
+ :arg treeType: the name of the tree type required (case-insensitive). Supported
+ values are:
+
+ * "dom" - A generic builder for DOM implementations, defaulting to a
+ xml.dom.minidom based implementation.
+ * "etree" - A generic builder for tree implementations exposing an
+ ElementTree-like interface, defaulting to xml.etree.cElementTree if
+ available and xml.etree.ElementTree if not.
+ * "lxml" - A etree-based builder for lxml.etree, handling limitations
+ of lxml's implementation.
+
+ :arg implementation: (Currently applies to the "etree" and "dom" tree
+ types). A module implementing the tree type e.g. xml.etree.ElementTree
+ or xml.etree.cElementTree.
+
+ :arg kwargs: Any additional options to pass to the TreeBuilder when
+ creating it.
+
+ Example:
+
+ >>> from html5lib.treebuilders import getTreeBuilder
+ >>> builder = getTreeBuilder('etree')
+
+ """
treeType = treeType.lower()
if treeType not in treeBuilderCache:
diff --git a/html5lib/treebuilders/base.py b/html5lib/treebuilders/base.py
index a4b2792a..05d97ecc 100644
--- a/html5lib/treebuilders/base.py
+++ b/html5lib/treebuilders/base.py
@@ -21,22 +21,25 @@
class Node(object):
+ """Represents an item in the tree"""
def __init__(self, name):
- """Node representing an item in the tree.
- name - The tag name associated with the node
- parent - The parent of the current node (or None for the document node)
- value - The value of the current node (applies to text nodes and
- comments
- attributes - a dict holding name, value pairs for attributes of the node
- childNodes - a list of child nodes of the current node. This must
- include all elements but not necessarily other node types
- _flags - A list of miscellaneous flags that can be set on the node
+ """Creates a Node
+
+ :arg name: The tag name associated with the node
+
"""
+ # The tag name assocaited with the node
self.name = name
+ # The parent of the current node (or None for the document node)
self.parent = None
+ # The value of the current node (applies to text nodes and comments)
self.value = None
+ # A dict holding name -> value pairs for attributes of the node
self.attributes = {}
+ # A list of child nodes of the current node. This must include all
+ # elements but not necessarily other node types.
self.childNodes = []
+ # A list of miscellaneous flags that can be set on the node.
self._flags = []
def __str__(self):
@@ -53,23 +56,41 @@ def __repr__(self):
def appendChild(self, node):
"""Insert node as a child of the current node
+
+ :arg node: the node to insert
+
"""
raise NotImplementedError
def insertText(self, data, insertBefore=None):
"""Insert data as text in the current node, positioned before the
start of node insertBefore or to the end of the node's text.
+
+ :arg data: the data to insert
+
+ :arg insertBefore: True if you want to insert the text before the node
+ and False if you want to insert it after the node
+
"""
raise NotImplementedError
def insertBefore(self, node, refNode):
"""Insert node as a child of the current node, before refNode in the
list of child nodes. Raises ValueError if refNode is not a child of
- the current node"""
+ the current node
+
+ :arg node: the node to insert
+
+ :arg refNode: the child node to insert the node before
+
+ """
raise NotImplementedError
def removeChild(self, node):
"""Remove node from the children of the current node
+
+ :arg node: the child node to remove
+
"""
raise NotImplementedError
@@ -77,6 +98,9 @@ def reparentChildren(self, newParent):
"""Move all the children of the current node to newParent.
This is needed so that trees that don't store text as nodes move the
text in the correct way
+
+ :arg newParent: the node to move all this node's children to
+
"""
# XXX - should this method be made more general?
for child in self.childNodes:
@@ -121,10 +145,12 @@ def nodesEqual(self, node1, node2):
class TreeBuilder(object):
"""Base treebuilder implementation
- documentClass - the class to use for the bottommost node of a document
- elementClass - the class to use for HTML Elements
- commentClass - the class to use for comments
- doctypeClass - the class to use for doctypes
+
+ * documentClass - the class to use for the bottommost node of a document
+ * elementClass - the class to use for HTML Elements
+ * commentClass - the class to use for comments
+ * doctypeClass - the class to use for doctypes
+
"""
# pylint:disable=not-callable
@@ -144,6 +170,11 @@ class TreeBuilder(object):
fragmentClass = None
def __init__(self, namespaceHTMLElements):
+ """Create a TreeBuilder
+
+ :arg namespaceHTMLElements: whether or not to namespace HTML elements
+
+ """
if namespaceHTMLElements:
self.defaultNamespace = "http://www.w3.org/1999/xhtml"
else:
@@ -367,11 +398,11 @@ def generateImpliedEndTags(self, exclude=None):
self.generateImpliedEndTags(exclude)
def getDocument(self):
- "Return the final tree"
+ """Return the final tree"""
return self.document
def getFragment(self):
- "Return the final fragment"
+ """Return the final fragment"""
# assert self.innerHTML
fragment = self.fragmentClass()
self.openElements[0].reparentChildren(fragment)
@@ -379,5 +410,8 @@ def getFragment(self):
def testSerializer(self, node):
"""Serialize the subtree of node in the format required by unit tests
- node - the node from which to start serializing"""
+
+ :arg node: the node from which to start serializing
+
+ """
raise NotImplementedError
diff --git a/html5lib/treebuilders/etree_lxml.py b/html5lib/treebuilders/etree_lxml.py
index 908820c0..ca12a99c 100644
--- a/html5lib/treebuilders/etree_lxml.py
+++ b/html5lib/treebuilders/etree_lxml.py
@@ -309,7 +309,6 @@ def insertCommentMain(self, data, parent=None):
super(TreeBuilder, self).insertComment(data, parent)
def insertRoot(self, token):
- """Create the document root"""
# Because of the way libxml2 works, it doesn't seem to be possible to
# alter information like the doctype after the tree has been parsed.
# Therefore we need to use the built-in parser to create our initial
From 461bda30aa01ec6c861a89a1051f65cb44613535 Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Thu, 30 Nov 2017 18:08:08 -0500
Subject: [PATCH 138/223] First pass at documenting serializer (#376)
---
html5lib/serializer.py | 163 ++++++++++++++++++++++++++++++-----------
1 file changed, 119 insertions(+), 44 deletions(-)
diff --git a/html5lib/serializer.py b/html5lib/serializer.py
index 103dd206..d6b7105d 100644
--- a/html5lib/serializer.py
+++ b/html5lib/serializer.py
@@ -68,10 +68,33 @@ def htmlentityreplace_errors(exc):
else:
return xmlcharrefreplace_errors(exc)
+
register_error("htmlentityreplace", htmlentityreplace_errors)
def serialize(input, tree="etree", encoding=None, **serializer_opts):
+ """Serializes the input token stream using the specified treewalker
+
+ :arg input: the token stream to serialize
+
+ :arg tree: the treewalker to use
+
+ :arg encoding: the encoding to use
+
+ :arg serializer_opts: any options to pass to the
+ :py:class:`html5lib.serializer.HTMLSerializer` that gets created
+
+ :returns: the tree serialized as a string
+
+ Example:
+
+ >>> from html5lib.html5parser import parse
+ >>> from html5lib.serializer import serialize
+ >>> token_stream = parse('
'
+
+ """
# XXX: Should we cache this?
walker = treewalkers.getTreeWalker(tree)
s = HTMLSerializer(**serializer_opts)
@@ -110,50 +133,83 @@ class HTMLSerializer(object):
"strip_whitespace", "sanitize")
def __init__(self, **kwargs):
- """Initialize HTMLSerializer.
-
- Keyword options (default given first unless specified) include:
-
- inject_meta_charset=True|False
- Whether it insert a meta element to define the character set of the
- document.
- quote_attr_values="legacy"|"spec"|"always"
- Whether to quote attribute values that don't require quoting
- per legacy browser behaviour, when required by the standard, or always.
- quote_char=u'"'|u"'"
- Use given quote character for attribute quoting. Default is to
- use double quote unless attribute value contains a double quote,
- in which case single quotes are used instead.
- escape_lt_in_attrs=False|True
- Whether to escape < in attribute values.
- escape_rcdata=False|True
- Whether to escape characters that need to be escaped within normal
- elements within rcdata elements such as style.
- resolve_entities=True|False
- Whether to resolve named character entities that appear in the
- source tree. The XML predefined entities < > & " '
- are unaffected by this setting.
- strip_whitespace=False|True
- Whether to remove semantically meaningless whitespace. (This
- compresses all whitespace to a single space except within pre.)
- minimize_boolean_attributes=True|False
- Shortens boolean attributes to give just the attribute value,
- for example becomes .
- use_trailing_solidus=False|True
- Includes a close-tag slash at the end of the start tag of void
- elements (empty elements whose end tag is forbidden). E.g. .
- space_before_trailing_solidus=True|False
- Places a space immediately before the closing slash in a tag
- using a trailing solidus. E.g. . Requires use_trailing_solidus.
- sanitize=False|True
- Strip all unsafe or unknown constructs from output.
- See `html5lib user documentation`_
- omit_optional_tags=True|False
- Omit start/end tags that are optional.
- alphabetical_attributes=False|True
- Reorder attributes to be in alphabetical order.
-
- .. _html5lib user documentation: http://code.google.com/p/html5lib/wiki/UserDocumentation
+ """Initialize HTMLSerializer
+
+ :arg inject_meta_charset: Whether or not to inject the meta charset.
+
+ Defaults to ``True``.
+
+ :arg quote_attr_values: Whether to quote attribute values that don't
+ require quoting per legacy browser behavior (``"legacy"``), when
+ required by the standard (``"spec"``), or always (``"always"``).
+
+ Defaults to ``"legacy"``.
+
+ :arg quote_char: Use given quote character for attribute quoting.
+
+ Defaults to ``"`` which will use double quotes unless attribute
+ value contains a double quote, in which case single quotes are
+ used.
+
+ :arg escape_lt_in_attrs: Whether or not to escape ``<`` in attribute
+ values.
+
+ Defaults to ``False``.
+
+ :arg escape_rcdata: Whether to escape characters that need to be
+ escaped within normal elements within rcdata elements such as
+ style.
+
+ Defaults to ``False``.
+
+ :arg resolve_entities: Whether to resolve named character entities that
+ appear in the source tree. The XML predefined entities < >
+ & " ' are unaffected by this setting.
+
+ Defaults to ``True``.
+
+ :arg strip_whitespace: Whether to remove semantically meaningless
+ whitespace. (This compresses all whitespace to a single space
+ except within ``pre``.)
+
+ Defaults to ``False``.
+
+ :arg minimize_boolean_attributes: Shortens boolean attributes to give
+ just the attribute value, for example::
+
+
+
+ becomes::
+
+
+
+ Defaults to ``True``.
+
+ :arg use_trailing_solidus: Includes a close-tag slash at the end of the
+ start tag of void elements (empty elements whose end tag is
+ forbidden). E.g. ````.
+
+ Defaults to ``False``.
+
+ :arg space_before_trailing_solidus: Places a space immediately before
+ the closing slash in a tag using a trailing solidus. E.g.
+ ````. Requires ``use_trailing_solidus=True``.
+
+ Defaults to ``True``.
+
+ :arg sanitize: Strip all unsafe or unknown constructs from output.
+ See :py:class:`html5lib.filters.sanitizer.Filter`.
+
+ Defaults to ``False``.
+
+ :arg omit_optional_tags: Omit start/end tags that are optional.
+
+ Defaults to ``True``.
+
+ :arg alphabetical_attributes: Reorder attributes to be in alphabetical order.
+
+ Defaults to ``False``.
+
"""
unexpected_args = frozenset(kwargs) - frozenset(self.options)
if len(unexpected_args) > 0:
@@ -317,6 +373,25 @@ def serialize(self, treewalker, encoding=None):
self.serializeError(token["data"])
def render(self, treewalker, encoding=None):
+ """Serializes the stream from the treewalker into a string
+
+ :arg treewalker: the treewalker to serialize
+
+ :arg encoding: the string encoding to use
+
+ :returns: the serialized tree
+
+ Example:
+
+ >>> from html5lib import parse, getTreeWalker
+ >>> from html5lib.serializer import HTMLSerializer
+ >>> token_stream = parse('Hi!')
+ >>> walker = getTreeWalker('etree')
+ >>> serializer = HTMLSerializer(omit_optional_tags=False)
+ >>> serializer.render(walker(token_stream))
+ 'Hi!'
+
+ """
if encoding:
return b"".join(list(self.serialize(treewalker, encoding)))
else:
From 21a6820957e677f24684ec84cddfecf1d541b11d Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Wed, 29 Nov 2017 14:39:01 -0500
Subject: [PATCH 139/223] Remove undoc-members and add documentation for
__init__
The public API should all be documented. Anything that isn't documented with a
docstring or starts with a _ isn't part of the public API. Given that, we
shouldn't be autodoc'ing undocumented members.
We do want to document __init__ since that's how the classes get built. So
we explicitly add that to autodoc.
I think this is a good base to build on. If it isn't, we can adjust things
and maybe explicitly specify what should and shouldn't be documented.
---
doc/html5lib.filters.rst | 15 +++++++--------
doc/html5lib.rst | 6 ++----
doc/html5lib.treeadapters.rst | 8 ++++----
doc/html5lib.treebuilders.rst | 11 +++++------
doc/html5lib.treewalkers.rst | 13 ++++++-------
5 files changed, 24 insertions(+), 29 deletions(-)
diff --git a/doc/html5lib.filters.rst b/doc/html5lib.filters.rst
index 38d4a956..d70e4552 100644
--- a/doc/html5lib.filters.rst
+++ b/doc/html5lib.filters.rst
@@ -6,54 +6,53 @@ filters Package
.. automodule:: html5lib.filters.base
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`alphabeticalattributes` Module
------------------------------------
.. automodule:: html5lib.filters.alphabeticalattributes
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`inject_meta_charset` Module
---------------------------------
.. automodule:: html5lib.filters.inject_meta_charset
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`lint` Module
------------------
.. automodule:: html5lib.filters.lint
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`optionaltags` Module
--------------------------
.. automodule:: html5lib.filters.optionaltags
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`sanitizer` Module
-----------------------
.. automodule:: html5lib.filters.sanitizer
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`whitespace` Module
------------------------
.. automodule:: html5lib.filters.whitespace
:members:
- :undoc-members:
:show-inheritance:
-
+ :special-members: __init__
diff --git a/doc/html5lib.rst b/doc/html5lib.rst
index 2a0b150f..d7c75c58 100644
--- a/doc/html5lib.rst
+++ b/doc/html5lib.rst
@@ -9,7 +9,6 @@ html5lib Package
.. automodule:: html5lib.constants
:members:
- :undoc-members:
:show-inheritance:
:mod:`html5parser` Module
@@ -17,16 +16,16 @@ html5lib Package
.. automodule:: html5lib.html5parser
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`serializer` Module
------------------------
.. automodule:: html5lib.serializer
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
Subpackages
-----------
@@ -37,4 +36,3 @@ Subpackages
html5lib.treebuilders
html5lib.treewalkers
html5lib.treeadapters
-
diff --git a/doc/html5lib.treeadapters.rst b/doc/html5lib.treeadapters.rst
index 6b2dc78d..1d3a9fba 100644
--- a/doc/html5lib.treeadapters.rst
+++ b/doc/html5lib.treeadapters.rst
@@ -1,4 +1,4 @@
-treebuilders Package
+treeadapters Package
====================
:mod:`~html5lib.treeadapters` Package
@@ -6,15 +6,15 @@ treebuilders Package
.. automodule:: html5lib.treeadapters
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
.. automodule:: html5lib.treeadapters.genshi
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
.. automodule:: html5lib.treeadapters.sax
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
diff --git a/doc/html5lib.treebuilders.rst b/doc/html5lib.treebuilders.rst
index aee82142..1a051e50 100644
--- a/doc/html5lib.treebuilders.rst
+++ b/doc/html5lib.treebuilders.rst
@@ -6,38 +6,37 @@ treebuilders Package
.. automodule:: html5lib.treebuilders
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`base` Module
-------------------
.. automodule:: html5lib.treebuilders.base
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`dom` Module
-----------------
.. automodule:: html5lib.treebuilders.dom
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`etree` Module
-------------------
.. automodule:: html5lib.treebuilders.etree
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`etree_lxml` Module
------------------------
.. automodule:: html5lib.treebuilders.etree_lxml
:members:
- :undoc-members:
:show-inheritance:
-
+ :special-members: __init__
diff --git a/doc/html5lib.treewalkers.rst b/doc/html5lib.treewalkers.rst
index 085d8a98..4afef476 100644
--- a/doc/html5lib.treewalkers.rst
+++ b/doc/html5lib.treewalkers.rst
@@ -6,46 +6,45 @@ treewalkers Package
.. automodule:: html5lib.treewalkers
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`base` Module
------------------
.. automodule:: html5lib.treewalkers.base
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`dom` Module
-----------------
.. automodule:: html5lib.treewalkers.dom
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`etree` Module
-------------------
.. automodule:: html5lib.treewalkers.etree
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
:mod:`etree_lxml` Module
------------------------
.. automodule:: html5lib.treewalkers.etree_lxml
:members:
- :undoc-members:
:show-inheritance:
-
+ :special-members: __init__
:mod:`genshi` Module
--------------------
.. automodule:: html5lib.treewalkers.genshi
:members:
- :undoc-members:
:show-inheritance:
+ :special-members: __init__
From dc9443d11809db88003ee3b360d078817bf61845 Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Wed, 29 Nov 2017 14:51:04 -0500
Subject: [PATCH 140/223] Remove items from __all__ that aren't in the
namespace
---
html5lib/treewalkers/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/treewalkers/__init__.py b/html5lib/treewalkers/__init__.py
index 9e19a559..402b722e 100644
--- a/html5lib/treewalkers/__init__.py
+++ b/html5lib/treewalkers/__init__.py
@@ -13,7 +13,7 @@
from .. import constants
from .._utils import default_etree
-__all__ = ["getTreeWalker", "pprint", "dom", "etree", "genshi", "etree_lxml"]
+__all__ = ["getTreeWalker", "pprint"]
treeWalkerCache = {}
From 805f272868365ed336a9d707d24120348f68e536 Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Wed, 29 Nov 2017 15:08:19 -0500
Subject: [PATCH 141/223] Document html5parser module
---
html5lib/html5parser.py | 123 ++++++++++++++++++++++++++++++----------
1 file changed, 94 insertions(+), 29 deletions(-)
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 75765924..9d39b9d4 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -25,13 +25,48 @@
def parse(doc, treebuilder="etree", namespaceHTMLElements=True, **kwargs):
- """Parse a string or file-like object into a tree"""
+ """Parse an HTML document as a string or file-like object into a tree
+
+ :arg doc: the document to parse as a string or file-like object
+
+ :arg treebuilder: the treebuilder to use when parsing
+
+ :arg namespaceHTMLElements: whether or not to namespace HTML elements
+
+ :returns: parsed tree
+
+ Example:
+
+ >>> from html5lib.html5parser import parse
+ >>> parse('
This is a doc
')
+
+
+ """
tb = treebuilders.getTreeBuilder(treebuilder)
p = HTMLParser(tb, namespaceHTMLElements=namespaceHTMLElements)
return p.parse(doc, **kwargs)
def parseFragment(doc, container="div", treebuilder="etree", namespaceHTMLElements=True, **kwargs):
+ """Parse an HTML fragment as a string or file-like object into a tree
+
+ :arg doc: the fragment to parse as a string or file-like object
+
+ :arg container: the container context to parse the fragment in
+
+ :arg treebuilder: the treebuilder to use when parsing
+
+ :arg namespaceHTMLElements: whether or not to namespace HTML elements
+
+ :returns: parsed tree
+
+ Example:
+
+ >>> from html5lib.html5libparser import parseFragment
+ >>> parseFragment('this is a fragment')
+
+
+ """
tb = treebuilders.getTreeBuilder(treebuilder)
p = HTMLParser(tb, namespaceHTMLElements=namespaceHTMLElements)
return p.parseFragment(doc, container=container, **kwargs)
@@ -50,16 +85,30 @@ def __new__(meta, classname, bases, classDict):
class HTMLParser(object):
- """HTML parser. Generates a tree structure from a stream of (possibly
- malformed) HTML"""
+ """HTML parser
+
+ Generates a tree structure from a stream of (possibly malformed) HTML.
+
+ """
def __init__(self, tree=None, strict=False, namespaceHTMLElements=True, debug=False):
"""
- strict - raise an exception when a parse error is encountered
+ :arg tree: a treebuilder class controlling the type of tree that will be
+ returned. Built in treebuilders can be accessed through
+ html5lib.treebuilders.getTreeBuilder(treeType)
+
+ :arg strict: raise an exception when a parse error is encountered
+
+ :arg namespaceHTMLElements: whether or not to namespace HTML elements
+
+ :arg debug: whether or not to enable debug mode which logs things
+
+ Example:
+
+ >>> from html5lib.html5parser import HTMLParser
+ >>> parser = HTMLParser() # generates parser with etree builder
+ >>> parser = HTMLParser('lxml', strict=True) # generates parser with lxml builder which is strict
- tree - a treebuilder class controlling the type of tree that will be
- returned. Built in treebuilders can be accessed through
- html5lib.treebuilders.getTreeBuilder(treeType)
"""
# Raise an exception on the first error encountered
@@ -123,9 +172,8 @@ def reset(self):
@property
def documentEncoding(self):
- """The name of the character encoding
- that was used to decode the input stream,
- or :obj:`None` if that is not determined yet.
+ """Name of the character encoding that was used to decode the input stream, or
+ :obj:`None` if that is not determined yet
"""
if not hasattr(self, 'tokenizer'):
@@ -219,14 +267,24 @@ def normalizedTokens(self):
def parse(self, stream, *args, **kwargs):
"""Parse a HTML document into a well-formed tree
- stream - a filelike object or string containing the HTML to be parsed
+ :arg stream: a file-like object or string containing the HTML to be parsed
+
+ The optional encoding parameter must be a string that indicates
+ the encoding. If specified, that encoding will be used,
+ regardless of any BOM or later declaration (such as in a meta
+ element).
+
+ :arg scripting: treat noscript elements as if JavaScript was turned on
- The optional encoding parameter must be a string that indicates
- the encoding. If specified, that encoding will be used,
- regardless of any BOM or later declaration (such as in a meta
- element)
+ :returns: parsed tree
+
+ Example:
+
+ >>> from html5lib.html5parser import HTMLParser
+ >>> parser = HTMLParser()
+ >>> parser.parse('
This is a doc
')
+
- scripting - treat noscript elements as if javascript was turned on
"""
self._parse(stream, False, None, *args, **kwargs)
return self.tree.getDocument()
@@ -234,17 +292,27 @@ def parse(self, stream, *args, **kwargs):
def parseFragment(self, stream, *args, **kwargs):
"""Parse a HTML fragment into a well-formed tree fragment
- container - name of the element we're setting the innerHTML property
- if set to None, default to 'div'
+ :arg container: name of the element we're setting the innerHTML
+ property if set to None, default to 'div'
+
+ :arg stream: a file-like object or string containing the HTML to be parsed
+
+ The optional encoding parameter must be a string that indicates
+ the encoding. If specified, that encoding will be used,
+ regardless of any BOM or later declaration (such as in a meta
+ element)
- stream - a filelike object or string containing the HTML to be parsed
+ :arg scripting: treat noscript elements as if JavaScript was turned on
- The optional encoding parameter must be a string that indicates
- the encoding. If specified, that encoding will be used,
- regardless of any BOM or later declaration (such as in a meta
- element)
+ :returns: parsed tree
+
+ Example:
+
+ >>> from html5lib.html5libparser import HTMLParser
+ >>> parser = HTMLParser()
+ >>> parser.parseFragment('this is a fragment')
+
- scripting - treat noscript elements as if javascript was turned on
"""
self._parse(stream, True, *args, **kwargs)
return self.tree.getFragment()
@@ -258,8 +326,7 @@ def parseError(self, errorcode="XXX-undefined-error", datavars=None):
raise ParseError(E[errorcode] % datavars)
def normalizeToken(self, token):
- """ HTML5 specific normalizations to the token stream """
-
+ # HTML5 specific normalizations to the token stream
if token["type"] == tokenTypes["StartTag"]:
raw = token["data"]
token["data"] = OrderedDict(raw)
@@ -327,9 +394,7 @@ def resetInsertionMode(self):
self.phase = new_phase
def parseRCDataRawtext(self, token, contentType):
- """Generic RCDATA/RAWTEXT Parsing algorithm
- contentType - RCDATA or RAWTEXT
- """
+ # Generic RCDATA/RAWTEXT Parsing algorithm
assert contentType in ("RAWTEXT", "RCDATA")
self.tree.insertElement(token)
From e8f93e9bfeab9016889b05e77eb141a8cce90196 Mon Sep 17 00:00:00 2001
From: Hugo
Date: Sun, 3 Dec 2017 18:52:08 +0200
Subject: [PATCH 142/223] Via: git log --format="%aN" --reverse | perl -e 'my
%dedupe; while () { print unless {1}++}'
---
AUTHORS.rst | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/AUTHORS.rst b/AUTHORS.rst
index af0a7a65..fc635dea 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -6,6 +6,7 @@ Credits
- James Graham
- Geoffrey Sneddon
- Åukasz Langa
+- Will Kahn-Greene
Patches and suggestions
@@ -23,26 +24,43 @@ Patches and suggestions
- Philip Taylor
- Edward Z. Yang
- fantasai
-- Mike West
- Philip Jägenstedt
- Ms2ger
- Mohammad Taha Jahangir
- Andy Wingo
-- Juan Carlos Garcia Segovia
- Andreas Madsack
- Karim Valiev
+- Juan Carlos Garcia Segovia
+- Mike West
- Marc DM
+- Simon Sapin
+- Michael[tm] Smith
- Ritwik Gupta
+- Marc Abramowitz
- Tony Lopes
- lilbludevil
-- Simon Sapin
-- Jon Dufresne
+- Kevin
- Drew Hubl
- Austin Kumbera
- Jim Baker
-- Michael[tm] Smith
-- Marc Abramowitz
- Jon Dufresne
-- Ville Skyttä
+- Donald Stufft
+- Alex Gaynor
+- Nik Nyby
+- Jakub Wilk
+- Sigmund Cherem
+- Gabi Davar
+- Florian Mounier
+- neumond
+- Vitalik Verhovodov
+- Kovid Goyal
+- Adam Chainz
+- John Vandenberg
+- Eric Amorde
+- Benedikt Morbach
- Jonathan Vanasco
- Tom Most
+- Ville Skyttä
+- Hugo van Kemenade
+- Mark Vasilkov
+
From f7708c43f86c6e912dd29f3d77bd17bc76695d51 Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Sun, 3 Dec 2017 17:29:55 -0500
Subject: [PATCH 143/223] First pass at documenting html5lib.filters (#375)
---
html5lib/filters/alphabeticalattributes.py | 1 +
html5lib/filters/inject_meta_charset.py | 8 ++++
html5lib/filters/lint.py | 12 ++++++
html5lib/filters/optionaltags.py | 1 +
html5lib/filters/sanitizer.py | 43 +++++++++++++++++++---
html5lib/filters/whitespace.py | 2 +-
6 files changed, 60 insertions(+), 7 deletions(-)
diff --git a/html5lib/filters/alphabeticalattributes.py b/html5lib/filters/alphabeticalattributes.py
index 5fea9f69..5ba926e3 100644
--- a/html5lib/filters/alphabeticalattributes.py
+++ b/html5lib/filters/alphabeticalattributes.py
@@ -17,6 +17,7 @@ def _attr_key(attr):
class Filter(base.Filter):
+ """Alphabetizes attributes for elements"""
def __iter__(self):
for token in base.Filter.__iter__(self):
if token["type"] in ("StartTag", "EmptyTag"):
diff --git a/html5lib/filters/inject_meta_charset.py b/html5lib/filters/inject_meta_charset.py
index 2059ec86..aefb5c84 100644
--- a/html5lib/filters/inject_meta_charset.py
+++ b/html5lib/filters/inject_meta_charset.py
@@ -4,7 +4,15 @@
class Filter(base.Filter):
+ """Injects ```` tag into head of document"""
def __init__(self, source, encoding):
+ """Creates a Filter
+
+ :arg source: the source token stream
+
+ :arg encoding: the encoding to set
+
+ """
base.Filter.__init__(self, source)
self.encoding = encoding
diff --git a/html5lib/filters/lint.py b/html5lib/filters/lint.py
index a9c0831a..acd4d7a2 100644
--- a/html5lib/filters/lint.py
+++ b/html5lib/filters/lint.py
@@ -10,7 +10,19 @@
class Filter(base.Filter):
+ """Lints the token stream for errors
+
+ If it finds any errors, it'll raise an ``AssertionError``.
+
+ """
def __init__(self, source, require_matching_tags=True):
+ """Creates a Filter
+
+ :arg source: the source token stream
+
+ :arg require_matching_tags: whether or not to require matching tags
+
+ """
super(Filter, self).__init__(source)
self.require_matching_tags = require_matching_tags
diff --git a/html5lib/filters/optionaltags.py b/html5lib/filters/optionaltags.py
index f6edb734..4a865012 100644
--- a/html5lib/filters/optionaltags.py
+++ b/html5lib/filters/optionaltags.py
@@ -4,6 +4,7 @@
class Filter(base.Filter):
+ """Removes optional tags from the token stream"""
def slider(self):
previous1 = previous2 = None
for token in self.source:
diff --git a/html5lib/filters/sanitizer.py b/html5lib/filters/sanitizer.py
index 6315a1c5..e852f53b 100644
--- a/html5lib/filters/sanitizer.py
+++ b/html5lib/filters/sanitizer.py
@@ -705,7 +705,7 @@
class Filter(base.Filter):
- """ sanitization of XHTML+MathML+SVG and of inline style attributes."""
+ """Sanitizes token stream of XHTML+MathML+SVG and of inline style attributes"""
def __init__(self,
source,
allowed_elements=allowed_elements,
@@ -718,6 +718,37 @@ def __init__(self,
attr_val_is_uri=attr_val_is_uri,
svg_attr_val_allows_ref=svg_attr_val_allows_ref,
svg_allow_local_href=svg_allow_local_href):
+ """Creates a Filter
+
+ :arg allowed_elements: set of elements to allow--everything else will
+ be escaped
+
+ :arg allowed_attributes: set of attributes to allow in
+ elements--everything else will be stripped
+
+ :arg allowed_css_properties: set of CSS properties to allow--everything
+ else will be stripped
+
+ :arg allowed_css_keywords: set of CSS keywords to allow--everything
+ else will be stripped
+
+ :arg allowed_svg_properties: set of SVG properties to allow--everything
+ else will be removed
+
+ :arg allowed_protocols: set of allowed protocols for URIs
+
+ :arg allowed_content_types: set of allowed content types for ``data`` URIs.
+
+ :arg attr_val_is_uri: set of attributes that have URI values--values
+ that have a scheme not listed in ``allowed_protocols`` are removed
+
+ :arg svg_attr_val_allows_ref: set of SVG attributes that can have
+ references
+
+ :arg svg_allow_local_href: set of SVG elements that can have local
+ hrefs--these are removed
+
+ """
super(Filter, self).__init__(source)
self.allowed_elements = allowed_elements
self.allowed_attributes = allowed_attributes
@@ -737,11 +768,11 @@ def __iter__(self):
yield token
# Sanitize the +html+, escaping all elements not in ALLOWED_ELEMENTS, and
- # stripping out all # attributes not in ALLOWED_ATTRIBUTES. Style
- # attributes are parsed, and a restricted set, # specified by
- # ALLOWED_CSS_PROPERTIES and ALLOWED_CSS_KEYWORDS, are allowed through.
- # attributes in ATTR_VAL_IS_URI are scanned, and only URI schemes specified
- # in ALLOWED_PROTOCOLS are allowed.
+ # stripping out all attributes not in ALLOWED_ATTRIBUTES. Style attributes
+ # are parsed, and a restricted set, specified by ALLOWED_CSS_PROPERTIES and
+ # ALLOWED_CSS_KEYWORDS, are allowed through. attributes in ATTR_VAL_IS_URI
+ # are scanned, and only URI schemes specified in ALLOWED_PROTOCOLS are
+ # allowed.
#
# sanitize_html('')
# => <script> do_nasty_stuff() </script>
diff --git a/html5lib/filters/whitespace.py b/html5lib/filters/whitespace.py
index 89210528..0d12584b 100644
--- a/html5lib/filters/whitespace.py
+++ b/html5lib/filters/whitespace.py
@@ -10,7 +10,7 @@
class Filter(base.Filter):
-
+ """Collapses whitespace except in pre, textarea, and script elements"""
spacePreserveElements = frozenset(["pre", "textarea"] + list(rcdataElements))
def __iter__(self):
From 6263ec1a21d3419e15407286ec95105ed9da70f8 Mon Sep 17 00:00:00 2001
From: hugovk
Date: Mon, 4 Dec 2017 23:43:46 +0200
Subject: [PATCH 144/223] Update changes since last release
---
CHANGES.rst | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 8690d749..fc0671a5 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,9 +4,37 @@ Change Log
unreleased
~~~~~~~~~~~~~~~~~~
-* Added the seamless attribute for iframes.
-* Added `itemscope` as boolean attribute
- https://github.com/html5lib/html5lib-python/issues/194
+Breaking changes:
+
+* Drop support for Python 2.6. (#330) (Thank you, Hugo, Will Kahn-Greene!)
+* Remove ``utils/spider.py`` (#353) (Thank you, Jon Dufresne!)
+
+Features:
+
+* Improve documentation. (#300, #307) (Thank you, Jon Dufresne, Tom Most,
+ Will Kahn-Greene!)
+* Add iframe seamless boolean attribute. (Thank you, Ritwik Gupta!)
+* Add itemscope as a boolean attribute. (#194) (Thank you, Jonathan Vanasco!)
+* Support Python 3.6. (#333) (Thank you, Jon Dufresne!)
+* Add CI support for Windows using AppVeyor. (Thank you, John Vandenberg!)
+* Improve testing and CI and add code coverage (#323, #334), (Thank you, Jon
+ Dufresne, John Vandenberg, Geoffrey Sneddon, Will Kahn-Greene!)
+* Semver-compliant version number.
+
+Bug fixes:
+
+* Add support for setuptools < 18.5 to support environment markers. (Thank you,
+ John Vandenberg!)
+* Add explicit dependency for six >= 1.9. (Thank you, Eric Amorde!)
+* Fix regexes to work with Python 3.7 regex adjustments. (#318, #379) (Thank
+ you, Benedikt Morbach, Ville Skyttä, Mark Vasilkov!)
+* Fix alphabeticalattributes filter namespace bug. (#324) (Thank you, Will
+ Kahn-Greene!)
+* Include license file in generated wheel package. (#350) (Thank you, Jon
+ Dufresne!)
+* Fix annotation-xml typo. (#339) (Thank you, Will Kahn-Greene!)
+* Allow uppercase hex chararcters in CSS colour check. (#377) (Thank you,
+ Komal Dembla, Hugo!)
0.999999999/1.0b10
~~~~~~~~~~~~~~~~~~
From 0f1994b1a2c19a6b835ed1d763defc857080c9ef Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene
Date: Tue, 5 Dec 2017 19:11:26 -0500
Subject: [PATCH 145/223] Document html5lib.treewalkers (#386)
---
html5lib/treewalkers/__init__.py | 41 ++++++++-----
html5lib/treewalkers/base.py | 102 +++++++++++++++++++++++++++++++
2 files changed, 128 insertions(+), 15 deletions(-)
diff --git a/html5lib/treewalkers/__init__.py b/html5lib/treewalkers/__init__.py
index 402b722e..9bec2076 100644
--- a/html5lib/treewalkers/__init__.py
+++ b/html5lib/treewalkers/__init__.py
@@ -21,20 +21,25 @@
def getTreeWalker(treeType, implementation=None, **kwargs):
"""Get a TreeWalker class for various types of tree with built-in support
- Args:
- treeType (str): the name of the tree type required (case-insensitive).
- Supported values are:
-
- - "dom": The xml.dom.minidom DOM implementation
- - "etree": A generic walker for tree implementations exposing an
- elementtree-like interface (known to work with
- ElementTree, cElementTree and lxml.etree).
- - "lxml": Optimized walker for lxml.etree
- - "genshi": a Genshi stream
-
- Implementation: A module implementing the tree type e.g.
- xml.etree.ElementTree or cElementTree (Currently applies to the
- "etree" tree type only).
+ :arg str treeType: the name of the tree type required (case-insensitive).
+ Supported values are:
+
+ * "dom": The xml.dom.minidom DOM implementation
+ * "etree": A generic walker for tree implementations exposing an
+ elementtree-like interface (known to work with ElementTree,
+ cElementTree and lxml.etree).
+ * "lxml": Optimized walker for lxml.etree
+ * "genshi": a Genshi stream
+
+ :arg implementation: A module implementing the tree type e.g.
+ xml.etree.ElementTree or cElementTree (Currently applies to the "etree"
+ tree type only).
+
+ :arg kwargs: keyword arguments passed to the etree walker--for other
+ walkers, this has no effect
+
+ :returns: a TreeWalker class
+
"""
treeType = treeType.lower()
@@ -73,7 +78,13 @@ def concatenateCharacterTokens(tokens):
def pprint(walker):
- """Pretty printer for tree walkers"""
+ """Pretty printer for tree walkers
+
+ Takes a TreeWalker instance and pretty prints the output of walking the tree.
+
+ :arg walker: a TreeWalker instance
+
+ """
output = []
indent = 0
for token in concatenateCharacterTokens(walker):
diff --git a/html5lib/treewalkers/base.py b/html5lib/treewalkers/base.py
index 36e1ba24..80c474c4 100644
--- a/html5lib/treewalkers/base.py
+++ b/html5lib/treewalkers/base.py
@@ -18,16 +18,48 @@
class TreeWalker(object):
+ """Walks a tree yielding tokens
+
+ Tokens are dicts that all have a ``type`` field specifying the type of the
+ token.
+
+ """
def __init__(self, tree):
+ """Creates a TreeWalker
+
+ :arg tree: the tree to walk
+
+ """
self.tree = tree
def __iter__(self):
raise NotImplementedError
def error(self, msg):
+ """Generates an error token with the given message
+
+ :arg msg: the error message
+
+ :returns: SerializeError token
+
+ """
return {"type": "SerializeError", "data": msg}
def emptyTag(self, namespace, name, attrs, hasChildren=False):
+ """Generates an EmptyTag token
+
+ :arg namespace: the namespace of the token--can be ``None``
+
+ :arg name: the name of the element
+
+ :arg attrs: the attributes of the element as a dict
+
+ :arg hasChildren: whether or not to yield a SerializationError because
+ this tag shouldn't have children
+
+ :returns: EmptyTag token
+
+ """
yield {"type": "EmptyTag", "name": name,
"namespace": namespace,
"data": attrs}
@@ -35,17 +67,61 @@ def emptyTag(self, namespace, name, attrs, hasChildren=False):
yield self.error("Void element has children")
def startTag(self, namespace, name, attrs):
+ """Generates a StartTag token
+
+ :arg namespace: the namespace of the token--can be ``None``
+
+ :arg name: the name of the element
+
+ :arg attrs: the attributes of the element as a dict
+
+ :returns: StartTag token
+
+ """
return {"type": "StartTag",
"name": name,
"namespace": namespace,
"data": attrs}
def endTag(self, namespace, name):
+ """Generates an EndTag token
+
+ :arg namespace: the namespace of the token--can be ``None``
+
+ :arg name: the name of the element
+
+ :returns: EndTag token
+
+ """
return {"type": "EndTag",
"name": name,
"namespace": namespace}
def text(self, data):
+ """Generates SpaceCharacters and Characters tokens
+
+ Depending on what's in the data, this generates one or more
+ ``SpaceCharacters`` and ``Characters`` tokens.
+
+ For example:
+
+ >>> from html5lib.treewalkers.base import TreeWalker
+ >>> # Give it an empty tree just so it instantiates
+ >>> walker = TreeWalker([])
+ >>> list(walker.text(''))
+ []
+ >>> list(walker.text(' '))
+ [{u'data': ' ', u'type': u'SpaceCharacters'}]
+ >>> list(walker.text(' abc ')) # doctest: +NORMALIZE_WHITESPACE
+ [{u'data': ' ', u'type': u'SpaceCharacters'},
+ {u'data': u'abc', u'type': u'Characters'},
+ {u'data': u' ', u'type': u'SpaceCharacters'}]
+
+ :arg data: the text data
+
+ :returns: one or more ``SpaceCharacters`` and ``Characters`` tokens
+
+ """
data = data
middle = data.lstrip(spaceCharacters)
left = data[:len(data) - len(middle)]
@@ -60,18 +136,44 @@ def text(self, data):
yield {"type": "SpaceCharacters", "data": right}
def comment(self, data):
+ """Generates a Comment token
+
+ :arg data: the comment
+
+ :returns: Comment token
+
+ """
return {"type": "Comment", "data": data}
def doctype(self, name, publicId=None, systemId=None):
+ """Generates a Doctype token
+
+ :arg name:
+
+ :arg publicId:
+
+ :arg systemId:
+
+ :returns: the Doctype token
+
+ """
return {"type": "Doctype",
"name": name,
"publicId": publicId,
"systemId": systemId}
def entity(self, name):
+ """Generates an Entity token
+
+ :arg name: the entity name
+
+ :returns: an Entity token
+
+ """
return {"type": "Entity", "name": name}
def unknown(self, nodeType):
+ """Handles unknown node types"""
return self.error("Unknown node type: " + nodeType)
From 07404cabc5ea2cab65be063225a093362175e45f Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Thu, 7 Dec 2017 12:26:19 +0000
Subject: [PATCH 146/223] Bump version number for release
---
html5lib/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/__init__.py b/html5lib/__init__.py
index 3edfcbf3..ecda9fa4 100644
--- a/html5lib/__init__.py
+++ b/html5lib/__init__.py
@@ -32,4 +32,4 @@
# this has to be at the top level, see how setup.py parses this
#: Distribution version number.
-__version__ = "0.9999999999-dev"
+__version__ = "1.0"
From a4e7d17d27fee25d4d4d06cb16c44ed1712b5426 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Thu, 7 Dec 2017 13:56:29 +0000
Subject: [PATCH 147/223] Bump version number beyond release
---
html5lib/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/__init__.py b/html5lib/__init__.py
index ecda9fa4..373fb925 100644
--- a/html5lib/__init__.py
+++ b/html5lib/__init__.py
@@ -32,4 +32,4 @@
# this has to be at the top level, see how setup.py parses this
#: Distribution version number.
-__version__ = "1.0"
+__version__ = "1.1-dev"
From b4887f037e47857b4667106cc968ec91d1121140 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Thu, 7 Dec 2017 14:00:45 +0000
Subject: [PATCH 148/223] Fix CHANGES.rst to have 1.0.1 instead of unrelased
---
CHANGES.rst | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index fc0671a5..82605a21 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,8 +1,10 @@
Change Log
----------
-unreleased
-~~~~~~~~~~~~~~~~~~
+1.0.1
+~~~~~
+
+Released on December 7, 2017
Breaking changes:
@@ -36,6 +38,13 @@ Bug fixes:
* Allow uppercase hex chararcters in CSS colour check. (#377) (Thank you,
Komal Dembla, Hugo!)
+
+1.0
+~~~
+
+Released and unreleased on December 7, 2017. Badly packaged release.
+
+
0.999999999/1.0b10
~~~~~~~~~~~~~~~~~~
From 4b8a119e51c4d4ad681489ef4f42e1a5184c9312 Mon Sep 17 00:00:00 2001
From: Geoffrey Sneddon
Date: Tue, 16 Jan 2018 09:57:06 +0000
Subject: [PATCH 149/223] Refer to EOF by its constant everywhere (#388)
---
html5lib/_inputstream.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py
index 177f0ab9..aabc7b88 100644
--- a/html5lib/_inputstream.py
+++ b/html5lib/_inputstream.py
@@ -367,7 +367,7 @@ def charsUntil(self, characters, opposite=False):
def unget(self, char):
# Only one character is allowed to be ungotten at once - it must
# be consumed again before any further call to unget
- if char is not None:
+ if char is not EOF:
if self.chunkOffset == 0:
# unget is called quite rarely, so it's a good idea to do
# more work here if it saves a bit of work in the frequently
From 786dbf83f9c5b882eb1f4355dc3a4f1d45a67b14 Mon Sep 17 00:00:00 2001
From: Ward Bradt
Date: Tue, 16 Jan 2018 04:57:52 -0500
Subject: [PATCH 150/223] fixed misspelling of "association" in base.py (#387)
---
html5lib/treebuilders/base.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html5lib/treebuilders/base.py b/html5lib/treebuilders/base.py
index 05d97ecc..15ba609e 100644
--- a/html5lib/treebuilders/base.py
+++ b/html5lib/treebuilders/base.py
@@ -28,7 +28,7 @@ def __init__(self, name):
:arg name: The tag name associated with the node
"""
- # The tag name assocaited with the node
+ # The tag name associated with the node
self.name = name
# The parent of the current node (or None for the document node)
self.parent = None
From 5e6b61b4630165dd4765fff41d0f855534d5e2fe Mon Sep 17 00:00:00 2001
From: Ward Bradt
Date: Sat, 20 Jan 2018 13:56:50 -0500
Subject: [PATCH 151/223] fixed some minor grammar in opening comment (#389)
---
html5lib/treewalkers/__init__.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/html5lib/treewalkers/__init__.py b/html5lib/treewalkers/__init__.py
index 9bec2076..b2d3aac3 100644
--- a/html5lib/treewalkers/__init__.py
+++ b/html5lib/treewalkers/__init__.py
@@ -2,10 +2,10 @@
tree, generating tokens identical to those produced by the tokenizer
module.
-To create a tree walker for a new type of tree, you need to do
+To create a tree walker for a new type of tree, you need to
implement a tree walker object (called TreeWalker by convention) that
-implements a 'serialize' method taking a tree as sole argument and
-returning an iterator generating tokens.
+implements a 'serialize' method which takes a tree as sole argument and
+returns an iterator which generates tokens.
"""
from __future__ import absolute_import, division, unicode_literals
From e9ef538bf58b0e821711d6368663064125d33115 Mon Sep 17 00:00:00 2001
From: luzpaz
Date: Mon, 5 Mar 2018 10:55:05 -0500
Subject: [PATCH 152/223] Misc. source comment typos (#391)
Found via `codespell -q 3`
---
html5lib/_inputstream.py | 2 +-
html5lib/serializer.py | 2 +-
html5lib/tests/serializer-testdata/core.test | 4 ++--
setup.py | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py
index aabc7b88..c20e94fd 100644
--- a/html5lib/_inputstream.py
+++ b/html5lib/_inputstream.py
@@ -461,7 +461,7 @@ def determineEncoding(self, chardet=True):
if charEncoding[0] is not None:
return charEncoding
- # If we've been overriden, we've been overriden
+ # If we've been overridden, we've been overridden
charEncoding = lookupEncoding(self.override_encoding), "certain"
if charEncoding[0] is not None:
return charEncoding
diff --git a/html5lib/serializer.py b/html5lib/serializer.py
index d6b7105d..c66df683 100644
--- a/html5lib/serializer.py
+++ b/html5lib/serializer.py
@@ -274,7 +274,7 @@ def serialize(self, treewalker, encoding=None):
if token["systemId"]:
if token["systemId"].find('"') >= 0:
if token["systemId"].find("'") >= 0:
- self.serializeError("System identifer contains both single and double quote characters")
+ self.serializeError("System identifier contains both single and double quote characters")
quote_char = "'"
else:
quote_char = '"'
diff --git a/html5lib/tests/serializer-testdata/core.test b/html5lib/tests/serializer-testdata/core.test
index 70828d0d..55294b68 100644
--- a/html5lib/tests/serializer-testdata/core.test
+++ b/html5lib/tests/serializer-testdata/core.test
@@ -375,7 +375,7 @@
"-//W3C//DTD HTML 4.01//EN"
]
],
- "description": "HTML 4.01 DOCTYPE without system identifer"
+ "description": "HTML 4.01 DOCTYPE without system identifier"
},
{
"expected": [
@@ -389,7 +389,7 @@
"http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"
]
],
- "description": "IBM DOCTYPE without public identifer"
+ "description": "IBM DOCTYPE without public identifier"
}
]
}
diff --git a/setup.py b/setup.py
index 3e413f2a..cb96f2f2 100644
--- a/setup.py
+++ b/setup.py
@@ -46,7 +46,7 @@ def default_environment():
_markerlib.default_environment = default_environment
-# Avoid the very buggy pkg_resources.parser, which doesnt consistently
+# Avoid the very buggy pkg_resources.parser, which doesn't consistently
# recognise the markers needed by this setup.py
# Change this to setuptools 20.10.0 to support all markers.
if pkg_resources:
From 7f613b331c4299943403d8e12ccb51077e910205 Mon Sep 17 00:00:00 2001
From: Hugo
Date: Wed, 23 May 2018 12:50:20 +0300
Subject: [PATCH 153/223] Drop support for EOL Python 3.3 (#358)
---
.travis.yml | 1 -
README.rst | 2 +-
setup.py | 1 -
tox.ini | 2 +-
4 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 5727e094..a694dc70 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,7 +4,6 @@ python:
- "3.6"
- "3.5"
- "3.4"
- - "3.3"
- "2.7"
sudo: false
diff --git a/README.rst b/README.rst
index 8c151328..fc7e21c6 100644
--- a/README.rst
+++ b/README.rst
@@ -90,7 +90,7 @@ More documentation is available at https://html5lib.readthedocs.io/.
Installation
------------
-html5lib works on CPython 2.7+, CPython 3.3+ and PyPy. To install it,
+html5lib works on CPython 2.7+, CPython 3.4+ and PyPy. To install it,
use:
.. code-block:: bash
diff --git a/setup.py b/setup.py
index cb96f2f2..1876f3e8 100644
--- a/setup.py
+++ b/setup.py
@@ -66,7 +66,6 @@ def default_environment():
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
diff --git a/tox.ini b/tox.ini
index e07ef670..8e4a0835 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = {py27,py33,py34,py35,py36,pypy}-{base,six19,optional}
+envlist = {py27,py34,py35,py36,pypy}-{base,six19,optional}
[testenv]
deps =
From 950ea0ec60970ba1c88bd9e35d8d85c2a1f318e4 Mon Sep 17 00:00:00 2001
From: Hugo
Date: Wed, 23 May 2018 12:50:37 +0300
Subject: [PATCH 154/223] Upgrade Travis CI badge to SVG (#393)
---
README.rst | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/README.rst b/README.rst
index fc7e21c6..095e5f92 100644
--- a/README.rst
+++ b/README.rst
@@ -1,8 +1,9 @@
html5lib
========
-.. image:: https://travis-ci.org/html5lib/html5lib-python.png?branch=master
- :target: https://travis-ci.org/html5lib/html5lib-python
+.. image:: https://travis-ci.org/html5lib/html5lib-python.svg?branch=master
+ :target: https://travis-ci.org/html5lib/html5lib-python
+
html5lib is a pure-python library for parsing HTML. It is designed to
conform to the WHATWG HTML specification, as is implemented by all major
From 7facf987f52ad25b5cf9aa1fa76252ea04702777 Mon Sep 17 00:00:00 2001
From: Tom Most
Date: Mon, 1 Oct 2018 04:28:12 -0700
Subject: [PATCH 155/223] Remove Appveyor Python 3.3 builds (#397)
It looks like this was missed in #358. It is causing build failures in #395 and #396.
---
.appveyor.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.appveyor.yml b/.appveyor.yml
index 984e2b7f..dd96a399 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -6,8 +6,6 @@ environment:
matrix:
- TOXENV: py27-base
- TOXENV: py27-optional
- - TOXENV: py33-base
- - TOXENV: py33-optional
- TOXENV: py34-base
- TOXENV: py34-optional
- TOXENV: py35-base
From fd04f6a10c80cf8850650066a04e4c12686f4be1 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Mon, 1 Oct 2018 06:30:13 -0500
Subject: [PATCH 156/223] Remove unnecessary use of six.binary_type (#400)
The bytes type is available on all support Pythons. On Python 2 it is an
alias of str (same as six). Reduce unnecessary compatibility shims and
by using modern Python idioms. Makes the code more forward compatible
with Python 3.
---
html5lib/_inputstream.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py
index c20e94fd..62f5e9d5 100644
--- a/html5lib/_inputstream.py
+++ b/html5lib/_inputstream.py
@@ -1,6 +1,6 @@
from __future__ import absolute_import, division, unicode_literals
-from six import text_type, binary_type
+from six import text_type
from six.moves import http_client, urllib
import codecs
@@ -908,7 +908,7 @@ def parse(self):
def lookupEncoding(encoding):
"""Return the python codec name corresponding to an encoding or None if the
string doesn't correspond to a valid encoding."""
- if isinstance(encoding, binary_type):
+ if isinstance(encoding, bytes):
try:
encoding = encoding.decode("ascii")
except UnicodeDecodeError:
From 0ba6628e1e43f3d4b07180d1a6e39bc47ff50c09 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Mon, 1 Oct 2018 06:31:35 -0500
Subject: [PATCH 157/223] Remove unnecessary compatibility shim for BytesIO
(#401)
io.BytesIO is available on all supported Pythons. Can simplify by
assuming the import will succeed.
---
html5lib/_inputstream.py | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py
index 62f5e9d5..37d749ca 100644
--- a/html5lib/_inputstream.py
+++ b/html5lib/_inputstream.py
@@ -5,6 +5,7 @@
import codecs
import re
+from io import BytesIO, StringIO
import webencodings
@@ -12,13 +13,6 @@
from .constants import _ReparseException
from . import _utils
-from io import StringIO
-
-try:
- from io import BytesIO
-except ImportError:
- BytesIO = StringIO
-
# Non-unicode versions of constants for use in the pre-parser
spaceCharactersBytes = frozenset([item.encode("ascii") for item in spaceCharacters])
asciiLettersBytes = frozenset([item.encode("ascii") for item in asciiLetters])
From 4f9235752cea29c5a31721440578b430823a1e69 Mon Sep 17 00:00:00 2001
From: 5j9 <5j9@users.noreply.github.com>
Date: Mon, 1 Oct 2018 15:02:33 +0330
Subject: [PATCH 158/223] Try to import MutableMapping from collections.abc
(#403)
Note that collections.abc has been added in Python 3.3.
Fixes #402
---
html5lib/_trie/_base.py | 5 ++++-
html5lib/treebuilders/dom.py | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/html5lib/_trie/_base.py b/html5lib/_trie/_base.py
index a1158bbb..6b71975f 100644
--- a/html5lib/_trie/_base.py
+++ b/html5lib/_trie/_base.py
@@ -1,6 +1,9 @@
from __future__ import absolute_import, division, unicode_literals
-from collections import Mapping
+try:
+ from collections.abc import Mapping
+except ImportError: # Python 2.7
+ from collections import Mapping
class Trie(Mapping):
diff --git a/html5lib/treebuilders/dom.py b/html5lib/treebuilders/dom.py
index dcfac220..d8b53004 100644
--- a/html5lib/treebuilders/dom.py
+++ b/html5lib/treebuilders/dom.py
@@ -1,7 +1,10 @@
from __future__ import absolute_import, division, unicode_literals
-from collections import MutableMapping
+try:
+ from collections.abc import MutableMapping
+except ImportError: # Python 2.7
+ from collections import MutableMapping
from xml.dom import minidom, Node
import weakref
From e7a34499e083aadaaa0da487f7adbd6f68f97747 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Tue, 16 Apr 2019 05:23:15 -0700
Subject: [PATCH 159/223] Remove unnecessary flake8 exclude (#416)
Modern flake8 has a good default for exclude that includes the tox
directory.
https://gitlab.com/pycqa/flake8/blob/2b333fad1abe0bdb2e04132eabb0822e6ce63888/src/flake8/defaults.py#L4-14
---
tox.ini | 3 ---
1 file changed, 3 deletions(-)
diff --git a/tox.ini b/tox.ini
index 8e4a0835..c5ef6b2a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -18,6 +18,3 @@ commands =
[testenv:doc]
changedir = doc
commands = sphinx-build -b html . _build
-
-[flake8]
-exclude = ./.tox
From 2d8919a43d011a4712d427bc74e7bd9e5fa475a9 Mon Sep 17 00:00:00 2001
From: cclauss
Date: Thu, 18 Apr 2019 15:53:07 +0200
Subject: [PATCH 160/223] Travis CI: Add Python 3.7 and pypy3 (#417)
---
.travis.yml | 15 +++++++++++++--
requirements-optional.txt | 4 +++-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index a694dc70..b1e04fad 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,13 +1,12 @@
language: python
python:
+ - "pypy3"
- "pypy"
- "3.6"
- "3.5"
- "3.4"
- "2.7"
-sudo: false
-
cache: pip
env:
@@ -18,6 +17,18 @@ env:
- TOXENV=base
- TOXENV=six19-optional
+matrix:
+ include:
+ - python: "3.7"
+ dist: xenial # required for Python >= 3.7
+ env: TOXENV=optional
+ - python: "3.7"
+ dist: xenial # required for Python >= 3.7
+ env: TOXENV=base
+ - python: "3.7"
+ dist: xenial # required for Python >= 3.7
+ env: TOXENV=six19-optional
+
install:
- pip install tox codecov
diff --git a/requirements-optional.txt b/requirements-optional.txt
index c00fd242..d8be39ff 100644
--- a/requirements-optional.txt
+++ b/requirements-optional.txt
@@ -14,4 +14,6 @@ lxml ; platform_python_implementation == 'CPython'
# DATrie can be used in place of our Python trie implementation for
# slightly better parsing performance.
-datrie ; platform_python_implementation == 'CPython'
+# https://github.com/pytries/datrie/issues/52 although closed is not
+# yet released to https://pypi.org/project/datrie
+datrie ; platform_python_implementation == 'CPython' and python_version < '3.7'
From 4b2275497b624c6e97150fa2eb16a7db7ed42111 Mon Sep 17 00:00:00 2001
From: Ms2ger
Date: Fri, 26 Apr 2019 14:50:52 +0200
Subject: [PATCH 161/223] Improve the 'Coercing non-XML name' warning (#418)
This can be helpful in finding the code triggering the warning.
---
html5lib/_ihatexml.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/html5lib/_ihatexml.py b/html5lib/_ihatexml.py
index 4c77717b..a7aa72e8 100644
--- a/html5lib/_ihatexml.py
+++ b/html5lib/_ihatexml.py
@@ -254,7 +254,7 @@ def toXmlName(self, name):
nameRest = name[1:]
m = nonXmlNameFirstBMPRegexp.match(nameFirst)
if m:
- warnings.warn("Coercing non-XML name", DataLossWarning)
+ warnings.warn("Coercing non-XML name: %s" % name, DataLossWarning)
nameFirstOutput = self.getReplacementCharacter(nameFirst)
else:
nameFirstOutput = nameFirst
@@ -262,7 +262,7 @@ def toXmlName(self, name):
nameRestOutput = nameRest
replaceChars = set(nonXmlNameBMPRegexp.findall(nameRest))
for char in replaceChars:
- warnings.warn("Coercing non-XML name", DataLossWarning)
+ warnings.warn("Coercing non-XML name: %s" % name, DataLossWarning)
replacement = self.getReplacementCharacter(char)
nameRestOutput = nameRestOutput.replace(char, replacement)
return nameFirstOutput + nameRestOutput
From 77879b0d25b7db88d70f902c6cfdfe49ba270de4 Mon Sep 17 00:00:00 2001
From: Hugo van Kemenade
Date: Tue, 29 Oct 2019 19:13:40 +0100
Subject: [PATCH 162/223] Drop support for EOL Python 3.4 (#421)
---
.appveyor.yml | 2 --
.travis.yml | 1 -
setup.py | 2 +-
tox.ini | 2 +-
4 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/.appveyor.yml b/.appveyor.yml
index dd96a399..3a032f75 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -6,8 +6,6 @@ environment:
matrix:
- TOXENV: py27-base
- TOXENV: py27-optional
- - TOXENV: py34-base
- - TOXENV: py34-optional
- TOXENV: py35-base
- TOXENV: py35-optional
- TOXENV: py36-base
diff --git a/.travis.yml b/.travis.yml
index b1e04fad..3d87fe5f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,7 +4,6 @@ python:
- "pypy"
- "3.6"
- "3.5"
- - "3.4"
- "2.7"
cache: pip
diff --git a/setup.py b/setup.py
index 1876f3e8..27c97727 100644
--- a/setup.py
+++ b/setup.py
@@ -66,7 +66,6 @@ def default_environment():
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Software Development :: Libraries :: Python Modules',
@@ -104,6 +103,7 @@ def default_environment():
'six>=1.9',
'webencodings',
],
+ python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
extras_require={
# A conditional extra will only install these items when the extra is
# requested and the condition matches.
diff --git a/tox.ini b/tox.ini
index c5ef6b2a..edb752f6 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = {py27,py34,py35,py36,pypy}-{base,six19,optional}
+envlist = {py27,py35,py36,pypy}-{base,six19,optional}
[testenv]
deps =
From af19281fa28788830684b4c8fc6d0c588b092616 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Tue, 29 Oct 2019 11:17:28 -0700
Subject: [PATCH 163/223] Use modern Python syntax set literals and dict
comprehension (#415)
Available since Python 2.7. Instances discovered using pyupgrade.
---
html5lib/_inputstream.py | 14 +++++++-------
html5lib/constants.py | 9 ++++-----
html5lib/html5parser.py | 9 ++++-----
html5lib/tests/test_serializer.py | 2 +-
html5lib/tests/tokenizer.py | 2 +-
html5lib/treebuilders/base.py | 6 +++---
utils/entities.py | 8 ++++----
7 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py
index 37d749ca..b8021291 100644
--- a/html5lib/_inputstream.py
+++ b/html5lib/_inputstream.py
@@ -34,13 +34,13 @@
else:
invalid_unicode_re = re.compile(invalid_unicode_no_surrogate)
-non_bmp_invalid_codepoints = set([0x1FFFE, 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE,
- 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE, 0x5FFFF,
- 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE,
- 0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF,
- 0xBFFFE, 0xBFFFF, 0xCFFFE, 0xCFFFF, 0xDFFFE,
- 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
- 0x10FFFE, 0x10FFFF])
+non_bmp_invalid_codepoints = {0x1FFFE, 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE,
+ 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE, 0x5FFFF,
+ 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE,
+ 0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF,
+ 0xBFFFE, 0xBFFFF, 0xCFFFE, 0xCFFFF, 0xDFFFE,
+ 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
+ 0x10FFFE, 0x10FFFF}
ascii_punctuation_re = re.compile("[\u0009-\u000D\u0020-\u002F\u003A-\u0040\u005C\u005B-\u0060\u007B-\u007E]")
diff --git a/html5lib/constants.py b/html5lib/constants.py
index 1ff80419..fe3e237c 100644
--- a/html5lib/constants.py
+++ b/html5lib/constants.py
@@ -519,8 +519,8 @@
"xmlns:xlink": ("xmlns", "xlink", namespaces["xmlns"])
}
-unadjustForeignAttributes = dict([((ns, local), qname) for qname, (prefix, local, ns) in
- adjustForeignAttributes.items()])
+unadjustForeignAttributes = {(ns, local): qname for qname, (prefix, local, ns) in
+ adjustForeignAttributes.items()}
spaceCharacters = frozenset([
"\t",
@@ -544,8 +544,7 @@
digits = frozenset(string.digits)
hexDigits = frozenset(string.hexdigits)
-asciiUpper2Lower = dict([(ord(c), ord(c.lower()))
- for c in string.ascii_uppercase])
+asciiUpper2Lower = {ord(c): ord(c.lower()) for c in string.ascii_uppercase}
# Heading elements need to be ordered
headingElements = (
@@ -2934,7 +2933,7 @@
tokenTypes["EmptyTag"]])
-prefixes = dict([(v, k) for k, v in namespaces.items()])
+prefixes = {v: k for k, v in namespaces.items()}
prefixes["http://www.w3.org/1998/Math/MathML"] = "math"
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 9d39b9d4..4d12d9de 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -119,8 +119,8 @@ def __init__(self, tree=None, strict=False, namespaceHTMLElements=True, debug=Fa
self.tree = tree(namespaceHTMLElements)
self.errors = []
- self.phases = dict([(name, cls(self, self.tree)) for name, cls in
- getPhases(debug).items()])
+ self.phases = {name: cls(self, self.tree) for name, cls in
+ getPhases(debug).items()}
def _parse(self, stream, innerHTML=False, container="div", scripting=False, **kwargs):
@@ -413,8 +413,7 @@ def parseRCDataRawtext(self, token, contentType):
def getPhases(debug):
def log(function):
"""Logger that records which phase processes each token"""
- type_names = dict((value, key) for key, value in
- tokenTypes.items())
+ type_names = {value: key for key, value in tokenTypes.items()}
def wrapped(self, *args, **kwargs):
if function.__name__.startswith("process") and len(args) > 0:
@@ -2478,7 +2477,7 @@ def processStartTag(self, token):
currentNode = self.tree.openElements[-1]
if (token["name"] in self.breakoutElements or
(token["name"] == "font" and
- set(token["data"].keys()) & set(["color", "face", "size"]))):
+ set(token["data"].keys()) & {"color", "face", "size"})):
self.parser.parseError("unexpected-html-element-in-foreign-content",
{"name": token["name"]})
while (self.tree.openElements[-1].namespace !=
diff --git a/html5lib/tests/test_serializer.py b/html5lib/tests/test_serializer.py
index 9333286e..c23592af 100644
--- a/html5lib/tests/test_serializer.py
+++ b/html5lib/tests/test_serializer.py
@@ -80,7 +80,7 @@ def _convertAttrib(self, attribs):
def serialize_html(input, options):
- options = dict([(str(k), v) for k, v in options.items()])
+ options = {str(k): v for k, v in options.items()}
encoding = options.get("encoding", None)
if "encoding" in options:
del options["encoding"]
diff --git a/html5lib/tests/tokenizer.py b/html5lib/tests/tokenizer.py
index 1440a722..f93ae030 100644
--- a/html5lib/tests/tokenizer.py
+++ b/html5lib/tests/tokenizer.py
@@ -28,7 +28,7 @@ def parse(self, stream, encoding=None, innerHTML=False):
tokenizer.currentToken = {"type": "startTag",
"name": self._lastStartTag}
- types = dict((v, k) for k, v in constants.tokenTypes.items())
+ types = {v: k for k, v in constants.tokenTypes.items()}
for token in tokenizer:
getattr(self, 'process%s' % types[token["type"]])(token)
diff --git a/html5lib/treebuilders/base.py b/html5lib/treebuilders/base.py
index 15ba609e..e4a3d710 100644
--- a/html5lib/treebuilders/base.py
+++ b/html5lib/treebuilders/base.py
@@ -10,9 +10,9 @@
listElementsMap = {
None: (frozenset(scopingElements), False),
- "button": (frozenset(scopingElements | set([(namespaces["html"], "button")])), False),
- "list": (frozenset(scopingElements | set([(namespaces["html"], "ol"),
- (namespaces["html"], "ul")])), False),
+ "button": (frozenset(scopingElements | {(namespaces["html"], "button")}), False),
+ "list": (frozenset(scopingElements | {(namespaces["html"], "ol"),
+ (namespaces["html"], "ul")}), False),
"table": (frozenset([(namespaces["html"], "html"),
(namespaces["html"], "table")]), False),
"select": (frozenset([(namespaces["html"], "optgroup"),
diff --git a/utils/entities.py b/utils/entities.py
index 6dccf5f0..c8f268d0 100644
--- a/utils/entities.py
+++ b/utils/entities.py
@@ -8,10 +8,10 @@ def parse(path="html5ents.xml"):
def entity_table(tree):
- return dict((entity_name("".join(tr[0].xpath(".//text()"))),
- entity_characters(tr[1].text))
- for tr in tree.xpath("//h:tbody/h:tr",
- namespaces={"h": "http://www.w3.org/1999/xhtml"}))
+ return {entity_name("".join(tr[0].xpath(".//text()"))):
+ entity_characters(tr[1].text)
+ for tr in tree.xpath("//h:tbody/h:tr",
+ namespaces={"h": "http://www.w3.org/1999/xhtml"})}
def entity_name(inp):
From 7fea68a9f6dfdc7bf5df068cd92c2b7e95eb9875 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Wed, 8 Jan 2020 19:54:13 -0800
Subject: [PATCH 164/223] Simplify Travis CI configuration
Travis now support Python 3.7.
---
.travis.yml | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 3d87fe5f..7536b8db 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,6 +2,7 @@ language: python
python:
- "pypy3"
- "pypy"
+ - "3.7"
- "3.6"
- "3.5"
- "2.7"
@@ -16,18 +17,6 @@ env:
- TOXENV=base
- TOXENV=six19-optional
-matrix:
- include:
- - python: "3.7"
- dist: xenial # required for Python >= 3.7
- env: TOXENV=optional
- - python: "3.7"
- dist: xenial # required for Python >= 3.7
- env: TOXENV=base
- - python: "3.7"
- dist: xenial # required for Python >= 3.7
- env: TOXENV=six19-optional
-
install:
- pip install tox codecov
From dbeeacc01833a3330edffe283ead61f65443023f Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Tue, 25 Feb 2020 16:46:50 -0800
Subject: [PATCH 165/223] Remove unnecessary/empty try/except construct
The exception is caught and always re-raised without any additional
action. Simply let the original exception bubble up instead.
---
html5lib/html5parser.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 4d12d9de..6ba7b080 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -418,10 +418,7 @@ def log(function):
def wrapped(self, *args, **kwargs):
if function.__name__.startswith("process") and len(args) > 0:
token = args[0]
- try:
- info = {"type": type_names[token['type']]}
- except:
- raise
+ info = {"type": type_names[token['type']]}
if token['type'] in tagTokenTypes:
info["name"] = token['name']
From 986560a462ae2189f5e3a5b11ebb80e6feaff666 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Thu, 31 Oct 2019 18:50:29 -0700
Subject: [PATCH 166/223] Update flake8 to the latest version and fix all
errors
---
doc/conf.py | 179 ++--------------------------
html5lib/_ihatexml.py | 1 +
html5lib/_inputstream.py | 2 +-
html5lib/_utils.py | 2 +-
html5lib/tests/support.py | 1 +
html5lib/tests/tokenizer.py | 1 +
html5lib/tests/tokenizertotree.py | 1 +
html5lib/tests/tree_construction.py | 1 +
html5lib/treewalkers/etree.py | 1 +
parse.py | 7 +-
requirements-test.txt | 2 +-
setup.cfg | 2 +-
utils/entities.py | 1 +
13 files changed, 26 insertions(+), 175 deletions(-)
diff --git a/doc/conf.py b/doc/conf.py
index e02218b8..9e4beeb4 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -12,18 +12,11 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys, os
-
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.insert(0, os.path.abspath('.'))
+import sys
+import os
# -- General configuration -----------------------------------------------------
-# If your documentation needs a minimal Sphinx version, state it here.
-#needs_sphinx = '1.0'
-
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.viewcode']
@@ -34,9 +27,6 @@
# The suffix of source filenames.
source_suffix = '.rst'
-# The encoding of source files.
-#source_encoding = 'utf-8-sig'
-
# The master toctree document.
master_doc = 'index'
@@ -52,168 +42,35 @@
version = '1.0'
# The full version, including alpha/beta/rc tags.
sys.path.append(os.path.abspath('..'))
-from html5lib import __version__
+from html5lib import __version__ # noqa
release = __version__
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-#language = 'en'
-
-# There are two options for replacing |today|: either, you set today to some
-# non-false value, then it is used:
-#today = ''
-# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
-
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build', 'theme']
-# The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
-
-# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
-
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-#add_module_names = True
-
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-#show_authors = False
-
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
-# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
-
-# If true, keep warnings as "system message" paragraphs in the built documents.
-#keep_warnings = False
-
-
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
-# Theme options are theme-specific and customize the look and feel of a theme
-# further. For a list of options available for each theme, see the
-# documentation.
-#html_theme_options = {}
-
-# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
-
-# The name for this set of Sphinx documents. If None, it defaults to
-# " v documentation".
-#html_title = None
-
-# A shorter title for the navigation bar. Default is the same as html_title.
-#html_short_title = None
-
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-#html_logo = None
-
-# The name of an image file (within the static path) to use as favicon of the
-# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-#html_favicon = None
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-#html_static_path = ['_static']
-
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
-# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
-
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-#html_use_smartypants = True
-
-# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
-
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-#html_additional_pages = {}
-
-# If false, no module index is generated.
-#html_domain_indices = True
-
-# If false, no index is generated.
-#html_use_index = True
-
-# If true, the index is split into individual pages for each letter.
-#html_split_index = False
-
-# If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
-
-# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
-#html_show_sphinx = True
-
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#html_show_copyright = True
-
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a tag referring to it. The value of this option must be the
-# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
-
-# This is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = None
-
# Output file base name for HTML help builder.
htmlhelp_basename = 'html5libdoc'
# -- Options for LaTeX output --------------------------------------------------
-latex_elements = {
-# The paper size ('letterpaper' or 'a4paper').
-#'papersize': 'letterpaper',
-
-# The font size ('10pt', '11pt' or '12pt').
-#'pointsize': '10pt',
-
-# Additional stuff for the LaTeX preamble.
-#'preamble': '',
-}
-
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
- ('index', 'html5lib.tex', 'html5lib Documentation',
- 'James Graham, Geoffrey Sneddon, and contributors', 'manual'),
+ ('index', 'html5lib.tex', 'html5lib Documentation',
+ 'James Graham, Geoffrey Sneddon, and contributors', 'manual'),
]
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-#latex_use_parts = False
-
-# If true, show page references after internal links.
-#latex_show_pagerefs = False
-
-# If true, show URL addresses after external links.
-#latex_show_urls = False
-
-# Documents to append as an appendix to all manuals.
-#latex_appendices = []
-
-# If false, no module index is generated.
-#latex_domain_indices = True
-
-
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
@@ -223,32 +80,17 @@
['James Graham, Geoffrey Sneddon, and contributors'], 1)
]
-# If true, show URL addresses after external links.
-#man_show_urls = False
-
-
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- ('index', 'html5lib', 'html5lib Documentation',
- 'James Graham, Geoffrey Sneddon, and contributors', 'html5lib', 'One line description of project.',
- 'Miscellaneous'),
+ ('index', 'html5lib', 'html5lib Documentation',
+ 'James Graham, Geoffrey Sneddon, and contributors', 'html5lib', 'One line description of project.',
+ 'Miscellaneous'),
]
-# Documents to append as an appendix to all manuals.
-#texinfo_appendices = []
-
-# If false, no module index is generated.
-#texinfo_domain_indices = True
-
-# How to display URL addresses: 'footnote', 'no', or 'inline'.
-#texinfo_show_urls = 'footnote'
-
-# If true, do not generate a @detailmenu in the "Top" node's menu.
-#texinfo_no_detailmenu = False
class CExtMock(object):
"""Required for autodoc on readthedocs.org where you cannot build C extensions."""
@@ -265,15 +107,16 @@ def __getattr__(cls, name):
else:
return CExtMock()
+
try:
- import lxml # flake8: noqa
+ import lxml # noqa
except ImportError:
sys.modules['lxml'] = CExtMock()
sys.modules['lxml.etree'] = CExtMock()
print("warning: lxml modules mocked.")
try:
- import genshi # flake8: noqa
+ import genshi # noqa
except ImportError:
sys.modules['genshi'] = CExtMock()
sys.modules['genshi.core'] = CExtMock()
diff --git a/html5lib/_ihatexml.py b/html5lib/_ihatexml.py
index a7aa72e8..3ff803c1 100644
--- a/html5lib/_ihatexml.py
+++ b/html5lib/_ihatexml.py
@@ -136,6 +136,7 @@ def normaliseCharList(charList):
i += j
return rv
+
# We don't really support characters above the BMP :(
max_unicode = int("FFFF", 16)
diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py
index b8021291..49f6d9f1 100644
--- a/html5lib/_inputstream.py
+++ b/html5lib/_inputstream.py
@@ -443,7 +443,7 @@ def openStream(self, source):
try:
stream.seek(stream.tell())
- except: # pylint:disable=bare-except
+ except Exception:
stream = BufferedStream(stream)
return stream
diff --git a/html5lib/_utils.py b/html5lib/_utils.py
index 91252f2c..2fcfb802 100644
--- a/html5lib/_utils.py
+++ b/html5lib/_utils.py
@@ -27,7 +27,7 @@
# We need this with u"" because of http://bugs.jython.org/issue2039
_x = eval('u"\\uD800"') # pylint:disable=eval-used
assert isinstance(_x, text_type)
-except: # pylint:disable=bare-except
+except Exception:
supports_lone_surrogates = False
else:
supports_lone_surrogates = True
diff --git a/html5lib/tests/support.py b/html5lib/tests/support.py
index dab65c1c..b7d524e3 100644
--- a/html5lib/tests/support.py
+++ b/html5lib/tests/support.py
@@ -143,6 +143,7 @@ def convertData(data):
return "\n".join(rv)
return convertData
+
convertExpected = convert(2)
diff --git a/html5lib/tests/tokenizer.py b/html5lib/tests/tokenizer.py
index f93ae030..706d0e6f 100644
--- a/html5lib/tests/tokenizer.py
+++ b/html5lib/tests/tokenizer.py
@@ -176,6 +176,7 @@ def repl(m):
def _doCapitalize(match):
return match.group(1).upper()
+
_capitalizeRe = re.compile(r"\W+(\w)").sub
diff --git a/html5lib/tests/tokenizertotree.py b/html5lib/tests/tokenizertotree.py
index b841c76c..8528e876 100644
--- a/html5lib/tests/tokenizertotree.py
+++ b/html5lib/tests/tokenizertotree.py
@@ -64,5 +64,6 @@ def make_test(test_data):
rv.append("")
return "\n".join(rv)
+
if __name__ == "__main__":
main(sys.argv[1])
diff --git a/html5lib/tests/tree_construction.py b/html5lib/tests/tree_construction.py
index c6e7ca09..6112d11d 100644
--- a/html5lib/tests/tree_construction.py
+++ b/html5lib/tests/tree_construction.py
@@ -77,6 +77,7 @@ def _getTreeWalkerTests(self, treeName, treeAPIs):
def convertTreeDump(data):
return "\n".join(convert(3)(data).split("\n")[1:])
+
namespaceExpected = re.compile(r"^(\s*)<(\S+)>", re.M).sub
diff --git a/html5lib/treewalkers/etree.py b/html5lib/treewalkers/etree.py
index d15a7eeb..44653372 100644
--- a/html5lib/treewalkers/etree.py
+++ b/html5lib/treewalkers/etree.py
@@ -127,4 +127,5 @@ def getParentNode(self, node):
return locals()
+
getETreeModule = moduleFactoryFactory(getETreeBuilder)
diff --git a/parse.py b/parse.py
index 3e65c330..de622a22 100755
--- a/parse.py
+++ b/parse.py
@@ -33,7 +33,7 @@ def parse():
if contentType:
(mediaType, params) = cgi.parse_header(contentType)
encoding = params.get('charset')
- except:
+ except Exception:
pass
elif f == '-':
f = sys.stdin
@@ -94,7 +94,7 @@ def parse():
def run(parseMethod, f, encoding, scripting):
try:
document = parseMethod(f, override_encoding=encoding, scripting=scripting)
- except:
+ except Exception:
document = None
traceback.print_exc()
return document
@@ -127,7 +127,7 @@ def printOutput(parser, document, opts):
for opt in serializer.HTMLSerializer.options:
try:
kwargs[opt] = getattr(opts, opt)
- except:
+ except Exception:
pass
if not kwargs['quote_char']:
del kwargs['quote_char']
@@ -240,5 +240,6 @@ def getOptParser():
return parser
+
if __name__ == "__main__":
parse()
diff --git a/requirements-test.txt b/requirements-test.txt
index 4e223a3f..4dd5ca53 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -2,7 +2,7 @@
tox
-flake8<3.0
+flake8==3.7.9
pytest==3.2.5
coverage
diff --git a/setup.cfg b/setup.cfg
index d309fdaa..72edbfb0 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -7,7 +7,7 @@ max-line-length = 139
exclude = .git,__pycache__,.tox,doc
[flake8]
-ignore = N
+ignore = N, W504
max-line-length = 139
[metadata]
diff --git a/utils/entities.py b/utils/entities.py
index c8f268d0..6e8ca458 100644
--- a/utils/entities.py
+++ b/utils/entities.py
@@ -96,5 +96,6 @@ def main():
code = make_entities_code(entities)
open("entities_constants.py", "w").write(code)
+
if __name__ == "__main__":
main()
From 9c443671982d155ad6935b1fb65ee25fac9cf1e1 Mon Sep 17 00:00:00 2001
From: Stanislav Levin
Date: Thu, 30 May 2019 12:42:26 +0300
Subject: [PATCH 167/223] Fix Pytest4.x compatibility error
According to pytest docs:
```
marks in pytest.mark.parametrize
Removed in version 4.0.
Applying marks to values of a pytest.mark.parametrize call is now deprecated.
...
This was considered hard to read and understand, and also its implementation
presented problems to the code preventing further internal improvements in the
marks architecture.
To update the code, use pytest.param
```
Signed-off-by: Stanislav Levin
---
html5lib/tests/test_stream.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/html5lib/tests/test_stream.py b/html5lib/tests/test_stream.py
index 27c39538..efe9b472 100644
--- a/html5lib/tests/test_stream.py
+++ b/html5lib/tests/test_stream.py
@@ -308,9 +308,11 @@ def test_invalid_codepoints(inp, num):
("'\\uD800\\uD800\\uD800'", 3),
("'a\\uD800a\\uD800a\\uD800a'", 3),
("'\\uDFFF\\uDBFF'", 2),
- pytest.mark.skipif(sys.maxunicode == 0xFFFF,
- ("'\\uDBFF\\uDFFF'", 2),
- reason="narrow Python")])
+ pytest.param(
+ "'\\uDBFF\\uDFFF'", 2,
+ marks=pytest.mark.skipif(
+ sys.maxunicode == 0xFFFF,
+ reason="narrow Python"))])
def test_invalid_codepoints_surrogates(inp, num):
inp = eval(inp) # pylint:disable=eval-used
fp = StringIO(inp)
From 73a279552cd8024a4eddcc5e670a59ea4ed53c86 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Thu, 17 Oct 2019 21:16:22 -0700
Subject: [PATCH 168/223] Remove deprecated license_file from setup.cfg
Starting with wheel 0.32.0 (2018-09-29), the "license_file" option is
deprecated.
https://wheel.readthedocs.io/en/stable/news.html
The wheel will continue to include LICENSE, it is now included
automatically:
https://wheel.readthedocs.io/en/stable/user_guide.html#including-license-files-in-the-generated-wheel-file
---
setup.cfg | 3 ---
1 file changed, 3 deletions(-)
diff --git a/setup.cfg b/setup.cfg
index 72edbfb0..0b2bb9c7 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -9,6 +9,3 @@ exclude = .git,__pycache__,.tox,doc
[flake8]
ignore = N, W504
max-line-length = 139
-
-[metadata]
-license_file = LICENSE
From 4733d5c570c936ca71f1a07978bd8048091f31fa Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Wed, 10 Oct 2018 20:11:15 -0700
Subject: [PATCH 169/223] Replace deprecated optparse with argparse
https://docs.python.org/3/library/optparse.html
> Deprecated since version 3.2: The optparse module is deprecated and
> will not be developed further; development will continue with the
> argparse module.
---
parse.py | 129 ++++++++++++++++++++++++++-----------------------------
1 file changed, 60 insertions(+), 69 deletions(-)
diff --git a/parse.py b/parse.py
index de622a22..e6806b46 100755
--- a/parse.py
+++ b/parse.py
@@ -1,12 +1,11 @@
#!/usr/bin/env python
-"""usage: %prog [options] filename
-
+"""
Parse a document to a tree, with optional profiling
"""
+import argparse
import sys
import traceback
-from optparse import OptionParser
from html5lib import html5parser
from html5lib import treebuilders, serializer, treewalkers
@@ -15,12 +14,12 @@
def parse():
- optParser = getOptParser()
- opts, args = optParser.parse_args()
+ parser = get_parser()
+ opts = parser.parse_args()
encoding = "utf8"
try:
- f = args[-1]
+ f = opts.filename
# Try opening from the internet
if f.startswith('http://'):
try:
@@ -151,92 +150,84 @@ def printOutput(parser, document, opts):
sys.stdout.write("\nParse errors:\n" + "\n".join(errList) + "\n")
-def getOptParser():
- parser = OptionParser(usage=__doc__)
+def get_parser():
+ parser = argparse.ArgumentParser(description=__doc__)
+
+ parser.add_argument("-p", "--profile", action="store_true",
+ help="Use the hotshot profiler to "
+ "produce a detailed log of the run")
- parser.add_option("-p", "--profile", action="store_true", default=False,
- dest="profile", help="Use the hotshot profiler to "
- "produce a detailed log of the run")
+ parser.add_argument("-t", "--time",
+ action="store_true",
+ help="Time the run using time.time (may not be accurate on all platforms, especially for short runs)")
- parser.add_option("-t", "--time",
- action="store_true", default=False, dest="time",
- help="Time the run using time.time (may not be accurate on all platforms, especially for short runs)")
+ parser.add_argument("-b", "--treebuilder",
+ default="etree")
- parser.add_option("-b", "--treebuilder", action="store", type="string",
- dest="treebuilder", default="etree")
+ parser.add_argument("-e", "--error", action="store_true",
+ help="Print a list of parse errors")
- parser.add_option("-e", "--error", action="store_true", default=False,
- dest="error", help="Print a list of parse errors")
+ parser.add_argument("-f", "--fragment", action="store_true",
+ help="Parse as a fragment")
- parser.add_option("-f", "--fragment", action="store_true", default=False,
- dest="fragment", help="Parse as a fragment")
+ parser.add_argument("-s", "--scripting", action="store_true",
+ help="Handle noscript tags as if scripting was enabled")
- parser.add_option("-s", "--scripting", action="store_true", default=False,
- dest="scripting", help="Handle noscript tags as if scripting was enabled")
+ parser.add_argument("--tree", action="store_true",
+ help="Output as debug tree")
- parser.add_option("", "--tree", action="store_true", default=False,
- dest="tree", help="Output as debug tree")
+ parser.add_argument("-x", "--xml", action="store_true",
+ help="Output as xml")
- parser.add_option("-x", "--xml", action="store_true", default=False,
- dest="xml", help="Output as xml")
+ parser.add_argument("--no-html", action="store_false",
+ dest="html", help="Don't output html")
- parser.add_option("", "--no-html", action="store_false", default=True,
- dest="html", help="Don't output html")
+ parser.add_argument("-c", "--encoding", action="store_true",
+ help="Print character encoding used")
- parser.add_option("-c", "--encoding", action="store_true", default=False,
- dest="encoding", help="Print character encoding used")
+ parser.add_argument("--inject-meta-charset", action="store_true",
+ help="inject ")
- parser.add_option("", "--inject-meta-charset", action="store_true",
- default=False, dest="inject_meta_charset",
- help="inject ")
+ parser.add_argument("--strip-whitespace", action="store_true",
+ help="strip whitespace")
- parser.add_option("", "--strip-whitespace", action="store_true",
- default=False, dest="strip_whitespace",
- help="strip whitespace")
+ parser.add_argument("--omit-optional-tags", action="store_true",
+ help="omit optional tags")
- parser.add_option("", "--omit-optional-tags", action="store_true",
- default=False, dest="omit_optional_tags",
- help="omit optional tags")
+ parser.add_argument("--quote-attr-values", action="store_true",
+ help="quote attribute values")
- parser.add_option("", "--quote-attr-values", action="store_true",
- default=False, dest="quote_attr_values",
- help="quote attribute values")
+ parser.add_argument("--use-best-quote-char", action="store_true",
+ help="use best quote character")
- parser.add_option("", "--use-best-quote-char", action="store_true",
- default=False, dest="use_best_quote_char",
- help="use best quote character")
+ parser.add_argument("--quote-char",
+ help="quote character")
- parser.add_option("", "--quote-char", action="store",
- default=None, dest="quote_char",
- help="quote character")
+ parser.add_argument("--no-minimize-boolean-attributes",
+ action="store_false",
+ dest="minimize_boolean_attributes",
+ help="minimize boolean attributes")
- parser.add_option("", "--no-minimize-boolean-attributes",
- action="store_false", default=True,
- dest="minimize_boolean_attributes",
- help="minimize boolean attributes")
+ parser.add_argument("--use-trailing-solidus", action="store_true",
+ help="use trailing solidus")
- parser.add_option("", "--use-trailing-solidus", action="store_true",
- default=False, dest="use_trailing_solidus",
- help="use trailing solidus")
+ parser.add_argument("--space-before-trailing-solidus",
+ action="store_true",
+ help="add space before trailing solidus")
- parser.add_option("", "--space-before-trailing-solidus",
- action="store_true", default=False,
- dest="space_before_trailing_solidus",
- help="add space before trailing solidus")
+ parser.add_argument("--escape-lt-in-attrs", action="store_true",
+ help="escape less than signs in attribute values")
- parser.add_option("", "--escape-lt-in-attrs", action="store_true",
- default=False, dest="escape_lt_in_attrs",
- help="escape less than signs in attribute values")
+ parser.add_argument("--escape-rcdata", action="store_true",
+ help="escape rcdata element values")
- parser.add_option("", "--escape-rcdata", action="store_true",
- default=False, dest="escape_rcdata",
- help="escape rcdata element values")
+ parser.add_argument("--sanitize", action="store_true",
+ help="sanitize")
- parser.add_option("", "--sanitize", action="store_true", default=False,
- dest="sanitize", help="sanitize")
+ parser.add_argument("-l", "--log", action="store_true",
+ help="log state transitions")
- parser.add_option("-l", "--log", action="store_true", default=False,
- dest="log", help="log state transitions")
+ parser.add_argument("filename")
return parser
From e4de4c99de116a28fc3426de405d50701287d18a Mon Sep 17 00:00:00 2001
From: ")_("
Date: Tue, 25 Feb 2020 17:47:22 -0800
Subject: [PATCH 170/223] Fix typos (#424)
---
html5lib/tests/support.py | 2 +-
html5lib/tests/test_meta.py | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/html5lib/tests/support.py b/html5lib/tests/support.py
index b7d524e3..9cd5afbe 100644
--- a/html5lib/tests/support.py
+++ b/html5lib/tests/support.py
@@ -148,7 +148,7 @@ def convertData(data):
def errorMessage(input, expected, actual):
- msg = ("Input:\n%s\nExpected:\n%s\nRecieved\n%s\n" %
+ msg = ("Input:\n%s\nExpected:\n%s\nReceived\n%s\n" %
(repr(input), repr(expected), repr(actual)))
if sys.version_info[0] == 2:
msg = msg.encode("ascii", "backslashreplace")
diff --git a/html5lib/tests/test_meta.py b/html5lib/tests/test_meta.py
index e42eafdb..dd02dd7f 100644
--- a/html5lib/tests/test_meta.py
+++ b/html5lib/tests/test_meta.py
@@ -28,10 +28,10 @@ def test_errorMessage():
# Assertions!
if six.PY2:
- assert b"Input:\n1\nExpected:\n2\nRecieved\n3\n" == r
+ assert b"Input:\n1\nExpected:\n2\nReceived\n3\n" == r
else:
assert six.PY3
- assert "Input:\n1\nExpected:\n2\nRecieved\n3\n" == r
+ assert "Input:\n1\nExpected:\n2\nReceived\n3\n" == r
assert input.__repr__.call_count == 1
assert expected.__repr__.call_count == 1
From 6c21db28326fa4e7c76579a258806b66489c6b40 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Tue, 1 Jan 2019 10:56:57 -0800
Subject: [PATCH 171/223] Add testing and document support for Python 3.7, 3.8
& PyPy3
Python 3.7 was released on June 27, 2018.
Python 3.8 was released on October 14th, 2019.
---
.appveyor.yml | 4 ++++
.travis.yml | 1 +
setup.py | 4 ++++
tox.ini | 2 +-
4 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/.appveyor.yml b/.appveyor.yml
index 3a032f75..92f34f15 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -10,6 +10,10 @@ environment:
- TOXENV: py35-optional
- TOXENV: py36-base
- TOXENV: py36-optional
+ - TOXENV: py37-base
+ - TOXENV: py37-optional
+ - TOXENV: py38-base
+ - TOXENV: py38-optional
install:
- git submodule update --init --recursive
diff --git a/.travis.yml b/.travis.yml
index 7536b8db..c944f922 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,6 +2,7 @@ language: python
python:
- "pypy3"
- "pypy"
+ - "3.8"
- "3.7"
- "3.6"
- "3.5"
diff --git a/setup.py b/setup.py
index 27c97727..d3841290 100644
--- a/setup.py
+++ b/setup.py
@@ -68,6 +68,10 @@ def default_environment():
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
+ 'Programming Language :: Python :: 3.8',
+ 'Programming Language :: Python :: Implementation :: CPython',
+ 'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Text Processing :: Markup :: HTML'
]
diff --git a/tox.ini b/tox.ini
index edb752f6..58758cea 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = {py27,py35,py36,pypy}-{base,six19,optional}
+envlist = py{27,35,36,37,38,py,py3}-{base,six19,optional}
[testenv]
deps =
From 0fe6df40fc0f6054e082bee5d6df091944ba91b2 Mon Sep 17 00:00:00 2001
From: Hugo
Date: Wed, 26 Feb 2020 16:04:56 +0200
Subject: [PATCH 172/223] Document Python support
---
README.rst | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.rst b/README.rst
index 095e5f92..fb9398f6 100644
--- a/README.rst
+++ b/README.rst
@@ -91,13 +91,15 @@ More documentation is available at https://html5lib.readthedocs.io/.
Installation
------------
-html5lib works on CPython 2.7+, CPython 3.4+ and PyPy. To install it,
-use:
+html5lib works on CPython 2.7+, CPython 3.5+ and PyPy. To install:
.. code-block:: bash
$ pip install html5lib
+The goal is to support a (non-strict) superset of the versions that [pip
+supports](https://pip.pypa.io/en/stable/installing/#python-and-os-compatibility).
+
Optional Dependencies
---------------------
From 1df0206766c18a0f5a4bfd4d1b8eeb7eb78693cb Mon Sep 17 00:00:00 2001
From: Sam Sneddon
Date: Wed, 26 Feb 2020 15:20:43 +0000
Subject: [PATCH 173/223] Pin all the test requirements to try and make testing
deterministic
---
requirements-test.txt | 39 ++++++++++++++++++++++++++++++++++-----
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/requirements-test.txt b/requirements-test.txt
index 4dd5ca53..ee5074a0 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,10 +1,39 @@
-r requirements.txt
-tox
+# make sure we have a deterministic test setup
+# pin all of our direct dependencies
+tox==3.14.5
flake8==3.7.9
+pytest==3.2.5,<4 # see https://github.com/html5lib/html5lib-python/pull/429
+coverage==5.0.3
+pytest-expect==1.1.0
+mock==3.0.5
-pytest==3.2.5
-coverage
-pytest-expect>=1.1,<2.0
-mock
+# and all recursive dependencies
+appdirs==1.4.3
+configparser==4.0.2
+contextlib2==0.6.0.post1
+distlib==0.3.0
+entrypoints==0.3
+enum34==1.1.9
+filelock==3.0.12
+funcsigs==1.0.2
+functools32==3.2.3.post2 ; python_version < '3'
+importlib-metadata==1.5.0
+importlib-resources==1.0.2
+mccabe==0.6.1
+packaging==20.1
+pathlib2==2.3.5
+pluggy==0.13.1
+py==1.8.1
+pycodestyle==2.5.0
+pyflakes==2.1.1
+pyparsing==2.4.6
+scandir==1.10.0
+# six==1.14.0 # ignored because it's also in requirements.txt
+toml==0.10.0
+typing==3.7.4.1
+u-msgpack-python==2.5.2
+virtualenv==20.0.6
+zipp==1.2.0
From 05b73ef7298529e4b86067de82dbd725d04b2960 Mon Sep 17 00:00:00 2001
From: Sam Sneddon
Date: Thu, 27 Feb 2020 17:05:43 +0000
Subject: [PATCH 174/223] Update pytest to 3.10.1 (the last < 4 release)
See https://github.com/html5lib/html5lib-python/pull/429 for
upgrading to >= 4
---
requirements-test.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/requirements-test.txt b/requirements-test.txt
index ee5074a0..c3aa391d 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -5,7 +5,7 @@
# pin all of our direct dependencies
tox==3.14.5
flake8==3.7.9
-pytest==3.2.5,<4 # see https://github.com/html5lib/html5lib-python/pull/429
+pytest==3.10.1,<4 # see https://github.com/html5lib/html5lib-python/pull/429
coverage==5.0.3
pytest-expect==1.1.0
mock==3.0.5
From 4b8cabfd9b9b46870d3b08297e463e21a582b8e7 Mon Sep 17 00:00:00 2001
From: Jon Dufresne
Date: Tue, 3 Mar 2020 10:02:57 -0800
Subject: [PATCH 175/223] Fix rst syntax in README.rst
---
README.rst | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.rst b/README.rst
index fb9398f6..2114cfc8 100644
--- a/README.rst
+++ b/README.rst
@@ -97,9 +97,9 @@ html5lib works on CPython 2.7+, CPython 3.5+ and PyPy. To install:
$ pip install html5lib
-The goal is to support a (non-strict) superset of the versions that [pip
-supports](https://pip.pypa.io/en/stable/installing/#python-and-os-compatibility).
-
+The goal is to support a (non-strict) superset of the versions that `pip
+supports
+`_.
Optional Dependencies
---------------------
From 2310bd8b610bc56a0521a6e8d96fedebcd15cc17 Mon Sep 17 00:00:00 2001
From: Sam Sneddon
Date: Mon, 13 Apr 2020 05:59:31 +0100
Subject: [PATCH 176/223] Make scanning for meta encoding much quicker
Previously, this code tried to match everything with strings
beginning with "<"; now we jump forward to each "<" and compare
there. This also alters the jumpTo implementation to avoid
computing a (perhaps long) slice, making repeated calls O(n^2).
---
html5lib/_inputstream.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py
index 49f6d9f1..c0cdccfb 100644
--- a/html5lib/_inputstream.py
+++ b/html5lib/_inputstream.py
@@ -668,15 +668,11 @@ def matchBytes(self, bytes):
def jumpTo(self, bytes):
"""Look for the next sequence of bytes matching a given sequence. If
a match is found advance the position to the last byte of the match"""
- newPosition = self[self.position:].find(bytes)
- if newPosition > -1:
- # XXX: This is ugly, but I can't see a nicer way to fix this.
- if self._position == -1:
- self._position = 0
- self._position += (newPosition + len(bytes) - 1)
- return True
- else:
+ try:
+ self._position = self.index(bytes, self.position) + len(bytes) - 1
+ except ValueError:
raise StopIteration
+ return True
class EncodingParser(object):
@@ -697,6 +693,10 @@ def getEncoding(self):
(b"<", self.handlePossibleStartTag))
for _ in self.data:
keepParsing = True
+ try:
+ self.data.jumpTo(b"<")
+ except StopIteration:
+ break
for key, method in methodDispatch:
if self.data.matchBytes(key):
try:
From 2ea55c74ccd6fe4e50657ec619732d63b6e15027 Mon Sep 17 00:00:00 2001
From: Sam Sneddon
Date: Sat, 29 Feb 2020 13:19:49 +0000
Subject: [PATCH 177/223] bye-bye deadname
---
AUTHORS.rst | 2 +-
CHANGES.rst | 2 +-
doc/conf.py | 8 ++++----
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/AUTHORS.rst b/AUTHORS.rst
index fc635dea..90401390 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -4,7 +4,7 @@ Credits
``html5lib`` is written and maintained by:
- James Graham
-- Geoffrey Sneddon
+- Sam Sneddon
- Åukasz Langa
- Will Kahn-Greene
diff --git a/CHANGES.rst b/CHANGES.rst
index 82605a21..9442ba67 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -20,7 +20,7 @@ Features:
* Support Python 3.6. (#333) (Thank you, Jon Dufresne!)
* Add CI support for Windows using AppVeyor. (Thank you, John Vandenberg!)
* Improve testing and CI and add code coverage (#323, #334), (Thank you, Jon
- Dufresne, John Vandenberg, Geoffrey Sneddon, Will Kahn-Greene!)
+ Dufresne, John Vandenberg, Sam Sneddon, Will Kahn-Greene!)
* Semver-compliant version number.
Bug fixes:
diff --git a/doc/conf.py b/doc/conf.py
index 9e4beeb4..22ebab4f 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -32,7 +32,7 @@
# General information about the project.
project = 'html5lib'
-copyright = '2006 - 2013, James Graham, Geoffrey Sneddon, and contributors'
+copyright = '2006 - 2013, James Graham, Sam Sneddon, and contributors'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -68,7 +68,7 @@
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'html5lib.tex', 'html5lib Documentation',
- 'James Graham, Geoffrey Sneddon, and contributors', 'manual'),
+ 'James Graham, Sam Sneddon, and contributors', 'manual'),
]
# -- Options for manual page output --------------------------------------------
@@ -77,7 +77,7 @@
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'html5lib', 'html5lib Documentation',
- ['James Graham, Geoffrey Sneddon, and contributors'], 1)
+ ['James Graham, Sam Sneddon, and contributors'], 1)
]
# -- Options for Texinfo output ------------------------------------------------
@@ -87,7 +87,7 @@
# dir menu entry, description, category)
texinfo_documents = [
('index', 'html5lib', 'html5lib Documentation',
- 'James Graham, Geoffrey Sneddon, and contributors', 'html5lib', 'One line description of project.',
+ 'James Graham, Sam Sneddon, and contributors', 'html5lib', 'One line description of project.',
'Miscellaneous'),
]
From 5cd73ef383cdf9dd93f81a214b4bd364b579ff6d Mon Sep 17 00:00:00 2001
From: Sam Sneddon
Date: Thu, 28 May 2020 16:26:44 +0100
Subject: [PATCH 178/223] Drop datrie support (#455)
---
CHANGES.rst | 17 +++++++++++++++
README.rst | 3 ---
debug-info.py | 2 +-
html5lib/_trie/__init__.py | 13 ++---------
html5lib/_trie/datrie.py | 44 --------------------------------------
requirements-optional.txt | 6 ------
setup.py | 3 +--
7 files changed, 21 insertions(+), 67 deletions(-)
delete mode 100644 html5lib/_trie/datrie.py
diff --git a/CHANGES.rst b/CHANGES.rst
index 9442ba67..abc7bb18 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,23 @@
Change Log
----------
+1.1
+~~~
+
+UNRELEASED
+
+Breaking changes:
+
+* Drop support for Python 3.3. (#358)
+* Drop support for Python 3.4. (#421)
+
+Other changes:
+
+* Try to import from `collections.abc` to remove DeprecationWarning and ensure
+ `html5lib` keeps working in future Python versions. (#403)
+* Drop optional `datrie` dependency. (#442)
+
+
1.0.1
~~~~~
diff --git a/README.rst b/README.rst
index 2114cfc8..d367905d 100644
--- a/README.rst
+++ b/README.rst
@@ -107,9 +107,6 @@ Optional Dependencies
The following third-party libraries may be used for additional
functionality:
-- ``datrie`` can be used under CPython to improve parsing performance
- (though in almost all cases the improvement is marginal);
-
- ``lxml`` is supported as a tree format (for both building and
walking) under CPython (but *not* PyPy where it is known to cause
segfaults);
diff --git a/debug-info.py b/debug-info.py
index f93fbdbe..b47b8ebf 100644
--- a/debug-info.py
+++ b/debug-info.py
@@ -12,7 +12,7 @@
"maxsize": sys.maxsize
}
-search_modules = ["chardet", "datrie", "genshi", "html5lib", "lxml", "six"]
+search_modules = ["chardet", "genshi", "html5lib", "lxml", "six"]
found_modules = []
for m in search_modules:
diff --git a/html5lib/_trie/__init__.py b/html5lib/_trie/__init__.py
index a5ba4bf1..07bad5d3 100644
--- a/html5lib/_trie/__init__.py
+++ b/html5lib/_trie/__init__.py
@@ -1,14 +1,5 @@
from __future__ import absolute_import, division, unicode_literals
-from .py import Trie as PyTrie
+from .py import Trie
-Trie = PyTrie
-
-# pylint:disable=wrong-import-position
-try:
- from .datrie import Trie as DATrie
-except ImportError:
- pass
-else:
- Trie = DATrie
-# pylint:enable=wrong-import-position
+__all__ = ["Trie"]
diff --git a/html5lib/_trie/datrie.py b/html5lib/_trie/datrie.py
deleted file mode 100644
index 51f3d046..00000000
--- a/html5lib/_trie/datrie.py
+++ /dev/null
@@ -1,44 +0,0 @@
-from __future__ import absolute_import, division, unicode_literals
-
-from datrie import Trie as DATrie
-from six import text_type
-
-from ._base import Trie as ABCTrie
-
-
-class Trie(ABCTrie):
- def __init__(self, data):
- chars = set()
- for key in data.keys():
- if not isinstance(key, text_type):
- raise TypeError("All keys must be strings")
- for char in key:
- chars.add(char)
-
- self._data = DATrie("".join(chars))
- for key, value in data.items():
- self._data[key] = value
-
- def __contains__(self, key):
- return key in self._data
-
- def __len__(self):
- return len(self._data)
-
- def __iter__(self):
- raise NotImplementedError()
-
- def __getitem__(self, key):
- return self._data[key]
-
- def keys(self, prefix=None):
- return self._data.keys(prefix)
-
- def has_keys_with_prefix(self, prefix):
- return self._data.has_keys_with_prefix(prefix)
-
- def longest_prefix(self, prefix):
- return self._data.longest_prefix(prefix)
-
- def longest_prefix_item(self, prefix):
- return self._data.longest_prefix_item(prefix)
diff --git a/requirements-optional.txt b/requirements-optional.txt
index d8be39ff..2e78c952 100644
--- a/requirements-optional.txt
+++ b/requirements-optional.txt
@@ -11,9 +11,3 @@ chardet>=2.2
# lxml is supported with its own treebuilder ("lxml") and otherwise
# uses the standard ElementTree support
lxml ; platform_python_implementation == 'CPython'
-
-# DATrie can be used in place of our Python trie implementation for
-# slightly better parsing performance.
-# https://github.com/pytries/datrie/issues/52 although closed is not
-# yet released to https://pypi.org/project/datrie
-datrie ; platform_python_implementation == 'CPython' and python_version < '3.7'
diff --git a/setup.py b/setup.py
index d3841290..f84c1284 100644
--- a/setup.py
+++ b/setup.py
@@ -111,7 +111,6 @@ def default_environment():
extras_require={
# A conditional extra will only install these items when the extra is
# requested and the condition matches.
- "datrie:platform_python_implementation == 'CPython'": ["datrie"],
"lxml:platform_python_implementation == 'CPython'": ["lxml"],
# Standard extras, will be installed when the extra is requested.
@@ -123,6 +122,6 @@ def default_environment():
# extra that will be installed whenever the condition matches and the
# all extra is requested.
"all": ["genshi", "chardet>=2.2"],
- "all:platform_python_implementation == 'CPython'": ["datrie", "lxml"],
+ "all:platform_python_implementation == 'CPython'": ["lxml"],
},
)
From 93c35554d1284c824e86e9d6bcb074a8b4e463b0 Mon Sep 17 00:00:00 2001
From: Sam Sneddon
Date: Sun, 7 Jun 2020 17:51:33 +0100
Subject: [PATCH 179/223] Move to pytest4/5
This largely involves moving away from using generators as tests
---
.pytest.expect | 6 ++--
html5lib/tests/test_encoding.py | 21 +++++++------
html5lib/tests/test_sanitizer.py | 45 ++++++++++++++------------
html5lib/tests/test_serializer.py | 49 +++++++++++++++--------------
html5lib/tests/test_treewalkers.py | 39 ++++++++++++-----------
html5lib/tests/tree_construction.py | 12 +++----
requirements-test.txt | 45 +++++---------------------
7 files changed, 98 insertions(+), 119 deletions(-)
diff --git a/.pytest.expect b/.pytest.expect
index 0fa326f0..1b3705a7 100644
--- a/.pytest.expect
+++ b/.pytest.expect
@@ -1,7 +1,7 @@
pytest-expect file v1
-(2, 7, 11, 'final', 0)
-b'html5lib/tests/test_encoding.py::test_encoding::[110]': FAIL
-b'html5lib/tests/test_encoding.py::test_encoding::[111]': FAIL
+(2, 7, 18, 'final', 0)
+b'html5lib/tests/test_encoding.py::test_parser_encoding[\\n-iso-8859-2]': FAIL
+b'html5lib/tests/test_encoding.py::test_prescan_encoding[\\n-iso-8859-2]': FAIL
u'html5lib/tests/testdata/tokenizer/test2.test::0::dataState': FAIL
u'html5lib/tests/testdata/tokenizer/test3.test::228::dataState': FAIL
u'html5lib/tests/testdata/tokenizer/test3.test::231::dataState': FAIL
diff --git a/html5lib/tests/test_encoding.py b/html5lib/tests/test_encoding.py
index 9a411c77..47c4814a 100644
--- a/html5lib/tests/test_encoding.py
+++ b/html5lib/tests/test_encoding.py
@@ -75,7 +75,15 @@ def test_parser_args_raises(kwargs):
assert exc_info.value.args[0].startswith("Cannot set an encoding with a unicode input")
-def runParserEncodingTest(data, encoding):
+def param_encoding():
+ for filename in get_data_files("encoding"):
+ tests = _TestData(filename, b"data", encoding=None)
+ for test in tests:
+ yield test[b'data'], test[b'encoding']
+
+
+@pytest.mark.parametrize("data, encoding", param_encoding())
+def test_parser_encoding(data, encoding):
p = HTMLParser()
assert p.documentEncoding is None
p.parse(data, useChardet=False)
@@ -84,7 +92,8 @@ def runParserEncodingTest(data, encoding):
assert encoding == p.documentEncoding, errorMessage(data, encoding, p.documentEncoding)
-def runPreScanEncodingTest(data, encoding):
+@pytest.mark.parametrize("data, encoding", param_encoding())
+def test_prescan_encoding(data, encoding):
stream = _inputstream.HTMLBinaryInputStream(data, useChardet=False)
encoding = encoding.lower().decode("ascii")
@@ -95,14 +104,6 @@ def runPreScanEncodingTest(data, encoding):
assert encoding == stream.charEncoding[0].name, errorMessage(data, encoding, stream.charEncoding[0].name)
-def test_encoding():
- for filename in get_data_files("encoding"):
- tests = _TestData(filename, b"data", encoding=None)
- for test in tests:
- yield (runParserEncodingTest, test[b'data'], test[b'encoding'])
- yield (runPreScanEncodingTest, test[b'data'], test[b'encoding'])
-
-
# pylint:disable=wrong-import-position
try:
import chardet # noqa
diff --git a/html5lib/tests/test_sanitizer.py b/html5lib/tests/test_sanitizer.py
index 45046d57..9a8e7f2d 100644
--- a/html5lib/tests/test_sanitizer.py
+++ b/html5lib/tests/test_sanitizer.py
@@ -1,21 +1,11 @@
from __future__ import absolute_import, division, unicode_literals
+import pytest
+
from html5lib import constants, parseFragment, serialize
from html5lib.filters import sanitizer
-def runSanitizerTest(_, expected, input):
- parsed = parseFragment(expected)
- expected = serialize(parsed,
- omit_optional_tags=False,
- use_trailing_solidus=True,
- space_before_trailing_solidus=False,
- quote_attr_values="always",
- quote_char='"',
- alphabetical_attributes=True)
- assert expected == sanitize_html(input)
-
-
def sanitize_html(stream):
parsed = parseFragment(stream)
serialized = serialize(parsed,
@@ -59,7 +49,7 @@ def test_data_uri_disallowed_type():
assert expected == sanitized
-def test_sanitizer():
+def param_sanitizer():
for ns, tag_name in sanitizer.allowed_elements:
if ns != constants.namespaces["html"]:
continue
@@ -67,19 +57,19 @@ def test_sanitizer():
'tfoot', 'th', 'thead', 'tr', 'select']:
continue # TODO
if tag_name == 'image':
- yield (runSanitizerTest, "test_should_allow_%s_tag" % tag_name,
+ yield ("test_should_allow_%s_tag" % tag_name,
"foo <bad>bar</bad> baz",
"<%s title='1'>foo bar baz%s>" % (tag_name, tag_name))
elif tag_name == 'br':
- yield (runSanitizerTest, "test_should_allow_%s_tag" % tag_name,
+ yield ("test_should_allow_%s_tag" % tag_name,
" foo <bad>bar</bad> baz ",
"<%s title='1'>foo bar baz%s>" % (tag_name, tag_name))
elif tag_name in constants.voidElements:
- yield (runSanitizerTest, "test_should_allow_%s_tag" % tag_name,
+ yield ("test_should_allow_%s_tag" % tag_name,
"<%s title=\"1\"/>foo <bad>bar</bad> baz" % tag_name,
"<%s title='1'>foo bar baz%s>" % (tag_name, tag_name))
else:
- yield (runSanitizerTest, "test_should_allow_%s_tag" % tag_name,
+ yield ("test_should_allow_%s_tag" % tag_name,
"<%s title=\"1\">foo <bad>bar</bad> baz%s>" % (tag_name, tag_name),
"<%s title='1'>foo bar baz%s>" % (tag_name, tag_name))
@@ -93,7 +83,7 @@ def test_sanitizer():
attribute_value = 'foo'
if attribute_name in sanitizer.attr_val_is_uri:
attribute_value = '%s://sub.domain.tld/path/object.ext' % sanitizer.allowed_protocols[0]
- yield (runSanitizerTest, "test_should_allow_%s_attribute" % attribute_name,
+ yield ("test_should_allow_%s_attribute" % attribute_name,
"
This specification defines a big part of the Web platform, in lots of detail. Its place in the
+ Web platform specification stack relative to other specifications can be best summed up as
+ follows:
+
+
+
+
+
+
+
Is this HTML5?
+
+
+
+
In short: Yes.
+
+
In more length: The term "HTML5" is widely used as a buzzword to refer to modern Web
+ technologies, many of which (though by no means all) are developed at the WHATWG. This document is
+ one such; others are available from the WHATWG
+ specification index.
+
+
Although we have asked them to stop doing so, the W3C also republishes some parts
+ of this specification as separate documents. There are numerous differences between this
+ specification and the W3C forks; some minor, some major. Unfortunately these are not currently
+ accurately documented anywhere, so there is no way to know which are intentional and which are
+ not.
+
+
+
Background
+
+
+
+
HTML is the World Wide Web's core markup language. Originally, HTML was primarily designed as a
+ language for semantically describing scientific documents. Its general design, however, has
+ enabled it to be adapted, over the subsequent years, to describe a number of other types of
+ documents and even applications.
+
+
+
Audience
+
+
+
+
This specification is intended for authors of documents and scripts that use the features
+ defined in this specification, implementors of tools that operate on pages that
+ use the features defined in this specification, and individuals wishing to establish the
+ correctness of documents or implementations with respect to the requirements of this
+ specification.
+
+
This document is probably not suited to readers who do not already have at least a passing
+ familiarity with Web technologies, as in places it sacrifices clarity for precision, and brevity
+ for completeness. More approachable tutorials and authoring guides can provide a gentler
+ introduction to the topic.
+
+
In particular, familiarity with the basics of DOM is necessary for a complete understanding of
+ some of the more technical parts of this specification. An understanding of Web IDL, HTTP, XML,
+ Unicode, character encodings, JavaScript, and CSS will also be helpful in places but is not
+ essential.
+
+
+
Scope
+
+
+
+
This specification is limited to providing a semantic-level markup language and associated
+ semantic-level scripting APIs for authoring accessible pages on the Web ranging from static
+ documents to dynamic applications.
+
+
The scope of this specification does not include providing mechanisms for media-specific
+ customization of presentation (although default rendering rules for Web browsers are included at
+ the end of this specification, and several mechanisms for hooking into CSS are provided as part of
+ the language).
+
+
The scope of this specification is not to describe an entire operating system. In particular,
+ hardware configuration software, image manipulation tools, and applications that users would be
+ expected to use with high-end workstations on a daily basis are out of scope. In terms of
+ applications, this specification is targeted specifically at applications that would be expected
+ to be used by users on an occasional basis, or regularly but from disparate locations, with low
+ CPU requirements. Examples of such applications include online purchasing systems, searching
+ systems, games (especially multiplayer online games), public telephone books or address books,
+ communications software (e-mail clients, instant messaging clients, discussion software), document
+ editing software, etc.
+
+
+
History
+
+
+
+
For its first five years (1990-1995), HTML went through a number of revisions and experienced a
+ number of extensions, primarily hosted first at CERN, and then at the IETF.
+
+
With the creation of the W3C, HTML's development changed venue again. A first abortive attempt
+ at extending HTML in 1995 known as HTML 3.0 then made way to a more pragmatic approach known as
+ HTML 3.2, which was completed in 1997. HTML4 quickly followed later that same year.
+
+
The following year, the W3C membership decided to stop evolving HTML and instead begin work on
+ an XML-based equivalent, called XHTML. This
+ effort started with a reformulation of HTML4 in XML, known as XHTML 1.0, which added no new
+ features except the new serialisation, and which was completed in 2000. After XHTML 1.0, the W3C's
+ focus turned to making it easier for other working groups to extend XHTML, under the banner of
+ XHTML Modularization. In parallel with this, the W3C also worked on a new language that was not
+ compatible with the earlier HTML and XHTML languages, calling it XHTML2.
+
+
Around the time that HTML's evolution was stopped in 1998, parts of the API for HTML developed
+ by browser vendors were specified and published under the name DOM Level 1 (in 1998) and DOM Level
+ 2 Core and DOM Level 2 HTML (starting in 2000 and culminating in 2003). These efforts then petered
+ out, with some DOM Level 3 specifications published in 2004 but the working group being closed
+ before all the Level 3 drafts were completed.
+
+
In 2003, the publication of XForms, a technology which was positioned as the next generation of
+ Web forms, sparked a renewed interest in evolving HTML itself, rather than finding replacements
+ for it. This interest was borne from the realization that XML's deployment as a Web technology was
+ limited to entirely new technologies (like RSS and later Atom), rather than as a replacement for
+ existing deployed technologies (like HTML).
+
+
A proof of concept to show that it was possible to extend HTML4's forms to provide many of the
+ features that XForms 1.0 introduced, without requiring browsers to implement rendering engines
+ that were incompatible with existing HTML Web pages, was the first result of this renewed
+ interest. At this early stage, while the draft was already publicly available, and input was
+ already being solicited from all sources, the specification was only under Opera Software's
+ copyright.
+
+
The idea that HTML's evolution should be reopened was tested at a W3C workshop in 2004, where
+ some of the principles that underlie the HTML5 work (described below), as well as the
+ aforementioned early draft proposal covering just forms-related features, were presented to the
+ W3C jointly by Mozilla and Opera. The proposal was rejected on the grounds that the proposal
+ conflicted with the previously chosen direction for the Web's evolution; the W3C staff and
+ membership voted to continue developing XML-based replacements instead.
+
+
Shortly thereafter, Apple, Mozilla, and Opera jointly announced their intent to continue
+ working on the effort under the umbrella of a new venue called the WHATWG. A public mailing list
+ was created, and the draft was moved to the WHATWG site. The copyright was subsequently amended to
+ be jointly owned by all three vendors, and to allow reuse of the specification.
+
+
The WHATWG was based on several core principles, in particular that technologies need to be
+ backwards compatible, that specifications and implementations need to match even if this means
+ changing the specification rather than the implementations, and that specifications need to be
+ detailed enough that implementations can achieve complete interoperability without
+ reverse-engineering each other.
+
+
The latter requirement in particular required that the scope of the HTML5 specification include
+ what had previously been specified in three separate documents: HTML4, XHTML1, and DOM2 HTML. It
+ also meant including significantly more detail than had previously been considered the norm.
+
+
In 2006, the W3C indicated an interest to participate in the development of HTML5 after all,
+ and in 2007 formed a working group chartered to work with the WHATWG on the development of the
+ HTML5 specification. Apple, Mozilla, and Opera allowed the W3C to publish the specification under
+ the W3C copyright, while keeping a version with the less restrictive license on the WHATWG
+ site.
+
+
For a number of years, both groups then worked together. In 2011, however, the groups came to
+ the conclusion that they had different goals: the W3C wanted to publish a "finished" version of
+ "HTML5", while the WHATWG wanted to continue working on a Living Standard for HTML, continuously
+ maintaining the specification rather than freezing it in a state with known problems, and adding
+ new features as needed to evolve the platform.
+
+
Since then, the WHATWG has been working on this specification (amongst others), and the W3C has
+ been copying fixes made by the WHATWG into their fork of the document, as well as making other
+ changes, some intentional and some not, with no documentation listing or explaining the
+ differences.
+
+
+
+
Design notes
+
+
+
+
It must be admitted that many aspects of HTML appear at first glance to be nonsensical and
+ inconsistent.
+
+
HTML, its supporting DOM APIs, as well as many of its supporting technologies, have been
+ developed over a period of several decades by a wide array of people with different priorities
+ who, in many cases, did not know of each other's existence.
+
+
Features have thus arisen from many sources, and have not always been designed in especially
+ consistent ways. Furthermore, because of the unique characteristics of the Web, implementation
+ bugs have often become de-facto, and now de-jure, standards, as content is often unintentionally
+ written in ways that rely on them before they can be fixed.
+
+
Despite all this, efforts have been made to adhere to certain design goals. These are described
+ in the next few subsections.
+
+
+
+
Serializability of script execution
+
+
+
+
To avoid exposing Web authors to the complexities of multithreading, the HTML and DOM APIs are
+ designed such that no script can ever detect the simultaneous execution of other scripts. Even
+ with workers, the intent is that the behavior of implementations can
+ be thought of as completely serializing the execution of all scripts in all browsing contexts.
+
+
The navigator.yieldForStorageUpdates() method, in
+ this model, is equivalent to allowing other scripts to run while the calling script is
+ blocked.
+
+
+
+
Compliance with other specifications
+
+
+
+
This specification interacts with and relies on a wide variety of other specifications. In
+ certain circumstances, unfortunately, conflicting needs have led to this specification violating
+ the requirements of these other specifications. Whenever this has occurred, the transgressions
+ have each been noted as a "willful violation", and the reason for the violation has
+ been noted.
+
+
+
+
Extensibility
+
+
+
+
HTML has a wide array of extensibility mechanisms that can be used for adding semantics in a
+ safe manner:
+
+
+
+
Authors can use the class attribute to extend elements,
+ effectively creating their own elements, while using the most applicable existing "real" HTML
+ element, so that browsers and other tools that don't know of the extension can still support it
+ somewhat well. This is the tack used by microformats, for example.
+
+
Authors can include data for inline client-side scripts or server-side site-wide scripts
+ to process using the data-*="" attributes. These are guaranteed
+ to never be touched by browsers, and allow scripts to include data on HTML elements that scripts
+ can then look for and process.
+
+
Authors can use the <meta name="" content=""> mechanism to
+ include page-wide metadata by registering extensions to
+ the predefined set of metadata names.
+
+
Authors can use the rel="" mechanism to annotate
+ links with specific meanings by registering extensions to
+ the predefined set of link types. This is also used by microformats.
+
+
Authors can embed raw data using the <script type="">
+ mechanism with a custom type, for further handling by inline or server-side scripts.
+
+
Authors can create plugins and invoke them using the
+ embed element. This is how Flash works.
+
+
Authors can extend APIs using the JavaScript prototyping mechanism. This is widely used by
+ script libraries, for instance.
+
+
Authors can use the microdata feature (the itemscope="" and itemprop=""
+ attributes) to embed nested name-value pairs of data to be shared with other applications and
+ sites.
+
+
+
+
+
+
+
HTML vs XHTML
+
+
+
+
This specification defines an abstract language for describing documents and applications, and
+ some APIs for interacting with in-memory representations of resources that use this language.
+
+
The in-memory representation is known as "DOM HTML", or "the DOM" for short.
+
+
There are various concrete syntaxes that can be used to transmit resources that use this
+ abstract language, two of which are defined in this specification.
+
+
The first such concrete syntax is the HTML syntax. This is the format suggested for most
+ authors. It is compatible with most legacy Web browsers. If a document is transmitted with the
+ text/htmlMIME type, then it will be processed as an HTML document by
+ Web browsers. This specification defines the latest HTML syntax, known simply as "HTML".
+
+
The second concrete syntax is the XHTML syntax, which is an application of XML. When a document
+ is transmitted with an XML MIME type, such as application/xhtml+xml,
+ then it is treated as an XML document by Web browsers, to be parsed by an XML processor. Authors
+ are reminded that the processing for XML and HTML differs; in particular, even minor syntax errors
+ will prevent a document labeled as XML from being rendered fully, whereas they would be ignored in
+ the HTML syntax. This specification defines the latest XHTML syntax, known simply as "XHTML".
+
+
The DOM, the HTML syntax, and the XHTML syntax cannot all represent the same content. For
+ example, namespaces cannot be represented using the HTML syntax, but they are supported in the DOM
+ and in the XHTML syntax. Similarly, documents that use the noscript feature can be
+ represented using the HTML syntax, but cannot be represented with the DOM or in the XHTML syntax.
+ Comments that contain the string "-->" can only be represented in the
+ DOM, not in the HTML and XHTML syntaxes.
+
+
+
Structure of this specification
+
+
+
+
This specification is divided into the following major sections:
Documents are built from elements. These elements form a tree using the DOM. This section
+ defines the features of this DOM, as well as introducing the features common to all elements, and
+ the concepts used in defining elements.
Each element has a predefined meaning, which is explained in this section. Rules for authors
+ on how to use the element, along with user agent requirements for how to
+ handle each element, are also given. This includes large signature features of HTML such
+ as video playback and subtitles, form controls and form submission, and a 2D graphics API known
+ as the HTML canvas.
This specification introduces a mechanism for adding machine-readable annotations to
+ documents, so that tools can extract trees of name-value pairs from the document. This section
+ describes this mechanism and some algorithms that can be used to convert HTML
+ documents into other formats. This section also defines some sample Microdata vocabularies
+ for contact information, calendar events, and licensing works.
HTML documents can provide a number of mechanisms for users to interact with and modify
+ content, which are described in this section, such as how focus works, and drag-and-drop.
HTML documents do not exist in a vacuum — this section defines many of the features
+ that affect environments that deal with multiple pages, such as Web browsers and offline
+ caching of Web applications.
This section describes some mechanisms that applications written in HTML can use to
+ communicate with other applications from different domains running on the same client. It also
+ introduces a server-push event stream mechanism known as Server Sent Events or
+ EventSource, and a two-way full-duplex socket protocol for scripts known as Web
+ Sockets.
+
+
All of these features would be for naught if they couldn't be represented in a serialized
+ form and sent to other people, and so these sections define the syntaxes of HTML and XHTML, along with rules for how to parse content using those syntaxes.
This specification should be read like all other specifications. First, it should be read
+ cover-to-cover, multiple times. Then, it should be read backwards at least once. Then it should be
+ read by picking random sections from the contents list and following all the cross-references.
+
+
As described in the conformance requirements section below, this specification describes
+ conformance criteria for a variety of conformance classes. In particular, there are conformance
+ requirements that apply to producers, for example authors and the documents they create,
+ and there are conformance requirements that apply to consumers, for example Web browsers.
+ They can be distinguished by what they are requiring: a requirement on a producer states what is
+ allowed, while a requirement on a consumer states how software is to act.
+
+
+
+
For example, "the foo attribute's value must be a valid
+ integer" is a requirement on producers, as it lays out the allowed values; in contrast,
+ the requirement "the foo attribute's value must be parsed using the
+ rules for parsing integers" is a requirement on consumers, as it describes how to
+ process the content.
+
+
+
+
Requirements on producers have no bearing whatsoever on consumers.
+
+
+
+
Continuing the above example, a requirement stating that a particular attribute's value is
+ constrained to being a valid integer emphatically does not imply anything
+ about the requirements on consumers. It might be that the consumers are in fact required to treat
+ the attribute as an opaque string, completely unaffected by whether the value conforms to the
+ requirements or not. It might be (as in the previous example) that the consumers are required to
+ parse the value using specific rules that define how invalid (non-numeric in this case) values
+ are to be processed.
+
+
+
+
+
+
Typographic conventions
+
+
This is a definition, requirement, or explanation.
+
+
This is a note.
+
+
This is an example.
+
+
This is an open issue.
+
+
This is a warning.
+
+
interface Example {
+ // this is an IDL definition
+};
This is a note to authors describing the usage of an interface.
+
+
+
+
+
+
/* this is a CSS fragment */
+
+
The defining instance of a term is marked up like this. Uses of that
+ term are marked up like this or like this.
+
+
The defining instance of an element, attribute, or API is marked up like this. References to that element, attribute, or API are marked
+ up like this.
+
+
Other code fragments are marked up like this.
+
+
Variables are marked up like this.
+
+
In an algorithm, steps in synchronous sections are
+ marked with ⌛.
+
+
In some cases, requirements are given in the form of lists with conditions and corresponding
+ requirements. In such cases, the requirements that apply to a condition are always the first set
+ of requirements that follow the condition, even in the case of there being multiple sets of
+ conditions for those requirements. Such cases are presented as follows:
+
+
+
+
This is a condition
+
This is another condition
+
This is the requirement that applies to the conditions above.
+
+
This is a third condition
+
This is the requirement that applies to the third condition.
+
+
+
+
+
+
Privacy concerns
+
+
+
+
Some features of HTML trade user convenience for a measure of user privacy.
+
+
In general, due to the Internet's architecture, a user can be distinguished from another by the
+ user's IP address. IP addresses do not perfectly match to a user; as a user moves from device to
+ device, or from network to network, their IP address will change; similarly, NAT routing, proxy
+ servers, and shared computers enable packets that appear to all come from a single IP address to
+ actually map to multiple users. Technologies such as onion routing can be used to further
+ anonymise requests so that requests from a single user at one node on the Internet appear to come
+ from many disparate parts of the network.
+
+
However, the IP address used for a user's requests is not the only mechanism by which a user's
+ requests could be related to each other. Cookies, for example, are designed specifically to enable
+ this, and are the basis of most of the Web's session features that enable you to log into a site
+ with which you have an account.
+
+
There are other mechanisms that are more subtle. Certain characteristics of a user's system can
+ be used to distinguish groups of users from each other; by collecting enough such information, an
+ individual user's browser's "digital fingerprint" can be computed, which can be as good, if not
+ better, as an IP address in ascertaining which requests are from the same user.
+
+
Grouping requests in this manner, especially across multiple sites, can be used for both benign
+ (and even arguably positive) purposes, as well as for malevolent purposes. An example of a
+ reasonably benign purpose would be determining whether a particular person seems to prefer sites
+ with dog illustrations as opposed to sites with cat illustrations (based on how often they visit
+ the sites in question) and then automatically using the preferred illustrations on subsequent
+ visits to participating sites. Malevolent purposes, however, could include governments combining
+ information such as the person's home address (determined from the addresses they use when getting
+ driving directions on one site) with their apparent political affiliations (determined by
+ examining the forum sites that they participate in) to determine whether the person should be
+ prevented from voting in an election.
+
+
Since the malevolent purposes can be remarkably evil, user agent implementors are encouraged to
+ consider how to provide their users with tools to minimise leaking information that could be used
+ to fingerprint a user.
+
+
Unfortunately, as the first paragraph in this section implies, sometimes there is great benefit
+ to be derived from exposing the very information that can also be used for fingerprinting
+ purposes, so it's not as easy as simply blocking all possible leaks. For instance, the ability to
+ log into a site to post under a specific identity requires that the user's requests be
+ identifiable as all being from the same user, more or less by definition. More subtly, though,
+ information such as how wide text is, which is necessary for many effects that involve drawing
+ text onto a canvas (e.g. any effect that involves drawing a border around the text) also leaks
+ information that can be used to group a user's requests. (In this case, by potentially exposing,
+ via a brute force search, which fonts a user has installed, information which can vary
+ considerably from user to user.)
+
+
Features in this specification which can be used to
+ fingerprint the user are marked as this paragraph is.
+
+
+
+
Other features in the platform can be used for the same purpose, though, including, though not
+ limited to:
+
+
+
+
The exact list of which features a user agents supports.
+
+
The maximum allowed stack depth for recursion in script.
+
+
Features that describe the user's environment, like Media Queries and the Screen
+ object. [MQ][CSSOMVIEW]
+
+
The user's time zone.
+
+
+
+
+
+
A quick introduction to HTML
+
+
+
+
A basic HTML document looks like this:
+
+
<!DOCTYPE html>
+<html>
+ <head>
+ <title>Sample page</title>
+ </head>
+ <body>
+ <h1>Sample page</h1>
+ <p>This is a <a href="demo.html">simple</a> sample.</p>
+ <!-- this is a comment -->
+ </body>
+</html>
+
+
HTML documents consist of a tree of elements and text. Each element is denoted in the source by
+ a start tag, such as "<body>", and
+ an end tag, such as "</body>".
+ (Certain start tags and end tags can in certain cases be omitted and are implied by other tags.)
+
+
Tags have to be nested such that elements are all completely within each other, without
+ overlapping:
+
+
<p>This is <em>very <strong>wrong</em>!</strong></p>
+
<p>This <em>is <strong>correct</strong>.</em></p>
+
+
This specification defines a set of elements that can be used in HTML, along with rules about
+ the ways in which the elements can be nested.
+
+
Elements can have attributes, which control how the elements work. In the example below, there
+ is a hyperlink, formed using the a element and its href attribute:
+
+
<a href="demo.html">simple</a>
+
+
Attributes are placed inside the start tag, and consist
+ of a name and a value, separated by an "=" character.
+ The attribute value can remain unquoted if it doesn't contain space characters or any of "'`=< or
+ >. Otherwise, it has to be quoted using either single or double quotes.
+ The value, along with the "=" character, can be omitted altogether if the
+ value is the empty string.
+
+
<!-- empty attributes -->
+<input name=address disabled>
+<input name=address disabled="">
+
+<!-- attributes with a value -->
+<input name=address maxlength=200>
+<input name=address maxlength='200'>
+<input name=address maxlength="200">
+
+
HTML user agents (e.g. Web browsers) then parse this markup, turning it into a DOM
+ (Document Object Model) tree. A DOM tree is an in-memory representation of a document.
+
+
DOM trees contain several kinds of nodes, in particular a DocumentType node,
+ Element nodes, Text nodes, Comment nodes, and in some cases
+ ProcessingInstruction nodes.
The root element of this tree is the html element, which is the
+ element always found at the root of HTML documents. It contains two elements, head
+ and body, as well as a Text node between them.
+
+
There are many more Text nodes in the DOM tree than one would initially expect,
+ because the source contains a number of spaces (represented here by "␣") and line breaks
+ ("⏎") that all end up as Text nodes in the DOM. However, for historical
+ reasons not all of the spaces and line breaks in the original markup appear in the DOM. In
+ particular, all the whitespace before head start tag ends up being dropped silently,
+ and all the whitespace after the body end tag ends up placed at the end of the
+ body.
+
+
The head element contains a title element, which itself contains a
+ Text node with the text "Sample page". Similarly, the body element
+ contains an h1 element, a p element, and a comment.
+
+
+
+
This DOM tree can be manipulated from scripts in the page. Scripts (typically in JavaScript)
+ are small programs that can be embedded using the script element or using event
+ handler content attributes. For example, here is a form with a script that sets the value
+ of the form's output element to say "Hello World":
Each element in the DOM tree is represented by an object, and these objects have APIs so that
+ they can be manipulated. For instance, a link (e.g. the a element in the tree above)
+ can have its "href" attribute changed in several
+ ways:
+
+
var a = document.links[0]; // obtain the first link in the document
+a.href = 'sample.html'; // change the destination URL of the link
+a.protocol = 'https'; // change just the scheme part of the URL
+a.setAttribute('href', 'http://example.com/'); // change the content attribute directly
+
+
Since DOM trees are used as the way to represent HTML documents when they are processed and
+ presented by implementations (especially interactive implementations like Web browsers), this
+ specification is mostly phrased in terms of DOM trees, instead of the markup described above.
+
+
+
+
HTML documents represent a media-independent description of interactive content. HTML documents
+ might be rendered to a screen, or through a speech synthesiser, or on a braille display. To
+ influence exactly how such rendering takes place, authors can use a styling language such as
+ CSS.
+
+
In the following example, the page has been made yellow-on-blue using CSS.
+
+
<!DOCTYPE html>
+<html>
+ <head>
+ <title>Sample styled page</title>
+ <style>
+ body { background: navy; color: yellow; }
+ </style>
+ </head>
+ <body>
+ <h1>Sample styled page</h1>
+ <p>This page is just a demo.</p>
+ </body>
+</html>
+
+
For more details on how to use HTML, authors are encouraged to consult tutorials and guides.
+ Some of the examples included in this specification might also be of use, but the novice author is
+ cautioned that this specification, by necessity, defines the language with a level of detail that
+ might be difficult to understand at first.
+
+
+
+
+
Writing secure applications with HTML
+
+
+
+
When HTML is used to create interactive sites, care needs to be taken to avoid introducing
+ vulnerabilities through which attackers can compromise the integrity of the site itself or of the
+ site's users.
+
+
A comprehensive study of this matter is beyond the scope of this document, and authors are
+ strongly encouraged to study the matter in more detail. However, this section attempts to provide
+ a quick introduction to some common pitfalls in HTML application development.
+
+
The security model of the Web is based on the concept of "origins", and correspondingly many of
+ the potential attacks on the Web involve cross-origin actions. [ORIGIN]
+
+
+
+
Not validating user input
+
Cross-site scripting (XSS)
+
SQL injection
+
+
+
+
When accepting untrusted input, e.g. user-generated content such as text comments, values in
+ URL parameters, messages from third-party sites, etc, it is imperative that the data be
+ validated before use, and properly escaped when displayed. Failing to do this can allow a
+ hostile user to perform a variety of attacks, ranging from the potentially benign, such as
+ providing bogus user information like a negative age, to the serious, such as running scripts
+ every time a user looks at a page that includes the information, potentially propagating the
+ attack in the process, to the catastrophic, such as deleting all data in the server.
+
+
When writing filters to validate user input, it is imperative that filters always be
+ whitelist-based, allowing known-safe constructs and disallowing all other input. Blacklist-based
+ filters that disallow known-bad inputs and allow everything else are not secure, as not
+ everything that is bad is yet known (for example, because it might be invented in the
+ future).
+
+
+
+
For example, suppose a page looked at its URL's query string to determine what to display,
+ and the site then redirected the user to that page to display a message, as in:
If the attacker then convinced a victim user to visit this page, a script of the attacker's
+ choosing would run on the page. Such a script could do any number of hostile actions, limited
+ only by what the site offers: if the site is an e-commerce shop, for instance, such a script
+ could cause the user to unknowingly make arbitrarily many unwanted purchases.
+
+
This is called a cross-site scripting attack.
+
+
+
+
There are many constructs that can be used to try to trick a site into executing code. Here
+ are some that authors are encouraged to consider when writing whitelist filters:
+
+
+
+
When allowing harmless-seeming elements like img, it is important to whitelist
+ any provided attributes as well. If one allowed all attributes then an attacker could, for
+ instance, use the onload attribute to run arbitrary
+ script.
+
+
When allowing URLs to be provided (e.g. for links), the scheme of each URL also needs to be
+ explicitly whitelisted, as there are many schemes that can be abused. The most prominent
+ example is "javascript:", but user agents can
+ implement (and indeed, have historically implemented) others.
+
+
Allowing a base element to be inserted means any script elements
+ in the page with relative links can be hijacked, and similarly that any form submissions can
+ get redirected to a hostile site.
+
+
+
+
+
+
+
Cross-site request forgery (CSRF)
+
+
+
+
If a site allows a user to make form submissions with user-specific side-effects, for example
+ posting messages on a forum under the user's name, making purchases, or applying for a passport,
+ it is important to verify that the request was made by the user intentionally, rather than by
+ another site tricking the user into making the request unknowingly.
+
+
This problem exists because HTML forms can be submitted to other origins.
+
+
Sites can prevent such attacks by populating forms with user-specific hidden tokens, or by
+ checking Origin headers on all requests.
+
+
+
+
+
+
Clickjacking
+
+
+
+
A page that provides users with an interface to perform actions that the user might not wish
+ to perform needs to be designed so as to avoid the possibility that users can be tricked into
+ activating the interface.
+
+
One way that a user could be so tricked is if a hostile site places the victim site in a
+ small iframe and then convinces the user to click, for instance by having the user
+ play a reaction game. Once the user is playing the game, the hostile site can quickly position
+ the iframe under the mouse cursor just as the user is about to click, thus tricking the user
+ into clicking the victim site's interface.
+
+
To avoid this, sites that do not expect to be used in frames are encouraged to only enable
+ their interface if they detect that they are not in a frame (e.g. by comparing the window object to the value of the top
+ attribute).
+
+
+
+
+
+
+
+
Common pitfalls to avoid when using the scripting APIs
+
+
+
+
Scripts in HTML have "run-to-completion" semantics, meaning that the browser will generally run
+ the script uninterrupted before doing anything else, such as firing further events or continuing
+ to parse the document.
+
+
On the other hand, parsing of HTML files happens asynchronously and incrementally, meaning that
+ the parser can pause at any point to let scripts run. This is generally a good thing, but it does
+ mean that authors need to be careful to avoid hooking event handlers after the events could have
+ possibly fired.
+
+
There are two techniques for doing this reliably: use event handler content
+ attributes, or create the element and add the event handlers in the same script. The latter
+ is safe because, as mentioned earlier, scripts are run to completion before further events can
+ fire.
+
+
+
+
One way this could manifest itself is with img elements and the load event. The event could fire as soon as the element has been
+ parsed, especially if the image has already been cached (which is common).
+
+
Here, the author uses the onload handler on an
+ img element to catch the load event:
If the element is being added by script, then so long as the event handlers are added in the
+ same script, the event will still not be missed:
+
+
<script>
+ var img = new Image();
+ img.src = 'games.png';
+ img.alt = 'Games';
+ img.onload = gamesLogoHasLoaded;
+ // img.addEventListener('load', gamesLogoHasLoaded, false); // would work also
+</script>
+
+
However, if the author first created the img element and then in a separate
+ script added the event listeners, there's a chance that the load
+ event would be fired in between, leading it to be missed:
+
+
<!-- Do not use this style, it has a race condition! -->
+ <img id="games" src="games.png" alt="Games">
+ <!-- the 'load' event might fire here while the parser is taking a
+ break, in which case you will not see it! -->
+ <script>
+ var img = document.getElementById('games');
+ img.onload = gamesLogoHasLoaded; // might never fire!
+ </script>
+
+
+
+
+
+
How to catch mistakes when writing HTML: validators and conformance checkers
+
+
+
+
Authors are encouraged to make use of conformance checkers (also known as validators) to
+ catch common mistakes. The WHATWG maintains a list of such tools at: http://validator.whatwg.org/
+
+
+
+
Conformance requirements for authors
+
+
+
+
Unlike previous versions of the HTML specification, this specification defines in some detail
+ the required processing for invalid documents as well as valid documents.
+
+
However, even though the processing of invalid content is in most cases well-defined,
+ conformance requirements for documents are still important: in practice, interoperability (the
+ situation in which all implementations process particular content in a reliable and identical or
+ equivalent way) is not the only goal of document conformance requirements. This section details
+ some of the more common reasons for still distinguishing between a conforming document and one
+ with errors.
+
+
+
Presentational markup
+
+
+
+
The majority of presentational features from previous versions of HTML are no longer allowed.
+ Presentational markup in general has been found to have a number of problems:
+
+
+
+
The use of presentational elements leads to poorer accessibility
+
+
+
+
While it is possible to use presentational markup in a way that provides users of assistive
+ technologies (ATs) with an acceptable experience (e.g. using ARIA), doing so is significantly
+ more difficult than doing so when using semantically-appropriate markup. Furthermore, even using
+ such techniques doesn't help make pages accessible for non-AT non-graphical users, such as users
+ of text-mode browsers.
+
+
Using media-independent markup, on the other hand, provides an easy way for documents to be
+ authored in such a way that they work for more users (e.g. text browsers).
+
+
+
+
+
Higher cost of maintenance
+
+
+
+
It is significantly easier to maintain a site written in such a way that the markup is
+ style-independent. For example, changing the colour of a site that uses
+ <font color=""> throughout requires changes across the entire site, whereas
+ a similar change to a site based on CSS can be done by changing a single file.
+
+
+
+
+
Larger document sizes
+
+
+
+
Presentational markup tends to be much more redundant, and thus results in larger document
+ sizes.
+
+
+
+
+
+
For those reasons, presentational markup has been removed from HTML in this version. This
+ change should not come as a surprise; HTML4 deprecated presentational markup many years ago and
+ provided a mode (HTML4 Transitional) to help authors move away from presentational markup; later,
+ XHTML 1.1 went further and obsoleted those features altogether.
+
+
The only remaining presentational markup features in HTML are the style attribute and the style element. Use of the style attribute is somewhat discouraged in production environments, but
+ it can be useful for rapid prototyping (where its rules can be directly moved into a separate
+ style sheet later) and for providing specific styles in unusual cases where a separate style sheet
+ would be inconvenient. Similarly, the style element can be useful in syndication or
+ for page-specific styles, but in general an external style sheet is likely to be more convenient
+ when the styles apply to multiple pages.
+
+
It is also worth noting that some elements that were previously presentational have been
+ redefined in this specification to be media-independent: b, i,
+ hr, s, small, and u.
+
+
+
Syntax errors
+
+
+
+
The syntax of HTML is constrained to avoid a wide variety of problems.
+
+
+
+
Unintuitive error-handling behavior
+
+
+
+
Certain invalid syntax constructs, when parsed, result in DOM trees that are highly
+ unintuitive.
+
+
+
+
For example, the following markup fragment results in a DOM with an hr element
+ that is an earlier sibling of the corresponding table element:
+
+
<table><hr>...
+
+
+
+
+
+
+
Errors with optional error recovery
+
+
+
+
To allow user agents to be used in controlled environments without having to implement the
+ more bizarre and convoluted error handling rules, user agents are permitted to fail whenever
+ encountering a parse error.
+
+
+
+
+
Errors where the error-handling behavior is not compatible with streaming user agents
+
+
+
+
Some error-handling behavior, such as the behavior for the <table><hr>... example mentioned above, are incompatible with streaming
+ user agents (user agents that process HTML files in one pass, without storing state). To avoid
+ interoperability problems with such user agents, any syntax resulting in such behavior is
+ considered invalid.
+
+
+
+
+
Errors that can result in infoset coercion
+
+
+
+
When a user agent based on XML is connected to an HTML parser, it is possible that certain
+ invariants that XML enforces, such as comments never containing two consecutive hyphens, will be
+ violated by an HTML file. Handling this can require that the parser coerce the HTML DOM into an
+ XML-compatible infoset. Most syntax constructs that require such handling are considered
+ invalid.
+
+
+
+
+
Errors that result in disproportionally poor performance
+
+
+
+
Certain syntax constructs can result in disproportionally poor performance. To discourage the
+ use of such constructs, they are typically made non-conforming.
+
+
+
+
For example, the following markup results in poor performance, since all the unclosed
+ i elements have to be reconstructed in each paragraph, resulting in progressively
+ more elements in each paragraph:
+
+
<p><i>He dreamt.
+<p><i>He dreamt that he ate breakfast.
+<p><i>Then lunch.
+<p><i>And finally dinner.
+
+
The resulting DOM for this fragment would be:
+
+
p
i
#text: He dreamt.
p
i
i
#text: He dreamt that he ate breakfast.
p
i
i
i
#text: Then lunch.
p
i
i
i
i
#text: And finally dinner.
+
+
+
+
+
+
+
Errors involving fragile syntax constructs
+
+
+
+
There are syntax constructs that, for historical reasons, are relatively fragile. To help
+ reduce the number of users who accidentally run into such problems, they are made
+ non-conforming.
+
+
+
+
For example, the parsing of certain named character references in attributes happens even
+ with the closing semicolon being omitted. It is safe to include an ampersand followed by
+ letters that do not form a named character reference, but if the letters are changed to a
+ string that does form a named character reference, they will be interpreted as that
+ character instead.
+
+
In this fragment, the attribute's value is "?bill&ted":
To avoid this problem, all named character references are required to end with a semicolon,
+ and uses of named character references without a semicolon are flagged as errors.
+
+
Thus, the correct way to express the above cases is as
+ follows:
+
+
<a href="?bill&ted">Bill and Ted</a> <!-- &ted is ok, since it's not a named character reference -->
Errors involving known interoperability problems in legacy user agents
+
+
+
+
Certain syntax constructs are known to cause especially subtle or serious problems in legacy
+ user agents, and are therefore marked as non-conforming to help authors avoid them.
+
+
+
+
For example, this is why the U+0060 GRAVE ACCENT character (`) is not allowed in unquoted
+ attributes. In certain legacy user agents, it is sometimes treated as a
+ quote character.
+
+
+
+
+
+
Another example of this is the DOCTYPE, which is required to trigger no-quirks
+ mode, because the behavior of legacy user agents in quirks mode is often
+ largely undocumented.
+
+
+
+
+
+
+
+
Errors that risk exposing authors to security attacks
+
+
+
+
Certain restrictions exist purely to avoid known security problems.
+
+
+
+
For example, the restriction on using UTF-7 exists purely to avoid authors falling prey to a
+ known cross-site-scripting attack using UTF-7. [UTF7]
+
+
+
+
+
+
+
+
Cases where the author's intent is unclear
+
+
+
+
Markup where the author's intent is very unclear is often made non-conforming. Correcting
+ these errors early makes later maintenance easier.
+
+
+
+
For example, it is unclear whether the author intended the following to be an
+ h1 heading or an h2 heading:
+
+
<h1>Contact details</h2>
+
+
+
+
+
+
+
Cases that are likely to be typos
+
+
+
+
When a user makes a simple typo, it is helpful if the error can be caught early, as this can
+ save the author a lot of debugging time. This specification therefore usually considers it an
+ error to use element names, attribute names, and so forth, that do not match the names defined
+ in this specification.
+
+
+
+
For example, if the author typed <capton> instead of
+ <caption>, this would be flagged as an error and the author could correct the
+ typo immediately.
+
+
+
+
+
+
+
Errors that could interfere with new syntax in the future
+
+
+
+
In order to allow the language syntax to be extended in the future, certain otherwise
+ harmless features are disallowed.
+
+
+
+
For example, "attributes" in end tags are ignored currently, but they are invalid, in case a
+ future change to the language makes use of that syntax feature without conflicting with
+ already-deployed (and valid!) content.
+
+
+
+
+
+
+
+
+
Some authors find it helpful to be in the practice of always quoting all attributes and always
+ including all optional tags, preferring the consistency derived from such custom over the minor
+ benefits of terseness afforded by making use of the flexibility of the HTML syntax. To aid such
+ authors, conformance checkers can provide modes of operation wherein such conventions are
+ enforced.
+
+
+
+
Restrictions on content models and on attribute values
+
+
+
+
Beyond the syntax of the language, this specification also places restrictions on how elements
+ and attributes can be specified. These restrictions are present for similar reasons:
+
+
+
+
+
Errors involving content with dubious semantics
+
+
+
+
To avoid misuse of elements with defined meanings, content models are defined that restrict
+ how elements can be nested when such nestings would be of dubious value.
+
+
For example, this specification disallows nesting a section
+ element inside a kbd element, since it is highly unlikely for an author to indicate
+ that an entire section should be keyed in.
+
+
+
+
+
Errors that involve a conflict in expressed semantics
+
+
+
+
Similarly, to draw the author's attention to mistakes in the use of elements, clear
+ contradictions in the semantics expressed are also considered conformance errors.
+
+
+
+
In the fragments below, for example, the semantics are nonsensical: a separator cannot
+ simultaneously be a cell, nor can a radio button be a progress bar.
+
+
<hr role="cell">
+
<input type=radio role=progressbar>
+
+
+
+
Another example is the restrictions on the content models of the
+ ul element, which only allows li element children. Lists by definition
+ consist just of zero or more list items, so if a ul element contains something
+ other than an li element, it's not clear what was meant.
+
+
+
+
+
Cases where the default styles are likely to lead to confusion
+
+
+
+
Certain elements have default styles or behaviors that make certain combinations likely to
+ lead to confusion. Where these have equivalent alternatives without this problem, the confusing
+ combinations are disallowed.
+
+
For example, div elements are rendered as block boxes, and
+ span elements as inline boxes. Putting a block box in an inline box is
+ unnecessarily confusing; since either nesting just div elements, or nesting just
+ span elements, or nesting span elements inside div
+ elements all serve the same purpose as nesting a div element in a span
+ element, but only the latter involves a block box in an inline box, the latter combination is
+ disallowed.
+
+
Another example would be the way interactive content cannot be
+ nested. For example, a button element cannot contain a textarea
+ element. This is because the default behavior of such nesting interactive elements would be
+ highly confusing to users. Instead of nesting these elements, they can be placed side by
+ side.
+
+
+
+
+
Errors that indicate a likely misunderstanding of the specification
+
+
+
+
Sometimes, something is disallowed because allowing it would likely cause author
+ confusion.
+
+
For example, setting the disabled
+ attribute to the value "false" is disallowed, because despite the
+ appearance of meaning that the element is enabled, it in fact means that the element is
+ disabled (what matters for implementations is the presence of the attribute, not its
+ value).
+
+
+
+
+
Errors involving limits that have been imposed merely to simplify the language
+
+
+
+
Some conformance errors simplify the language that authors need to learn.
+
+
For example, the area element's shape attribute, despite accepting both circ and circle values in practice as synonyms, disallows
+ the use of the circ value, so as to simplify
+ tutorials and other learning aids. There would be no benefit to allowing both, but it would
+ cause extra confusion when teaching the language.
+
+
+
+
+
Errors that involve peculiarities of the parser
+
+
+
+
Certain elements are parsed in somewhat eccentric ways (typically for historical reasons),
+ and their content model restrictions are intended to avoid exposing the author to these
+ issues.
+
+
+
+
For example, a form element isn't allowed inside phrasing content,
+ because when parsed as HTML, a form element's start tag will imply a
+ p element's end tag. Thus, the following markup results in two paragraphs, not one:
Errors that would likely result in scripts failing in hard-to-debug ways
+
+
+
+
Some errors are intended to help prevent script problems that would be hard to debug.
+
+
This is why, for instance, it is non-conforming to have two id attributes with the same value. Duplicate IDs lead to the wrong
+ element being selected, with sometimes disastrous effects whose cause is hard to determine.
+
+
+
+
+
Errors that waste authoring time
+
+
+
+
Some constructs are disallowed because historically they have been the cause of a lot of
+ wasted authoring time, and by encouraging authors to avoid making them, authors can save time in
+ future efforts.
+
+
For example, a script element's src attribute causes the element's contents to be ignored.
+ However, this isn't obvious, especially if the element's contents appear to be executable script
+ — which can lead to authors spending a lot of time trying to debug the inline script
+ without realizing that it is not executing. To reduce this problem, this specification makes it
+ non-conforming to have executable script in a script element when the src attribute is present. This means that authors who are
+ validating their documents are less likely to waste time with this kind of mistake.
+
+
+
+
+
Errors that involve areas that affect authors migrating to and from XHTML
+
+
+
+
Some authors like to write files that can be interpreted as both XML and HTML with similar
+ results. Though this practice is discouraged in general due to the myriad of subtle
+ complications involved (especially when involving scripting, styling, or any kind of automated
+ serialisation), this specification has a few restrictions intended to at least somewhat mitigate
+ the difficulties. This makes it easier for authors to use this as a transitionary step when
+ migrating between HTML and XHTML.
+
+
For example, there are somewhat complicated rules surrounding the lang and xml:lang attributes
+ intended to keep the two synchronized.
+
+
Another example would be the restrictions on the values of xmlns attributes in the HTML serialisation, which are intended to ensure that
+ elements in conforming documents end up in the same namespaces whether processed as HTML or
+ XML.
+
+
+
+
+
Errors that involve areas reserved for future expansion
+
+
+
+
As with the restrictions on the syntax intended to allow for new syntax in future revisions
+ of the language, some restrictions on the content models of elements and values of attributes
+ are intended to allow for future expansion of the HTML vocabulary.
+
+
For example, limiting the values of the target attribute that start with an U+005F LOW LINE
+ character (_) to only specific predefined values allows new predefined values to be introduced
+ at a future time without conflicting with author-defined values.
+
+
+
+
+
Errors that indicate a mis-use of other specifications
+
+
+
+
Certain restrictions are intended to support the restrictions made by other
+ specifications.
+
+
For example, requiring that attributes that take media queries use only
+ valid media queries reinforces the importance of following the conformance rules of
+ that specification.
+
+
+
+
+
+
+
+
Suggested reading
+
+
+
+
The following documents might be of interest to readers of this specification.
+
+
+
+
Character Model for the World Wide Web 1.0: Fundamentals [CHARMOD]
+
+
This Architectural Specification provides authors of specifications, software
+ developers, and content developers with a common reference for interoperable text manipulation on
+ the World Wide Web, building on the Universal Character Set, defined jointly by the Unicode
+ Standard and ISO/IEC 10646. Topics addressed include use of the terms 'character', 'encoding' and
+ 'string', a reference processing model, choice and identification of character encodings,
+ character escaping, and string indexing.
Because Unicode contains such a large number of characters and incorporates
+ the varied writing systems of the world, incorrect usage can expose programs or systems to
+ possible security attacks. This is especially important as more and more products are
+ internationalized. This document describes some of the security considerations that programmers,
+ system analysts, standards developers, and users should take into account, and provides specific
+ recommendations to reduce the risk of problems.
+
+
Web Content Accessibility Guidelines (WCAG) 2.0 [WCAG]
+
+
Web Content Accessibility Guidelines (WCAG) 2.0 covers a wide range of
+ recommendations for making Web content more accessible. Following these guidelines will make
+ content accessible to a wider range of people with disabilities, including blindness and low
+ vision, deafness and hearing loss, learning disabilities, cognitive limitations, limited
+ movement, speech disabilities, photosensitivity and combinations of these. Following these
+ guidelines will also often make your Web content more usable to users in
+ general.
This specification provides guidelines for designing Web content
+ authoring tools that are more accessible for people with disabilities. An authoring tool that
+ conforms to these guidelines will promote accessibility by providing an accessible user interface
+ to authors with disabilities as well as by enabling, supporting, and promoting the production of
+ accessible Web content by all authors.
+
+
User Agent Accessibility Guidelines (UAAG) 2.0 [UAAG]
+
+
This document provides guidelines for designing user agents that
+ lower barriers to Web accessibility for people with disabilities. User agents include browsers
+ and other types of software that retrieve and render Web content. A user agent that conforms to
+ these guidelines will promote accessibility through its own user interface and through other
+ internal facilities, including its ability to communicate with other technologies (especially
+ assistive technologies). Furthermore, all users, not just users with disabilities, should find
+ conforming user agents to be more usable.
+
+
+
+
+
+
Common infrastructure
+
+
Terminology
+
+
This specification refers to both HTML and XML attributes and IDL attributes, often in the same
+ context. When it is not clear which is being referred to, they are referred to as content attributes for HTML and XML attributes, and IDL
+ attributes for those defined on IDL interfaces. Similarly, the term "properties" is used for
+ both JavaScript object properties and CSS properties. When these are ambiguous they are qualified
+ as object properties and CSS properties respectively.
+
+
Generally, when the specification states that a feature applies to the HTML syntax
+ or the XHTML syntax, it also includes the other. When a feature specifically only
+ applies to one of the two languages, it is called out by explicitly stating that it does not apply
+ to the other format, as in "for HTML, ... (this does not apply to XHTML)".
+
+
This specification uses the term document to refer to any use of HTML,
+ ranging from short static documents to long essays or reports with rich multimedia, as well as to
+ fully-fledged interactive applications. The term is used to refer both to Document
+ objects and their descendant DOM trees, and to serialised byte streams using the HTML syntax or XHTML syntax, depending
+ on context.
+
+
In the context of the DOM structures, the terms HTML
+ document and XML document are used as defined in the DOM
+ specification, and refer specifically to two different modes that Document objects
+ can find themselves in. [DOM] (Such uses are always hyperlinked to their
+ definition.)
+
+
In the context of byte streams, the term HTML document refers to resources labeled as
+ text/html, and the term XML document refers to resources labeled with an XML
+ MIME type.
+
+
The term XHTML document is used to refer to both Documents in the XML document mode that contains element nodes in the HTML
+ namespace, and byte streams labeled with an XML MIME type that contain
+ elements from the HTML namespace, depending on context.
+
+
+
+
For simplicity, terms such as shown, displayed, and
+ visible might sometimes be used when referring to the way a document is
+ rendered to the user. These terms are not meant to imply a visual medium; they must be considered
+ to apply to other media in equivalent ways.
+
+
+
+
When an algorithm B says to return to another algorithm A, it implies that A called B. Upon
+ returning to A, the implementation must continue from where it left off in calling B.
+
+
+
+
+
The term "transparent black" refers to the colour with red, green, blue, and alpha channels all
+ set to zero.
+
+
+
Resources
+
+
The specification uses the term supported when referring to whether a user
+ agent has an implementation capable of decoding the semantics of an external resource. A format or
+ type is said to be supported if the implementation can process an external resource of that
+ format or type without critical aspects of the resource being ignored. Whether a specific resource
+ is supported can depend on what features of the resource's format are in use.
+
+
For example, a PNG image would be considered to be in a supported format if its
+ pixel data could be decoded and rendered, even if, unbeknownst to the implementation, the image
+ also contained animation data.
+
+
An MPEG-4 video file would not be considered to be in a supported format if the
+ compression format used was not supported, even if the implementation could determine the
+ dimensions of the movie from the file's metadata.
+
+
What some specifications, in particular the HTTP specification, refer to as a
+ representation is referred to in this specification as a resource. [HTTP]
+
+
The term MIME type is used to refer to what is sometimes called an Internet media
+ type in protocol literature. The term media type in this specification is used to refer
+ to the type of media intended for presentation, as used by the CSS specifications. [RFC2046][MQ]
+
+
A string is a valid MIME type if it matches the media-type
+ rule defined in section 3.7 "Media Types" of RFC 2616. In particular, a valid MIME
+ type may include MIME type parameters. [HTTP]
+
+
A string is a valid MIME type with no parameters if it matches the media-type rule defined in section 3.7 "Media Types" of RFC 2616, but does not
+ contain any U+003B SEMICOLON characters (;). In other words, if it consists only of a type and
+ subtype, with no MIME Type parameters. [HTTP]
+
+
The term HTML MIME type is used to refer to the MIME type
+ text/html.
+
+
A resource's critical subresources are those that the resource needs to have
+ available to be correctly processed. Which resources are considered critical or not is defined by
+ the specification that defines the resource's format.
+
+
The term data: URL refers to URLs that use the data: scheme. [RFC2397]
+
+
+
XML
+
+
To ease migration from HTML to XHTML, UAs conforming to this specification
+ will place elements in HTML in the http://www.w3.org/1999/xhtml namespace, at least
+ for the purposes of the DOM and CSS. The term "HTML elements", when used in this
+ specification, refers to any element in that namespace, and thus refers to both HTML and XHTML
+ elements.
+
+
Except where otherwise stated, all elements defined or mentioned in this specification are in
+ the HTML namespace ("http://www.w3.org/1999/xhtml"), and all attributes
+ defined or mentioned in this specification have no namespace.
+
+
The term element type is used to refer to the set of elements that have a given
+ local name and namespace. For example, button elements are elements with the element
+ type button, meaning they have the local name "button" and
+ (implicitly as defined above) the HTML namespace.
+
+
Attribute names are said to be XML-compatible if they match the Name production defined in XML
+ and they contain no U+003A COLON characters (:). [XML]
+
+
The term XML MIME type is used to refer to the MIME
+ typestext/xml, application/xml, and any
+ MIME type whose subtype ends with the four characters "+xml".
+ [RFC3023]
+
+
+
DOM trees
+
+
The root element of a Document object is that Document's
+ first element child, if any. If it does not have one then the Document has no root
+ element.
+
+
The term root element, when not referring to a Document object's root
+ element, means the furthest ancestor element node of whatever node is being discussed, or the node
+ itself if it has no ancestors. When the node is a part of the document, then the node's root
+ element is indeed the document's root element; however, if the node is not currently part
+ of the document tree, the root element will be an orphaned node.
+
+
When an element's root element is the root element of a
+ Document object, it is said to be in a Document. An
+ element is said to have been inserted into a
+ document when its root element changes and is now the document's root
+ element. Analogously, an element is said to have been removed from a document when its root element changes from being the
+ document's root element to being another element.
+
+
A node's home subtree is the subtree rooted at that node's root
+ element. When a node is in a Document, its home
+ subtree is that Document's tree.
+
+
The Document of a Node (such as an element) is the
+ Document that the Node's ownerDocument IDL attribute returns. When a
+ Node is in a Document then that Document is
+ always the Node's Document, and the Node's ownerDocument IDL attribute thus always returns that
+ Document.
+
+
The Document of a content attribute is the Document of the
+ attribute's element.
+
+
The term tree order means a pre-order, depth-first traversal of DOM nodes involved
+ (through the parentNode/childNodes relationship).
+
+
When it is stated that some element or attribute is ignored, or
+ treated as some other value, or handled as if it was something else, this refers only to the
+ processing of the node after it is in the DOM. A user agent must not mutate the
+ DOM in such situations.
+
+
A content attribute is said to change value only if its new value is
+ different than its previous value; setting an attribute to a value it already has does not change
+ it.
+
+
The term empty, when used of an attribute value, Text node, or
+ string, means that the length of the text is zero (i.e. not even containing spaces or control
+ characters).
+
+
+
Scripting
+
+
The construction "a Foo object", where Foo is actually an interface,
+ is sometimes used instead of the more accurate "an object implementing the interface
+ Foo".
+
+
An IDL attribute is said to be getting when its value is being retrieved
+ (e.g. by author script), and is said to be setting when a new value is
+ assigned to it.
+
+
If a DOM object is said to be live, then the attributes and methods on that object
+ must operate on the actual underlying data, not a snapshot of the
+ data.
+
+
In the contexts of events, the terms fire and dispatch are used as defined in the
+ DOM specification: firing an event means to create and dispatch it, and dispatching an event means to follow the steps that propagate
+ the event through the tree. The term trusted event is
+ used to refer to events whose isTrusted attribute is
+ initialised to true. [DOM]
+
+
+
Plugins
+
+
The term plugin refers to a user-agent defined set of content handlers used by the
+ user agent that can take part in the user agent's rendering of a Document object, but
+ that neither act as child browsing contexts of the
+ Document nor introduce any Node objects to the Document's
+ DOM.
+
+
Typically such content handlers are provided by third parties, though a user agent can also
+ designate built-in content handlers as plugins.
+
+
+
+
A user agent must not consider the types text/plain and
+ application/octet-stream as having a registered plugin.
+
+
+
+
One example of a plugin would be a PDF viewer that is instantiated in a
+ browsing context when the user navigates to a PDF file. This would count as a plugin
+ regardless of whether the party that implemented the PDF viewer component was the same as that
+ which implemented the user agent itself. However, a PDF viewer application that launches separate
+ from the user agent (as opposed to using the same interface) is not a plugin by this
+ definition.
+
+
This specification does not define a mechanism for interacting with plugins, as it
+ is expected to be user-agent- and platform-specific. Some UAs might opt to support a plugin
+ mechanism such as the Netscape Plugin API; others might use remote content converters or have
+ built-in support for certain types. Indeed, this specification doesn't require user agents to
+ support plugins at all. [NPAPI]
+
+
A plugin can be secured if it honors the semantics of
+ the sandbox attribute.
+
+
For example, a secured plugin would prevent its contents from creating pop-up
+ windows when the plugin is instantiated inside a sandboxed iframe.
+
+
+
+
Browsers should take extreme care when interacting with external content
+ intended for plugins. When third-party software is run with the same
+ privileges as the user agent itself, vulnerabilities in the third-party software become as
+ dangerous as those in the user agent.
+
+
Since different users having differents sets of plugins provides a
+ fingerprinting vector that increases the chances of users being uniquely identified, user agents
+ are encouraged to support the exact same set of plugins for each
+ user.
+
+
+
+
+
+
+
+
Character encodings
+
+
A character encoding, or just encoding where that is not
+ ambiguous, is a defined way to convert between byte streams and Unicode strings, as defined in the
+ WHATWG Encoding standard. An encoding has an encoding name and one or more
+ encoding labels, referred to as the encoding's name and
+ labels in the Encoding standard. [ENCODING]
+
+
An ASCII-compatible character encoding is a single-byte or variable-length
+ encoding in which the bytes 0x09, 0x0A, 0x0C, 0x0D, 0x20 - 0x22, 0x26, 0x27, 0x2C -
+ 0x3F, 0x41 - 0x5A, and 0x61 - 0x7A, ignoring bytes that are the second and later bytes of multibyte
+ sequences, all correspond to single-byte sequences that map to the same Unicode characters as
+ those bytes in Windows-1252. [ENCODING]
+
+
This includes such encodings as Shift_JIS, HZ-GB-2312, and variants of ISO-2022,
+ even though it is possible in these encodings for bytes like 0x70 to be part of longer sequences
+ that are unrelated to their interpretation as ASCII. It excludes UTF-16 variants, as well as
+ obsolete legacy encodings such as UTF-7, GSM03.38, and EBCDIC variants.
+
+
+
+
The term a UTF-16 encoding refers to any variant of UTF-16: UTF-16LE or UTF-16BE,
+ regardless of the presence or absence of a BOM. [ENCODING]
+
+
The term code unit is used as defined in the Web IDL specification: a 16 bit
+ unsigned integer, the smallest atomic component of a DOMString. (This is a narrower
+ definition than the one used in Unicode, and is not the same as a code point.) [WEBIDL]
+
+
The term Unicode code point means a Unicode scalar value where
+ possible, and an isolated surrogate code point when not. When a conformance requirement is defined
+ in terms of characters or Unicode code points, a pair of code units
+ consisting of a high surrogate followed by a low surrogate must be treated as the single code
+ point represented by the surrogate pair, but isolated surrogates must each be treated as the
+ single code point with the value of the surrogate. [UNICODE]
+
+
In this specification, the term character, when not qualified as Unicode
+ character, is synonymous with the term Unicode code point.
+
+
The term Unicode character is used to mean a Unicode scalar value
+ (i.e. any Unicode code point that is not a surrogate code point). [UNICODE]
+
+
The code-unit length of a string is the number of code
+ units in that string.
+
+
This complexity results from the historical decision to define the DOM API in
+ terms of 16 bit (UTF-16) code units, rather than in terms of Unicode characters.
+
+
+
+
+
+
Conformance requirements
+
+
All diagrams, examples, and notes in this specification are non-normative, as are all sections
+ explicitly marked non-normative. Everything else in this specification is normative.
+
+
The key words "MUST", "MUST NOT", "SHOULD", "SHOULD
+ NOT", "MAY", and "OPTIONAL" in the normative parts of
+ this document are to be interpreted as described in RFC2119. The key word "OPTIONALLY" in the
+ normative parts of this document is to be interpreted with the same normative meaning as "MAY" and
+ "OPTIONAL". For readability, these words do not appear in all uppercase letters in this
+ specification. [RFC2119]
+
+
Requirements phrased in the imperative as part of algorithms (such as "strip any leading space
+ characters" or "return false and abort these steps") are to be interpreted with the meaning of the
+ key word ("must", "should", "may", etc) used in introducing the algorithm.
+
+
+
+
For example, were the spec to say:
+
+
To eat an orange, the user must:
+1. Peel the orange.
+2. Separate each slice of the orange.
+3. Eat the orange slices.
+
+
...it would be equivalent to the following:
+
+
To eat an orange:
+1. The user must peel the orange.
+2. The user must separate each slice of the orange.
+3. The user must eat the orange slices.
+
+
Here the key word is "must".
+
+
The former (imperative) style is generally preferred in this specification for stylistic
+ reasons.
+
+
+
+
Conformance requirements phrased as algorithms or specific steps may be implemented in any
+ manner, so long as the end result is equivalent. (In particular, the algorithms defined in this
+ specification are intended to be easy to follow, and not intended to be performant.)
+
+
+
+
+
+
+
+
Conformance classes
+
+
This specification describes the conformance criteria for user agents
+ (relevant to implementors) and documents (relevant to authors and
+ authoring tool implementors).
+
+
Conforming documents are those that comply with all the conformance criteria for
+ documents. For readability, some of these conformance requirements are phrased as conformance
+ requirements on authors; such requirements are implicitly requirements on documents: by
+ definition, all documents are assumed to have had an author. (In some cases, that author may
+ itself be a user agent — such user agents are subject to additional rules, as explained
+ below.)
+
+
For example, if a requirement states that "authors must not use the foobar element", it would imply that documents are not allowed to contain elements
+ named foobar.
+
+
There is no implied relationship between document conformance requirements
+ and implementation conformance requirements. User agents are not free to handle non-conformant
+ documents as they please; the processing model described in this specification applies to
+ implementations regardless of the conformity of the input documents.
+
+
User agents fall into several (overlapping) categories with different conformance
+ requirements.
+
+
+
+
Web browsers and other interactive user agents
+
+
+
+
Web browsers that support the XHTML syntax must process elements and attributes
+ from the HTML namespace found in XML documents as described in this specification,
+ so that users can interact with them, unless the semantics of those elements have been
+ overridden by other specifications.
+
+
A conforming XHTML processor would, upon finding an XHTML script
+ element in an XML document, execute the script contained in that element. However, if the
+ element is found within a transformation expressed in XSLT (assuming the user agent also
+ supports XSLT), then the processor would instead treat the script element as an
+ opaque element that forms part of the transform.
+
+
Web browsers that support the HTML syntax must process documents labeled with an
+ HTML MIME type as described in this specification, so that users can interact with
+ them.
+
+
User agents that support scripting must also be conforming implementations of the IDL
+ fragments in this specification, as described in the Web IDL specification. [WEBIDL]
+
+
Unless explicitly stated, specifications that override the semantics of HTML
+ elements do not override the requirements on DOM objects representing those elements. For
+ example, the script element in the example above would still implement the
+ HTMLScriptElement interface.
+
+
+
+
Non-interactive presentation user agents
+
+
+
+
User agents that process HTML and XHTML documents purely to render non-interactive versions
+ of them must comply to the same conformance criteria as Web browsers, except that they are
+ exempt from requirements regarding user interaction.
+
+
Typical examples of non-interactive presentation user agents are printers
+ (static UAs) and overhead displays (dynamic UAs). It is expected that most static
+ non-interactive presentation user agents will also opt to lack scripting
+ support.
+
+
A non-interactive but dynamic presentation UA would still execute scripts,
+ allowing forms to be dynamically submitted, and so forth. However, since the concept of "focus"
+ is irrelevant when the user cannot interact with the document, the UA would not need to support
+ any of the focus-related DOM APIs.
+
+
+
+
Visual user agents that support the suggested default rendering
+
+
+
+
User agents, whether interactive or not, may be designated (possibly as a user option) as
+ supporting the suggested default rendering defined by this specification.
+
+
This is not required. In particular, even user agents that do implement the suggested default
+ rendering are encouraged to offer settings that override this default to improve the experience
+ for the user, e.g. changing the colour contrast, using different focus styles, or otherwise
+ making the experience more accessible and usable to the user.
+
+
User agents that are designated as supporting the suggested default rendering must, while so
+ designated, implement the rules in the rendering section that that
+ section defines as the behavior that user agents are expected to implement.
+
+
+
+
User agents with no scripting support
+
+
+
+
Implementations that do not support scripting (or which have their scripting features
+ disabled entirely) are exempt from supporting the events and DOM interfaces mentioned in this
+ specification. For the parts of this specification that are defined in terms of an events model
+ or in terms of the DOM, such user agents must still act as if events and the DOM were
+ supported.
+
+
Scripting can form an integral part of an application. Web browsers that do not
+ support scripting, or that have scripting disabled, might be unable to fully convey the author's
+ intent.
+
+
+
+
+
Conformance checkers
+
+
+
+
Conformance checkers must verify that a document conforms to the applicable conformance
+ criteria described in this specification. Automated conformance checkers are exempt from
+ detecting errors that require interpretation of the author's intent (for example, while a
+ document is non-conforming if the content of a blockquote element is not a quote,
+ conformance checkers running without the input of human judgement do not have to check that
+ blockquote elements only contain quoted material).
+
+
Conformance checkers must check that the input document conforms when parsed without a
+ browsing context (meaning that no scripts are run, and that the parser's
+ scripting flag is disabled), and should also check that the input document conforms
+ when parsed with a browsing context in which scripts execute, and that the scripts
+ never cause non-conforming states to occur other than transiently during script execution
+ itself. (This is only a "SHOULD" and not a "MUST" requirement because it has been proven to be
+ impossible. [COMPUTABLE])
+
+
The term "HTML validator" can be used to refer to a conformance checker that itself conforms
+ to the applicable requirements of this specification.
+
+
+
+
XML DTDs cannot express all the conformance requirements of this specification. Therefore, a
+ validating XML processor and a DTD cannot constitute a conformance checker. Also, since neither
+ of the two authoring formats defined in this specification are applications of SGML, a
+ validating SGML system cannot constitute a conformance checker either.
+
+
To put it another way, there are three types of conformance criteria:
+
+
+
+
Criteria that can be expressed in a DTD.
+
+
Criteria that cannot be expressed by a DTD, but can still be checked by a machine.
+
+
Criteria that can only be checked by a human.
+
+
+
+
A conformance checker must check for the first two. A simple DTD-based validator only checks
+ for the first class of errors and is therefore not a conforming conformance checker according
+ to this specification.
+
+
+
+
+
+
Data mining tools
+
+
+
+
Applications and tools that process HTML and XHTML documents for reasons other than to either
+ render the documents or check them for conformance should act in accordance with the semantics
+ of the documents that they process.
+
+
A tool that generates document outlines but
+ increases the nesting level for each paragraph and does not increase the nesting level for each
+ section would not be conforming.
+
+
+
+
+
Authoring tools and markup generators
+
+
+
+
Authoring tools and markup generators must generate conforming documents.
+ Conformance criteria that apply to authors also apply to authoring tools, where appropriate.
+
+
Authoring tools are exempt from the strict requirements of using elements only for their
+ specified purpose, but only to the extent that authoring tools are not yet able to determine
+ author intent. However, authoring tools must not automatically misuse elements or encourage
+ their users to do so.
+
+
For example, it is not conforming to use an address element for
+ arbitrary contact information; that element can only be used for marking up contact information
+ for the author of the document or section. However, since an authoring tool is likely unable to
+ determine the difference, an authoring tool is exempt from that requirement. This does not mean,
+ though, that authoring tools can use address elements for any block of italics text
+ (for instance); it just means that the authoring tool doesn't have to verify that when the user
+ uses a tool for inserting contact information for a section, that the user really is doing that
+ and not inserting something else instead.
+
+
In terms of conformance checking, an editor has to output documents that conform
+ to the same extent that a conformance checker will verify.
+
+
When an authoring tool is used to edit a non-conforming document, it may preserve the
+ conformance errors in sections of the document that were not edited during the editing session
+ (i.e. an editing tool is allowed to round-trip erroneous content). However, an authoring tool
+ must not claim that the output is conformant if errors have been so preserved.
+
+
Authoring tools are expected to come in two broad varieties: tools that work from structure
+ or semantic data, and tools that work on a What-You-See-Is-What-You-Get media-specific editing
+ basis (WYSIWYG).
+
+
The former is the preferred mechanism for tools that author HTML, since the structure in the
+ source information can be used to make informed choices regarding which HTML elements and
+ attributes are most appropriate.
+
+
However, WYSIWYG tools are legitimate. WYSIWYG tools should use elements they know are
+ appropriate, and should not use elements that they do not know to be appropriate. This might in
+ certain extreme cases mean limiting the use of flow elements to just a few elements, like
+ div, b, i, and span and making liberal use
+ of the style attribute.
+
+
All authoring tools, whether WYSIWYG or not, should make a best effort attempt at enabling
+ users to create well-structured, semantically rich, media-independent content.
+
+
+
+
+
+
User agents may impose implementation-specific limits on otherwise
+ unconstrained inputs, e.g. to prevent denial of service attacks, to guard against running out of
+ memory, or to work around platform-specific limitations.
+
+
+
+
For compatibility with existing content and prior specifications, this specification describes
+ two authoring formats: one based on XML (referred to as the XHTML syntax), and one
+ using a custom format inspired by SGML (referred to as the HTML
+ syntax). Implementations must support at least one of these two formats, although
+ supporting both is encouraged.
+
+
Some conformance requirements are phrased as requirements on elements, attributes, methods or
+ objects. Such requirements fall into two categories: those describing content model restrictions,
+ and those describing implementation behavior. Those in the former category are requirements on
+ documents and authoring tools. Those in the second category are requirements on user agents.
+ Similarly, some conformance requirements are phrased as requirements on authors; such requirements
+ are to be interpreted as conformance requirements on the documents that authors produce. (In other
+ words, this specification does not distinguish between conformance criteria on authors and
+ conformance criteria on documents.)
+
+
+
+
+
+
+
Dependencies
+
+
This specification relies on several other underlying specifications.
+
+
+
+
Unicode and Encoding
+
+
+
+
The Unicode character set is used to represent textual data, and the WHATWG Encoding standard
+ defines requirements around character encodings. [UNICODE]
+
+
This specification introduces terminology
+ based on the terms defined in those specifications, as described earlier.
+
+
The following terms are used as defined in the WHATWG Encoding standard: [ENCODING]
+
+
+
+
Getting an encoding
+
+
The encoder and decoder algorithms for various encodings, including
+ the UTF-8 encoder and UTF-8 decoder
+
+
The generic decode algorithm which takes a byte stream and an encoding and
+ returns a character stream
+
+
The UTF-8 decode algorithm which takes a byte stream and returns a character
+ stream, additionally stripping one leading UTF-8 Byte Order Mark (BOM), if any
+
+
+
+
The UTF-8 decoder is distinct from the UTF-8 decode
+ algorithm. The latter first strips a Byte Order Mark (BOM), if any, and then invokes the
+ former.
+
+
For readability, character encodings are sometimes referenced in this specification with a
+ case that differs from the canonical case given in the WHATWG Encoding standard. (For example,
+ "UTF-16LE" instead of "utf-16le".)
+
+
+
+
+
XML
+
+
+
+
Implementations that support the XHTML syntax must support some version of XML,
+ as well as its corresponding namespaces specification, because that syntax uses an XML
+ serialisation with namespaces. [XML][XMLNS]
+
+
+
+
+
URLs
+
+
+
+
The following terms are defined in the WHATWG URL standard: [URL]
+
+
+
URL
+
Absolute URL
+
Relative URL
+
Relative schemes
+
The URL parser
+
Parsed URL
+
The scheme component of a parsed URL
+
The scheme data component of a parsed URL
+
The username component of a parsed URL
+
The password component of a parsed URL
+
The host component of a parsed URL
+
The port component of a parsed URL
+
The path component of a parsed URL
+
The query component of a parsed URL
+
The fragment component of a parsed URL
+
Parse errors from the URL parser
+
The URL serializer
+
Default encode set
+
Percent encode
+
UTF-8 percent encode
+
Percent decode
+
Decoder error
+
The domain label to ASCII algorithm
+
The domain label to Unicode algorithm
+
URLUtils interface
+
URLUtilsReadOnly interface
+
href attribute
+
protocol attribute
+
The get the base hook for URLUtils
+
The update steps hook for URLUtils
+
The set the input algorithm for URLUtils
+
The query encoding of an URLUtils object
+
The input of an URLUtils object
+
The url of an URLUtils object
+
+
+
+
+
+
Cookies
+
+
+
+
The following terms are defined in the Cookie specification: [COOKIES]
+
+
+
cookie-string
+
receives a set-cookie-string
+
+
+
+
+
+
Fetch
+
+
+
+
The following terms are defined in the WHATWG Fetch specification: [FETCH]
+
+
+
cross-origin request
+
cross-origin request status
+
custom request headers
+
simple cross-origin request
+
redirect steps
+
omit credentials flag
+
resource sharing check
+
+
+
This specification does not yet use the "fetch" algorithm from the WHATWG Fetch
+ specification. It will be updated to do so in due course.
+
+
+
+
+
+
+
Web IDL
+
+
+
+
The IDL fragments in this specification must be interpreted as required for conforming IDL
+ fragments, as described in the Web IDL specification. [WEBIDL]
+
+
The terms supported property indices, determine the value of an indexed
+ property, support named properties, supported property names,
+ unenumerable, determine the value of a named property, platform array
+ objects, and read only (when applied to arrays)
+ are used as defined in the Web IDL specification. The algorithm to convert a DOMString to a
+ sequence of Unicode characters is similarly that defined in the Web IDL specification.
+
+
When this specification requires a user agent to create a Date object
+ representing a particular time (which could be the special value Not-a-Number), the milliseconds
+ component of that time, if any, must be truncated to an integer, and the time value of the newly
+ created Date object must represent the resulting truncated time.
+
+
For instance, given the time 23045 millionths of a second after 01:00 UTC on
+ January 1st 2000, i.e. the time 2000-01-01T00:00:00.023045Z, then the Date object
+ created representing that time would represent the same time as that created representing the
+ time 2000-01-01T00:00:00.023Z, 45 millionths earlier. If the given time is NaN, then the result
+ is a Date object that represents a time value NaN (indicating that the object does
+ not represent a specific instant of time).
+
+
+
+
+
JavaScript
+
+
+
+
Some parts of the language described by this specification only support JavaScript as the
+ underlying scripting language. [ECMA262]
+
+
The term "JavaScript" is used to refer to ECMA262, rather than the official term
+ ECMAScript, since the term JavaScript is more widely known. Similarly, the MIME
+ type used to refer to JavaScript in this specification is text/javascript, since that is the most commonly used type, despite it being an officially obsoleted type according to RFC 4329. [RFC4329]
+
+
The term JavaScript global environment refers to the global
+ environment concept defined in the ECMAScript specification.
+
+
The ECMAScript SyntaxError exception is also
+ defined in the ECMAScript specification. [ECMA262]
+
+
The ArrayBuffer and related object types and underlying concepts from the
+ ECMAScript Specification are used for several features in this specification. [ECMA262]
+
+
The following helper IDL is used for referring to ArrayBuffer-related types:
+
+
typedef (Int8Array or Uint8Array or Uint8ClampedArray or
+ Int16Array or Uint16Array or
+ Int32Array or Uint32Array or
+ Float32Array or Float64Array or
+ DataView) ArrayBufferView;
+
+
In particular, the Uint8ClampedArray type is used by some 2D canvas APIs, and the WebSocket
+ API uses ArrayBuffer objects for handling binary frames.
+
+
+
+
+
DOM
+
+
+
+
The Document Object Model (DOM) is a representation — a model — of a document and
+ its content. The DOM is not just an API; the conformance criteria of HTML implementations are
+ defined, in this specification, in terms of operations on the DOM. [DOM]
+
+
Implementations must support DOM and the events defined in DOM Events, because this
+ specification is defined in terms of the DOM, and some of the features are defined as extensions
+ to the DOM interfaces. [DOM][DOMEVENTS]
+
+
In particular, the following features are defined in the DOM specification: [DOM]
+
+
+
+
Attr interface
+
Comment interface
+
DOMImplementation interface
+
Document interface
+
XMLDocument interface
+
DocumentFragment interface
+
DocumentType interface
+
DOMException interface
+
ChildNode interface
+
Element interface
+
Node interface
+
NodeList interface
+
ProcessingInstruction interface
+
Text interface
+
+
HTMLCollection interface
+
item() method
+
The terms collections and represented by the collection
+
+
DOMTokenList interface
+
DOMSettableTokenList interface
+
+
createDocument() method
+
createHTMLDocument() method
+
createElement() method
+
createElementNS() method
+
getElementById() method
+
insertBefore() method
+
+
ownerDocument attribute
+
childNodes attribute
+
localName attribute
+
parentNode attribute
+
namespaceURI attribute
+
tagName attribute
+
id attribute
+
textContent attribute
+
+
The insert, append, remove, replace, and adopt algorithms for nodes
+
The nodes are inserted and nodes are removed concepts
+
An element's adopting steps
+
The attribute list concept.
+
The data of a text node.
+
+
Event interface
+
EventTarget interface
+
EventInit dictionary type
+
target attribute
+
isTrusted attribute
+
The type of an event
+
The concept of an event listener and the event listeners associated with an EventTarget
+
The concept of a target override
+
The concept of a regular event parent and a cross-boundary event parent
+
+
The encoding (herein the character encoding) and content type of a Document
+
The distinction between XML documents and HTML documents
+
The terms quirks mode, limited-quirks mode, and no-quirks mode
+
The algorithm to clone a Node, and the concept of cloning steps used by that algorithm
+
The concept of base URL change steps and the definition of what happens when an element is affected by a base URL change
+
The concept of an element's unique identifier (ID)
+
+
The concept of a DOM range, and the terms start, end, and boundary point as applied to ranges.
+
+
MutationObserver interface
+
The invoke MutationObserver objects algorithm
+
+
Promise interface
+
The resolver concept
+
The fulfill and reject algorithms
+
+
+
+
The term throw in this specification is used as defined in the DOM specification.
+ The following DOMException types are defined in the DOM specification: [DOM]
+
+
+
IndexSizeError
+
HierarchyRequestError
+
WrongDocumentError
+
InvalidCharacterError
+
NoModificationAllowedError
+
NotFoundError
+
NotSupportedError
+
InvalidStateError
+
SyntaxError
+
InvalidModificationError
+
NamespaceError
+
InvalidAccessError
+
SecurityError
+
NetworkError
+
AbortError
+
URLMismatchError
+
QuotaExceededError
+
TimeoutError
+
InvalidNodeTypeError
+
DataCloneError
+
+
+
For example, to throw a TimeoutError exception, a user
+ agent would construct a DOMException object whose type was the string "TimeoutError" (and whose code was the number 23, for legacy reasons) and
+ actually throw that object as an exception.
+
+
The following features are defined in the DOM Events specification: [DOMEVENTS]
+
+
+
+
MouseEvent interface
+
MouseEventInit dictionary type
+
+
The FocusEvent interface and its relatedTarget attribute
+
+
The UIEvent interface's detail attribute
+
+
click event
+
dblclick event
+
mousedown event
+
mouseenter event
+
mouseleave event
+
mousemove event
+
mouseout event
+
mouseover event
+
mouseup event
+
mousewheel event
+
+
keydown event
+
keyup event
+
keypress event
+
+
+
+
The following features are defined in the Touch Events specification: [TOUCH]
+
+
+
+
Touch interface
+
+
Touch point concept
+
+
+
+
This specification sometimes uses the term name to refer to the event's
+ type; as in, "an event named click"
+ or "if the event name is keypress". The terms "name" and "type" for
+ events are synonymous.
+
+
The following features are defined in the DOM Parsing and Serialisation specification: [DOMPARSING]
+
+
+
innerHTML
+
outerHTML
+
+
+
User agents are also encouraged to implement the features described in the
+ HTML Editing APIs and UndoManager and DOM Transaction
+ specifications.
+ [EDITING]
+ [UNDO]
+
+
+
The following parts of the Fullscreen specification are referenced from this specification,
+ in part to define the rendering of dialog elements, and also to define how the
+ Fullscreen API interacts with the sandboxing features in HTML: [FULLSCREEN]
+
+
+
The top layer concept
+
requestFullscreen()
+
The fullscreen enabled flag
+
The fully exit fullscreen algorithm
+
+
+
+
+
+
+
File API
+
+
+
+
This specification uses the following features defined in the File API specification: [FILEAPI]
+
+
+
+
Blob
+
File
+
FileList
+
Blob.close()
+
Blob.type
+
The concept of read errors
+
+
+
+
+
+
XMLHttpRequest
+
+
+
+
This specification references the XMLHttpRequest specification to describe how the two
+ specifications interact and to use its ProgressEvent features. The following
+ features and terms are defined in the XMLHttpRequest specification: [XHR]
+
+
+
+
XMLHttpRequest
+
ProgressEvent
+
Fire a progress event named e
+
+
+
+
+
+
+
+
+
Media Queries
+
+
+
+
Implementations must support the Media Queries language. [MQ]
+
+
+
+
+
CSS modules
+
+
+
+
While support for CSS as a whole is not required of implementations of this specification
+ (though it is encouraged, at least for Web browsers), some features are defined in terms of
+ specific CSS requirements.
+
+
In particular, some features require that a string be parsed as a CSS <color>
+ value. When parsing a CSS value, user agents are required by the CSS specifications to
+ apply some error handling rules. These apply to this specification also. [CSSCOLOR][CSS]
+
+
For example, user agents are required to close all open constructs upon
+ finding the end of a style sheet unexpectedly. Thus, when parsing the string "rgb(0,0,0" (with a missing close-parenthesis) for a colour value, the close
+ parenthesis is implied by this error handling rule, and a value is obtained (the colour 'black').
+ However, the similar construct "rgb(0,0," (with both a missing parenthesis
+ and a missing "blue" value) cannot be parsed, as closing the open construct does not result in a
+ viable value.
+
+
The term CSS element reference identifier is used as defined in the CSS
+ Image Values and Replaced Content specification to define the API that declares
+ identifiers for use with the CSS 'element()' function. [CSSIMAGES]
+
+
Similarly, the term provides a paint source is used as defined in the CSS
+ Image Values and Replaced Content specification to define the interaction of certain HTML
+ elements with the CSS 'element()' function. [CSSIMAGES]
+
+
The term default object size is also defined in the CSS Image Values and
+ Replaced Content specification. [CSSIMAGES]
+
+
Implementations that support scripting must support the CSS Object Model. The following
+ features and terms are defined in the CSSOM specifications: [CSSOM][CSSOMVIEW]
+
+
+
Screen
+
LinkStyle
+
CSSStyleDeclaration
+
cssText attribute of CSSStyleDeclaration
+
StyleSheet
+
The terms create a CSS style sheet, remove a CSS style sheet, and associated CSS style sheet
Alternative style sheet sets and the preferred style sheet set
+
Serializing a CSS value
+
Scroll an element into view
+
Scroll to the beginning of the document
+
The resize event
+
The scroll event
+
+
+
The term environment encoding is defined in the CSS Syntax
+ specifications. [CSSSYNTAX]
+
+
The term CSS styling attribute is defined in the CSS Style Attributes
+ specification. [CSSATTR]
+
+
The CanvasRenderingContext2D object's use of fonts depends on the features
+ described in the CSS Fonts and Font Load Events specifications, including in particular
+ FontLoader. [CSSFONTS][CSSFONTLOAD]
+
+
+
+
+
+
+
SVG
+
+
+
+
The following interface is defined in the SVG specification: [SVG]
+
+
+
SVGMatrix
+
+
+
+
+
+
+
+
WebGL
+
+
+
+
The following interface is defined in the WebGL specification: [WEBGL]
+
+
+
WebGLRenderingContext
+
+
+
+
+
+
+
+
+
+
+
+
+
WebVTT
+
+
+
+
Implementations may support WebVTT as a text track format for subtitles, captions,
+ chapter titles, metadata, etc, for media resources. [WEBVTT]
+
+
The following terms, used in this specification, are defined in the WebVTT specification:
+
+
+
WebVTT file
+
WebVTT file using cue text
+
WebVTT file using chapter title text
+
WebVTT file using only nested cues
+
WebVTT parser
+
The rules for updating the display of WebVTT text tracks
+
The rules for interpreting WebVTT cue text
+
The WebVTT text track cue writing direction
+
+
+
+
+
+
+
+
The WebSocket protocol
+
+
+
+
The following terms are defined in the WebSocket protocol specification: [WSP]
+
+
+
+
establish a WebSocket connection
+
the WebSocket connection is established
+
validate the server's response
+
extensions in use
+
subprotocol in use
+
headers to send appropriate cookies
+
cookies set during the server's opening handshake
+
a WebSocket message has been received
+
send a WebSocket Message
+
fail the WebSocket connection
+
close the WebSocket connection
+
start the WebSocket closing handshake
+
the WebSocket closing handshake is started
+
the WebSocket connection is closed (possibly cleanly)
+
the WebSocket connection close code
+
the WebSocket connection close reason
+
+
+
+
+
+
+
+
+
ARIA
+
+
+
+
The terms strong native semantics is used as defined in the ARIA specification.
+ The term default implicit ARIA semantics has the same meaning as the term implicit
+ WAI-ARIA semantics as used in the ARIA specification. [ARIA]
+
+
The role and aria-*
+ attributes are defined in the ARIA specification. [ARIA]
+
+
+
+
+
+
+
+
This specification does not require support of any particular network protocol, style
+ sheet language, scripting language, or any of the DOM specifications beyond those required in the
+ list above. However, the language described by this specification is biased towards CSS as the
+ styling language, JavaScript as the scripting language, and HTTP as the network protocol, and
+ several features assume that those languages and protocols are in use.
+
+
A user agent that implements the HTTP protocol must implement the Web Origin Concept
+ specification and the HTTP State Management Mechanism specification (Cookies) as well. [HTTP][ORIGIN][COOKIES]
+
+
This specification might have certain additional requirements on character
+ encodings, image formats, audio formats, and video formats in the respective sections.
+
+
+
+
+
+
+
Extensibility
+
+
Vendor-specific proprietary user agent extensions to this specification are strongly
+ discouraged. Documents must not use such extensions, as doing so reduces interoperability and
+ fragments the user base, allowing only users of specific user agents to access the content in
+ question.
+
+
+
+
If such extensions are nonetheless needed, e.g. for experimental purposes, then vendors are
+ strongly urged to use one of the following extension mechanisms:
+
+
+
+
For markup-level features that can be limited to the XML serialisation and need not be
+ supported in the HTML serialisation, vendors should use the namespace mechanism to define custom
+ namespaces in which the non-standard elements and attributes are supported.
+
+
+
+
For markup-level features that are intended for use with the HTML syntax,
+ extensions should be limited to new attributes of the form "x-vendor-feature", where vendor is a
+ short string that identifies the vendor responsible for the extension, and feature is the name of the feature. New element names should not be created.
+ Using attributes for such extensions exclusively allows extensions from multiple vendors to
+ co-exist on the same element, which would not be possible with elements. Using the "x-vendor-feature" form allows extensions
+ to be made without risk of conflicting with future additions to the specification.
+
+
+
+
For instance, a browser named "FerretBrowser" could use "ferret" as a vendor prefix, while a
+ browser named "Mellblom Browser" could use "mb". If both of these browsers invented extensions
+ that turned elements into scratch-and-sniff areas, an author experimenting with these features
+ could write:
Attribute names beginning with the two characters "x-" are reserved for
+ user agent use and are guaranteed to never be formally added to the HTML language. For
+ flexibility, attributes names containing underscores (the U+005F LOW LINE character) are also
+ reserved for experimental purposes and are guaranteed to never be formally added to the HTML
+ language.
+
+
Pages that use such attributes are by definition non-conforming.
+
+
For DOM extensions, e.g. new methods and IDL attributes, the new members should be prefixed by
+ vendor-specific strings to prevent clashes with future versions of this specification.
+
+
For events, experimental event types should be prefixed with vendor-specific strings.
+
+
+
+
For example, if a user agent called "Pleasold" were to add an event to indicate when
+ the user is going up in an elevator, it could use the prefix "pleasold" and
+ thus name the event "pleasoldgoingup", possibly with an event handler
+ attribute named "onpleasoldgoingup".
+
+
+
+
All extensions must be defined so that the use of extensions neither contradicts nor causes the
+ non-conformance of functionality defined in the specification.
+
+
+
+
For example, while strongly discouraged from doing so, an implementation "Foo Browser" could
+ add a new IDL attribute "fooTypeTime" to a control's DOM interface that
+ returned the time it took the user to select the current value of a control (say). On the other
+ hand, defining a new control that appears in a form's elements array would be in violation of the above requirement,
+ as it would violate the definition of elements given in
+ this specification.
+
+
+
+
When adding new reflecting IDL attributes corresponding to content
+ attributes of the form "x-vendor-feature", the IDL attribute should be named "vendorFeature" (i.e. the "x" is
+ dropped from the IDL attribute's name).
+
+
+
+
+
+
When vendor-neutral extensions to this specification are needed, either this specification can
+ be updated accordingly, or an extension specification can be written that overrides the
+ requirements in this specification. When someone applying this specification to their activities
+ decides that they will recognise the requirements of such an extension specification, it becomes
+ an applicable specification for the purposes of
+ conformance requirements in this specification.
+
+
Someone could write a specification that defines any arbitrary byte stream as
+ conforming, and then claim that their random junk is conforming. However, that does not mean that
+ their random junk actually is conforming for everyone's purposes: if someone else decides that
+ that specification does not apply to their work, then they can quite legitimately say that the
+ aforementioned random junk is just that, junk, and not conforming at all. As far as conformance
+ goes, what matters in a particular community is what that community agrees is
+ applicable.
+
+
+
+
+
+
User agents must treat elements and attributes that they do not understand as semantically
+ neutral; leaving them in the DOM (for DOM processors), and styling them according to CSS (for CSS
+ processors), but not inferring any meaning from them.
+
+
+
When support for a feature is disabled (e.g. as an emergency measure to mitigate a security
+ problem, or to aid in development, or for performance reasons), user agents must act as if they
+ had no support for the feature whatsoever, and as if the feature was not mentioned in this
+ specification. For example, if a particular feature is accessed via an attribute in a Web IDL
+ interface, the attribute itself would be omitted from the objects that implement that interface
+ — leaving the attribute on the object but making it return null or throw an exception is
+ insufficient.
+
+
+
+
+
+
+
+
Interactions with XPath and XSLT
+
+
Implementations of XPath 1.0 that operate on HTML
+ documents parsed or created in the manners described in this specification (e.g. as part of
+ the document.evaluate() API) must act as if the following edit was applied
+ to the XPath 1.0 specification.
+
+
First, remove this paragraph:
+
+
+
+
A QName in the node test is expanded
+ into an expanded-name
+ using the namespace declarations from the expression context. This is the same way expansion is
+ done for element type names in start and end-tags except that the default namespace declared with
+ xmlns is not used: if the QName does not have a prefix, then the
+ namespace URI is null (this is the same way attribute names are expanded). It is an error if the
+ QName has a prefix for which there is
+ no namespace declaration in the expression context.
+
+
+
+
Then, insert in its place the following:
+
+
+
+
A QName in the node test is expanded into an expanded-name using the namespace declarations
+ from the expression context. If the QName has a prefix, then there must be a namespace declaration for this prefix in
+ the expression context, and the corresponding namespace URI is the one that is
+ associated with this prefix. It is an error if the QName has a prefix for which there is no
+ namespace declaration in the expression context.
+
+
If the QName has no prefix and the principal node type of the axis is element, then the
+ default element namespace is used. Otherwise if the QName has no prefix, the namespace URI is
+ null. The default element namespace is a member of the context for the XPath expression. The
+ value of the default element namespace when executing an XPath expression through the DOM3 XPath
+ API is determined in the following way:
+
+
+
+
If the context node is from an HTML DOM, the default element namespace is
+ "http://www.w3.org/1999/xhtml".
+
+
Otherwise, the default element namespace URI is null.
+
+
+
+
This is equivalent to adding the default element namespace feature of XPath 2.0
+ to XPath 1.0, and using the HTML namespace as the default element namespace for HTML documents.
+ It is motivated by the desire to have implementations be compatible with legacy HTML content
+ while still supporting the changes that this specification introduces to HTML regarding the
+ namespace used for HTML elements, and by the desire to use XPath 1.0 rather than XPath 2.0.
+
+
+
+
This change is a willful violation of the XPath 1.0 specification,
+ motivated by desire to have implementations be compatible with legacy content while still
+ supporting the changes that this specification introduces to HTML regarding which namespace is
+ used for HTML elements. [XPATH10]
+
+
+
+
XSLT 1.0 processors outputting to a DOM when the output
+ method is "html" (either explicitly or via the defaulting rule in XSLT 1.0) are affected as
+ follows:
+
+
If the transformation program outputs an element in no namespace, the processor must, prior to
+ constructing the corresponding DOM element node, change the namespace of the element to the
+ HTML namespace, ASCII-lowercase the
+ element's local name, and ASCII-lowercase the
+ names of any non-namespaced attributes on the element.
+
+
This requirement is a willful violation of the XSLT 1.0
+ specification, required because this specification changes the namespaces and case-sensitivity
+ rules of HTML in a manner that would otherwise be incompatible with DOM-based XSLT
+ transformations. (Processors that serialise the output are unaffected.) [XSLT10]
+
+
+
+
This specification does not specify precisely how XSLT processing interacts with the HTML
+ parser infrastructure (for example, whether an XSLT processor acts as if it puts any
+ elements into a stack of open elements). However, XSLT processors must stop
+ parsing if they successfully complete, and must set the current document
+ readiness first to "interactive" and then to "complete" if they are aborted.
+
+
+
+
This specification does not specify how XSLT interacts with the navigation algorithm, how it fits in with the event loop, nor
+ how error pages are to be handled (e.g. whether XSLT errors are to replace an incremental XSLT
+ output, or are rendered inline, etc).
Comparing two strings in a case-sensitive manner means comparing them exactly, code
+ point for code point.
+
+
Comparing two strings in an ASCII case-insensitive manner means comparing them
+ exactly, code point for code point, except that the characters in the range U+0041 to U+005A (i.e.
+ LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z) and the corresponding characters in the range
+ U+0061 to U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL LETTER Z) are considered to also
+ match.
+
+
Comparing two strings in a compatibility caseless manner means using the Unicode
+ compatibility caseless match operation to compare the two strings, with no language-specific tailoirings. [UNICODE]
+
+
Except where otherwise stated, string comparisons must be performed in a
+ case-sensitive manner.
+
+
+
+
+
Converting a string to ASCII uppercase means
+ replacing all characters in the range U+0061 to U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL
+ LETTER Z) with the corresponding characters in the range U+0041 to U+005A (i.e. LATIN CAPITAL
+ LETTER A to LATIN CAPITAL LETTER Z).
+
+
Converting a string to ASCII lowercase means
+ replacing all characters in the range U+0041 to U+005A (i.e. LATIN CAPITAL LETTER A to LATIN
+ CAPITAL LETTER Z) with the corresponding characters in the range U+0061 to U+007A (i.e. LATIN
+ SMALL LETTER A to LATIN SMALL LETTER Z).
+
+
+
+
+
A string pattern is a prefix match for a string s when pattern is not longer than s and
+ truncating s to pattern's length leaves the two strings as
+ matches of each other.
+
+
+
+
Common microsyntaxes
+
+
There are various places in HTML that accept particular data types, such as dates or numbers.
+ This section describes what the conformance criteria for content in those formats is, and how to
+ parse them.
+
+
+
+
Implementors are strongly urged to carefully examine any third-party libraries
+ they might consider using to implement the parsing of syntaxes described below. For example, date
+ libraries are likely to implement error handling behavior that differs from what is required in
+ this specification, since error-handling behavior is often not defined in specifications that
+ describe date syntaxes similar to those used in this specification, and thus implementations tend
+ to vary greatly in how they handle errors.
+
+
+
+
+
+
+
Common parser idioms
+
+
+
+
The space characters, for the purposes of this
+ specification, are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab), U+000A LINE FEED (LF), U+000C
+ FORM FEED (FF), and U+000D CARRIAGE RETURN (CR).
+
+
The White_Space characters are those that have the Unicode
+ property "White_Space" in the Unicode PropList.txt data file. [UNICODE]
+
+
This should not be confused with the "White_Space" value (abbreviated "WS") of the
+ "Bidi_Class" property in the Unicode.txt data file.
+
+
The control characters are those whose Unicode "General_Category" property has the
+ value "Cc" in the Unicode UnicodeData.txt data file. [UNICODE]
+
+
The uppercase ASCII letters are the characters in the range U+0041 LATIN CAPITAL
+ LETTER A to U+005A LATIN CAPITAL LETTER Z.
+
+
The lowercase ASCII letters are the characters in the range U+0061 LATIN SMALL
+ LETTER A to U+007A LATIN SMALL LETTER Z.
+
+
The ASCII digits are the characters in the range U+0030 DIGIT ZERO (0) to U+0039
+ DIGIT NINE (9).
+
+
The alphanumeric ASCII characters are those that are either uppercase ASCII
+ letters, lowercase ASCII letters, or ASCII digits.
+
+
The ASCII hex digits are the characters in the ranges U+0030 DIGIT ZERO (0) to
+ U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F, and U+0061
+ LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F.
+
+
The uppercase ASCII hex digits are the characters in the ranges U+0030 DIGIT ZERO (0) to
+ U+0039 DIGIT NINE (9) and U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F only.
+
+
The lowercase ASCII hex digits are the characters in the ranges U+0030 DIGIT ZERO
+ (0) to U+0039 DIGIT NINE (9) and U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F
+ only.
+
+
+
+
Some of the micro-parsers described below follow the pattern of having an input variable that holds the string being parsed, and having a position variable pointing at the next character to parse in input.
+
+
For parsers based on this pattern, a step that requires the user agent to collect a
+ sequence of characters means that the following algorithm must be run, with characters being the set of characters that can be collected:
+
+
+
+
Let input and position be the same variables as
+ those of the same name in the algorithm that invoked these steps.
+
+
Let result be the empty string.
+
+
While position doesn't point past the end of input
+ and the character at position is one of the characters,
+ append that character to the end of result and advance position to the next character in input.
+
+
Return result.
+
+
+
+
The step skip whitespace means that the user agent must collect a sequence of
+ characters that are space characters. The step
+ skip White_Space characters means that the user agent must collect a sequence of
+ characters that are White_Space characters. In both cases, the collected
+ characters are not used. [UNICODE]
+
+
When a user agent is to strip line breaks from a string, the user agent must remove
+ any U+000A LINE FEED (LF) and U+000D CARRIAGE RETURN (CR) characters from that string.
+
+
When a user agent is to strip leading and trailing whitespace from a string, the
+ user agent must remove all space characters that are at the
+ start or end of the string.
+
+
When a user agent is to strip and collapse whitespace in a string, it must replace
+ any sequence of one or more consecutive space characters in
+ that string with a single U+0020 SPACE character, and then strip leading and trailing
+ whitespace from that string.
+
+
When a user agent has to strictly split a string on a particular delimiter character
+ delimiter, it must use the following algorithm:
+
+
+
+
Let input be the string being parsed.
+
+
Let position be a pointer into input, initially
+ pointing at the start of the string.
+
+
Let tokens be an ordered list of tokens, initially empty.
+
+
While position is not past the end of input:
+
+
+
+
Collect a sequence of characters that are not the delimiter character.
+
+
Append the string collected in the previous step to tokens.
+
+
Advance position to the next character in input.
+
+
+
+
+
+
Return tokens.
+
+
+
+
For the special cases of splitting a string on spaces and on commas, this
+ algorithm does not apply (those algorithms also perform whitespace trimming).
+
+
+
+
+
+
Boolean attributes
+
+
A number of attributes are boolean attributes. The
+ presence of a boolean attribute on an element represents the true value, and the absence of the
+ attribute represents the false value.
+
+
If the attribute is present, its value must either be the empty string or a value that is an
+ ASCII case-insensitive match for the attribute's canonical name, with no leading or
+ trailing whitespace.
+
+
The values "true" and "false" are not allowed on boolean attributes. To represent
+ a false value, the attribute has to be omitted altogether.
+
+
+
+
Here is an example of a checkbox that is checked and disabled. The checked and disabled
+ attributes are the boolean attributes.
Some attributes are defined as taking one of a finite set of keywords. Such attributes are
+ called enumerated attributes. The keywords are each
+ defined to map to a particular state (several keywords might map to the same state, in
+ which case some of the keywords are synonyms of each other; additionally, some of the keywords can
+ be said to be non-conforming, and are only in the specification for historical reasons). In
+ addition, two default states can be given. The first is the invalid value default, the
+ second is the missing value default.
+
+
If an enumerated attribute is specified, the attribute's value must be an ASCII
+ case-insensitive match for one of the given keywords that are not said to be
+ non-conforming, with no leading or trailing whitespace.
+
+
When the attribute is specified, if its value is an ASCII case-insensitive match
+ for one of the given keywords then that keyword's state is the state that the attribute
+ represents. If the attribute value matches none of the given keywords, but the attribute has an
+ invalid value default, then the attribute represents that state. Otherwise, if the
+ attribute value matches none of the keywords but there is a missing value default state
+ defined, then that is the state represented by the attribute. Otherwise, there is no
+ default, and invalid values mean that there is no state represented.
+
+
When the attribute is not specified, if there is a missing value default state
+ defined, then that is the state represented by the (missing) attribute. Otherwise, the absence of
+ the attribute means that there is no state represented.
+
+
The empty string can be a valid keyword.
+
+
+
Numbers
+
+
Signed integers
+
+
A string is a valid integer if it consists of one or more ASCII digits,
+ optionally prefixed with a U+002D HYPHEN-MINUS character (-).
+
+
A valid integer without a U+002D HYPHEN-MINUS (-) prefix represents the number
+ that is represented in base ten by that string of digits. A valid integer
+ with a U+002D HYPHEN-MINUS (-) prefix represents the number represented in base ten by
+ the string of digits that follows the U+002D HYPHEN-MINUS, subtracted from zero.
+
+
+
+
The rules for parsing integers are as given in the following algorithm. When
+ invoked, the steps must be followed in the order given, aborting at the first step that returns a
+ value. This algorithm will return either an integer or an error.
+
+
+
+
Let input be the string being parsed.
+
+
Let position be a pointer into input, initially
+ pointing at the start of the string.
+
+
Let sign have the value "positive".
+
+
Skip whitespace.
+
+
If position is past the end of input, return an
+ error.
+
+
+
+
If the character indicated by position (the first character) is a U+002D
+ HYPHEN-MINUS character (-):
+
+
+
+
Let sign be "negative".
+
+
Advance position to the next character.
+
+
If position is past the end of input, return an
+ error.
+
+
+
+
Otherwise, if the character indicated by position (the first character)
+ is a U+002B PLUS SIGN character (+):
+
+
+
+
Advance position to the next character. (The "+"
+ is ignored, but it is not conforming.)
+
+
If position is past the end of input, return an
+ error.
+
+
+
+
+
+
If the character indicated by position is not an ASCII digit, then return an error.
+
+
+
+
Collect a sequence of characters that are ASCII digits, and
+ interpret the resulting sequence as a base-ten integer. Let value be that
+ integer.
+
+
If sign is "positive", return value, otherwise return the result of subtracting
+ value from zero.
+
+
+
+
+
+
+
Non-negative integers
+
+
A string is a valid non-negative integer if it consists of one or more ASCII
+ digits.
+
+
A valid non-negative integer represents the number that is represented in base ten
+ by that string of digits.
+
+
+
+
The rules for parsing non-negative integers are as given in the following algorithm.
+ When invoked, the steps must be followed in the order given, aborting at the first step that
+ returns a value. This algorithm will return either zero, a positive integer, or an error.
+
+
+
+
Let input be the string being parsed.
+
+
Let value be the result of parsing input using the
+ rules for parsing integers.
+
+
If value is an error, return an error.
+
+
If value is less than zero, return an error.
+
+
Return value.
+
+
+
+
+
+
+
+
+
Floating-point numbers
+
+
A string is a valid floating-point number if it consists of:
+
+
+
+
Optionally, a U+002D HYPHEN-MINUS character (-).
+
+
One or both of the following, in the given order:
+
+
+
+
A series of one or more ASCII digits.
+
+
+
+
+
+
A single U+002E FULL STOP character (.).
+
+
A series of one or more ASCII digits.
+
+
+
+
+
+
+
+
+
+
Optionally:
+
+
+
+
Either a U+0065 LATIN SMALL LETTER E character (e) or a U+0045 LATIN CAPITAL LETTER E
+ character (E).
+
+
Optionally, a U+002D HYPHEN-MINUS character (-) or U+002B PLUS SIGN character (+).
+
+
A series of one or more ASCII digits.
+
+
+
+
+
+
+
+
A valid floating-point number represents the number obtained by multiplying the
+ significand by ten raised to the power of the exponent, where the significand is the first number,
+ interpreted as base ten (including the decimal point and the number after the decimal point, if
+ any, and interpreting the significand as a negative number if the whole string starts with a
+ U+002D HYPHEN-MINUS character (-) and the number is not zero), and where the exponent is the
+ number after the E, if any (interpreted as a negative number if there is a U+002D HYPHEN-MINUS
+ character (-) between the E and the number and the number is not zero, or else ignoring a U+002B
+ PLUS SIGN character (+) between the E and the number if there is one). If there is no E, then the
+ exponent is treated as zero.
+
+
The Infinity and Not-a-Number (NaN) values are not valid floating-point numbers.
+
+
+
+
The best
+ representation of the number n as a floating-point number is the string
+ obtained from applying the JavaScript operator ToString to n. The JavaScript
+ operator ToString is not uniquely determined. When there are multiple possible strings that could
+ be obtained from the JavaScript operator ToString for a particular value, the user agent must
+ always return the same string for that value (though it may differ from the value used by other
+ user agents).
+
+
The rules for parsing floating-point number values are as given in the following
+ algorithm. This algorithm must be aborted at the first step that returns something. This algorithm
+ will return either a number or an error.
+
+
+
+
Let input be the string being parsed.
+
+
Let position be a pointer into input, initially
+ pointing at the start of the string.
+
+
Let value have the value 1.
+
+
Let divisor have the value 1.
+
+
Let exponent have the value 1.
+
+
Skip whitespace.
+
+
If position is past the end of input, return an
+ error.
+
+
+
+
If the character indicated by position is a U+002D HYPHEN-MINUS character
+ (-):
+
+
+
+
Change value and divisor to −1.
+
+
Advance position to the next character.
+
+
If position is past the end of input, return an
+ error.
+
+
+
+
Otherwise, if the character indicated by position (the first character)
+ is a U+002B PLUS SIGN character (+):
+
+
+
+
Advance position to the next character. (The "+"
+ is ignored, but it is not conforming.)
+
+
If position is past the end of input, return an
+ error.
+
+
+
+
+
+
If the character indicated by position is a U+002E FULL STOP (.), and
+ that is not the last character in input, and the character after the
+ character indicated by position is an ASCII
+ digit, then set value to zero and jump to the step labeled
+ fraction.
+
+
If the character indicated by position is not an ASCII digit, then return an error.
+
+
Collect a sequence of characters that are ASCII digits, and
+ interpret the resulting sequence as a base-ten integer. Multiply value by
+ that integer.
+
+
If position is past the end of input, jump to the
+ step labeled conversion.
+
+
Fraction: If the character indicated by position is a U+002E
+ FULL STOP (.), run these substeps:
+
+
+
+
Advance position to the next character.
+
+
If position is past the end of input, or if the
+ character indicated by position is not an ASCII
+ digit, U+0065 LATIN SMALL LETTER E (e), or U+0045 LATIN CAPITAL LETTER E (E), then jump
+ to the step labeled conversion.
+
+
If the character indicated by position is a U+0065 LATIN SMALL
+ LETTER E character (e) or a U+0045 LATIN CAPITAL LETTER E character (E), skip the remainder of
+ these substeps.
+
+
Fraction loop: Multiply divisor by ten.
+
+
Add the value of the character indicated by position, interpreted as a
+ base-ten digit (0..9) and divided by divisor, to value.
+
+
Advance position to the next character.
+
+
If position is past the end of input, then jump
+ to the step labeled conversion.
+
+
If the character indicated by position is an ASCII digit, jump back to the step labeled fraction loop in these
+ substeps.
+
+
+
+
+
+
If the character indicated by position is a U+0065 LATIN SMALL LETTER
+ E character (e) or a U+0045 LATIN CAPITAL LETTER E character (E), run these substeps:
+
+
+
+
Advance position to the next character.
+
+
If position is past the end of input, then jump
+ to the step labeled conversion.
+
+
+
+
If the character indicated by position is a U+002D HYPHEN-MINUS
+ character (-):
+
+
+
+
Change exponent to −1.
+
+
Advance position to the next character.
+
+
If position is past the end of input, then
+ jump to the step labeled conversion.
+
+
+
+
Otherwise, if the character indicated by position is a U+002B PLUS SIGN
+ character (+):
+
+
+
+
Advance position to the next character.
+
+
If position is past the end of input, then
+ jump to the step labeled conversion.
+
+
+
+
+
+
If the character indicated by position is not an ASCII digit, then jump to the step labeled conversion.
+
+
Collect a sequence of characters that are ASCII digits, and
+ interpret the resulting sequence as a base-ten integer. Multiply exponent
+ by that integer.
+
+
Multiply value by ten raised to the exponentth
+ power.
+
+
+
+
+
+
Conversion: Let S be the set of finite IEEE 754
+ double-precision floating-point values except −0, but with two special values added: 21024 and −21024.
+
+
Let rounded-value be the number in S that is
+ closest to value, selecting the number with an even significand if there are
+ two equally close values. (The two special values 21024 and −21024 are considered to have even significands for this purpose.)
+
+
If rounded-value is 21024 or −21024, return an error.
+
+
Return rounded-value.
+
+
+
+
+
+
+
+
Percentages and lengths
+
+
The rules for parsing dimension values are as given in the following algorithm. When
+ invoked, the steps must be followed in the order given, aborting at the first step that returns a
+ value. This algorithm will return either a number greater than or equal to 1.0, or an error; if a
+ number is returned, then it is further categorised as either a percentage or a length.
+
+
+
+
Let input be the string being parsed.
+
+
Let position be a pointer into input, initially
+ pointing at the start of the string.
+
+
Skip whitespace.
+
+
If position is past the end of input, return an
+ error.
+
+
If the character indicated by position is a U+002B PLUS SIGN character
+ (+), advance position to the next character.
+
+
Collect a sequence of characters that are U+0030 DIGIT ZERO (0) characters,
+ and discard them.
+
+
If position is past the end of input, return an
+ error.
+
+
If the character indicated by position is not one of U+0031 DIGIT ONE
+ (1) to U+0039 DIGIT NINE (9), then return an error.
+
+
+
+
Collect a sequence of characters that are ASCII digits, and
+ interpret the resulting sequence as a base-ten integer. Let value be that
+ number.
+
+
If position is past the end of input, return value as a length.
+
+
+
+
If the character indicated by position is a U+002E FULL STOP character
+ (.):
+
+
+
+
Advance position to the next character.
+
+
If position is past the end of input, or if the
+ character indicated by position is not an ASCII
+ digit, then return value as a length.
+
+
Let divisor have the value 1.
+
+
Fraction loop: Multiply divisor by ten.
+
+
Add the value of the character indicated by position, interpreted as a
+ base-ten digit (0..9) and divided by divisor, to value.
+
+
Advance position to the next character.
+
+
If position is past the end of input, then
+ return value as a length.
+
+
If the character indicated by position is an ASCII digit, return to the step labeled fraction loop in these
+ substeps.
+
+
+
+
+
+
If position is past the end of input, return value as a length.
+
+
If the character indicated by position is a U+0025 PERCENT SIGN
+ character (%), return value as a percentage.
+
+
Return value as a length.
+
+
+
+
+
+
+
Lists of integers
+
+
A valid list of integers is a number of valid
+ integers separated by U+002C COMMA characters, with no other characters (e.g. no space characters). In addition, there might be restrictions on the
+ number of integers that can be given, or on the range of values allowed.
+
+
+
+
The rules for parsing a list of integers are as follows:
+
+
+
+
Let input be the string being parsed.
+
+
Let position be a pointer into input, initially
+ pointing at the start of the string.
+
+
Let numbers be an initially empty list of integers. This list will be
+ the result of this algorithm.
+
+
If there is a character in the string input at position position, and it is either a U+0020 SPACE, U+002C COMMA, or U+003B SEMICOLON
+ character, then advance position to the next character in input, or to beyond the end of the string if there are no more
+ characters.
+
+
If position points to beyond the end of input,
+ return numbers and abort.
+
+
If the character in the string input at position position is a U+0020 SPACE, U+002C COMMA, or U+003B SEMICOLON character, then
+ return to step 4.
+
+
Let negated be false.
Let value be
+ 0.
+
+
Let started be false. This variable is set to true when the parser
+ sees a number or a U+002D HYPHEN-MINUS character (-).
+
+
Let got number be false. This variable is set to true when the parser
+ sees a number.
+
+
Let finished be false. This variable is set to true to switch parser
+ into a mode where it ignores characters until the next separator.
+
+
Let bogus be false.
+
+
Parser: If the character in the string input at position position is:
+
+
+
+
A U+002D HYPHEN-MINUS character
+
+
+
+
Follow these substeps:
+
+
+
+
If got number is true, let finished be true.
+
+
If finished is true, skip to the next step in the overall set of
+ steps.
+
+
If started is true, let negated be false.
+
+
Otherwise, if started is false and if bogus is
+ false, let negated be true.
+
+
Let started be true.
+
+
+
+
+
+
An ASCII digit
+
+
+
+
Follow these substeps:
+
+
+
+
If finished is true, skip to the next step in the overall set of
+ steps.
+
+
Multiply value by ten.
+
+
Add the value of the digit, interpreted in base ten, to value.
+
+
Let started be true.
+
+
Let got number be true.
+
+
+
+
+
+
+
A U+0020 SPACE character
+
A U+002C COMMA character
+
A U+003B SEMICOLON character
+
+
+
+
Follow these substeps:
+
+
+
+
If got number is false, return the numbers list
+ and abort. This happens if an entry in the list has no digits, as in "1,2,x,4".
+
+
If negated is true, then negate value.
+
+
Append value to the numbers list.
+
+
Jump to step 4 in the overall set of steps.
+
+
+
+
+
+
+
+
A character in the range U+0001 to U+001F, U+0021 to U+002B, U+002D to U+002F, U+003A, U+003C to U+0040, U+005B to U+0060, U+007b to U+007F
+ (i.e. any other non-alphabetic ASCII character)
+
+
+
+
+
+
Follow these substeps:
+
+
+
+
If got number is true, let finished be true.
+
+
If finished is true, skip to the next step in the overall set of
+ steps.
+
+
Let negated be false.
+
+
+
+
+
+
+
Any other character
+
+
+
+
+
Follow these substeps:
+
+
+
+
If finished is true, skip to the next step in the overall set of
+ steps.
+
+
Let negated be false.
+
+
Let bogus be true.
+
+
If started is true, then return the numbers list,
+ and abort. (The value in value is not appended to the list first; it is
+ dropped.)
+
+
+
+
+
+
+
+
+
+
Advance position to the next character in input,
+ or to beyond the end of the string if there are no more characters.
+
+
If position points to a character (and not to beyond the end of input), jump to the big Parser step above.
+
+
If negated is true, then negate value.
+
+
If got number is true, then append value to the
+ numbers list.
+
+
Return the numbers list and abort.
+
+
+
+
+
+
+
+
+
Lists of dimensions
+
+
+
+
The rules for parsing a list of dimensions are as follows. These rules return a list
+ of zero or more pairs consisting of a number and a unit, the unit being one of percentage,
+ relative, and absolute.
+
+
+
+
Let raw input be the string being parsed.
+
+
If the last character in raw input is a U+002C COMMA character (,),
+ then remove that character from raw input.
+
+
Split the string raw input on
+ commas. Let raw tokens be the resulting list of tokens.
+
+
Let result be an empty list of number/unit pairs.
+
+
+
+
For each token in raw tokens, run the following substeps:
+
+
+
+
Let input be the token.
+
+
Let position be a pointer into input,
+ initially pointing at the start of the string.
+
+
Let value be the number 0.
+
+
Let unit be absolute.
+
+
If position is past the end of input, set unit to relative and jump to the last substep.
+
+
If the character at position is an ASCII digit, collect a sequence of characters that are ASCII
+ digits, interpret the resulting sequence as an integer in base ten, and increment value by that integer.
+
+
+
+
If the character at position is a U+002E FULL STOP character (.), run
+ these substeps:
+
+
+
+
Collect a sequence of characters consisting of space characters and ASCII digits. Let s
+ be the resulting sequence.
+
+
Remove all space characters in s.
+
+
+
+
If s is not the empty string, run these subsubsteps:
+
+
+
+
Let length be the number of characters in s (after the spaces were removed).
+
+
Let fraction be the result of interpreting s as a base-ten integer, and then dividing that number by 10length.
+
+
Increment value by fraction.
+
+
+
+
+
+
+
+
+
+
Skip whitespace.
+
+
+
+
If the character at position is a U+0025 PERCENT SIGN character (%),
+ then set unit to percentage.
+
+
Otherwise, if the character at position is a U+002A ASTERISK character
+ (*), then set unit to relative.
+
+
+
+
+
+
Add an entry to result consisting of the number given by value and the unit given by unit.
+
+
+
+
+
+
Return the list result.
+
+
+
+
+
+
+
Dates and times
+
+
In the algorithms below, the number of days in month month of year
+ year is: 31 if month is 1, 3, 5, 7, 8,
+ 10, or 12; 30 if month is 4, 6, 9, or 11; 29 if month is 2 and year is a number divisible by 400, or if year is a number divisible by 4 but not by 100; and 28 otherwise. This
+ takes into account leap years in the Gregorian calendar. [GREGORIAN]
+
+
When ASCII digits are used in the date and time syntaxes defined in this section,
+ they express numbers in base ten.
+
+
+
+
While the formats described here are intended to be subsets of the corresponding
+ ISO8601 formats, this specification defines parsing rules in much more detail than ISO8601.
+ Implementors are therefore encouraged to carefully examine any date parsing libraries before using
+ them to implement the parsing rules described below; ISO8601 libraries might not parse dates and
+ times in exactly the same manner. [ISO8601]
+
+
+
+
Where this specification refers to the proleptic Gregorian calendar, it means the
+ modern Gregorian calendar, extrapolated backwards to year 1. A date in the proleptic
+ Gregorian calendar, sometimes explicitly referred to as a proleptic-Gregorian
+ date, is one that is described using that calendar even if that calendar was not in use at
+ the time (or place) in question. [GREGORIAN]
A month consists of a specific proleptic-Gregorian
+ date with no time-zone information and no date information beyond a year and a month. [GREGORIAN]
+
+
A string is a valid month string representing a year year and
+ month month if it consists of the following components in the given order:
+
+
+
+
Four or more ASCII digits, representing year, where year > 0
+
+
A U+002D HYPHEN-MINUS character (-)
+
+
Two ASCII digits, representing the month month, in the range
+ 1 ≤ month ≤ 12
+
+
+
+
+
+
The rules to parse a month string are as follows. This will return either a year and
+ month, or nothing. If at any point the algorithm says that it "fails", this means that it is
+ aborted at that point and returns nothing.
+
+
+
+
Let input be the string being parsed.
+
+
Let position be a pointer into input, initially
+ pointing at the start of the string.
+
+
Parse a month component to obtain year and month. If this returns nothing, then fail.
+
+
If position is not beyond the
+ end of input, then fail.
+
+
Return year and month.
+
+
+
+
The rules to parse a month component, given an input string and
+ a position, are as follows. This will return either a year and a month, or
+ nothing. If at any point the algorithm says that it "fails", this means that it is aborted at that
+ point and returns nothing.
+
+
+
+
Collect a sequence of characters that are ASCII digits. If the
+ collected sequence is not at least four characters long, then fail. Otherwise, interpret the
+ resulting sequence as a base-ten integer. Let that number be the year.
+
+
If year is not a number greater than zero, then fail.
+
+
If position is beyond the end of input or if the
+ character at position is not a U+002D HYPHEN-MINUS character, then fail.
+ Otherwise, move position forwards one character.
+
+
Collect a sequence of characters that are ASCII digits. If the
+ collected sequence is not exactly two characters long, then fail. Otherwise, interpret the
+ resulting sequence as a base-ten integer. Let that number be the month.
+
+
If month is not a number in the range 1 ≤ month ≤ 12, then fail.
+
+
Return year and month.
+
+
+
+
+
+
+
Dates
+
+
A date consists of a specific proleptic-Gregorian
+ date with no time-zone information, consisting of a year, a month, and a day. [GREGORIAN]
+
+
A string is a valid date string representing a year year, month
+ month, and day day if it consists of the following
+ components in the given order:
+
+
+
+
A valid month string, representing year and month
+
+
A U+002D HYPHEN-MINUS character (-)
+
+
Two ASCII digits, representing day, in the range
+ 1 ≤ day ≤ maxday where maxday is the number of
+ days in the month month and year year
+
+
+
+
+
+
The rules to parse a date string are as follows. This will return either a date, or
+ nothing. If at any point the algorithm says that it "fails", this means that it is aborted at that
+ point and returns nothing.
+
+
+
+
Let input be the string being parsed.
+
+
Let position be a pointer into input, initially
+ pointing at the start of the string.
+
+
Parse a date component to obtain year, month, and day. If this returns nothing, then fail.
+
+
If position is not beyond the end of input, then fail.
+
+
Let date be the date with year year, month month, and day day.
+
+
Return date.
+
+
+
+
The rules to parse a date component, given an input string and a
+ position, are as follows. This will return either a year, a month, and a day,
+ or nothing. If at any point the algorithm says that it "fails", this means that it is aborted at
+ that point and returns nothing.
+
+
+
+
Parse a month component to obtain year and month. If this returns nothing, then fail.
+
+
Let maxday be the number of days in month month of year year.
+
+
If position is beyond the end of input or if the
+ character at position is not a U+002D HYPHEN-MINUS character, then fail.
+ Otherwise, move position forwards one character.
+
+
Collect a sequence of characters that are ASCII digits. If the
+ collected sequence is not exactly two characters long, then fail. Otherwise, interpret the
+ resulting sequence as a base-ten integer. Let that number be the day.
+
+
If day is not a number in the range 1 ≤ day ≤ maxday, then fail.
+
+
Return year, month, and day.
+
+
+
+
+
+
+
Yearless dates
+
+
A yearless date consists of a Gregorian month and a
+ day within that month, but with no associated year. [GREGORIAN]
+
+
A string is a valid yearless date string representing a month month and a day day if it consists of the following components
+ in the given order:
+
+
+
+
Optionally, two U+002D HYPHEN-MINUS characters (-)
+
+
Two ASCII digits, representing the month month, in the range
+ 1 ≤ month ≤ 12
+
+
A U+002D HYPHEN-MINUS character (-)
+
+
Two ASCII digits, representing day, in the range
+ 1 ≤ day ≤ maxday where maxday is the number of
+ days in the month month and any arbitrary leap year (e.g. 4 or
+ 2000)
+
+
+
+
In other words, if the month is "02",
+ meaning February, then the day can be 29, as if the year was a leap year.
+
+
+
+
The rules to parse a yearless date string are as follows. This will return either a
+ month and a day, or nothing. If at any point the algorithm says that it "fails", this means that
+ it is aborted at that point and returns nothing.
+
+
+
+
Let input be the string being parsed.
+
+
Let position be a pointer into input, initially
+ pointing at the start of the string.
+
+
Parse a yearless date component to obtain month and day. If this returns nothing, then fail.
+
+
If position is not beyond the end of input, then fail.
+
+
Return month and day.
+
+
+
+
The rules to parse a yearless date component, given an input
+ string and a position, are as follows. This will return either a month and a
+ day, or nothing. If at any point the algorithm says that it "fails", this means that it is aborted
+ at that point and returns nothing.
+
+
+
+
Collect a sequence of characters that are U+002D HYPHEN-MINUS characters (-).
+ If the collected sequence is not exactly zero or two characters long, then fail.
+
+
Collect a sequence of characters that are ASCII digits. If the
+ collected sequence is not exactly two characters long, then fail. Otherwise, interpret the
+ resulting sequence as a base-ten integer. Let that number be the month.
+
+
If month is not a number in the range 1 ≤ month ≤ 12, then fail.
+
+
Let maxday be the number of days in month month of any arbitrary leap year (e.g. 4
+ or 2000).
+
+
If position is beyond the end of input or if the
+ character at position is not a U+002D HYPHEN-MINUS character, then fail.
+ Otherwise, move position forwards one character.
+
+
Collect a sequence of characters that are ASCII digits. If the
+ collected sequence is not exactly two characters long, then fail. Otherwise, interpret the
+ resulting sequence as a base-ten integer. Let that number be the day.
+
+
If day is not a number in the range 1 ≤ day ≤ maxday, then fail.
+
+
Return month and day.
+
+
+
+
+
+
+
Times
+
+
A time consists of a specific time with no time-zone
+ information, consisting of an hour, a minute, a second, and a fraction of a second.
+
+
A string is a valid time string representing an hour hour, a
+ minute minute, and a second second if it consists of the
+ following components in the given order:
+
+
+
+
Two ASCII digits, representing hour, in the range
+ 0 ≤ hour ≤ 23
+
+
A U+003A COLON character (:)
+
+
Two ASCII digits, representing minute, in the range
+ 0 ≤ minute ≤ 59
+
+
If second is non-zero, or optionally if second is
+ zero:
+
+
+
+
A U+003A COLON character (:)
+
+
Two ASCII digits, representing the integer part of second,
+ in the range 0 ≤ s ≤ 59
+
+
If second is not an integer, or optionally if second is an integer:
+
+
+
+
A 002E FULL STOP character (.)
+
+
One, two, or three ASCII digits, representing the fractional part of second
+
+
+
+
+
+
+
+
+
+
+
+
The second component cannot be 60 or 61; leap seconds cannot
+ be represented.
+
+
+
+
The rules to parse a time string are as follows. This will return either a time, or
+ nothing. If at any point the algorithm says that it "fails", this means that it is aborted at that
+ point and returns nothing.
+
+
+
+
Let input be the string being parsed.
+
+
Let position be a pointer into input, initially
+ pointing at the start of the string.
+
+
Parse a time component to obtain hour, minute, and second. If this returns nothing, then fail.
+
+
If position is not beyond the end of input, then fail.
+
+
Let time be the time with hour hour, minute minute, and second second.
+
+
Return time.
+
+
+
+
The rules to parse a time component, given an input string and a
+ position, are as follows. This will return either an hour, a minute, and a
+ second, or nothing. If at any point the algorithm says that it "fails", this means that it is
+ aborted at that point and returns nothing.
+
+
+
+
Collect a sequence of characters that are ASCII digits. If the
+ collected sequence is not exactly two characters long, then fail. Otherwise, interpret the
+ resulting sequence as a base-ten integer. Let that number be the hour.
+
+
If hour is not a number in the range 0 ≤ hour ≤ 23, then fail.
+
+
If position is beyond the end of input or if the
+ character at position is not a U+003A COLON character, then fail. Otherwise,
+ move position forwards one character.
+
+
Collect a sequence of characters that are ASCII digits. If the
+ collected sequence is not exactly two characters long, then fail. Otherwise, interpret the
+ resulting sequence as a base-ten integer. Let that number be the minute.
+
+
If minute is not a number in the range 0 ≤ minute ≤ 59, then fail.
+
+
Let second be a string with the value "0".
+
+
+
+
If position is not beyond the end of input and the
+ character at position is a U+003A COLON, then run these substeps:
+
+
+
+
Advance position to the next character in input.
+
+
If position is beyond the end of input, or at
+ the last character in input, or if the next two characters in input starting at position are not both ASCII
+ digits, then fail.
+
+
Collect a sequence of characters that are either ASCII digits
+ or U+002E FULL STOP characters. If the collected sequence is three characters long, or if it is
+ longer than three characters long and the third character is not a U+002E FULL STOP character,
+ or if it has more than one U+002E FULL STOP character, then fail. Otherwise, let the collected
+ string be second instead of its previous value.
+
+
+
+
+
+
Interpret second as a base-ten number (possibly with a fractional
+ part). Let second be that number instead of the string version.
+
+
If second is not a number in the range 0 ≤ second < 60, then fail.
+
+
Return hour, minute, and second.
+
+
+
+
+
+
+
Local dates and times
+
+
A local date and time consists of a specific
+ proleptic-Gregorian date, consisting of a year, a month, and a day, and a time,
+ consisting of an hour, a minute, a second, and a fraction of a second, but expressed without a
+ time zone. [GREGORIAN]
+
+
A string is a valid local date and time string representing a date and time if it
+ consists of the following components in the given order:
+
+
+
+
A valid date string representing the date
+
+
A U+0054 LATIN CAPITAL LETTER T character (T) or a U+0020 SPACE character
+
+
A valid time string representing the time
+
+
+
+
A string is a valid normalised local date and time string representing a date and
+ time if it consists of the following components in the given order:
+
+
+
+
A valid date string representing the date
+
+
A U+0054 LATIN CAPITAL LETTER T character (T)
+
+
A valid time string representing the time, expressed as the shortest possible
+ string for the given time (e.g. omitting the seconds component entirely if the given time is zero
+ seconds past the minute)
+
+
+
+
+
+
The rules to parse a local date and time string are as follows. This will return
+ either a date and time, or nothing. If at any point the algorithm says that it "fails", this means
diff --git a/benchmarks/data/wpt/LICENSE.md b/benchmarks/data/wpt/LICENSE.md
new file mode 100644
index 00000000..ad4858c8
--- /dev/null
+++ b/benchmarks/data/wpt/LICENSE.md
@@ -0,0 +1,11 @@
+# The 3-Clause BSD License
+
+Copyright 2019 web-platform-tests contributors
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/benchmarks/data/wpt/README.md b/benchmarks/data/wpt/README.md
new file mode 100644
index 00000000..61b65694
--- /dev/null
+++ b/benchmarks/data/wpt/README.md
@@ -0,0 +1,52 @@
+This directory contains a number of tests from
+[web-platform-tests](https://github.com/web-platform-tests/wpt) at
+77585330fd7da01392aec01cf5fed7aa22597180, chosen from the files processed by the manifest script.
+
+These files are split into two directories:
+
+ * `weighted`, a set of 15 tests curated from a random weighted sample of 30, weighted by parse
+ time as of html5lib 1.0.1. The curation was performed primarily as many of the slowest files are
+ very similar and therefore provide little extra coverage while it is relatively probable both
+ with be chosen. This provides a set of files which significantly contribute to the manifest
+ generation time.
+
+ * `random`, a further set of 15 tests, this time a random unweighted sample of 15. This provides a
+ set of files much closer to the average file in WPT.
+
+The files are sourced from the following:
+
+`weighted`:
+
+ * `css/compositing/test-plan/test-plan.src.html`
+ * `css/css-flexbox/align-content-wrap-002.html`
+ * `css/css-grid/grid-definition/grid-auto-fill-rows-001.html`
+ * `css/css-grid/masonry.tentative/masonry-item-placement-006.html`
+ * `css/css-images/image-orientation/reference/image-orientation-from-image-content-images-ref.html`
+ * `css/css-position/position-sticky-table-th-bottom-ref.html`
+ * `css/css-text/white-space/pre-float-001.html`
+ * `css/css-ui/resize-004.html`
+ * `css/css-will-change/will-change-abspos-cb-001.html`
+ * `css/filter-effects/filter-turbulence-invalid-001.html`
+ * `css/vendor-imports/mozilla/mozilla-central-reftests/css21/pagination/moz-css21-table-page-break-inside-avoid-2.html`
+ * `encoding/legacy-mb-tchinese/big5/big5_chars_extra.html`
+ * `html/canvas/element/compositing/2d.composite.image.destination-over.html`
+ * `html/semantics/embedded-content/the-canvas-element/toBlob.png.html`
+ * `referrer-policy/4K-1/gen/top.http-rp/unsafe-url/fetch.http.html`
+
+`random`:
+
+ * `content-security-policy/frame-ancestors/frame-ancestors-self-allow.html`
+ * `css/css-backgrounds/reference/background-origin-007-ref.html`
+ * `css/css-fonts/idlharness.html`
+ * `css/css-position/static-position/htb-ltr-ltr.html`
+ * `css/vendor-imports/mozilla/mozilla-central-reftests/css21/pagination/moz-css21-float-page-break-inside-avoid-6.html`
+ * `css/vendor-imports/mozilla/mozilla-central-reftests/shapes1/shape-outside-content-box-002.html`
+ * `encoding/legacy-mb-korean/euc-kr/euckr-encode-form.html`
+ * `html/browsers/browsing-the-web/unloading-documents/beforeunload-on-history-back-1.html`
+ * `html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/001.html`
+ * `html/editing/dnd/overlay/heavy-styling-005.html`
+ * `html/rendering/non-replaced-elements/lists/li-type-unsupported-ref.html`
+ * `html/semantics/grouping-content/the-dl-element/grouping-dl.html`
+ * `trusted-types/worker-constructor.https.html`
+ * `webvtt/rendering/cues-with-video/processing-model/selectors/cue/background_shorthand_css_relative_url.html`
+ * `IndexedDB/idbindex_get8.htm`
diff --git a/benchmarks/data/wpt/random/001.html b/benchmarks/data/wpt/random/001.html
new file mode 100644
index 00000000..7b0f21ec
--- /dev/null
+++ b/benchmarks/data/wpt/random/001.html
@@ -0,0 +1,3 @@
+
+
Accessing named windows from outside the unit of related browsing contexts
+Click here
diff --git a/benchmarks/data/wpt/random/background-origin-007-ref.html b/benchmarks/data/wpt/random/background-origin-007-ref.html
new file mode 100644
index 00000000..d3a1d053
--- /dev/null
+++ b/benchmarks/data/wpt/random/background-origin-007-ref.html
@@ -0,0 +1,18 @@
+
+
+CSS Backgrounds and Borders Reference
+
+
+
+
Test passes if there is a filled green square and no red.
+
+
diff --git a/benchmarks/data/wpt/weighted/position-sticky-table-th-bottom-ref.html b/benchmarks/data/wpt/weighted/position-sticky-table-th-bottom-ref.html
new file mode 100644
index 00000000..2aa5c08a
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/position-sticky-table-th-bottom-ref.html
@@ -0,0 +1,62 @@
+
+Reference for position:sticky bottom constraint should behave correctly for <th> elements
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
You should see three green boxes above. No red should be visible.
diff --git a/benchmarks/data/wpt/weighted/pre-float-001.html b/benchmarks/data/wpt/weighted/pre-float-001.html
new file mode 100644
index 00000000..8dd08d80
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/pre-float-001.html
@@ -0,0 +1,36 @@
+
+CSS test preserved spaces and floats interaction
+
+
+
+
+
+
+
+
123456 123456
+
+
1234567 1234567
+
+
1234567 1234567
+
+
1234567 1234567
+
+
12345678 12345678
+
diff --git a/benchmarks/data/wpt/weighted/resize-004.html b/benchmarks/data/wpt/weighted/resize-004.html
new file mode 100644
index 00000000..3a1f5617
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/resize-004.html
@@ -0,0 +1,20 @@
+
+
+CSS Basic User Interface Test: resize initial value - none
+
+
+
+
+
+
+
+
Test passes if neither the height nor the width of the blue border square can be adjusted(for instance by dragging the bottom-right corner).
+
+
diff --git a/benchmarks/data/wpt/weighted/test-plan.src.html b/benchmarks/data/wpt/weighted/test-plan.src.html
new file mode 100644
index 00000000..c29f2688
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/test-plan.src.html
@@ -0,0 +1,1616 @@
+
+
+
+
+ Compositing and Blending Test Plan
+
+
+
+
+
+
+
+
+ This document is intended to be used as a guideline for the testing
+ activities related to the Compositing and Blending spec [[!compositing-1]]. Its main
+ goal is to provide an overview of the general testing areas and an informative
+ description of possible test cases.
+
+
+ This document is not meant to replace the spec in determining the
+ normative and non-normative assertions to be tested, but rather
+ complement it.
+
+
+
+
Goals
+
+
Providing guidance on testing
+
+ In order to increase the quality of the test contributions, this
+ document offers a set of test cases description for conducting testing (see
+ ).
+
+
+
+
Creating automation-friendly tests
+
+ In terms of actual tests produced for the CSS Compositing and Blending, the main goal
+ is to ensure that most tests are automatable (i.e. they're either
+ reftests or use testharness.js). Even where manual tests
+ are absolutely necessary they should be written so that they can be
+ easily automated – as there are on-going efforts to make
+ WebDriver [[webdriver]] automated tests a first class citizen in W3C
+ testing. This means that even if a manual test requires user
+ interaction, the validation or PASS/FAIL conditions should still be
+ clear enough as to allow automatic validation if said interaction is
+ later automated.
+
+
+
+
+
Approach
+
+ Since CSS blending has only three new CSS properties,
+ the approach is to deep dive into every aspect of the spec as much as possible.
+
+ Tests will be created for the testing areas listed in
+ and having as guidance the test cases description from .
+
+
+
+
Testing areas
+
+
Explicit testing areas
+
+ These testing areas cover things explicitly defined in the normative sections of the Blending and Compositing spec. Please note that while detailed, this list is not necessarily
+ exhaustive and some normative behaviors may not be contained in it.
+ When in doubt, consult the Blending and Compositing spec or ask a question on the
+ mailing
+ list.
+
+
Below is the list of explicit testing areas:
+
+
Proper parsing of the CSS properties and rendering according to the spec
+
mix-blend-mode
+
isolation
+
background-blend-mode
+
+
SVG blending
+
Canvas 2D blending
+
+
+
+
Implicit testing areas
+
+ These are testing areas either normatively defined in other specs
+ that explicitly refer to the Blending and Compositing spec (e.g. [[!css3-transforms]])
+ or simply not explicitly defined, but implied by various aspects of
+ the spec (e.g. processing model, CSS 2.1 compliance, etc.).
+ Please note that while detailed, this list is not necessarily
+ exhaustive and some normative behaviors may not be contained in it.
+ When in doubt, consult the Blending and Compositing spec or ask a question on the
+ mailing
+ list.
+
+
Below is the list of implicit testing areas:
+
+
Blending different types of elements
+
+
<video>
+
<canvas>
+
<table>
+
+
+
Blending elements with specific style rules applied
+
+
transforms
+
transitions
+
animations
+
+
+
+
+
+
+
Test cases description
+
+
Test cases for mix-blend-mode
+
+ The following diagram describes a list of notations to be used later on in the document as well as the general document structure the test cases will follow. The test cases should not be limited to this structure. This should be a wireframe and people are encouraged to come up with complex test cases as well.
+
+
+
+
+
The intended structure of the document is the following:
Unless otherwise stated, test cases assume the following properties for the elements:
+
+
default value for the background-color of the body
+
background-color set to a fully opaque color for all the other elements
+
+
+
The CSS associated to the elements used in the tests shouldn't use properties that creates a stacking context, except the ones specified in the test case descriptions.
+
Every test case has a description of the elements used. The notation from the image is used in the test case description too (e.g. for parent element the notation is [P]). Each test case uses only a subset of the elements while the other elements should just be removed.
+
+
+
An element with mix-blend-mode other than normal creates a stacking context
+
Refers to the following assertion in the spec: Applying a blendmode other than ‘normal’ to the element must establish a new stacking context [CSS21].
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Simple <div>
+
1 element required: [B]
+ [B] - element with mix-blend-mode other than normal
+
+
The element [B] creates a stacking context
+
+
+
+
+
An element with mix-blend-mode blends with the content within the current stacking context
+
Refers to the following assertion in the spec: An element that has blending applied, must blend with all the underlying content of the stacking context [CSS21] that that element belongs to.
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Blending simple elements
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal
+
+
The color of the parent element [P] mixes with the color of the child element [B].
+
+
+
Blending <video>
+
2 elements required: [B] and [IN-S]
+ [B] - <video> element with mix-blend-mode other than normal
+ [IN-S] - sibling(of the element [B]) visually overlaping the <video> element
+ [IN-S] has some text inside
+
+
The content of the video element [B] mixes with the colors of the sibling element and the text from [IN-S].
+
+
+
Blending with a sibling
+
3 elements required: [P], [B] and [IN-S]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal
+ [IN-S] - sibling of the element [B]
+ The [IN-S] element visually overlaps the [B] element
+
+
The colors of the parent element [P] and the sibling element [IN-S] mixes with the color of the blended element [B].
+
+
+
Blending with two levels of ascendants
+
3 elements required: [P], [B] and [IN-P]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal
+ [IN-P] - Intermediate child element between the parent [P] and the child [B]
+
+
The colors of the parent element [P] and the child element [IN-P] mixes with the color of the blended element [B].
+
+
+
+
+
An element with mix-blend-mode doesn't blend with anything outside the current stacking context
+
Refers to the following assertion in the spec: An element that has blending applied, must blend with all the underlying content of the stacking context [CSS21] that that element belongs to.
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Blending child overflows the parent
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal
+ The blending element [B] has content that lies outside the parent element.
+ Set the background-color of the body to a value other than default
+
The color of the parent element mixes with the color of the child element.
+ The area of the child element outside of the parent element doesn't mix with the color of the body
+
+
+
Parent with transparent pixels
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ The element has some text inside and default value for background-color
+ [B] - element with mix-blend-mode other than normal
+ The background-color of the body has a value other than default
+
The color of the text from the parent element [P] mixes with the color of the child element [B].
+ No blending between the color of the body and the color of the blending element [B].
+
+
+
+
Parent with border-radius
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [P] has border-radius specified (e.g.50%).
+ [B] - element with mix-blend-mode other than normal
+ [B] has content that lies outside the parent element, over a rounded corner.
+ The background-color of the body has a value other than default.
+
The color of the parent element mixes with the color of the child element.
+ The area of the child element which draws over the rounded corner doesn't mix with the color of the body
+
+
+
+
+
An element with mix-blend-mode other than normal must cause a group to be isolated
+
Refers to the following assertion in the spec: operations that cause the creation of stacking context [CSS21] must cause a group to be isolated.
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Child of the blended element has opacity
+
3 elements required: [P], [B] and [CB]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal
+ [CB] - child of the element [B] with opacity less than one.
+
The group created by the two child elements([B] and [CB]) is blended with the parent element [P].
+ No blending between [B] and [CB]
+
+
+
Overflowed child of the blended element
+
3 elements required: [P], [B] and [CB]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal
+ [CB] - child of the element [B] with content that lies outside the parent element [B].
+
+
The group created by the two child elements([B] and [CB]) is blended with the parent element [P].
+ No blending between [B] and [CB]. There is only one color for the entire element [CB]
+
+
+
Blended element with transparent pixels
+
3 elements required: [P], [B] and [CB]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal and transparent background-color
+ [CB] - child of the element [B]
+
+
The group created by the two child elements([B] and [CB]) is blended with the parent element [P].
+ No blending between [B] and [CB].
+
+
+
+
+
An element with mix-blend-mode must work properly with css transforms
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Parent with 3D transform
+
2 elements required: [P] and [B]
+ [P] - parent element with 3D transform
+ [B] - element with mix-blend-mode other than normal
+
The color of the parent element [P] mixes with the color of the child element [B]
+ The element (and the content) of the element [P] is properly transformed
+
+
+
+
Blended element with 3D transform
+
2 elements required: [P], [B] and [CB]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal and 3D transform
+ [CB] - child of the element [B]
+
The color of the parent element [P] mixes with the color of the child element [B]
+ The element (and the content) of the element [P] is properly transformed
+
+
+
Both parent and blended element with 3D transform
+
2 elements required: [P] and [B]
+ [P] - parent element with 3D transform
+ [B] - element with mix-blend-mode other than normal and 3D transform
+
+
The color of the parent element [P] mixes with the color of the child element [B]
+ The elements (and the content) of the elements [P] and [B] are properly transformed
+
+
+
Blended element with transform and preserve-3d
+
3 elements required: [P], [B] and [CB]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal and transform with transform-style:preserve-3d
+ [CB] - child of the element [B]. It has 3D transform property
+
The child element [CB] will NOT preserve its 3D position.
+ mix-blend-mode override the behavior of transform-style:preserve-3d:
+ creates a flattened representation of the descendant elements
+ The color of the group created by the child elements([B] and [CB]) will blend with the color of the parent element [P]
+
+
+
Blended element with transform and perspective
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal and transform with perspective set to positive length
+
The colors of the parent and the child are mixed ([P] and [B])
+ The element (and the content) of the element [B] is properly transformed
+
+
+
+
Sibling with 3D transform between the parent and the blended element
+
3 elements required: [P], [B] and [IN-S]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal
+ [IN-S] - Sibling(of the element [B]) with 3D transform between the parent [P] and the child [B]
+
+
The colors of the parent element [P] and the transformed sibling element [IN-S] mixes with the color of the blended element [B].
+ The element (and the content) of the element [IN-S] is properly transformed
+
+
+
+
Parent with 3D transform and transition
+
2 elements required: [P] and [B]
+ [P] - parent element with 3D transform and transition
+ [B] - element with mix-blend-mode other than normal
+
The color of the parent element [P] mixes with the color of the child element [B]
+ The element (and the content) of the element [P] is properly transformed
+
+
+
+
Sibling with 3D transform(and transition) between the parent and the blended element
+
3 elements required: [P], [B] and [IN-S]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal
+ [IN-S] - sibling(of the element [B]) with 3D transform and transition between the parent [P] and the child [B]
+
+
The colors of the parent element [P] and the transformed sibling element [IN-S] mixes with the color of the blended element [B].
+ The element (and the content) of the element [IN-S] is properly transformed
+
+
+
+
+
+
An element with mix-blend-mode must work properly with elements with overflow property
+
+
+
Parent element with overflow:scroll
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [P] has overflow:scroll
+ [B] - element with mix-blend-mode other than normal tat overflows the parents [P] dimensions so that it creates scrolling for the parent
+
The color of the parent element [P] mixes with the color of the child element [B].
+ The scrolling mechanism is not affected.
+
+
+
+
Blended element with overflow:scroll
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal, overflow:scroll and a child element that creates overflow for [B]
+
The color of the parent element [P] mixes with the color of the child element [B]
+ The scrolling mechanism is not affected.
+
+
+
+
Parent element with overflow:scroll and blended with position:fixed
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [P] has overflow:scroll
+ [B] - element with mix-blend-mode other than normal, position:fixed and should overflow the parents [P] dimensions so that it creates scrolling for the parent
+
The color of the parent element [P] mixes with the color of the child element [B]
+ The blending happens when scrolling the content of the parent element [P] too.
+ The scrolling mechanism is not affected.
+
+
+
+
Parent with overflow:hidden and border-radius
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [P] has overflow:hidden and border-radius specified (e.g.50%)
+ [B] - element with mix-blend-mode other than normal with content that lies outside the parent element, over a rounded corner
+ Set the background-color of the body to a value other than default.
+
The color of the parent element mixes with the color of the child element.
+ The area of the child element which draws over the rounded corner is properly cut
+
+
+
Blended element with overflow:hidden and border-radius
+
3 elements required: [P] and [B] and [CB]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal, overflow:hidden and border-radius specified (e.g.50%).
+ [CB] - child of the element [B], with content that lies outside the parent element, over a rounded corner.
+
The group created by the two child elements([B] and [CB]) is blended with the parent element [P].
+ No blending between [B] and [CB].
+ [CB] is properly clipped so no overflow is visible.
+
+
+
Intermediate child with overflow:hidden and border-radius between the parent and the blended element
+
3 elements required: [P], [B] and [IN-P]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal that overflows the parents [IN-P] dimensions
+ [IN-P] - child(of the element [P]) with overflow:hidden and border-radius specified (e.g.50%)
+
+
The colors of the parent element [P] and the child element [IN-P] mixes with the color of the blended element [B].
+ [B] is is properly clipped so no overflow is visible
+
+
+
+
+
+
Other test cases
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Blended element with border-image
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal and border-image specified as a png file
+
+
The color of the parent element [P] mixes with the color of the child element.
+ The color of the border-image mixes with the color of the parent element [P].
+
+
+
+
Blending with <canvas>
+
2 elements required: [B] and [IN-S]
+ [B] - <canvas> element with mix-blend-mode other than normal
+ [IN-S] - Sibling of the <canvas> element with some text
+ The [IN-S] element overlaps the <canvas> element
+
+
The content of the <canvas> element mixes with the color of the sibling element and the text [IN-S].
+
+
+
Blended <canvas>
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - Child <canvas> element with mix-blend-mode other than normal
+
+
The color of the <canvas> element [B] mixes with the color of the parent element [P] .
+
+
+
Blended <video>
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - <video> element with mix-blend-mode other than normal
+
+
The color of the <video> element mixes with the color of the parent element [P] .
+
+
+
Blending with <iframe>
+
2 elements required: [B] and [IN-S]
+ [B] - <iframe> element with mix-blend-mode other than normal
+ [IN-S] - sibling(of the element [B]) with some text
+ The [IN-S] element visually overlaps the <iframe> element
+
+
The color of the <iframe> element mixes with the color of the sibling element and the text [IN-S].
+
+
+
Blended <iframe>
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - <iframe> element with mix-blend-mode other than normal
+
+
The color of the <iframe> element [B] mixes with the color of the parent element [P].
+
+
+
Blended element with mask property
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal and mask property specified to an SVG image (e.g. circle)
+
The colors of the parent and the masked child are mixed ([P] and [B])
+
+
+
Blended element with clip-path property
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal and clip-path property specified to a basic shape (e.g. ellipse)
+
The colors of the parent and the clipped child are mixed ([P] and [B])
+
+
+
Blended element with filter property
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal and filter property value other than none
+
The filter is applied and the result is mixed with the parent element
+
+
+
Blended element with transition
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal and transition-property for opacity
+
The transition is applied and the result is mixed with the parent element
+
+
+
Blended element with animation
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - element with mix-blend-mode other than normal and animation specified
+
The animation is applied to the child element and the result is mixed with the parent element
+
+
+
Image element
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - <img> element (.jpeg or .gif image) with mix-blend-mode other than normal
+
The color of the <img> is mixed with the color of the <div>.
+
+
+
SVG element
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - SVG element with mix-blend-mode other than normal
+
The color of the SVG is mixed with the color of the <div>.
+
+
+
Paragraph element
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - paragraph element with mix-blend-mode other than normal
+
The color of the text from the paragraph element is mixed with the color of the <div>
+
+
+
Paragraph element and background-image
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ and background-image
+ [B] - Child p element with some text and mix-blend-mode other than normal
+
The color of the text from the p element is mixed with the background image of the <div>.
+
+
+
Set blending from JavaScript
+
2 elements required: [P] and [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [B] - Child <div> element with no mix-blend-mode specified
+ From JavaScript, set the mix-blend-mode property for the child <div> to a value other than normal
+
The colors of the <div> elements are mixed.
+
+
+
+
+
+
Test cases for SVG elements with mix-blend-mode
+
+
mix-blend-mode with simple SVG graphical elements
+
Refers to the following assertion in the spec : mix-blend-mode applies to svg, g, use, image, path, rect, circle, ellipse, line, polyline, polygon, text, tspan, and marker.
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Circle with SVG background
+
Set a background color for the SVG.
+ Create 16 circle elements and fill them with a solid color.
+ Apply each mix-blend-mode on them.
+
The color of the circle is mixed with the color of the background.
+
+
+
Ellipse with SVG background
+
Set a background color for the SVG.
+ Create an ellipse element and fill it with a solid color.
+ Apply a mix-blend-mode on it other than normal.
+
The color of the ellipse is mixed with the color of the background.
+
+
+
Image with SVG background
+
Set a background color for the SVG.
+ Create an image element and apply a mix-blend-mode other than normal.
+
The image is mixed with the color of the background.
+
+
+
Line with SVG background
+
Set a background color for the SVG.
+ Create a line element and fill it with a solid color.
+ Apply a mix-blend-mode on it other than normal.
+
The color of the line is mixed with the color of the background.
+
+
+
Path with SVG background
+
Set a background color for the SVG.
+ Create a path element and fill it with a solid color.
+ Apply a mix-blend-mode on it other than normal.
+
The color of the path is mixed with the color of the background.
+
+
+
Polygon with SVG background
+
Set a background color for the SVG.
+ Create a polygon element and fill it with a solid color.
+ Apply a mix-blend-mode on it other than normal.
+
The color of the polygon is mixed with the color of the background.
+
+
+
Polyline with SVG background
+
Set a background color for the SVG.
+ Create a polyline element and fill it with a solid color.
+ Apply a mix-blend-mode on it other than normal.
+
The color of the polyline is mixed with the color of the background.
+
+
+
Rect with SVG background
+
Set a background color for the SVG.
+ Create a rect element and fill it with a solid color.
+ Apply a mix-blend-mode on it other than normal.
+
The color of the rect is mixed with the color of the background.
+
+
+
Text with SVG background
+
Set a background color for the SVG.
+ Create a text element and apply a mix-blend-mode other than normal.
+
The text is mixed with the color of the background.
+
+
+
Text having tspan with SVG background
+
Set a background color for the SVG.
+ Create a text element and a tspan inside it.
+ Apply a mix-blend-mode other than normal on the tspan.
+
The text is mixed with the color of the background.
+
+
+
Gradient with SVG background
+
Set a background color for the SVG.
+ Create a rect element and fill it with a gradient.
+ Apply a mix-blend-mode on it other than normal.
+
The gradient is mixed with the color of the background.
+
+
+
Pattern with SVG background
+
Set a background color for the SVG.
+ Create a rect element and fill it with a pattern.
+ Apply a mix-blend-mode on it other than normal.
+
The pattern is mixed with the color of the background.
+
+
+
Set blending on an element from JavaScript
+
Set a background color for the SVG.
+ Create a rect element and fill it with a solid color.
+ Apply a mix-blend-mode (other than normal) on it from JavaScript.
+
The color of the rect is mixed with the color of the background.
+
+
+
Marker with SVG background
+
Set a background color for the SVG.
+ Create a line element containing a marker.
+ Apply a mix-blend-mode other than normal on the marker.
+
The marker color is mixed with the color of the background.
+
+
+
Metadata with SVG background
+
Set a background color for the SVG.
+ Create a metadata element containing an embedded pdf.
+ Apply a mix-blend-mode other than normal on the marker.
+
The metadata content is not mixed with the color of the background.
+
+
+
ForeignObject with SVG background
+
Set a background color for the SVG.
+ Create a foreignObject element containing a simple xhtml file.
+ Apply a mix-blend-mode other than normal on the marker.
+
The foreignObject content is not mixed with the color of the background.
+
+
+
+
+
mix-blend-mode with SVG groups
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Group of overlapping elements with SVG background
+
Set a background color for the SVG.
+ Create a group element containing two overlapping rect elements, each filled with a different solid color.
+ Apply a mix-blend-mode other than normal on the group.
+
The group is mixed as a whole with the color of the background.
+
+
+
+
+
mix-blend-mode with isolated groups
+
Refers to the following assertion in the spec:
+ By default, every element must create a non-isolated group.
+ However, certain operations in SVG will create isolated groups.
+ If one of the following features is used, the group must become isolated:
+
+
opacity
+
filters
+
3D transforms (2D transforms must NOT cause isolation)
+
blending
+
masking
+
+
+
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Blending two elements in an isolated group
+
Set a background color for the SVG.
+ Create a group element containing two overlapping rect elements, each filled with a different solid color.
+ Apply opacity less than 1 on the group and a mix-blend-mode other than normal on the second rect.
+
Only the intersection of the rect elements should mix.
+
+
+
Blending in a group with opacity
+
Set a background color for the SVG.
+ Create a group element containing a rect element filled with a different solid color.
+ Apply opacity less than 1 on the group and a mix-blend-mode other than normal on the rect.
+
The rect will not mix with the content behind it.
+
+
+
Blending in a group with filter
+
Set a background color for the SVG.
+ Create a group element containing a rect element filled with a different solid color.
+ Apply a filter on the group and a mix-blend-mode other than normal on the rect.
+
The rect will not mix with the content behind it.
+
+
+
Blending in a group with 2D transform
+
Set a background color for the SVG.
+ Create a group element containing a rect element filled with a different solid color.
+ Apply a transform on the group and a mix-blend-mode other than normal on the rect.
+
The rect will mix with the content behind it.
+
+
+
Blending in a group with 3D transform
+
Set a background color for the SVG.
+ Create a group element containing a rect element filled with a different solid color.
+ Apply a 3d transform on the group and a mix-blend-mode other than normal on the rect.
+
The rect will not mix with the content behind it.
+
+
+
Blending in a group with a mask
+
Set a background color for the SVG.
+ Create a group element containing a rect element filled with a different solid color.
+ Apply a mask on the group and a mix-blend-mode other than normal on the rect.
+
The rect will not mix with the content behind it.
+
+
+
Blending in a group with mix-blend-mode
+
Set a background color for the SVG.
+ Create a group element containing a rect element filled with a different solid color.
+ Apply a mix-blend-mode other than normal on the group and a mix-blend-mode other than normal on the rect.
+
The rect will not mix with the content behind it.
+
+
+
+
+
Other test cases for SVG
+
+
+
Blend with element having opacity
+
Set a background color for the SVG.
+ Create a rect element filled with a different solid color.
+ Apply opacity less than 1 and a mix-blend-mode other than normal on the rect.
+
The rect will mix with the content behind it.
+
+
+
Blend with element having stroke
+
Set a background color for the SVG.
+ Create a rect element filled with a different solid color.
+ Apply a stroke and a mix-blend-mode other than normal on the rect.
+
The rect will mix with the content behind it.
+
+
+
Blend with element having stroke-opacity
+
Set a background color for the SVG.
+ Create a rect element filled with a different solid color.
+ Apply a stroke, stroke-opacity less than 1 and a mix-blend-mode other than normal on the rect.
+
The rect will mix with the content behind it.
+
+
+
Blend with element having stroke-dasharray
+
Set a background color for the SVG.
+ Create a rect element filled with a different solid color.
+ Apply a stroke-dasharray and a mix-blend-mode other than normal on the rect.
+
The rect will mix with the content behind it.
+
+
+
Blend with element having transform
+
Set a background color for the SVG.
+ Create an image element. Apply a transform (any combination of translate, rotate, scale, skew) and a mix-blend-mode other than normal on the image.
+
The image will mix with the content behind it.
+
+
+
Blend with SVG having viewbox and preserveAspectRatio set
+
Set a background color for the SVG, as well as viewbox and preserveAspectRatio.
+ Create a rect element filled with a different solid color and apply a mix-blend-mode other than normal on it.
+
The rect will mix with the content behind it.
+
+
+
Blend with an element having color-profile set
+
Set a background color for the SVG.
+ Create an image element. Apply a color-profile (sRGB, for example) and a mix-blend-mode other than normal on the image.
+
The image will mix with the content behind it.
+
+
+
Blend with an element having overflow
+
Set a background color for the SVG.
+ Create an image larger than the SVG.
+ Apply overflow (visible, hidden, scroll) and a mix-blend-mode other than normal on the image.
+
The image will mix with the content behind it.
+
+
+
Blend with an element having clip-path
+
Set a background color for the SVG.
+ Create an image element. Apply a clip-path and a mix-blend-mode other than normal on the image.
+
The image will mix with the content behind it.
+
+
+
Blend with an element having a mask
+
Set a background color for the SVG.
+ Create an image element.
+ Apply a mask and a mix-blend-mode other than normal on the image.
+
The image will mix with the content behind it.
+
+
+
Blend with an element having a filter
+
Set a background color for the SVG.
+ Create an image element.
+ Apply a filter and a mix-blend-mode other than normal on the image.
+
The image will mix with the content behind it.
+
+
+
Blend with an animated element
+
Set a background color for the SVG.
+ Create a rect element filled with a different solid color.
+ Apply an animateTransform and a mix-blend-mode other than normal on the rect.
+
The rect will mix with the content behind it.
+
+
+
Set blending from an SVG script element
+
Set a background color for the SVG.
+ Create a rect element and fill it with a solid color.
+ Apply a mix-blend-mode (other than normal) on it from an svg script element.
+
The rect will mix with the content behind it.
+
+
+
+
+
+
Test cases for background-blend-mode
+
+
Blending between the background layers and the background color for an element with background-blend-mode
+
Refers to the following assertion in the spec: Each background layer must blend with the element's background layer that are below it and the element's background color.
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Images with different formats
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-blend-mode other than normal
+
+ Tests should be created for <image> with different formats such as PNG, JPEG or SVG
+
+
The content of the background-image is mixed with the color of the background-color
+
+
+
Gradient and background color
+
+ Element with
+
+
background-image set to an <gradient>
+
background-color set to a fully opaque color
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+
+
+
Image and gradient
+
+ Element with
+
+
background-image set to an <image> on top of a <gradient>
+
background-blend-mode other than normal
+
+
+
The content of the <image> is mixed with the content of the <gradient>
+
+
+
+
Gradient and image
+
Element with
+
+
background-image set to a <gradient> on top of an <image>
+
background-blend-mode other than normal
+
+
+
The content of the <image> is mixed with the content of the <gradient>
+
+
+
Two gradients
+
Element with
+
+
background-image set to a <gradient> on top of another <gradient>
+
background-blend-mode other than normal
+
+
The content of the two gradients is mixed
+
+
+
Two images
+
Element with
+
+
background-image set to an <image> on top of another <image>
+
background-blend-mode other than normal
+
+
The content of the two images is mixed
+
+
+
Image and background color with transparency
+
Element with
+
+
background-image set to an <image> with transparency(e.g. PNG images)
+
background-color set to a transparent color
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+
+
+
Cross-fade image and gradient
+
Element with
+
+
background-image set to a cross-fade() image on top of a <gradient>
+
background-blend-mode other than normal
+
+
+
The content of the cross-faded image is mixed with the content of the <gradient>
+
+
+
SVG image and background color
+
Element with
+
+
background-image set to a data URI for an SVG image
+
background-color set to a fully opaque color
+
background-blend-mode other than normal
+
+
+
The content of the image is mixed with the color of the background
+
+
+
Animated gif image and background color
+
Element with
+
+
background-image set to an animated gif image
+
background-color set to a fully opaque color
+
background-blend-mode other than normal
+
+
+
The content of the image is mixed with the color of the background
+
+
+
Set background-blend-mode from JavaScript
+
Element with
+
+
background-image set to a gradient
+
background-color set to a fully opaque color
+
no background-blend-mode explicitly specified
+ From JavaScript, set the background-blend-mode property to a value other than normal.
+
+
+
The content of the gradient is mixed with the color of the background
+
+
+
background-blend-mode on element with 3D transform
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-blend-mode other than normal
+
transform set to a 3D function like rotateX, rotateY or translateZ
+
+
+
The content of the image is mixed with the color of the background
+
+
+
+
+
Background layers do not blend with content outside the background (or behind the element)
+
Refers to the following assertion in the spec: Background layer must not blend with the content that is behind the element instead they must act as if they are rendered into an isolated group.
+
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
One background layer
+
Element with
+
+
background-image set to an <image>
+
background-blend-mode other than normal
+
+
+
The background-image is not mixed with anything outside the element
+
+
+
Two elements
+
2 elements required: a parent element with a child.
+ Each one with the following properties:
+
+
background-color set to a fully opaque color
+
background-blend-mode other than normal
+
+
No blending between the background colors of the two elements
+
+
+
Parent and child with background-blend-mode
+
2 elements required: a parent element with a child
+ Parent properties:
+
+
background-color set to a fully opaque color
+
background-blend-mode other than normal
+
+ Child properties:
+
+
background-image set to an <image>
+
background-blend-mode other than normal
+
+
The content of the image from the child element does not mixes with the background color from the parent element
+
+
+
+
+
background-blend-mode list values apply to the corresponding background layer
+
Refers to the following assertion in the spec: The ‘background-blend-mode’ list must be applied in the same order as ‘background-image’[CSS3BG]. This means that the first element in the list will apply to the layer that is on top.
+
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Different blend modes applied between layers
+
Element with
+
+
background-image set to an <image-list> containing three images: (e.g. I1, I2 and I3 )
+
background-blend-mode set to different blendmode for every image: (e.g. multiply, difference, screen)
+
+
The content of the three images is correctly mixed
+ (multiply for I1, difference for I2 and screen for I3)
+
+
+
+
+
+
background-blend-mode list values are repeated if the list is shorter than the background layer list
+
Refers to the following assertion in the spec: If a property doesn't have enough comma-separated values to match the number of layers, the UA must calculate its used value by repeating the list of values until there are enough.
+
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Blend mode list repeat
+
Element with
+
+
background-image set to an <image-list> containing three images
+
background-blend-mode set to two different blendmode values
+
+
The unspecified blend modes should be obtained by repeating the blend mode list from the beginning
+
+
+
+
+
The default background-blend-mode value for the background shorthand is 'normal'
+
Refers to the following assertion in the spec: If the ‘background’ [CSS3BG] shorthand is used, the ‘background-blend-mode’ property for that element must be reset to its initial value.
+
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Default blend mode for 'background' shorthand
+
Element with
+
+
background property set to an image and a color
+
No value explicitly set for background-blend-mode
+
+
The computed value of background-blend-mode is 'normal'
+
+
+
+
+
+
background-blend-mode for an element with background-position
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
background-position percentage
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-position specified in percentage, such as 50% 50%
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+ The background-image is correctly positioned
+
+
+
+
+
+
background-blend-mode for an element with background-size
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Background size defined in pixels
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-size specified in pixels
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+ The background-image has the correct size
+
+
+
+
Background size defined in percentage (second phase)
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-size specified in percentage
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+ The background-image has the correct size
+
+
+
+
Background size cover
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-size set to cover
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+ The background-image has the correct size
+
+
+
+
Background size contain
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-size set to contain
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+ The background-image has the correct size
+
+
+
+
+
+
background-blend-mode for an element with background-repeat
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
background-repeat set to no-repeat
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-repeat set to no-repeat
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+ The background-image is not repeated
+
+
+
+
background-repeat set to space
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-repeat set to space
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+
+
+
+
background-repeat set to round
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-repeat set to round
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+
+
+
+
+
+
background-blend-mode for an element with background-clip
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
background-clip set to padding-box
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-clip set to padding-box
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+ No background is drawn below the border (background extends to the outside edge of the padding)
+
+
+
+
background-clip set to content-box
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-clip set to content-box
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+ The background is painted within (clipped to) the content box
+
+
+
+
+
+
background-blend-mode for an element with background-origin
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
background-origin set to border-box
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-origin set to border-box
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+ The background extends to the outside edge of the border (but underneath the border in z-ordering)
+
+
+
+
background-origin set to content-box
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-origin set to content-box
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+ The background is painted within (clipped to) the content box
+
+
+
+
+
+
background-blend-mode for an element with background-attachement
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
background-attachment set to fixed
+
Element with
+
+
background-image set to an <image>
+
background-color set to a fully opaque color
+
background-attachment set to fixed
+
background-blend-mode other than normal
+
+
+
The content of the background-image is mixed with the color of the background-color
+ The background image will not scroll with its containing element, instead remaining stationary within the viewport
+
+
+
+
2 background images with background-attachment set to fixed, scroll
+
Element with
+
+
background-image set to 2 <image>(s)
+
background-attachment set to fixed, scroll
+
background-blend-mode other than normal
+
+
+
The background images will be mixed when they overlap while scrolling
+
+
+
+
+
+
+
Test cases for isolation
+
+
An element with isolation:isolate creates a stacking context
+
Refers to the following assertion in the spec: For CSS, setting ‘isolation’ to ‘isolate’ will turn the element into a stacking context [CSS21].
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Isolation isolate
+
Have an element with isolation set to isolate
+
The element creates a stacking context.
+
+
+
+
+
An element with isolation:isolate creates an isolated group for blended children
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Isolation of blended child which overflows
+
3 elements required:
+ [P],
+ [IN-P] and
+ [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed)
+ [IN-P] - Intermediate child element between the parent [P] and the child [B]
+ This element has isolation:isolate set.
+ [B] - element with mix-blend-mode other than normal
+ The blending element [B] has content that lies outside the parent element.
+
+
+ The color of the child element [B] mixes with the color of the intermediate element [IN-P], where they overlap.
+ The area of the child element outside of the intermediate parent element does not mix with the color of the parent element [P], or of the body.
+
+
+
+
Isolation on intermediate element with transparent pixels
+
3 elements required:
+ [P],
+ [IN-P] and
+ [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed); the element background-color is other than transparent
+ [IN-P] - Intermediate child element between the parent [P] and the child [B]
+ The intermediate element has text content, default value for background-color and isolation:isolate set
+ [B] - element with mix-blend-mode other than normal
+
+ The color of the child element [B] mixes with the color of the intermediate element [IN-P], where they overlap.
+ There is no blending between the color of the parent element [P] and the color of the blended element [B].
+
+
+
+
Isolate inside a stacking context created by a 3d transform
+
+ 3 elements required:
+ [P],
+ [IN-P] and
+ [B]
+ [P] - parent element with a 3D transform applied
+ [IN-P] - Intermediate child element between the parent [P] and the child [B]
+ The intermediate element has isolation:isolate set
+ [B] - element with mix-blend-mode other than normal
+
+
+ The color of the child element [B] mixes with the color of the intermediate element [IN-P], where they overlap.
+ There is no blending between the color of the parent element [P] and the color of the blended element [B].
+
+
+
+
+
+
An element with isolation:auto set does not change the elements existing stacking context behavior
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Isolation auto
+
Have an element with isolation explicitly set to auto, and no other style that would create a stacking context
+
The element does not create a stacking context - the computed value of its z-index is value auto
+
+
+
Stacking context not affected by isolation
+
2 elements required:
+ [P] and
+ [B]
+ [P] - parent element with a property that creates a stacking context (e.g. position:fixed); This element has isolation explicitly set to auto
+ [B] - element with mix-blend-mode other than normal
+ The blending element [B] has content that lies outside the parent element.
+ Set the background-color of the body to a value other than default
+
+
The color of the parent element mixes with the color of the child element.
+ The area of the child element outside of the parent element doesn't mix with the color of the body.
+ In other words, setting the isolation to auto does not affect the creation of a stacking context by other properties.
+
+
+
+
+
+
+
Test cases for isolation in SVG
+
+
In SVG, an element with isolation:isolate creates an isolated group for blended children
+
Refers to the following assertion in the spec: In SVG, this defines whether an element is isolated or not.
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Blending in an isolated group
+
Set a background color for the SVG.
+ Create a group element containing a rect element filled with a different solid color.
+ Apply isolation:isolate on the group and a mix-blend-mode other than normal on the rect.
+
The rect will not mix with the content behind it.
+
+
+
Blending two elements in an isolated group
+
Set a background color for the SVG.
+ Create a group element containing two overlapping rect elements, each filled with a different solid color.
+ Apply isolation:isolate on the group and a mix-blend-mode other than normal on the second rect.
+
Only the intersection of the rect elements should mix.
+
+
+
Blending in an isolated group with 2D transform
+
Set a background color for the SVG.
+ Create a group element containing a rect element filled with a different solid color.
+ Apply isolation:isolate and 2D transform on the group and a mix-blend-mode other than normal on the rect.
+
The rect will not mix with the content behind it.
+
+
+
Set isolation on an element from JavaScript
+
Set a background color for the SVG.
+ Create a rect element and fill it with a solid color and a mix-blend-mode other than normal.
+ Apply isolation:isolate on it from JavaScript.
+
The rect will not mix with the content behind it.
+
+
+
+
+
In SVG, an element with isolation:auto set does not change the rendering behaviour
+
+
+
Test name
+
Elements and styles
+
Expected result
+
+
+
Blending a group with isolation:auto
+
Set a background color for the SVG.
+ Create a group element containing a rect element filled with a different solid color.
+ Apply isolation:auto on the group and a mix-blend-mode other than normal on the rect.
+
The element will mix with the content behind it.
+
+
+
Blending in a group with opacity
+
Set a background color for the SVG.
+ Create a group element containing a rect element filled with a different solid color.
+ Apply opacity less than 1 and isolation:auto on the group and a mix-blend-mode other than normal on the rect.
+
The rect will not mix with the content behind it.
+
+
+
+
+
+
diff --git a/benchmarks/data/wpt/weighted/toBlob.png.html b/benchmarks/data/wpt/weighted/toBlob.png.html
new file mode 100644
index 00000000..1533bfdb
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/toBlob.png.html
@@ -0,0 +1,17 @@
+
+Canvas test: toBlob.png
+
+
+
+
+
diff --git a/benchmarks/data/wpt/weighted/will-change-abspos-cb-001.html b/benchmarks/data/wpt/weighted/will-change-abspos-cb-001.html
new file mode 100644
index 00000000..d59e4433
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/will-change-abspos-cb-001.html
@@ -0,0 +1,30 @@
+
+
+CSS Test: will-change: position turns an element in an abspos containing block.
+
+
+
+
+
+
+
+
')
- el = doc[1][0]
- assert el.get("class") == "a"
-
-
-def test_maintain_duplicate_attribute_order():
- # This is here because we impl it in parser and not tokenizer
- p = HTMLParser()
- attrs = [(unichr(x), i) for i, x in enumerate(range(ord('a'), ord('z')))]
- token = {'name': 'html',
- 'selfClosing': False,
- 'selfClosingAcknowledged': False,
- 'type': tokenTypes["StartTag"],
- 'data': attrs + [('a', len(attrs))]}
- out = p.normalizeToken(token)
- attr_order = list(out["data"].keys())
- assert attr_order == [x for x, i in attrs]
-
-
def test_debug_log():
parser = HTMLParser(debug=True)
parser.parse("
a
bd
e")
diff --git a/html5lib/tests/test_tokenizer2.py b/html5lib/tests/test_tokenizer2.py
new file mode 100644
index 00000000..158d847a
--- /dev/null
+++ b/html5lib/tests/test_tokenizer2.py
@@ -0,0 +1,66 @@
+from __future__ import absolute_import, division, unicode_literals
+
+import io
+
+from six import unichr, text_type
+
+from html5lib._tokenizer import HTMLTokenizer
+from html5lib.constants import tokenTypes
+
+
+def ignore_parse_errors(toks):
+ for tok in toks:
+ if tok['type'] != tokenTypes['ParseError']:
+ yield tok
+
+
+def test_maintain_attribute_order():
+ # generate loads to maximize the chance a hash-based mutation will occur
+ attrs = [(unichr(x), text_type(i)) for i, x in enumerate(range(ord('a'), ord('z')))]
+ stream = io.StringIO("")
+
+ toks = HTMLTokenizer(stream)
+ out = list(ignore_parse_errors(toks))
+
+ assert len(out) == 1
+ assert out[0]['type'] == tokenTypes['StartTag']
+
+ attrs_tok = out[0]['data']
+ assert len(attrs_tok) == len(attrs)
+
+ for (in_name, in_value), (out_name, out_value) in zip(attrs, attrs_tok.items()):
+ assert in_name == out_name
+ assert in_value == out_value
+
+
+def test_duplicate_attribute():
+ stream = io.StringIO("")
+
+ toks = HTMLTokenizer(stream)
+ out = list(ignore_parse_errors(toks))
+
+ assert len(out) == 1
+ assert out[0]['type'] == tokenTypes['StartTag']
+
+ attrs_tok = out[0]['data']
+ assert len(attrs_tok) == 1
+ assert list(attrs_tok.items()) == [('a', '1')]
+
+
+def test_maintain_duplicate_attribute_order():
+ # generate loads to maximize the chance a hash-based mutation will occur
+ attrs = [(unichr(x), text_type(i)) for i, x in enumerate(range(ord('a'), ord('z')))]
+ stream = io.StringIO("")
+
+ toks = HTMLTokenizer(stream)
+ out = list(ignore_parse_errors(toks))
+
+ assert len(out) == 1
+ assert out[0]['type'] == tokenTypes['StartTag']
+
+ attrs_tok = out[0]['data']
+ assert len(attrs_tok) == len(attrs)
+
+ for (in_name, in_value), (out_name, out_value) in zip(attrs, attrs_tok.items()):
+ assert in_name == out_name
+ assert in_value == out_value
diff --git a/html5lib/tests/test_treewalkers.py b/html5lib/tests/test_treewalkers.py
index 81d5132c..4a21b479 100644
--- a/html5lib/tests/test_treewalkers.py
+++ b/html5lib/tests/test_treewalkers.py
@@ -1,7 +1,9 @@
from __future__ import absolute_import, division, unicode_literals
import itertools
+import sys
+from six import unichr, text_type
import pytest
try:
@@ -135,3 +137,65 @@ def test_lxml_xml():
output = Lint(walker(lxmltree))
assert list(output) == expected
+
+
+@pytest.mark.parametrize("treeName",
+ [pytest.param(treeName, marks=[getattr(pytest.mark, treeName),
+ pytest.mark.skipif(sys.version_info < (3, 7), reason="dict order undef")])
+ for treeName in sorted(treeTypes.keys())])
+def test_maintain_attribute_order(treeName):
+ treeAPIs = treeTypes[treeName]
+ if treeAPIs is None:
+ pytest.skip("Treebuilder not loaded")
+
+ # generate loads to maximize the chance a hash-based mutation will occur
+ attrs = [(unichr(x), text_type(i)) for i, x in enumerate(range(ord('a'), ord('z')))]
+ data = ""
+
+ parser = html5parser.HTMLParser(tree=treeAPIs["builder"])
+ document = parser.parseFragment(data)
+
+ document = treeAPIs.get("adapter", lambda x: x)(document)
+ output = list(Lint(treeAPIs["walker"](document)))
+
+ assert len(output) == 2
+ assert output[0]['type'] == 'StartTag'
+ assert output[1]['type'] == "EndTag"
+
+ attrs_out = output[0]['data']
+ assert len(attrs) == len(attrs_out)
+
+ for (in_name, in_value), (out_name, out_value) in zip(attrs, attrs_out.items()):
+ assert (None, in_name) == out_name
+ assert in_value == out_value
+
+
+@pytest.mark.parametrize("treeName",
+ [pytest.param(treeName, marks=[getattr(pytest.mark, treeName),
+ pytest.mark.skipif(sys.version_info < (3, 7), reason="dict order undef")])
+ for treeName in sorted(treeTypes.keys())])
+def test_maintain_attribute_order_adjusted(treeName):
+ treeAPIs = treeTypes[treeName]
+ if treeAPIs is None:
+ pytest.skip("Treebuilder not loaded")
+
+ # generate loads to maximize the chance a hash-based mutation will occur
+ data = "